KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > net > axis > ServiceFactory


1 /*
2  * JBoss, the OpenSource J2EE webOS
3  *
4  * Distributable under LGPL license.
5  * See terms of license at gnu.org.
6  */

7
8 // $Id: ServiceFactory.java,v 1.8.6.1 2005/03/02 14:19:53 tdiesler Exp $
9

10 package org.jboss.net.axis;
11
12 import org.jboss.axis.EngineConfiguration;
13 import org.jboss.axis.EngineConfigurationFactory;
14 import org.jboss.axis.client.AxisClient;
15 import org.jboss.axis.client.Service;
16 import org.jboss.axis.configuration.EngineConfigurationFactoryFinder;
17
18 import javax.naming.Context JavaDoc;
19 import javax.naming.Name JavaDoc;
20 import javax.naming.Reference JavaDoc;
21 import javax.naming.spi.ObjectFactory JavaDoc;
22 import java.util.Hashtable JavaDoc;
23
24 /**
25  * <p>This service factory will reinstall (wsdl-generated)
26  * web service references and re-attach the stubs to the right
27  * configurations with the help of axis engine configuration factory.</p>
28  * <p>It is a temporary alternative to the prototypical axis service factory
29  * that only deals with untyped services at this point.</p>
30  * @author <a HREF="mailto:Christoph.Jung@infor.de">Christoph G. Jung</a>
31  * @version $Revision: 1.8.6.1 $
32  * @since 26.04.02
33  */

34
35 public class ServiceFactory implements ObjectFactory JavaDoc
36 {
37
38    /* (non-javadoc)
39     * does dereference jndi links consisting of stub classname
40     * and string-based configuration names.
41     */

42    public Object JavaDoc getObjectInstance(Object JavaDoc refObject,
43                                    Name JavaDoc name,
44                                    Context JavaDoc nameCtx,
45                                    Hashtable JavaDoc environment)
46            throws Exception JavaDoc
47    {
48       Service instance = null;
49       if (refObject instanceof Reference JavaDoc)
50       {
51          Reference JavaDoc ref = (Reference JavaDoc)refObject;
52
53          Class JavaDoc serviceClass =
54                  Thread.currentThread().getContextClassLoader().loadClass(ref.getClassName());
55
56          EngineConfigurationFactory factory =
57                  EngineConfigurationFactoryFinder.newFactory((String JavaDoc)ref
58                  .get(Constants.CONFIGURATION_CONTEXT)
59                  .getContent());
60
61          EngineConfiguration engine = null;
62
63          if (factory != null)
64          {
65             engine = factory.getClientEngineConfig();
66          }
67
68          instance = (Service)serviceClass.newInstance();
69
70          instance.setEngineConfiguration(engine);
71          // and reinstall the engine
72
instance.setEngine(new AxisClient(engine));
73       }
74
75       return instance;
76    }
77
78 }
79
Popular Tags