-
1. Re: is it still a good idea to have a separate project only for the ejb interfaces?
sfcoy Jun 2, 2012 9:52 PM (in response to jaabax)In my opinion you should use a separate module/project for all remote interfaces (and dependent POJOs).
The use of a separate module/project is needless complexity if there are no remote calls.
-
2. Re: is it still a good idea to have a separate project only for the ejb interfaces?
jaabax Jun 3, 2012 9:58 AM (in response to sfcoy)for now there is no remote calls in my system
but I want to be guarded if someday I need it because a mobile module is to be made next year
I was thinking and its really a good idea, because I can give only the interfaces jar to the develop team, so they can unse the interface type to call the methods when getting the service via jndi
-
3. Re: is it still a good idea to have a separate project only for the ejb interfaces?
sfcoy Jun 4, 2012 1:13 AM (in response to jaabax)I would avoid doing it until you have some kind of concrete architecture in place that includes your mobile module. Don't make life harder than it needs to be!
Also, in JEE terms, code deployed externally to the application unit (ie. the EAR) is considered to be remote even if it is deployed in the same server instance.
-
4. Re: is it still a good idea to have a separate project only for the ejb interfaces?
wdfink Jun 4, 2012 2:01 AM (in response to jaabax)I think this is nothing special to AS7.
It is more a general architecture desicion whether you separate the interfaces.
I have an application where the local interfaces are combinded with some additional classes for a 'friend' usage, i.e. add-ons, extensions and products using this, but only for inner-company or partner use.
The remote interfaces are separated with some additional classes to represent the official API.
This is to avoid call-by-reference and class dependencies for unknown applications.
-
5. Re: is it still a good idea to have a separate project only for the ejb interfaces?
jaabax Jun 4, 2012 8:27 PM (in response to wdfink)Wolf-Dieter Fink, how do you separate this remote and inner-company interfaces? In 2 different projects?
About this I was thinking...
In create my EJB client projects: my-app-ejb-inner-company-client.jar and my-app-ejb-remote-client.jar
Than the main package for the inner-company interfaces: com.my.app.client.inner.company
Than the main package for the remote interfaces: com.my.app.client.remote
Will there be issues because of the different package names of the interfaces in each project? (When the third-party code look-up the interface via JNDI, think, my implementation will have to choose one interface to implement, or maybe both? I'm confused.)
In both projects, the interfaces packages must have the same name?
Thanks in advance.
-
6. Re: is it still a good idea to have a separate project only for the ejb interfaces?
wdfink Jun 5, 2012 2:27 AM (in response to jaabax)At this time where I used that I've used ant as build-tool. Here it is no problem to build different jar's and ear's from the same project and source path.
In your case it's simple you might split by package name.
If ouy use maven I'm not sure whether it is possible, but I think it is at least uncommon. So I would split in different projects with dependencies.
The package and class names must not match, only requirement is that the implementation should implement it.
In EJB2 the implmentation does not 'implements' the interfaces.
With EJB3 I would add 'implements' to my bean class for compiler dependencies.
-
7. Re: is it still a good idea to have a separate project only for the ejb interfaces?
jaabax Jun 5, 2012 9:21 PM (in response to wdfink)So for example... if I have MBeanImpl.java... this bean should implement both, MBeanInnerCompanyInterface.java and MBeanRemoteInterface.java?
And should I use @javax.ejb.Remote passing both interface as parameters to the annotation?
Example:
{code}
public interface MBeanInnerCompanyInterface {
void businessMethod1(String parameter);
void businessMethod2OnlyForInnerCompany(String[] parameter);
}
public interface MBeanRemoteInterface {
void businessMethod1(String parameter);
}
@Remote({ MBeanInnerCompanyInterface.class, MBeanRemoteInterface.class })
public class MBeanImpl implements MBeanInnerCompanyInterface, MBeanRemoteInterface {
void businessMethod1(String parameter) {
...
}
void businessMethod2OnlyForInnerCompany(String[] parameter) {
...
}
}
{code}
Thanks a lot for you help guys.
-
8. Re: is it still a good idea to have a separate project only for the ejb interfaces?
wdfink Jun 6, 2012 1:56 AM (in response to jaabax)I prefer the annotation @javax.ejb.Remote (Local) at interface side and implements on the implementataion.
Also as I understand you want have InnerCompany as a local interface, right?
But nevertheless based on the DRY (dont repeat yourselve) paradigm you should use "extends MBeanRemoteInterface" instead of writing the method again.
-
9. Re: is it still a good idea to have a separate project only for the ejb interfaces?
jaabax Jun 7, 2012 1:44 PM (in response to wdfink)Yes Wolf-Dieter Fink... InnerCompany as a local interface... I forgot this annotation.
Let me extend the example so... Imagine that you need 2 local interfaces and 2 remote interface (each one, local and remote, with different methods to expose).
The below, is the correct implementation (look that I have different methods for each client of my EJBs)?
{code}
@Local
public interface MBeanInnerCompanyInterfaceA {
void businessMethod1(String parameter);
void businessMethod2OnlyForInnerCompany(String[] parameter);
}
@Local
public interface MBeanInnerCompanyInterfaceB {
void businessMethod2OnlyForInnerCompany(String[] parameter);
}
@Remote
public interface MBeanRemoteInterface1 {
void anotherBusinessMethod3(String parameter);
}
@Remote
public interface MBeanRemoteInterface2 {
void oneMoreBusinessMethod4(String parameter);
}
// Should I implement all interfaces?
public class MBeanImpl implements MBeanInnerCompanyInterfaceA, MBeanInnerCompanyInterfaceB, MBeanRemoteInterface1, MBeanRemoteInterface2 {
// ...all implementations of the interfaces above...
}
{code}
Sorry to be extending this post so long but I'll be entering in a project soon and I really need to understand this EJB architecture.
Thanks a lot.