Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Remote Application Platform (RAP) » RWT Standalone and EJB access
RWT Standalone and EJB access [message #1073731] Thu, 25 July 2013 11:46 Go to next message
Milko Krastev is currently offline Milko KrastevFriend
Messages: 17
Registered: July 2013
Junior Member
Using servlets, one can easily inject EJBs using the @EJB annotation. Can I achieve the same thing with RAP? Let's consider the following scenario:

@Stateless
public class MyStatelessBean {
      public String getApplicationName() {
                  return "My application";
      }
}

public class MyApplication implements EntryPoint {
        
        @EJB
        MyStatelessBean myBean;

        public int createUI() {
            Shell shell = new Shell();
            shell.setText(myBean!=null?myBean.getApplicationName():"null");
            return 0;
        }
}

I've done all the standard plumbing in order to deploy my application to JBoss. And it works, sort of ... But myBean is null.

The question really is:

Can I access my service layer from RAP using annotations and injections?

A kind of E4 approach. Or the only way is JNDI lookup? Obviously using the new operator for creating an object (some part of the UI) prevents the EJB container from injecting into that object, but is there any clever workaround I am missing?
Re: RWT Standalone and EJB access [message #1077410 is a reply to message #1073731] Thu, 01 August 2013 17:00 Go to previous messageGo to next message
Milko Krastev is currently offline Milko KrastevFriend
Messages: 17
Registered: July 2013
Junior Member
Since no one has replied so far, I assume JNDI is the only realistic solution. Then, I have another question. Should I implement the Service Locator pattern as a singleton for all users, or each user should have her own service locator? I can't really estimate what overhead many InitialContext objects would cause ...

Has anyone ever combined Spring AOP (@Configurable) with RWT standalone deployment in order to access the service layer from non managed UI objects as described in the following blog:

blog.codecentric.de/en/2011/12/swt-and-springs-configurable-dependency-injection-for-the-ui/

Re: RWT Standalone and EJB access [message #1078590 is a reply to message #1073731] Sat, 03 August 2013 07:53 Go to previous message
Ralf Sternberg is currently offline Ralf SternbergFriend
Messages: 1291
Registered: July 2009
Senior Member

In the JEE compatibility mode (the default for non-workbench
applications) you should be able to access your EJBs directly. If it's a
workbench application, you could try to wrap the EJB lookup in a
runnable and execute it in an RWT.requestThreadExec().

HTH, Ralf

--
Ralf Sternberg

Twitter: @EclipseRAP
Blog: http://eclipsesource.com/blogs/

Professional services for RAP and RCP?
http://eclipsesource.com/services/rap/
Previous Topic:Popup Menu can be used in RAP?
Next Topic:Bundles Problem in RAP
Goto Forum:
  


Current Time: Mon Nov 24 15:11:39 GMT 2014

Powered by FUDForum. Page generated in 0.02115 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software