???????????????????
???????????? ???????[ 2014/8/1 16:09:50 ] ??????????????? ???????
????at java.io.FileInputStream.(FileInputStream.java:106)
????at java.io.FileInputStream.(FileInputStream.java:66)
????at java.io.FileReader.(FileReader.java:41)
????at com.foo.bar.config.ServerConfigAgent.parseFile(ServerConfigAgent.java:1593)
????at com.foo.bar.config.ServerConfigAgent.parseConfigFile(ServerConfigAgent.java:1720)
????at com.foo.bar.config.ServerConfigAgent.parseConfigFile(ServerConfigAgent.java:1712)
????at com.foo.bar.config.ServerConfigAgent.readServerConf(ServerConfigAgent.java:1581)
????at com.foo.bar.ServerConfigFactory.initServerConfig(ServerConfigFactory.java:38)
????at com.foo.bar.util.HibernateUtil.setupDatabaseProperties(HibernateUtil.java:207)
????at com.foo.bar.util.HibernateUtil.doStart(HibernateUtil.java:135)
????at com.foo.bar.util.HibernateUtil.(HibernateUtil.java:125)
???????????????server.conf????????????????????????Щ????????????д?????????????????????????????е????????????HibernateUtil??????????????????????????????????????Щ?????????database.properties??????????????????????????÷????????????server.conf???????????????????????????ζ?????????о??????????????????С??????????“???”?????????ζ?????????????????????Щ?????????????ServerConfigFactory??HibernateUtil??ServerConfigAgent??Щ?????????????HibernateUtil??????database.properties??????ɡ????????????????????????????????ó?????????????????????????????????????????????????AspectJ??
????void around():
????call(public static void com.foo.bar.ServerConfigFactory.initServerConfig()){
????System.out.println("bypassing com.foo.bar.ServerConfigFactory.initServerConfig");
????}
?????????????????????????AspectJ??????????????????????????????????????ServerConfigFactory.initServerConfig()???????????????????????????????÷???????в???????????????????????hack?????????????????????????г???????????????????????????????ò??Щ????????£?????????????????????????????????????????????????????е???????????????????????????????????????????????????????????????????????????????????ServerMain?е?????
??????????????????HibernateUtil??????server.conf?????????????????????database.properties?н??ж????
????String around():call(public String com.foo.bar.config.ServerConfig.getJDBCUrl()){
????// code omitted?? reading from database.properties
????}
????String around():call(public String com.foo.bar.config.ServerConfig.getDBUser()){
????// code omitted?? reading from database.properties
????}
?????????????????????μ??????????????????????????????????????????????????????mock????????????????????????????????TestServerMain.main()??????????????????′???
????- Factory name: java:comp/env/hibernate/SessionFactory
????- JNDI InitialContext properties:{}
????- Could not bind factory to JNDI
????javax.naming.NoInitialContextException: Need to specify class name in environment
????or system property?? or as an applet
????parameter?? or in an application resource file: java.naming.factory.initial
????at javax.naming.spi.NamingManager.getInitialContext(NamingManager.java:645)
????at javax.naming.InitialContext.getDefaultInitCtx(InitialContext.java:288)
????????????JBoss????????δ??????????????????????????hack??????????????????InitialContext?????????Javax???????????????????????????????????????????hack???????????????????????????Spring??????????????mock??SimpleNamingContext???????????????????????????
????SimpleNamingContextBuilder builder = new SimpleNamingContextBuilder();
????builder.bind(“java:comp/env/hibernate/SessionFactory”??sessionFactory);
????builder.activate();
???????????η???????????????????????????TestServerMain.main()?????????????ServerMain?????????????mock?????JBoss??????????????????????????鷳??
?????????????
????TestServerMain???????????????????????????????????洢??????????????????????????????????????????????????????????????????????????????????????е????а???????????????α????????????????????????????????????????????з?????????????
??????Щ??????????????????????????У??????????????????????κ?С???????????????????????У?????????????????????д????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????——??????????????в??????????????????????????й??????????????????????????????????м???????????????????????????????????????????Щ?????????ζ?????????????????????????????д????μ???壬??????????????????????????????д?Щ??ù????????????????Щ??塣
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11