User: user57  
  Date: 02/02/23 21:04:59

  Modified:    src/main/org/jboss/web AbstractWebContainer.java
  Log:
   o moved findEjb*Link methods to AbstractWebContainer, they don't have
     any business inside DI
  
  Revision  Changes    Path
  1.34      +83 -3     jboss/src/main/org/jboss/web/AbstractWebContainer.java
  
  Index: AbstractWebContainer.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/web/AbstractWebContainer.java,v
  retrieving revision 1.33
  retrieving revision 1.34
  diff -u -r1.33 -r1.34
  --- AbstractWebContainer.java 22 Feb 2002 04:24:56 -0000      1.33
  +++ AbstractWebContainer.java 24 Feb 2002 05:04:59 -0000      1.34
  @@ -43,6 +43,8 @@
   import org.jboss.deployment.DeploymentException;
   import org.jboss.deployment.J2eeApplicationMetaData;
   import org.jboss.deployment.J2eeModuleMetaData;
  +import org.jboss.metadata.ApplicationMetaData;
  +import org.jboss.metadata.BeanMetaData;
   import org.jboss.metadata.EjbRefMetaData;
   import org.jboss.metadata.EjbLocalRefMetaData;
   import org.jboss.metadata.EnvEntryMetaData;
  @@ -146,7 +148,7 @@
   @see org.jboss.security.SecurityAssociation;
   
   @author  [EMAIL PROTECTED]
  -@version $Revision: 1.33 $
  +@version $Revision: 1.34 $
   */
   public abstract class AbstractWebContainer 
      extends ServiceMBeanSupport 
  @@ -675,6 +677,84 @@
         }
      }
   
  +   /** 
  +    * A method that walks through the DeploymentInfo hiearchy looking
  +    * for the ejb-name that corresponds to the given ejb-link value.
  +    *
  +    * @param ejbLink, the ejb-link value from the ejb-jar.xml or web.xml
  +    * descriptor to find. Need to add support for the <path>/ejb.jar#ejb-name style.
  +    * @return The deployment JNDI name of the ejb home to which the ejbLink
  +    * refers if it is found, null if no such ejb exists.
  +    */
  +   public String findEjbLink(DeploymentInfo parent, String ejbLink)
  +   {
  +      // Walk up to the topmost DeploymentInfo
  +      DeploymentInfo top = parent;
  +      while( top != null && top.parent != null )
  +         top = top.parent;
  +      if( top == null )
  +         return null;
  +      // Search from the top for a matching ejb
  +      return findEjbLink(top, ejbLink, false);
  +   }
  +
  +   /** 
  +    * A method that walks through the DeploymentInfo hiearchy looking
  +    * for the ejb-name that corresponds to the given ejb-link value.
  +    *
  +    * @param ejbLink, the ejb-link value from the ejb-jar.xml or web.xml
  +    * descriptor to find. Need to add support for the <path>/ejb.jar#ejb-name style.
  +    * @return The deployment JNDI name of the ejb local home to which the ejbLink
  +    * refers if it is found, null if no such ejb exists.
  +    */
  +   public String findEjbLocalLink(DeploymentInfo parent, String ejbLink)
  +   {
  +      // Walk up to the topmost DeploymentInfo
  +      DeploymentInfo top = parent;
  +      while( top != null && top.parent != null )
  +         top = top.parent;
  +      if( top == null )
  +         return null;
  +      // Search from the top for a matching ejb
  +      return findEjbLink(top, ejbLink, true);
  +   }
  +
  +   /** 
  +    * Recursively search the DeploymentInfo looking for ApplicationMetaData
  +    * nodes that may contain a BeanMetaData keyed by the ejbLink value.
  +    *
  +    * @param isLocal, a flag indicating if the JNDI name requested is for the
  +    * local home vs the remote home.
  +    */
  +   private static String findEjbLink(DeploymentInfo parent, String ejbLink,
  +      boolean isLocal)
  +   {
  +      String ejbName = null;
  +      // Search the parent if it has ApplicationMetaData
  +      if( parent.metaData instanceof ApplicationMetaData )
  +      {
  +         ApplicationMetaData appMD = (ApplicationMetaData) parent.metaData;
  +         BeanMetaData beanMD = appMD.getBeanByEjbName(ejbLink);
  +         if( beanMD != null )
  +         {
  +            if( isLocal == true )
  +               ejbName = beanMD.getLocalJndiName();
  +            else
  +               ejbName = beanMD.getJndiName();
  +            return ejbName;
  +         }
  +      }
  +      // Search each subcontext
  +      Iterator iter = parent.subDeployments.iterator();
  +      while( iter.hasNext() && ejbName == null )
  +      {
  +         DeploymentInfo child = (DeploymentInfo) iter.next();
  +         ejbName = findEjbLink(child, ejbLink, isLocal);
  +      }
  +      return ejbName;
  +   }
  +
  +
      protected void linkEjbRefs(Iterator ejbRefs, Context envCtx, DeploymentInfo di)
         throws NamingException
      {      
  @@ -687,7 +767,7 @@
            if( jndiName == null )
            {
               // Search the DeploymentInfo for a match
  -            jndiName = di.findEjbLink(linkName);
  +            jndiName = findEjbLink(di, linkName);
               if( jndiName == null )
                  throw new NamingException("ejb-ref: "+name+", no ejb-link match, use 
jndi-name in jboss-web.xml");
            }
  @@ -704,7 +784,7 @@
            EjbLocalRefMetaData ejb = (EjbLocalRefMetaData) ejbRefs.next();
            String name = ejb.getName();
            String linkName = ejb.getLink();
  -         String jndiName = di.findEjbLocalLink(linkName);
  +         String jndiName = findEjbLocalLink(di, linkName);
   
            if( jndiName == null )
               throw new NamingException("ejb-local-ref: "+name+", target not found, 
add valid ejb-link");
  
  
  

_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development

Reply via email to