ATITIT.IOC Dynamic configuration file Guice design principle

Source: Internet
Author: User
Tags dbx

ATITIT.IOC Dynamic configuration file guice Design principle

1 .  Bat Injection configuration file at startup 1

2 .  IOC call 1

3 .  Ioc Dispatcher with Apche methodutils.invokestaticmethod 2

1.Bat Injection configuration file at startup

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, configuring classpath%resin-home%\lib\resin.jar ( no need to set if win7 )

REM otherwise reported exception:com.caucho.loader.SystemClassLoader

REM otherwise reported exception: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"

author:: Nickname:Old Wow's claws( Full Name::AttilaxAkbar Al Rapanui Attilaksachanui) Kanji Name:Ayron, email:[email protected]

Reprint please indicate source: http://www.cnblogs.com/attilax/

2.IOC call

This . dbx =com.attilax.ioc.iocxq214. Getbean (DBX. class );

3.Ioc Dispatcher with Apche methodutils.invokestaticmethod

/**

* @author Attilax The claws of old Wow

@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 The claws of old Wow

* @since o92 j_48_u$

*/

public class IocXq214 {

// Public static Injector ati;

public static void Main (string[] args) {

System.setproperty ("Apptype", "Jobus");

System.out.println (Getbean (Dbx.class));

}

/**

@author Attilax The claws of old Wow

@since o92 j_48_40

* @param Class1

* @return

*/

public static <t> T Getbean (class<t> Class1) {

String apptype=system.getproperty ("Apptype");

String clsname= "[Email protected]@". Replace ("@[email protected]", apptype);

Object o= Com.attilax.reflect.MethodUtils.invokeStaticMethod (Clsname, "Getbean", (Object) class1);

Attilax 's Paw j_48_40 o92

Return (t) o;

}

Attilax 's Paw J_48_u o92

/* (Non-javadoc)

* @see Org.directwebremoting.extend.creator#gettype ()

* @author Attilax The claws of old Wow

* @since o93 l_d_c$

*/

/**

@author Attilax The claws of old Wow

@since o02 4_f_56

* @param string

*/

Public <t> T Getbean (String className) {

Attilax 's Paw 4_f_56 o02

try {

Class C=class.forname (className);

Return (t) Getbean (c);

} catch (ClassNotFoundException e) {

Attilax 's Paw 4_h_t o02

E.printstacktrace ();

throw new RuntimeException (e);

}

// return null;

}

}

Attilax The claws of old Wow

ATITIT.IOC Dynamic configuration file Guice design principle

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.