The previous blog entry showed how to use LMAppletserver in a web archive (WAR) without any enterprise beans or enterprise app. It could also have been deployed to e.g. Tomcat where you don't have EJB3 session beans.
In this example I'm showing how to call EJB3 session beans from your java applet using LMAppletserver.
Download and start netbeans 6.0 (http://netbeans.org)
Versioning -> Subversion -> Checkout
Checkout the following URL:
http://lmappletserver.svn.sourceforge.net/svnroot/lmappletserver/LMAppletServerEJB3
(no username or password)
Right click on the newly opened LMAppletServerEJB3 project and select "Undeploy and Deploy" to deploy the project.
When the server has started and everything is deployed then open this URL in your browser:
http://localhost:8080/LMAppletServerEJB3-war/
The applet shows a message that is obtained by calling an EJB3 session bean method method on the server, using the RPC features of LMAppletserver. This is what happens in the applet:
HelloWorldRemote helloObj = (HelloWorldRemote)AppletServiceClientProxy.newInstance(HelloWorldRemote.class);
add(new JLabel(helloObj.helloWorld()));
And on the server, a Stateless EJB3 session bean:
@Stateless
public class HelloWorldBean implements HelloWorldRemote {
public String helloWorld() {
return "Hello world from EJB3 session bean";
}
}
See? Calling EJB3 session bean methods using LMAppletServer clients is really simple too .. :)
In this example I'm showing how to call EJB3 session beans from your java applet using LMAppletserver.
Download and start netbeans 6.0 (http://netbeans.org)
Versioning -> Subversion -> Checkout
Checkout the following URL:
http://lmappletserver.svn.sourceforge.net/svnroot/lmappletserver/LMAppletServerEJB3
(no username or password)
Right click on the newly opened LMAppletServerEJB3 project and select "Undeploy and Deploy" to deploy the project.
When the server has started and everything is deployed then open this URL in your browser:
http://localhost:8080/LMAppletServerEJB3-war/
The applet shows a message that is obtained by calling an EJB3 session bean method method on the server, using the RPC features of LMAppletserver. This is what happens in the applet:
HelloWorldRemote helloObj = (HelloWorldRemote)AppletServiceClientProxy.newInstance(HelloWorldRemote.class);
add(new JLabel(helloObj.helloWorld()));
And on the server, a Stateless EJB3 session bean:
@Stateless
public class HelloWorldBean implements HelloWorldRemote {
public String helloWorld() {
return "Hello world from EJB3 session bean";
}
}
See? Calling EJB3 session bean methods using LMAppletServer clients is really simple too .. :)
Comments