KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > ejb3 > test > clusteredservice > ServiceWeb


1 /*
2   * JBoss, Home of Professional Open Source
3   * Copyright 2005, JBoss Inc., and individual contributors as indicated
4   * by the @authors tag. See the copyright.txt in the distribution for a
5   * full listing of individual contributors.
6   *
7   * This is free software; you can redistribute it and/or modify it
8   * under the terms of the GNU Lesser General Public License as
9   * published by the Free Software Foundation; either version 2.1 of
10   * the License, or (at your option) any later version.
11   *
12   * This software is distributed in the hope that it will be useful,
13   * but WITHOUT ANY WARRANTY; without even the implied warranty of
14   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15   * Lesser General Public License for more details.
16   *
17   * You should have received a copy of the GNU Lesser General Public
18   * License along with this software; if not, write to the Free
19   * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20   * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21   */

22 package org.jboss.ejb3.test.clusteredservice;
23
24 import javax.jws.WebMethod;
25 import javax.jws.WebService;
26 import javax.jws.soap.SOAPBinding;
27 import javax.naming.InitialContext JavaDoc;
28 import javax.naming.NamingException JavaDoc;
29 import javax.naming.Context JavaDoc;
30 import javax.xml.rpc.ServiceException JavaDoc;
31 import javax.xml.rpc.server.ServiceLifecycle JavaDoc;
32 import javax.rmi.PortableRemoteObject JavaDoc;
33 import java.util.Properties JavaDoc;
34
35 /**
36  * @version <tt>$Revision: 45712 $</tt>
37  * @author <a HREF="mailto:bdecoste@jboss.com">William DeCoste</a>
38  */

39 @WebService
40 @SOAPBinding(style = SOAPBinding.Style.RPC)
41 public class ServiceWeb implements ServiceLifecycle JavaDoc
42 {
43    ServiceRemote service;
44
45    public ServiceWeb() {}
46
47    @WebMethod(operationName = "RemoteMethod")
48    public void remoteMethod() {
49       System.out.println("ServiceWeb.remoteMethod");
50       try
51       {
52          service.remoteMethod();
53       } catch (Exception JavaDoc e)
54       {
55          e.printStackTrace();
56       }
57    }
58
59    private InitialContext JavaDoc getContext() throws NamingException JavaDoc{
60       Properties JavaDoc p = new Properties JavaDoc();
61       p.put(Context.INITIAL_CONTEXT_FACTORY, "org.jnp.interfaces.NamingContextFactory");
62       p.put(Context.URL_PKG_PREFIXES, "jboss.naming:org.jnp.interfaces");
63       p.put("jnp.partitionName", "HASingletonPartition");
64       return new InitialContext JavaDoc(p);
65    }
66
67    public void init(Object JavaDoc object) throws ServiceException JavaDoc {
68       try
69       {
70          service = (ServiceRemote) PortableRemoteObject.narrow(
71                getContext().lookup("ServiceBean/remote"), ServiceRemote.class);
72       } catch (NamingException JavaDoc e)
73       {
74          e.printStackTrace();
75          throw new ServiceException JavaDoc("Could not find Service in JNDI service", e);
76       }
77    }
78
79    public void destroy() {
80    }
81
82 }
83
Popular Tags