============== Stateless Bean ====================
package bean;
import javax.ejb.Remote;
import javax.ejb.Stateless;
import org.jboss.annotation.ejb.Local;
@Stateless
@Remote
@Local
public class CountupBean implements Countup{
/* (non-Javadoc)
* @see bean.Countup#count(int)
*/
public int count(int n){
return n + 10;
}
}
============ interface ===================
ackage bean;
import javax.ejb.Remote;
@Remote
public interface Countup {
public int count(int n);
}
============ jndi.properties ===============
java.naming.factory.initial=org.jnp.interfaces.NamingContextFactory
java.naming.factory.url.pkgs=org.jboss.naming:org.jnp.interfaces
java.naming.provider.url=localhost:1099
============== Call ========================
InitialContext ctx;
try{
ctx = new InitialContext();
// EJB 呼出し
Countup countup = (Countup)ctx.lookup("CountupBean/remote");
int ans = countup.count(12);
logger.info("■■ EJB3.0 call Countup = "+ans);
}catch(NamingException e){
logger.error("NamingException ERROR "+e.getMessage(),e);
}
=============================================
WTP JARエクスポートで、ファイル名;sampleA.ejb3 を deploy に置く
11:13:07,765 INFO [JmxKernelAbstraction] installing MBean: jboss.j2ee:jar=sampleA.ejb3,name=CountupBean,service=EJB3 with dependencies:
11:13:07,890 INFO [EJBContainer] STARTED EJB: bean.CountupBean ejbName: CountupBean
11:13:07,953 INFO [EJB3Deployer] Deployed: file:/C:/usr/local/jboss-4.0.4.GA/server/default/deploy/sampleA.ejb3