1 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 ; 28 import javax.naming.NamingException ; 29 import javax.naming.Context ; 30 import javax.xml.rpc.ServiceException ; 31 import javax.xml.rpc.server.ServiceLifecycle ; 32 import javax.rmi.PortableRemoteObject ; 33 import java.util.Properties ; 34 35 39 @WebService 40 @SOAPBinding(style = SOAPBinding.Style.RPC) 41 public class ServiceWeb implements ServiceLifecycle 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 e) 54 { 55 e.printStackTrace(); 56 } 57 } 58 59 private InitialContext getContext() throws NamingException { 60 Properties p = new Properties (); 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 (p); 65 } 66 67 public void init(Object object) throws ServiceException { 68 try 69 { 70 service = (ServiceRemote) PortableRemoteObject.narrow( 71 getContext().lookup("ServiceBean/remote"), ServiceRemote.class); 72 } catch (NamingException e) 73 { 74 e.printStackTrace(); 75 throw new ServiceException ("Could not find Service in JNDI service", e); 76 } 77 } 78 79 public void destroy() { 80 } 81 82 } 83 | Popular Tags |