YaxuSong

代码的世界我不懂.

  • 主页
  • 随笔
  • JAVA
  • Linux
  • ATLASSIAN
  • 简历
搜索 友请链接 关于我

YaxuSong

代码的世界我不懂.

  • 主页
  • 随笔
  • JAVA
  • Linux
  • ATLASSIAN
  • 简历

Atlassian产品使用单点登陆-SSO

2017-12-13

一、配置JIRA

1.修改/atlassian-jira/WEB-INF/classes/seraph-config.xml

<!--注释以下节点-->
<!--<authenticator class="com.atlassian.jira.security.login.JiraSeraphAuthenticator"/>-->

<!--取消注释以下节点-->
<authenticator class="com.atlassian.jira.security.login.SSOSeraphAuthenticator"/>

2.复制/client/conf/crowd.properties到<JIRA-INSTALLATION/atlassian-jira/WEB-INF/classes下.

编辑/atlassian-jira/WEB-INF/classes/crowd.properties

Key Value
application.name jira The application name must match the name that you specified when you defined the application in Crowd (see Step 1 above).
application.password The password must match the one that you specified when you defined the application in Crowd (see Step 1 above).
crowd.base.url eg. (http://localhost:8095/crowd/)If your Crowd server’s port is configured differently from the default (i.e. 8095), set it accordingly.crowd.base.url must be the same URL used to access Crowd in your Browser.
session.validationinterval Set to 0, if you want authentication checks to occur on each request. Otherwise set to the number of minutes between request to validate if the user is logged in or out of the Crowd SSO server. Setting this value to 1 or higher will increase the performance of Crowd’s integration.
以上信息几乎在文件里边都有,只需修改对应的取值即可

二、配置bitbucket

添加/shared/bitbucket.properties

plugin.auth-crowd.sso.enabled=true

一些可选的参数:

key value description
plugin.auth-crowd.sso.enabled false Whether SSO support should be enabled or not. Regardless of this setting SSO authentication will only be activated when the system is connected to a Crowd directory that is configured for SSO.
plugin.auth-crowd.sso.config.ttl 15 The auth plugin caches the SSO configuration that is retrieved from the remote Crowd server. This setting controls the time to live of that cache.This value is in minutes.
plugin.auth-crowd.sso.config.error.wait 1 If an error occurs while retrieving the SSO configuration from the remote Crowd server, the system will wait this long before retrying. The wait time between subsequent attempts is incremented exponentially (1s -> 1.5s -> 2.3s -> 3.4s, etc). The wait time is capped at the configured TTL.This value is in seconds.
plugin.auth-crowd.sso.http.max.connections 20 The maximum number of HTTP connections in the connection pool for communication with the Crowd server.
plugin.auth-crowd.sso.http.proxy.host The name of the proxy server used to transport SOAP traffic to the Crowd server.
plugin.auth-crowd.sso.http.proxy.port The connection port of the proxy server (must be specified if a proxy host is specified).
plugin.auth-crowd.sso.http.proxy.username The username used to authenticate with the proxy server (if the proxy server requires authentication).
plugin.auth-crowd.sso.http.proxy.password The password used to authenticate with the proxy server (if the proxy server requires authentication).
plugin.auth-crowd.sso.http.timeout 5000 The HTTP connection timeout used for communication with the Crowd server. A value of zero indicates that there is no connection timeout.This value is in milliseconds.
plugin.auth-crowd.sso.socket.timeout 20000 The socket timeout. You may wish to override the default value if the latency to the Crowd server is high.This value is in milliseconds.
plugin.auth-crowd.sso.session.validationinterval 3 The number of minutes to cache authentication validation in the session. If this value is set to 0, each HTTP request will be authenticated with the Crowd server.
plugin.auth-crowd.sso.session.lastvalidation atl.crowd.sso.lastvalidation The session key to use when storing a Date value of the user’s last authentication.
plugin.auth-crowd.sso.session.tokenkey atl.crowd.sso.tokenkey The session key to use when storing a String value of the user’s authentication token.

三、配置confluence

1.修改/confluence/WEB-INF/classes/seraph-config.xml

<!--注释以下节点-->
<!-- <authenticator class="com.atlassian.confluence.user.ConfluenceAuthenticator"/> -->

<!--取消注释以下节点-->
<authenticator class="com.atlassian.confluence.user.ConfluenceCrowdSSOAuthenticator"/>

2.复制/client/conf/crowd.properties到<CONFLUENCE-INSTALLATION/confluence/WEB-INF/classes下.

编辑/confluence/WEB-INF/classes/crowd.properties

Key Value
application.name confluence The application name must match the name that you specified when you defined the application in Crowd (see Step 1 above).
application.password The password must match the one that you specified when you defined the application in Crowd (see Step 1 above).
crowd.base.url eg. (http://localhost:8095/crowd/)If your Crowd server’s port is configured differently from the default (i.e. 8095), set it accordingly.crowd.base.url must be the same URL used to access Crowd in your Browser.
session.validationinterval Set to 0, if you want authentication checks to occur on each request. Otherwise set to the number of minutes between request to validate if the user is logged in or out of the Crowd SSO server. Setting this value to 1 or higher will increase the performance of Crowd’s integration.
以上信息几乎在文件里边都有,只需修改对应的取值即可

四、配置bamboo

1.编辑\webapp\WEB-INF\classes\seraph-config.xml

<!--注释以下节点-->
<!--<authenticator class="com.atlassian.bamboo.user.authentication.BambooAuthenticator"/>-->

<!--取消注释以下节点-->
<authenticator class="com.atlassian.crowd.integration.seraph.v25.BambooAuthenticator"/>

五、配置fisheye

修改FISHEYE_INST/config.xml

<config>
...
    <security allow-anon="false" allow-cru-anon="false">
        <built-in>
                <signup enabled="true"/>
        </built-in>
        <crowd sso-enabled="true"/>
        <admins>
                <system-admins>
                        <group>confluence-users</group>
                </system-admins>
        </admins>
        <avatar><disabled/></avatar>
        <emailVisibility/>
    </security>
...
</config>
//以上内容只需添加<crowd sso-enabled="true"/>

六、配置jiraServiceDesk

请参考 一、配置JIRA
  • ATLASSIAN

展开全文 >>

Atlassian产品安装环境准备-数据库(1):MySQL

2017-12-11

一、JIRA使用MySQL数据库

1、 编辑my.cnf

  • 设置default storage engine为InnoDB:
    [mysqld]
    …
    default-storage-engine=INNODB
    …
  • 确认max_allowed_packet最少为256M:
    [mysqld]
    …
    max_allowed_packet=256M
    …
  • 确认innodb_log_file_size至少为256M当MySQL的版本是5.5或5.5以下时:
    [mysqld]
    …
    innodb_log_file_size=256M
    …
  • 确保sql_mode的值不是NO_AUTO_VALUE_ON_ZERO
    // remove this if it exists
    sql_mode = NO_AUTO_VALUE_ON_ZERO

    2、 创建数据库

    CREATE DATABASE jiradb CHARACTER SET utf8 COLLATE utf8_bin;

3、 为数据库创建相应的用户

MySQL5.5,MySQL 5.6和MySQL 5.7.0到MySQL 5.7.5的语法:

CREATE USER 'confluenceUser'@'%' IDENTIFIED BY 'Confluence@123';

GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,ALTER,INDEX on <JIRADB>.* TO '<USERNAME>'@'<JIRA_SERVER_HOSTNAME>' IDENTIFIED BY '<PASSWORD>';
flush privileges;

MySQL5.7.6及以上必须包括REFERENCES的权限:

GRANT SELECT,INSERT,UPDATE,DELETE,CREATE,DROP,REFERENCES,ALTER,INDEX on <JIRADB>.* TO '<USERNAME>'@'<JIRA_SERVER_HOSTNAME>' IDENTIFIED BY '<PASSWORD>';
flush privileges;

//确认数据库用户权限
SHOW GRANTS FOR <USERNAME>@<JIRA_SERVER_HOSTNAME>;

4、 重启数据库

  • Windows:使用系统服务管理器重启。
  • Linux: /etc/init.d/mysqld stop’ 或者 ‘/etc/init.d/mysql stop’ 或者 ‘service mysqld stop’.
    -启动时将stop换成start.
  • ATLASSIAN

展开全文 >>

《Thinking in java》读书笔记(23)

2017-11-24

4.8 switch

switch有时也被划归为一种选择语句。根据证书表达式的值,switch语句可以从一系列代码中选出一段去执行。它的格式如下:

1
2
3
4
5
6
7
8
9
switch(integer-selector){
case integral-value1: statement ;break;
case integral-value2: statement ;break;
case integral-value3: statement ;break;
case integral-value4: statement ;break;
case integral-value5: statement ;break;
//...
default:statement;
}

more >>
  • 读书笔记
  • Java

展开全文 >>

《Thinking in java》读书笔记(22)

2017-11-24

4.4 Foreach语法

Java SE5引入了一种新的更加简洁的for语法用于数组和容器,也就是foreach语法,表示不必创建int变量去对由访问项构成的序列进行计数,foreach将自动产生每一项。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
package demo;
/**
*
* @ClassName testForeach
* @author yaxuSong
* @date 2017年11月24日 下午3:01:31
* @Description TODO
*/
public class testForeach {
public static void main(String[] args) {
for(char c : "Hello Java!".toCharArray())
{
System.out.println(c);
}
}
}

more >>
  • 读书笔记
  • Java

展开全文 >>

Java工程师成神之路

2017-11-24

这是我在微信公众号上看到的一篇文章,关于Java学习的一个文章,我觉得写的特别好,所以留下来,作为自己学习的指导.

一、基础篇

1.1 JVM

1.1.1. Java内存模型,Java内存管理,Java堆和栈,垃圾回收
http://www.jcp.org/en/jsr/detail?id=133
http://ifeve.com/jmm-faq/
1.1.2. 了解JVM各种参数及调优

1.1.3. 学习使用Java工具
jps, jstack, jmap, jconsole, jinfo, jhat, javap, …
http://kenai.com/projects/btrace
http://www.crashub.org/
https://github.com/taobao/TProfiler
https://github.com/CSUG/HouseMD
http://wiki.cyclopsgroup.org/jmxterm
https://github.com/jlusdy/TBJMap
1.1.4. 学习Java诊断工具
http://www.eclipse.org/mat/
http://visualvm.java.net/oqlhelp.html
1.1.5. 自己编写各种outofmemory,stackoverflow程序
HeapOutOfMemory
Young OutOfMemory
MethodArea OutOfMemory
ConstantPool OutOfMemory
DirectMemory OutOfMemory
Stack OutOfMemory
Stack OverFlow
1.1.6. 使用工具尝试解决以下问题,并写下总结
当一个Java程序响应很慢时如何查找问题
当一个Java程序频繁FullGC时如何解决问题,如何查看垃圾回收日志
当一个Java应用发生OutOfMemory时该如何解决,年轻代、年老代、永久代解决办法不同,导致原因也不同
1.1.7. 参考资料
http://docs.oracle.com/javase/specs/jvms/se7/html/
http://www.cs.umd.edu/~pugh/java/memoryModel/
http://gee.cs.oswego.edu/dl/jmm/cookbook.html
1.2. Java基础知识

1.2.1. 阅读源代码
java.lang.String
java.lang.Integer
java.lang.Long
java.lang.Enum
java.math.BigDecimal
java.lang.ThreadLocal
java.lang.ClassLoader & java.net.URLClassLoader
java.util.ArrayList & java.util.LinkedList
java.util.HashMap & java.util.LinkedHashMap & java.util.TreeMap
java.util.HashSet & java.util.LinkedHashSet & java.util.TreeSet
1.2.2. 熟悉Java中各种变量类型
1.2.3. 熟悉Java String的使用,熟悉String的各种函数
1.2.4. 熟悉Java中各种关键字
1.2.5. 学会使用List,Map,Stack,Queue,Set
上述数据结构的遍历
上述数据结构的使用场景
Java实现对Array/List排序
java.uti.Arrays.sort()
java.util.Collections.sort()
Java实现对List去重
Java实现对List去重,并且需要保留数据原始的出现顺序
Java实现最近最少使用cache,用LinkedHashMap
1.2.6. Java IO&Java NIO,并学会使用
java.io.
java.nio.
nio和reactor设计模式
文件编码,字符集
1.2.7. Java反射与javassist
反射与工厂模式
java.lang.reflect.
1.2.8. Java序列化
java.io. Serializable
什么是序列化,为什么序列化
序列化与单例模式
google序列化protobuf
1.2.9. 虚引用,弱引用,软引用
java.lang.ref.
实验这些引用的回收
1.2.10. 熟悉Java系统属性
java.util.Properties
1.2.11. 熟悉Annotation用法
java.lang.annotation.
1.2.12. JMS
javax.jms.
1.2.13. JMX
java.lang.management.
javax.management.
1.2.14. 泛型和继承,泛型和擦除
1.2.15. 自动拆箱装箱与字节码
1.2.16. 实现Callback
1.2.17. java.lang.Void类使用
1.2.18. Java Agent,premain函数
java.lang.instrument
1.2.19. 单元测试
Junit,http://junit.org/
Jmockit,https://code.google.com/p/jmockit/
djUnit,http://works.dgic.co.jp/djunit/
1.2.20. Java实现通过正则表达式提取一段文本中的电子邮件,并将@替换为#输出
java.lang.util.regex.
1.2.21. 学习使用常用的Java工具库
commons.lang, commons.…
guava-libraries
netty
1.2.22. 什么是API&SPI
http://en.wikipedia.org/wiki/Application_programming_interface
http://en.wikipedia.org/wiki/Service_provider_interface
1.2.23. 参考资料
JDK src.zip 源代码
http://openjdk.java.net/
http://commons.apache.org/
https://code.google.com/p/guava-libraries/
http://netty.io/
http://stackoverflow.com/questions/2954372/difference-between-spi-and-api
http://stackoverflow.com/questions/11404230/how-to-implement-the-api-spi-pattern-in-java
1.3. Java并发编程

1.3.1. 阅读源代码,并学会使用

java.lang.Thread
java.lang.Runnable
java.util.concurrent.Callable
java.util.concurrent.locks.ReentrantLock
java.util.concurrent.locks.ReentrantReadWriteLock
java.util.concurrent.atomic.Atomic*
java.util.concurrent.Semaphore
java.util.concurrent.CountDownLatch
java.util.concurrent.CyclicBarrier
java.util.concurrent.ConcurrentHashMap
java.util.concurrent.Executors
1.3.2. 学习使用线程池,自己设计线程池需要注意什么
1.3.3. 锁
什么是锁,锁的种类有哪些,每种锁有什么特点,适用场景是什么
在并发编程中锁的意义是什么
1.3.4. synchronized的作用是什么,synchronized和lock
1.3.5. sleep和wait
1.3.6. wait和notify
1.3.7. 写一个死锁的程序
1.3.8. 什么是守护线程,守护线程和非守护线程的区别以及用法
1.3.9. volatile关键字的理解
C++ volatile关键字和Java volatile关键字
happens-before语义
编译器指令重排和CPU指令重排
http://en.wikipedia.org/wiki/Memory_ordering
http://en.wikipedia.org/wiki/Volatile_variable
http://preshing.com/20130702/the-happens-before-relation/
1.3.10. 以下代码是不是线程安全?为什么?如果为count加上volatile修饰是否能够做到线程安全?你觉得该怎么做是线程安全的?
public class Sample {
private static int count = 0;
public static void increment() {
count++;
}
}
1.3.11. 解释一下下面两段代码的差别
// 代码1
public class Sample {
private static int count = 0;
synchronized public static void increment() {
count++;
}
}

// 代码2
public class Sample {
private static AtomicInteger count = new AtomicInteger(0);
public static void increment() {
count.getAndIncrement();
}
}
1.3.12. 参考资料
http://book.douban.com/subject/10484692/
http://www.intel.com/content/www/us/en/processors/architectures-software-developer-manuals.html
二、 进阶篇

2.1. Java底层知识

2.1.1. 学习了解字节码、class文件格式
http://en.wikipedia.org/wiki/Java_class_file
http://en.wikipedia.org/wiki/Java_bytecode
http://en.wikipedia.org/wiki/Java_bytecode_instruction_listings
http://www.csg.ci.i.u-tokyo.ac.jp/~chiba/javassist/
http://asm.ow2.org/
2.1.2. 写一个程序要求实现javap的功能(手工完成,不借助ASM等工具)
如Java源代码:
public static void main(String[] args) {
int i = 0;
i += 1;
i *= 1;
System.out.println(i);
}
编译后读取class文件输出以下代码:
public static void main(java.lang.String[]);
Code:
Stack=2, Locals=2, Args_size=1
0: iconst_0
1: istore_1
2: iinc 1, 1
5: iload_1
6: iconst_1
7: imul
8: istore_1
9: getstatic #2; //Field java/lang/System.out:Ljava/io/PrintStream;
12: iload_1
13: invokevirtual #3; //Method java/io/PrintStream.println:(I)V
16: return
LineNumberTable:
line 4: 0
line 5: 2
line 6: 5
line 7: 9
line 8: 16
2.1.3. CPU缓存,L1,L2,L3和伪共享
http://duartes.org/gustavo/blog/post/intel-cpu-caches/
http://mechanical-sympathy.blogspot.com/2011/07/false-sharing.html
2.1.4. 什么是尾递归
2.1.5. 熟悉位运算
用位运算实现加、减、乘、除、取余
2.1.6. 参考资料
http://book.douban.com/subject/1138768/
http://book.douban.com/subject/6522893/
http://en.wikipedia.org/wiki/Java_class_file
http://en.wikipedia.org/wiki/Java_bytecode
http://en.wikipedia.org/wiki/Java_bytecode_instruction_listings
2.2. 设计模式

2.2.1. 实现AOP
CGLIB和InvocationHandler的区别
http://cglib.sourceforge.net/
动态代理模式
Javassist实现AOP
http://www.csg.ci.i.u-tokyo.ac.jp/~chiba/javassist/
ASM实现AOP
http://asm.ow2.org/
2.2.2. 使用模板方法设计模式和策略设计模式实现IOC
2.2.3. 不用synchronized和lock,实现线程安全的单例模式
2.2.4. nio和reactor设计模式
2.2.5. 参考资料
http://asm.ow2.org/
http://cglib.sourceforge.net/
http://www.javassist.org/
2.3. 网络编程知识
2.3.1. Java RMI,Socket,HttpClient
2.3.2. 用Java写一个简单的静态文件的HTTP服务器
实现客户端缓存功能,支持返回304
实现可并发下载一个文件
使用线程池处理客户端请求
使用nio处理客户端请求
支持简单的rewrite规则
上述功能在实现的时候需要满足“开闭原则”
2.3.3. 了解nginx和apache服务器的特性并搭建一个对应的服务器
http://nginx.org/
http://httpd.apache.org/
2.3.4. 用Java实现FTP、SMTP协议
2.3.5. 什么是CDN?如果实现?DNS起到什么作用?
搭建一个DNS服务器
搭建一个 Squid 或 Apache Traffic Server 服务器
http://www.squid-cache.org/
http://trafficserver.apache.org/
http://en.wikipedia.org/wiki/Domain_Name_System
2.3.6. 参考资料
http://www.ietf.org/rfc/rfc2616.txt
http://tools.ietf.org/rfc/rfc5321.txt
http://en.wikipedia.org/wiki/Open/closed_principle
2.4. 框架知识
spring,spring mvc,阅读主要源码
ibatis,阅读主要源码
用spring和ibatis搭建java server
2.5. 应用服务器知识
熟悉使用jboss,https://www.jboss.org/overview/
熟悉使用tomcat,http://tomcat.apache.org/
熟悉使用jetty,http://www.eclipse.org/jetty/
三、 高级篇

3.1. 编译原理知识

3.1.1. 用Java实现以下表达式解析并返回结果(语法和Oracle中的select sysdate-1 from dual类似)
sysdate
sysdate - 1
sysdate - 1/24
sysdate - 1/(12*2)
3.1.2. 实现对一个List通过DSL筛选
QList> mapList = new QList>;
mapList.add({“name”: “hatter test”});
mapList.add({“id”: -1,”name”: “hatter test”});
mapList.add({“id”: 0, “name”: “hatter test”});
mapList.add({“id”: 1, “name”: “test test”});
mapList.add({“id”: 2, “name”: “hatter test”});
mapList.add({“id”: 3, “name”: “test hatter”});
mapList.query(“id is not null and id > 0 and name like ‘%hatter%’”);
要求返回列表中匹配的对象,即最后两个对象;

3.1.3. 用Java实现以下程序(语法和变量作用域处理都和JavaScript类似):
代码:
var a = 1;
var b = 2;
var c = function() {
var a = 3;
println(a);
println(b);
};
c();
println(a);
println(b);
输出:
3
2
1
2
3.1.4. 参考资料
http://en.wikipedia.org/wiki/Abstract_syntax_tree
https://javacc.java.net/
http://www.antlr.org/
3.2. 操作系统知识
Ubuntu
Centos
使用linux,熟悉shell脚本
3.3. 数据存储知识

3.3.1. 关系型数据库
MySQL
如何看执行计划
如何搭建MySQL主备
binlog是什么
Derby,H2,PostgreSQL
SQLite
3.3.2. NoSQL
Cache
Redis
Memcached
Leveldb
Bigtable
HBase
Cassandra
Mongodb
图数据库
neo4j
3.3.3. 参考资料
http://db-engines.com/en/ranking
http://redis.io/
https://code.google.com/p/leveldb/
http://hbase.apache.org/
http://cassandra.apache.org/
http://www.mongodb.org/
http://www.neo4j.org/
3.4. 大数据知识

3.4.1. Zookeeper,在linux上部署zk
3.4.2. Solr,Lucene,ElasticSearch
在linux上部署solr,solrcloud,,新增、删除、查询索引
3.4.3. Storm,流式计算,了解Spark,S4
在linux上部署storm,用zookeeper做协调,运行storm hello world,local和remote模式运行调试storm topology。
3.4.4. Hadoop,离线计算
Hdfs:部署NameNode,SecondaryNameNode,DataNode,上传文件、打开文件、更改文件、删除文件
MapReduce:部署JobTracker,TaskTracker,编写mr job
Hive:部署hive,书写hive sql,得到结果
Presto:类hive,不过比hive快,非常值得学习
3.4.5. 分布式日志收集flume,kafka,logstash
3.4.6. 数据挖掘,mahout
3.4.7. 参考资料
http://zookeeper.apache.org/
https://lucene.apache.org/solr/
https://github.com/nathanmarz/storm/wiki
http://hadoop.apache.org/
http://prestodb.io/
http://flume.apache.org/,http://logstash.net/,http://kafka.apache.org/
http://mahout.apache.org/
3.5. 网络安全知识

3.5.1. 什么是DES、AES
3.5.2. 什么是RSA、DSA
3.5.3. 什么是MD5,SHA1
3.5.4. 什么是SSL、TLS,为什么HTTPS相对比较安全
3.5.5. 什么是中间人攻击、如果避免中间人攻击
3.5.6. 什么是DOS、DDOS、CC攻击
3.5.7. 什么是CSRF攻击
3.5.8. 什么是CSS攻击
3.5.9. 什么是SQL注入攻击
3.5.10. 什么是Hash碰撞拒绝服务攻击
3.5.11. 了解并学习下面几种增强安全的技术

http://www.openauthentication.org/
HOTP http://www.ietf.org/rfc/rfc4226.txt
TOTP http://tools.ietf.org/rfc/rfc6238.txt
OCRA http://tools.ietf.org/rfc/rfc6287.txt
http://en.wikipedia.org/wiki/Salt_(cryptography)
3.5.12. 用openssl签一个证书部署到apache或nginx
3.5.13. 参考资料
http://en.wikipedia.org/wiki/Cryptographic_hash_function
http://en.wikipedia.org/wiki/Block_cipher
http://en.wikipedia.org/wiki/Public-key_cryptography
http://en.wikipedia.org/wiki/Transport_Layer_Security
http://www.openssl.org/
https://code.google.com/p/google-authenticator/
四、 扩展篇

4.1. 相关知识

4.1.1. 云计算,分布式,高可用,可扩展
4.1.2. 虚拟化
https://linuxcontainers.org/
http://www.linux-kvm.org/page/Main_Page
http://www.xenproject.org/
https://www.docker.io/
4.1.3. 监控
http://www.nagios.org/
http://ganglia.info/
4.1.4. 负载均衡
http://www.linuxvirtualserver.org/
4.1.5. 学习使用git
https://github.com/
https://git.oschina.net/
4.1.6. 学习使用maven
http://maven.apache.org/
4.1.7. 学习使用gradle
http://www.gradle.org/
4.1.8. 学习一个小语种语言
Groovy
Scala
LISP, Common LISP, Schema, Clojure
R
Julia
Lua
Ruby
4.1.9. 尝试了解编码的本质

了解以下概念
ASCII, ISO-8859-1
GB2312, GBK, GB18030
Unicode, UTF-8
不使用 String.getBytes() 等其他工具类/函数完成下面功能

public static void main(String[] args) throws IOException {
String str = “Hello, 我们是中国人。”;
byte[] utf8Bytes = toUTF8Bytes(str);
FileOutputStream fos = new FileOutputStream(“f.txt”);
fos.write(utf8Bytes);
fos.close();
}
public static byte[] toUTF8Bytes(String str) {
return null; // TODO
}

想一下上面的程序能不能写一个转GBK的?
写个程序自动判断一个文件是哪种编码
4.1.10. 尝试了解时间的本质
时区 & 冬令时、夏令时
http://en.wikipedia.org/wiki/Time_zone
ftp://ftp.iana.org/tz/data/asia
http://zh.wikipedia.org/wiki/%E4%B8%AD%E5%9C%8B%E6%99%82%E5%8D%80
闰年
http://en.wikipedia.org/wiki/Leap_year
闰秒
ftp://ftp.iana.org/tz/data/leapseconds
System.currentTimeMillis() 返回的时间是什么
4.1.11. 参考资料
http://git-scm.com/
http://en.wikipedia.org/wiki/UTF-8
http://www.iana.org/time-zones
4.2. 扩展学习

4.2.1. JavaScript知识
4.2.1.1. 什么是prototype
修改代码,使程序输出“1 3 5”:
http://jsfiddle.net/Ts7Fk/
4.2.1.2. 什么是闭包
看一下这段代码,并解释一下为什么按Button1时没有alert出“This is button: 1”,如何修改:
http://jsfiddle.net/FDPj3/1/
4.2.1.3. 了解并学习一个JS框架
jQuery
ExtJS
ArgularJS
4.2.1.4. 写一个Greasemonkey插件

http://en.wikipedia.org/wiki/Greasemonkey
4.2.1.5. 学习node.js
http://nodejs.org/
4.2.2. 学习html5
ArgularJS,https://docs.angularjs.org/api
4.2.3. 参考资料
http://www.ecmascript.org/
http://jsfiddle.net/
http://jsbin.com/
http://runjs.cn/
http://userscripts.org/
五、 推荐书籍
《深入Java虚拟机》
《深入理解Java虚拟机》
《Effective Java》
《七周七语言》
《七周七数据》
《Hadoop技术内幕》
《Hbase In Action》
《Mahout In Action》
《这就是搜索引擎》
《Solr In Action》
《深入分析Java Web技术内幕》
《大型网站技术架构》
《高性能MySQL》
《算法导论》
《计算机程序设计艺术》
《代码大全》
《JavaScript权威指南》

  • Java

展开全文 >>

say something to myself

2017-11-23

好久没有写博客了,大概是没有时间,大概是懒吧。
在自己看来,时间还是很多的,要看你去做什么事情。

这段时间,自己经历了很多,出去玩了一趟,请了几天的假,然后换了一家公司,在上家公司辞职后,这家公司上班前,发生了很多有趣的事情。
more >>

  • 随笔

展开全文 >>

怀念那些我喜欢的经典

2017-10-25

昨晚一时兴起,特别想看之前看过的一部电影,然后就下载了下来,当时已经是1点多了,然后还是禁不住看了起来,还是被故事中的人物和情节所感动。
希望自己也能够拥有那样的爱情吧。

  • 随笔

展开全文 >>

《Thinking in java》读书笔记(21)

2017-10-24

第四章 控制执行流程

就像有知觉的生物一样,程序必须在执行过程中控制它的世界,并做出选择。在Java中,你要使用执行控制语句来做出选择。
Java使用了C的所有流程控制语句,所以如果读者以前用过C或者C++编程,那么应该非常熟悉了,大多数过程编程语言都具有某些形式的控制语句,它们通常在各种语言间是交迭的。在Java中,涉及的关键字包括if-else、while、do-while、for、return、break以及选择语句switch。然而Java并不支持goto.

4.1true和false

所有的语句都利用表达式的真假来决定是否执行。
在Java中不支持使用数字作为布尔值来使用。虽然在C和C++中是允许的。

4.2if-else

if-else语句是控制程序流程中最基本的形式。其中else是可选的,所以可按下述两种形式来使用if:
if(Bollean-expression)
statement
或
if(Bollean-expression)
statement
else
statement

其中布尔表达式必须产生布尔值。如下判断数大数小的例子:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
package alljavaexample;
/**
*
* @ClassName IfElse
* @author yaxuSong
* @date 2017年10月24日 下午3:40:08
* @Description TODO
*/
public class IfElse {
public static int test(int num1,int num2) {
if(num1>=num2)
return num1;
else
return num2;
}
public static void main(String[] args) {
System.out.println(test(10,5));
System.out.println(test(6,11));
}
}

output:

10
11

4.3迭代

while、do-while和for用来控制循环,有时将他们划分为迭代语句(iteration statement)。语句会重复执行,直到起控制作用的布尔表达式(Booleanexperssion)得到“假”的结果为止。
while循环到的格式如下:
while(Boolean-experssion)
statement

4.3.1 do-while

do-while的格式如下:
do
statement
while(Boolean-experssion);
while和do-while语句的区别就是do-while中的语句至少会执行一次。即便第一次表达式的值false,也会先执行一次。

4.3.2 for

for循环可能是最经常使用的迭代形式,这种在第一次迭代之前要进行初始化。随后,它会进行条件测试,而且在每一次迭代结束时,进行某种形式的“步进”,for循环格式如下:
for(initialization;Boolean-experssion;step)
statement
初始化(initialization)表达式、布尔表达式(Boolean-experssion),或者步进(step)运算,都可以为空。每次迭代前会测试布尔表达式。若为true才会执行。

4.3.3 逗号操作符

逗号操作符的作用是用来分隔函数的不同参数。
Java中唯一用到逗号操作符的地方就是for循环的控制表达式。在控制表达式的初始化和步进控制部分,可以使用一系列由逗号分隔的语句;而且那些语句会独立执行。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
package alljavaexample;
/**
*
* @ClassName CommaOperator
* @author yaxuSong
* @date 2017年10月24日 下午4:15:57
* @Description TODO
*/
public class CommaOperator {
public static void main(String[] args) {
for (int i = 1, j = i + 10; i < 5; i++, j = i * 2) {
System.out.println("i = " + i + " j = " + j);
}
}
}

输出:

i = 1 j = 11
i = 2 j = 4
i = 3 j = 6
i = 4 j = 8

  • 读书笔记
  • Java

展开全文 >>

国庆快乐

2017-10-01

国庆快乐,马上就要回家的心情还是很激动的!

当然也少不了中秋快乐。

  • 随笔

展开全文 >>

《Thinking in java》读书笔记(20)

2017-09-30

3.14使用操作符时常犯的错误

使用操作符时一个常犯的错误就是,即使对表达式如何计算结果不确定,也不愿意使用括号。
这个问题在Java中仍然存在。
在C和C++中,一个特别常见的错误

1
2
3
while(x = y){
//do something
}

很明显是“==”而不是“=”,但是因为C和C++的机制,如果y是一个非0值m,这会造成一个死循环。而在java中它期望的是一个boolean结果,而int不会转成boolean,自然会报错的。

3.15 类型转换器操作符

类型转换(cast)的原意就是“模型铸造”。在适当得时候,Java会将一种数据类型自动转换成另一种。例如,假设我们为浮点变量赋以一个整数值,编译器会自动将int转为float。类型转换允许我们显式地进行这种类型转换,或者在不能自动进行转换的时候进行强制转换。

1
2
int i = 200;
long lon= (long)i;

在C和C++中,类型转换有时会让人头痛。但在Java中,类型转换则是一种比较安全的操作。然而,如果执行一种名为窄化转换(narrowing conversion)的操作(也就是说,将能容纳更多信息的数据类型转换成无法 容纳那么多信息的类型),就会可能面临信息丢失的危险。此时编译器会强制我们去进行类型转换。而对于扩展转换(widening conversion),则不必进行显示转换。
Java允许我们把任何基本数据类型转换成别的基本数据类型,布尔类型除外。

3.15.1 截尾和舍入

在执行窄化转换时,必须注意截尾与舍入的问题。例如浮点型转整型。
29.7转化成int,结果不是30而是29。
因为float或者double转为整型时进行的是截尾,如果想要进行舍入需要使用java.lang.Math中的round()方法。

3.15.2 提升

如果对基本数据类型执行算术运算或按位运算,大家会发现,只要类型比int小(char、byte、short),那么在运算前,这些值会自动转换成int。最终的结果也是int。如果想把结果赋值给小的类型,就必须使用类型转换。

3.16 Java没有sizeof

在C和C++中,sizeof()操作符可以告诉我们数据项分配的字节数。在C和C++中,需要使用sizeof()的最大原因是为了“移植”。不同的数据类型在不同的机器上可能会有不同的大小。
Java不需要sizeof()是因为所有数据类型在所有机器的大小都是相同的。我们不必考虑移植问题——————因为它已经被设计在语言中了。

3.17 操作符小结

能够对布尔型值进行的运算非常有限。我们只能赋予它true和false值,并测试它为真还是为假,而不能将布尔值相加,或对布尔值进行其它运算。
我们要在类型的提升上多多关注。

3.18 总结

这一张花了很多时间,主要是自己的时间不是很多,希望自己能在2018年之前看完一半吧。

  • 读书笔记
  • Java

展开全文 >>

« Prev123456…9Next »
© 2019 YaxuSong
Hexo Theme Yilia by Litten
  • 搜索
  • 友请链接
  • 关于我

tag:

  • 随笔
  • ATLASSIAN
  • 读书笔记
  • Java
  • Linux
  • JAVA

    缺失模块。
    1、请确保node版本大于6.2
    2、在博客根目录(注意不是yilia根目录)执行以下命令:
    npm i hexo-generator-json-content --save

    3、在根目录_config.yml里添加配置:

      jsonContent:
        meta: false
        pages: false
        posts:
          title: true
          date: true
          path: true
          text: false
          raw: false
          content: false
          slug: false
          updated: false
          comments: false
          link: false
          permalink: false
          excerpt: false
          categories: false
          tags: true
    

  • jira-managing-project-permissions

    2018-08-22

    #读书笔记

  • SpringBoot使用Swagger2

    2018-06-10

    #JAVA

  • Redisson 的介绍与使用

    2018-06-04

    #JAVA

  • Spring Boot 关乎java程序员

    2018-05-16

    #JAVA

  • Kafka在SpringBoot 2.0中的整合-1

    2018-05-07

    #JAVA

  • 微信公众号后台在SpringBoot2.0中的实现(上)

    2018-05-01

    #JAVA

  • Kafka在SpringBoot 2.0中的整合

    2018-04-23

    #Java

  • Redis在SpringBoot 2.0中的整合

    2018-04-18

    #Java

  • 好久都没有发表博客了

    2018-04-18

    #随笔

  • 使用Xtrabackup备份InnoDB(MySQL)

    2018-03-06

    #Linux

  • LinuxMySQL的安装(3)

    2018-02-08

    #Linux

  • Linux下MySQL主从数据库的安装与配置

    2018-02-08

    #Linux

  • Linux离线安装Nginx

    2018-02-07

    #Linux

  • Linux定时任务备份mysql和数据

    2018-02-06

    #ATLASSIAN#Linux

  • 回家过年前一周

    2018-02-05

    #随笔

  • LinuxMySQL的安装(2)

    2018-02-02

    #ATLASSIAN#Linux

  • Atlassian产品设置JVM

    2018-01-31

    #读书笔记

  • Crucible安装

    2018-01-29

    #读书笔记

  • 当璀璨速朽成尘埃

    2018-01-25

    #读书笔记

  • JIRA高于7.2版本导出xlsx格式的EXCEL文件

    2018-01-22

    #ATLASSIAN

  • Linux离线git的安装

    2018-01-17

    #Linux

  • 终于复活啦

    2018-01-15

    #随笔

  • LinuxMySQL的安装(1)

    2018-01-15

    #ATLASSIAN#Linux

  • Bitbucket的安装

    2018-01-15

    #ATLASSIAN

  • JIRA修改license

    2018-01-11

    #ATLASSIAN

  • rsync的使用与配置

    2018-01-09

    #Linux

  • 最近电脑重装了,导致电脑里边的博客全没了

    2018-01-08

    #随笔

  • JIRA安装

    2017-12-15

    #ATLASSIAN

  • Nginx代理Atlassian产品(2):Use Domain:*.mydomain.com

    2017-12-13

    #ATLASSIAN

  • Nginx代理Atlassian产品(1):Use Domain:www.mydomain.com/*

    2017-12-13

    #ATLASSIAN

  • Atlassian产品使用单点登陆-SSO

    2017-12-13

    #ATLASSIAN

  • Atlassian产品安装环境准备-数据库(1):MySQL

    2017-12-11

    #ATLASSIAN

  • 《Thinking in java》读书笔记(23)

    2017-11-24

    #读书笔记#Java

  • 《Thinking in java》读书笔记(22)

    2017-11-24

    #读书笔记#Java

  • Java工程师成神之路

    2017-11-24

    #Java

  • say something to myself

    2017-11-23

    #随笔

  • 怀念那些我喜欢的经典

    2017-10-25

    #随笔

  • 《Thinking in java》读书笔记(21)

    2017-10-24

    #读书笔记#Java

  • 国庆快乐

    2017-10-01

    #随笔

  • 《Thinking in java》读书笔记(20)

    2017-09-30

    #读书笔记#Java

  • 《Thinking in java》读书笔记(19)

    2017-09-27

    #读书笔记#Java

  • 《Thinking in java》读书笔记(18)

    2017-09-18

    #读书笔记#Java

  • 《Thinking in java》读书笔记(17)

    2017-09-18

    #读书笔记#Java

  • 《Thinking in java》读书笔记(16)

    2017-09-11

    #读书笔记#Java

  • 回忆总是会使我泪流满面

    2017-09-05

    #随笔

  • 迷茫

    2017-09-01

    #随笔

  • 一个人的情人节

    2017-08-28

    #随笔

  • 没有什么事情是办不到的,只怕你没法战胜自己

    2017-08-23

    #随笔

  • 感觉最近有点霉运

    2017-08-07

    #随笔

  • 确实感觉还是有点小累的

    2017-08-04

    #随笔

  • 难受

    2017-08-01

    #随笔

  • 《Thinking in java》读书笔记(15)

    2017-08-01

    #读书笔记#Java

  • 感觉慢慢的步入正轨了

    2017-07-31

    #随笔

  • 每次写标题都很困难啊

    2017-07-24

    #随笔

  • 2017.07.18记

    2017-07-18

    #随笔

  • 《Thinking in java》读书笔记(14)

    2017-07-14

    #读书笔记#Java

  • 停更ThinKing in Java的读书笔记

    2017-07-11

    #读书笔记

  • 做决定看似简单其实很难

    2017-07-05

    #随笔

  • 《Thinking-in-java》读书笔记(13)

    2017-06-23

    #读书笔记#Java

  • 《Thinking in java》读书笔记(12)

    2017-06-22

    #读书笔记#Java

  • 《Thinking in java》读书笔记(11)

    2017-06-22

    #读书笔记#Java

  • 《Thinking in java》读书笔记(10)

    2017-06-21

    #读书笔记#Java

  • 《Thinking in java》读书笔记(9)

    2017-06-17

    #读书笔记#Java

  • 《Thinking in java》读书笔记(8)

    2017-06-15

    #读书笔记

  • 《Thinking in java》读书笔记(7)

    2017-06-14

    #读书笔记

  • 一些想法

    2017-06-14

    #随笔

  • 《Thinking in java》读书笔记(6)

    2017-06-12

    #读书笔记#Java

  • 《Thinking in java》读书笔记(5)

    2017-06-10

    #读书笔记#Java

  • 《Thinking in java》读书笔记(4)

    2017-06-07

    #读书笔记#Java

  • 决定

    2017-06-07

    #随笔

  • 《Thinking in java》读书笔记(3)

    2017-06-06

    #读书笔记#Java

  • 听完这首歌忘记所有的一切

    2017-06-05

    #随笔

  • 《Thinking in java》读书笔记(2)

    2017-06-04

    #读书笔记#Java

  • 《Thinking in java》读书笔记(1)

    2017-06-01

    #读书笔记#Java

  • 六一儿童节快乐

    2017-06-01

    #随笔

  • The mood may be better

    2017-05-31

    #随笔

  • NoTitle

    2017-05-27

    #随笔

  • 努力吧,少年

    2017-05-26

    #随笔

  • 想念那些日子

    2017-05-08

    #随笔

  • 此时此刻的心情

    2017-05-04

    #随笔

  • welcome

    2017-05-03

    #随笔

  • Leno's Blog
  • GitHub
  • CSDN博客
  • 国内站点(同站)
宋亚旭,就读于内蒙古大学软件工程专业,在大学期间就很喜欢写代码,现在在一家公司做Java后端工作。