You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2005/08/03 08:15:08 UTC
svn commit: r227172 - in
/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation:
AbstractCopletTransformer.java CopletTransformer.java
EventLinkTransformer.java NewEventLinkTransformer.java
Author: cziegeler
Date: Tue Aug 2 23:15:04 2005
New Revision: 227172
URL: http://svn.apache.org/viewcvs?rev=227172&view=rev
Log:
Start cleaning up transformers
Modified:
cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/AbstractCopletTransformer.java
cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/CopletTransformer.java
cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/EventLinkTransformer.java
cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/NewEventLinkTransformer.java
Modified: cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/AbstractCopletTransformer.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/AbstractCopletTransformer.java?rev=227172&r1=227171&r2=227172&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/AbstractCopletTransformer.java (original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/AbstractCopletTransformer.java Tue Aug 2 23:15:04 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><map:transform type="coplet">
- * <map:parameter name="portalName" type="exampleportal"/>
- * <map:parameter name="copletId" type="examplecoplet"/>
- * </map:transform></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><map:transform type="coplet">
+ * <map:parameter name="copletId" type="examplecoplet"/>
+ * </map:transform></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,17 +54,12 @@
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 */
- 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
@@ -72,25 +74,7 @@
}
return cid;
}
-
-
- /**
- * 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;
- }
-
-
+
/**
* Try to get the coplet instance data with the given id
* @param copletId The id of the coplet instance or null if this transformer
@@ -122,19 +106,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/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/CopletTransformer.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/CopletTransformer.java?rev=227172&r1=227171&r2=227172&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/CopletTransformer.java (original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/CopletTransformer.java Tue Aug 2 23:15:04 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/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/EventLinkTransformer.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/EventLinkTransformer.java?rev=227172&r1=227171&r2=227172&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/EventLinkTransformer.java (original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/EventLinkTransformer.java Tue Aug 2 23:15:04 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/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/NewEventLinkTransformer.java
URL: http://svn.apache.org/viewcvs/cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/NewEventLinkTransformer.java?rev=227172&r1=227171&r2=227172&view=diff
==============================================================================
--- cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/NewEventLinkTransformer.java (original)
+++ cocoon/blocks/portal/trunk/java/org/apache/cocoon/portal/transformation/NewEventLinkTransformer.java Tue Aug 2 23:15:04 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) {