`
收藏列表
标题 标签 来源
启动脚本
#!/bin/sh

JAVA_HOME="/usr/local/jdk1.7.0_17/"

RUNNING_USER=root
APP_HOME=/workspace/totem
APP_MAINCLASS=org.x.server.app.AppServer

CLASSPATH=$APP_HOME
for i in "$APP_HOME"/lib/*.jar; do
CLASSPATH="$CLASSPATH":"$i"
done

JAVA_OPTS="-server -ms2048m -mx2048m -Xmn256m -Djava.awt.headless=true -XX:MaxPermSize=128m"

psid=0

checkpid()
{
javaps=`$JAVA_HOME/bin/jps -l | grep $APP_MAINCLASS`
if [ -n "$javaps" ]; then
psid=`echo $javaps | awk '{print $1}'`
else
psid=0
fi
echo "psid=$psid"
}


start()
{
checkpid
if [ $psid -ne 0 ]; then
echo "================================"
echo "warn: $APP_MAINCLASS already started! (pid=$psid)"
echo "================================"
else
echo -n "Starting $APP_MAINCLASS ..."
JAVA_CMD="nohup java $JAVA_OPTS -classpath $CLASSPATH $APP_MAINCLASS > appserver.log 2>&1 </dev/null &"
su -c "$JAVA_CMD"
checkpid
if [ $psid -ne 0 ]; then
echo "(pid=$psid) [OK]"
else
echo "[Failed]"
fi
fi
}

stop()
{
checkpid
if [ $psid -ne 0 ]; then
echo -n "Stopping $APP_MAINCLASS ...(pid=$psid) "
kill -9 $psid
if [ $? -eq 0 ]; then
echo "[OK]"
else
echo "[Failed]"
fi
checkpid
if [ $psid -ne 0 ]; then
stop
fi
else
echo "================================"
echo "warn: $APP_MAINCLASS is not running"
echo "================================"
fi
}

status()
{
checkpid
if [ $psid -ne 0 ];  then
echo "$APP_MAINCLASS is running! (pid=$psid)"
else
echo "$APP_MAINCLASS is not running"
fi
}

info()
{
echo "System Information:"
echo "****************************"
echo `head -n 1 /etc/issue`
echo `uname -a`
echo
echo "JAVA_HOME=$JAVA_HOME"
echo `$JAVA_HOME/bin/java -version`
echo
echo "APP_HOME=$APP_HOME"
echo "APP_MAINCLASS=$APP_MAINCLASS"
echo "****************************"
}

case "$1" in
'start')
start
;;
'stop')
stop
;;
'restart')
stop
start
;;
'status')
status
;;
'info')
info
;;
*)
echo "Usage: $0 {start|stop|restart|status|info}"
exit 1
esac
exit 0
String、 String.split()和StringTokenizer和indexOf()的比较
	public static String[] split(String s, String delimiter){
		if (s == null) {
			return null;
		}
		int delimiterLength;
		int stringLength = s.length();
		if (delimiter == null || (delimiterLength = delimiter.length()) == 0){
			return new String[] {s};
		}

		// a two pass solution is used because a one pass solution would
		// require the possible resizing and copying of memory structures
		// In the worst case it would have to be resized n times with each
		// resize having a O(n) copy leading to an O(n^2) algorithm.

		int count;
		int start;
		int end;

		// Scan s and count the tokens.
		count = 0;
		start = 0;
		while((end = s.indexOf(delimiter, start)) != -1){
			count++;
			start = end + delimiterLength;
		}
		count++;

		// allocate an array to return the tokens,
		// we now know how big it should be
		String[] result = new String[count];

		// Scan s again, but this time pick out the tokens
		count = 0;
		start = 0;
		while((end = s.indexOf(delimiter, start)) != -1){
			result[count] = (s.substring(start, end));
			count++;
			start = end + delimiterLength;
		}
		end = stringLength;
		result[count] = s.substring(start, end);

		return (result);
	}
单例模式经典 设计模式 探索设计模式之六——单例模式
/**
 * 能应对大多数情况的单例实现
 */
public class SingletonKerrigan implements Serializable {
 
    private static class SingletonHolder {
        /**
         * 单例对象实例
         */
        static final SingletonKerrigan INSTANCE = new SingletonKerrigan();
    }
 
    public static SingletonKerrigan getInstance() {
        return SingletonHolder.INSTANCE;
    }
 
    /**
     * private的构造函数用于避免外界直接使用new来实例化对象
     */
    private SingletonKerrigan() {
    }
 
    /**
     * readResolve方法应对单例对象被序列化时候
     */
    private Object readResolve() {
        return getInstance();
    }
}
jquery 自动渲染 jquery jQuery EasyUI动态添加控件或者ajax加载页面后不能自动渲染问题的解决方法
(function($){
	$.parser = {
		auto: true,
		plugins:['linkbutton','menu','menubutton','splitbutton','layout',
				 'tree','window','dialog','datagrid',
				 'combobox','combotree','numberbox','validatebox',
				 'calendar','datebox','panel','tabs','accordion'
		],
		parse: function(context){
			if ($.parser.auto){
				for(var i=0; i<$.parser.plugins.length; i++){
					(function(){
						var name = $.parser.plugins[i];
						var r = $('.easyui-' + name, context);
						if (r.length){
							if (r[name]){
								r[name]();
							} else if (window.easyloader){
								easyloader.load(name, function(){
									r[name]();
								})
							}
						}
					})();
				}
			}
		}
	};
	$(function(){
		$.parser.parse();
	});
})(jQuery);
Global site tag (gtag.js) - Google Analytics