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

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

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

    I want to fly higher
    programming Explorer
    posts - 114,comments - 263,trackbacks - 0
    1.Spring-loaded項目核心作者Andy Clement
         github主頁:
            https://github.com/aclement
        可以看到是一個開源大神.

    2.往來郵件,其中有很多東西值得學習:尤其是紅色部分

    2015年6月26日

    Hi,

    Really all the docs is what I wrote in that bug report: https://github.com/spring-projects/spring-loaded/issues/70

    Yes you need javaagent (and noverify), the -Dspringloaded=watchJars=foo.jar:bar.jar part is just the options that get passed to the agent to configure the behavior.

    There are a couple of regression tests in the class: SpringLoadedTestsInSeparateJVM

    Remember that you only need the short part of the jar name (foo.jar), I’m not sure what will happen if you fully qualify the path to the jar.

    You could turn on -Dspringloaded=verbose to check spring loaded is basically functioning (can’t recall if I added extra verbose output specifically for jar reloading).

    cheers,
    Andy

    On Jun 232015, at 5:09 AM, landon <340706410@qq.com> wrote:

    Hi,
       I'm a software engineer in china.I'm interested in spring-loaded recently.But pre 1.2.3,it's only reload calsses.In github,i saw you said 1.2.4 can do reload class files in jar.
      eg,with -Dspringloaded=watchJars parameters.
      My question is:
      1.Can you give a detail examples,it's also need -javaagent?
      2.I build a jar using the master code in github,but i test it's no effect to reload jar files.I want to know when the 1.2.4 version can support the function.
       _____________________
       Thanks very much.
       Best Regards.


    2015年6月29日

    Hi,

    Possibly it could be a windows thing I suppose. This works perfectly for me:

    Code.java
    ===
    public class Code {
      public static void main(String []argv) {
        while (true) {
          new Bar().run();
          try { Thread.sleep(2000); } catch (Exception e) {}
        }
      }
    }
    ===

    Bar.java
    ===
    public class Bar {
      public void run() {
        System.out.println(“one");
      }
    }
    ===

    javac *.java
    jar -cvMf spring-load-example-main.jar Code.class
    jar -cvMf spring-load-example-extra.jar Bar.class

    java -classpath spring-load-example-main.jar:spring-load-example-extra.jar -Dspringloaded="verbose;watchJars=spring-load-example-extra.jar" -javaagent:/Users/aclement/gits/spring-loaded/springloaded/build/libs/springloaded-1.2.4.BUILD-SNAPSHOT.jar -noverify Code

    This will print ‘one’ every second.

    Then I change Bar, edit the ‘one’ and replace with ‘two’. Then:

    javac Bar.java
    jar -cvMf newjar.jar Bar.class
    mv newjar.jar spring-load-example-extra.jar

    This triggers some trace output and then it starts printing two:


    INFO: Observed last modification time change for /Users/aclement/gits/spring-loaded/springloaded/build/libs/play/spring-load-example-extra.jar (lastScanTime=1435594228140)
    Jun 292015 9:10:29 AM org.springsource.loaded.agent.Watcher determineChangesSince
    INFO: Firing file changed event /Users/aclement/gits/spring-loaded/springloaded/build/libs/play/spring-load-example-extra.jar

    Reloading: Loading new version of Bar [PH0x0kq]

    two
    two
    two


    This is on a mac. Can you look at the timestamps of your files inside the jar? Confirm it is changing to something more recent inside the jar? That is what is being used to determine if an update occurred.

    > can the spring-loaded used to the production environment?

    Nothing prevents it but it does add significant overhead to running code because it introduces a lot of indirection to make the reloading work.

    cheers,
    Andy

    On Jun 282015, at 7:29 PM, landon <340706410@qq.com> wrote:

    Hi,
      I'm so excited to receive your reply.Thanks very much.
      I say my example:
         I have two jars,spring-load-example-main.jar,spring-load-example-extra.jar,The former depends on the latter.The classes in spring-loaded-example-extra.jar often changes,so i want to reload the jar using spring-loaded.
          My Launch script is:
                     @echo off
                     cd /%~dp0
                     java -Dspringloaded=verbose;explain;watchJars=spring-load-example-extra.jar -javaagent:springloaded-1.2.4.BUILD-SNAPSHOT.jar -noverify -cp spring-load-example-main.jar;spring-load-example-extra.jar com.mavsplus.example.springloaded.SpringLoadedExample
         The spring-load-example-main.jar,spring-load-example-extra.jar,springloaded-1.2.4.BUILD-SNAPSHOT.jar are in the same directory.When i want to reload the spring-load-example-extra.jar,i repackage the jar and replace to the directory and override it,but it has no effect.That's all.I also used jrebel,it can reload ja,but must assign the monitor reload jar classes dirctory,i also cannot to ovverride the reload jar to reache the reload goal.
     And Finally i want to ask: can the spring-loaded used to the production environment?


    2015年6月30日

    Hi,

    Sorry about that - I made the change you noticed to correctly use File.separator and committed that (thanks for telling me about it). I notice a TODO had been left there saying to sort it out for windows!

       ->I ask another question,i know if used to production environment,it maybe has some performance loss.To avoid it,i suggest,when we decide to reload the jar,we can send a message to notice to reload,and to avoid must be monitor the jar change every seconds.
        ->can extract a mini-framework only to reload jars.
        ->or can add a switch,by the switch,we can reload jars manually?
          if above can reduce the performance loss?

    It isn’t the act of watching the jar that is expensive or the act of loading the jar changes into the system. Basically for code to support reloading it goes through a massive transformation process at loadtime, this transformed byte code is slower, but it needs to be done up front just in case you reload anything.  To minimize the performance impact you would reduce what is made reloadable - so in the jar watching case watch as few jars as possible. Maybe break big jars into smaller ones so you can watch only a subset of the jars.

    cheers,
    Andy

    On Jun 302015, at 3:00 AM, landon <340706410@qq.com> wrote:

    Hi,
      First,Thanks very much to reply me.
      Okay,I Got the reason,you are right,it's the os environment problem.I Browse the source code,i find the code,{@link org.springsource.loaded.TypeRegistry#private boolean couldBeReloadable(String slashedName)},The method 689L:
           int lastSlashPos = slashedName.lastIndexOf('/');
       The Seperator is unix seperator,not windows.I change it to the cross-platform code:
           int lastSlashPos = slashedName.lastIndexOf(File.separator);
        And finally,I rebuild the source code and got the new jar.I tested,it can reload jars perfectly!

       ->I ask another question,i know if used to production environment,it maybe has some performance loss.To avoid it,i suggest,when we decide to reload the jar,we can send a message to notice to reload,and to avoid must be monitor the jar change every seconds.
        ->can extract a mini-framework only to reload jars.
        ->or can add a switch,by the switch,we can reload jars manually?
          if above can reduce the performance loss?



    2015-7-2

    Hey,
    Actually email is probably the best way to communicate on this, I don’t work on spring loaded all that much, only occasionally.
               ->two jars,main.jar and patch.jar,when launch main,i used a classloader load classes in patch.jar and put them to a Map,and some logic used the class intance...when some logic changes,i send a message(eg.use http) to the main process(it's a network program,can listen),when receive the message,i used another classloader to load the new patch.jar and re-fill the Map.By this method,i can implement some hot-swap logics,new request can used the new classes from Map...
    I think there are use cases where that can work fine and you don’t need the full flexibility of a general purpose reloading system like spring loaded. You just have to make sure those instances don’t leak into other places where you can’t keep track of them as you’ll want to get rid of all of them when loading a new version.
         ->another question is:i think the hot-loaded has a deadly problem is : the Data in the class instance or in the memory...when reload the new class,the data in the old class instance was lost...
     to avoid it,in the class implemention,only have method/logic,not has property/data...put all data to a common place...but in my opinion,in oop,data and actions in fact ,they are together...so this is the confict.
             ->so can you give me some suggestion or give me a good practice?
    With spring loaded the class instances remain around, they change on the fly to support new fields and methods are not rebuilt. This can cause issues because constructors are not re-run for pre-existing instances and so new fields added to existing objects may not be set. I think, in your case, you can break encapsulation by keeping state separation to behaviour if it is necessary and helpful for your use case - don’t be forced to keep them together if it makes your system less flexible than you need. I don’t see why you can’t have a bean that keeps state and then a class something like XXXOperator that operates on those state objects.  Or perhaps you could have a constructor on your objects that takes in one of the older objects and copies the state into the new instance before you discard the older object.
    cheers,
    Andy

    On Jul 1, 2015, at 6:47 AM, landon <340706410@qq.com> wrote:

    Hi,
      So excited to reply me.Thank you.
      Here, i have two questions want to interchange with you.
          ->I write a function used to reload jar.The implementation is:
                ->two jars,main.jar and patch.jar,when launch main,i used a classloader load classes in patch.jar and put them to a Map,and some logic used the class intance...when some logic changes,i send a message(eg.use http) to the main process(it's a network program,can listen),when receive the message,i used another classloader to load the new patch.jar and re-fill the Map.By this method,i can implement some hot-swap logics,new request can used the new classes from Map...
               ->how would you evaluate my way?
         ->another question is:i think the hot-loaded has a deadly problem is : the Data in the class instance or in the memory...when reload the new class,the data in the old class instance was lost...
     to avoid it,in the class implemention,only have method/logic,not has property/data...put all data to a common place...but in my opinion,in oop,data and actions in fact ,they are together...so this is the confict.
             ->so can you give me some suggestion or give me a good practice?
         ->finally,can you give a contact way the except email.i think it's low efficiency.
      Cherrs.



    3.感受
        1.開源的力量真是偉大!
        2.開源大神的回復真是給力!
        3.我也會加入開源的大軍中!
    posted on 2015-07-01 21:06 landon 閱讀(6706) 評論(3)  編輯  收藏 所屬分類: JVMHotSwap

    FeedBack:
    # re: Spring-Loaded 使用Ⅲ -與其作者Andy Clement往來郵件
    2015-07-29 13:57 | David1228
    Good!!!  回復  更多評論
      
    # re: Spring-Loaded 使用Ⅲ -與其作者Andy Clement往來郵件[未登錄]
    2015-09-23 13:22 | zy
    博主你好:

    我按照你的博客測試,watchJars并沒有起作用啊,是我的版本問題嗎?我從github上下的springloaded-1.2.4.RELEASE.jar ,和你所使用的springloaded-1.2.4.BUILD-SNAPSHOT.jar會有區別嗎?
    我的測試代碼是借用的你與大神郵件中的測試代碼。  回復  更多評論
      
    # re: Spring-Loaded 使用Ⅲ -與其作者Andy Clement往來郵件
    2015-10-05 23:04 | landon
    @zy
    http://www.tkk7.com/landon/archive/2015/10/05/425994.html#427599
    _______
    看一下這下面我的評論回復.  回復  更多評論
      
    主站蜘蛛池模板: 亚洲日本天堂在线| 一区二区三区免费视频观看| 日韩黄色免费观看| 一级特黄录像视频免费| 亚洲一二成人精品区| 成人毛片视频免费网站观看| eeuss影院www天堂免费| 亚洲成aⅴ人片在线观| 青青青国产色视频在线观看国产亚洲欧洲国产综合 | 亚洲精品乱码久久久久久按摩 | 久久美女网站免费| 亚洲熟妇无码八V在线播放| 国产亚洲精品久久久久秋霞| 1000部禁片黄的免费看| 黄色毛片免费在线观看| 亚洲欧洲日产v特级毛片| 中文字幕亚洲不卡在线亚瑟| 性做久久久久久免费观看| 你是我的城池营垒免费看 | 亚洲AV中文无码乱人伦下载| 成人午夜18免费看| 日本亚洲欧洲免费天堂午夜看片女人员| 亚洲一区二区三区高清在线观看 | 午夜一级毛片免费视频| 免费人成毛片动漫在线播放| 偷自拍亚洲视频在线观看99| 亚洲第一页在线观看| 亚洲无线观看国产精品| 国产精品黄页在线播放免费| 四虎精品视频在线永久免费观看| 一级一级一级毛片免费毛片| 亚洲人成欧美中文字幕| 亚洲美女中文字幕| 亚洲精品乱码久久久久久| 免费国产在线观看不卡| 成人在线免费观看| 97免费人妻无码视频| 久久精品国产影库免费看| 国产99久久久国产精免费| 黄页网站在线观看免费| 亚洲爆乳少妇无码激情|