Remote Interface:
package com.scalaejb;
import javax.ejb.Remote;
@Remote
public interface ScalaEjbRemote {
}
Local Interface:
package com.scalaejb;Bean Implementation:
import javax.ejb.Local;
@Local
public interface ScalaEjbLocal {
public void sayHi( String name );
}
package com.scalaejb
import javax.ejb.Stateless
@Stateless
class ScalaEjbImpl extends ScalaEjbRemote with ScalaEjbLocal {
def sayHi( name:String ) { println("Hi, "+name ) }
}
And finally a client, which is in my case a ServletContextListener, because I want to inject an EJB reference and call a method on the bean upon startup of the web application.
package com.scalaejb.servlet;So... what happens when this is packaged, deployed, and ran? It works. My injection println and my call to sayHi happens and the appropriate output is present in the log file.
import javax.servlet.*;
import javax.ejb.*;
import com.scalaejb.ScalaEjbLocal;
public class StartupShutdown implements javax.servlet.ServletContextListener {
@EJB private ScalaEjbLocal localEJB;
public void contextInitialized( ServletContextEvent sce ) {
System.out.println("HERE!!! "+localEJB);
localEJB.sayHi("Fred");
}
public void contextDestroyed( ServletContextEvent sce ) { }
}
This will be my baseline going forward with further experiments.
No comments:
Post a Comment