[jboss-user] [JNDI and Naming] - Service Override in JNDI

Thomas Goettlich do-not-reply at jboss.com
Wed Nov 24 06:05:54 EST 2010

Thomas Goettlich [http://community.jboss.org/people/ThomasGo] created the discussion

"Service Override in JNDI"

To view the discussion, visit: http://community.jboss.org/message/572722#572722


before I ask my question, here's a short description of what we try to do:

We are building a platform for our projects that consists of multiple components.
Each component contains entities, data access objects and business services.

If we use those components in a project and need to extend the entities, we inherit from the base entity and the dao but not from the service.
The daos are abstract generic services, i.e. they provide generic implementations but are not annotated with @Stateless.
The services are neither generic nor abstract and thus might be extended but the logic must not be overridden.

A short example to illustrate my description:

The user component contains the following classes:

UserEntity{ /*code here*/ }

abstract class UserDAOBean
     doCrudStuff(Entity user) { ... }

@Local (IUserService.class)
class UserServiceBean
  doBusinessLogic(UserEntity user) { ... }

The project needs to extend UserEntity and thus we have the following:

ProjectUserEntity extends UserEntity { /*additional attributes*/ }

ProjectUserDAOBean extends UserDAOBean
 doCrudStuff(ProjectUserEntity user) { /*some extended or changed code here */ }

This works so far.

The problem are the business services.
When I want to extend UserServiceBean, that's no problem. I then just add a ProjectUserServiceBean and call that where needed.

However, when I need to override a method - e.g. doBusinessLogic - I need other services to use the overriding service instead of the base one.
I can't change the calling services and thus have to rely on JNDI to return the correct service.
The problem is, that the JBoss 4.2.3 implemantion (that's what we're using) returns any service that implements the IUserService interface (and declares it as its local interface).

So I need UserServiceBean not to be returned by JNDI or not be registered in JNDI at all.

Finally the question: Is that possible? If so, how?

Thanks in advance.


Reply to this message by going to Community

Start a new discussion in JNDI and Naming at Community

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20101124/7322fbda/attachment.html 

More information about the jboss-user mailing list