亚洲性色AV日韩在线观看,97se亚洲综合在线,亚洲AV蜜桃永久无码精品http://m.tkk7.com/sdyjmc/category/17746.html單飛zh-cnFri, 05 Apr 2019 08:19:54 GMTFri, 05 Apr 2019 08:19:54 GMT60微同商城使用私庫解決打包編譯問題http://m.tkk7.com/sdyjmc/archive/2019/04/04/433704.html單飛單飛Thu, 04 Apr 2019 01:36:00 GMThttp://m.tkk7.com/sdyjmc/archive/2019/04/04/433704.htmlhttp://m.tkk7.com/sdyjmc/comments/433704.htmlhttp://m.tkk7.com/sdyjmc/archive/2019/04/04/433704.html#Feedback0http://m.tkk7.com/sdyjmc/comments/commentRss/433704.htmlhttp://m.tkk7.com/sdyjmc/services/trackbacks/433704.html微同商城 搭建私服
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:
deploy (default-deploy) on project platform: Failed to deploy artifacts: Could n
ot find artifact com.platform:platform:pom:1.0.0 in releases(http://nkf:
8081/repository/xiaowang-host/) -> [Help 1]

    <modelVersion>4.0.0</modelVersion>
    <groupId>com.platform</groupId>
    <artifactId>platform</artifactId>
    <version>1.0.0</version>
    <packaging>pom</packaging>
    <description>platform</description>
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:
deploy (default-deploy) on project platform: Deployment failed: repository eleme
nt was not specified in the POM inside distributionManagement element or in -Dal
tDeploymentRepository=id::layout::url parameter -> [Help 1]
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:
deploy (default-deploy) on project platform-mp: Failed to deploy artifacts: Coul
d not find artifact com.platform:platform-mp:jar:1.0.0 in releases (http:
//nkf:8081/repository/xiaowang-host/) -> [Help 1]
搭建私服
D:\public\mvn\apache-maven-3.2.2\conf\settings.xml
<mirror>
        <id>nexus-aliyun</id>
        <mirrorOf>central</mirrorOf>
        <name>Nexus aliyun</name>
        <url>http://maven.aliyun.com/nexus/content/groups/public</url>
    </mirror>
阿里倉庫改為中央倉庫

N:\JetBrains\platform\pom.xml

解決上傳第二方jar文件和下載第二方jar文件問題:

<distributionManagement>
      <repository>
        <id>releases.xiaowang</id>
        <name>Releases</name>
        <url>http://server2:8081/repository/xiaowang-host/</url>
      </repository>
      <snapshotRepository>
        <id>snapshots.xiaowang</id>
        <name>Snapshot</name>
        <url>http://server2:8081/repository/xiaowang-host/</url>
      </snapshotRepository>
    </distributionManagement>
    <repositories>
        <repository>
          <id>releases.xiaowang</id>
          <url>http://server2:8081/repository/xiaowang-host/</url>
          <releases>
            <enabled>true</enabled>
            <updatePolicy>always</updatePolicy>
          </releases>
          <snapshots>
            <enabled>true</enabled>
            <updatePolicy>always</updatePolicy>
          </snapshots>
        </repository>
    </repositories>


其它pom.xml文件無需做改變,就可以使用mvn deploy 上傳和下載第二方jar文件
然后使用mvn package 就沒有問題了。


單飛 2019-04-04 09:36 發表評論
]]>
hornetq could not obtain connection to any of these urls localhost 1099 jbosshttp://m.tkk7.com/sdyjmc/archive/2015/08/05/426607.html單飛單飛Wed, 05 Aug 2015 01:15:00 GMThttp://m.tkk7.com/sdyjmc/archive/2015/08/05/426607.htmlhttp://m.tkk7.com/sdyjmc/comments/426607.htmlhttp://m.tkk7.com/sdyjmc/archive/2015/08/05/426607.html#Feedback2http://m.tkk7.com/sdyjmc/comments/commentRss/426607.htmlhttp://m.tkk7.com/sdyjmc/services/trackbacks/426607.htmlcould not obtain connection to any of these urls localhost 1099 jboss
修改
run.bat

-Djnp.host=172.16.0.128 -Dhornetq.remoting.netty.host=172.16.0.23
-Djava.rmi.server.hostname=172.16.0.23修改后:

REM set CLUSTER_PROPS="-Djnp.port=1099 -Djnp.rmiPort=1098 -Djnp.host=172.16.0.23 -Dhornetq.remoting.netty.host=172.16.0.23 -Dhornetq.remoting.netty.port=5445"
set JVM_ARGS=%CLUSTER_PROPS% -XX:+UseParallelGC  -XX:+AggressiveOpts -XX:+UseFastAccessorMethods -Xms512M -Xmx1024M -Dhornetq.config.dir=%CONFIG_DIR%  -Djava.util.logging.config.file=%CONFIG_DIR%\logging.properties -Djava.library.path=. -Djava.rmi.server.hostname=172.16.0.23
run.sh

export CLUSTER_PROPS="-Djnp.port=6099 -Djnp.rmiPort=6098 -Djnp.host=server23 -Dhornetq.remoting.netty.host=server23 -Dhornetq.remoting.netty.port=6445"
export JVM_ARGS="$CLUSTER_PROPS  -Xms512M -Xmx4096M -Dhornetq.config.dir=$CONFIG_DIR -Djava.util.logging.config.file=$CONFIG_DIR/logging.properties -Djava.library.path=. -Dcom.sun.management.jmxre
mote -Dcom.sun.management.jmxremote.port=4000 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=server23"


單飛 2015-08-05 09:15 發表評論
]]>
linux 環境下tomcat啟動失敗問題http://m.tkk7.com/sdyjmc/archive/2014/12/04/421044.html單飛單飛Thu, 04 Dec 2014 08:37:00 GMThttp://m.tkk7.com/sdyjmc/archive/2014/12/04/421044.htmlhttp://m.tkk7.com/sdyjmc/comments/421044.htmlhttp://m.tkk7.com/sdyjmc/archive/2014/12/04/421044.html#Feedback0http://m.tkk7.com/sdyjmc/comments/commentRss/421044.htmlhttp://m.tkk7.com/sdyjmc/services/trackbacks/421044.html
嚴重: Error deploying web application directory news
java.lang.ClassFormatError: com/sun/faces/config/ConfigureListener : illegal LocalVariableTable missing: LVT
        at java.lang.ClassLoader.defineClass1(Native Method)
        at java.lang.ClassLoader.defineClassCond(ClassLoader.java:631)
        at java.lang.ClassLoader.defineClass(ClassLoader.java:615)
        at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:141)
        at org.apache.catalina.loader.WebappClassLoader.findClassInternal(WebappClassLoader.java:1814)
        at org.apache.catalina.loader.WebappClassLoader.findClass(WebappClassLoader.java:868)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1321)
        at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1200)
        at org.apache.catalina.startup.WebAnnotationSet.loadClassAnnotation(WebAnnotationSet.java:144)
        at org.apache.catalina.startup.WebAnnotationSet.loadApplicationListenerAnnotations(WebAnnotationSet.java:72)
        at org.apache.catalina.startup.WebAnnotationSet.loadApplicationAnnotations(WebAnnotationSet.java:55)
        at org.apache.catalina.startup.ContextConfig.applicationAnnotationsConfig(ContextConfig.java:296)
        at org.apache.catalina.startup.ContextConfig.start(ContextConfig.java:1061)
        at org.apache.catalina.startup.ContextConfig.lifecycleEvent(ContextConfig.java:260)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
        at org.apache.catalina.core.StandardContext.start(StandardContext.java:4237)
        at org.apache.catalina.core.ContainerBase.addChildInternal(ContainerBase.java:759)
        at org.apache.catalina.core.ContainerBase.addChild(ContainerBase.java:739)
        at org.apache.catalina.core.StandardHost.addChild(StandardHost.java:524)
        at org.apache.catalina.startup.HostConfig.deployDirectory(HostConfig.java:919)
        at org.apache.catalina.startup.HostConfig.deployDirectories(HostConfig.java:882)
        at org.apache.catalina.startup.HostConfig.deployApps(HostConfig.java:491)
        at org.apache.catalina.startup.HostConfig.start(HostConfig.java:1137)
        at org.apache.catalina.startup.HostConfig.lifecycleEvent(HostConfig.java:310)
        at org.apache.catalina.util.LifecycleSupport.fireLifecycleEvent(LifecycleSupport.java:119)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1021)
        at org.apache.catalina.core.StandardHost.start(StandardHost.java:718)
        at org.apache.catalina.core.ContainerBase.start(ContainerBase.java:1013)
        at org.apache.catalina.core.StandardEngine.start(StandardEngine.java:442)
        at org.apache.catalina.core.StandardService.start(StandardService.java:450)
        at org.apache.catalina.core.StandardServer.start(StandardServer.java:709)
        at org.apache.catalina.startup.Catalina.start(Catalina.java:551)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.apache.catalina.startup.Bootstrap.start(Bootstrap.java:287)
        at org.apache.catalina.startup.Bootstrap.main(Bootstrap.java:412)
2014-12-4 16:09:00 org.apache.coyote.http11.Http11NioProtocol start
 

[data@server7 tomcat-news]$ vi bin/catalina.sh             
export LANG=zh_CN.GBK
 
-Dfile.encoding=GBK
vi  /etc/profile
#export JAVA_HOME=/opt/java/jrockit-jdk
export JAVA_HOME=/opt/datam/java/jdk1.8.0_25

jrockit-jdk 存在這個問題,換成sun jdk

https://community.oracle.com/thread/2213951?tstart=0


單飛 2014-12-04 16:37 發表評論
]]>
android 使用ssh2協議登陸服務器客戶端http://m.tkk7.com/sdyjmc/archive/2013/11/20/406592.html單飛單飛Wed, 20 Nov 2013 09:52:00 GMThttp://m.tkk7.com/sdyjmc/archive/2013/11/20/406592.htmlhttp://m.tkk7.com/sdyjmc/comments/406592.htmlhttp://m.tkk7.com/sdyjmc/archive/2013/11/20/406592.html#Feedback0http://m.tkk7.com/sdyjmc/comments/commentRss/406592.htmlhttp://m.tkk7.com/sdyjmc/services/trackbacks/406592.htmlJuiceSSH - SSH Client支持ssh2 協議,支持使用key文件。

把下面的網址:
https://play.google.com/store/apps/details?id=com.sonelli.juicessh
拷貝到
http://apps.evozi.com/apk-downloader/
就可以從google app 下載apk文件了,然后使用360手機助手安裝到手機里面

單飛 2013-11-20 17:52 發表評論
]]>
監控Hornetq消息數目--monitor hornetq message counthttp://m.tkk7.com/sdyjmc/archive/2013/01/25/394779.html單飛單飛Fri, 25 Jan 2013 09:34:00 GMThttp://m.tkk7.com/sdyjmc/archive/2013/01/25/394779.htmlhttp://m.tkk7.com/sdyjmc/comments/394779.htmlhttp://m.tkk7.com/sdyjmc/archive/2013/01/25/394779.html#Feedback0http://m.tkk7.com/sdyjmc/comments/commentRss/394779.htmlhttp://m.tkk7.com/sdyjmc/services/trackbacks/394779.html
export JVM_ARGS="$CLUSTER_PROPS  -Xms512M -Xmx1024M -Dhornetq.config.dir=$CONFIG_DIR -Djava.util.logging.config.file=$CONFIG_DIR/loggin
g.properties -Djava.library.path=. -Dcom.sun.management.jmxremote -Dcom.sun.management.jmxremote.port=4000 -Dcom.sun.management.jmxremo
te.authenticate=false -Dcom.sun.management.jmxremote.ssl=false -Djava.rmi.server.hostname=hadoop119"
#export JVM_ARGS="-Xmx512M -Djava.util.logging.config.file=$CONFIG_DIR/logging.properties -Dhornetq.config.dir=$CONFIG_DIR -Djava.libra
ry.path=. -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005"

2.hornetq-configuration.xml
 
[hadoop@server119 hornetq-2.2.14.Final]$ cd config/stand-alone/non-clustered/
[hadoop@server119 non-clustered]$ vi hornetq-configuration.xml
 
 <message-counter-enabled>true</message-counter-enabled>
3.配置jmx

jnp=jnp://192.168.0.119:1099
jmx_url=service:jmx:rmi:///jndi/rmi://192.168.0.119:4000/jmxrmi


3.
https://code.google.com/p/jms-monitor



public class Task implements Runnable {
    
private static Log log = LogFactory.getLog(Main.class);
 
    @Override
    
public void run() {
        Context initialContext 
= null;
        JMXConnector connector 
= null;
 
        
try {
            initialContext 
= new InitialContext(Service.getEnv());
            String queueName 
= "/queue/" + Service.getProperties().getProperty("queue.name");
            Queue queue 
= (Queue) initialContext.lookup(queueName);
            ObjectName on 
= ObjectNameBuilder.DEFAULT.getJMSQueueObjectName(queue.getQueueName());
            connector 
= JMXConnectorFactory.connect(new JMXServiceURL(Service.getProperties().getProperty("jmx_url")), new HashMap());
            MBeanServerConnection mbsc 
= connector.getMBeanServerConnection();
            JMSQueueControl queueControl 
= MBeanServerInvocationHandler.newProxyInstance(mbsc, on, JMSQueueControl.classfalse);
 
            String counters 
= queueControl.listMessageCounter();
            MessageCounterInfo messageCounter 
= MessageCounterInfo.fromJSON(counters);
 
            
int count = messageCounter.getDepth();
            
if (count < Integer.valueOf(Service.getProperties().getProperty("warning_msg_count"))) {
                log.info(
"jms queue length is " + count + ". Additional info: " + new Gson().toJson(messageCounter));
            }
 
            
if (count >= Integer.valueOf(Service.getProperties().getProperty("warning_msg_count"))
                    
&& count < Integer.valueOf(Service.getProperties().getProperty("fatal_msg_count"))) {
                log.warn(
"jms queue length is " + count + ". Additional info: " + new Gson().toJson(messageCounter));
            }
 
            
if (count >= Integer.valueOf(Service.getProperties().getProperty("fatal_msg_count"))) {
                log.fatal(
"jms queue length is " + count + ". Additional info: " + new Gson().toJson(messageCounter));
            }
        } 
catch (Exception ex) {
            log.error(ex.getMessage(), ex);
        } 
finally {
            
try {
                connector.close();
                initialContext.close();
            } 
catch (Exception e) {
                log.error(e.getMessage(), e);
            }
        }
    }
}


4.查看結果

25:01:2013 17:16:18.891  INFO pool-1-thread-1 Main:run:50 - jms queue length is 0. Additional info: {"name":"DLQ","subscription":"null","durable":true,"count":0,"countDelta":0,"depth":0,"depthDelta":0,"lastAddTimestamp":"70-1-1 8:00:00","udpateTimestamp":"13-1-25 17:16:05"}
25:01:2013 17:16:19.891  INFO pool-1-thread-1 Main:run:50 - jms queue length is 0. Additional info: {"name":"DLQ","subscription":"null","durable":true,"count":0,"countDelta":0,"depth":0,"depthDelta":0,"lastAddTimestamp":"70-1-1 8:00:00","udpateTimestamp":"13-1-25 17:16:15"}



單飛 2013-01-25 17:34 發表評論
]]>
velocity 字符串相加http://m.tkk7.com/sdyjmc/archive/2012/12/12/392863.html單飛單飛Wed, 12 Dec 2012 06:44:00 GMThttp://m.tkk7.com/sdyjmc/archive/2012/12/12/392863.htmlhttp://m.tkk7.com/sdyjmc/comments/392863.htmlhttp://m.tkk7.com/sdyjmc/archive/2012/12/12/392863.html#Feedback0http://m.tkk7.com/sdyjmc/comments/commentRss/392863.htmlhttp://m.tkk7.com/sdyjmc/services/trackbacks/392863.html獲取頁面請求基礎地址:

#set( $basePath = "$!{request.scheme}://$!{request.serverName}:$!{request.serverPort}$!{request.contextPath}/" )
String Literals
當你使用#set directive,String literal 封閉在一對雙引號內。象下面:
#set( $directoryRoot = "www" )
#set( $templateName = "index.vm" )
#set( $template = "$directoryRoot/$templateName" )
$template
上面這段代碼的輸出結果為:
www/index.vm
但是,當string literal 被封裝在單引號內時,它將不被解析:
#set( $foo = "bar" )
$foo
#set( $blargh = '$foo' )
$blargh
輸出為:
bar $foo
上面這個特性可以通過修改 velocity.properties 文件的 stringliterals.interpolate = false 的
值來改變上面的特性是否有效。


單飛 2012-12-12 14:44 發表評論
]]>
【原創】系統宕機導致flare db 因為臨時文件flare.xml 損壞不能啟動故障排除記錄http://m.tkk7.com/sdyjmc/archive/2012/11/21/391686.html單飛單飛Wed, 21 Nov 2012 02:40:00 GMThttp://m.tkk7.com/sdyjmc/archive/2012/11/21/391686.htmlhttp://m.tkk7.com/sdyjmc/comments/391686.htmlhttp://m.tkk7.com/sdyjmc/archive/2012/11/21/391686.html#Feedback0http://m.tkk7.com/sdyjmc/comments/commentRss/391686.htmlhttp://m.tkk7.com/sdyjmc/services/trackbacks/391686.html/db/flare/flare/bin/flared --daemonize --data-dir /db/flare/data/proxy/ --index-server-name 127.0.0.1 --index-server-port 12120 --server-name 127.0.0.1 --server-port 11211
/db/flare/flare/bin/flared --daemonize --data-dir /db/flare/data/master1/ --index-server-name 127.0.0.1 --index-server-port 12120 --server-name 127.0.0.1 --server-port 11212  
/db/flare/flare/bin/flared --daemonize -f /db/flare/flare/etc/flare-proxy.conf
 
data-dir = /db/flare/data/proxy
index-server-name = localhost
index-server-port = 12120
log-facility = local1
server-name = localhost
server-port = 11211
 
1.查看flare日志:
[flare@server logs]# vi /etc/syslog.conf

# falre logs
local0.*                                                /opt/logs/flare-index.log
local2.*                                               /opt/logs/flare-master.log
local1.*                                               /opt/logs/flare-proxy.log
 
 
[flare@server flare]$ cd /opt/logs/
[flare@server logs]$ ll
總計 15836
-rw------- 1 flare flare 11889779 09-10 10:16 flare-index.log
-rw------- 1 flare flare    23490 09-04 17:15 flare-master.log
-rw------- 1 flare flare  4270801 09-10 09:55 flare-proxy.log
 
 
分析日志查詢為啥起不起來。

[flare@server logs]# tail -f flare-proxy.log
 
2.查看端口是否被占用
[flare@server logs]# lsof -i:11212
[flare@server logs]# lsof -i:11211
[flare@server logs]# lsof -i:11210

3.查看tmp臨時目錄文件是否正常
vi /db/flare/tmp/flare.xml
發現改文件損壞,從備份程序拷貝
cp /opt/flare/tmp/flare.xml /db/flare/tmp/


啟動成功


單飛 2012-11-21 10:40 發表評論
]]>
Aspose.Words.jdk16.jar ccccccccccccccchttp://m.tkk7.com/sdyjmc/archive/2012/11/20/391637.html單飛單飛Tue, 20 Nov 2012 05:52:00 GMThttp://m.tkk7.com/sdyjmc/archive/2012/11/20/391637.htmlhttp://m.tkk7.com/sdyjmc/comments/391637.htmlhttp://m.tkk7.com/sdyjmc/archive/2012/11/20/391637.html#Feedback0http://m.tkk7.com/sdyjmc/comments/commentRss/391637.htmlhttp://m.tkk7.com/sdyjmc/services/trackbacks/391637.html

單飛 2012-11-20 13:52 發表評論
]]>
把字符串第一個字母大寫http://m.tkk7.com/sdyjmc/archive/2012/03/20/372291.html單飛單飛Tue, 20 Mar 2012 09:15:00 GMThttp://m.tkk7.com/sdyjmc/archive/2012/03/20/372291.htmlhttp://m.tkk7.com/sdyjmc/comments/372291.htmlhttp://m.tkk7.com/sdyjmc/archive/2012/03/20/372291.html#Feedback1http://m.tkk7.com/sdyjmc/comments/commentRss/372291.htmlhttp://m.tkk7.com/sdyjmc/services/trackbacks/372291.html1 private static String getMethodName(String fildeName){
2 byte[] items = fildeName.getBytes();
3 items[0= (byte)((char)items[0]-'a'+'A');;
4 return new String(items);
5 }


效率是最高的.


單飛 2012-03-20 17:15 發表評論
]]>
封裝jre安裝程序http://m.tkk7.com/sdyjmc/archive/2010/12/15/340765.html單飛單飛Wed, 15 Dec 2010 03:49:00 GMThttp://m.tkk7.com/sdyjmc/archive/2010/12/15/340765.htmlhttp://m.tkk7.com/sdyjmc/comments/340765.htmlhttp://m.tkk7.com/sdyjmc/archive/2010/12/15/340765.html#Feedback0http://m.tkk7.com/sdyjmc/comments/commentRss/340765.htmlhttp://m.tkk7.com/sdyjmc/services/trackbacks/340765.html
    permission java.util.PropertyPermission "file.encoding", "read";
所以封裝了一下jre安裝程序
文件準備:
D:\svn1.3\setup\jre-6u22-windows-i586.exe
D:\svn1.3\setup\java.policy


java.policy

這個文件包含了permission java.util.PropertyPermission "file.encoding", "read" 修改后的結果。

使用setupfactory制作安裝腳本:

http://m.tkk7.com/Files/sdyjmc/setupJRE.sf7.zip

下載后,去掉.zip后綴使用setupfactory 7導入即可制作自己的jre安裝程序。


單飛 2010-12-15 11:49 發表評論
]]>
applet訪問本地資源,需要修改jre的java.policyhttp://m.tkk7.com/sdyjmc/archive/2010/12/14/340674.html單飛單飛Tue, 14 Dec 2010 09:16:00 GMThttp://m.tkk7.com/sdyjmc/archive/2010/12/14/340674.htmlhttp://m.tkk7.com/sdyjmc/comments/340674.htmlhttp://m.tkk7.com/sdyjmc/archive/2010/12/14/340674.html#Feedback0http://m.tkk7.com/sdyjmc/comments/commentRss/340674.htmlhttp://m.tkk7.com/sdyjmc/services/trackbacks/340674.html 使用 JRE 版本 1.6.0_22-b04 Java HotSpot(TM) Client VM
用戶主目錄 = C:\Documents and Settings\Administrator
----------------------------------------------------
c:   清除控制臺窗口
f:   終結在結束隊列上的對象
g:   垃圾收集
h:   顯示此幫助消息
l:   轉儲類載入程序列表
m:   打印內存使用
o:   觸發日志記錄
q:   隱藏控制臺
r:   重新載入策略配置
s:   轉儲系統和部署屬性
t:   轉儲線程列表
v:   轉儲線程堆棧
x:   清除類載入程序高速緩存
0-5: 設置跟蹤級別為<n>
----------------------------------------------------


java.security.AccessControlException: access denied (java.util.PropertyPermission file.encoding read)
    at java.security.AccessControlContext.checkPermission(Unknown Source)
    at java.security.AccessController.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkPermission(Unknown Source)
    at java.lang.SecurityManager.checkPropertyAccess(Unknown Source)
    at java.lang.System.getProperty(Unknown Source)
    at org.apache.tools.zip.ZipEncodingHelper.isUTF8(ZipEncodingHelper.java:246)
    at org.apache.tools.zip.ZipEncodingHelper.getZipEncoding(ZipEncodingHelper.java:214)
    at org.apache.tools.zip.ZipOutputStream.<init>(ZipOutputStream.java:236)
    at com.smapp.service.exchange.web.upload.zip.ZipBean.<init>(ZipBean.java:39)
    at com.smapp.service.exchange.web.upload.MainPanel$3.<init>(MainPanel.java:443)
    at com.smapp.service.exchange.web.upload.MainPanel.zipFile(MainPanel.java:443)
    at com.smapp.service.exchange.web.upload.MainPanel.access$3(MainPanel.java:440)
    at com.smapp.service.exchange.web.upload.MainPanel$2.run(MainPanel.java:364)
java.lang.NullPointerException
    at com.smapp.service.exchange.web.upload.zip.ZipBean.makeZipSize(ZipBean.java:87)
    at com.smapp.service.exchange.web.upload.zip.ZipBean.getMaxProcessValue(ZipBean.java:108)
    at com.smapp.service.exchange.web.upload.MainPanel.zipFile(MainPanel.java:450)
    at com.smapp.service.exchange.web.upload.MainPanel.access$3(MainPanel.java:440)
    at com.smapp.service.exchange.web.upload.MainPanel$2.run(MainPanel.java:364)
2010-12-14 16:51:59 com.smapp.service.exchange.web.upload.zip.ZipBean getMaxProcessValue
信息: 總體進度:0
java.lang.NullPointerException
    at com.smapp.service.exchange.web.upload.zip.ZipBean.closeZip(ZipBean.java:57)
    at com.smapp.service.exchange.web.upload.MainPanel.zipFile(MainPanel.java:455)
    at com.smapp.service.exchange.web.upload.MainPanel.access$3(MainPanel.java:440)
    at com.smapp.service.exchange.web.upload.MainPanel$2.run(MainPanel.java:364)

xp、win7系統下面會出現改問題,修改
c:\Program Files\Java\jdk1.6.0_21\jre\lib\security\java.policy
最后增加一行代碼:
permission java.util.PropertyPermission "file.encoding", "read";
};






單飛 2010-12-14 17:16 發表評論
]]>
Web工程依賴多個工程,編譯運行找不到類問題http://m.tkk7.com/sdyjmc/archive/2010/12/09/340115.html單飛單飛Thu, 09 Dec 2010 02:21:00 GMThttp://m.tkk7.com/sdyjmc/archive/2010/12/09/340115.htmlhttp://m.tkk7.com/sdyjmc/comments/340115.htmlhttp://m.tkk7.com/sdyjmc/archive/2010/12/09/340115.html#Feedback0http://m.tkk7.com/sdyjmc/comments/commentRss/340115.htmlhttp://m.tkk7.com/sdyjmc/services/trackbacks/340115.html 但是使用tomcat調試的時候,會找不到其它工程的class。
在工程名上右擊,選 Properties,找到 Java Build Path,選第二個選項卡“Projects”,點“Add...”按鈕,
會彈出“Required Project Selection”框,里面會出現這個工作區中除了當前工程之外的其他工程,把需要鏈
接的工程勾選上點“OK”就可以了

右擊工程名,選擇Properties,選擇libraries Tab,點Add External Class Folder...,
選擇你lib工程的目標輸出文件夾,添加進去應該就可以

這樣可以解決多個依賴工程自動輸出class的問題。

    <classpathentry combineaccessrules="false" kind="src" path="/business"/>
    <classpathentry combineaccessrules="false" kind="src" path="/dao"/>
    <classpathentry combineaccessrules="false" kind="src" path="/datamodel"/>





單飛 2010-12-09 10:21 發表評論
]]>
ext3上傳文件為空http://m.tkk7.com/sdyjmc/archive/2010/12/04/339783.html單飛單飛Sat, 04 Dec 2010 03:33:00 GMThttp://m.tkk7.com/sdyjmc/archive/2010/12/04/339783.htmlhttp://m.tkk7.com/sdyjmc/comments/339783.htmlhttp://m.tkk7.com/sdyjmc/archive/2010/12/04/339783.html#Feedback0http://m.tkk7.com/sdyjmc/comments/commentRss/339783.htmlhttp://m.tkk7.com/sdyjmc/services/trackbacks/339783.html     var loginForm = new Ext.FormPanel({
                    id:'loginForm',// formPanel組件的ID
                    width:600,// 組件寬度
                    height:300,// 組件高度
                    frame:true,
                    fileUpload: true,
                    enctype:'multipart/form-data',
                    //實現非AJAX提交表單一定要加下面的兩行!
                    onSubmit: Ext.emptyFn,
                    method:'POST',
                    align:'center',// 組件居左布局,還有right和center兩個值可以選擇
                    name: 'loginForm', //組件名稱
                    labelAlign:"left",//讓label居右
                    labelWidth:120,//定義label的寬度
                    items:[{

xtype: "textfield",
                            inputType:'file',
                            name: 'processFile',
                            fieldLabel: '文件',
                            allowBlank:false,
                            anchor:'95%'


public void deploy(HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        request.setCharacterEncoding("utf-8");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmmss");  
        String tmpDir = getServletContext().getRealPath("/temp");// 初始化上傳文件的臨時寄放目錄
        String uploadPath = getServletContext().getRealPath("/upload");// 初始化上傳文件后的保存
        try {
            if (ServletFileUpload.isMultipartContent(request)) {
                 DiskFileItemFactory factory = new DiskFileItemFactory();
                 //指定在內存中緩存數據大小,單位為byte,這里設為1Mb  
                factory.setSizeThreshold(1 * 1024 * 1024);   
                //設置一旦文件大小超過getSizeThreshold()的值時數據存放在硬盤的目錄  
                factory.setRepository(new File(tmpDir));   
                ServletFileUpload sfu = new ServletFileUpload(factory);  
                 // 指定單個上傳文件的最大尺寸,單位:字節,這里設為5Mb  
                sfu.setFileSizeMax(100 * 1024 * 1024);  
                //指定一次上傳多個文件的總尺寸,單位:字節,這里設為10Mb  
                sfu.setSizeMax(100 * 1024 * 1024);   
                sfu.setHeaderEncoding("UTF-8"); //設置編碼,因為我的jsp頁面的編碼是utf-8的  
                FileItemIterator fii = sfu.getItemIterator(request);// 解析request請求  
                uploadPath = uploadPath + "\\jbpm\\"; // 選定上傳的目錄此處為當前目錄  
                if (!new File(uploadPath).isDirectory()){  
                    new File(uploadPath).mkdirs(); //選定上傳的目錄此處為當前目錄,沒有則創建  
                }  
                  
                int index = 0;  
                while (fii.hasNext()) {  
                    FileItemStream fis = fii.next();// 從集合中獲得一個文件流  
                    if (!fis.isFormField() && fis.getName().length() > 0) {// 過濾掉表單中非文件域  
                        String fileName = fis.getName();// 獲得上傳文件的文件名                        
                        BufferedInputStream in = new BufferedInputStream(fis.openStream());   
                        BufferedOutputStream out = new BufferedOutputStream(  
                                new FileOutputStream(new File(uploadPath + "\\" + fileName)));  
                        Streams.copy(in, out, true); // 開始把文件寫到你指定的上傳文件夾  
                        index++;  
                    }  
                }  
            }
        } catch (Exception e) {
            e.printStackTrace();
        }

        response.setContentType("text/html");
        response.getWriter().print("{success:true}");
    }

上傳文件為空:因為:
    <filter-mapping>
        <!--攔截所有的URL請求-->
        <filter-name>struts2</filter-name>
        <!--上傳文件會不起作用-->
        <!-- url-pattern>/*</url-pattern -->
        <url-pattern>*.action</url-pattern>
    </filter-mapping>

原因就是因為在web.xml中配置了Struts的filter
<filter-mapping>
  <filter-name>struts2</filter-name>
  <url-pattern>/*</url-pattern>
</filter-mapping>

改成

<filter-mapping>
  <filter-name>struts2</filter-name>
  <url-pattern>*.action</url-pattern>
</filter-mapping>

就可以了




單飛 2010-12-04 11:33 發表評論
]]>
求救:jbpm4.3部署到weblogic報錯http://m.tkk7.com/sdyjmc/archive/2010/11/24/338973.html單飛單飛Wed, 24 Nov 2010 12:56:00 GMThttp://m.tkk7.com/sdyjmc/archive/2010/11/24/338973.htmlhttp://m.tkk7.com/sdyjmc/comments/338973.htmlhttp://m.tkk7.com/sdyjmc/archive/2010/11/24/338973.html#Feedback1http://m.tkk7.com/sdyjmc/comments/commentRss/338973.htmlhttp://m.tkk7.com/sdyjmc/services/trackbacks/338973.html icationContext.xml]: Instantiation of bean failed; nested exception is org.sprin
gframework.beans.factory.BeanDefinitionStoreException: Factory method [public or
g.jbpm.api.ProcessEngine org.jbpm.pvm.internal.processengine.SpringHelper.create
ProcessEngine()] threw exception; nested exception is org.springframework.beans.
factory.BeanCreationException: Error creating bean with name 'sessionFactory' de
fined in ServletContext resource [/WEB-INF/classes/applicationContext.xml]: Invo
cation of init method failed; nested exception is org.hibernate.HibernateExcepti
on: Errors in named queries: findTasks, findMessages, findTimers, findGroupsByUs
erAndGroupType, findProcessInstanceIds, findJobsWithException, findProcessInstan
ceById, findExecutionById, findProcessInstanceByIdIgnoreSuspended, findGroupsByU
ser, findFirstDueJob, findExclusiveJobs, findFirstAcquirableJob
        at org.springframework.beans.factory.support.ConstructorResolver.instant
iateUsingFactoryMethod(ConstructorResolver.java:572)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:97
3)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:879)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.java:456)
        Truncated. see log file for complete stacktrace

Caused By: org.springframework.beans.factory.BeanDefinitionStoreException: Facto
ry method [public org.jbpm.api.ProcessEngine org.jbpm.pvm.internal.processengine
.SpringHelper.createProcessEngine()] threw exception; nested exception is org.sp
ringframework.beans.factory.BeanCreationException: Error creating bean with name
 'sessionFactory' defined in ServletContext resource [/WEB-INF/classes/applicati
onContext.xml]: Invocation of init method failed; nested exception is org.hibern
ate.HibernateException: Errors in named queries: findTasks, findMessages, findTi
mers, findGroupsByUserAndGroupType, findProcessInstanceIds, findJobsWithExceptio
n, findProcessInstanceById, findExecutionById, findProcessInstanceByIdIgnoreSusp
ended, findGroupsByUser, findFirstDueJob, findExclusiveJobs, findFirstAcquirable
Job
        at org.springframework.beans.factory.support.SimpleInstantiationStrategy
.instantiate(SimpleInstantiationStrategy.java:154)
        at org.springframework.beans.factory.support.ConstructorResolver.instant
iateUsingFactoryMethod(ConstructorResolver.java:561)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:97
3)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:879)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
        Truncated. see log file for complete stacktrace

Caused By: org.springframework.beans.factory.BeanCreationException: Error creati
ng bean with name 'sessionFactory' defined in ServletContext resource [/WEB-INF/
classes/applicationContext.xml]: Invocation of init method failed; nested except
ion is org.hibernate.HibernateException: Errors in named queries: findTasks, fin
dMessages, findTimers, findGroupsByUserAndGroupType, findProcessInstanceIds, fin
dJobsWithException, findProcessInstanceById, findExecutionById, findProcessInsta
nceByIdIgnoreSuspended, findGroupsByUser, findFirstDueJob, findExclusiveJobs, fi
ndFirstAcquirableJob
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.initializeBean(AbstractAutowireCapableBeanFactory.java:1412)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.java:456)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
ject(AbstractBeanFactory.java:291)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr
y.getSingleton(DefaultSingletonBeanRegistry.java:222)
        Truncated. see log file for complete stacktrace

Caused By: org.hibernate.HibernateException: Errors in named queries: findTasks,
 findMessages, findTimers, findGroupsByUserAndGroupType, findProcessInstanceIds,
 findJobsWithException, findProcessInstanceById, findExecutionById, findProcessI
nstanceByIdIgnoreSuspended, findGroupsByUser, findFirstDueJob, findExclusiveJobs
, findFirstAcquirableJob
        at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:
397)
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.jav
a:1327)
        at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSession
Factory(LocalSessionFactoryBean.java:855)
        at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessi
onFactory(LocalSessionFactoryBean.java:774)
        at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPr
opertiesSet(AbstractSessionFactoryBean.java:211)
        Truncated. see log file for complete stacktrace
>
<2010-11-24 下午08時13分23秒 CST> <Error> <Deployer> <BEA-149265> <Failure occur
red in the execution of deployment request with ID '1290600743834' for task '4'.
 Error is: 'weblogic.application.ModuleException: '
weblogic.application.ModuleException:
        at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.jav
a:1514)
        at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:486)
        at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleSta
teDriver.java:425)
        at weblogic.application.utils.StateMachineDriver.nextState(StateMachineD
river.java:41)
        at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStat
eDriver.java:119)
        Truncated. see log file for complete stacktrace

Caused By: org.hibernate.HibernateException: Errors in named queries: findTasks,
 findMessages, findTimers, findGroupsByUserAndGroupType, findProcessInstanceIds,
 findJobsWithException, findProcessInstanceById, findExecutionById, findProcessI
nstanceByIdIgnoreSuspended, findGroupsByUser, findFirstDueJob, findExclusiveJobs
, findFirstAcquirableJob
        at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:
397)
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.jav
a:1327)
        at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSession
Factory(LocalSessionFactoryBean.java:855)
        at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessi
onFactory(LocalSessionFactoryBean.java:774)
        at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPr
opertiesSet(AbstractSessionFactoryBean.java:211)
        Truncated. see log file for complete stacktrace
>
<2010-11-24 下午08時13分23秒 CST> <Error> <Deployer> <BEA-149202> <Encountered a
n exception while attempting to commit the 1 task for the application 'oa'.>
<2010-11-24 下午08時13分23秒 CST> <Warning> <Deployer> <BEA-149004> <Failures we
re detected while initiating deploy task for application 'oa'.>
<2010-11-24 下午08時13分23秒 CST> <Warning> <Deployer> <BEA-149078> <Stack trace
 for message 149004
weblogic.application.ModuleException: :org.hibernate.HibernateException:Errors i
n named queries: findTasks, findMessages, findTimers, findGroupsByUserAndGroupTy
pe, findProcessInstanceIds, findJobsWithException, findProcessInstanceById, find
ExecutionById, findProcessInstanceByIdIgnoreSuspended, findGroupsByUser, findFir
stDueJob, findExclusiveJobs, findFirstAcquirableJob
        at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:
397)
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.jav
a:1327)
        at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSession
Factory(LocalSessionFactoryBean.java:855)
        at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessi
onFactory(LocalSessionFactoryBean.java:774)
        at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPr
opertiesSet(AbstractSessionFactoryBean.java:211)
        Truncated. see log file for complete stacktrace
>
<2010-11-24 下午08時13分23秒 CST> <Error> <Console> <BEA-240003> <Console encoun
tered the following error weblogic.application.ModuleException: :org.hibernate.H
ibernateException:Errors in named queries: findTasks, findMessages, findTimers,
findGroupsByUserAndGroupType, findProcessInstanceIds, findJobsWithException, fin
dProcessInstanceById, findExecutionById, findProcessInstanceByIdIgnoreSuspended,
 findGroupsByUser, findFirstDueJob, findExclusiveJobs, findFirstAcquirableJob
        at org.hibernate.impl.SessionFactoryImpl.<init>(SessionFactoryImpl.java:
397)
        at org.hibernate.cfg.Configuration.buildSessionFactory(Configuration.jav
a:1327)
        at org.springframework.orm.hibernate3.LocalSessionFactoryBean.newSession
Factory(LocalSessionFactoryBean.java:855)
        at org.springframework.orm.hibernate3.LocalSessionFactoryBean.buildSessi
onFactory(LocalSessionFactoryBean.java:774)
        at org.springframework.orm.hibernate3.AbstractSessionFactoryBean.afterPr
opertiesSet(AbstractSessionFactoryBean.java:211)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.invokeInitMethods(AbstractAutowireCapableBeanFactory.java:1469)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.initializeBean(AbstractAutowireCapableBeanFactory.java:1409)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:519)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.java:456)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
ject(AbstractBeanFactory.java:291)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr
y.getSingleton(DefaultSingletonBeanRegistry.java:222)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe
an(AbstractBeanFactory.java:288)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:190)
        at org.springframework.context.support.AbstractApplicationContext.getBea
n(AbstractApplicationContext.java:1075)
        at org.jbpm.pvm.internal.processengine.SpringProcessEngine.get(SpringPro
cessEngine.java:116)
        at org.jbpm.pvm.internal.processengine.SpringProcessEngine.create(Spring
ProcessEngine.java:64)
        at org.jbpm.pvm.internal.cfg.ConfigurationImpl.buildProcessEngine(Config
urationImpl.java:90)
        at org.jbpm.pvm.internal.processengine.SpringHelper.createProcessEngine(
SpringHelper.java:50)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.springframework.beans.factory.support.SimpleInstantiationStrategy
.instantiate(SimpleInstantiationStrategy.java:142)
        at org.springframework.beans.factory.support.ConstructorResolver.instant
iateUsingFactoryMethod(ConstructorResolver.java:561)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.instantiateUsingFactoryMethod(AbstractAutowireCapableBeanFactory.java:97
3)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBeanInstance(AbstractAutowireCapableBeanFactory.java:879)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.doCreateBean(AbstractAutowireCapableBeanFactory.java:485)
        at org.springframework.beans.factory.support.AbstractAutowireCapableBean
Factory.createBean(AbstractAutowireCapableBeanFactory.java:456)
        at org.springframework.beans.factory.support.AbstractBeanFactory$1.getOb
ject(AbstractBeanFactory.java:291)
        at org.springframework.beans.factory.support.DefaultSingletonBeanRegistr
y.getSingleton(DefaultSingletonBeanRegistry.java:222)
        at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBe
an(AbstractBeanFactory.java:288)
        at org.springframework.beans.factory.support.AbstractBeanFactory.getBean
(AbstractBeanFactory.java:190)
        at org.springframework.beans.factory.support.DefaultListableBeanFactory.
preInstantiateSingletons(DefaultListableBeanFactory.java:574)
        at org.springframework.context.support.AbstractApplicationContext.finish
BeanFactoryInitialization(AbstractApplicationContext.java:895)
        at org.springframework.context.support.AbstractApplicationContext.refres
h(AbstractApplicationContext.java:425)
        at org.springframework.web.context.ContextLoader.createWebApplicationCon
text(ContextLoader.java:276)
        at org.springframework.web.context.ContextLoader.initWebApplicationConte
xt(ContextLoader.java:197)
        at org.springframework.web.context.ContextLoaderListener.contextInitiali
zed(ContextLoaderListener.java:47)
        at weblogic.servlet.internal.EventsManager$FireContextListenerAction.run
(EventsManager.java:481)
        at weblogic.security.acl.internal.AuthenticatedSubject.doAs(Authenticate
dSubject.java:321)
        at weblogic.security.service.SecurityManager.runAs(SecurityManager.java:
121)
        at weblogic.servlet.internal.EventsManager.notifyContextCreatedEvent(Eve
ntsManager.java:181)
        at weblogic.servlet.internal.WebAppServletContext.preloadResources(WebAp
pServletContext.java:1863)
        at weblogic.servlet.internal.WebAppServletContext.start(WebAppServletCon
text.java:3126)
        at weblogic.servlet.internal.WebAppModule.startContexts(WebAppModule.jav
a:1512)
        at weblogic.servlet.internal.WebAppModule.start(WebAppModule.java:486)
        at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleSta
teDriver.java:425)
        at weblogic.application.utils.StateMachineDriver.nextState(StateMachineD
river.java:41)
        at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStat
eDriver.java:119)
        at weblogic.application.internal.flow.ScopedModuleDriver.start(ScopedMod
uleDriver.java:200)
        at weblogic.application.internal.flow.ModuleListenerInvoker.start(Module
ListenerInvoker.java:247)
        at weblogic.application.internal.flow.ModuleStateDriver$3.next(ModuleSta
teDriver.java:425)
        at weblogic.application.utils.StateMachineDriver.nextState(StateMachineD
river.java:41)
        at weblogic.application.internal.flow.ModuleStateDriver.start(ModuleStat
eDriver.java:119)
        at weblogic.application.internal.flow.StartModulesFlow.activate(StartMod
ulesFlow.java:27)
        at weblogic.application.internal.BaseDeployment$2.next(BaseDeployment.ja
va:1267)
        at weblogic.application.utils.StateMachineDriver.nextState(StateMachineD
river.java:41)
        at weblogic.application.internal.BaseDeployment.activate(BaseDeployment.
java:409)
        at weblogic.application.internal.SingleModuleDeployment.activate(SingleM
oduleDeployment.java:43)
        at weblogic.application.internal.DeploymentStateChecker.activate(Deploym
entStateChecker.java:161)
        at weblogic.deploy.internal.targetserver.AppContainerInvoker.activate(Ap
pContainerInvoker.java:79)
        at weblogic.deploy.internal.targetserver.operations.AbstractOperation.ac
tivate(AbstractOperation.java:569)
        at weblogic.deploy.internal.targetserver.operations.ActivateOperation.ac
tivateDeployment(ActivateOperation.java:150)
        at weblogic.deploy.internal.targetserver.operations.ActivateOperation.do
Commit(ActivateOperation.java:116)
        at weblogic.deploy.internal.targetserver.operations.AbstractOperation.co
mmit(AbstractOperation.java:323)
        at weblogic.deploy.internal.targetserver.DeploymentManager.handleDeploym
entCommit(DeploymentManager.java:844)
        at weblogic.deploy.internal.targetserver.DeploymentManager.activateDeplo
ymentList(DeploymentManager.java:1253)
        at weblogic.deploy.internal.targetserver.DeploymentManager.handleCommit(
DeploymentManager.java:440)
        at weblogic.deploy.internal.targetserver.DeploymentServiceDispatcher.com
mit(DeploymentServiceDispatcher.java:163)
        at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallb
ackDeliverer.doCommitCallback(DeploymentReceiverCallbackDeliverer.java:195)
        at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallb
ackDeliverer.access$100(DeploymentReceiverCallbackDeliverer.java:13)
        at weblogic.deploy.service.internal.targetserver.DeploymentReceiverCallb
ackDeliverer$2.run(DeploymentReceiverCallbackDeliverer.java:68)
        at weblogic.work.SelfTuningWorkManagerImpl$WorkAdapterImpl.run(SelfTunin
gWorkManagerImpl.java:528)
        at weblogic.work.ExecuteThread.execute(ExecuteThread.java:201)
        at weblogic.work.ExecuteThread.run(ExecuteThread.java:173)
>
<2010-11-24 下午08時13分44秒 CST> <Warning> <netuix> <BEA-423420> <Redirect is e
xecuted in begin or refresh action. Redirect url is /console/console.portal?_nfp
b=true&_pageLabel=WebAppApplicationOverviewPage&WebAppApplicationOverviewPortlet
handle=com.bea.console.handles.AppDeploymentHandle%28%22com.bea%3AName%3Doa%2CTy
pe%3DAppDeployment%22%29.>




單飛 2010-11-24 20:56 發表評論
]]>
分析引用的jar文件是否有用http://m.tkk7.com/sdyjmc/archive/2010/08/30/330274.html單飛單飛Mon, 30 Aug 2010 06:02:00 GMThttp://m.tkk7.com/sdyjmc/archive/2010/08/30/330274.htmlhttp://m.tkk7.com/sdyjmc/comments/330274.htmlhttp://m.tkk7.com/sdyjmc/archive/2010/08/30/330274.html#Feedback0http://m.tkk7.com/sdyjmc/comments/commentRss/330274.htmlhttp://m.tkk7.com/sdyjmc/services/trackbacks/330274.html

Programmer's Friend

Class Dependency Analyzer (CDA) V1.13.1


http://www.dependency-analyzer.org/



單飛 2010-08-30 14:02 發表評論
]]>
[轉] 如何把JAVA工程生成一個.JAR文件,而不是一堆JAR(ECLIPSE生成JAR) http://m.tkk7.com/sdyjmc/archive/2010/02/04/311945.html單飛單飛Thu, 04 Feb 2010 05:58:00 GMThttp://m.tkk7.com/sdyjmc/archive/2010/02/04/311945.htmlhttp://m.tkk7.com/sdyjmc/comments/311945.htmlhttp://m.tkk7.com/sdyjmc/archive/2010/02/04/311945.html#Feedback0http://m.tkk7.com/sdyjmc/comments/commentRss/311945.htmlhttp://m.tkk7.com/sdyjmc/services/trackbacks/311945.html

我現在在編寫一個JAVA工程,是提供給客戶調用的API,但是我的API中大約需要依賴10個.JAR,

以前我都是使用ECLIPSE 的 EXPORT  JAR file功能導出 JAR,這樣的JAR可以使用,但是我的API種依賴的包客戶還是需要導入,這樣一共就需要導入11個包了,太麻煩了,現在就是想包括API和依賴的JAR打成一個JAR,這樣子就方便多了,

現在找到了,使用ECLIPSE3.4的EXPORT Runnable JAR file功能導出的JAR就是包含了依賴的JAR,導入這一個JAR就可以了,具體操作如下,

1. 先找到你的工程中提供接口的類(要包含MAIN方法),

2. 在該類中右鍵選擇 RUN as

3. 選擇 Run configurations

4. 在main窗口中選擇main class為本類

5. 點擊RUN

6. 選擇你的工程,右鍵選擇 EXPORT

7. 在彈出的窗口中選擇 runnable jar file

8. 在彈出的 runnable jar file export窗口中第一個launch configuration 中選擇你剛才配置的類,

     第二個窗口中選擇你要導出的路徑

9. 然后選擇下一步就OK了




單飛 2010-02-04 13:58 發表評論
]]>
[轉]JAVA正則表達式高級用法(分組與捕獲)http://m.tkk7.com/sdyjmc/archive/2010/01/06/308391.html單飛單飛Wed, 06 Jan 2010 02:14:00 GMThttp://m.tkk7.com/sdyjmc/archive/2010/01/06/308391.htmlhttp://m.tkk7.com/sdyjmc/comments/308391.htmlhttp://m.tkk7.com/sdyjmc/archive/2010/01/06/308391.html#Feedback0http://m.tkk7.com/sdyjmc/comments/commentRss/308391.htmlhttp://m.tkk7.com/sdyjmc/services/trackbacks/308391.html
正則表達式在字符串處理中經常使用,關于正則簡單的用法相信有一點程序基礎的人都懂得一些,這里就不介紹簡單基礎了。這里主要講解一下在JAVA中實現了的正則的高級用法-分組與捕獲。

    對于要重復單個字符,非常簡單,直接在字符后賣弄加上限定符即可,例如 a+ 表示匹配1個或一個以上的a,a?表示匹配0個或1個a。這些限定符如下所示:

  X? X,一次或一次也沒有
X* X,零次或多次
X+ X,一次或多次
X{n} X,恰好 n 次
X{n,} X,至少 n 次
X{n,m} X,至少 n 次,但是不超過 m 次





但是我們如果要對多個字符進行重復怎么辦呢?此時我們就要用到分組,我們可以使用小括號"()"來指定要重復的子表達式,然后對這個子表達式進行重復,例如:(abc)? 表示0個或1個abc 這里一個括號的表達式就表示一個分組。



   分組可以分為兩種形式,捕獲組和非捕獲組。



捕獲組

捕獲組可以通過從左到右計算其開括號來編號。例如,在表達式 ((A)(B(C))) 中,存在四個這樣的組:

1     ((A)(B(C)))
2     "A
3     (B(C))
4     (C)

組零始終代表整個表達式

之所以這樣命名捕獲組是因為在匹配中,保存了與這些組匹配的輸入序列的每個子序列。捕獲的子序列稍后可以通過 Back 引用在表達式中使用,也可以在匹配操作完成后從匹配器檢索。



Back 引用 是說在后面的表達式中我們可以使用組的編號來引用前面的表達式所捕獲到的文本序列(是文本不是正則)。



例如 ([" ']).* "1   其中使用了分組,"1就是對引號這個分組的引用,它匹配包含在兩個引號或者兩個單引號中的所有字符串,如,"abc" 或 " ' " 或 ' " '  ,但是請注意,它并不會對" a'或者 'a"匹配。原因上面已經說明,Back引用只是引用文本而不是表達式。



非捕獲組

      以 (?) 開頭的組是純的非捕獲 組,它不捕獲文本,也不針對組合計進行計數。就是說,如果小括號中以?號開頭,那么這個分組就不會捕獲文本,當然也不會有組的編號,因此也不存在Back 引用。

      在Java中,支持的非捕獲組,有如下幾種:

 
   
  
(?=X)     X,通過零寬度的正 lookahead
(?!X)     X,通過零寬度的負 lookahead
(?<=X)     X,通過零寬度的正 lookbehind
(?<!X)     X,通過零寬度的負 lookbehind
 




這四個非捕獲組用于匹配表達式X,但是不包含表達式的文本。

(?=X ) 零寬度正先行斷言。僅當子表達式 X 在 此位置的右側匹配時才繼續匹配。例如,"w+(?="d) 與后跟數字的單詞匹配,而不與該數字匹配。此構造不會回溯。
(?!X) 零寬度負先行斷言。僅當子表達式 X 不在 此位置的右側匹配時才繼續匹配。例如,例如,"w+(?!"d) 與后不跟數字的單詞匹配,而不與該數字匹配。
(?<=X) 零寬度正后發斷言。僅當子表達式 X 在 此位置的左側匹配時才繼續匹配。例如,(?<=19)99 與跟在 19 后面的 99 的實例匹配。此構造不會回溯。
(?<!X) 零寬度負后發斷言。僅當子表達式 X 不在此位置的左側匹配時才繼續匹配。例如,(?<!19)99 與不跟在 19 后面的 99 的實例匹配






舉例:



上面都是理論性的介紹,這里就使用一些例子來說明一下問題:

   1、測試匹配性   (?<!4)56(?=9) 這里的含義就是匹配后面的文本56前面不能是4,后面必須是9組成。因此,可以匹配如下文本 5569  ,與4569不匹配。



  2 、提取字符串   提取 da12bka3434bdca4343bdca234bm   提取包含在字符a和b之間的數字,但是這個a之前的字符不能是c,b后面的字符必須是d才能提取。



        例如這里就只有3434這個數字滿足要求。那么我們怎么提取呢?

       首先我們寫出提取這個字符串的表達式: (?<!c)a("d+)bd  這里就只有一個捕獲組("d+)

       JAVA代碼片段如下:

Pattern p = Pattern.compile("(?<!c)a(""d+)bd");
Matcher m = p.matcher("da12bca3434bdca4343bdca234bm");
while(m.find()){
   System.out.println(m.group(1)); //我們只要捕獲組1的數字即可。結果 3434
   System.out.println(m.group(0)); // 0組是整個表達式,看這里,并沒有提煉出(?<!c)的字符 。結果 a3434bd
}
    可以看到,非捕獲組,最后是不會返回結果的,因為它本身并不捕獲文本。



正則表達式功能其實非常強大,這里只是對高級用法的簡單探討。有興趣的朋友和本人共同討論。

單飛 2010-01-06 10:14 發表評論
]]>
[轉]Java正則表達式入門http://m.tkk7.com/sdyjmc/archive/2009/12/29/307231.html單飛單飛Tue, 29 Dec 2009 02:34:00 GMThttp://m.tkk7.com/sdyjmc/archive/2009/12/29/307231.htmlhttp://m.tkk7.com/sdyjmc/comments/307231.htmlhttp://m.tkk7.com/sdyjmc/archive/2009/12/29/307231.html#Feedback0http://m.tkk7.com/sdyjmc/comments/commentRss/307231.htmlhttp://m.tkk7.com/sdyjmc/services/trackbacks/307231.html  大 家都知道,正則表達式是一種可以用于模式匹配和替換的規范,一個正則表達式就是由普通的字符(例如字符a到z)以及特殊字符(元字符)組成的文字模式,它 用以描述在查找文字主體時待匹配的一個或多個字符串。正則表達式作為一個模板,將某個字符模式與所搜索的字符串進行匹配。
  自從jdk1.4推出java.util.regex包,就為我們提供了很好的JAVA正則表達式應用平臺。
 
 因為正則表達式是一個很龐雜的體系,所以我僅例舉些入門的概念,更多的請參閱相關書籍及自行摸索。

\\ 反斜杠
\t 間隔 ('\u0009')
\n 換行 ('\u000A')
\r 回車 ('\u000D')
\d 數字 等價于[0-9]
\D 非數字 等價于[^0-9]
\s 空白符號 [\t\n\x0B\f\r]
\S 非空白符號 [^\t\n\x0B\f\r]
\w 單獨字符 [a-zA-Z_0-9]
\W 非單獨字符 [^a-zA-Z_0-9]
\f 換頁符
\e Escape
\b 一個單詞的邊界
\B 一個非單詞的邊界
\G 前一個匹配的結束

^為限制開頭
^java     條件限制為以Java為開頭字符
$為限制結尾
java$     條件限制為以java為結尾字符
.  條件限制除\n以外任意一個單獨字符
java..     條件限制為java后除換行外任意兩個字符


加入特定限制條件「[]」
[a-z]     條件限制在小寫a to z范圍中一個字符
[A-Z]     條件限制在大寫A to Z范圍中一個字符
[a-zA-Z] 條件限制在小寫a to z或大寫A to Z范圍中一個字符
[0-9]     條件限制在小寫0 to 9范圍中一個字符
[0-9a-z] 條件限制在小寫0 to 9或a to z范圍中一個字符
[0-9[a-z]] 條件限制在小寫0 to 9或a to z范圍中一個字符(交集)

[]中加入^后加再次限制條件「[^]」
[^a-z]     條件限制在非小寫a to z范圍中一個字符
[^A-Z]     條件限制在非大寫A to Z范圍中一個字符
[^a-zA-Z] 條件限制在非小寫a to z或大寫A to Z范圍中一個字符
[^0-9]     條件限制在非小寫0 to 9范圍中一個字符
[^0-9a-z] 條件限制在非小寫0 to 9或a to z范圍中一個字符
[^0-9[a-z]] 條件限制在非小寫0 to 9或a to z范圍中一個字符(交集)

在限制條件為特定字符出現0次以上時,可以使用「*」
J*     0個以上J
.*     0個以上任意字符
J.*D     J與D之間0個以上任意字符

在限制條件為特定字符出現1次以上時,可以使用「+」
J+     1個以上J
.+     1個以上任意字符
J.+D     J與D之間1個以上任意字符

在限制條件為特定字符出現有0或1次以上時,可以使用「?」
JA?     J或者JA出現

限制為連續出現指定次數字符「{a}」
J{2}     JJ
J{3}     JJJ
文字a個以上,并且「{a,}」
J{3,}     JJJ,JJJJ,JJJJJ,???(3次以上J并存)
文字個以上,b個以下「{a,b}」
J{3,5}     JJJ或JJJJ或JJJJJ
兩者取一「|」
J|A     J或A
Java|Hello     Java或Hello
 
「()」中規定一個組合類型
比如,我查詢<a href=\"index.html\">index</a>中<a href></a>間的數據,可寫作<a.*href=\".*\">(.+?)</a>

在使用Pattern.compile函數時,可以加入控制正則表達式的匹配行為的參數:
Pattern Pattern.compile(String regex, int flag)

flag的取值范圍如下:
Pattern.CANON_EQ     當且僅當兩個字符的"正規分解(canonical decomposition)"都完全相同的情況下,才認定匹配。比如用了這個標志之后,表達式"a\u030A"會匹配"?"。默認情況下,不考慮"規 范相等性(canonical equivalence)"。
Pattern.CASE_INSENSITIVE(?i)     默認情況下,大小寫不明感的匹配只適用于US-ASCII字符集。這個標志能讓表達式忽略大小寫進行匹配。要想對Unicode字符進行大小不明感的匹 配,只要將UNICODE_CASE與這個標志合起來就行了。
Pattern.COMMENTS(?x)     在這種模式下,匹配時會忽略(正則表達式里的)空格字符(譯者注:不是指表達式里的"\\s",而是指表達式里的空格,tab,回車之類)。注釋從#開始,一直到這行結束??梢酝ㄟ^嵌入式的標志來啟用Unix行模式。
Pattern.DOTALL(?s)     在這種模式下,表達式'.'可以匹配任意字符,包括表示一行的結束符。默認情況下,表達式'.'不匹配行的結束符。
Pattern.MULTILINE
(?m)     在這種模式下,'^'和'$'分別匹配一行的開始和結束。此外,'^'仍然匹配字符串的開始,'$'也匹配字符串的結束。默認情況下,這兩個表達式僅僅匹配字符串的開始和結束。
Pattern.UNICODE_CASE
(?u)     在這個模式下,如果你還啟用了CASE_INSENSITIVE標志,那么它會對Unicode字符進行大小寫不明感的匹配。默認情況下,大小寫不敏感的匹配只適用于US-ASCII字符集。
Pattern.UNIX_LINES(?d)     在這個模式下,只有'\n'才被認作一行的中止,并且與'.','^',以及'$'進行匹配。


拋開空泛的概念,下面寫出幾個簡單的Java正則用例:

◆比如,在字符串包含驗證時

//查找以Java開頭,任意結尾的字符串
  Pattern pattern = Pattern.compile("^Java.*");
  Matcher matcher = pattern.matcher("Java不是人");
  boolean b= matcher.matches();
  //當條件滿足時,將返回true,否則返回false
  System.out.println(b);


◆以多條件分割字符串時
Pattern pattern = Pattern.compile("[, |]+");
String[] strs = pattern.split("Java Hello World  Java,Hello,,World|Sun");
for (int i=0;i<strs.length;i++) {
    System.out.println(strs[i]);
}

◆文字替換(首次出現字符)
Pattern pattern = Pattern.compile("正則表達式");
Matcher matcher = pattern.matcher("正則表達式 Hello World,正則表達式 Hello World");
//替換第一個符合正則的數據
System.out.println(matcher.replaceFirst("Java"));

◆文字替換(全部)
Pattern pattern = Pattern.compile("正則表達式");
Matcher matcher = pattern.matcher("正則表達式 Hello World,正則表達式 Hello World");
//替換第一個符合正則的數據
System.out.println(matcher.replaceAll("Java"));


◆文字替換(置換字符)
Pattern pattern = Pattern.compile("正則表達式");
Matcher matcher = pattern.matcher("正則表達式 Hello World,正則表達式 Hello World ");
StringBuffer sbr = new StringBuffer();
while (matcher.find()) {
    matcher.appendReplacement(sbr, "Java");
}
matcher.appendTail(sbr);
System.out.println(sbr.toString());

◆驗證是否為郵箱地址

String str="ceponline@yahoo.com.cn";
Pattern pattern = Pattern.compile("[\\w\\.\\-]+@([\\w\\-]+\\.)+[\\w\\-]+",Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(str);
System.out.println(matcher.matches());

◆去除html標記
Pattern pattern = Pattern.compile("<.+?>", Pattern.DOTALL);
Matcher matcher = pattern.matcher("<a href=\"index.html\">主頁</a>");
String string = matcher.replaceAll("");
System.out.println(string);

◆查找html中對應條件字符串
Pattern pattern = Pattern.compile("href=\"(.+?)\"");
Matcher matcher = pattern.matcher("<a href=\"index.html\">主頁</a>");
if(matcher.find())
  System.out.println(matcher.group(1));
}

◆截取http://地址
//截取url
Pattern pattern = Pattern.compile("(http://|https://){1}[\\w\\.\\-/:]+");
Matcher matcher = pattern.matcher("dsdsds<http://dsds//gfgffdfd>fdf");
StringBuffer buffer = new StringBuffer();
while(matcher.find()){             
    buffer.append(matcher.group());       
    buffer.append("\r\n");             
System.out.println(buffer.toString());
}
       
◆替換指定{}中文字

String str = "Java目前的發展史是由{0}年-{1}年";
String[][] object={new String[]{"\\{0\\}","1995"},new String[]{"\\{1\\}","2007"}};
System.out.println(replace(str,object));

public static String replace(final String sourceString,Object[] object) {
            String temp=sourceString;   
            for(int i=0;i<object.length;i++){
                      String[] result=(String[])object[i];
               Pattern    pattern = Pattern.compile(result[0]);
               Matcher matcher = pattern.matcher(temp);
               temp=matcher.replaceAll(result[1]);
            }
            return temp;
}


◆以正則條件查詢指定目錄下文件

 //用于緩存文件列表
        private ArrayList files = new ArrayList();
        //用于承載文件路徑
        private String _path;
        //用于承載未合并的正則公式
        private String _regexp;
       
        class MyFileFilter implements FileFilter {

              /**
               * 匹配文件名稱
               */
              public boolean accept(File file) {
                try {
                  Pattern pattern = Pattern.compile(_regexp);
                  Matcher match = pattern.matcher(file.getName());               
                  return match.matches();
                } catch (Exception e) {
                  return true;
                }
              }
            }
       
        /**
         * 解析輸入流
         * @param inputs
         */
        FilesAnalyze (String path,String regexp){
            getFileName(path,regexp);
        }
       
        /**
         * 分析文件名并加入files
         * @param input
         */
        private void getFileName(String path,String regexp) {
            //目錄
              _path=path;
              _regexp=regexp;
              File directory = new File(_path);
              File[] filesFile = directory.listFiles(new MyFileFilter());
              if (filesFile == null) return;
              for (int j = 0; j < filesFile.length; j++) {
                files.add(filesFile[j]);
              }
              return;
            }
   
        /**
         * 顯示輸出信息
         * @param out
         */
        public void print (PrintStream out) {
            Iterator elements = files.iterator();
            while (elements.hasNext()) {
                File file=(File) elements.next();
                    out.println(file.getPath());   
            }
        }

        public static void output(String path,String regexp) {

            FilesAnalyze fileGroup1 = new FilesAnalyze(path,regexp);
            fileGroup1.print(System.out);
        }
   
        public static void main (String[] args) {
            output("C:\\","[A-z|.]*");
        }

Java正則的功用還有很多,事實上只要是字符處理,就沒有正則做不到的事情存在。(當然,正則解釋時較耗時間就是了|||……)


單飛 2009-12-29 10:34 發表評論
]]>
bitmaphttp://m.tkk7.com/sdyjmc/archive/2009/11/27/303857.html單飛單飛Fri, 27 Nov 2009 02:07:00 GMThttp://m.tkk7.com/sdyjmc/archive/2009/11/27/303857.htmlhttp://m.tkk7.com/sdyjmc/comments/303857.htmlhttp://m.tkk7.com/sdyjmc/archive/2009/11/27/303857.html#Feedback0http://m.tkk7.com/sdyjmc/comments/commentRss/303857.htmlhttp://m.tkk7.com/sdyjmc/services/trackbacks/303857.html

1byte = 8 bit

一比特 bit

4

低四位

R

G

B

R

G

B



單飛 2009-11-27 10:07 發表評論
]]>
Java寫的代理服務器http://m.tkk7.com/sdyjmc/archive/2009/11/25/303607.html單飛單飛Wed, 25 Nov 2009 06:09:00 GMThttp://m.tkk7.com/sdyjmc/archive/2009/11/25/303607.htmlhttp://m.tkk7.com/sdyjmc/comments/303607.htmlhttp://m.tkk7.com/sdyjmc/archive/2009/11/25/303607.html#Feedback0http://m.tkk7.com/sdyjmc/comments/commentRss/303607.htmlhttp://m.tkk7.com/sdyjmc/services/trackbacks/303607.html 2.javanetlib

在看源代碼的時候,看到一個設計簡單的線程池
package cs519.proxy.tpool;

import java.util.*;

/**
 * Thread Pool Manager.
 *
 * Use a fixed number of threads and process requests.
 */
public class ThreadPool
{
    /**
     * @param    nThread
     *        number of threads to create.
     */
    public ThreadPool( int nThread ) {
        for( int i=0; i<nThread; i++ )
            new WorkerThread().start();
    }
    
    /** list of tasks waiting for execution */
    private final List tasks = new LinkedList();
    
    /** list of lower-priority tasks waiting for execution */
    private final List backgroundTasks = new LinkedList();
    
    /**
     * Adds a new 'task' to the pool.
     * Assigned task will be eventually processed by one of the threads
     * in the pool.
     */
    public synchronized void addTask( Runnable task ) {
        tasks.add(task);
        notify();   // notify any thread waiting for a task
    }
    
    /**
     * Adds a new low-priority 'task' to the pool.
     * Assigned task will be eventually processed by one of the threads
     * in the pool.
     */
    public synchronized void addBackgroundTask( Runnable task ) {
        backgroundTasks.add(task);
    }
    
    /**
     * Obtains a task from the queue.
     */
    private synchronized Runnable getTask() {
        while(true) {
            if(!tasks.isEmpty())
                return (Runnable)tasks.remove(0);
            
            if(!backgroundTasks.isEmpty())
                return (Runnable)backgroundTasks.remove(0);
            
            try {
                wait(); // wait for a new task
            } catch( InterruptedException e ) {
                System.err.println("thread interrupted");
                throw new InternalError();
            }
        }
    }

    
    /** destructs the pool. */
    public void dispose() {
        suicideSignal = true;
    }
    private boolean suicideSignal = false;
    
    private class WorkerThread extends Thread {
        public void run() {
            while(!suicideSignal)
                getTask().run();
        }
    }
}

并且提供了緩存管理
package cs519.proxy.cache;

import java.io.*;
import java.util.*;
import java.text.ParseException;
import cs519.proxy.http.*;

public class CacheManagerImpl implements CacheManager
{
    /**
     * Set to non-null to see debug traces.
     */
    private PrintStream debug = System.out;

    /**
     * The number of bytes in the cache.
     * This field is accessed by the Janitor.
     */
    long usedCacheSize = 0;
    
    private Object usedCacheSizeLock = new Object();
        
    /** Atomically modify the value of usedCacheSize. */
    private void modifyUsedCacheSize( long offset ) {
        synchronized(usedCacheSizeLock) {
            usedCacheSize += offset;
        }
    }
        
    private final long cacheLimit;
    protected final TreeMap map=new TreeMap();
    protected final TreeSet fileSet=new TreeSet();
    
    /** The directory in which all cached objects are placed. */
    private final File dir = new File("cache");
    public final File getCacheDir() { return dir; }
    
      
    private final CachePolicy policy;

    /**
     * Constructor:
     *   Load cache file information into CacheFileInfo objects.
     *   Include: filename, lastModified time, file length in byte.
     *   Add these objects to a TreeSet object, make them ordered
     *   by lastModified time.
     *   get current used cache size (in Bytes)
     */
    public CacheManagerImpl(long limit, CachePolicy _policy) throws IOException
    {
        this.policy = _policy;
        this.cacheLimit=limit;  //in bytes

        if(!dir.exists())
            dir.mkdir();
                  
        String[] files=dir.list();

        for(int i=0;i<files.length;i++)
        {
            //System.out.println(files[i].getName());
            File f=new File(dir,files[i]);
            CacheFileInfo cfi = new CacheFileInfo(f);
            fileSet.add(cfi);
            
            map.put( files[i], cfi );
            
            modifyUsedCacheSize(cfi.fsize);
        }
        
        // launch the janitor
        new Thread(new CacheJanitor(this)).start();
    }

  /**
   * Put HttpResponse object into proxy cache.
   * Write HttpResponse to a cache file if it is "toBeCached":
   * 1. use request URL as a base of filename
   * 2. the structure of the cache file contains two parts
   *   a. Request URL (String)
   *   b. HttpResponse object
   */
    public void put( HttpRequest request, HttpResponse response ) {

        long reservedSize;
        
        try {
            
//            if(debug!=null)
//                debug.println("trying to store:"+request.getPath());

            if(policy.toBeCached(request,response))
            {
                
                reservedSize = response.getBodySize()+2000;
                
                // TODO: check if this object fits into the memory
//                if(...)
//                    return;
                
                
                // allocate the space before we actually use it
                modifyUsedCacheSize(reservedSize);
                
                // allocate physical space if it's necessary
                if(!compactCache()) {
            
                    if(debug!=null)
                        debug.println("cache compacting failure:"+request.getPath());
                    
                    // we can't store this object.
                    // cancel this reservation
                    modifyUsedCacheSize(-reservedSize);
                    return;
                }
                
//                if(debug!=null)
//                    debug.println("storing "+request.getPath());

                File f = getCacheFileName(request);
                ObjectOutputStream fileOut=new ObjectOutputStream(
                        new FileOutputStream(f));
                fileOut.writeObject(request.getPath());
                try {
                    fileOut.writeObject(response.getHeaderAsDate("Expires"));
                } catch( java.text.ParseException e ) {
                    fileOut.writeObject(null);  // write a dummy
                }
                fileOut.writeObject(response);
                fileOut.close();
                
                long actualSize = f.length();
                
                synchronized(fileSet) { // use one lock for both objects
                    CacheFileInfo cfi = new CacheFileInfo(f);
                    fileSet.add( cfi );
                    map.put( cfi.fname, cfi );
                }
                
                modifyUsedCacheSize(actualSize-reservedSize);

                if(debug!=null)
                    debug.println("stored  :"+request.getPath());
            }
        } catch( IOException e ) {
            // TODO: possibly return the reservedSize.
            reservedSize=-0;
            modifyUsedCacheSize(reservedSize);
            e.printStackTrace();
            // TODO: remove any corrupted file

        }
    }

    /**
     * Get requested object from proxy cache.
     * if (URL in file)==(request URL), and object not expired, then
     * return object to callee. else return null
     */
    public HttpResponse get( HttpRequest request )
    {
        try {
            File f = getCacheFileName(request);
    
            if(f.exists()) {
                ObjectInputStream oi=new ObjectInputStream(
                                          new FileInputStream(f));
                String fURL=(String)oi.readObject();
                
                if(fURL.equals(request.getPath())) {
                    Date now = new Date();
                    
                    // we won't use it, but we need to read this object
                    // to get to the body
                    Date expires = (Date)oi.readObject();
                
                    // parse the body
                    HttpResponse resp=(HttpResponse)oi.readObject();
                    oi.close();
                    
                    if(debug!=null)
                        debug.println("hit     :"+request.getPath());
                    
                    //check if the object expired
                    try {
                        Date d = resp.getHeaderAsDate("Expires");

                        if(d==null || d.after(now)) {
                            // not expired. use this object.
                            
                            // touch this file for LRU purpose, and
                            // modify fileSet and map content
                            Util.setLastModified(f,now.getTime());
                    
                            // maintain the control data structure
                            synchronized(fileSet) {
                                //remove this object first
                                fileSet.remove(map.get(f.getName()));
                                map.remove(f.getName());
                                
                                //add this object with current attributes
                                CacheFileInfo new_cfi=new CacheFileInfo(f);
                                fileSet.add(new_cfi);
                                map.put(f.getName(),new_cfi);
                            }
                            
                            return resp;
                        }
                    } catch( ParseException e ) { ; }
                    
                    // we'll return null, so the caller will go ahead
                    // and fetch a new one, then store that new object
                    // into the cache.
                    // so we don't need to remove the old item now.
                }
                oi.close();
            }
        } catch( IOException e ) {
            e.printStackTrace();
        } catch( ClassNotFoundException e ) {
            e.printStackTrace();
        }
        if(debug!=null)
            debug.println("miss    :"+request.getPath());
        return null;
    }
    
    public boolean contains( HttpRequest request ) {
        try {
            File f = getCacheFileName(request);
    
            if(!f.exists()) return false;
            
            ObjectInputStream oi=new ObjectInputStream(
                                      new FileInputStream(f));
            String fURL=(String)oi.readObject();
            boolean r = fURL.equals(request.getPath());
            oi.close();
            return r;
        } catch( Exception e ) {
            return false;
        }
    }
    
 
    private File getCacheFileName( HttpRequest msg ) {
        return new File( dir, Integer.toHexString( msg.getPath().hashCode() ) );
    }
 

    /**
     * Compacts the cache so that the total size fell below the limit.
     *
     * @return
     *      true if the operation is successful and our used size is
     *      now lower then the limit.
     */
    public boolean compactCache() {
        synchronized(fileSet) {
            /**
            * Remove LRU cache file until get enough free space
            * LRU strategy
            */
            CacheFileInfo cFile;

            while(cacheLimit<usedCacheSize && !fileSet.isEmpty()) {
                cFile=(CacheFileInfo)fileSet.first();   //the LRU cache file
                
                removeCacheItem(cFile);
            }
            
            return cacheLimit>=usedCacheSize;
        }
    }

    /**
     * Deletes the object represented by a given CacheFileInfo.
     *
     * To remove something from the cache, you need to call this method
     * so that the cache manager can maintain the proper data structure.
     */
    protected void removeCacheItem( CacheFileInfo cfi ) {
        
        synchronized(fileSet) {
            fileSet.remove(cfi);
            map.remove(cfi.fname);
        }
        
        File tmp = new File(dir,"_"+cfi.fname);
        new File(dir,cfi.fname).renameTo(tmp);
        
        if(debug!=null) {
            try {
                // open the file just to print the name of URL
                ObjectInputStream ois = new ObjectInputStream(new FileInputStream(tmp));
                debug.println("delete  :"+ois.readObject());
                ois.close();
            } catch( Exception e ) {
                // it's OK if we fail to print the debug message.
                // so just ignore the error
            }
        }
        
        tmp.delete();
                        
        modifyUsedCacheSize(-cfi.fsize);
    }
}





單飛 2009-11-25 14:09 發表評論
]]>
http 協議http://m.tkk7.com/sdyjmc/archive/2009/11/05/301272.html單飛單飛Thu, 05 Nov 2009 06:45:00 GMThttp://m.tkk7.com/sdyjmc/archive/2009/11/05/301272.htmlhttp://m.tkk7.com/sdyjmc/comments/301272.htmlhttp://m.tkk7.com/sdyjmc/archive/2009/11/05/301272.html#Feedback0http://m.tkk7.com/sdyjmc/comments/commentRss/301272.htmlhttp://m.tkk7.com/sdyjmc/services/trackbacks/301272.html import java.io.IOException; import java.io.In...  閱讀全文

單飛 2009-11-05 14:45 發表評論
]]>
Java執行命令,等待介紹才返回http://m.tkk7.com/sdyjmc/archive/2009/10/30/300391.html單飛單飛Fri, 30 Oct 2009 09:24:00 GMThttp://m.tkk7.com/sdyjmc/archive/2009/10/30/300391.htmlhttp://m.tkk7.com/sdyjmc/comments/300391.htmlhttp://m.tkk7.com/sdyjmc/archive/2009/10/30/300391.html#Feedback0http://m.tkk7.com/sdyjmc/comments/commentRss/300391.htmlhttp://m.tkk7.com/sdyjmc/services/trackbacks/300391.htmlString cmd = "ping 127.0.0.1 -t";
        Runtime rt 
= Runtime.getRuntime();
        System.out.println(
""+cmd );
        Process process 
= rt.exec(cmd );
        InputStream stdin 
= process.getInputStream();
        InputStreamReader isr 
= new InputStreamReader(stdin);
        BufferedReader br 
= new BufferedReader(isr);
        String line;
        StringBuffer buf 
= new StringBuffer();
        
while ((line = br.readLine()) != null) {
            buf.append(line);
            System.out.println(line);
        }
        
int exitVal = process.waitFor();
        System.out.println(
"Process exitValue: " + exitVal);

單飛 2009-10-30 17:24 發表評論
]]>
FeeMarker入門函數 ?exists ${key} ?default('') if assignhttp://m.tkk7.com/sdyjmc/archive/2009/09/21/295854.html單飛單飛Mon, 21 Sep 2009 05:53:00 GMThttp://m.tkk7.com/sdyjmc/archive/2009/09/21/295854.htmlhttp://m.tkk7.com/sdyjmc/comments/295854.htmlhttp://m.tkk7.com/sdyjmc/archive/2009/09/21/295854.html#Feedback0http://m.tkk7.com/sdyjmc/comments/commentRss/295854.htmlhttp://m.tkk7.com/sdyjmc/services/trackbacks/295854.html  <#assign ndex = 1>
<#else>
 <#assign index = 0>
 </#if>
<u>${address?if_exists}</u>
<n>${n?default('')}</n>


單飛 2009-09-21 13:53 發表評論
]]>
java proxy registry ie http://m.tkk7.com/sdyjmc/archive/2009/07/08/285937.html單飛單飛Wed, 08 Jul 2009 05:27:00 GMThttp://m.tkk7.com/sdyjmc/archive/2009/07/08/285937.htmlhttp://m.tkk7.com/sdyjmc/comments/285937.htmlhttp://m.tkk7.com/sdyjmc/archive/2009/07/08/285937.html#Feedback0http://m.tkk7.com/sdyjmc/comments/commentRss/285937.htmlhttp://m.tkk7.com/sdyjmc/services/trackbacks/285937.htmlhttp://www.trustice.com/java/jnireg/index.shtml registry-3.1.3.zip

public
 static void setProxy(String ip, int port) {
        String topKeyName 
= "HKCU";
        String keyName 
= "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings";
        RegistryKey topKey 
= Registry.getTopLevelKey(topKeyName);
        RegistryUtil.setDWordCommand(topKey, keyName, 
"ProxyEnable""1");
        RegistryUtil.setStringCommand(topKey, keyName, 
"ProxyServer", ip + ":" + port);
    }

    
public static boolean isProxy() {
        
try {
            RegistryKey registryKey 
= Registry.openSubkey(Registry.HKEY_CURRENT_USER, "Software\\Microsoft\\Windows\\CurrentVersion\\Internet Settings", RegistryKey.ACCESS_READ);
            RegistryValue registryValue 
= registryKey.getValue("ProxyEnable");
            
boolean proxyEnable = ((RegDWordValue) registryValue).getData() != 0;

            System.out.println(
"IE 是否啟用了代理設置: " + proxyEnable);

            
if (proxyEnable) {
                registryValue 
= registryKey.getValue("ProxyServer");
                System.out.println(
"IE 代理服務器是: " + new String(registryValue.getByteData()));
                
return true;
            }

        } 
catch (NoSuchKeyException ne) {
            ne.printStackTrace();
        } 
catch (RegistryException re) {
            re.printStackTrace();
        }
        
return false;
    }


單飛 2009-07-08 13:27 發表評論
]]>
最近感興趣的技術http://m.tkk7.com/sdyjmc/archive/2009/03/21/261198.html單飛單飛Sat, 21 Mar 2009 06:13:00 GMThttp://m.tkk7.com/sdyjmc/archive/2009/03/21/261198.htmlhttp://m.tkk7.com/sdyjmc/comments/261198.htmlhttp://m.tkk7.com/sdyjmc/archive/2009/03/21/261198.html#Feedback0http://m.tkk7.com/sdyjmc/comments/commentRss/261198.htmlhttp://m.tkk7.com/sdyjmc/services/trackbacks/261198.html 2.bp神經網絡
3.matlab
4.模式識別



單飛 2009-03-21 14:13 發表評論
]]>
Utilhttp://m.tkk7.com/sdyjmc/archive/2009/03/18/260484.html單飛單飛Wed, 18 Mar 2009 07:02:00 GMThttp://m.tkk7.com/sdyjmc/archive/2009/03/18/260484.htmlhttp://m.tkk7.com/sdyjmc/comments/260484.htmlhttp://m.tkk7.com/sdyjmc/archive/2009/03/18/260484.html#Feedback0http://m.tkk7.com/sdyjmc/comments/commentRss/260484.htmlhttp://m.tkk7.com/sdyjmc/services/trackbacks/260484.html    public static String convertRGB2HexString(RGB theRGB...  閱讀全文

單飛 2009-03-18 15:02 發表評論
]]>
【轉】排序算法復習(Java實現)(一): 插入,冒泡,選擇,Shell,快速排序http://m.tkk7.com/sdyjmc/archive/2009/03/09/258519.html單飛單飛Mon, 09 Mar 2009 00:44:00 GMThttp://m.tkk7.com/sdyjmc/archive/2009/03/09/258519.htmlhttp://m.tkk7.com/sdyjmc/comments/258519.htmlhttp://m.tkk7.com/sdyjmc/archive/2009/03/09/258519.html#Feedback0http://m.tkk7.com/sdyjmc/comments/commentRss/258519.htmlhttp://m.tkk7.com/sdyjmc/services/trackbacks/258519.html
package algorithms;

/**
 * 
@author yovn
 *
 
*/
public abstract class Sorter<extends Comparable<E>> {
    
    
public abstract void sort(E[] array,int from ,int len);
    
    
public final void sort(E[] array)
    {
        sort(array,
0,array.length);
    }
    
protected final void swap(E[] array,int from ,int to)
    {
        E tmp
=array[from];
        array[from]
=array[to];
        array[to]
=tmp;
    }

}
一 插入排序
該算法在數據規模小的時候十分高效,該算法每次插入第K+1到前K個有序數組中一個合適位置,K從0開始到N-1,從而完成排序:
package algorithms;
/**
 * 
@author yovn
 
*/
public class InsertSorter<extends Comparable<E>> extends Sorter<E> {

    
/* (non-Javadoc)
     * @see algorithms.Sorter#sort(E[], int, int)
     
*/
    
public void sort(E[] array, int from, int len) {
         E tmp
=null;
          
for(int i=from+1;i<from+len;i++)
          {
              tmp
=array[i];
              
int j=i;
              
for(;j>from;j--)
              {
                  
if(tmp.compareTo(array[j-1])<0)
                  {
                      array[j]
=array[j-1];
                  }
                  
else break;
              }
              array[j]
=tmp;
          }
    }
        
    

}

二 冒泡排序
這可能是最簡單的排序算法了,算法思想是每次從數組末端開始比較相鄰兩元素,把第i小的冒泡到數組的第i個位置。i從0一直到N-1從而完成排序。(當然也可以從數組開始端開始比較相鄰兩元素,把第i大的冒泡到數組的第N-i個位置。i從0一直到N-1從而完成排序。)

package algorithms;

/**
 * 
@author yovn
 *
 
*/
public class BubbleSorter<extends Comparable<E>> extends Sorter<E> {

    
private static  boolean DWON=true;
    
    
public final void bubble_down(E[] array, int from, int len)
    {
        
for(int i=from;i<from+len;i++)
        {
            
for(int j=from+len-1;j>i;j--)
            {
                
if(array[j].compareTo(array[j-1])<0)
                {
                    swap(array,j
-1,j);
                }
            }
        }
    }
    
    
public final void bubble_up(E[] array, int from, int len)
    {
        
for(int i=from+len-1;i>=from;i--)
        {
            
for(int j=from;j<i;j++)
            {
                
if(array[j].compareTo(array[j+1])>0)
                {
                    swap(array,j,j
+1);
                }
            }
        }
    }
    @Override
    
public void sort(E[] array, int from, int len) {
        
        
if(DWON)
        {
            bubble_down(array,from,len);
        }
        
else
        {
            bubble_up(array,from,len);
        }
    }
    
}

三,選擇排序
選擇排序相對于冒泡來說,它不是每次發現逆序都交換,而是在找到全局第i小的時候記下該元素位置,最后跟第i個元素交換,從而保證數組最終的有序。
相對與插入排序來說,選擇排序每次選出的都是全局第i小的,不會調整前i個元素了。
package algorithms;
/**
 * 
@author yovn
 *
 
*/
public class SelectSorter<extends Comparable<E>> extends Sorter<E> {

    
/* (non-Javadoc)
     * @see algorithms.Sorter#sort(E[], int, int)
     
*/
    @Override
    
public void sort(E[] array, int from, int len) {
        
for(int i=0;i<len;i++)
        {
            
int smallest=i;
            
int j=i+from;
            
for(;j<from+len;j++)
            {
                
if(array[j].compareTo(array[smallest])<0)
                {
                    smallest
=j;
                }
            }
            swap(array,i,smallest);
                   
        }

    }
 
}
四 Shell排序
Shell排序可以理解為插入排序的變種,它充分利用了插入排序的兩個特點:
1)當數據規模小的時候非常高效
2)當給定數據已經有序時的時間代價為O(N)
所以,Shell排序每次把數據分成若個小塊,來使用插入排序,而且之后在這若個小塊排好序的情況下把它們合成大一點的小塊,繼續使用插入排序,不停的合并小塊,知道最后成一個塊,并使用插入排序。

這里每次分成若干小塊是通過“增量” 來控制的,開始時增量交大,接近N/2,從而使得分割出來接近N/2個小塊,逐漸的減小“增量“最終到減小到1。

一直較好的增量序列是2^k-1,2^(k-1)-1,.....7,3,1,這樣可使Shell排序時間復雜度達到O(N^1.5)
所以我在實現Shell排序的時候采用該增量序列
package algorithms;

/**
 * 
@author yovn
 
*/
public class ShellSorter<extends Comparable<E>> extends Sorter<E>  {

    
/* (non-Javadoc)
     * Our delta value choose 2^k-1,2^(k-1)-1,.7,3,1.
     * complexity is O(n^1.5)
     * @see algorithms.Sorter#sort(E[], int, int)
     
*/
    @Override
    
public void sort(E[] array, int from, int len) {
        
        
//1.calculate  the first delta value;
        int value=1;
        
while((value+1)*2<len)
        {
            value
=(value+1)*2-1;
        
        }
    
        
for(int delta=value;delta>=1;delta=(delta+1)/2-1)
        {
            
for(int i=0;i<delta;i++)
            {
                modify_insert_sort(array,from
+i,len-i,delta);
            }
        }

    }
    
    
private final  void modify_insert_sort(E[] array, int from, int len,int delta) {
          
if(len<=1)return;
          E tmp
=null;
          
for(int i=from+delta;i<from+len;i+=delta)
          {
              tmp
=array[i];
              
int j=i;
              
for(;j>from;j-=delta)
              {
                  
if(tmp.compareTo(array[j-delta])<0)
                  {
                      array[j]
=array[j-delta];
                  }
                  
else break;
              }
              array[j]
=tmp;
          }

    }
}

五 快速排序
快速排序是目前使用可能最廣泛的排序算法了。
一般分如下步驟:
1)選擇一個樞紐元素(有很對選法,我的實現里采用去中間元素的簡單方法)
2)使用該樞紐元素分割數組,使得比該元素小的元素在它的左邊,比它大的在右邊。并把樞紐元素放在合適的位置。
3)根據樞紐元素最后確定的位置,把數組分成三部分,左邊的,右邊的,樞紐元素自己,對左邊的,右邊的分別遞歸調用快速排序算法即可。
快速排序的核心在于分割算法,也可以說是最有技巧的部分。
package algorithms;

/**
 * 
@author yovn
 *
 
*/
public class QuickSorter<extends Comparable<E>> extends Sorter<E> {

    
/* (non-Javadoc)
     * @see algorithms.Sorter#sort(E[], int, int)
     
*/
    @Override
    
public void sort(E[] array, int from, int len) {
        q_sort(array,from,from
+len-1);
    }

    
    
private final void q_sort(E[] array, int from, int to) {
        
if(to-from<1)return;
        
int pivot=selectPivot(array,from,to);

        
        
        pivot
=partion(array,from,to,pivot);
        
        q_sort(array,from,pivot
-1);
        q_sort(array,pivot
+1,to);
        
    }


    
private int partion(E[] array, int from, int to, int pivot) {
        E tmp
=array[pivot];
        array[pivot]
=array[to];//now to's position is available
        
        
while(from!=to)
        {
            
while(from<to&&array[from].compareTo(tmp)<=0)from++;
            
if(from<to)
            {
                array[to]
=array[from];//now from's position is available
                to--;
            }
            
while(from<to&&array[to].compareTo(tmp)>=0)to--;
            
if(from<to)
            {
                array[from]
=array[to];//now to's position is available now 
                from++;
            }
        }
        array[from]
=tmp;
        
return from;
    }


    
private int selectPivot(E[] array, int from, int to) {
    
        
return (from+to)/2;
    }

}

還有歸并排序,堆排序,桶式排序,基數排序,下次在歸納。

單飛 2009-03-09 08:44 發表評論
]]>
[原創]用泛型實現通用類型數組的操作,eg:刪除http://m.tkk7.com/sdyjmc/archive/2008/09/23/230762.html單飛單飛Tue, 23 Sep 2008 13:44:00 GMThttp://m.tkk7.com/sdyjmc/archive/2008/09/23/230762.htmlhttp://m.tkk7.com/sdyjmc/comments/230762.htmlhttp://m.tkk7.com/sdyjmc/archive/2008/09/23/230762.html#Feedback0http://m.tkk7.com/sdyjmc/comments/commentRss/230762.htmlhttp://m.tkk7.com/sdyjmc/services/trackbacks/230762.html// 用泛型實現通用數組的刪除操作
package test;

import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.List;

public class Test1 {
     
public static <T> T[] deleteArray(T[] items,int index) {
        
if (items == null || items.length == 0 || index < 0
                
|| index > items.length - 1) {
            
return items;
        }
        T[] newItems 
= (T[]) Array.newInstance(items.getClass().getComponentType(), items.length - 1);
        
if(index == 0){
            
// first
            System.arraycopy(items, 1, newItems, 0, newItems.length);    
        }
else if(index == items.length - 1){
            
// end
            System.arraycopy(items, 0, newItems, 0, newItems.length);
        }
else{
            
// middle
            System.arraycopy(items, 0, newItems, 0, index);
            System.arraycopy(items, index
+1, newItems, index, items.length - index -1);            
        }
        
        
return newItems;
        
    }
    
/**
     * 
@param args
     
*/
    
public static void main(String[] args) {
        
// TODO Auto-generated method stub
        
// first
        String[] first = new String[]{"0","1","2"};
        String[] rt 
= deleteArray(first,0);
        printArray(rt);
        
// end
        Integer[] end = new Integer[]{0,1,2};
        Integer[]  rt1 
= deleteArray(end,2);
        printIntegerArray(rt1);
    }
    
    
public static void printArray(String[] array){
        System.out.println(
"start ====================");
        
for(String s:array){
            System.out.println(s);
        }
        System.out.println(
"end ====================");
        
        List
<String> a = new ArrayList<String>();
        
    }
    
    
public static void printIntegerArray(Integer[] array){
        System.out.println(
"start ====================");
        
for(Integer s:array){
            System.out.println(s);
        }
        System.out.println(
"end ====================");
        
        List
<String> a = new ArrayList<String>();
        
    }

}


單飛 2008-09-23 21:44 發表評論
]]>
communication link failure Bad handshakehttp://m.tkk7.com/sdyjmc/archive/2008/07/04/212525.html單飛單飛Fri, 04 Jul 2008 03:13:00 GMThttp://m.tkk7.com/sdyjmc/archive/2008/07/04/212525.htmlhttp://m.tkk7.com/sdyjmc/comments/212525.htmlhttp://m.tkk7.com/sdyjmc/archive/2008/07/04/212525.html#Feedback0http://m.tkk7.com/sdyjmc/comments/commentRss/212525.htmlhttp://m.tkk7.com/sdyjmc/services/trackbacks/212525.html

單飛 2008-07-04 11:13 發表評論
]]>
ClassLoader.getResourceAsStream(name);路徑問題http://m.tkk7.com/sdyjmc/archive/2007/04/26/113766.html單飛單飛Thu, 26 Apr 2007 05:54:00 GMThttp://m.tkk7.com/sdyjmc/archive/2007/04/26/113766.htmlhttp://m.tkk7.com/sdyjmc/comments/113766.htmlhttp://m.tkk7.com/sdyjmc/archive/2007/04/26/113766.html#Feedback0http://m.tkk7.com/sdyjmc/comments/commentRss/113766.htmlhttp://m.tkk7.com/sdyjmc/services/trackbacks/113766.htmlInputStream in = getClass().getResourceAsStream("spring-beans.dtd"); 表示從當前classs下面的路徑找文件
如果是在com.a.b.c.d.Test這個class就表示spring-beans.dtd要放在目錄src\com\a\b\c\d下.

SAXBuilder builder = new SAXBuilder();
            EntityResolver resolver = new EntityResolver() {

                public InputSource resolveEntity(String publicId,
                        String systemId) {
                    if (publicId.equals("-//SPRING//DTD BEAN//EN")) {
                        InputStream in = getClass().getResourceAsStream(
                                '/'+"spring-beans.dtd");
                        return new InputSource(in);
                    } else {
                        return null;
                    }
                }

            };
            builder.setEntityResolver(resolver);

這樣才能解決dtd的本地查找問題.



單飛 2007-04-26 13:54 發表評論
]]>
主站蜘蛛池模板: 久久久久久噜噜精品免费直播| 好吊妞在线新免费视频| 亚洲精品网站在线观看你懂的| 麻豆国产精品入口免费观看| 亚洲免费视频网站| 一级毛片在线免费播放| 亚洲一级免费视频| 亚洲妇熟XXXX妇色黄| www亚洲一级视频com| 色妞WWW精品免费视频| 114级毛片免费观看| 精品视频在线免费观看| 9久热精品免费观看视频| 无码国产精品一区二区免费模式| 国产乱码免费卡1卡二卡3卡| 57pao一国产成永久免费| 日本一道本高清免费| 成人黄页网站免费观看大全| 一二三四在线播放免费观看中文版视频 | 国产高清视频免费在线观看| 国产亚洲精品免费| 亚洲熟女乱色一区二区三区| 亚洲欧洲高清有无| 看成年女人免费午夜视频| 好紧我太爽了视频免费国产| 青青青免费国产在线视频小草| 69pao强力打造免费高清| 在线观看国产情趣免费视频| 国产V亚洲V天堂无码久久久| 亚洲sss综合天堂久久久| 国产成人精品亚洲2020| 国产激情久久久久影院老熟女免费| 亚洲啪啪免费视频| 99久久免费精品国产72精品九九| 亚洲午夜国产片在线观看| 亚洲一级片内射网站在线观看| 亚洲国产成人九九综合| 亚洲区日韩精品中文字幕| 最新亚洲人成无码网www电影| 亚洲aⅴ无码专区在线观看春色 | 亚洲av之男人的天堂网站|