posted @ 2016-03-23 10:14 Milo的海域 閱讀(185) | 評論 (0) | 編輯 收藏
2. 3個加載器并不是真正的父子繼承關系,而是邏輯上的,JVM啟動先創建ExtClassloader instance,然后構造AppClassloader的時候傳入ExtClassloader實例作為parent
try {
extcl = Launcher.ExtClassLoader.getExtClassLoader();
} catch (IOException var10) {
throw new InternalError("Could not create extension class loader", var10);
}
try {
this.loader = Launcher.AppClassLoader.getAppClassLoader(extcl);
} catch (IOException var9) {
throw new InternalError("Could not create application class loader", var9);
}
關于雙親委派原理: 在加載類的時候,會看看parent有沒有設定,如果設定了 就調用parent.loadClass方法,如果沒設定(==null)也就是parent應該是BootstrapClassloader, 會調用native的findBootstrapClass來加載類,代碼:
if(this.parent != null) {
c = this.parent.loadClass(name, false);
} else {
c = this.findBootstrapClassOrNull(name);
}
} catch (ClassNotFoundException var10) {
;
}
目的是按照一定優先級別裝載系統的lib,系統ext目錄的lib,以及classpath的lib,防止系統的默認行為或者類的實現被修改。
3. java 類的動態加載
另外一個問題是,每個被加載的Class都需要被鏈接(link),這是通過執行ClassLoader.resolve()來實現的,這個方法是 final的,因此無法重寫。Resove()方法不允許一個ClassLoader實例link一個Class兩次,因此,當你需要重新加載一個 Class的時候,你需要重新New一個你自己的ClassLoader實例。
posted @ 2016-03-16 15:40 Milo的海域 閱讀(315) | 評論 (0) | 編輯 收藏
exec-maven-plugin 可以執行外部命令, 在項目中對python代碼進行編譯, 配合maven-assembly-plugin來生成package
maven-assembly-plugin 用來構建項目發行包, 要配合xml配置文件來組織包的結構,基本思路是從build環境copy到outputDirectory
license-maven-plugin 用來生成項目用到的3方庫的版權匯總 或者其他的一些用法
maven-dependency-plugin 用來生成項目庫之間的依賴關系
appassembler-maven-plugin 可以為項目生成優雅的啟動腳本 支持linux/win
rpm-maven-plugin 用來為項目構建rpm安裝包
maven-compiler-plugin 指定項目的jdk的編譯兼容版本以及encoding類別
posted @ 2016-01-26 11:41 Milo的海域 閱讀(262) | 評論 (0) | 編輯 收藏
posted @ 2015-11-09 15:11 Milo的海域 閱讀(244) | 評論 (0) | 編輯 收藏
知道了問題所在解決就容易了, 只要修改pom.xml, 然后直接mvn exec:exec就能正常調式了
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>${mvnexec.version}</version>
<executions>
<execution>
<goals>
<goal>exec</goal>
</goals>
</execution>
</executions>
<configuration>
<includeProjectDependencies>true</includeProjectDependencies>
<executable>java</executable>
<workingDirectory>${basedir}/config/sim</workingDirectory>
<classpathScope>runtime</classpathScope>
<arguments>
<argument>-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=4000</argument>
<argument>-classpath</argument>
<classpath/>
<argument>com.ymiao.Main</argument>
<argument>server</argument>
<argument>${basedir}/config/sim/sim.yml</argument>
</arguments>
</configuration>
</plugin>
</plugins>
</build>
總結就是exec:exec是要獨立一個新進程來執行程序的, exec:java就相反, 其實用mvnDebug + exec:java也是理論可行的
posted @ 2015-10-21 17:12 Milo的海域 閱讀(832) | 評論 (0) | 編輯 收藏
Googled many pages, most of them introduced how to scan wifi links by command line tool "iw", i tried all steps supplied by the pages but was blocked at the last step to get dynamical ipaddress by dhclient command "sudo dhclient wlp3s0 -v". The dhclient always complain "NO DHCPOFFERS received." (I doubted there should be some tricky to play with dhclient but which i am not faimiar with.. sad.. )
But i think there would be some extending tool for NetworkManager to manager wifi, then i google "NetworkManager wifi", i got "NetwrokManager-wifi plugin" from link https://www.centos.org/forums/viewtopic.php?f=47&t=52810
After following steps , i finally make wifi work well on centos 7.1
- yum install NetworkManager-wifi
- reboot machine (i tried logout and login, not work)
Problem is NetworkManager-wifi is not installed by default on centos 7.1, (would it be my mistake when install OS? strange..)
posted @ 2015-09-17 10:41 Milo的海域 閱讀(390) | 評論 (1) | 編輯 收藏
posted @ 2015-09-09 15:57 Milo的海域 閱讀(244) | 評論 (0) | 編輯 收藏
- 自定義的Mbean的普通method能在jconsole的Mbeans里顯示出來,但是涉及到geters/seters就無法顯示了
- 如果MBean注冊到下面形式創建的MBeanServer在Jconsole上無法顯示的但是如果注冊到下面的形式創建的Server在Jconsole上是可以顯示MBean的MBeanServer server = MBeanServerFactory.createMBeanServer();MBeanServer server = ManagementFactory.getPlatformMBeanServer();
stackoverflow上也有人發現這個問題
posted @ 2015-09-08 10:53 Milo的海域 閱讀(516) | 評論 (0) | 編輯 收藏
posted @ 2015-08-26 11:22 Milo的海域 閱讀(252) | 評論 (0) | 編輯 收藏