User: starksm Date: 02/02/16 19:06:45 Modified: src/main/org/jboss/ejb Container.java Log: The linking of ejb-local-refs was uneccessarily generating jndi names when a simple LinkRef to the BaseLocalContainerInvoker home proxy works just fine. Revision Changes Path 1.76 +19 -57 jboss/src/main/org/jboss/ejb/Container.java Index: Container.java =================================================================== RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/ejb/Container.java,v retrieving revision 1.75 retrieving revision 1.76 diff -u -r1.75 -r1.76 --- Container.java 16 Feb 2002 18:31:38 -0000 1.75 +++ Container.java 17 Feb 2002 03:06:45 -0000 1.76 @@ -55,6 +55,7 @@ import org.jboss.metadata.ResourceRefMetaData; import org.jboss.metadata.ResourceEnvRefMetaData; import org.jboss.metadata.ApplicationMetaData; +import org.jboss.naming.Util; import org.jboss.security.AuthenticationManager; import org.jboss.security.RealmMapping; @@ -78,7 +79,7 @@ * @author <a href="mailto:[EMAIL PROTECTED]">Marc Fleury</a> * @author <a href="mailto:[EMAIL PROTECTED]">Scott Stark</a>. * @author <a href="[EMAIL PROTECTED]">Bill Burke</a> -* @version $Revision: 1.75 $ +* @version $Revision: 1.76 $ ** <p><b>Revisions:</b> * * <p><b>2001/07/26 bill burke:</b> @@ -819,7 +820,7 @@ Container refContainer = getApplication().getContainer(ref.getLink()); if (refContainer == null) throw new DeploymentException ("Bean "+ref.getLink()+" not found within this application."); - bind(envCtx, ref.getName(), new LinkRef(refContainer.getBeanMetaData().getJndiName())); + Util.bind(envCtx, ref.getName(), new LinkRef(refContainer.getBeanMetaData().getJndiName())); // bind(envCtx, ref.getName(), new Reference(ref.getHome(), new StringRefAddr("Container",ref.getLink()), getClass().getName()+".EjbReferenceFactory", null)); // bind(envCtx, ref.getName(), new LinkRef(ref.getLink())); @@ -833,7 +834,7 @@ } if (debug) log.debug("Binding "+ref.getName()+" to external JNDI source: "+ref.getJndiName()); - bind(envCtx, ref.getName(), new LinkRef(ref.getJndiName())); + Util.bind(envCtx, ref.getName(), new LinkRef(ref.getJndiName())); } } } @@ -842,30 +843,23 @@ { Iterator enum = beanMetaData.getEjbLocalReferences(); // unique key name - String uniqueKey = Long.toString( (new java.util.Date()).getTime() ); + String localJndiName = beanMetaData.getLocalJndiName(); while(enum.hasNext()) { - EjbLocalRefMetaData ref = (EjbLocalRefMetaData)enum.next(); - if (debug) - log.debug("Binding an EJBLocalReference "+ref.getName()); + String refName = ref.getName(); + log.debug("Binding an EJBLocalReference "+ref.getName()); if (ref.getLink() != null) { // Internal link - if (debug) - log.debug("Binding "+ref.getName()+" to bean source: "+ref.getLink()); + log.debug("Binding "+refName+" to bean source: "+ref.getLink()); if (getApplication().getContainer(ref.getLink()) == null) throw new DeploymentException ("Bean "+ref.getLink()+" not found within this application."); - // get local home - // bind it into the local namespace - LocalHomeObjectFactory.rebind( uniqueKey + ref.getName(), - getApplication(), getApplication().getContainer(ref.getLink()) ); - StringRefAddr refAddr = new StringRefAddr("nns", uniqueKey+ref.getName() ); - Reference jndiRef = new Reference(ref.getLocalHome(), - refAddr, LocalHomeObjectFactory.class.getName(), null ); - bind(envCtx, ref.getName(), jndiRef ); - + /* Create a link from the ENC to the localJndiName where the + which is the location of the local home + */ + Util.bind(envCtx, refName, new LinkRef(localJndiName)); } else { @@ -873,7 +867,7 @@ } } } - + // Bind resource references { Iterator enum = beanMetaData.getResourceReferences(); @@ -929,7 +923,7 @@ { if (debug) log.debug("Binding URL: "+finalName+ " to JDNI ENC as: " +ref.getRefName()); - bind(envCtx, ref.getRefName(), new URL(finalName)); + Util.bind(envCtx, ref.getRefName(), new URL(finalName)); } catch (MalformedURLException e) { throw new NamingException("Malformed URL:"+e.getMessage()); @@ -940,7 +934,7 @@ // Resource Manager bindings, should validate the type... if (debug) log.debug("Binding resource manager: "+finalName+ " to JDNI ENC as: " +ref.getRefName()); - bind(envCtx, ref.getRefName(), new LinkRef(finalName)); + Util.bind(envCtx, ref.getRefName(), new LinkRef(finalName)); } } } @@ -956,7 +950,7 @@ // Should validate the type... if (debug) log.debug("Binding env resource: "+jndiName+ " to JDNI ENC as: " +encName); - bind(envCtx, encName, new LinkRef(jndiName)); + Util.bind(envCtx, encName, new LinkRef(jndiName)); } } @@ -971,8 +965,8 @@ { if (debug) log.debug("Binding securityDomain: "+securityDomain+ " to JDNI ENC as: security/security-domain"); - bind(envCtx, "security/security-domain", new LinkRef(securityDomain)); - bind(envCtx, "security/subject", new LinkRef(securityDomain+"/subject")); + Util.bind(envCtx, "security/security-domain", new LinkRef(securityDomain)); + Util.bind(envCtx, "security/subject", new LinkRef(securityDomain+"/subject")); } if (debug) @@ -984,37 +978,5 @@ throw new DeploymentException("Could not set up environment", e); } } - - - /** - * Bind a value to a name in a JNDI-context, and create any missing - * subcontexts. - * - * @param ctx - * @param name - * @param val - * - * @throws NamingException - */ - private void bind(Context ctx, String name, Object val) - throws NamingException - { - // Bind val to name in ctx, and make sure that all - // intermediate contexts exist - Name n = ctx.getNameParser("").parse(name); - while (n.size() > 1) - { - String ctxName = n.get(0); - try - { - ctx = (Context)ctx.lookup(ctxName); - } catch (NameNotFoundException e) - { - ctx = ctx.createSubcontext(ctxName); - } - n = n.getSuffix(1); - } - - ctx.bind(n.get(0), val); - } + }
_______________________________________________ Jboss-development mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jboss-development
