cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r158825 - in cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal: event/EventManager.java generation/AbstractCopletGenerator.java generation/PortalGenerator.java impl/DefaultPortalComponentManager.java impl/PortalManagerImpl.java impl/PortalServiceImpl.java layout/renderer/aspect/impl/AbstractCIncludeAspect.java
Date Wed, 23 Mar 2005 20:00:59 GMT
Author: cziegeler
Date: Wed Mar 23 12:00:56 2005
New Revision: 158825

URL: http://svn.apache.org/viewcvs?view=rev&rev=158825
Log:
Fix copy/paste typos
PortalService is thread safe so we can simply store a reference

Modified:
    cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/event/EventManager.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/generation/AbstractCopletGenerator.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/generation/PortalGenerator.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/impl/DefaultPortalComponentManager.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/impl/PortalManagerImpl.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/impl/PortalServiceImpl.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/AbstractCIncludeAspect.java

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/event/EventManager.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/event/EventManager.java?view=diff&r1=158824&r2=158825
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/event/EventManager.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/event/EventManager.java
Wed Mar 23 12:00:56 2005
@@ -33,7 +33,7 @@
  * @author <a href="mailto:volker.schmitt@basf-it-services.com">Volker Schmitt</a>
  * @author Mauro Talevi
  * 
- * @version CVS $Id: EventManager.java,v 1.2 2004/03/05 13:02:11 bdelacretaz Exp $
+ * @version CVS $Id$
  */
 public interface EventManager extends Component {
  

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/generation/AbstractCopletGenerator.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/generation/AbstractCopletGenerator.java?view=diff&r1=158824&r2=158825
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/generation/AbstractCopletGenerator.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/generation/AbstractCopletGenerator.java
Wed Mar 23 12:00:56 2005
@@ -17,8 +17,10 @@
 
 import java.util.Map;
 
+import org.apache.avalon.framework.activity.Disposable;
 import org.apache.avalon.framework.parameters.ParameterException;
 import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.cocoon.environment.ObjectModelHelper;
 import org.apache.cocoon.generation.ServiceableGenerator;
 import org.apache.cocoon.portal.Constants;
@@ -44,7 +46,8 @@
  * @version CVS $Id: AbstractCopletTransformer.java 30941 2004-07-29 19:56:58Z vgritsenko
$
  */
 public abstract class AbstractCopletGenerator 
-extends ServiceableGenerator {
+extends ServiceableGenerator
+implements Disposable {
 
     /**
      * Parameter name.
@@ -56,8 +59,8 @@
      */
     public static final String PORTAL_NAME_PARAM = "portalName";
 
-    /** The portal service */
-    private PortalService _portalService;
+    /** The portal service. @since 2.1.8 */
+    protected PortalService portalService;
     
     /**
      * Try to get the coplet instance data belonging to the current request
@@ -77,16 +80,8 @@
     /**
      * Get the portal service
      */
-    protected PortalService getPortalService()
-    throws SAXException {
-        if ( this._portalService == null ) {
-            try {
-                this._portalService = (PortalService)this.manager.lookup(PortalService.ROLE);
-            } catch (ServiceException se) {
-                throw new SAXException("Unable to get portal service.", se);
-            }
-        }
-        return this._portalService;
+    protected PortalService getPortalService() {
+        return this.portalService;
     }
     
     
@@ -126,14 +121,22 @@
         return object;
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.avalon.excalibur.pool.Recyclable#recycle()
+    /**
+     * @see org.apache.avalon.framework.activity.Disposable#dispose()
      */
-    public void recycle() {
-        if ( this._portalService != null ) {
-            this.manager.release( this._portalService );
-            this._portalService = null;            
+    public void dispose() {
+        if ( this.manager != null ) {
+            this.manager.release(this.portalService);
+            this.portalService = null;
         }
-        super.recycle();
+        super.dispose();
+    }
+
+    /**
+     * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
+     */
+    public void service(ServiceManager manager) throws ServiceException {
+        super.service(manager);
+        this.portalService = (PortalService)this.manager.lookup(PortalService.ROLE);
     }
 }

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/generation/PortalGenerator.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/generation/PortalGenerator.java?view=diff&r1=158824&r2=158825
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/generation/PortalGenerator.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/generation/PortalGenerator.java
Wed Mar 23 12:00:56 2005
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2002,2004 The Apache Software Foundation.
+ * Copyright 1999-2002,2004-2005 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,6 +20,7 @@
 
 import org.apache.avalon.framework.parameters.Parameters;
 import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.cocoon.ProcessingException;
 import org.apache.cocoon.environment.SourceResolver;
 import org.apache.cocoon.generation.ServiceableGenerator;
@@ -43,7 +44,29 @@
 public class PortalGenerator 
 extends ServiceableGenerator {
 
-	/* (non-Javadoc)
+    /** The portal service. */
+    protected PortalService portalService;
+
+    /**
+     * @see org.apache.avalon.framework.activity.Disposable#dispose()
+     */
+    public void dispose() {
+        if ( this.manager != null ) {
+            this.manager.release(this.portalService);
+            this.portalService = null;
+        }
+        super.dispose();
+    }
+
+    /**
+     * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
+     */
+    public void service(ServiceManager manager) throws ServiceException {
+        super.service(manager);
+        this.portalService = (PortalService)this.manager.lookup(PortalService.ROLE);
+    }
+
+    /* (non-Javadoc)
 	 * @see org.apache.cocoon.generation.Generator#generate()
 	 */
 	public void generate()
@@ -51,17 +74,9 @@
         // start the portal rendering
         // 1. event processing
         // 2. rendering
-        PortalService service = null;
-        try {
-            service = (PortalService)this.manager.lookup(PortalService.ROLE);
-            PortalManager pm = service.getComponentManager().getPortalManager();
-            pm.process();
-            pm.showPortal(this.xmlConsumer, this.parameters);
-        } catch (ServiceException ce) {
-            throw new ProcessingException("Unable to lookup portal service.", ce);
-        } finally {
-            this.manager.release(service);
-        }
+        PortalManager pm = this.portalService.getComponentManager().getPortalManager();
+        pm.process();
+        pm.showPortal(this.xmlConsumer, this.parameters);
 	}
 
     /* (non-Javadoc)
@@ -74,20 +89,9 @@
     throws ProcessingException, SAXException, IOException {
         super.setup(resolver, objectModel, src, par);
         
-        // instantiate the portal service for this request
-        PortalService service = null;
-        try {
-            service = (PortalService)this.manager.lookup(PortalService.ROLE);
-            
-            // This is a fix: if we don't use the link service here, we get
-            // in some rare cases a wrong uri!
-            service.getComponentManager().getLinkService().getRefreshLinkURI();
-            
-        } catch (ServiceException ce) {
-            throw new ProcessingException("Unable to lookup portal service.", ce);
-        } finally {
-            this.manager.release(service);
-        }
+        // This is a fix: if we don't use the link service here, we get
+        // in some rare cases a wrong uri!
+        this.portalService.getComponentManager().getLinkService().getRefreshLinkURI();
     }
 
 }

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/impl/DefaultPortalComponentManager.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/impl/DefaultPortalComponentManager.java?view=diff&r1=158824&r2=158825
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/impl/DefaultPortalComponentManager.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/impl/DefaultPortalComponentManager.java
Wed Mar 23 12:00:56 2005
@@ -33,6 +33,7 @@
 import org.apache.cocoon.portal.LinkService;
 import org.apache.cocoon.portal.PortalComponentManager;
 import org.apache.cocoon.portal.PortalManager;
+import org.apache.cocoon.portal.PortalService;
 import org.apache.cocoon.portal.coplet.CopletFactory;
 import org.apache.cocoon.portal.event.EventManager;
 import org.apache.cocoon.portal.layout.LayoutFactory;
@@ -54,8 +55,12 @@
     extends AbstractLogEnabled
     implements PortalComponentManager, Serviceable, Disposable, ThreadSafe, Configurable
{
 
+    /** The avalon component manager */
     protected ServiceManager manager;
 
+    /** The portal service */
+    protected PortalService portalService;
+
     protected String profileManagerRole;
     protected ProfileManager profileManager;
 
@@ -79,6 +84,18 @@
     protected String portalManagerRole;
     protected PortalManager portalManager;
 
+    /**
+     * Create a new portal component manager. Each portal has a own
+     * component manager that manages all central components for this
+     * portal.
+     * This implementation stores the portal service (a global singleton)
+     * to pass it to the other components (TODO).
+     * @param service The portal service.
+     */
+    public DefaultPortalComponentManager(final PortalService service) {
+        this.portalService = service;
+    }
+
     /* (non-Javadoc)
      * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
      */
@@ -122,7 +139,7 @@
             try {
                 this.eventManager = (EventManager)this.manager.lookup( this.eventManagerRole
);
             } catch (ServiceException e) {
-                throw new CascadingRuntimeException("Unable to lookup event manager with
role " + EventManager.ROLE, e);
+                throw new CascadingRuntimeException("Unable to lookup event manager with
role " + this.eventManagerRole, e);
             }
         }
         return this.eventManager;
@@ -217,7 +234,7 @@
             try {
                 this.layoutFactory = (LayoutFactory)this.manager.lookup( this.layoutFactoryRole);
             } catch (ServiceException e) {
-                throw new CascadingRuntimeException("Unable to lookup layout factory with
role " + this.copletFactoryRole, e);
+                throw new CascadingRuntimeException("Unable to lookup layout factory with
role " + this.layoutFactoryRole, e);
             }
         }
         return this.layoutFactory;
@@ -232,7 +249,7 @@
             try {
                 this.portalManager = (PortalManager)this.manager.lookup( this.portalManagerRole);
             } catch (ServiceException e) {
-                throw new CascadingRuntimeException("Unable to lookup portal manager with
role " + this.copletFactoryRole, e);
+                throw new CascadingRuntimeException("Unable to lookup portal manager with
role " + this.portalManagerRole, e);
             }
         }
         return this.portalManager;

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/impl/PortalManagerImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/impl/PortalManagerImpl.java?view=diff&r1=158824&r2=158825
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/impl/PortalManagerImpl.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/impl/PortalManagerImpl.java
Wed Mar 23 12:00:56 2005
@@ -1,5 +1,5 @@
 /*
- * Copyright 1999-2002,2004 The Apache Software Foundation.
+ * Copyright 1999-2002,2004-2005 The Apache Software Foundation.
  * 
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -15,6 +15,7 @@
  */
 package org.apache.cocoon.portal.impl;
 
+import org.apache.avalon.framework.activity.Disposable;
 import org.apache.avalon.framework.logger.AbstractLogEnabled;
 import org.apache.avalon.framework.parameters.Parameters;
 import org.apache.avalon.framework.service.ServiceException;
@@ -39,25 +40,41 @@
  */
 public class PortalManagerImpl
 	extends AbstractLogEnabled
-	implements PortalManager, Serviceable, ThreadSafe {
+	implements PortalManager, Serviceable, Disposable, ThreadSafe {
 
+    /** The service manager */
     protected ServiceManager manager;
-        
-    /* (non-Javadoc)
+
+    /** The portal service */
+    protected PortalService portalService;
+
+    /**
+     * @see org.apache.avalon.framework.service.Serviceable#service(ServiceManager)
+     */
+    public void service(ServiceManager serviceManager)
+    throws ServiceException {
+        this.manager = serviceManager;
+        this.portalService = (PortalService)this.manager.lookup(PortalService.ROLE);
+    }
+
+    /**
+     * @see org.apache.avalon.framework.activity.Disposable#dispose()
+     */
+    public void dispose() {
+        if ( this.manager != null ) {
+            this.manager.release(this.portalService);
+            this.portalService = null;
+            this.manager = null;
+        }
+    }
+
+    /**
      * @see org.apache.cocoon.portal.PortalManager#process()
      */
     public void process()
     throws ProcessingException {
-        PortalService service = null;
-        try {
-            service = (PortalService)this.manager.lookup(PortalService.ROLE);
-            EventManager eventManager = service.getComponentManager().getEventManager();
-            eventManager.processEvents();
-        } catch (ServiceException ce) {
-            throw new ProcessingException("Unable to lookup portal service.", ce);
-        } finally {
-            this.manager.release(service);
-        }
+        EventManager eventManager = this.portalService.getComponentManager().getEventManager();
+        eventManager.processEvents();
     }
 
 	/**
@@ -65,33 +82,16 @@
 	 */
 	public void showPortal(ContentHandler contentHandler, Parameters parameters) 
     throws SAXException {
-        PortalService service = null;
-        try {
-            service = (PortalService)this.manager.lookup(PortalService.ROLE);
-            // first check for a full screen layout
-            Layout portalLayout = service.getEntryLayout(null);
-            if ( portalLayout == null ) {
-                portalLayout = service.getComponentManager().getProfileManager().getPortalLayout(null,
null);
-            }
-
-            Renderer portalLayoutRenderer = service.getComponentManager().getRenderer( portalLayout.getRendererName());
      
-
-            contentHandler.startDocument();
-            portalLayoutRenderer.toSAX(portalLayout, service, contentHandler);
-            contentHandler.endDocument();
-        } catch (ServiceException ce) {
-            throw new SAXException("Unable to lookup portal service.", ce);
-        } finally {
-            this.manager.release(service);
+        // first check for a full screen layout
+        Layout portalLayout = this.portalService.getEntryLayout(null);
+        if ( portalLayout == null ) {
+            portalLayout = this.portalService.getComponentManager().getProfileManager().getPortalLayout(null,
null);
         }
-	}
 
-	/**
-	 * @see org.apache.avalon.framework.service.Serviceable#service(ServiceManager)
-	 */
-	public void service(ServiceManager serviceManager)
-    throws ServiceException {
-        this.manager = serviceManager;
-	}
+        Renderer portalLayoutRenderer = this.portalService.getComponentManager().getRenderer(
portalLayout.getRendererName());       
 
+        contentHandler.startDocument();
+        portalLayoutRenderer.toSAX(portalLayout, this.portalService, contentHandler);
+        contentHandler.endDocument();
+	}
 }

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/impl/PortalServiceImpl.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/impl/PortalServiceImpl.java?view=diff&r1=158824&r2=158825
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/impl/PortalServiceImpl.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/impl/PortalServiceImpl.java
Wed Mar 23 12:00:56 2005
@@ -194,7 +194,7 @@
             final Configuration current = portals[i];
             final String name = current.getAttribute("name");
             try {
-                PortalComponentManager c = new DefaultPortalComponentManager();
+                PortalComponentManager c = new DefaultPortalComponentManager(this);
                 this.portalComponentManagers.put( name, c );
                 ContainerUtil.enableLogging( c, this.getLogger() );
                 ContainerUtil.contextualize( c, this.context );

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/AbstractCIncludeAspect.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/AbstractCIncludeAspect.java?view=diff&r1=158824&r2=158825
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/AbstractCIncludeAspect.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/AbstractCIncludeAspect.java
Wed Mar 23 12:00:56 2005
@@ -27,7 +27,7 @@
  * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
  * @author <a href="mailto:volker.schmitt@basf-it-services.com">Volker Schmitt</a>
  * 
- * @version CVS $Id: AbstractCIncludeAspect.java,v 1.4 2004/04/25 20:09:34 haul Exp $
+ * @version CVS $Id$
  */
 public abstract class AbstractCIncludeAspect 
     extends AbstractAspect {
@@ -48,7 +48,7 @@
     throws SAXException {
         handler.startPrefixMapping(PREFIX, NAMESPACE);
         AttributesImpl attributes = new AttributesImpl();
-        attributes.addCDATAAttribute("src", source);
+        attributes.addCDATAAttribute(ATTRIBUTE, source);
         handler.startElement(NAMESPACE, ELEMENT, QELEMENT, attributes);
         handler.endElement(NAMESPACE, ELEMENT, QELEMENT);
         handler.endPrefixMapping(PREFIX);



Mime
View raw message