[jboss-dev-forums] [Design of EJB 3.0] - javax.ejb.EJB Annotations Outside EJB3 Components

richard.opalka@jboss.com do-not-reply at jboss.com
Thu Apr 30 00:00:44 EDT 2009


This post relates to: JBWS-2634

Hi EJB3 Team,

   I need your help. I'm working on the above issue at the moment and there are many issues regarding the EJB specification defaults I'm dealing with.

Here's my usecase:

ad1) I defined EJB3 bean:

package org.jboss.test.ws.jaxws.jbws2634.shared;

import javax.ejb.Stateless;

@Stateless
public class BeanImpl implements BeanIface
{
   public String printString()
   {
      return "Injected hello message";
   }
}
---
package org.jboss.test.ws.jaxws.jbws2634.shared;

public interface BeanIface
{
   String printString();
}


ad2) Then I defined POJO webservice injecting the EJB3 bean:


package org.jboss.test.ws.jaxws.jbws2634.webservice;

import javax.ejb.EJB;
import javax.jws.WebService;

import org.jboss.test.ws.jaxws.jbws2634.shared.BeanIface;

@WebService
(
   serviceName = "EndpointService", 
   targetNamespace = "http://jbossws.org/JBWS2634", 
   endpointInterface="org.jboss.test.ws.jaxws.jbws2634.webservice.POJOIface"
)
public class POJOBean implements POJOIface
{
   @EJB
   private BeanIface testBean;

   public String getMessage()
   {
      return testBean.printString();
   }
}
---
package org.jboss.test.ws.jaxws.jbws2634.webservice;

import javax.jws.WebMethod;
import javax.jws.WebService;
import javax.jws.soap.SOAPBinding;

@WebService
@SOAPBinding(style = SOAPBinding.Style.RPC)
public interface POJOIface
{
   @WebMethod
   String getMessage();
}


Issue I'm dealing with:

 * Above usecase doesn't work because I don't know how to construct/obtain injected EJB3 JNDI name. Is it possible to do it outside EJB3 components (in my case from webservice code)?

I'm able to workaround this problem with specifying name attribute:

   @EJB(name = "jaxws-jbws2634/BeanImpl/local-org.jboss.test.ws.jaxws.jbws2634.shared.BeanIface")
   private BeanIface testBean;

but I'd like to support both usecases i.e. with/out name EJB annotation attribute.

Also javax.ejb.EJB annotation is really confusing me. What's the difference between name and mappedName? Where in the EJB spec I can find exhausting description of this annotation?


View the original post : http://www.jboss.org/index.html?module=bb&op=viewtopic&p=4227690#4227690

Reply to the post : http://www.jboss.org/index.html?module=bb&op=posting&mode=reply&p=4227690



More information about the jboss-dev-forums mailing list