亚洲精品国模,欧美日韩电影一区二区,深夜视频在线免费http://www.aygfsteel.com/sdyjmc/category/17746.html單飛zh-cnFri, 05 Apr 2019 08:19:54 GMTFri, 05 Apr 2019 08:19:54 GMT60微同商城使用私庫解決打包編譯問題http://www.aygfsteel.com/sdyjmc/archive/2019/04/04/433704.html單飛單飛Thu, 04 Apr 2019 01:36:00 GMThttp://www.aygfsteel.com/sdyjmc/archive/2019/04/04/433704.htmlhttp://www.aygfsteel.com/sdyjmc/comments/433704.htmlhttp://www.aygfsteel.com/sdyjmc/archive/2019/04/04/433704.html#Feedback0http://www.aygfsteel.com/sdyjmc/comments/commentRss/433704.htmlhttp://www.aygfsteel.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

解決上傳第二方j(luò)ar文件和下載第二方j(luò)ar文件問題:

<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 上傳和下載第二方j(luò)ar文件
然后使用mvn package 就沒有問題了。


單飛 2019-04-04 09:36 發(fā)表評(píng)論
]]>
hornetq could not obtain connection to any of these urls localhost 1099 jbosshttp://www.aygfsteel.com/sdyjmc/archive/2015/08/05/426607.html單飛單飛Wed, 05 Aug 2015 01:15:00 GMThttp://www.aygfsteel.com/sdyjmc/archive/2015/08/05/426607.htmlhttp://www.aygfsteel.com/sdyjmc/comments/426607.htmlhttp://www.aygfsteel.com/sdyjmc/archive/2015/08/05/426607.html#Feedback2http://www.aygfsteel.com/sdyjmc/comments/commentRss/426607.htmlhttp://www.aygfsteel.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 發(fā)表評(píng)論
]]>
linux 環(huán)境下tomcat啟動(dòng)失敗問題http://www.aygfsteel.com/sdyjmc/archive/2014/12/04/421044.html單飛單飛Thu, 04 Dec 2014 08:37:00 GMThttp://www.aygfsteel.com/sdyjmc/archive/2014/12/04/421044.htmlhttp://www.aygfsteel.com/sdyjmc/comments/421044.htmlhttp://www.aygfsteel.com/sdyjmc/archive/2014/12/04/421044.html#Feedback0http://www.aygfsteel.com/sdyjmc/comments/commentRss/421044.htmlhttp://www.aygfsteel.com/sdyjmc/services/trackbacks/421044.html
嚴(yán)重: 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 存在這個(gè)問題,換成sun jdk

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


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

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

單飛 2013-11-20 17:52 發(fā)表評(píng)論
]]>
監(jiān)控Hornetq消息數(shù)目--monitor hornetq message counthttp://www.aygfsteel.com/sdyjmc/archive/2013/01/25/394779.html單飛單飛Fri, 25 Jan 2013 09:34:00 GMThttp://www.aygfsteel.com/sdyjmc/archive/2013/01/25/394779.htmlhttp://www.aygfsteel.com/sdyjmc/comments/394779.htmlhttp://www.aygfsteel.com/sdyjmc/archive/2013/01/25/394779.html#Feedback0http://www.aygfsteel.com/sdyjmc/comments/commentRss/394779.htmlhttp://www.aygfsteel.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.查看結(jié)果

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 發(fā)表評(píng)論
]]>
velocity 字符串相加http://www.aygfsteel.com/sdyjmc/archive/2012/12/12/392863.html單飛單飛Wed, 12 Dec 2012 06:44:00 GMThttp://www.aygfsteel.com/sdyjmc/archive/2012/12/12/392863.htmlhttp://www.aygfsteel.com/sdyjmc/comments/392863.htmlhttp://www.aygfsteel.com/sdyjmc/archive/2012/12/12/392863.html#Feedback0http://www.aygfsteel.com/sdyjmc/comments/commentRss/392863.htmlhttp://www.aygfsteel.com/sdyjmc/services/trackbacks/392863.html獲取頁面請(qǐng)求基礎(chǔ)地址:

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


單飛 2012-12-12 14:44 發(fā)表評(píng)論
]]>
【原創(chuàng)】系統(tǒng)宕機(jī)導(dǎo)致flare db 因?yàn)榕R時(shí)文件flare.xml 損壞不能啟動(dòng)故障排除記錄http://www.aygfsteel.com/sdyjmc/archive/2012/11/21/391686.html單飛單飛Wed, 21 Nov 2012 02:40:00 GMThttp://www.aygfsteel.com/sdyjmc/archive/2012/11/21/391686.htmlhttp://www.aygfsteel.com/sdyjmc/comments/391686.htmlhttp://www.aygfsteel.com/sdyjmc/archive/2012/11/21/391686.html#Feedback0http://www.aygfsteel.com/sdyjmc/comments/commentRss/391686.htmlhttp://www.aygfsteel.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
總計(jì) 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
 
 
分析日志查詢?yōu)樯镀鸩黄饋怼?br />
[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臨時(shí)目錄文件是否正常
vi /db/flare/tmp/flare.xml
發(fā)現(xiàn)改文件損壞,從備份程序拷貝
cp /opt/flare/tmp/flare.xml /db/flare/tmp/


啟動(dòng)成功


單飛 2012-11-21 10:40 發(fā)表評(píng)論
]]>
Aspose.Words.jdk16.jar ccccccccccccccchttp://www.aygfsteel.com/sdyjmc/archive/2012/11/20/391637.html單飛單飛Tue, 20 Nov 2012 05:52:00 GMThttp://www.aygfsteel.com/sdyjmc/archive/2012/11/20/391637.htmlhttp://www.aygfsteel.com/sdyjmc/comments/391637.htmlhttp://www.aygfsteel.com/sdyjmc/archive/2012/11/20/391637.html#Feedback0http://www.aygfsteel.com/sdyjmc/comments/commentRss/391637.htmlhttp://www.aygfsteel.com/sdyjmc/services/trackbacks/391637.html

單飛 2012-11-20 13:52 發(fā)表評(píng)論
]]>
把字符串第一個(gè)字母大寫http://www.aygfsteel.com/sdyjmc/archive/2012/03/20/372291.html單飛單飛Tue, 20 Mar 2012 09:15:00 GMThttp://www.aygfsteel.com/sdyjmc/archive/2012/03/20/372291.htmlhttp://www.aygfsteel.com/sdyjmc/comments/372291.htmlhttp://www.aygfsteel.com/sdyjmc/archive/2012/03/20/372291.html#Feedback1http://www.aygfsteel.com/sdyjmc/comments/commentRss/372291.htmlhttp://www.aygfsteel.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 發(fā)表評(píng)論
]]>
封裝jre安裝程序http://www.aygfsteel.com/sdyjmc/archive/2010/12/15/340765.html單飛單飛Wed, 15 Dec 2010 03:49:00 GMThttp://www.aygfsteel.com/sdyjmc/archive/2010/12/15/340765.htmlhttp://www.aygfsteel.com/sdyjmc/comments/340765.htmlhttp://www.aygfsteel.com/sdyjmc/archive/2010/12/15/340765.html#Feedback0http://www.aygfsteel.com/sdyjmc/comments/commentRss/340765.htmlhttp://www.aygfsteel.com/sdyjmc/services/trackbacks/340765.html
    permission java.util.PropertyPermission "file.encoding", "read";
所以封裝了一下jre安裝程序
文件準(zhǔn)備:
D:\svn1.3\setup\jre-6u22-windows-i586.exe
D:\svn1.3\setup\java.policy


java.policy

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

使用setupfactory制作安裝腳本:

http://www.aygfsteel.com/Files/sdyjmc/setupJRE.sf7.zip

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


單飛 2010-12-15 11:49 發(fā)表評(píng)論
]]>
applet訪問本地資源,需要修改jre的java.policyhttp://www.aygfsteel.com/sdyjmc/archive/2010/12/14/340674.html單飛單飛Tue, 14 Dec 2010 09:16:00 GMThttp://www.aygfsteel.com/sdyjmc/archive/2010/12/14/340674.htmlhttp://www.aygfsteel.com/sdyjmc/comments/340674.htmlhttp://www.aygfsteel.com/sdyjmc/archive/2010/12/14/340674.html#Feedback0http://www.aygfsteel.com/sdyjmc/comments/commentRss/340674.htmlhttp://www.aygfsteel.com/sdyjmc/services/trackbacks/340674.html 使用 JRE 版本 1.6.0_22-b04 Java HotSpot(TM) Client VM
用戶主目錄 = C:\Documents and Settings\Administrator
----------------------------------------------------
c:   清除控制臺(tái)窗口
f:   終結(jié)在結(jié)束隊(duì)列上的對(duì)象
g:   垃圾收集
h:   顯示此幫助消息
l:   轉(zhuǎn)儲(chǔ)類載入程序列表
m:   打印內(nèi)存使用
o:   觸發(fā)日志記錄
q:   隱藏控制臺(tái)
r:   重新載入策略配置
s:   轉(zhuǎn)儲(chǔ)系統(tǒng)和部署屬性
t:   轉(zhuǎn)儲(chǔ)線程列表
v:   轉(zhuǎn)儲(chǔ)線程堆棧
x:   清除類載入程序高速緩存
0-5: 設(shè)置跟蹤級(jí)別為<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
信息: 總體進(jìn)度: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系統(tǒng)下面會(huì)出現(xiàn)改問題,修改
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 發(fā)表評(píng)論
]]>
Web工程依賴多個(gè)工程,編譯運(yùn)行找不到類問題http://www.aygfsteel.com/sdyjmc/archive/2010/12/09/340115.html單飛單飛Thu, 09 Dec 2010 02:21:00 GMThttp://www.aygfsteel.com/sdyjmc/archive/2010/12/09/340115.htmlhttp://www.aygfsteel.com/sdyjmc/comments/340115.htmlhttp://www.aygfsteel.com/sdyjmc/archive/2010/12/09/340115.html#Feedback0http://www.aygfsteel.com/sdyjmc/comments/commentRss/340115.htmlhttp://www.aygfsteel.com/sdyjmc/services/trackbacks/340115.html 但是使用tomcat調(diào)試的時(shí)候,會(huì)找不到其它工程的class。
在工程名上右擊,選 Properties,找到 Java Build Path,選第二個(gè)選項(xiàng)卡“Projects”,點(diǎn)“Add...”按鈕,
會(huì)彈出“Required Project Selection”框,里面會(huì)出現(xiàn)這個(gè)工作區(qū)中除了當(dāng)前工程之外的其他工程,把需要鏈
接的工程勾選上點(diǎn)“OK”就可以了

右擊工程名,選擇Properties,選擇libraries Tab,點(diǎn)Add External Class Folder...,
選擇你lib工程的目標(biāo)輸出文件夾,添加進(jìn)去應(yīng)該就可以

這樣可以解決多個(gè)依賴工程自動(dòng)輸出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 發(fā)表評(píng)論
]]>
ext3上傳文件為空http://www.aygfsteel.com/sdyjmc/archive/2010/12/04/339783.html單飛單飛Sat, 04 Dec 2010 03:33:00 GMThttp://www.aygfsteel.com/sdyjmc/archive/2010/12/04/339783.htmlhttp://www.aygfsteel.com/sdyjmc/comments/339783.htmlhttp://www.aygfsteel.com/sdyjmc/archive/2010/12/04/339783.html#Feedback0http://www.aygfsteel.com/sdyjmc/comments/commentRss/339783.htmlhttp://www.aygfsteel.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',
                    //實(shí)現(xiàn)非AJAX提交表單一定要加下面的兩行!
                    onSubmit: Ext.emptyFn,
                    method:'POST',
                    align:'center',// 組件居左布局,還有right和center兩個(gè)值可以選擇
                    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");// 初始化上傳文件的臨時(shí)寄放目錄
        String uploadPath = getServletContext().getRealPath("/upload");// 初始化上傳文件后的保存
        try {
            if (ServletFileUpload.isMultipartContent(request)) {
                 DiskFileItemFactory factory = new DiskFileItemFactory();
                 //指定在內(nèi)存中緩存數(shù)據(jù)大小,單位為byte,這里設(shè)為1Mb  
                factory.setSizeThreshold(1 * 1024 * 1024);   
                //設(shè)置一旦文件大小超過getSizeThreshold()的值時(shí)數(shù)據(jù)存放在硬盤的目錄  
                factory.setRepository(new File(tmpDir));   
                ServletFileUpload sfu = new ServletFileUpload(factory);  
                 // 指定單個(gè)上傳文件的最大尺寸,單位:字節(jié),這里設(shè)為5Mb  
                sfu.setFileSizeMax(100 * 1024 * 1024);  
                //指定一次上傳多個(gè)文件的總尺寸,單位:字節(jié),這里設(shè)為10Mb  
                sfu.setSizeMax(100 * 1024 * 1024);   
                sfu.setHeaderEncoding("UTF-8"); //設(shè)置編碼,因?yàn)槲业膉sp頁面的編碼是utf-8的  
                FileItemIterator fii = sfu.getItemIterator(request);// 解析request請(qǐng)求  
                uploadPath = uploadPath + "\\jbpm\\"; // 選定上傳的目錄此處為當(dāng)前目錄  
                if (!new File(uploadPath).isDirectory()){  
                    new File(uploadPath).mkdirs(); //選定上傳的目錄此處為當(dāng)前目錄,沒有則創(chuàng)建  
                }  
                  
                int index = 0;  
                while (fii.hasNext()) {  
                    FileItemStream fis = fii.next();// 從集合中獲得一個(gè)文件流  
                    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}");
    }

上傳文件為空:因?yàn)椋?br />     <filter-mapping>
        <!--攔截所有的URL請(qǐng)求-->
        <filter-name>struts2</filter-name>
        <!--上傳文件會(huì)不起作用-->
        <!-- url-pattern>/*</url-pattern -->
        <url-pattern>*.action</url-pattern>
    </filter-mapping>

原因就是因?yàn)樵趙eb.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 發(fā)表評(píng)論
]]>
求救:jbpm4.3部署到weblogic報(bào)錯(cuò)http://www.aygfsteel.com/sdyjmc/archive/2010/11/24/338973.html單飛單飛Wed, 24 Nov 2010 12:56:00 GMThttp://www.aygfsteel.com/sdyjmc/archive/2010/11/24/338973.htmlhttp://www.aygfsteel.com/sdyjmc/comments/338973.htmlhttp://www.aygfsteel.com/sdyjmc/archive/2010/11/24/338973.html#Feedback1http://www.aygfsteel.com/sdyjmc/comments/commentRss/338973.htmlhttp://www.aygfsteel.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時(shí)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時(shí)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時(shí)13分23秒 CST> <Warning> <Deployer> <BEA-149004> <Failures we
re detected while initiating deploy task for application 'oa'.>
<2010-11-24 下午08時(shí)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時(shí)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時(shí)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 發(fā)表評(píng)論
]]>
分析引用的jar文件是否有用http://www.aygfsteel.com/sdyjmc/archive/2010/08/30/330274.html單飛單飛Mon, 30 Aug 2010 06:02:00 GMThttp://www.aygfsteel.com/sdyjmc/archive/2010/08/30/330274.htmlhttp://www.aygfsteel.com/sdyjmc/comments/330274.htmlhttp://www.aygfsteel.com/sdyjmc/archive/2010/08/30/330274.html#Feedback0http://www.aygfsteel.com/sdyjmc/comments/commentRss/330274.htmlhttp://www.aygfsteel.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 發(fā)表評(píng)論
]]>
[轉(zhuǎn)] 如何把JAVA工程生成一個(gè).JAR文件,而不是一堆JAR(ECLIPSE生成JAR) http://www.aygfsteel.com/sdyjmc/archive/2010/02/04/311945.html單飛單飛Thu, 04 Feb 2010 05:58:00 GMThttp://www.aygfsteel.com/sdyjmc/archive/2010/02/04/311945.htmlhttp://www.aygfsteel.com/sdyjmc/comments/311945.htmlhttp://www.aygfsteel.com/sdyjmc/archive/2010/02/04/311945.html#Feedback0http://www.aygfsteel.com/sdyjmc/comments/commentRss/311945.htmlhttp://www.aygfsteel.com/sdyjmc/services/trackbacks/311945.html

我現(xiàn)在在編寫一個(gè)JAVA工程,是提供給客戶調(diào)用的API,但是我的API中大約需要依賴10個(gè).JAR,

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

現(xiàn)在找到了,使用ECLIPSE3.4的EXPORT Runnable JAR file功能導(dǎo)出的JAR就是包含了依賴的JAR,導(dǎo)入這一個(gè)JAR就可以了,具體操作如下,

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

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

3. 選擇 Run configurations

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

5. 點(diǎn)擊RUN

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

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

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

     第二個(gè)窗口中選擇你要導(dǎo)出的路徑

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




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

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

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





但是我們?nèi)绻獙?duì)多個(gè)字符進(jìn)行重復(fù)怎么辦呢?此時(shí)我們就要用到分組,我們可以使用小括號(hào)"()"來指定要重復(fù)的子表達(dá)式,然后對(duì)這個(gè)子表達(dá)式進(jìn)行重復(fù),例如:(abc)? 表示0個(gè)或1個(gè)abc 這里一個(gè)括號(hào)的表達(dá)式就表示一個(gè)分組。



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



捕獲組

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

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

組零始終代表整個(gè)表達(dá)式

之所以這樣命名捕獲組是因?yàn)樵谄ヅ渲校4媪伺c這些組匹配的輸入序列的每個(gè)子序列。捕獲的子序列稍后可以通過 Back 引用在表達(dá)式中使用,也可以在匹配操作完成后從匹配器檢索。



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



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



非捕獲組

      以 (?) 開頭的組是純的非捕獲 組,它不捕獲文本,也不針對(duì)組合計(jì)進(jìn)行計(jì)數(shù)。就是說,如果小括號(hào)中以?號(hào)開頭,那么這個(gè)分組就不會(huì)捕獲文本,當(dāng)然也不會(huì)有組的編號(hào),因此也不存在Back 引用。

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

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




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

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






舉例:



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

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



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



        例如這里就只有3434這個(gè)數(shù)字滿足要求。那么我們?cè)趺刺崛∧兀?

       首先我們寫出提取這個(gè)字符串的表達(dá)式: (?<!c)a("d+)bd  這里就只有一個(gè)捕獲組("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的數(shù)字即可。結(jié)果 3434
   System.out.println(m.group(0)); // 0組是整個(gè)表達(dá)式,看這里,并沒有提煉出(?<!c)的字符 。結(jié)果 a3434bd
}
    可以看到,非捕獲組,最后是不會(huì)返回結(jié)果的,因?yàn)樗旧聿⒉徊东@文本。



正則表達(dá)式功能其實(shí)非常強(qiáng)大,這里只是對(duì)高級(jí)用法的簡單探討。有興趣的朋友和本人共同討論。

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

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

^為限制開頭
^java     條件限制為以Java為開頭字符
$為限制結(jié)尾
java$     條件限制為以java為結(jié)尾字符
.  條件限制除\n以外任意一個(gè)單獨(dú)字符
java..     條件限制為java后除換行外任意兩個(gè)字符


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

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

在限制條件為特定字符出現(xiàn)0次以上時(shí),可以使用「*」
J*     0個(gè)以上J
.*     0個(gè)以上任意字符
J.*D     J與D之間0個(gè)以上任意字符

在限制條件為特定字符出現(xiàn)1次以上時(shí),可以使用「+」
J+     1個(gè)以上J
.+     1個(gè)以上任意字符
J.+D     J與D之間1個(gè)以上任意字符

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

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

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

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


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

◆比如,在字符串包含驗(yàn)證時(shí)

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


◆以多條件分割字符串時(shí)
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]);
}

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

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


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

◆驗(yàn)證是否為郵箱地址

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標(biāo)記
Pattern pattern = Pattern.compile("<.+?>", Pattern.DOTALL);
Matcher matcher = pattern.matcher("<a href=\"index.html\">主頁</a>");
String string = matcher.replaceAll("");
System.out.println(string);

◆查找html中對(duì)應(yīng)條件字符串
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目前的發(fā)展史是由{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正則的功用還有很多,事實(shí)上只要是字符處理,就沒有正則做不到的事情存在。(當(dāng)然,正則解釋時(shí)較耗時(shí)間就是了|||……)


單飛 2009-12-29 10:34 發(fā)表評(píng)論
]]>
bitmaphttp://www.aygfsteel.com/sdyjmc/archive/2009/11/27/303857.html單飛單飛Fri, 27 Nov 2009 02:07:00 GMThttp://www.aygfsteel.com/sdyjmc/archive/2009/11/27/303857.htmlhttp://www.aygfsteel.com/sdyjmc/comments/303857.htmlhttp://www.aygfsteel.com/sdyjmc/archive/2009/11/27/303857.html#Feedback0http://www.aygfsteel.com/sdyjmc/comments/commentRss/303857.htmlhttp://www.aygfsteel.com/sdyjmc/services/trackbacks/303857.html

1byte = 8 bit

一比特 bit

4

低四位

R

G

B

R

G

B



單飛 2009-11-27 10:07 發(fā)表評(píng)論
]]>
Java寫的代理服務(wù)器http://www.aygfsteel.com/sdyjmc/archive/2009/11/25/303607.html單飛單飛Wed, 25 Nov 2009 06:09:00 GMThttp://www.aygfsteel.com/sdyjmc/archive/2009/11/25/303607.htmlhttp://www.aygfsteel.com/sdyjmc/comments/303607.htmlhttp://www.aygfsteel.com/sdyjmc/archive/2009/11/25/303607.html#Feedback0http://www.aygfsteel.com/sdyjmc/comments/commentRss/303607.htmlhttp://www.aygfsteel.com/sdyjmc/services/trackbacks/303607.html 2.javanetlib

在看源代碼的時(shí)候,看到一個(gè)設(shè)計(jì)簡單的線程池
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 發(fā)表評(píng)論
]]>
http 協(xié)議http://www.aygfsteel.com/sdyjmc/archive/2009/11/05/301272.html單飛單飛Thu, 05 Nov 2009 06:45:00 GMThttp://www.aygfsteel.com/sdyjmc/archive/2009/11/05/301272.htmlhttp://www.aygfsteel.com/sdyjmc/comments/301272.htmlhttp://www.aygfsteel.com/sdyjmc/archive/2009/11/05/301272.html#Feedback0http://www.aygfsteel.com/sdyjmc/comments/commentRss/301272.htmlhttp://www.aygfsteel.com/sdyjmc/services/trackbacks/301272.html import java.io.IOException; import java.io.In...  閱讀全文

單飛 2009-11-05 14:45 發(fā)表評(píng)論
]]>
Java執(zhí)行命令,等待介紹才返回http://www.aygfsteel.com/sdyjmc/archive/2009/10/30/300391.html單飛單飛Fri, 30 Oct 2009 09:24:00 GMThttp://www.aygfsteel.com/sdyjmc/archive/2009/10/30/300391.htmlhttp://www.aygfsteel.com/sdyjmc/comments/300391.htmlhttp://www.aygfsteel.com/sdyjmc/archive/2009/10/30/300391.html#Feedback0http://www.aygfsteel.com/sdyjmc/comments/commentRss/300391.htmlhttp://www.aygfsteel.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 發(fā)表評(píng)論
]]>
FeeMarker入門函數(shù) ?exists ${key} ?default('') if assignhttp://www.aygfsteel.com/sdyjmc/archive/2009/09/21/295854.html單飛單飛Mon, 21 Sep 2009 05:53:00 GMThttp://www.aygfsteel.com/sdyjmc/archive/2009/09/21/295854.htmlhttp://www.aygfsteel.com/sdyjmc/comments/295854.htmlhttp://www.aygfsteel.com/sdyjmc/archive/2009/09/21/295854.html#Feedback0http://www.aygfsteel.com/sdyjmc/comments/commentRss/295854.htmlhttp://www.aygfsteel.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 發(fā)表評(píng)論
]]>
java proxy registry ie http://www.aygfsteel.com/sdyjmc/archive/2009/07/08/285937.html單飛單飛Wed, 08 Jul 2009 05:27:00 GMThttp://www.aygfsteel.com/sdyjmc/archive/2009/07/08/285937.htmlhttp://www.aygfsteel.com/sdyjmc/comments/285937.htmlhttp://www.aygfsteel.com/sdyjmc/archive/2009/07/08/285937.html#Feedback0http://www.aygfsteel.com/sdyjmc/comments/commentRss/285937.htmlhttp://www.aygfsteel.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 是否啟用了代理設(shè)置: " + proxyEnable);

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

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


單飛 2009-07-08 13:27 發(fā)表評(píng)論
]]>
最近感興趣的技術(shù)http://www.aygfsteel.com/sdyjmc/archive/2009/03/21/261198.html單飛單飛Sat, 21 Mar 2009 06:13:00 GMThttp://www.aygfsteel.com/sdyjmc/archive/2009/03/21/261198.htmlhttp://www.aygfsteel.com/sdyjmc/comments/261198.htmlhttp://www.aygfsteel.com/sdyjmc/archive/2009/03/21/261198.html#Feedback0http://www.aygfsteel.com/sdyjmc/comments/commentRss/261198.htmlhttp://www.aygfsteel.com/sdyjmc/services/trackbacks/261198.html 2.bp神經(jīng)網(wǎng)絡(luò)
3.matlab
4.模式識(shí)別



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

單飛 2009-03-18 15:02 發(fā)表評(píng)論
]]>
【轉(zhuǎn)】排序算法復(fù)習(xí)(Java實(shí)現(xiàn))(一): 插入,冒泡,選擇,Shell,快速排序http://www.aygfsteel.com/sdyjmc/archive/2009/03/09/258519.html單飛單飛Mon, 09 Mar 2009 00:44:00 GMThttp://www.aygfsteel.com/sdyjmc/archive/2009/03/09/258519.htmlhttp://www.aygfsteel.com/sdyjmc/comments/258519.htmlhttp://www.aygfsteel.com/sdyjmc/archive/2009/03/09/258519.html#Feedback0http://www.aygfsteel.com/sdyjmc/comments/commentRss/258519.htmlhttp://www.aygfsteel.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;
    }

}
一 插入排序
該算法在數(shù)據(jù)規(guī)模小的時(shí)候十分高效,該算法每次插入第K+1到前K個(gè)有序數(shù)組中一個(gè)合適位置,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;
          }
    }
        
    

}

二 冒泡排序
這可能是最簡單的排序算法了,算法思想是每次從數(shù)組末端開始比較相鄰兩元素,把第i小的冒泡到數(shù)組的第i個(gè)位置。i從0一直到N-1從而完成排序。(當(dāng)然也可以從數(shù)組開始端開始比較相鄰兩元素,把第i大的冒泡到數(shù)組的第N-i個(gè)位置。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);
        }
    }
    
}

三,選擇排序
選擇排序相對(duì)于冒泡來說,它不是每次發(fā)現(xiàn)逆序都交換,而是在找到全局第i小的時(shí)候記下該元素位置,最后跟第i個(gè)元素交換,從而保證數(shù)組最終的有序。
相對(duì)與插入排序來說,選擇排序每次選出的都是全局第i小的,不會(huì)調(diào)整前i個(gè)元素了。
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排序可以理解為插入排序的變種,它充分利用了插入排序的兩個(gè)特點(diǎn):
1)當(dāng)數(shù)據(jù)規(guī)模小的時(shí)候非常高效
2)當(dāng)給定數(shù)據(jù)已經(jīng)有序時(shí)的時(shí)間代價(jià)為O(N)
所以,Shell排序每次把數(shù)據(jù)分成若個(gè)小塊,來使用插入排序,而且之后在這若個(gè)小塊排好序的情況下把它們合成大一點(diǎn)的小塊,繼續(xù)使用插入排序,不停的合并小塊,知道最后成一個(gè)塊,并使用插入排序。

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

一直較好的增量序列是2^k-1,2^(k-1)-1,.....7,3,1,這樣可使Shell排序時(shí)間復(fù)雜度達(dá)到O(N^1.5)
所以我在實(shí)現(xiàn)Shell排序的時(shí)候采用該增量序列
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)選擇一個(gè)樞紐元素(有很對(duì)選法,我的實(shí)現(xiàn)里采用去中間元素的簡單方法)
2)使用該樞紐元素分割數(shù)組,使得比該元素小的元素在它的左邊,比它大的在右邊。并把樞紐元素放在合適的位置。
3)根據(jù)樞紐元素最后確定的位置,把數(shù)組分成三部分,左邊的,右邊的,樞紐元素自己,對(duì)左邊的,右邊的分別遞歸調(diào)用快速排序算法即可。
快速排序的核心在于分割算法,也可以說是最有技巧的部分。
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;
    }

}

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

單飛 2009-03-09 08:44 發(fā)表評(píng)論
]]>
[原創(chuàng)]用泛型實(shí)現(xiàn)通用類型數(shù)組的操作,eg:刪除http://www.aygfsteel.com/sdyjmc/archive/2008/09/23/230762.html單飛單飛Tue, 23 Sep 2008 13:44:00 GMThttp://www.aygfsteel.com/sdyjmc/archive/2008/09/23/230762.htmlhttp://www.aygfsteel.com/sdyjmc/comments/230762.htmlhttp://www.aygfsteel.com/sdyjmc/archive/2008/09/23/230762.html#Feedback0http://www.aygfsteel.com/sdyjmc/comments/commentRss/230762.htmlhttp://www.aygfsteel.com/sdyjmc/services/trackbacks/230762.html// 用泛型實(shí)現(xiàn)通用數(shù)組的刪除操作
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 發(fā)表評(píng)論
]]>
communication link failure Bad handshakehttp://www.aygfsteel.com/sdyjmc/archive/2008/07/04/212525.html單飛單飛Fri, 04 Jul 2008 03:13:00 GMThttp://www.aygfsteel.com/sdyjmc/archive/2008/07/04/212525.htmlhttp://www.aygfsteel.com/sdyjmc/comments/212525.htmlhttp://www.aygfsteel.com/sdyjmc/archive/2008/07/04/212525.html#Feedback0http://www.aygfsteel.com/sdyjmc/comments/commentRss/212525.htmlhttp://www.aygfsteel.com/sdyjmc/services/trackbacks/212525.html

單飛 2008-07-04 11:13 發(fā)表評(píng)論
]]>
ClassLoader.getResourceAsStream(name);路徑問題http://www.aygfsteel.com/sdyjmc/archive/2007/04/26/113766.html單飛單飛Thu, 26 Apr 2007 05:54:00 GMThttp://www.aygfsteel.com/sdyjmc/archive/2007/04/26/113766.htmlhttp://www.aygfsteel.com/sdyjmc/comments/113766.htmlhttp://www.aygfsteel.com/sdyjmc/archive/2007/04/26/113766.html#Feedback0http://www.aygfsteel.com/sdyjmc/comments/commentRss/113766.htmlhttp://www.aygfsteel.com/sdyjmc/services/trackbacks/113766.htmlInputStream in = getClass().getResourceAsStream("spring-beans.dtd"); 表示從當(dāng)前classs下面的路徑找文件
如果是在com.a.b.c.d.Test這個(gè)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 發(fā)表評(píng)論
]]>
主站蜘蛛池模板: 南召县| 逊克县| 荔波县| 金溪县| 德兴市| 达拉特旗| 固始县| 浦东新区| 凌云县| 通渭县| 葫芦岛市| 黎平县| 聂荣县| 太保市| 乐东| 饶平县| 九龙坡区| 荣昌县| 肇庆市| 金山区| 旬阳县| 石屏县| 临夏市| 新密市| 太湖县| 顺义区| 石屏县| 吕梁市| 庆城县| 濮阳县| 盘锦市| 宁南县| 海盐县| 平安县| 咸阳市| 建平县| 中超| 丰县| 宜州市| 丰城市| 临颍县|