User: starksm
Date: 02/04/04 11:06:27
Modified: src/main/org/jboss/ejb Tag: Branch_2_4 Container.java
Log:
Add support for ejb-local-ref values to web apps.
Revision Changes Path
No revision
No revision
1.44.2.9 +18 -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.44.2.8
retrieving revision 1.44.2.9
diff -u -r1.44.2.8 -r1.44.2.9
--- Container.java 20 Nov 2001 09:42:48 -0000 1.44.2.8
+++ Container.java 4 Apr 2002 19:06:27 -0000 1.44.2.9
@@ -41,6 +41,7 @@
import javax.sql.DataSource;
import org.jboss.logging.Logger;
+import org.jboss.naming.Util;
import org.jboss.security.AuthenticationManager;
import org.jboss.security.RealmMapping;
@@ -70,7 +71,7 @@
* @author Rickard �berg ([EMAIL PROTECTED])
* @author <a href="[EMAIL PROTECTED]">Marc Fleury</a>
* @author [EMAIL PROTECTED]
- * @version $Revision: 1.44.2.8 $
+ * @version $Revision: 1.44.2.9 $
*/
public abstract class Container
{
@@ -481,10 +482,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()));
-
- // 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()));
+ Util.bind(envCtx, ref.getName(), new
LinkRef(refContainer.getBeanMetaData().getJndiName()));
}
else
{
@@ -494,7 +492,7 @@
throw new DeploymentException("ejb-ref "+ref.getName()+",
expected either ejb-link in ejb-jar.xml or jndi-name in jboss.xml");
}
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()));
}
}
}
@@ -502,29 +500,22 @@
// Bind Local EJB references
{
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();
- log.debug("Binding an EJBLocalReference "+ref.getName());
+ String refName = ref.getName();
+ log.debug("Binding an EJBLocalReference "+refName);
if (ref.getLink() != null)
{
// Internal link
- log.debug("Binding "+ref.getName()+" 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 );
-
+ String refLink = ref.getLink();
+ log.debug("Binding "+refName+" to bean source: "+refLink);
+ Container refContainer = getApplication().getContainer(refLink);
+ if( refContainer == null )
+ throw new DeploymentException ("Bean "+refLink+" not found
within this application.");
+ Util.bind(envCtx, refName, new
LinkRef(refContainer.getBeanMetaData().getLocalJndiName()));
}
else
{
@@ -586,7 +577,7 @@
try
{
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());
@@ -596,7 +587,7 @@
{
// Resource Manager bindings, should validate the type...
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));
}
}
}
@@ -611,7 +602,7 @@
String jndiName = resRef.getJndiName();
// Should validate the type...
log.debug("Binding env resource: "+jndiName+ " to JDNI ENC as: "
+encName);
- bind(envCtx, encName, new LinkRef(jndiName));
+ Util.bind(envCtx, encName, new LinkRef(jndiName));
}
}
@@ -625,8 +616,8 @@
if( securityDomain != null )
{
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"));
}
log.debug("End java:comp/env for EJB: "+beanMetaData.getEjbName());
@@ -638,34 +629,4 @@
}
-
- /**
- * Bind a value to a name in a JNDI-context, and create any missing subcontexts
- *
- * @param ctx
- * @param name
- * @param val
- * @exception 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