struts-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ced...@apache.org
Subject cvs commit: jakarta-struts/src/share/org/apache/struts/tiles DefinitionsUtil.java TilesPlugin.java
Date Thu, 11 Jul 2002 17:37:01 GMT
cedric      2002/07/11 10:37:01

  Modified:    src/share/org/apache/struts/tiles DefinitionsUtil.java
                        TilesPlugin.java
  Log:
  Remove references to the not yet (maybe never) released
  ConfigurableDefinitionsFactory class.
  
  Revision  Changes    Path
  1.3       +48 -5     jakarta-struts/src/share/org/apache/struts/tiles/DefinitionsUtil.java
  
  Index: DefinitionsUtil.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/tiles/DefinitionsUtil.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- DefinitionsUtil.java	11 Jul 2002 16:40:34 -0000	1.2
  +++ DefinitionsUtil.java	11 Jul 2002 17:37:01 -0000	1.3
  @@ -76,7 +76,6 @@
   import java.io.IOException;
   
   import org.apache.struts.tiles.definition.ReloadableDefinitionsFactory;
  -import org.apache.struts.tiles.definition.ConfigurableDefinitionsFactory;
   import org.apache.struts.tiles.definition.ComponentDefinitionsFactoryWrapper;
   import org.apache.struts.tiles.xmlDefinition.I18nFactorySet;
   import org.apache.struts.taglib.tiles.ComponentConstants;
  @@ -273,11 +272,55 @@
         // Set user debug level
       setUserDebugLevel( factoryConfig.getDebugLevel() );
         // Create configurable factory
  -    DefinitionsFactory factory = new ConfigurableDefinitionsFactory( );
  +    DefinitionsFactory factory = createDefinitionFactoryInstance(factoryConfig.getFactoryClassname());
       factory.init( factoryConfig, servletContext );
         // Make factory accessible from jsp tags
       DefinitionsUtil.makeDefinitionsFactoryAccessible(factory, servletContext );
       return factory;
  +  }
  +
  +
  +  /**
  +   * Create Definition factory from provided classname.
  +   * Factory class must extends TilesDefinitionsFactory.
  +   * @param classname Class name of the factory to create.
  +   * @return newly created factory.
  +   * @throws DefinitionsFactoryException If an error occur while initializing factory
  +   */
  +  static public DefinitionsFactory createDefinitionFactoryInstance(String classname)
  +    throws DefinitionsFactoryException
  +  {
  +  try
  +    {
  +    Class factoryClass = Class.forName(classname);
  +    Object factory = factoryClass.newInstance();
  +      // Backward compatibility : if factory classes implements old interface,
  +      // provide appropriate wrapper
  +    if( factory instanceof ComponentDefinitionsFactory )
  +      {
  +      factory = new ComponentDefinitionsFactoryWrapper( (ComponentDefinitionsFactory)factory
);
  +      } // end if
  +    return (DefinitionsFactory)factory;
  +    }
  +   catch( ClassCastException ex )
  +    { // Bad classname
  +    throw new DefinitionsFactoryException( "Error - createDefinitionsFactory : Factory
class '"
  +                                           + classname +" must implements 'TilesDefinitionsFactory'.",
ex );
  +    }
  +   catch( ClassNotFoundException ex )
  +    { // Bad classname
  +    throw new DefinitionsFactoryException( "Error - createDefinitionsFactory : Bad class
name '"
  +                                           + classname +"'.", ex );
  +    }
  +   catch( InstantiationException ex )
  +    { // Bad constructor or error
  +    throw new DefinitionsFactoryException( ex );
  +    }
  +   catch( IllegalAccessException ex )
  +    { //
  +    throw new DefinitionsFactoryException( ex );
  +    }
  +
     }
   
     /**
  
  
  
  1.2       +2 -3      jakarta-struts/src/share/org/apache/struts/tiles/TilesPlugin.java
  
  Index: TilesPlugin.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/tiles/TilesPlugin.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- TilesPlugin.java	11 Jul 2002 16:22:27 -0000	1.1
  +++ TilesPlugin.java	11 Jul 2002 17:37:01 -0000	1.2
  @@ -61,7 +61,6 @@
   
   package org.apache.struts.tiles;
   
  -import org.apache.struts.tiles.definition.ConfigurableDefinitionsFactory;
   
   import org.apache.struts.action.Action;
   import org.apache.struts.action.PlugIn;
  
  
  

--
To unsubscribe, e-mail:   <mailto:struts-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:struts-dev-help@jakarta.apache.org>


Mime
View raw message