public class HelloBean implements SessionBean {
private SessionContext ctx;
public HelloBean() {
}
public static void main(String[] args) {
HelloBean helloBean1 = new HelloBean();
}
public void setSessionContext(SessionContext parm1) throws javax.ejb.EJBException, java.rmi.RemoteException {
ctx=parm1;
}
public void ejbRemove() throws javax.ejb.EJBException, java.rmi.RemoteException {
/**@todo Implement this javax.ejb.SessionBean method*/
throw new java.lang.UnsupportedOperationException("Method ejbRemove() not yet implemented.");
}
public void ejbActivate() throws javax.ejb.EJBException, java.rmi.RemoteException {
/**@todo Implement this javax.ejb.SessionBean method*/
throw new java.lang.UnsupportedOperationException("Method ejbActivate() not yet implemented.");
}
public void ejbPassivate() throws javax.ejb.EJBException, java.rmi.RemoteException {
/**@todo Implement this javax.ejb.SessionBean method*/
throw new java.lang.UnsupportedOperationException("Method ejbPassivate() not yet implemented.");
}
public String hello() {
System.out.println("Hello()");
return "Hello,world";
}
}
----------------------------------------
import java.rmi.*;public interface Hello extends EJBObject {
public String hello() throws RemoteException;
}
--------------------------------------------
import javax.naming.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import java.util.Properties;public class HelloClient {
public HelloClient() {
}
public static void main(String[] args) {
try{
Properties props=System.getProperties();
Context ctx=new InitialContext(props);
Object obj=ctx.lookup("HelloHome");
HelloHome home=(HelloHome)javax.rmi.PortableRemoteObject.narrow(obj,HelloHome.class);
Hello hello=home.create();
System.out.println(hello.hello());
hello.remove();
}catch(Exception e)
{
}
}}
private SessionContext ctx;
public HelloBean() {
}
public static void main(String[] args) {
HelloBean helloBean1 = new HelloBean();
}
public void setSessionContext(SessionContext parm1) throws javax.ejb.EJBException, java.rmi.RemoteException {
ctx=parm1;
}
public void ejbRemove() throws javax.ejb.EJBException, java.rmi.RemoteException {
/**@todo Implement this javax.ejb.SessionBean method*/
throw new java.lang.UnsupportedOperationException("Method ejbRemove() not yet implemented.");
}
public void ejbActivate() throws javax.ejb.EJBException, java.rmi.RemoteException {
/**@todo Implement this javax.ejb.SessionBean method*/
throw new java.lang.UnsupportedOperationException("Method ejbActivate() not yet implemented.");
}
public void ejbPassivate() throws javax.ejb.EJBException, java.rmi.RemoteException {
/**@todo Implement this javax.ejb.SessionBean method*/
throw new java.lang.UnsupportedOperationException("Method ejbPassivate() not yet implemented.");
}
public String hello() {
System.out.println("Hello()");
return "Hello,world";
}
}
----------------------------------------
import java.rmi.*;public interface Hello extends EJBObject {
public String hello() throws RemoteException;
}
--------------------------------------------
import javax.naming.*;
import javax.naming.Context;
import javax.naming.InitialContext;
import java.util.Properties;public class HelloClient {
public HelloClient() {
}
public static void main(String[] args) {
try{
Properties props=System.getProperties();
Context ctx=new InitialContext(props);
Object obj=ctx.lookup("HelloHome");
HelloHome home=(HelloHome)javax.rmi.PortableRemoteObject.narrow(obj,HelloHome.class);
Hello hello=home.create();
System.out.println(hello.hello());
hello.remove();
}catch(Exception e)
{
}
}}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货