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 2007/12/01 01:34:54 UTC
svn commit: r600024 - in /cocoon/trunk/blocks/cocoon-portal:
cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/
cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/impl/
cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/layout/ren...
Author: cziegeler
Date: Fri Nov 30 16:34:52 2007
New Revision: 600024
URL: http://svn.apache.org/viewvc?rev=600024&view=rev
Log:
CopletType directly references CopletAdapter and not a weak reference just using a name. Removed loading of coplet types by castor; coplet types are now spring managed beans. Use consistent names for identifiers.
Added:
cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/spring/CopletTypeDefinitionParser.java (with props)
Removed:
cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/persistence/castor/ConfigurationFieldHandler.java
cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/persistence/castor/coplettype.xml
cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/avalon/cocoon-portal-tools.xconf
cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/profiles/coplettype/
Modified:
cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/PortalService.java
cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/impl/PortalServiceImpl.java
cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/DefaultCopletAspect.java
cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/WindowAspect.java
cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/CopletType.java
cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/Layout.java
cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/persistence/castor/CastorSourceConverter.java
cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/ProfileLS.java
cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java
cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java
cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/ProfileHolder.java
cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/StaticProfileManager.java
cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/aspects/impl/PreloadPortalManagerAspect.java
cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultCopletFactory.java
cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/source/CopletSource.java
cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/source/CopletSourceFactory.java
cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/spring/PortalNamespaceHandler.java
cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/spring/schema/cocoon-portal-1.0.xsd
cocoon/trunk/blocks/cocoon-portal/cocoon-portal-portlet-impl/src/main/java/org/apache/cocoon/portal/pluto/TestProfileManager.java
cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/cocoon-portal-sample-components.xml
cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/coplet-types.xml
cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/profiles/copletdefinition/portal.xml
Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/PortalService.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/PortalService.java?rev=600024&r1=600023&r2=600024&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/PortalService.java (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/PortalService.java Fri Nov 30 16:34:52 2007
@@ -18,7 +18,6 @@
import java.util.List;
-import org.apache.cocoon.portal.coplet.adapter.CopletAdapter;
import org.apache.cocoon.portal.event.EventConverter;
import org.apache.cocoon.portal.event.EventManager;
import org.apache.cocoon.portal.profile.ProfileManager;
@@ -88,11 +87,6 @@
* Get the current profile manager.
*/
ProfileManager getProfileManager();
-
- /**
- * Get the coplet adapter.
- */
- CopletAdapter getCopletAdapter(String name);
/**
* Get the coplet factory.
Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/impl/PortalServiceImpl.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/impl/PortalServiceImpl.java?rev=600024&r1=600023&r2=600024&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/impl/PortalServiceImpl.java (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/impl/PortalServiceImpl.java Fri Nov 30 16:34:52 2007
@@ -36,7 +36,6 @@
import org.apache.cocoon.portal.PortalRuntimeException;
import org.apache.cocoon.portal.PortalService;
import org.apache.cocoon.portal.RequestContext;
-import org.apache.cocoon.portal.coplet.adapter.CopletAdapter;
import org.apache.cocoon.portal.event.EventConverter;
import org.apache.cocoon.portal.event.EventManager;
import org.apache.cocoon.portal.om.SkinDescription;
@@ -94,9 +93,6 @@
/** The link service. */
protected LinkService linkService;
- /** The used coplet adapters. */
- protected Map copletAdapters = Collections.EMPTY_MAP;
-
/** The coplet factory. */
protected CopletFactory copletFactory;
@@ -120,7 +116,6 @@
*/
public void service(ServiceManager serviceManager) throws ServiceException {
this.manager = serviceManager;
- this.copletAdapters = (Map)this.manager.lookup(CopletAdapter.class.getName()+"Map");
this.requestContextProvider = (RequestContextProvider)this.manager.lookup(RequestContextProvider.class.getName());
}
@@ -305,17 +300,6 @@
}
}
return this.eventManager;
- }
-
- /**
- * @see org.apache.cocoon.portal.PortalService#getCopletAdapter(java.lang.String)
- */
- public CopletAdapter getCopletAdapter(String name) {
- CopletAdapter o = (CopletAdapter) this.copletAdapters.get( name );
- if ( o == null ) {
- throw new PortalRuntimeException("Unable to lookup coplet adapter with name " + name);
- }
- return o;
}
/**
Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/DefaultCopletAspect.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/DefaultCopletAspect.java?rev=600024&r1=600023&r2=600024&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/DefaultCopletAspect.java (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/DefaultCopletAspect.java Fri Nov 30 16:34:52 2007
@@ -88,8 +88,7 @@
a.addCDATAAttribute("type", "text/javascript");
XMLUtils.createElement(handler, "script", a, buffer.toString());
} else {
- final String adapterName = cid.getCopletDefinition().getCopletType().getCopletAdapterName();
- final CopletAdapter copletAdapter = rendererContext.getPortalService().getCopletAdapter(adapterName);
+ final CopletAdapter copletAdapter = cid.getCopletDefinition().getCopletType().getCopletAdapter();
copletAdapter.toSAX(cid, new IncludeXMLConsumer(handler));
}
Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/WindowAspect.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/WindowAspect.java?rev=600024&r1=600023&r2=600024&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/WindowAspect.java (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/WindowAspect.java Fri Nov 30 16:34:52 2007
@@ -115,11 +115,11 @@
if ( config.rootTag ) {
XMLUtils.startElement(contenthandler, config.tagName);
}
- final CopletAdapter adapter = rendererContext.getPortalService().getCopletAdapter(copletInstance.getCopletDefinition().getCopletType().getCopletAdapterName());
+ final CopletAdapter adapter = copletInstance.getCopletDefinition().getCopletType().getCopletAdapter();
// stream some general infos about the copet instance data
this.streamCopletInstanceDataInfos(copletInstance, adapter, layout, contenthandler);
-
+
// stream the title
this.streamTitle(copletInstance, adapter, layout, contenthandler);
Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/CopletType.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/CopletType.java?rev=600024&r1=600023&r2=600024&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/CopletType.java (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/CopletType.java Fri Nov 30 16:34:52 2007
@@ -16,30 +16,31 @@
*/
package org.apache.cocoon.portal.om;
-import java.io.Serializable;
+import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
+import org.apache.cocoon.portal.coplet.adapter.CopletAdapter;
import org.apache.cocoon.portal.util.PortalUtils;
/**
* A coplet base data defines a coplet type, like a pipeline based coplet,
- * a JSR 168 portlet or a WSRP portlet. For each type exists a coplet base
- * data with some configuration.
+ * a JSR 168 portlet or a WSRP portlet. For each type exists a coplet type
+ * with some configuration.
* Based on the coplet type, coplets are created ({@link CopletDefinition}.
*
* @version $Id$
*/
-public final class CopletType implements Serializable, Cloneable {
+public final class CopletType {
- protected final Map copletConfig = new HashMap();
+ protected Map copletConfig = Collections.EMPTY_MAP;
protected final String id;
- protected String copletAdapterName;
+ protected CopletAdapter copletAdapter;
/**
- * Create a new coplet base data object.
+ * Create a new coplet base data object.
* @param id The unique id of the object.
* @see PortalUtils#testId(String)
*/
@@ -51,12 +52,20 @@
this.id = id;
}
+ /**
+ * Return the unique identifier for the coplet type.
+ * @return The non-null unique identifier.
+ */
public String getId() {
return id;
}
- public String getCopletAdapterName() {
- return this.copletAdapterName;
+ public CopletAdapter getCopletAdapter() {
+ return this.copletAdapter;
+ }
+
+ public void setCopletAdapter(final CopletAdapter ca) {
+ this.copletAdapter = ca;
}
public Object getCopletConfig(String key) {
@@ -64,19 +73,30 @@
}
public void setCopletConfig(String key, Object value) {
+ if ( this.copletConfig.size() == 0 ) {
+ this.copletConfig = new HashMap();
+ }
this.copletConfig.put(key, value);
}
public Object removeCopletConfig(String key) {
- return this.copletConfig.remove(key);
+ final Object oldValue = this.copletConfig.remove(key);
+ if ( this.copletConfig.size() == 0 ) {
+ this.copletConfig = Collections.EMPTY_MAP;
+ }
+ return oldValue;
}
public Map getCopletConfig() {
return this.copletConfig;
}
- public void setCopletAdapterName(String name) {
- this.copletAdapterName = name;
+ public void setCopletConfig(final Map config) {
+ if ( config.size() == 0 ) {
+ this.copletConfig = Collections.EMPTY_MAP;
+ } else {
+ this.copletConfig = new HashMap(config);
+ }
}
/**
@@ -84,6 +104,6 @@
*/
public String toString() {
return "CopletType (" + this.hashCode() +
- "), id=" + this.getId() + ", coplet-adapter=" + this.getCopletAdapterName();
+ "), id=" + this.getId() + ", coplet-adapter=" + this.getCopletAdapter();
}
}
Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/Layout.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/Layout.java?rev=600024&r1=600023&r2=600024&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/Layout.java (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/om/Layout.java Fri Nov 30 16:34:52 2007
@@ -39,7 +39,7 @@
* in the session, it is advisable to use serializable objects only.
*
* If you are implementing your own layout object make sure that your
- * class provides a two string constructor which calls {@link #Layout(String, LayoutType)}.
+ * class provides a one string constructor which calls {@link #Layout(String)}.
*
* @version $Id$
*/
Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/persistence/castor/CastorSourceConverter.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/persistence/castor/CastorSourceConverter.java?rev=600024&r1=600023&r2=600024&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/persistence/castor/CastorSourceConverter.java (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/persistence/castor/CastorSourceConverter.java Fri Nov 30 16:34:52 2007
@@ -55,12 +55,12 @@
* This is a component that converts a profile (= object tree) to XML and vice-versa
* using Castor. It could be used to persist objects as a XML representation.
*
- * In order to work properly the methods provided by this interface require some
+ * In order to work properly the methods provided by this interface require some
* parameters:
* objectmap : containing a map of objects for resolving references during load
* profiletype: specifying the mapping (e.g. in the portal this is one of layout, copletinstancedata, copletdata or copletbasedate)
* suppressXSIType: Sets whether or not the xsi:type attributes should appear on the marshalled document.
- *
+ *
* @version $Id$
*/
public class CastorSourceConverter
@@ -112,7 +112,7 @@
Object referenceObject,
Map parameters)
throws ConverterException {
- Object references = referenceObject;
+ Object references = referenceObject;
if ( referenceObject instanceof Collection && !(referenceObject instanceof CollectionWrapper) ) {
references = new CollectionWrapper((Collection)referenceObject);
}
@@ -161,7 +161,6 @@
// default configuration
final String prefix = "resource://org/apache/cocoon/portal/persistence/castor/";
this.mappingSources.put(ProfileLS.PROFILETYPE_LAYOUT, prefix + ProfileLS.PROFILETYPE_LAYOUT +".xml");
- this.mappingSources.put(ProfileLS.PROFILETYPE_COPLETTYPE, prefix + ProfileLS.PROFILETYPE_COPLETTYPE + ".xml");
this.mappingSources.put(ProfileLS.PROFILETYPE_COPLETDEFINITION, prefix + ProfileLS.PROFILETYPE_COPLETDEFINITION + ".xml");
this.mappingSources.put(ProfileLS.PROFILETYPE_COPLETINSTANCE, prefix + ProfileLS.PROFILETYPE_COPLETINSTANCE + ".xml");
boolean plutoAvailable = false;
@@ -198,10 +197,10 @@
Mapping mapping;
Iterator iterator = this.mappingSources.entrySet().iterator();
while (iterator.hasNext()) {
- entry = (Map.Entry)iterator.next();
+ entry = (Map.Entry)iterator.next();
name = (String)entry.getKey();
mappingSource = (String)entry.getValue();
-
+
source = resolver.resolveURI(mappingSource);
mapping = new Mapping();
mapping.loadMapping(SourceUtil.getInputSource(source));
Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/ProfileLS.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/ProfileLS.java?rev=600024&r1=600023&r2=600024&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/ProfileLS.java (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/ProfileLS.java Fri Nov 30 16:34:52 2007
@@ -29,7 +29,6 @@
* This object map varies depending on the profile type:
* PROFILETYPE_LAYOUT: A map with layout types.
* PROFILETYPE_LAYOUTINSTANCE: -
- * PROFILETYPE_COPLETTYPE: -
* PROFILETYPE_COPLETDEFINITION: A map with coplet types.
* PROFILETYPE_COPLETINSTANCE: A map with coplet definitions
*
@@ -42,7 +41,6 @@
String PROFILETYPE_LAYOUT = "layout";
String PROFILETYPE_LAYOUTINSTANCE = "layoutinstance";
- String PROFILETYPE_COPLETTYPE = "coplettype";
String PROFILETYPE_COPLETDEFINITION = "copletdefinition";
String PROFILETYPE_COPLETINSTANCE = "copletinstance";
Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java?rev=600024&r1=600023&r2=600024&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/AbstractProfileManager.java Fri Nov 30 16:34:52 2007
@@ -17,6 +17,7 @@
package org.apache.cocoon.portal.profile.impl;
import java.util.Collection;
+import java.util.Collections;
import java.util.Iterator;
import java.util.Map;
@@ -28,6 +29,7 @@
import org.apache.cocoon.portal.om.CompositeLayout;
import org.apache.cocoon.portal.om.CopletInstance;
import org.apache.cocoon.portal.om.CopletLayout;
+import org.apache.cocoon.portal.om.CopletType;
import org.apache.cocoon.portal.om.Item;
import org.apache.cocoon.portal.om.Layout;
import org.apache.cocoon.portal.om.LayoutException;
@@ -51,6 +53,13 @@
/** The chain for the configured profile manager aspects. */
protected AspectChainImpl chain;
+ /** The map of coplet types. */
+ protected Map copletTypesMap = Collections.EMPTY_MAP;
+
+ public void setCopletTypesMap(final Map m) {
+ this.copletTypesMap = (m != null ? m : Collections.EMPTY_MAP);
+ }
+
/**
* Set the event chain.
* @param a A chain.
@@ -67,6 +76,20 @@
}
/**
+ * @see org.apache.cocoon.portal.profile.ProfileManager#getCopletTypes()
+ */
+ public Collection getCopletTypes() {
+ return this.copletTypesMap.values();
+ }
+
+ /**
+ * @see org.apache.cocoon.portal.profile.ProfileManager#getCopletType(java.lang.String)
+ */
+ public CopletType getCopletType(String id) {
+ return (CopletType)this.copletTypesMap.get(id);
+ }
+
+ /**
* Receives any user related event and invokes login, logout etc.
* @see Receiver
*/
@@ -122,7 +145,7 @@
if ( cid.getCopletDefinition() != null ) {
// now invoke login on each instance
CopletAdapter adapter;
- adapter = this.portalService.getCopletAdapter(cid.getCopletDefinition().getCopletType().getCopletAdapterName());
+ adapter = cid.getCopletDefinition().getCopletType().getCopletAdapter();
adapter.login( cid );
}
}
@@ -155,23 +178,6 @@
}
}
return layout;
- }
-
- /**
- * Process a freshly loaded profile.
- */
- protected Collection processCopletTypes(Collection copletTypes)
- throws LayoutException {
- Collection result = copletTypes;
- if ( this.chain.hasAspects() ) {
- final ProfileManagerAspectContextImpl aspectContext = new ProfileManagerAspectContextImpl(this.portalService,
- this.chain,
- ProfileManagerAspectContextImpl.PHASE_COPLET_TYPES);
- aspectContext.invokeNext(copletTypes);
- result = (Collection)aspectContext.getResult();
- }
- this.prepareObject(null, result);
- return result;
}
/**
Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java?rev=600024&r1=600023&r2=600024&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/GroupBasedProfileManager.java Fri Nov 30 16:34:52 2007
@@ -36,7 +36,6 @@
import org.apache.cocoon.portal.event.layout.LayoutRemovedEvent;
import org.apache.cocoon.portal.om.CopletDefinition;
import org.apache.cocoon.portal.om.CopletInstance;
-import org.apache.cocoon.portal.om.CopletType;
import org.apache.cocoon.portal.om.Layout;
import org.apache.cocoon.portal.om.LayoutException;
import org.apache.cocoon.portal.om.LayoutInstance;
@@ -81,7 +80,6 @@
public SourceValidity validity;
}
- final protected ProfileInfo copletTypes = new ProfileInfo();
final protected ProfileInfo copletDefinitions = new ProfileInfo();
/** All deployed coplet datas. */
@@ -132,7 +130,7 @@
Iterator iter = profile.getCopletInstances().iterator();
while ( iter.hasNext() ) {
CopletInstance cid = (CopletInstance) iter.next();
- CopletAdapter adapter = this.portalService.getCopletAdapter(cid.getCopletDefinition().getCopletType().getCopletAdapterName());
+ CopletAdapter adapter = cid.getCopletDefinition().getCopletType().getCopletAdapter();
adapter.logout( cid );
}
@@ -290,8 +288,6 @@
profile.setLayoutTypes(this.portalService.getLayoutFactory().getLayoutTypes());
try {
- // first "load" the global data
- profile.setCopletTypes( this.getGlobalCopletTypes() );
// FIXME - We should be able to merge definitions from various locations
// This could also be handled by aspects?
profile.setCopletDefinitions( this.getGlobalCopletDefinitions(user, profile) );
@@ -333,65 +329,6 @@
}
}
- /**
- * Return the current set of global coplet types.
- * @return The global set of coplet types.
- * @throws Exception
- */
- protected Map getGlobalCopletTypes()
- throws Exception {
- // if we already have loaded the profile and don't check
- // for changes, just return the profile
- if ( this.copletTypes.objects != null && !this.checkForChanges ) {
- return this.copletTypes.objects;
- }
-
- // build key for loading the profile
- final Map key = this.buildKey(CATEGORY_GLOBAL,
- ProfileLS.PROFILETYPE_COPLETTYPE,
- null,
- true,
- null);
-
- SourceValidity newValidity = null;
- // if we have a profile, check for reloading
- if ( this.copletTypes.validity != null ) {
- // if it's still valid just return the profile
- final int validity = this.copletTypes.validity.isValid();
- if ( validity == SourceValidity.VALID) {
- return this.copletTypes.objects;
- } else if ( validity == SourceValidity.UNKNOWN ) {
- newValidity = loader.getValidity(key, ProfileLS.PROFILETYPE_COPLETTYPE);
- if ( newValidity != null
- && this.copletTypes.validity.isValid(newValidity) == SourceValidity.VALID) {
- return this.copletTypes.objects;
- }
- }
- }
-
- // we have to load/reload
- synchronized ( this ) {
- Collection collection = (Collection)loader.loadProfile(key, ProfileLS.PROFILETYPE_COPLETTYPE, null);
- collection = this.processCopletTypes(collection);
- final Map objects = new HashMap();
- final Iterator i = collection.iterator();
- while ( i.hasNext() ) {
- final CopletType current = (CopletType)i.next();
- objects.put(current.getId(), current);
- }
- this.copletTypes.objects = objects;
- if ( newValidity == null ) {
- newValidity = loader.getValidity(key, ProfileLS.PROFILETYPE_COPLETTYPE);
- }
- this.copletTypes.validity = newValidity;
- // now invalidate coplet definitions
- this.copletDefinitions.objects = null;
- this.copletDefinitions.validity = null;
-
- return this.copletTypes.objects;
- }
- }
-
protected Map getGlobalCopletDefinitions(final PortalUser info,
final ProfileHolder profile)
throws Exception {
@@ -423,7 +360,7 @@
}
synchronized ( this ) {
- Collection collection = (Collection)loader.loadProfile(key, ProfileLS.PROFILETYPE_COPLETDEFINITION, profile.getCopletTypesMap());
+ Collection collection = (Collection)loader.loadProfile(key, ProfileLS.PROFILETYPE_COPLETDEFINITION, this.copletTypesMap);
collection = this.processCopletDefinitions(collection);
final Iterator i = collection.iterator();
final Map objects = new HashMap();
@@ -582,33 +519,6 @@
// TODO
throw new ProfileException("Exception during save profile", e);
}
- }
-
- /**
- * @see org.apache.cocoon.portal.profile.ProfileManager#getCopletType(java.lang.String)
- */
- public CopletType getCopletType(String id) {
- if ( this.copletTypes.objects == null ) {
- this.getCopletTypes();
- }
- return (CopletType)this.copletTypes.objects.get(id);
- }
-
- /**
- * @see org.apache.cocoon.portal.profile.ProfileManager#getCopletTypes()
- */
- public Collection getCopletTypes() {
- if ( this.copletTypes.objects == null ) {
- try {
- // first "load" the global data
- this.getGlobalCopletTypes();
- } catch (ProfileException e) {
- throw e;
- } catch (Exception e) {
- throw new ProfileException("Unable to load global coplet types.", e);
- }
- }
- return this.copletTypes.objects.values();
}
/**
Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/ProfileHolder.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/ProfileHolder.java?rev=600024&r1=600023&r2=600024&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/ProfileHolder.java (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/ProfileHolder.java Fri Nov 30 16:34:52 2007
@@ -41,9 +41,6 @@
*/
public class ProfileHolder {
- /** A map of all coplet types. */
- protected Map copletTypes;
-
/** A map of all coplet definitions. */
protected Map copletDefinitions;
@@ -74,14 +71,6 @@
}
/**
- * Set all coplet types.
- * @param copletTypes An id based map of the types.
- */
- public void setCopletTypes(Map copletTypes) {
- this.copletTypes = copletTypes;
- }
-
- /**
* Set all coplet definitions.
* @param copletDefinitions An id based map of the definitions.
*/
@@ -110,13 +99,6 @@
}
/**
- * Return all coplet types of this profile.
- */
- public Collection getCopletTypes() {
- return this.copletTypes.values();
- }
-
- /**
* Return all coplet definitions.
*/
public Collection getCopletDefinitions() {
@@ -138,13 +120,6 @@
}
/**
- * Search for a coplet type.
- */
- public CopletType searchCopletType(String copletTypeId) {
- return (CopletType) this.copletTypes.get(copletTypeId);
- }
-
- /**
* Search for a coplet definition.
*/
public CopletDefinition searchCopletDefinition(String copletDefinitionId) {
@@ -167,17 +142,6 @@
}
/**
- * Search for all coplet definitions of the coplet type.
- */
- public Collection searchCopletDefinitions(String copletTypeId) {
- final CopletType cbd = this.searchCopletType(copletTypeId);
- if ( cbd != null ) {
- return this.searchCopletDefinitions(cbd);
- }
- return null;
- }
-
- /**
* Search for a coplet instance.
*/
public CopletInstance searchCopletInstance(String copletId) {
@@ -311,10 +275,6 @@
public Map getCopletDefinitionsMap() {
return this.copletDefinitions;
- }
-
- public Map getCopletTypesMap() {
- return this.copletTypes;
}
public Map getLayoutTypesMap() {
Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/StaticProfileManager.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/StaticProfileManager.java?rev=600024&r1=600023&r2=600024&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/StaticProfileManager.java (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/profile/impl/StaticProfileManager.java Fri Nov 30 16:34:52 2007
@@ -27,7 +27,6 @@
import org.apache.cocoon.portal.om.CompositeLayout;
import org.apache.cocoon.portal.om.CopletDefinition;
import org.apache.cocoon.portal.om.CopletInstance;
-import org.apache.cocoon.portal.om.CopletType;
import org.apache.cocoon.portal.om.Item;
import org.apache.cocoon.portal.om.Layout;
import org.apache.cocoon.portal.om.LayoutInstance;
@@ -50,7 +49,6 @@
protected final StaticBucketMap copletInstances = new StaticBucketMap();
protected final StaticBucketMap copletDefinitions = new StaticBucketMap();
- protected final StaticBucketMap copletTypes = new StaticBucketMap();
protected static final String LAYOUTKEY_PREFIX = StaticProfileManager.class.getName() + "/Layout/";
@@ -157,31 +155,16 @@
return instances;
}
- final Map map = new LinkedMap();
- map.put("base", this.profilesPath);
- map.put("portalname", this.portalService.getPortalName());
- map.put("profile", "coplet");
- map.put("name", "basedata");
- Collection cBase = (Collection) this.loader.loadProfile(map, ProfileLS.PROFILETYPE_COPLETTYPE, null);
- cBase = this.processCopletTypes(cBase);
- final Map types = new HashMap();
- Iterator i = cBase.iterator();
- while ( i.hasNext() ) {
- final CopletDefinition current = (CopletDefinition)i.next();
- types.put(current.getId(), current);
- }
- this.copletTypes.put(portalName, types);
-
// CopletDefinition
- map.clear();
+ final Map map = new LinkedMap();
map.put("base", this.profilesPath);
map.put("portalname", this.portalService.getPortalName());
map.put("profile", "coplet");
map.put("name", "data");
- Collection c = (Collection) this.loader.loadProfile(map, ProfileLS.PROFILETYPE_COPLETDEFINITION, types);
+ Collection c = (Collection) this.loader.loadProfile(map, ProfileLS.PROFILETYPE_COPLETDEFINITION, this.copletTypesMap);
c = this.processCopletDefinitions(c);
final Map definitions = new HashMap();
- i = c.iterator();
+ final Iterator i = c.iterator();
while ( i.hasNext() ) {
final CopletDefinition current = (CopletDefinition)i.next();
definitions.put(current.getId(), current);
@@ -284,20 +267,6 @@
} catch (Exception e) {
throw new ProfileException("Error in getCopletInstanceDatas.", e);
}
- }
-
- /**
- * @see org.apache.cocoon.portal.profile.ProfileManager#getCopletType(java.lang.String)
- */
- public CopletType getCopletType(String id) {
- return (CopletType)((Map)this.copletTypes.get(this.portalService.getPortalName())).get(id);
- }
-
- /**
- * @see org.apache.cocoon.portal.profile.ProfileManager#getCopletTypes()
- */
- public Collection getCopletTypes() {
- return ((Map)this.copletTypes.get(this.portalService.getPortalName())).values();
}
/**
Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/aspects/impl/PreloadPortalManagerAspect.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/aspects/impl/PreloadPortalManagerAspect.java?rev=600024&r1=600023&r2=600024&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/aspects/impl/PreloadPortalManagerAspect.java (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/aspects/impl/PreloadPortalManagerAspect.java Fri Nov 30 16:34:52 2007
@@ -57,8 +57,7 @@
final Iterator i = changedCoplets.iterator();
while (i.hasNext()) {
final CopletInstance cid = (CopletInstance)i.next();
- final String adapterName = cid.getCopletDefinition().getCopletType().getCopletAdapterName();
- final CopletAdapter adapter = context.getPortalService().getCopletAdapter(adapterName);
+ final CopletAdapter adapter = cid.getCopletDefinition().getCopletType().getCopletAdapter();
adapter.toSAX(cid, nullHandler );
}
// start "real" rendering
Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultCopletFactory.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultCopletFactory.java?rev=600024&r1=600023&r2=600024&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultCopletFactory.java (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultCopletFactory.java Fri Nov 30 16:34:52 2007
@@ -33,8 +33,8 @@
*
* @version $Id$
*/
-public class DefaultCopletFactory
- extends AbstractBean
+public class DefaultCopletFactory
+ extends AbstractBean
implements CopletFactory {
protected static long idCounter = System.currentTimeMillis();
@@ -63,8 +63,7 @@
instance.setCopletDefinition(copletData);
// now lookup the adapter
- final String adapterName = copletData.getCopletType().getCopletAdapterName();
- final CopletAdapter adapter = this.portalService.getCopletAdapter(adapterName);
+ final CopletAdapter adapter = instance.getCopletDefinition().getCopletType().getCopletAdapter();
adapter.login( instance );
// send an event
@@ -77,9 +76,7 @@
*/
public void remove(CopletInstance copletInstanceData) {
if ( copletInstanceData != null ) {
- // now lookup the adapter
- final String adapterName = copletInstanceData.getCopletDefinition().getCopletType().getCopletAdapterName();
- final CopletAdapter adapter = this.portalService.getCopletAdapter(adapterName);
+ final CopletAdapter adapter = copletInstanceData.getCopletDefinition().getCopletType().getCopletAdapter();
adapter.logout( copletInstanceData );
// send an event
@@ -99,17 +96,16 @@
idCounter += 1;
}
}
- final CopletDefinition instance = new CopletDefinition(id);
- instance.setCopletType(copletType);
+ final CopletDefinition definition = new CopletDefinition(id);
+ definition.setCopletType(copletType);
- final String adapterName = instance.getCopletType().getCopletAdapterName();
- final CopletAdapter adapter = this.portalService.getCopletAdapter(adapterName);
- adapter.init( instance );
+ final CopletAdapter adapter = definition.getCopletType().getCopletAdapter();
+ adapter.init( definition );
// send an event
- this.portalService.getEventManager().send(new CopletDefinitionAddedEvent(instance));
+ this.portalService.getEventManager().send(new CopletDefinitionAddedEvent(definition));
- return instance;
+ return definition;
}
/**
@@ -117,8 +113,7 @@
*/
public void remove(CopletDefinition copletDefinition) {
if ( copletDefinition != null ) {
- final String adapterName = copletDefinition.getCopletType().getCopletAdapterName();
- final CopletAdapter adapter = this.portalService.getCopletAdapter(adapterName);
+ final CopletAdapter adapter = copletDefinition.getCopletType().getCopletAdapter();
adapter.destroy( copletDefinition );
// send an event
Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/source/CopletSource.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/source/CopletSource.java?rev=600024&r1=600023&r2=600024&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/source/CopletSource.java (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/source/CopletSource.java Fri Nov 30 16:34:52 2007
@@ -25,7 +25,6 @@
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.Serviceable;
import org.apache.cocoon.CascadingIOException;
-import org.apache.cocoon.portal.PortalService;
import org.apache.cocoon.portal.coplet.adapter.CopletAdapter;
import org.apache.cocoon.portal.om.CopletInstance;
import org.apache.cocoon.serialization.Serializer;
@@ -41,21 +40,17 @@
*
* @version $Id$
*/
-public class CopletSource
+public class CopletSource
implements Source, XMLizable, Serviceable {
protected ServiceManager manager;
protected String uri;
- protected String copletControllerName;
protected CopletInstance copletInstanceData;
/** The used protocol */
protected String scheme;
- /** The portal service. */
- protected final PortalService portalService;
-
/**
* @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
*/
@@ -65,13 +60,10 @@
public CopletSource(String location,
String protocol,
- CopletInstance coplet,
- PortalService service) {
- this.portalService = service;
+ CopletInstance coplet) {
this.uri = location;
this.scheme = (protocol == null ? "coplet" : protocol);
this.copletInstanceData = coplet;
- this.copletControllerName = this.copletInstanceData.getCopletDefinition().getCopletType().getCopletAdapterName();
}
/**
@@ -112,7 +104,7 @@
* @see org.apache.excalibur.source.Source#refresh()
*/
public void refresh() {
- // nothing to do
+ // nothing to do
}
/**
@@ -139,9 +131,9 @@
/**
* @see org.apache.excalibur.xml.sax.XMLizable#toSAX(ContentHandler)
*/
- public void toSAX(ContentHandler handler)
+ public void toSAX(ContentHandler handler)
throws SAXException {
- final CopletAdapter copletAdapter = this.portalService.getCopletAdapter(this.copletControllerName);
+ final CopletAdapter copletAdapter = this.copletInstanceData.getCopletDefinition().getCopletType().getCopletAdapter();
copletAdapter.toSAX(this.copletInstanceData, handler);
}
Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/source/CopletSourceFactory.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/source/CopletSourceFactory.java?rev=600024&r1=600023&r2=600024&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/source/CopletSourceFactory.java (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/source/CopletSourceFactory.java Fri Nov 30 16:34:52 2007
@@ -32,7 +32,7 @@
*
* @version $Id$
*/
-public class CopletSourceFactory
+public class CopletSourceFactory
extends AbstractComponent
implements SourceFactory {
@@ -59,8 +59,7 @@
CopletSource copletSource =
new CopletSource(uri,
protocol,
- coplet,
- this.portalService);
+ coplet);
copletSource.service(this.manager);
return copletSource;
} catch (ServiceException ce) {
@@ -72,6 +71,6 @@
* @see org.apache.excalibur.source.SourceFactory#release(Source)
*/
public void release(Source source) {
- // nothing to do
+ // nothing to do
}
}
Added: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/spring/CopletTypeDefinitionParser.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/spring/CopletTypeDefinitionParser.java?rev=600024&view=auto
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/spring/CopletTypeDefinitionParser.java (added)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/spring/CopletTypeDefinitionParser.java Fri Nov 30 16:34:52 2007
@@ -0,0 +1,83 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.portal.spring;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.cocoon.portal.coplet.adapter.CopletAdapter;
+import org.apache.cocoon.portal.om.CopletType;
+import org.apache.cocoon.spring.configurator.impl.AbstractElementParser;
+import org.springframework.beans.factory.BeanDefinitionStoreException;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.factory.config.RuntimeBeanReference;
+import org.springframework.beans.factory.support.RootBeanDefinition;
+import org.springframework.beans.factory.xml.ParserContext;
+import org.w3c.dom.Element;
+
+/**
+ * This is the parser for the coplet type element.
+ * @version $Id$
+ */
+public class CopletTypeDefinitionParser extends AbstractElementParser {
+
+ /**
+ * @see org.springframework.beans.factory.xml.BeanDefinitionParser#parse(org.w3c.dom.Element, org.springframework.beans.factory.xml.ParserContext)
+ */
+ public BeanDefinition parse(Element element, ParserContext parserContext) {
+ // create a new bean definition for the coplet type
+ RootBeanDefinition beanDef = this.createBeanDefinition(CopletType.class, null, false);
+ final String copletTypeId = element.getAttribute("id");
+ beanDef.getConstructorArgumentValues().addIndexedArgumentValue(0, copletTypeId);
+
+ // handle coplet adapter element
+ final Element copletAdapterElement = this.getChildElements(element, "coplet-adapter")[0];
+ final String ref = this.getAttributeValue(copletAdapterElement, "ref", null);
+ final String type= this.getAttributeValue(copletAdapterElement, "type", null);
+ if ( ref == null && type == null ) {
+ throw new BeanDefinitionStoreException("Element 'coplet-adapter' must have either a 'ref' or a 'type' attribute.");
+ }
+ if ( ref != null && type != null ) {
+ throw new BeanDefinitionStoreException("Element 'coplet-adapter' must have either a 'ref' or a 'type' attribute, but not both.");
+ }
+ final String beanName = (ref != null ? ref : CopletAdapter.class.getName() + '.' + type);
+ beanDef.getPropertyValues().addPropertyValue("copletAdapter", new RuntimeBeanReference(beanName));
+
+ // handle configuration
+ final Map config = new HashMap();
+ final Element[] configElements = this.getChildElements(element, "configuration");
+ for(int i=0; i<configElements.length; i++) {
+ final String key = this.getAttributeValue(configElements[i], "key", null);
+ final String value = this.getAttributeValue(configElements[i], "value", null);
+ final String propType= this.getAttributeValue(configElements[i], "type", "string");
+ Object propValue = value;
+ if ( "boolean".equalsIgnoreCase(propType) ) {
+ propValue = Boolean.valueOf(value);
+ } else if ( "int".equalsIgnoreCase(propType) ) {
+ propValue = Integer.valueOf(value);
+ }
+ config.put(key, propValue);
+ }
+ if ( config.size() > 0 ) {
+ beanDef.getPropertyValues().addPropertyValue("copletConfig", config);
+ }
+
+ this.register(beanDef, CopletType.class.getName() + "." + copletTypeId, parserContext.getRegistry());
+ return null;
+ }
+
+}
Propchange: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/spring/CopletTypeDefinitionParser.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/spring/CopletTypeDefinitionParser.java
------------------------------------------------------------------------------
svn:keywords = author date id revision url
Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/spring/PortalNamespaceHandler.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/spring/PortalNamespaceHandler.java?rev=600024&r1=600023&r2=600024&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/spring/PortalNamespaceHandler.java (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/spring/PortalNamespaceHandler.java Fri Nov 30 16:34:52 2007
@@ -24,6 +24,12 @@
import org.springframework.beans.factory.xml.NamespaceHandlerSupport;
/**
+ * This is the namespace handler for the portal spring extension.
+ * It registers the parsers for the supported elements.
+ *
+ * @see AspectsBeanDefinitionParser
+ * @see LayoutTypeDefinitionParser
+ * @see CopletTypeDefinitionParser
*
* @version $Id$
*/
@@ -38,5 +44,6 @@
this.registerBeanDefinitionParser("response-processor-aspects", new AspectsBeanDefinitionParser(ResponseProcessorAspect.class.getName()));
this.registerBeanDefinitionParser("profile-manager-aspects", new AspectsBeanDefinitionParser(ProfileManagerAspect.class.getName()));
this.registerBeanDefinitionParser("layout-type", new LayoutTypeDefinitionParser());
+ this.registerBeanDefinitionParser("coplet-type", new CopletTypeDefinitionParser());
}
}
Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/spring/schema/cocoon-portal-1.0.xsd
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/spring/schema/cocoon-portal-1.0.xsd?rev=600024&r1=600023&r2=600024&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/spring/schema/cocoon-portal-1.0.xsd (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/spring/schema/cocoon-portal-1.0.xsd Fri Nov 30 16:34:52 2007
@@ -95,4 +95,26 @@
<xsd:attribute name="defaultIsStatic" type="xsd:boolean" use="optional"/>
</xsd:complexType>
</xsd:element>
+
+ <xsd:element name="coplet-type">
+ <xsd:complexType>
+ <xsd:sequence>
+ <xsd:element name="coplet-adapter" minOccurs="1" maxOccurs="1">
+ <xsd:complexType>
+ <xsd:attribute name="ref" type="xsd:string" use="optional"/>
+ <xsd:attribute name="type" type="xsd:string" use="optional"/>
+ </xsd:complexType>
+ </xsd:element>
+ <xsd:element name="configuration" minOccurs="0" maxOccurs="unbounded">
+ <xsd:complexType>
+ <xsd:attribute name="name" type="xsd:string" use="required"/>
+ <xsd:attribute name="value" type="xsd:string" use="required"/>
+ <xsd:attribute name="type" type="xsd:string" use="optional"/>
+ </xsd:complexType>
+ </xsd:element>
+ </xsd:sequence>
+ <xsd:attribute name="id" type="xsd:ID" use="optional"/>
+ <xsd:attribute name="name" type="xsd:string" use="optional"/>
+ </xsd:complexType>
+ </xsd:element>
</xsd:schema>
Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-portlet-impl/src/main/java/org/apache/cocoon/portal/pluto/TestProfileManager.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-portlet-impl/src/main/java/org/apache/cocoon/portal/pluto/TestProfileManager.java?rev=600024&r1=600023&r2=600024&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-portlet-impl/src/main/java/org/apache/cocoon/portal/pluto/TestProfileManager.java (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-portlet-impl/src/main/java/org/apache/cocoon/portal/pluto/TestProfileManager.java Fri Nov 30 16:34:52 2007
@@ -78,7 +78,6 @@
profile.setLayoutTypes(this.portalService.getLayoutFactory().getLayoutTypes());
// first "load" the global coplet types
- profile.setCopletTypes( this.getGlobalCopletTypes() );
profile.setCopletDefinitions( this.getGlobalCopletDefinitions( user, profile ) );
// create root layout
@@ -90,7 +89,7 @@
while ( i.hasNext() ) {
final CopletDefinition cd = (CopletDefinition)i.next();
// check for portlets
- if ( "portlet".equals(cd.getCopletType().getCopletAdapterName()) ) {
+ if ( "portlet".equals(cd.getCopletType().getId()) ) {
final String id = StringUtils.replaceChars(cd.getId() + "-1", '_', '-');
final CopletInstance cid = new CopletInstance(id);
cid.setCopletDefinition(cd);
Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/cocoon-portal-sample-components.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/cocoon-portal-sample-components.xml?rev=600024&r1=600023&r2=600024&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/cocoon-portal-sample-components.xml (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/cocoon-portal-sample-components.xml Fri Nov 30 16:34:52 2007
@@ -57,7 +57,6 @@
<property name="profileLS" ref="org.apache.cocoon.portal.profile.ProfileLS"/>
<property name="configuration">
<value>
- coplettype-global-load=cocoon:raw:/load-global-profile?profile=coplettype
copletdefinition-global-load=cocoon:raw:/load-global-profile?profile=copletdefinition
copletdefinition-role-load=cocoon:raw:/load-role-profile?profile=copletdefinition
copletdefinition-user-load=cocoon:raw:/load-user-profile?profile=copletdefinition
Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/coplet-types.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/coplet-types.xml?rev=600024&r1=600023&r2=600024&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/coplet-types.xml (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/config/spring/coplet-types.xml Fri Nov 30 16:34:52 2007
@@ -27,36 +27,21 @@
http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd
http://cocoon.apache.org/schema/portal http://cocoon.apache.org/schema/portal/cocoon-portal-1.0.xsd">
- <bean name="org.apache.cocoon.portal.om.CopletType/URICoplet"
- class="org.apache.cocoon.portal.om.CopletType">
- <constructor-arg value="URICoplet"/>
- <property name="copletAdapterName" value="cocoon"/>
- </bean>
+ <portal:coplet-type id="uri">
+ <portal:coplet-adapter type="cocoon"/>
+ </portal:coplet-type>
+
+ <portal:coplet-type id="portlet">
+ <portal:coplet-adapter type="portlet"/>
+ <portal:configuration key="buffer" type="boolean" value="true"/>
+ <portal:configuration key="full-screen" type="boolean" value="false"/>
+ <portal:configuration key="handle-sizing" type="boolean" value="true"/>
+ </portal:coplet-type>
- <bean name="org.apache.cocoon.portal.om.CopletType/Portlet"
- class="org.apache.cocoon.portal.om.CopletType">
- <constructor-arg value="Portlet"/>
- <property name="copletAdapterName" value="portlet"/>
-<!-- TODO Configuration
- <property name="configuration">
- <map>
- <entry key="buffer" value="true"/>
- <entry key="full-screen" value="false"/>
- <entry key="handle-sizing" value="true"/>
- </map>
- </property>
- -->
- </bean>
<!--
- <bean name="org.apache.cocoon.portal.om.CopletType/WSRP"
- class="org.apache.cocoon.portal.om.CopletType">
- <constructor-arg value="WSRP"/>
- <property name="copletAdapterName" value="wsrp"/>
- <property name="configuration">
- <map>
- <entry key="buffer" value="true"/>
- </map>
- </property>
- </bean>
+ <portal:coplet-type id="wsrp">
+ <portal:coplet-adapter type="wsrp"/>
+ <portal:configuration key="buffer" type="boolean" value="true"/>
+ </portal:coplet-type>
-->
</beans>
Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/profiles/copletdefinition/portal.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/profiles/copletdefinition/portal.xml?rev=600024&r1=600023&r2=600024&view=diff
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/profiles/copletdefinition/portal.xml (original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-sample/src/main/resources/COB-INF/profiles/copletdefinition/portal.xml Fri Nov 30 16:34:52 2007
@@ -23,7 +23,7 @@
-->
<coplet-definition id="Newsweek">
<title>Newsweek</title>
- <coplet-type>URICoplet</coplet-type>
+ <coplet-type>uri</coplet-type>
<attribute>
<name>uri</name>
<value xsi:type="java:java.lang.String">cocoon:/coplets/news/newsweek.rss</value>
@@ -32,7 +32,7 @@
<coplet-definition id="NYTBusiness">
<title>NYT Business</title>
- <coplet-type>URICoplet</coplet-type>
+ <coplet-type>uri</coplet-type>
<attribute>
<name>uri</name>
<value xsi:type="java:java.lang.String">cocoon:/coplets/news/nyt_business.rss</value>
@@ -41,7 +41,7 @@
<coplet-definition id="BBCNews">
<title>BBC News</title>
- <coplet-type>URICoplet</coplet-type>
+ <coplet-type>uri</coplet-type>
<attribute>
<name>uri</name>
<value xsi:type="java:java.lang.String">cocoon:/coplets/news/bbc_news.rss</value>
@@ -50,7 +50,7 @@
<coplet-definition id="CNETNews">
<title>CNET News</title>
- <coplet-type>URICoplet</coplet-type>
+ <coplet-type>uri</coplet-type>
<attribute>
<name>uri</name>
<value xsi:type="java:java.lang.String">cocoon:/coplets/news/cnet_news.rss</value>
@@ -59,7 +59,7 @@
<coplet-definition id="CNETBusiness">
<title>CNET Business News</title>
- <coplet-type>URICoplet</coplet-type>
+ <coplet-type>uri</coplet-type>
<attribute>
<name>uri</name>
<value xsi:type="java:java.lang.String">cocoon:/coplets/news/cnet_business.rss</value>
@@ -68,7 +68,7 @@
<coplet-definition id="CSTNews">
<title>Chicago Sunday Times</title>
- <coplet-type>URICoplet</coplet-type>
+ <coplet-type>uri</coplet-type>
<attribute>
<name>uri</name>
<value xsi:type="java:java.lang.String">cocoon:/coplets/news/cst_news.rss</value>
@@ -77,7 +77,7 @@
<coplet-definition id="CNNEurope">
<title>CNN Europe</title>
- <coplet-type>URICoplet</coplet-type>
+ <coplet-type>uri</coplet-type>
<attribute>
<name>uri</name>
<value xsi:type="java:java.lang.String">cocoon:/coplets/news/cnn_europe.rss</value>
@@ -86,7 +86,7 @@
<coplet-definition id="Weblog">
<title>Another Weblog</title>
- <coplet-type>URICoplet</coplet-type>
+ <coplet-type>uri</coplet-type>
<attribute>
<name>uri</name>
<value xsi:type="java:java.lang.String">cocoon:/coplets/news/nn_weblog.weblog-rss</value>
@@ -100,7 +100,7 @@
-->
<coplet-definition id="CZWeblog">
<title>CZ's Weblog</title>
- <coplet-type>URICoplet</coplet-type>
+ <coplet-type>uri</coplet-type>
<attribute>
<name>uri</name>
<value xsi:type="java:java.lang.String">cocoon:/coplets/news/live.weblog-rss?feed=http://www.osoco.org/weblogs/rael/index.xml</value>
@@ -120,7 +120,7 @@
-->
<coplet-definition id="PortalIntro">
<title>Introduction</title>
- <coplet-type>URICoplet</coplet-type>
+ <coplet-type>uri</coplet-type>
<attribute>
<name>uri</name>
<value xsi:type="java:java.lang.String">cocoon:/coplets/docs/portal-intro.html</value>
@@ -132,7 +132,7 @@
</coplet-definition>
<coplet-definition id="PortalDemo">
<title>Introduction</title>
- <coplet-type>URICoplet</coplet-type>
+ <coplet-type>uri</coplet-type>
<attribute>
<name>uri</name>
<value xsi:type="java:java.lang.String">cocoon:/coplets/docs/portal-demo.html</value>
@@ -148,7 +148,7 @@
</coplet-definition>
<coplet-definition id="PortalRight">
<title>Right</title>
- <coplet-type>URICoplet</coplet-type>
+ <coplet-type>uri</coplet-type>
<attribute>
<name>uri</name>
<value xsi:type="java:java.lang.String">cocoon:/coplets/docs/portal-right.html</value>
@@ -160,7 +160,7 @@
</coplet-definition>
<coplet-definition id="PortalLeft">
<title>Left</title>
- <coplet-type>URICoplet</coplet-type>
+ <coplet-type>uri</coplet-type>
<attribute>
<name>uri</name>
<value xsi:type="java:java.lang.String">cocoon:/coplets/docs/portal-left.html</value>
@@ -172,7 +172,7 @@
</coplet-definition>
<coplet-definition id="PortalBottom">
<title>Bottom</title>
- <coplet-type>URICoplet</coplet-type>
+ <coplet-type>uri</coplet-type>
<attribute>
<name>uri</name>
<value xsi:type="java:java.lang.String">cocoon:/coplets/docs/portal-bottom.html</value>
@@ -184,7 +184,7 @@
</coplet-definition>
<coplet-definition id="static_sample">
<title>Static Information</title>
- <coplet-type>URICoplet</coplet-type>
+ <coplet-type>uri</coplet-type>
<attribute>
<name>uri</name>
<value xsi:type="java:java.lang.String">cocoon:/coplets/docs/static-info.html</value>
@@ -204,7 +204,7 @@
-->
<coplet-definition id="Gallery">
<title>Picture Gallery</title>
- <coplet-type>URICoplet</coplet-type>
+ <coplet-type>uri</coplet-type>
<attribute>
<name>buffer</name>
<value xsi:type="java:java.lang.Boolean">true</value>
@@ -236,7 +236,7 @@
</coplet-definition>
<coplet-definition id="GalleryViewer">
<title>Gallery Viewer</title>
- <coplet-type>URICoplet</coplet-type>
+ <coplet-type>uri</coplet-type>
<attribute>
<name>buffer</name>
<value xsi:type="java:java.lang.Boolean">true</value>
@@ -252,7 +252,7 @@
-->
<coplet-definition id="Login">
<title>Login</title>
- <coplet-type>URICoplet</coplet-type>
+ <coplet-type>uri</coplet-type>
<attribute>
<name>uri</name>
<value xsi:type="java:java.lang.String">cocoon:/coplets/login/coplet</value>
@@ -272,7 +272,7 @@
-->
<coplet-definition id="TestPortlet1">
<title>Portlet-Test</title>
- <coplet-type>Portlet</coplet-type>
+ <coplet-type>portlet</coplet-type>
<attribute>
<name>portlet</name>
<value xsi:type="java:java.lang.String">webapp.TestPortlet1</value>
@@ -284,7 +284,7 @@
</coplet-definition>
<coplet-definition id="CocoonPortlet">
<title>CocoonPortlet</title>
- <coplet-type>Portlet</coplet-type>
+ <coplet-type>portlet</coplet-type>
<attribute>
<name>portlet</name>
<value xsi:type="java:java.lang.String">webapp.CocoonPortlet</value>
@@ -302,7 +302,7 @@
-->
<coplet-definition id="app_test_one">
<title>Application Test</title>
- <coplet-type>URICoplet</coplet-type>
+ <coplet-type>uri</coplet-type>
<attribute>
<name>buffer</name>
<value xsi:type="java:java.lang.Boolean">true</value>
@@ -322,7 +322,7 @@
</coplet-definition>
<coplet-definition id="app_test_two">
<title>Application Test</title>
- <coplet-type>URICoplet</coplet-type>
+ <coplet-type>uri</coplet-type>
<attribute>
<name>buffer</name>
<value xsi:type="java:java.lang.Boolean">true</value>
@@ -344,7 +344,7 @@
<!-- Example for the application coplet -->
<coplet-definition id="Google">
<title>Application</title>
- <coplet-type>URICoplet</coplet-type>
+ <coplet-type>uri</coplet-type>
<attribute>
<name>uri</name>
<value xsi:type="java:java.lang.String">cocoon:/coplets/html/app-coplet</value>
@@ -358,7 +358,7 @@
<!-- Example for the wsrp portlet -->
<coplet-definition id="wsrp_calc_portlet">
<title>WSRP-Calc-Portlet</title>
- <coplet-type>WSRP</coplet-type>
+ <coplet-type>wsrp</coplet-type>
<attribute>
<name>producer-id</name>
<value xsi:type="java:java.lang.String">prod_localhost_8081</value>
@@ -371,7 +371,7 @@
<coplet-definition id="wsrp_test_portlet">
<title>WSRP-Test-Portlet</title>
- <coplet-type>WSRP</coplet-type>
+ <coplet-type>wsrp</coplet-type>
<attribute>
<name>producer-id</name>
<value xsi:type="java:java.lang.String">prod_localhost_8081</value>