axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Berin Loritsch <blorit...@apache.org>
Subject JNDI solution for ServiceClient.
Date Mon, 01 Oct 2001 21:17:00 GMT
The following solution should fix all the EJB issues we were having.  The included file is
a new
class that builds an AxisEngine in JNDI's classloader (outside of EJB's environment).  The
attached
diff is the modifications required for altering ServiceClient.

Unfortunately, my cvs environment is crapping out, and I am not able to generate the diff
in the
preferred format.

Also, to run the ServiceClient outside of a JNDI environment, you must use the CVS version
of Excalibur.
I can send it to someone if they wish.  Another solution is to create our own simple JNDI
provider--but
one already exists...

Index: apache/axis/client/ServiceClient.java
===================================================================
RCS file: /home/cvs/xml-axis/java/src/org/apache/axis/client/ServiceClient.java,v
retrieving revision 1.51
diff -w -r1.51 ServiceClient.java
73,74c73,75
< 
< import org.w3c.dom.* ;
---
> import javax.naming.Context;
> import javax.naming.InitialContext;
> import javax.naming.Reference;
112,113d112
<     private static FileProvider configProvider = new FileProvider("client-config.xml");
< 
129a129,179
>     private static Context axisContext;
>     /** Get the reference to the AxisClient.
>      *  @return AxisClient reference
>      */
>     private static AxisClient getEngine() {
>         String provider = System.getProperty("java.naming.factory.initial", null);
> 
>         if (null == provider) {
>             System.setProperty("java.naming.factory.initial",
>                                "org.apache.avalon.excalibur.naming.memory.MemoryInitialContextFactory");
> 
>             try {
>                 ServiceClient.axisContext = new InitialContext().createSubcontext("java:comp")
>                                             .createSubcontext("env").createSubcontext("axis");
>             } catch (Exception e) {
>                 e.printStackTrace(System.err);
>                 throw new RuntimeException("Could not get client instance: " + e.getMessage());
>             }
>         }
> 
>         AxisClient client = null;
>         try {
>             if (ServiceClient.axisContext == null) {
>                 ServiceClient.axisContext = (Context) new InitialContext().lookup("java:comp/env/axis");
>             }
>             client = (AxisClient) axisContext.lookup("Client");
>         } catch (Exception e) {
>             // it wasn't there, so we bind the factory
>             try {
>                 if (ServiceClient.axisContext == null) {
>                     ServiceClient.axisContext = ((Context) new InitialContext().lookup("java:comp/env"))
>                                                 .createSubcontext("axis");
>                 }
> 
>                 ServiceClient.axisContext.bind("Client", new Reference("org.apache.axis.client.AxisClient",
>                                                                        "org.apache.axis.AxisEngineFactory",
>                                                                        null));
>                 client = (AxisClient) ServiceClient.axisContext.lookup("Client");
>             } catch (Exception ne) {
>                 ne.printStackTrace(System.err);
>                 throw new RuntimeException("Could not get client instance: " + e.getMessage());
>             }
>         }
> 
>         if (null == client) {
>             throw new RuntimeException("Could not get client instance");
>         }
> 
>         return client;
>     }
> 
205c255
<         this(new AxisClient(configProvider));
---
>         this(ServiceClient.getEngine());
228c278
<         this(endpointURL, new AxisClient(configProvider));
---
>         this(endpointURL, ServiceClient.getEngine());
249c299
<         this(transport, new AxisClient(configProvider));
---
>         this(transport, ServiceClient.getEngine());
Mime
View raw message