0
請參閱下面的代碼:應用程序客戶端使用遠程接口
//Main.Java
package clienttest;
import javax.ejb.EJB;
import test.TestEJBRemote;
/**
*
* @author
*/
public class Main {
@EJB
private static TestEJBRemote testEJB;
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
System.out.println(testEJB.getName("Ian"));
}
}
//TestEJBRemote.java
package test;
import javax.ejb.Remote;
/**
*
* @author
*/
@Remote
public interface TestEJBRemote {
public String getName (String name);
}
//TestEJB
package test;
import javax.ejb.Stateless;
/**
*
* @author
*/
@Stateless
public class TestEJB implements TestEJBRemote {
@Override
public String getName(String name) {
return "Hello " + name;
}
// Add business logic below. (Right-click in editor and choose
// "Insert Code > Add Business Method")
}
Q1)這是否意味着我可以部署Main.java到網絡上的另一臺電腦並運行它? Q2)一旦部署了,那麼Main.java如何知道在哪裏尋找testEJB?