1 22 package com.cluster.simple.sessionbeans; 23 24 import javax.ejb.SessionBean ; 25 import javax.ejb.SessionContext ; 26 import javax.naming.Context ; 27 import javax.naming.InitialContext ; 28 import java.rmi.RemoteException ; 29 import java.util.Properties ; 30 31 34 public class CallerSessionBean implements SessionBean 35 { 36 public String processRequest(String msg) 37 throws RemoteException 38 { 39 System.out.println("CallerSessionBean:processRequest"); 40 String res = null; 41 42 try 43 { 44 Context naming = null; 46 47 if (msg == null || msg.length() == 0) 48 { 49 naming = new InitialContext (); 50 } 51 else 52 { 53 Properties env = new Properties (); 54 env.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory"); 55 env.put("java.naming.provider.url", msg); 56 env.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces"); 57 58 naming = new InitialContext (env); 59 } 60 61 SimpleSessionHome home = (SimpleSessionHome) naming.lookup("SimpleSession"); 62 SimpleSession targetBean = home.create(); 63 targetBean.processRequest(""); 64 targetBean.remove(); 65 } 66 catch (Exception e) 67 { 68 e.printStackTrace(); 69 } 70 71 return res; 72 } 73 74 public void ejbCreate() 75 { 76 } 77 78 public void ejbRemove() 79 { 80 } 81 82 public void ejbActivate() 83 { 84 } 85 86 public void ejbPassivate() 87 { 88 } 89 90 public void setSessionContext(SessionContext sc) 91 { 92 } 93 94 95 } 96 | Popular Tags |