Using JBoss EJB 3 with Eclipse RCP [Part 5]
Sonntag
Mai 20,2007
Some code to test
To get something working we need to insert some code in our RCP. We will insert it directly in the Application.java. All output will be echo to the console so that there is no need for a GUI:
Application.java
JAVA:
-
package bz.jmc.blog.rcp_with_jboss.rcp;
-
-
import java.util.Properties;
-
-
import javax.naming.Context;
-
import javax.naming.InitialContext;
-
-
import org.eclipse.core.runtime.IPlatformRunnable;
-
import org.eclipse.swt.widgets.Display;
-
import org.eclipse.ui.PlatformUI;
-
-
import bz.jmc.blog.tutorial.rcp_with_jboss.ejb.MyTestStatelessSessionRemote;
-
-
/**
-
* This class controls all aspects of the application's execution
-
*/
-
public class Application implements IPlatformRunnable {
-
-
/* (non-Javadoc)
-
* @see org.eclipse.core.runtime.IPlatformRunnable#run(java.lang.Object)
-
*/
-
-
// EJB-Test
-
//
-
-
properties.put("java.naming.factory.initial",
-
"org.jnp.interfaces.NamingContextFactory");
-
properties.put("java.naming.factory.url.pkgs",
-
"=org.jboss.naming:org.jnp.interfaces");
-
properties.put("java.naming.provider.url","localhost:1099");
-
-
-
try {
-
-
MyTestStatelessSessionRemote sess =
-
(MyTestStatelessSessionRemote)
-
context.lookup("MyTestStatelessSessionBean/remote");
-
System.
out.
println( sess.
sayHello() );
-
-
e.printStackTrace();
-
}
-
// Normal RCP-App Code
-
Display display = PlatformUI.createDisplay();
-
try {
-
int returnCode = PlatformUI.createAndRunWorkbench(display, new ApplicationWorkbenchAdvisor());
-
if (returnCode == PlatformUI.RETURN_RESTART) {
-
return IPlatformRunnable.EXIT_RESTART;
-
}
-
return IPlatformRunnable.EXIT_OK;
-
} finally {
-
display.dispose();
-
}
-
}
-
}
Now click on "Lauch an Eclipse application" in the "Overview"-tab to lauch the RCP. If anything is OK you should see a RCP window and an output similar to this one:

Hopefully this small tutorial is a little helpful.
Start Slide Show with Cooliris
Leave a reply