<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<body link="#355491" alink="#4262a1" vlink="#355491" style="background: #e2e2e2; margin: 0; padding: 20px;">

<div>
        <table cellpadding="0" bgcolor="#FFFFFF" border="0" cellspacing="0" style="border: 1px solid #dadada; margin-bottom: 30px; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                <tbody>
                        <tr>

                                <td>

                                        <table border="0" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" style="border: solid 2px #ccc; background: #dadada; width: 100%; -moz-border-radius: 6px; -webkit-border-radius: 6px;">
                                                <tbody>
                                                        <tr>
                                                                <td bgcolor="#000000" valign="middle" height="58px" style="border-bottom: 1px solid #ccc; padding: 20px; -moz-border-radius-topleft: 3px; -moz-border-radius-topright: 3px; -webkit-border-top-right-radius: 5px; -webkit-border-top-left-radius: 5px;">
                                                                        <h1 style="color: #333333; font: bold 22px Arial, Helvetica, sans-serif; margin: 0; display: block !important;">
                                                                        <!-- To have a header image/logo replace the name below with your img tag -->
                                                                        <!-- Email clients will render the images when the message is read so any image -->
                                                                        <!-- must be made available on a public server, so that all recipients can load the image. -->
                                                                        <a href="http://community.jboss.org/index.jspa" style="text-decoration: none; color: #E1E1E1">JBoss Community</a></h1>
                                                                </td>

                                                        </tr>
                                                        <tr>
                                                                <td bgcolor="#FFFFFF" style="font: normal 12px Arial, Helvetica, sans-serif; color:#333333; padding: 20px;  -moz-border-radius-bottomleft: 4px; -moz-border-radius-bottomright: 4px; -webkit-border-bottom-right-radius: 5px; -webkit-border-bottom-left-radius: 5px;"><h3 style="margin: 10px 0 5px; font-size: 17px; font-weight: normal;">
    Service Override in JNDI
</h3>
<span style="margin-bottom: 10px;">
    created by <a href="http://community.jboss.org/people/ThomasGo">Thomas Goettlich</a> in <i>JNDI and Naming</i> - <a href="http://community.jboss.org/message/572722#572722">View the full discussion</a>
</span>
<hr style="margin: 20px 0; border: none; background-color: #dadada; height: 1px;">

<div class="jive-rendered-content"><p>Hi,</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>before I ask my question, here's a short description of what we try to do:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>We are building a platform for our projects that consists of multiple components.</p><p>Each component contains entities, data access objects and business services.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>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.</p><p>The daos are abstract generic services, i.e. they provide generic implementations but are not annotated with @Stateless.</p><p>The services are neither generic nor abstract and thus might be extended but the logic must not be overridden.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>A short example to illustrate my description:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The user component contains the following classes:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>@Entity</p><p>UserEntity{ /<strong>code here</strong>/ }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>abstract class UserDAOBean</p><p>{</p><p>&#160;&#160;&#160;&#160; doCrudStuff(Entity user) { ... }</p><p>}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>@Stateless</p><p>@Local (IUserService.class)</p><p>class UserServiceBean</p><p>{</p><p>&#160; doBusinessLogic(UserEntity user) { ... }</p><p>}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The project needs to extend UserEntity and thus we have the following:</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>@Entity</p><p>ProjectUserEntity extends UserEntity { /<strong>additional attributes</strong>/ }</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>@Stateless</p><p>ProjectUserDAOBean extends UserDAOBean</p><p>{</p><p> @Override</p><p> doCrudStuff(ProjectUserEntity user) { /*some extended or changed code here */ }</p><p>}</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>This works so far.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>The problem are the business services.</p><p>When I want to extend UserServiceBean, that's no problem. I then just add a ProjectUserServiceBean and call that where needed.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>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.</p><p>I can't change the calling services and thus have to rely on JNDI to return the correct service.</p><p>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).</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>So I need UserServiceBean not to be returned by JNDI or not be registered in JNDI at all.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Finally the question: Is that possible? If so, how?</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Thanks in advance.</p><p style="min-height: 8pt; height: 8pt; padding: 0px;">&#160;</p><p>Thomas</p></div>

<div style="background-color: #f4f4f4; padding: 10px; margin-top: 20px;">
    <p style="margin: 0;">Reply to this message by <a href="http://community.jboss.org/message/572722#572722">going to Community</a></p>
        <p style="margin: 0;">Start a new discussion in JNDI and Naming at <a href="http://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2083">Community</a></p>
</div></td>
                        </tr>
                    </tbody>
                </table>


                </td>
            </tr>
        </tbody>
    </table>

</div>

</body>
</html>