Christian, welcome to the forums.
Christian Strempfer wrote:
return ServiceLocator.findEJBService(TestService.class, "ejb/TestService")My intention is to keep the deployment transparent for the developers. They can use @EJB as normal, but will end up using the service locator.
Isn't it already transparent? I mean each developer just has to do @EJB. That's it! I'm not sure I understand the rationale behind using the ServiceLocator.
There are EJBs distributed across different servers, which have their own Java Naming Directories. Because of that I cannot define exactly one JNDI-URL for the lookup. The service locator is configured, so that it can determine the lookup URL.
I do not understand why you will spread EJBs accross different server.
@EJB will be transparent.
A individual lookup will increase the complexity. Also you might have problems with transaction handling.
Thank you for your advice about transaction handling, but the deployment scenario is not up for discussion, it is a specified requirement. We have application components which may be deployed independently on different servers. Also there are components which need access to other components on more than one server.
No, this is special. If you want to decide which server you want to connect the only way IMHO is to code it.
One option is a @PostConstruct initializer will fill, another one can be a Interceptor and your own annotation.