标签:
Atitit.ioc 动态配置文件guice 设计原理
3. Ioc 分发器 配合 apche MethodUtils.invokeStaticMethod2
SET JAVA_HOME=C:\Program Files\Java\jdk1.8.0_71
set RESIN-HOME=c:\resin-4.0.22
set classpath=%classpath%;%RESIN-HOME%\lib\jasper.jar;%RESIN-HOME%\lib\javaee-16.jar;%RESIN-HOME%\lib\resin.jar
rem 3,配置classpath %RESIN-HOME%\lib\resin.jar (如果是win7的话没必要设置)
rem 否则报异常:com.caucho.loader.SystemClassLoader
rem 否则报异常:com.caucho.loader.SystemClassLoader
rem %RESIN-HOME%\resin.exe console -resin-home %RESIN-HOME% --debug-port 8000
"%JAVA_HOME%\bin\java" -Dresin.server=1 -Djava.util.logging.manager=com.caucho.log.LogManagerImpl -Djava.system.class.loader=com.caucho.loader.SystemClassLoader -Djava.endorsed.dirs="%java_home%\jre\lib\endorsed;E:\resin-4.0.22\endorsed" -Djavax.management.builder.initial=com.caucho.jmx.MBeanServerBuilderImpl -Djava.awt.headless=true -Dresin.home=/%RESIN-HOME% -Xss1m -Xmx556m -Xrs -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=8000 com.caucho.server.resin.Resin --root-directory /%RESIN-HOME% -conf %RESIN-HOME%\conf\resin.xml -resin-home /%RESIN-HOME% -root-directory /%RESIN-HOME% console -debug-port 8000 -Dapptype="jobus"
作者:: 绰号:老哇的爪子 ( 全名::Attilax Akbar Al Rapanui 阿提拉克斯 阿克巴 阿尔 拉帕努伊 ) 汉字名:艾龙, EMAIL:1466519819@qq.com
转载请注明来源: http://www.cnblogs.com/attilax/
this.dbx=com.attilax.ioc.IocXq214.getBean(DBX.class);
/**
* @author attilax 老哇的爪子
@since o92 j_48_u$
*/
package com.attilax.ioc;
import com.attilax.core;
import com.attilax.db.DBX;
import com.attilax.db.DbxMybatis;
import com.attilax.persistence.HbxX;
import com.attilax.persistence.PX;
import com.focustar.ServiceLoctor4vod;
import com.focustar.downtask.GvDownloadTaskSvs;
import com.google.inject.Binder;
import com.google.inject.Guice;
import com.google.inject.Injector;
import com.google.inject.Module;
import com.google.inject.name.Names;
import static com.attilax.core.*;
import java.util.*;
import java.net.*;
import java.io.*;
import org.apache.commons.lang3.reflect.MethodUtils;
//import org.directwebremoting.extend.AbstractCreator;
//import org.directwebremoting.extend.Creator;
/**
* @author attilax 老哇的爪子
*@since o92 j_48_u$
*/
public class IocXq214 {
//publicstatic Injector ati;
public static void main(String[] args) {
System.setProperty("apptype","jobus");
System.out.println(getBean(DBX.class));
}
/**
@author attilax 老哇的爪子
@since o92 j_48_40
* @param class1
* @return
*/
public static <t> t getBean(Class<t> class1) {
String apptype=System.getProperty("apptype");
String clsName="aaaCfg.IocX4@app@".replace("@app@", apptype);
Object o= com.attilax.reflect.MethodUtils.invokeStaticMethod(clsName, "getBean", (Object)class1);
// attilax 老哇的爪子 j_48_40 o92
return (t) o;
}
// attilax 老哇的爪子 j_48_u o92
/* (non-Javadoc)
* @see org.directwebremoting.extend.Creator#getType()
* @author attilax 老哇的爪子
*@since o93 l_d_c$
*/
/**
@author attilax 老哇的爪子
@since o02 4_f_56
* @param string
*/
public <t> t getBean(String className) {
// attilax 老哇的爪子 4_f_56 o02
try {
Class c=Class.forName(className);
return (t) getBean(c);
} catch (ClassNotFoundException e) {
// attilax 老哇的爪子 4_h_t o02
e.printStackTrace();
throw new RuntimeException(e);
}
//return null;
}
}
// attilax 老哇的爪子
标签:
原文地址:http://www.cnblogs.com/attilax/p/5189693.html