<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項(xiàng)目核心作者Andy Clement
         github主頁(yè):
            https://github.com/aclement
        可以看到是一個(gè)開源大神.

    2.往來(lái)郵件,其中有很多東西值得學(xué)習(xí):尤其是紅色部分

    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.開源大神的回復(fù)真是給力!
        3.我也會(huì)加入開源的大軍中!
    posted on 2015-07-01 21:06 landon 閱讀(6694) 評(píng)論(3)  編輯  收藏 所屬分類: JVMHotSwap

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

    我按照你的博客測(cè)試,watchJars并沒有起作用啊,是我的版本問題嗎?我從github上下的springloaded-1.2.4.RELEASE.jar ,和你所使用的springloaded-1.2.4.BUILD-SNAPSHOT.jar會(huì)有區(qū)別嗎?
    我的測(cè)試代碼是借用的你與大神郵件中的測(cè)試代碼。  回復(fù)  更多評(píng)論
      
    # re: Spring-Loaded 使用Ⅲ -與其作者Andy Clement往來(lái)郵件
    2015-10-05 23:04 | landon
    @zy
    http://m.tkk7.com/landon/archive/2015/10/05/425994.html#427599
    _______
    看一下這下面我的評(píng)論回復(fù).  回復(fù)  更多評(píng)論
      
    主站蜘蛛池模板: 香蕉免费一级视频在线观看| 日韩电影免费在线观看网站| 三级毛片在线免费观看| 曰批全过程免费视频播放网站| 免费精品一区二区三区在线观看| 中文字幕不卡亚洲| 亚洲乱码在线观看| 成年免费a级毛片免费看无码| 成人性生交大片免费看无遮挡| 中文字幕不卡亚洲| 亚洲乱色伦图片区小说| 国产色爽免费无码视频| 午夜免费福利在线观看| 亚洲av不卡一区二区三区| 亚洲AV色欲色欲WWW| 免费人成视频在线观看网站| 亚洲成?v人片天堂网无码| 亚洲国产精品久久人人爱| 久久精品成人免费观看97| 老司机永久免费网站在线观看| 亚洲免费在线视频| 色吊丝性永久免费看码| 免费电视剧在线观看| 亚洲欧洲一区二区| 国产黄色免费观看| 尤物永久免费AV无码网站| 777亚洲精品乱码久久久久久| 一道本不卡免费视频| 日韩免费a级在线观看| 亚洲熟妇av一区| 爽爽爽爽爽爽爽成人免费观看| 免费精品一区二区三区在线观看| 亚洲黄色三级网站| 99在线免费视频| 亚洲人成无码www久久久| 亚洲欧美成人av在线观看| 2021在线永久免费视频| 国产AV无码专区亚洲AVJULIA| 无码AV动漫精品一区二区免费| 午夜神器成在线人成在线人免费| 久久精品九九亚洲精品|