cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r227171 - in /cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/transformation: AbstractCopletTransformer.java CopletTransformer.java EventLinkTransformer.java NewEventLinkTransformer.java
Date Wed, 03 Aug 2005 06:08:31 GMT
Author: cziegeler
Date: Tue Aug  2 23:08:26 2005
New Revision: 227171

URL: http://svn.apache.org/viewcvs?rev=227171&view=rev
Log:
Start cleaning up transformers

Modified:
    cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/transformation/AbstractCopletTransformer.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/transformation/CopletTransformer.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/transformation/EventLinkTransformer.java
    cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/transformation/NewEventLinkTransformer.java

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/transformation/AbstractCopletTransformer.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/transformation/AbstractCopletTransformer.java?rev=227171&r1=227170&r2=227171&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/transformation/AbstractCopletTransformer.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/transformation/AbstractCopletTransformer.java
Tue Aug  2 23:08:26 2005
@@ -1,12 +1,12 @@
 /*
- * 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.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -19,6 +19,7 @@
 
 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.portal.Constants;
 import org.apache.cocoon.portal.PortalService;
@@ -27,18 +28,24 @@
 import org.xml.sax.SAXException;
 
 /**
- * Abstract transformer implementation that provides a method getCopletInstanceData().
- * There are two possibilities how the transformer obtains the information required for 
- * getting the coplet instance data:<br><br>
- * 1) If it is used within a coplet pipeline and this pipeline is called using the "cocoon:"
protocol,
- * all required information are passed automatically.<br>
- * 2) Otherwise the portal name and the coplet id must be passed to the transformer 
- * as paremeters in the following way:
+ * Abstract transformer implementation that provides some useful methods and
+ * functionality. The portal service is stored in the instance variable
+ * {@link #portalService} and can be used.
+ * There are some methods to fetch a coplet instance data. {@link #getCopletInstanceData()}
+ * tries to get the instance associated with the current request and
+ * {@link #getCopletInstanceData(String)} fetches an instance with a given id.
  *
- * <pre>&lt;map:transform type="coplet"&gt;
- * 	&lt;map:parameter name="portalName" type="exampleportal"/&gt;
- * 	&lt;map:parameter name="copletId" type="examplecoplet"/&gt;
- * &lt;/map:transform&gt;</pre>
+ * If you want to get the coplet instance data associated with the current request,
+ * there are three possibilities how the transformer obtains the information required
+ * for getting the coplet instance data - or more precisly its id:<br><br>
+ * 1) If it is used within a coplet pipeline and this pipeline is called using
+ *    the "cocoon:" protocol, all required information is passed automatically.<br>
+ * 2) The id can be passed to the transformer as sitemap paremeters in the following way:
+ *    <pre>&lt;map:transform type="coplet"&gt;
+ * 	    &lt;map:parameter name="copletId" type="examplecoplet"/&gt;
+ *    &lt;/map:transform&gt;</pre>
+ * 3) Any component can set the id as a string in the object model of the current request.
+ *    This is the name of the key to be used: {@link org.apache.cocoon.portal.Constants#COPLET_ID_KEY}.
  *
  * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
  * @version CVS $Id$
@@ -47,18 +54,13 @@
 extends AbstractSAXTransformer {
 
     /**
-     * Parameter name.
+     * Parameter name for the coplet id.
      */
     public static final String COPLET_ID_PARAM = "copletId";
 
-    /**
-     * Parameter name.
-     */
-    public static final String PORTAL_NAME_PARAM = "portalName";
+    /** The portal service. @since 2.1.8 */
+    protected PortalService portalService;
 
-    /** The portal service */
-    private PortalService _portalService;
-    
     /**
      * Try to get the coplet instance data belonging to the current request
      * @return The coplet instance data
@@ -75,19 +77,12 @@
     
     
     /**
-     * Get the portal service
+     * Get the portal service.
+     * @deprecated Use directly the instance variable.
      */
     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;
+        return this.portalService;
     }
     
     
@@ -122,19 +117,27 @@
             throw new SAXException("copletId must be passed as parameter or in the object
model within the parent context.");
         }
 
-        CopletInstanceData object = this.getPortalService().getComponentManager().getProfileManager().getCopletInstanceData(
copletId );
+        CopletInstanceData object = this.portalService.getComponentManager().getProfileManager().getCopletInstanceData(
copletId );
             
         return object;
     }
 
-    /* (non-Javadoc)
-     * @see org.apache.avalon.excalibur.pool.Recyclable#recycle()
+    /**
+     * @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);    
   
+    }
+
+    /**
+     * @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.portalService != null ) {
+            this.manager.release( this.portalService );
+            this.portalService = null;            
         }
-        super.recycle();
+        super.dispose();
     }
 }

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/transformation/CopletTransformer.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/transformation/CopletTransformer.java?rev=227171&r1=227170&r2=227171&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/transformation/CopletTransformer.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/transformation/CopletTransformer.java
Tue Aug  2 23:08:26 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.
@@ -137,7 +137,7 @@
 
         } else if (name.equals(LINK_ELEM)) {
 
-            final LinkService linkService = this.getPortalService().getComponentManager().getLinkService();
+            final LinkService linkService = this.portalService.getComponentManager().getLinkService();
             final String format = attr.getValue("format");
             AttributesImpl newAttrs = new AttributesImpl();
             newAttrs.setAttributes(attr);
@@ -166,7 +166,7 @@
                 if ( attr.getValue("layout") != null ) {
                     newAttrs.removeAttribute("layout");
                     final String layoutId = attr.getValue("layout");
-                    Object layout = this.getPortalService().getComponentManager().getProfileManager().getPortalLayout(null,
layoutId);
+                    Object layout = this.portalService.getComponentManager().getProfileManager().getPortalLayout(null,
layoutId);
                     if ( layout != null ) {
                         event = new JXPathEvent(layout, path, value);
                     }
@@ -232,7 +232,7 @@
         } else if ( name.equals(LINKS_ELEM) ) {
             this.insideLinks = false;
             final String format = (String)this.stack.pop();
-            final LinkService linkService = this.getPortalService().getComponentManager().getLinkService();
+            final LinkService linkService = this.portalService.getComponentManager().getLinkService();
             String href = linkService.getLinkURI(this.collectedEvents);
 
             AttributesImpl newAttrs = (AttributesImpl)this.stack.pop();

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/transformation/EventLinkTransformer.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/transformation/EventLinkTransformer.java?rev=227171&r1=227170&r2=227171&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/transformation/EventLinkTransformer.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/transformation/EventLinkTransformer.java
Tue Aug  2 23:08:26 2005
@@ -167,7 +167,7 @@
                     // if attribute found that contains a link
                     if (link != null) {
                         CopletInstanceData cid = this.getCopletInstanceData(attr.getValue("coplet"));
-                        LinkService linkService = this.getPortalService().getComponentManager().getLinkService();
+                        LinkService linkService = this.portalService.getComponentManager().getLinkService();
 
                         // create event link
                         CopletLinkEvent event = new CopletLinkEvent(cid, link);
@@ -186,7 +186,7 @@
                     String link = this.endTextRecording();
 
                     CopletInstanceData cid = this.getCopletInstanceData();
-                    LinkService linkService = this.getPortalService().getComponentManager().getLinkService();
+                    LinkService linkService = this.portalService.getComponentManager().getLinkService();
 
                     // create event link
                     CopletLinkEvent event = new CopletLinkEvent(cid, link);

Modified: cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/transformation/NewEventLinkTransformer.java
URL: http://svn.apache.org/viewcvs/cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/transformation/NewEventLinkTransformer.java?rev=227171&r1=227170&r2=227171&view=diff
==============================================================================
--- cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/transformation/NewEventLinkTransformer.java
(original)
+++ cocoon/branches/BRANCH_2_1_X/src/blocks/portal/java/org/apache/cocoon/portal/transformation/NewEventLinkTransformer.java
Tue Aug  2 23:08:26 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.
@@ -158,7 +158,7 @@
             CopletInstanceData cid = this.getCopletInstanceData(attributes.getValue("coplet"));
             // create event link
             CopletLinkEvent event = new CopletLinkEvent(cid, link);
-            String eventLink = this.getPortalService().getComponentManager().getLinkService().getLinkURI(event);
+            String eventLink = this.portalService.getComponentManager().getLinkService().getLinkURI(event);
 
             //form elements need hidden inputs to change request parameters
             if (formSpecialTreatment) {



Mime
View raw message