Enoeht the Java source code Series (2) - Comprehensive plant

  Package org.kyle.net.svr.sample; 

  Public class IntegrationFactory 

  ( 

  Public IntegrationFactory () 

  ( 

  ) 

  Public static IListener createListener (GenProfile genCfg) 

  ( 

  IListener iListener = null; 

  Try ( 

  / / Configuration file set up under the category creates corresponding examples 

  IListener = (IListener) instantiateIt (genCfg.getListenerImpl ()); 

  ) 

  Catch (Exception e) ( 

  Debug.info ( "Listener class not found!"); 

  / / If the designated categories do not exist, use the default category to create examples, as well as because of the procedure used in the interface are therefore here to provide a default category invoked, the compiler compiler, and only mainclass, the need for a separate again the compiler default category 

  IListener = new SampleListenerImpl (); 

  ) 

  Return iListener; 

  ) 

  / / In accordance with the category names are examples of 

  Public static Object instantiateIt (String clsName) 

  Throws ClassNotFoundException, 

ClassCastException,

InstantiationException,

IllegalAccessException

  ( 

  Class cls = Class.forName (clsName); 

  Return cls.newInstance (); 

  ) 

  ) 

  In the configuration file, add the following: Listener = org.kyle.net.svr.sample.SampleListenerImpl 

Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • del.icio.us
  • Facebook
  • DotNetKicks
  • DZone
  • Netvouz
  • Propeller

Tags:

Releated Java Articles

Comments

Leave a Reply