KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > webservice > WebServiceClientHandler


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

7 package org.jboss.webservice;
8
9 // $Id: WebServiceClientHandler.java,v 1.1.4.1 2005/04/22 15:34:20 tdiesler Exp $
10

11 import org.jboss.deployment.DeploymentException;
12 import org.jboss.deployment.DeploymentInfo;
13 import org.jboss.logging.Logger;
14 import org.jboss.mx.util.MBeanProxy;
15 import org.jboss.mx.util.MBeanProxyCreationException;
16 import org.jboss.mx.util.MBeanServerLocator;
17 import org.jboss.mx.util.ObjectNameFactory;
18
19 import javax.management.MBeanServer JavaDoc;
20 import javax.management.ObjectName JavaDoc;
21 import javax.naming.Context JavaDoc;
22 import java.util.Iterator JavaDoc;
23
24 /**
25  * Created by IntelliJ IDEA.
26  *
27  * @author Thomas.Diesler@jboss.org
28  * @since 05-May-2004
29  */

30 public class WebServiceClientHandler
31 {
32    // provide logging
33
private static final Logger log = Logger.getLogger(WebServiceClientHandler.class);
34
35    /**
36     * This binds a jaxrpc Service into the callers ENC for every service-ref element
37     *
38     * @param envCtx ENC to bind the javax.rpc.xml.Service object to
39     * @param serviceRefs An iterator of the service-ref elements in the client deployment descriptor
40     * @param di The client's deployment info
41     * @throws org.jboss.deployment.DeploymentException if it goes wrong
42     */

43    public static void setupServiceRefEnvironment(Context JavaDoc envCtx, Iterator JavaDoc serviceRefs, DeploymentInfo di) throws DeploymentException
44    {
45       // nothing to do
46
if (serviceRefs.hasNext() == false)
47          return;
48
49       MBeanServer JavaDoc server = MBeanServerLocator.locateJBoss();
50       ObjectName JavaDoc ws4eeObjectName = ObjectNameFactory.create("jboss.ws4ee:service=ServiceClientDeployer");
51       ObjectName JavaDoc jbosswsObjectName = ObjectNameFactory.create("jboss.ws:service=WebServiceClientDeployer");
52
53       ObjectName JavaDoc objectName = null;
54       WebServiceClientDeployment wsClientDeployment;
55       try
56       {
57          if (server.isRegistered(ws4eeObjectName))
58          {
59             objectName = ws4eeObjectName;
60             wsClientDeployment = (WebServiceClientDeployment)MBeanProxy.get(WebServiceClientDeployment.class, ws4eeObjectName, server);
61          }
62          else if (server.isRegistered(jbosswsObjectName))
63          {
64             objectName = jbosswsObjectName;
65             wsClientDeployment = (WebServiceClientDeployment)MBeanProxy.get(WebServiceClientDeployment.class, jbosswsObjectName, server);
66          }
67          else
68          {
69             log.warn("No web service client deployer registered");
70             return;
71          }
72       }
73       catch (MBeanProxyCreationException e)
74       {
75          throw new DeploymentException("Cannot create proxy to the web service client deployer: " + objectName);
76       }
77
78       // Delegate to the web service client deloyer
79
wsClientDeployment.setupServiceRefEnvironment(envCtx, serviceRefs, di);
80    }
81 }
82
Popular Tags