bloritsch    01/04/05 09:57:14

  Modified:    lib      Tag: xml-cocoon2 avalonapi.jar
               src/org/apache/cocoon/components Tag: xml-cocoon2
                        ComponentSelector.java DefaultRoleInfo.java
               src/org/apache/cocoon/servlet Tag: xml-cocoon2
                        CocoonServlet.java
               webapp   Tag: xml-cocoon2 cocoon.xconf
  Log:
  Added improvements to ComponentSelector based on improvements
  in ComponentManager.  Made sure Avalonapi.jar has the J2eeDataSource
  in it.
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.32  +201 -192  xml-cocoon/lib/Attic/avalonapi.jar
  
        <<Binary file>>
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.2   +46 -2     
xml-cocoon/src/org/apache/cocoon/components/Attic/ComponentSelector.java
  
  Index: ComponentSelector.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/Attic/ComponentSelector.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- ComponentSelector.java    2001/04/05 15:40:36     1.1.2.1
  +++ ComponentSelector.java    2001/04/05 16:57:05     1.1.2.2
  @@ -36,7 +36,7 @@
   /** Default component manager for Cocoon's non sitemap components.
    * @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
    * @author <a href="mailto:[EMAIL PROTECTED]">Paul Russell</a>
  - * @version CVS $Revision: 1.1.2.1 $ $Date: 2001/04/05 15:40:36 $
  + * @version CVS $Revision: 1.1.2.2 $ $Date: 2001/04/05 16:57:05 $
    */
   public class ComponentSelector extends AbstractLoggable implements 
Contextualizable, org.apache.avalon.ComponentSelector, Composer, Configurable, 
ThreadSafe, Disposable {
   
  @@ -60,8 +60,14 @@
        */
       private Map componentHandlers;
   
  +    /** Flag for if this is disposed or not.
  +     */
       private boolean disposed = false;
   
  +    /** Shorthand for hints
  +     */
  +    private Map hints;
  +
       /** Construct a new default component manager.
        */
       public ComponentSelector() {
  @@ -156,7 +162,45 @@
       public void configure(Configuration conf) throws ConfigurationException {
           this.conf = conf;
           getLogger().debug("ComponentSelector setting up with root element: " 
+ conf.getName());
  -        Configuration[] instances = conf.getChildren("component-instance");
  +
  +        Configuration[] hints = conf.getChildren("hint");
  +        HashMap hintMap = new HashMap();
  +
  +        for (int i = 0; i < hints.length; i++) {
  +            hintMap.put(hints[i].getAttribute("short-hand").trim(), 
hints[i].getAttribute("class").trim());
  +        }
  +
  +        this.hints = Collections.unmodifiableMap(hintMap);
  +
  +        Iterator shorthand = this.hints.keySet().iterator();
  +        Configuration[] instances = null;
  +
  +        while (shorthand.hasNext()) {
  +            String type = (String) shorthand.next();
  +            Class clazz = null;
  +
  +            try {
  +                clazz = ClassUtils.loadClass((String) this.hints.get(type));
  +            } catch (Exception e) {
  +                getLogger().error("ComponentSelector The component instance 
for \"" + type + "\" has an invalid class name.", e);
  +                throw new ConfigurationException("The component instance for 
'" + type + "' has an invalid class name.", e);
  +            }
  +
  +            instances = conf.getChildren(type);
  +
  +            for (int i = 0; i < instances.length; i++) {
  +                Object hint = instances[i].getAttribute("name").trim();
  +
  +                try {
  +                    this.addComponent(hint, clazz, instances[i]);
  +                } catch (Exception e) {
  +                    getLogger().error("ComponentSelector The component 
instance for \"" + hint + "\" has an invalid class name.", e);
  +                    throw new ConfigurationException("The component instance 
for '" + hint + "' has an invalid class name.", e);
  +                }
  +            }
  +        }
  +
  +        instances = conf.getChildren("component-instance");
   
           for (int i = 0; i < instances.length; i++) {
               Object hint = instances[i].getAttribute("name").trim();
  
  
  
  1.1.2.2   +1 -2      
xml-cocoon/src/org/apache/cocoon/components/Attic/DefaultRoleInfo.java
  
  Index: DefaultRoleInfo.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/components/Attic/DefaultRoleInfo.java,v
  retrieving revision 1.1.2.1
  retrieving revision 1.1.2.2
  diff -u -r1.1.2.1 -r1.1.2.2
  --- DefaultRoleInfo.java      2001/04/05 15:40:36     1.1.2.1
  +++ DefaultRoleInfo.java      2001/04/05 16:57:06     1.1.2.2
  @@ -23,7 +23,7 @@
   /** Default RoleInfo implementation
    * @author <a href="mailto:[EMAIL PROTECTED],org">Ricardo Rocha</a>
    * @author <a href="mailto:[EMAIL PROTECTED],org">Giacomo Pati</a>
  - * @version CVS $Revision: 1.1.2.1 $ $Date: 2001/04/05 15:40:36 $
  + * @version CVS $Revision: 1.1.2.2 $ $Date: 2001/04/05 16:57:06 $
    */
   public class DefaultRoleInfo extends AbstractLoggable implements RoleInfo, 
Configurable {
       private Map shorthands = new Hashtable();
  @@ -37,7 +37,6 @@
       public Iterator shorthandNames() {
           return 
Collections.unmodifiableMap(this.shorthands).keySet().iterator();
       }
  -
   
       public String defaultClass(String role) {
           return (String) this.classNames.get(role);
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.4.79  +6 -2      
xml-cocoon/src/org/apache/cocoon/servlet/Attic/CocoonServlet.java
  
  Index: CocoonServlet.java
  ===================================================================
  RCS file: 
/home/cvs/xml-cocoon/src/org/apache/cocoon/servlet/Attic/CocoonServlet.java,v
  retrieving revision 1.1.4.78
  retrieving revision 1.1.4.79
  diff -u -r1.1.4.78 -r1.1.4.79
  --- CocoonServlet.java        2001/04/04 18:06:30     1.1.4.78
  +++ CocoonServlet.java        2001/04/05 16:57:10     1.1.4.79
  @@ -62,7 +62,7 @@
    * @author <a href="mailto:[EMAIL PROTECTED]">Stefano Mazzocchi</a>
    * @author <a href="mailto:[EMAIL PROTECTED]">Nicola Ken Barozzi</a> Aisa
    * @author <a href="mailto:[EMAIL PROTECTED]">Berin Loritsch</a>
  - * @version CVS $Revision: 1.1.4.78 $ $Date: 2001/04/04 18:06:30 $
  + * @version CVS $Revision: 1.1.4.79 $ $Date: 2001/04/05 16:57:10 $
    */
   
   public class CocoonServlet extends HttpServlet {
  @@ -525,7 +525,11 @@
           } catch (Exception e) {
               log.error("Exception reloading", e);
               this.exception = e;
  -            this.cocoon.dispose();
  +
  +            if (cocoon != null) {
  +                this.cocoon.dispose();
  +            }
  +
               this.cocoon = null;
           }
       }
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.1.2.30  +5 -2      xml-cocoon/webapp/Attic/cocoon.xconf
  
  Index: cocoon.xconf
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/webapp/Attic/cocoon.xconf,v
  retrieving revision 1.1.2.29
  retrieving revision 1.1.2.30
  diff -u -r1.1.2.29 -r1.1.2.30
  --- cocoon.xconf      2001/04/05 15:40:37     1.1.2.29
  +++ cocoon.xconf      2001/04/05 16:57:13     1.1.2.30
  @@ -77,12 +77,15 @@
     </markup-languages>
   
     <datasources>
  -    <component-instance name="personnel" 
class="org.apache.avalon.util.datasource.JdbcDataSource">
  +    <hint short-hand="jdbc" 
class="org.apache.avalon.util.datasource.JdbcDataSource"/>
  +    <hint short-hand="j2ee" 
class="org.apache.avalon.util.datasource.J2eeDataSource"/>
  +
  +    <jdbc name="personnel">
         <pool-controller min="5" max="10"/>
         <dburl>jdbc:postgresql://localhost/test</dburl>
         <user>test</user>
         <password>test</password>
  -    </component-instance>
  +    </jdbc>
     </datasources>
   
     <!-- these components is used as a PoolController for the sitemap 
component pools  -->
  
  
  

----------------------------------------------------------------------
In case of troubles, e-mail:     [EMAIL PROTECTED]
To unsubscribe, e-mail:          [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to