|
[x]
Posted via EE Mobile
|
||
Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again. |
||
| 10/13/2009 at 06:38AM PDT, ID: 24807650 | Points: 500 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: |
Server code:
package com.wily.ejb;
import javax.ejb.SessionBean;
import weblogic.ejb.GenericSessionBean;
import weblogic.ejbgen.Session;
import weblogic.ejbgen.JndiName;
import weblogic.ejbgen.FileGeneration;
import weblogic.ejbgen.Constants;
/**
* GenericSessionBean subclass automatically generated by Workshop.
*
* Please complete the ejbCreate method as needed to properly initialize new instances of your bean and add
* all required business methods. Also, review the Session, JndiName and FileGeneration annotations
* to ensure the settings match the bean's intended use.
*/
@Session(ejbName = "Hello")
@JndiName(remote = "ejb/HelloRemoteHome")
@FileGeneration(remoteClass = Constants.Bool.TRUE, remoteHome = Constants.Bool.TRUE, localClass = Constants.Bool.FALSE, localHome = Constants.Bool.FALSE)
public class Hello extends GenericSessionBean implements SessionBean {
private static final long serialVersionUID = 1L;
/* (non-Javadoc)
* @see weblogic.ejb.GenericSessionBean#ejbCreate()
*/
public void ejbCreate() {
// IMPORTANT: Add your code here
}
// IMPORTANT: Add business methods
public String sayHello(String name) {
return "Hello "+name;
}
}
Client code:
/**
*
*/
package com.wily.ejb;
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContext;
/**
* @author sirba01
*
*/
public class HelloClient {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
try{
//Hashtable tab = new Hashtable();
//tab.put("java.naming.factory.initial", "org.jnp.interfaces.NamingContextFactory");
//tab.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
//tab.put("java.naming.provider.url", "jnp://localhost:1099");
Hashtable tab = new Hashtable();
tab.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
//tab.put("java.naming.factory.url.pkgs", "org.jboss.naming:org.jnp.interfaces");
tab.put(Context.PROVIDER_URL, "t3://localhost:7001");
Context ctx = new InitialContext(tab);
Hello obj = (Hello) ctx.lookup("ejb/HelloRemoteHome");
//service = (ReviewService) ctx.lookup("java:comp/env/ejb/ReviewManager");
//InitialContext ic = new InitialContext(tab);
//Hello obj = (Hello) ic.lookup("ejb.HelloRemoteHome");
System.out.println(obj.sayHello("Srujana"));
}
catch(Exception e){
e.printStackTrace();
}
}
}
|
Advertisement