1. Create a java file with the following contents
package test.os9;
//import javax.ejb.Remote;
//@Remote
public interface Hello {
public String sayHello(String input);
}
Compile this file , create a class file and create a jar file and copy the jar file to SCA-INF\lib directory
2. Create an EJB Binding in the Services lane, based on this Java interface. Specify the JNDI Name for this EJB. For example: ejb/EjbBind and select the above interface file and the jar
3. Create a Mediator with no interface definition and Wire this mediator to this EJB Service
4. Create a BPEL process and wire this to the Medaitor
5. Create the mappings for the mediator
6. Create an EJB Client with the following code ,
package test.os9;
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
public class EjbClient {
public EjbClient() {
super();
}
public static void main(String[] args) {
EjbClient ejbClient = new EjbClient();
try {
final Context context = getInitialContext();
Hello hello = (Hello)context.lookup("ejb/EjbBind");
System.out.println(hello.sayHello("hello ravi"));
} catch (Exception ex) {
ex.printStackTrace();
}
}
private static Context getInitialContext() throws NamingException {
Hashtable env = new Hashtable();
// WebLogic Server 10.x connection details
env.put( Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory" );
env.put(Context.PROVIDER_URL, "t3://xxx.xxx.oracle.com:7001");
env.put(Context.SECURITY_PRINCIPAL,"weblogic");
env.put(Context.SECURITY_CREDENTIALS,"xxxxx");
return new InitialContext( env );
}
}
Add the following libraries to compile the class files
"EJB 3.0" and "WebLogic 10.3 Remote-Client"
Here is the example ,
No comments:
Post a Comment