Skip to content

Commit

Permalink
Use properties instead of parameters
Browse files Browse the repository at this point in the history
git-svn-id: https://svn.apache.org/repos/asf/cocoon/trunk@429319 13f79535-47bb-0310-9956-ffa450edef68
  • Loading branch information
cziegeler committed Aug 7, 2006
1 parent f15c69c commit 66ca163
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 51 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
*/
package org.apache.cocoon.portal;

import org.apache.avalon.framework.parameters.Parameters;
import java.util.Properties;

import org.apache.cocoon.ProcessingException;
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;
Expand All @@ -32,18 +33,19 @@
*/
public interface PortalManager {

/** This parameter containing a layout id can be passed to the
* {@link #showPortal(ContentHandler, Parameters)} method. In this
/** This property containing a layout id can be passed to the
* {@link #showPortal(ContentHandler, Properties)} method. In this
* case only the tree starting with this layout object is rendered.
*/
String PARAMETER_RENDER_LAYOUT = "render-layout";
String PROPERTY_RENDER_LAYOUT = "render-layout";

/** This parameter containing a coplet instance id can be passed to the
* {@link #showPortal(ContentHandler, Parameters)} method. In this
/** This property containing a coplet instance id can be passed to the
* {@link #showPortal(ContentHandler, Properties)} method. In this
* case only the coplet with the surrounding layout is rendered.
*/
String PARAMETER_RENDER_COPLET = "render-coplet";
String PROPERTY_RENDER_COPLET = "render-coplet";

/** The bean name of this component. */
String ROLE = PortalManager.class.getName();

/**
Expand All @@ -57,10 +59,10 @@ void process()
/**
* Render the portal.
* @param ch The content handler receiving the sax events.
* @param parameters A parameters object.
* @param Properties A properties object (can be null)
* @throws SAXException
*/
void showPortal(ContentHandler ch,
Parameters parameters)
Properties properties)
throws SAXException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@
*/
package org.apache.cocoon.portal;

import org.apache.avalon.framework.parameters.Parameters;
import java.util.Properties;

import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.portal.PortalService;
import org.xml.sax.ContentHandler;
Expand All @@ -37,6 +38,6 @@ void prepare(PortalManagerAspectPrepareContext context,
void render(PortalManagerAspectRenderContext context,
PortalService service,
ContentHandler ch,
Parameters parameters)
Properties properties)
throws SAXException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
package org.apache.cocoon.portal;

import java.util.Map;
import java.util.Properties;

import org.apache.avalon.framework.parameters.Parameters;
import org.apache.cocoon.ProcessingException;

/**
Expand All @@ -33,9 +33,9 @@ void invokeNext()
throws ProcessingException;

/**
* Get the {@link Parameters} of the aspect.
* Get the {@link Properties} of the aspect.
*/
Parameters getAspectParameters();
Properties getAspectProperties();

/**
* Get the object model.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,8 @@
package org.apache.cocoon.portal;

import java.util.Map;
import java.util.Properties;

import org.apache.avalon.framework.parameters.Parameters;
import org.xml.sax.ContentHandler;
import org.xml.sax.SAXException;

Expand All @@ -31,13 +31,13 @@ public interface PortalManagerAspectRenderContext {
* Invoke next aspect
*/
void invokeNext(ContentHandler ch,
Parameters parameters)
Properties parameters)
throws SAXException;

/**
* Get the {@link Parameters} of the aspect.
* Get the {@link Properties} of the aspect.
*/
Parameters getAspectParameters();
Properties getAspectProperties();

/**
* Get the object model.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public void generate()
// 2. rendering
PortalManager pm = this.portalService.getPortalManager();
pm.process();
pm.showPortal(this.xmlConsumer, this.parameters);
pm.showPortal(this.xmlConsumer, Parameters.toProperties(this.parameters));
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@

import java.util.Iterator;
import java.util.Map;
import java.util.Properties;

import org.apache.avalon.framework.parameters.Parameters;
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.portal.PortalManagerAspect;
import org.apache.cocoon.portal.PortalManagerAspectPrepareContext;
Expand All @@ -39,7 +39,7 @@ public final class DefaultPortalManagerAspectContext
private final Map objectModel;
private Iterator iterator;
private Iterator configIterator;
private Parameters config;
private Properties config;

public DefaultPortalManagerAspectContext(PortalManagerAspectChain chain,
PortalService service,
Expand All @@ -56,28 +56,28 @@ public DefaultPortalManagerAspectContext(PortalManagerAspectChain chain,
public void invokeNext()
throws ProcessingException {
if (this.iterator.hasNext()) {
this.config = (Parameters)this.configIterator.next();
this.config = (Properties)this.configIterator.next();
final PortalManagerAspect aspect = (PortalManagerAspect) iterator.next();
aspect.prepare(this, this.service);
}
}

/**
* @see org.apache.cocoon.portal.PortalManagerAspectPrepareContext#getAspectParameters()
* @see org.apache.cocoon.portal.PortalManagerAspectRenderContext#getAspectProperties()
*/
public Parameters getAspectParameters() {
public Properties getAspectProperties() {
return this.config;
}

/**
* @see org.apache.cocoon.portal.PortalManagerAspectRenderContext#invokeNext(org.xml.sax.ContentHandler, org.apache.avalon.framework.parameters.Parameters)
*/
public void invokeNext(ContentHandler ch, Parameters parameters)
public void invokeNext(ContentHandler ch, Properties properties)
throws SAXException {
if (this.iterator.hasNext()) {
this.config = (Parameters)this.configIterator.next();
this.config = (Properties)this.configIterator.next();
final PortalManagerAspect aspect = (PortalManagerAspect) iterator.next();
aspect.render(this, this.service, ch, parameters);
aspect.render(this, this.service, ch, properties);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Properties;

import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
Expand All @@ -42,7 +43,7 @@ public void configure(ServiceSelector aspectSelector,
ServiceSelector adapterSelector,
Configuration conf,
PortalManagerAspect endAspect,
Parameters endAspectParameters)
Properties endAspectProperties)
throws ConfigurationException {
if ( conf != null ) {
final Configuration[] aspectConfigs = conf.getChildren("aspect");
Expand Down Expand Up @@ -71,12 +72,12 @@ public void configure(ServiceSelector aspectSelector,
}
}
this.aspects.add(pAspect);
Parameters aspectConfiguration = Parameters.fromConfiguration(current);
this.configs.add(aspectConfiguration);
final Parameters aspectConfiguration = Parameters.fromConfiguration(current);
this.configs.add(Parameters.toProperties(aspectConfiguration));
}
}
this.aspects.add(endAspect);
this.configs.add(endAspectParameters);
this.configs.add(endAspectProperties);
}

public Iterator getIterator() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@

import java.util.Iterator;
import java.util.List;
import java.util.Properties;

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.parameters.Parameters;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.ServiceSelector;
Expand Down Expand Up @@ -105,15 +105,15 @@ public void process()
}

/**
* @see PortalManager#showPortal(ContentHandler, Parameters)
* @see PortalManager#showPortal(ContentHandler, Properties)
*/
public void showPortal(ContentHandler contentHandler, Parameters parameters)
public void showPortal(ContentHandler contentHandler, Properties properties)
throws SAXException {
DefaultPortalManagerAspectContext aspectContext =
new DefaultPortalManagerAspectContext(this.chain,
this.portalService,
ContextHelper.getObjectModel(this.context));
aspectContext.invokeNext(contentHandler, parameters);
aspectContext.invokeNext(contentHandler, properties);
}

/**
Expand All @@ -125,7 +125,7 @@ public void configure(Configuration conf) throws ConfigurationException {
this.adapterSelector,
conf.getChild("aspects"),
this,
new Parameters());
new Properties());
}

/**
Expand All @@ -144,12 +144,12 @@ public void prepare(PortalManagerAspectPrepareContext renderContext, PortalServi
}

/**
* @see org.apache.cocoon.portal.PortalManagerAspect#render(org.apache.cocoon.portal.PortalManagerAspectRenderContext, org.apache.cocoon.portal.PortalService, org.xml.sax.ContentHandler, org.apache.avalon.framework.parameters.Parameters)
* @see org.apache.cocoon.portal.PortalManagerAspect#render(org.apache.cocoon.portal.PortalManagerAspectRenderContext, org.apache.cocoon.portal.PortalService, org.xml.sax.ContentHandler, java.util.Properties)
*/
public void render(PortalManagerAspectRenderContext renderContext,
PortalService service,
ContentHandler ch,
Parameters parameters)
Properties properties)
throws SAXException {
final ProfileManager profileManager = this.portalService.getProfileManager();

Expand Down Expand Up @@ -177,8 +177,8 @@ public void render(PortalManagerAspectRenderContext renderContext,
Layout portalLayout = null;

// check for parameters
final String copletId = parameters.getParameter(PortalManager.PARAMETER_RENDER_COPLET, null);
final String layoutId = parameters.getParameter(PortalManager.PARAMETER_RENDER_LAYOUT, null);
final String copletId = (properties == null ? null : properties.getProperty(PortalManager.PROPERTY_RENDER_COPLET, null));
final String layoutId = (properties == null ? null : properties.getProperty(PortalManager.PROPERTY_RENDER_LAYOUT, null));
if ( StringUtils.isNotEmpty(copletId) && StringUtils.isNotEmpty(layoutId) ) {
throw new SAXException("Only one of the paramteters can be specified for rendering: coplet or layout.");
}
Expand Down Expand Up @@ -210,6 +210,6 @@ public void render(PortalManagerAspectRenderContext renderContext,
}
// although we should be the last in the queue,
// let's invoke the next
renderContext.invokeNext(ch, parameters);
renderContext.invokeNext(ch, properties);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@

import java.util.Iterator;
import java.util.List;
import java.util.Properties;

import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.parameters.Parameters;
import org.apache.cocoon.ProcessingException;
import org.apache.cocoon.portal.PortalManagerAspect;
import org.apache.cocoon.portal.PortalManagerAspectPrepareContext;
Expand Down Expand Up @@ -57,12 +57,12 @@ public void prepare(PortalManagerAspectPrepareContext context,
}

/**
* @see org.apache.cocoon.portal.PortalManagerAspect#render(org.apache.cocoon.portal.PortalManagerAspectRenderContext, org.apache.cocoon.portal.PortalService, org.xml.sax.ContentHandler, org.apache.avalon.framework.parameters.Parameters)
* @see org.apache.cocoon.portal.PortalManagerAspect#render(org.apache.cocoon.portal.PortalManagerAspectRenderContext, org.apache.cocoon.portal.PortalService, org.xml.sax.ContentHandler, java.util.Properties)
*/
public void render(PortalManagerAspectRenderContext context,
PortalService service,
ContentHandler ch,
Parameters parameters)
Properties properties)
throws SAXException {
// we should be the first aspect for rendering
// preload all changed coplets
Expand All @@ -75,6 +75,6 @@ public void render(PortalManagerAspectRenderContext context,
adapter.toSAX(cid, nullHandler );
}
// start "real" rendering
context.invokeNext(ch, parameters);
context.invokeNext(ch, properties);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -398,18 +398,18 @@ public void prepare(PortalManagerAspectPrepareContext aspectContext,
}

/**
* @see org.apache.cocoon.portal.PortalManagerAspect#render(org.apache.cocoon.portal.PortalManagerAspectRenderContext, org.apache.cocoon.portal.PortalService, org.xml.sax.ContentHandler, org.apache.avalon.framework.parameters.Parameters)
* @see org.apache.cocoon.portal.PortalManagerAspect#render(org.apache.cocoon.portal.PortalManagerAspectRenderContext, org.apache.cocoon.portal.PortalService, org.xml.sax.ContentHandler, java.util.Properties)
*/
public void render(PortalManagerAspectRenderContext aspectContext,
PortalService service,
ContentHandler ch,
Parameters contextParameters)
Properties properties)
throws SAXException {
final Map objectModel = aspectContext.getObjectModel();

// don't generate a response, if we issued a redirect
if (objectModel.remove("portlet-event") == null) {
aspectContext.invokeNext(ch, contextParameters);
aspectContext.invokeNext(ch, properties);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;

import oasis.names.tc.wsrp.v1.types.BlockingInteractionResponse;
import oasis.names.tc.wsrp.v1.types.LocalizedString;
Expand Down Expand Up @@ -669,14 +670,14 @@ public void prepare(PortalManagerAspectPrepareContext aspectContext,
}

/**
* @see org.apache.cocoon.portal.PortalManagerAspect#render(org.apache.cocoon.portal.PortalManagerAspectRenderContext, org.apache.cocoon.portal.PortalService, org.xml.sax.ContentHandler, org.apache.avalon.framework.parameters.Parameters)
* @see org.apache.cocoon.portal.PortalManagerAspect#render(org.apache.cocoon.portal.PortalManagerAspectRenderContext, org.apache.cocoon.portal.PortalService, org.xml.sax.ContentHandler, java.util.Properties)
*/
public void render(PortalManagerAspectRenderContext aspectContext,
PortalService service,
ContentHandler ch,
Parameters parameters)
Properties properties)
throws SAXException {
aspectContext.invokeNext(ch, parameters);
aspectContext.invokeNext(ch, properties);
}

/**
Expand Down

0 comments on commit 66ca163

Please sign in to comment.