cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject cvs commit: cocoon-2.1/src/blocks/xmldb/java/org/apache/cocoon/components/source/impl XMLDBSource.java XMLDBSourceFactory.java
Date Mon, 19 Apr 2004 14:53:50 GMT
cziegeler    2004/04/19 07:53:50

  Modified:    src/blocks/xmldb/java/org/apache/cocoon/components/source/impl
                        XMLDBSource.java XMLDBSourceFactory.java
  Log:
  Use offical way to get service manager
  
  Revision  Changes    Path
  1.14      +21 -13    cocoon-2.1/src/blocks/xmldb/java/org/apache/cocoon/components/source/impl/XMLDBSource.java
  
  Index: XMLDBSource.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/xmldb/java/org/apache/cocoon/components/source/impl/XMLDBSource.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- XMLDBSource.java	5 Mar 2004 13:02:36 -0000	1.13
  +++ XMLDBSource.java	19 Apr 2004 14:53:50 -0000	1.14
  @@ -15,17 +15,18 @@
    */
   package org.apache.cocoon.components.source.impl;
   
  -import org.apache.avalon.framework.component.ComponentException;
  -import org.apache.avalon.framework.component.ComponentSelector;
  -import org.apache.avalon.framework.component.ComponentManager;
  +import org.apache.avalon.framework.context.Context;
  +import org.apache.avalon.framework.context.ContextException;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
   import org.apache.avalon.framework.logger.Logger;
  +import org.apache.avalon.framework.service.ServiceException;
   import org.apache.avalon.framework.service.ServiceManager;
  +import org.apache.avalon.framework.service.ServiceSelector;
   import org.apache.cocoon.CascadingIOException;
   import org.apache.cocoon.ProcessingException;
   import org.apache.cocoon.ResourceNotFoundException;
   import org.apache.cocoon.components.source.helpers.SourceCredential;
  -import org.apache.cocoon.components.CocoonComponentManager;
  +import org.apache.cocoon.components.ContextHelper;
   import org.apache.cocoon.serialization.Serializer;
   import org.apache.cocoon.xml.IncludeXMLConsumer;
   import org.apache.excalibur.source.ModifiableSource;
  @@ -132,10 +133,14 @@
       protected String systemId;
   
       /** ServiceManager */
  -    protected ServiceManager manager;
  +    protected final ServiceManager manager;
   
       /** XMLDBOutputStream for writing to Modifiable resource */
       protected XMLDBOutputStream os;
  +    
  +    /** The Avalon context */
  +    protected final Context context;
  +    
       /**
        * The constructor.
        *
  @@ -147,8 +152,10 @@
       public XMLDBSource(Logger logger,
                          SourceCredential credential,
                          String url,
  -                       ServiceManager manager) {
  +                       ServiceManager manager,
  +                       Context context) {
           enableLogging(logger);
  +        this.context = context;
           this.manager = manager;
   
           this.user = credential.getPrincipal();
  @@ -432,12 +439,13 @@
       public InputStream getInputStream()
       throws IOException {
   
  -        ComponentSelector serializerSelector = null;
  +        ServiceManager manager = null;
  +        ServiceSelector serializerSelector = null;
           Serializer serializer = null;
           // this.manager does not have Serializer
  -        ComponentManager manager = CocoonComponentManager.getSitemapComponentManager();
           try {
  -            serializerSelector = (ComponentSelector) manager.lookup(Serializer.ROLE + "Selector");
  +            manager = (ServiceManager) this.context.get(ContextHelper.CONTEXT_SITEMAP_SERVICE_MANAGER);
  +            serializerSelector = (ServiceSelector) manager.lookup(Serializer.ROLE + "Selector");
               serializer = (Serializer)serializerSelector.select("xml");
               ByteArrayOutputStream os = new ByteArrayOutputStream();
               serializer.setOutputStream(os);
  @@ -445,10 +453,10 @@
               toSAX(serializer);
   
               return new ByteArrayInputStream(os.toByteArray());
  -//        } catch (ServiceException e) {
  -//            throw new CascadingIOException("Could not lookup pipeline components", e);
  -        } catch (ComponentException e) {
  +        } catch (ServiceException e) {
               throw new CascadingIOException("Could not lookup pipeline components", e);
  +        } catch (ContextException ce) {
  +            throw new CascadingIOException("Could not get service manager.", ce);
           } catch (Exception e) {
               throw new CascadingIOException("Exception during processing of " + getURI(),
e);
           } finally {
  
  
  
  1.8       +16 -3     cocoon-2.1/src/blocks/xmldb/java/org/apache/cocoon/components/source/impl/XMLDBSourceFactory.java
  
  Index: XMLDBSourceFactory.java
  ===================================================================
  RCS file: /home/cvs/cocoon-2.1/src/blocks/xmldb/java/org/apache/cocoon/components/source/impl/XMLDBSourceFactory.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- XMLDBSourceFactory.java	5 Mar 2004 13:02:36 -0000	1.7
  +++ XMLDBSourceFactory.java	19 Apr 2004 14:53:50 -0000	1.8
  @@ -23,6 +23,9 @@
   import org.apache.avalon.framework.configuration.Configurable;
   import org.apache.avalon.framework.configuration.Configuration;
   import org.apache.avalon.framework.configuration.ConfigurationException;
  +import org.apache.avalon.framework.context.Context;
  +import org.apache.avalon.framework.context.ContextException;
  +import org.apache.avalon.framework.context.Contextualizable;
   import org.apache.avalon.framework.logger.AbstractLogEnabled;
   import org.apache.avalon.framework.service.ServiceManager;
   import org.apache.avalon.framework.service.Serviceable;
  @@ -43,7 +46,7 @@
    * @version CVS $Id$
    */
   public final class XMLDBSourceFactory extends AbstractLogEnabled
  -                                      implements SourceFactory, Configurable, Serviceable,
ThreadSafe {
  +                                      implements SourceFactory, Contextualizable, Configurable,
Serviceable, ThreadSafe {
   
       /** The ServiceManager instance */
       protected ServiceManager m_manager;
  @@ -51,6 +54,15 @@
       /** A Map containing the authentication credentials */
       protected HashMap credentialMap;
   
  +    /** The avalon context */
  +    protected Context context;
  +    
  +    /* (non-Javadoc)
  +     * @see org.apache.avalon.framework.context.Contextualizable#contextualize(org.apache.avalon.framework.context.Context)
  +     */
  +    public void contextualize(Context context) throws ContextException {
  +        this.context = context;
  +    }
       /**
        * Configure the instance and initialize XML:DB connections (load and register the
drivers).
        */
  @@ -125,7 +137,8 @@
   
           return new XMLDBSource(this.getLogger(),
                                  credential, location,
  -                               this.m_manager);
  +                               this.m_manager,
  +                               this.context);
       }
   
       public void release(org.apache.excalibur.source.Source source) {
  
  
  

Mime
View raw message