KickJava   Java API By Example, From Geeks To Geeks.

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


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: ServiceClientDeployer.java,v 1.7.2.3 2005/06/17 22:33:05 tdiesler Exp $
9
package org.jboss.webservice;
10
11 // $Id: ServiceClientDeployer.java,v 1.7.2.3 2005/06/17 22:33:05 tdiesler Exp $
12

13 import org.jboss.deployment.DeploymentException;
14 import org.jboss.deployment.DeploymentInfo;
15 import org.jboss.logging.Logger;
16 import org.jboss.naming.Util;
17 import org.jboss.system.ServiceMBeanSupport;
18 import org.jboss.webservice.client.ServiceReferenceable;
19 import org.jboss.webservice.metadata.serviceref.ServiceRefMetaData;
20
21 import javax.naming.Context JavaDoc;
22 import java.util.Iterator JavaDoc;
23
24 /**
25  * Binds a JAXRPC Service object in the client's ENC for every service-ref element in the
26  * deployment descriptor.
27  *
28  * @author Thomas.Diesler@jboss.org
29  * @jmx.mbean name="jboss.ws4ee:service=ServiceClientDeployer"
30  * description="Webservice client deployer"
31  * extends="org.jboss.system.ServiceMBean"
32  * @since 27-April-2004
33  */

34 public class ServiceClientDeployer extends ServiceMBeanSupport
35         implements ServiceClientDeployerMBean, WebServiceClientDeployment
36 {
37    // provide logging
38
private static final Logger log = Logger.getLogger(ServiceClientDeployer.class);
39
40    /**
41     * This binds a jaxrpc Service into the callers ENC for every service-ref element
42     *
43     * @param envCtx ENC to bind the javax.rpc.xml.Service object to
44     * @param serviceRefs An iterator of the service-ref elements in the client deployment descriptor
45     * @param di The client's deployment info
46     * @throws org.jboss.deployment.DeploymentException
47     * if it goes wrong
48     * @jmx.managed-operation
49     */

50    public void setupServiceRefEnvironment(Context JavaDoc envCtx, Iterator JavaDoc serviceRefs, DeploymentInfo di)
51            throws DeploymentException
52    {
53       try
54       {
55          while (serviceRefs.hasNext())
56          {
57             ServiceRefMetaData serviceRef = (ServiceRefMetaData)serviceRefs.next();
58             String JavaDoc serviceRefName = serviceRef.getServiceRefName();
59
60             ServiceReferenceable ref = new ServiceReferenceable(serviceRef, di);
61             Util.bind(envCtx, serviceRefName, ref);
62
63             log.debug("Webservice binding: java:comp/env/" + serviceRefName);
64          }
65       }
66       catch (Exception JavaDoc e)
67       {
68          throw new DeploymentException("Cannot bind webservice to client environment", e);
69       }
70    }
71 }
72
Popular Tags