<rt id="bn8ez"></rt>
<label id="bn8ez"></label>

  • <span id="bn8ez"></span>

    <label id="bn8ez"><meter id="bn8ez"></meter></label>

    破門點滴(Java技術版)

    在日常學習和工作中記錄

      BlogJava :: 首頁 ::  :: 聚合  :: 管理
      15 Posts :: 7 Stories :: 36 Comments :: 0 Trackbacks
    發表于 2004-12-26 18:59:04

    ?思路:

    1、將URL對象中的factory對象擴展為一個factorysHashtable對象,將setURLStreamHandlerFactory的調用修改為將新的factory對象放入列表。

    2、創建Handler時則遍歷factorys列表,按照注冊的先后順序調用factory對象嘗試創建Handler對象。

    ?

    實際解決方案:

    通過java自帶的源代碼包找出 java.net.URL對象,做如下修改:

    1、增加 factorys 列表屬性

    static Hashtable factorys = new Hashtable();

    …..

    ?

    2、修改 setURLStreamHandlerFactory() 方法

    public static void setURLStreamHandlerFactory(URLStreamHandlerFactory fac) {

    ?????? synchronized (streamHandlerLock) {

    ????????????? // 為了支持多Factory

    //???? ??? if (factory != null) {

    //??????????? throw new Error("factory already defined");

    //???? ??? }

    ????????????? …..

    ?????? ??? factory = fac;

    ?????? ??? // factory 放入列表

    ?????? ??? factorys.put(Integer.toString(factorys.size()), fac);

    ?????? }

    ??? }

    1、? 增加createURLStreamHandler 私有方法,通過Factory列表創建Handler

    ?????? private static URLStreamHandler createURLStreamHandler(String protocol) {

    ????????????? for (int i=0; i < factorys.size(); i++) {

    ???????????????????? factory = (URLStreamHandlerFactory) factorys.get(Integer.toString(i));

    ???????????????????? URLStreamHandler handler = factory.createURLStreamHandler(protocol);

    ???????????????????? if (handler != null) {

    ??????????????????????????? return handler;

    ???????????????????? }

    ????????????? }

    ????????????? return null;

    ?????? }

    2、? 修改getURLStreamHandler中獲取Handler的方法

    …..

    ?????? ??? // Use the factory (if any)

    //???? ??? if (factory != null) {

    //??????????? handler = factory.createURLStreamHandler(protocol);

    //??????????? checkedWithFactory = true;

    //???? ??? }

    ?????? ??? // 使用factory列表

    ?????? ??? if (factorys != null) {

    ?????? ??? ?????? handler = createURLStreamHandler(protocol);

    ?????? ??? ?????? checkedWithFactory = true;

    ?????? ??? }

    ????????????? ……

    ?

    ????????????? // Check with factory if another thread set a

    ????????????? // factory since our last check

    //??????????? if (!checkedWithFactory && factory != null) {

    //??????????? ??? handler2 = factory.createURLStreamHandler(protocol);

    //??????????? }

    ????????????? if (!checkedWithFactory && factorys != null) {

    ????????????? ??? handler2 = createURLStreamHandler(protocol);

    ????????????? }

    ?

    3、? 編譯修改后的URL類,將URL.class 替換 rt.jar 包中的原始類文件。

    ?

    替換rt.jar的具體方法:

    a)?????? zip工具(或jar工具)將rt.jar文件解開到一個目錄(假設為rt

    b)????? 替換 rt/java/net/URL.class 文件為新類文件

    c)????? rt 目錄下運行命令 jar cvf0M rt.jar . 生成 rt.jar 文件

    d)????? 將新生成的 rt.jar 文件覆蓋原始的JRE中的 rt.jar 文件


    ?

    至此,以上ava.lang.Error: factory already defined問題解決。



    Triones Runtime: 新的JRE下,Triones web系統運行的輸出結果

    2004-12-26 1:10:07 org.apache.coyote.http11.Http11Protocol init

    信息 : Initializing Coyote HTTP/1.1 on http-8886

    2004-12-26 1:10:07 org.apache.catalina.startup.Catalina load

    信息 : Initialization processed in 1121 ms

    2004-12-26 1:10:07 org.apache.catalina.core.StandardService start

    信息 : Starting service Tomcat-Standalone

    2004-12-26 1:10:07 org.apache.catalina.core.StandardEngine start

    信息 : Starting Servlet Engine: Apache Tomcat/5.0.28

    2004-12-26 1:10:07 org.apache.catalina.core.StandardHost start

    信息 : XML validation disabled

    [ ] 這里是 Triones(Eclipse) 開始啟動

    Configuration file:

    ??? file:/D:/netshop/configuration/config.ini not found or not read

    Configuration location:

    ??? file:/D:/netshop/triones/configuration/

    Configuration file:

    ??? file:/D:/netshop/triones/configuration/config.ini loaded

    Shared configuration location:

    ??? file:/D:/netshop/configuration/

    Triones Framework located:

    ??? file:/D:/netshop/triones/plugins/org.softme.triones.runtime_0.0.1/

    Framework located:

    ??? file:/D:/netshop/triones/plugins/org.eclipse.osgi_3.1.0/

    Loading framework classpath from:

    ??? file:/D:/netshop/triones/plugins/org.eclipse.osgi_3.1.0/eclipse.properties

    Framework classpath:

    ??? file:/D:/netshop/triones/plugins/org.eclipse.osgi_3.1.0/core.jar

    ??? file:/D:/netshop/triones/plugins/org.eclipse.osgi_3.1.0/console.jar

    ??? file:/D:/netshop/triones/plugins/org.eclipse.osgi_3.1.0/osgi.jar

    ??? file:/D:/netshop/triones/plugins/org.eclipse.osgi_3.1.0/resolver.jar

    ??? file:/D:/netshop/triones/plugins/org.eclipse.osgi_3.1.0/defaultAdaptor.jar

    ??? file:/D:/netshop/triones/plugins/org.eclipse.osgi_3.1.0/eclipseAdaptor.jar

    Debug options:

    ??? file:/D:/DevEnv/eclipse/.options not found

    Time to load bundles: 30

    !SESSION 2004-12-26 01:10:09.697 -----------------------------------------------

    eclipse.buildId=M200409161125

    java.version=1.4.2

    java.vendor=Sun Microsystems Inc.

    BootLoader constants: OS=win32, ARCH=x86, WS=win32, NL=zh_CN

    Command-line arguments: -nosplash -refresh

    [ ] 這里是 Triones Framework (Runtime) 開始運行

    Starting application: 1563

    ------------------------------------

    Triones Framework: Started!

    Triones Framework: Hello!

    2004-12-26 1:10:10 org.apache.catalina.core.StandardHost getDeployer

    信息 : Create Host deployer for direct deployment ( non-jmx )

    2004-12-26 1:10:10 org.apache.coyote.http11.Http11Protocol start

    信息 : Starting Coyote HTTP/1.1 on http-8886

    2004-12-26 1:10:10 org.apache.catalina.startup.Catalina start

    信息 : Server startup in 2634 ms

    [ ] 這里是 Triones Framework (System Job) 開始運行, Tomcat 已經啟動完畢。

    Triones Job: begin...

    Triones Job: idle-0

    Triones Job: idle-1

    Triones Job: done.

    [ ] 這里是 Triones Framework (Runtime) 開始響應 web 請求,加載 Runtime 的控制器

    [URL]http://localhost:8886/netshop/

    LoadControllers(): found extentions - 1

    LoadControllers(): namespace - org.softme.triones.runtime.

    LoadControllers(): config size- 3

    LoadController:-org.softme.triones.controller.DefaultServletController@d0220c

    LoadController:-org.softme.triones.controller.DefaultActionController@1a19458

    LoadController:-org.softme.triones.controller.DefaultViewController@383118

    [ ] 這里是 Triones Framework (Runtime) 根據請求訪問指定的插件

    URL http://localhost:8886/netshop/triones/view/org.softme.triones.hello/hello.html

    update@/D:/netshop/triones/plugins/org.softme.triones.hello_0.0.1/ [7]

    hello.html

    file:/D:/netshop/triones/plugins/org.softme.triones.hello_0.0.1/hello.html

    [ ] 這里 Tomcat 開始關閉

    2004-12-26 1:10:49 org.apache.coyote.http11.Http11Protocol pause

    信息 : Pausing Coyote HTTP/1.1 on http-8886

    2004-12-26 1:10:50 org.apache.catalina.core.StandardService stop

    信息 : Stopping service Tomcat-Standalone

    2004-12-26 1:10:50 org.apache.catalina.core.StandardHostDeployer remove

    [ ] 這里是 Tomcat 關閉 Triones Framework 支持的應用 (netshop)

    信息 : Removing web application at context path /netshop

    [ ] 這里是 Triones Framework (Runtime) 關閉

    Triones Framework: Stoped!

    ------------------------------------

    2004-12-26 1:10:50 org.apache.catalina.logger.LoggerBase stop

    信息 : unregistering logger Standalone:type=Logger,host=localhost

    2004-12-26 1:10:50 org.apache.catalina.logger.LoggerBase stop

    信息 : unregistering logger Standalone:type=Logger

    2004-12-26 1:10:50 org.apache.coyote.http11.Http11Protocol destroy

    信息 : Stopping Coyote HTTP/1.1 on http-8886

    [ ] Tomcat 正常退出



    不得窺道門,不得悟佛門,不得入窄門,實乃破門。
    posted on 2006-03-27 10:30 破門 閱讀(708) 評論(0)  編輯  收藏 所屬分類: Triones
    主站蜘蛛池模板: 亚洲av无码专区在线观看素人| 99视频全部免费精品全部四虎| 日韩一级在线播放免费观看| 亚洲日本国产综合高清| 亚洲人成免费电影| 亚洲剧场午夜在线观看| 成人免费毛片内射美女APP| 亚洲日韩中文字幕无码一区| 最近中文字幕免费mv视频8| 亚洲日韩亚洲另类激情文学| 成人啪精品视频免费网站| 亚洲av日韩专区在线观看| 全亚洲最新黄色特级网站 | 亚洲成色在线综合网站| 99视频在线免费| 国产日本亚洲一区二区三区| 成年人免费观看视频网站| 亚洲国产美女精品久久久| 国产亚洲福利一区二区免费看| 老司机午夜在线视频免费| 一本色道久久综合亚洲精品高清| 一级做受视频免费是看美女| 亚洲精品无码成人片久久| 99爱在线观看免费完整版| 国产精品亚洲综合五月天| 性做久久久久免费观看| 一级做受视频免费是看美女| 亚洲成a人片77777老司机| 男人的好免费观看在线视频| 特级毛片免费播放| 亚洲精品国产成人片| 四虎最新永久免费视频| 婷婷亚洲综合五月天小说在线 | 久久精品国产亚洲av麻| 久久国内免费视频| 日韩免费高清一级毛片| 亚洲欧洲日韩国产综合在线二区| 成人免费看黄20分钟| 成人av片无码免费天天看| 亚洲国产成人在线视频| 国产精品xxxx国产喷水亚洲国产精品无码久久一区 |