User: starksm 
  Date: 02/04/04 19:50:37

  Modified:    src/main/org/jboss/web Tag: Branch_2_4
                        AbstractWebContainer.java WebApplication.java
  Log:
  Process the web.xml ejb-link values to map ejb-local-refs to the
  local home location
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.4.4.12  +32 -12    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.4.4.11
  retrieving revision 1.4.4.12
  diff -u -r1.4.4.11 -r1.4.4.12
  --- AbstractWebContainer.java 4 Apr 2002 19:06:27 -0000       1.4.4.11
  +++ AbstractWebContainer.java 5 Apr 2002 03:50:37 -0000       1.4.4.12
  @@ -12,6 +12,7 @@
   import java.util.HashMap;
   import java.util.HashSet;
   import java.util.Iterator;
  +import javax.ejb.EJBLocalHome;
   import javax.naming.Context;
   import javax.naming.InitialContext;
   import javax.naming.LinkRef;
  @@ -42,7 +43,9 @@
   into the JBoss server JNDI namespace:
   - env-entry
   - resource-ref
  +- resource-env-ref
   - ejb-ref
  +- ejb-local-ref
   - security-domain
   
   Subclasses need to implement the {@link #performDeploy(WebApplication, String,
  @@ -111,12 +114,13 @@
   the authentication/authorization callouts in tomcat3.2.1 not having the same
   thread context ClassLoader as was used to dispatch the http service request.
   
  -For a complete example see the {@link 
org.jboss.tomcat.security.JBossSecurityMgrRealm JBossSecurityMgrRealm}
  -in the contrib/tomcat module.
  +For a complete example see the {@link 
org.jboss.web.catalina.security.JBossSecurityMgrRealm
  + JBossSecurityMgrRealm} in the contrib/catalina module.
   
  -@see #performDeploy(String, String)
  +@see #performDeploy(WebApplication webApp, String warUrl,
  +        WebDescriptorParser webAppParser)
   @see #performUndeploy(String)
  -@see #parseWebAppDescriptors(ClassLoader, Element, Element)
  +@see #parseWebAppDescriptors(ClassLoader, WebMetaData)
   @see #linkSecurityDomain(String, Context)
   @see org.jboss.security.SecurityManager;
   @see org.jboss.security.RealmMapping;
  @@ -124,9 +128,10 @@
   @see org.jboss.security.SecurityAssociation;
   
   @author  [EMAIL PROTECTED]
  -@version $Revision: 1.4.4.11 $
  +@version $Revision: 1.4.4.12 $
   */
  -public abstract class AbstractWebContainer extends ServiceMBeanSupport implements 
AbstractWebContainerMBean
  +public abstract class AbstractWebContainer extends ServiceMBeanSupport
  +   implements AbstractWebContainerMBean
   {
       public static interface WebDescriptorParser
       {
  @@ -163,18 +168,19 @@
       }
   
       /** A template pattern implementation of the deploy() method. This method
  -     calls the {@link #performDeploy(String, String) performDeploy()} method to
  +     calls the {@link #performDeploy(WebApplication, String,
  +        WebDescriptorParser) performDeploy()} method to
        perform the container specific deployment steps and registers the
        returned WebApplication in the deployment map. The steps performed are:
   
           ClassLoader appClassLoader = thread.getContextClassLoader();
           URLClassLoader warLoader = URLClassLoader.newInstance(empty, 
appClassLoader);
           thread.setContextClassLoader(warLoader);
  +        WebMetaData metaData = parseMetaData(ctxPath, warUrl);
           WebDescriptorParser webAppParser = ...;
  -        WebApplication warInfo = performDeploy(ctxPath, warUrl, webAppParser);
  +        WebApplication warInfo = new WebApplication(metaData);
  +        performDeploy(warInfo, warUrl, webAppParser);
           ClassLoader loader = warInfo.getClassLoader();
  -        Element webApp = warInfo.getWebApp();
  -        Element jbossWeb = warInfo.getJbossWeb();
           deploymentMap.put(warUrl, warInfo);
           thread.setContextClassLoader(appClassLoader);
   
  @@ -201,8 +207,7 @@
            WebDescriptorParser webAppParser = new DescriptorParser();
            // Parse the web.xml and jboss-web.xml descriptors
            WebMetaData metaData = parseMetaData(ctxPath, warUrl);
  -         WebApplication warInfo = new WebApplication();
  -         warInfo.setMetaData(metaData);
  +         WebApplication warInfo = new WebApplication(metaData);
            performDeploy(warInfo, warUrl, webAppParser);
            deploymentMap.put(warUrl, warInfo);
         }
  @@ -212,6 +217,7 @@
         }
         catch(Exception e)
         {
  +         log.error("Cause", e);
            throw new DeploymentException("Error during deploy", e);
         }
         finally
  @@ -446,6 +452,7 @@
      protected void linkEjbLocalRefs(Iterator ejbRefs, Context envCtx)
         throws NamingException
      {
  +      InitialContext iniCtx = new InitialContext();
         while( ejbRefs.hasNext() )
         {
            EjbLocalRefMetaData ejb = (EjbLocalRefMetaData) ejbRefs.next();
  @@ -454,6 +461,19 @@
   
            if( jndiName == null )
               throw new NamingException("ejb-local-ref: "+name+", target not found, 
add valid ejb-link");
  +         /* The ejb-link value should be resolved against the ear modules, but
  +          this info is not well maintained currently. Here we see if there is a
  +          LocalHome at jndiName, and if not, use local/jndiName.
  +         */
  +         try
  +         {
  +            Object ref = iniCtx.lookup(jndiName);
  +            if( (ref instanceof EJBLocalHome) == false )
  +               jndiName = "local/"+jndiName;
  +         }
  +         catch(NamingException e)
  +         {
  +         }
            log.debug("Linking ejb-local-ref: "+name+" to JNDI name: "+jndiName);
            Util.bind(envCtx, name, new LinkRef(jndiName));
         }
  
  
  
  1.2.6.2   +10 -2     jboss/src/main/org/jboss/web/WebApplication.java
  
  Index: WebApplication.java
  ===================================================================
  RCS file: /cvsroot/jboss/jboss/src/main/org/jboss/web/WebApplication.java,v
  retrieving revision 1.2.6.1
  retrieving revision 1.2.6.2
  diff -u -r1.2.6.1 -r1.2.6.2
  --- WebApplication.java       4 Apr 2002 08:26:21 -0000       1.2.6.1
  +++ WebApplication.java       5 Apr 2002 03:50:37 -0000       1.2.6.2
  @@ -17,8 +17,8 @@
   
   @see AbstractWebContainer
   
  -@author [EMAIL PROTECTED]
  -@version $Revision: 1.2.6.1 $
  +@author [EMAIL PROTECTED]
  +@version $Revision: 1.2.6.2 $
   */
   public class WebApplication
   {
  @@ -37,6 +37,14 @@
        */
       public WebApplication()
       {
  +    }
  +    /** Create a WebApplication instance with with given web-app metadata.
  +     @param metaData, the web-app metadata containing the web.xml and
  +     jboss-web.xml descriptor metadata.
  +     */
  +    public WebApplication(WebMetaData metaData)
  +    {
  +       this.metaData = metaData;
       }
       /** Create a WebApplication instance with with given name,
           url and class loader.
  
  
  

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

Reply via email to