14 Replies Latest reply on May 22, 2008 4:07 PM by alrubinger

    EJBTHREE-1062 and metadata

    starksm64

      So one problem I'm seeing with trying to extract the jndi names is due to the EJBTHREE-1062 issue where a single interface not annotated with @Remote is assumed to be @Local. Such a bean's metadata has no local interfaces defined. I guess the annotation processing needs to perform this mapping.

        • 1. Re: EJBTHREE-1062 and metadata
          alrubinger

          Yes, this is one example of Spec-defined logic that I'd like performed by jboss-metadata (not a deployer responsible for populating JBossSessionMetadata).

          Another example is:

          @RemoteHome
          public interface RemoteHome extends EJBHome{
          
           public RemoteInterface1 create();
          
           public RemoteInterface2 create2();
          
          }


          The above example defines 2 EJB2.x Remote interfaces, even though they're not explicitly marked as such anywhere.

          That's EJBTHREE-1127, defined by:

          "EJB3 Core Specification 3.6.2.1" wrote:
          The return type of a create<METHOD> method on the remote home interface is the session bean's remote interface.


          Currently this is being handled (improperly?) by Proxy generation code. Metadata doesn't access the ClassLoader for the Container, so I don't see a way to handle this there now. Ideas?

          S,
          ALR

          • 2. Re: EJBTHREE-1062 and metadata
            starksm64

            The annotation processing is run with the deployment class loader, so that logic can be added to the @RemoteHome annotation handler.
            http://jira.jboss.com/jira/browse/JBMETA-41

            • 3. Re: EJBTHREE-1062 and metadata
              wolfc

              The above example is invalid. An EJB 2.1 view can't have multiple remote/local interfaces. (As per quoted spec.)

              Note that the use of @Remote in EJBTHREE-1127 is liberal versus spec. In actuality @Remote should only be used to specify remote business interfaces. The remote interface is always inferred from the remote home.

              • 4. Re: EJBTHREE-1062 and metadata
                alrubinger

                 

                "wolfc" wrote:
                The above example is invalid. An EJB 2.1 view can't have multiple remote/local interfaces. (As per quoted spec.)


                Whoops, bad example, should look like:

                @RemoteHome
                public interface RemoteHome extends EJBHome{
                
                 public RemoteInterface create();
                
                 public RemoteInterface create(String whatever);
                
                }


                There may be only one "create" method for SLSB, but there may be any N "create" methods for SFSB.

                The logic attached in the issue should be good, even if my contrived example was bogus.

                I don't see why this invalidates JBMETA-41; still need to determine the remote/local interface from the return type(s) of the home.

                S,
                ALR

                • 5. Re: EJBTHREE-1062 and metadata
                  emuckenhuber

                  While adding the logic described in JBMETA-41 to jboss-metadata there are now 3 tests failing, due the following:

                  package org.jboss.test.metadata.annotation.ejb3;
                  
                  @Stateful(name="AnotherName")
                  @Remote(MyStateful.class)
                  @RemoteHome(MyStatefulHome.class)
                  public class MyStatefulBean
                  {
                   ...
                  }
                  
                  public interface MyStatefulHome extends EJBHome
                  {
                   public MyStateful create(String x);
                  }
                  
                  public interface MyStateful
                  {
                  
                  }
                  


                  So MyStateful should actually extend extend javax.ejb.EjbHome and will be the remote interface for the stateful bean - instead of a BusinessRemote?
                  Or did i miss something? :)

                  Thanks,
                  Emanuel

                  • 6. Re: EJBTHREE-1062 and metadata
                    alrubinger

                    MyStateful should extend javax.ejb.EJBObject to become an EJB2.x Remote Interface.

                    Technically, @Remote is to designate business interfaces, so in this case it shouldn't be required on the SFSB implementation class. We happen to support its use for both EJB2.x Remote and EJB3 Business Remote, but for a valid EJB2.x view the interface must extend EJBObject.

                    S,
                    ALR

                    • 7. Re: EJBTHREE-1062 and metadata
                      emuckenhuber

                      Hmm i read in the spec (4.6.8-6):

                      The return type for a create method must be the session bean's remote interface type.

                      Does that not imply that if you have a RemoteHome the interface must be the remote business interface, which must extend the EJBObject? (sorry the EJBHome was typo)

                      Emanuel

                      • 8. Re: EJBTHREE-1062 and metadata
                        wolfc

                        Read 4.6.6 as well. :-)

                        • 9. Re: EJBTHREE-1062 and metadata
                          emuckenhuber

                          Yeah i read that too - maybe that's why i'm confused :)
                          so let me rephrase my question:

                          1) In this case we have MyStatefulBean -> MyStatefulHome -> MyStateful.
                          As we define a RemoteHome, the MyStateful interface must extend the EJBObject?

                          2) then we have 4.6.6 where they say: The interface must not extend the javax.ejb.EJBObject or javax.ejb.EJBLocalObject interface.
                          Which more or less means that a business interface can't be a Session Bean's Local or Remote Interface?

                          The actual problem i have is - after adding the functionality from the ProxyFactoryHelper to metadata - it should be that MyStateful extends EJBObject as it would be set as Remote interface.
                          But then the @Remote business interface would also be the remote interface.

                          Just wanted to ask how this should be handled correctly, as i don't want to break stuff :)

                          • 10. Re: EJBTHREE-1062 and metadata
                            alrubinger

                             

                            "emuckenhuber" wrote:
                            1) In this case we have MyStatefulBean -> MyStatefulHome -> MyStateful.
                            As we define a RemoteHome, the MyStateful interface must extend the EJBObject?


                            Yes. Because Home interfaces must return local/remote interfaces, and local/remote must extend EJBLocalObject/EJBObject.

                            "emuckenhuber" wrote:
                            2) then we have 4.6.6 where they say: The interface must not extend the javax.ejb.EJBObject or javax.ejb.EJBLocalObject interface.
                            Which more or less means that a business interface can't be a Session Bean's Local or Remote Interface?


                            Let's draw up some definitions first, because the wording in the spec is a little tricky.

                            * Business Interface - The EJB3 View, may be local or remote, and is denoted by the corresponding @Local and @Remote annotations.

                            * Remote Interface - The EJB2.x View, must extend from EJBObject, may only be obtained via the return of a create{METHOD} method of a Home interface (for SFSB) or the "create" method of a Home interface (for SLSB). See Spec 3.6.2.

                            So in regards to 4.6.6, they're talking only about *Business* interfaces, yes, saying that a business interface cannot also be a remote/local interface.

                            My solution to these tests is to make:

                            public interface MyStatefulRemote extends EJBObject{...}
                            
                            public interface MyStatefulRemoteBusiness{...}
                            
                            public interface MyStatefulRemoteHome extends EJBHome{
                             public MyStatefulRemote create() throws CreateException, RemoteException;
                            }
                            
                            @Stateful
                            @RemoteHome(MyStatefulRemoteHome.class)
                            @Remote(MyStatefulRemoteBusiness.class)
                            public class MyStatefulBean implements MyStatefulRemoteBusiness{...}


                            S,
                            ALR

                            • 11. Re: EJBTHREE-1062 and metadata
                              emuckenhuber

                              Yup i thought of doing the same to fix the tests.

                              But shouldn't metadata validate and fail when parsing the example above?
                              Referring to the RemoteProcessor which does smth like this:

                               // Although this is not explicitly allowed by the spec, we accept it
                               // EJB 3 4.6.7
                               if(EJBObject.class.isAssignableFrom(businessInterface))
                               {
                               if(metaData.getRemote() != null)
                               throw new IllegalArgumentException("2.1 bean " + metaData.getEjbName() + " already has a remote interface " + metaData.getRemote() + ", can't add " + businessInterface.getName());
                               metaData.setRemote(businessInterface.getName());
                               }
                               else
                               {
                               metaData.getBusinessRemotes().add(businessInterface.getName());
                               }
                              


                              That means if you have:

                              @Stateful(name="AnotherName")
                              @Remote(MyStateful.class)
                              @RemoteHome(MyStatefulHome.class)
                              public class MyStatefulBean
                              {
                               ...
                              }
                              
                              public interface MyStatefulHome extends EJBHome
                              {
                               public MyStateful create(String x);
                              }
                              
                              public interface MyStateful extends EJBObject
                              {
                              
                              }
                              


                              Which would be ok as the return type of the RemoteHome extends EJBObject - it would just set MyStateful as Remote interface - and @Remote will be more or less ignored.
                              Is that ok / the expected behaviour?

                              • 12. Re: EJBTHREE-1062 and metadata
                                alrubinger

                                 

                                "emuckenhuber" wrote:
                                But shouldn't metadata validate and fail when parsing the example above?


                                No, why would it fail?

                                "emuckenhuber" wrote:
                                Which would be ok as the return type of the RemoteHome extends EJBObject - it would just set MyStateful as Remote interface - and @Remote will be more or less ignored.
                                Is that ok / the expected behaviour?


                                I think we should introduce another fail-fast and validate @Remote as the spec intends - for use in business remotes only. To allow EJB2.x Remotes in there is redundant and confusing. For this we'll need consensus from the other devs.

                                Also note that the IllegalArgumentException you show should reference the spec and give a more clear error message than that given. Can't add x because of y says Spec z. :)

                                S,
                                ALR

                                • 13. Re: EJBTHREE-1062 and metadata
                                  emuckenhuber

                                   

                                  "ALRubinger" wrote:

                                  Also note that the IllegalArgumentException you show should reference the spec and give a more clear error message than that given. Can't add x because of y says Spec z. :)


                                  Well i haven't added this code - it was already there :)

                                  Basically the only thing i was doing is setting the Home and LocalHome interface extracted from the Remote/LocalHome - similar to the code in ProxyFactoryHelper.
                                  This works fine, beside this part with @Remote and @Local.

                                  I mean It is no problem to keep this - to make it working without changing the testcases (except the example classes i posted)

                                  I just wanted ask before if this is supposed to be like this, as i read something different :)


                                  • 14. Re: EJBTHREE-1062 and metadata
                                    alrubinger

                                    I still think we should be checking @Remote and @Local within jboss-metadata to ensure they're valid business interfaces.

                                    Opposing opinions anyone? Remember backwards-compat with EJB3 RCx for AS 4.2.x is out the window.

                                    S,
                                    ALR