cziegeler 2003/05/20 07:06:44
Modified: src/blocks/portal/java/org/apache/cocoon/portal/layout/impl
DefaultLayoutFactory.java
DefaultLayoutDescription.java
src/blocks/portal/samples/profiles/mapping layout.xml
src/blocks/portal/java/org/apache/cocoon/portal/layout
Layout.java AbstractLayout.java
LayoutDescription.java AbstractParameters.java
src/blocks/portal/java/org/apache/cocoon/portal/aspect/impl
AbstractAspectalizable.java
src/blocks/portal/conf portal.xconf
src/blocks/portal/java/org/apache/cocoon/portal/aspect
Aspectalizable.java AspectDataHandler.java
Added: src/blocks/portal/java/org/apache/cocoon/portal/factory/impl
AbstractProducibleDescription.java
AbstractProducible.java
src/blocks/portal/java/org/apache/cocoon/portal/aspect/impl
SessionAspectDataStore.java
AbstractAspectalizableDescription.java
DefaultAspectDataHandler.java
DefaultAspectDescription.java
RequestAspectDataStore.java AspectUtil.java
src/blocks/portal/java/org/apache/cocoon/portal/factory
ProducibleDescription.java Producible.java
src/blocks/portal/java/org/apache/cocoon/portal/aspect
AspectDescription.java
AspectalizableDescription.java AspectDataStore.java
Removed: src/blocks/portal/java/org/apache/cocoon/portal/layout/impl
DefaultLayoutAspectDescription.java
LayoutAspectDataHandler.java
src/blocks/portal/java/org/apache/cocoon/portal/layout
LayoutAspectDescription.java
Log:
Refactored aspect handling
Revision Changes Path
1.4 +41 -8
cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/impl/DefaultLayoutFactory.java
Index: DefaultLayoutFactory.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/impl/DefaultLayoutFactory.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DefaultLayoutFactory.java 19 May 2003 12:50:58 -0000 1.3
+++ DefaultLayoutFactory.java 20 May 2003 14:06:42 -0000 1.4
@@ -54,13 +54,22 @@
import java.util.Iterator;
import java.util.Map;
+import org.apache.avalon.framework.activity.Disposable;
import org.apache.avalon.framework.component.Component;
+import org.apache.avalon.framework.component.ComponentException;
+import org.apache.avalon.framework.component.ComponentManager;
+import org.apache.avalon.framework.component.ComponentSelector;
+import org.apache.avalon.framework.component.Composable;
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.logger.AbstractLogEnabled;
import org.apache.avalon.framework.thread.ThreadSafe;
import org.apache.cocoon.ProcessingException;
+import org.apache.cocoon.portal.aspect.AspectDataHandler;
+import org.apache.cocoon.portal.aspect.AspectDataStore;
+import org.apache.cocoon.portal.aspect.impl.DefaultAspectDataHandler;
+import org.apache.cocoon.portal.aspect.impl.DefaultAspectDescription;
import org.apache.cocoon.portal.layout.*;
import org.apache.cocoon.portal.layout.Item;
import org.apache.cocoon.portal.layout.Layout;
@@ -75,10 +84,14 @@
*/
public class DefaultLayoutFactory
extends AbstractLogEnabled
- implements ThreadSafe, Component, LayoutFactory, Configurable {
+ implements ThreadSafe, Component, LayoutFactory, Configurable,
Disposable, Composable {
protected Map layouts = new HashMap();
+ protected ComponentSelector storeSelector;
+
+ protected ComponentManager manager;
+
/* (non-Javadoc)
* @see
org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
*/
@@ -97,14 +110,15 @@
final Configuration[] aspectsConf =
layoutsConf[i].getChild("aspects").getChildren("aspect");
if (aspectsConf != null) {
for(int m=0; m < aspectsConf.length; m++) {
- DefaultLayoutAspectDescription adesc = new
DefaultLayoutAspectDescription();
+ DefaultAspectDescription adesc = new
DefaultAspectDescription();
adesc.setClassName(aspectsConf[m].getAttribute("class"));
adesc.setName(aspectsConf[m].getAttribute("name"));
-
adesc.setPersistence(aspectsConf[m].getAttribute("persistence"));
+
adesc.setPersistence(aspectsConf[m].getAttribute("store"));
+
adesc.setAutoCreate(aspectsConf[m].getAttributeAsBoolean("auto-create", false));
desc.addAspect( adesc );
}
}
- LayoutAspectDataHandler handler = new
LayoutAspectDataHandler(desc);
+ DefaultAspectDataHandler handler = new
DefaultAspectDataHandler(desc, this.storeSelector);
this.layouts.put(desc.getName(), new Object[] {desc,
handler});
}
}
@@ -125,9 +139,8 @@
}
DefaultLayoutDescription layoutDescription =
(DefaultLayoutDescription)o[0];
- // TODO do something here
- // we have to set the aspect data handler
- layout.setAspectDataHandler((LayoutAspectDataHandler)o[1]);
+ layout.setDescription( layoutDescription );
+ layout.setAspectDataHandler((AspectDataHandler)o[1]);
// recursive
if ( layout instanceof CompositeLayout ) {
@@ -138,6 +151,26 @@
}
}
}
+ }
+
+ /* (non-Javadoc)
+ * @see org.apache.avalon.framework.activity.Disposable#dispose()
+ */
+ public void dispose() {
+ if ( this.manager != null ) {
+ this.manager.release( this.storeSelector );
+ this.storeSelector = null;
+ this.manager = null;
+ }
+
+ }
+
+ /* (non-Javadoc)
+ * @see
org.apache.avalon.framework.component.Composable#compose(org.apache.avalon.framework.component.ComponentManager)
+ */
+ public void compose(ComponentManager manager) throws ComponentException {
+ this.manager = manager;
+ this.storeSelector = (ComponentSelector)this.manager.lookup(
AspectDataStore.ROLE+"Selector" );
}
}
1.2 +3 -89
cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/impl/DefaultLayoutDescription.java
Index: DefaultLayoutDescription.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/impl/DefaultLayoutDescription.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DefaultLayoutDescription.java 19 May 2003 12:50:58 -0000 1.1
+++ DefaultLayoutDescription.java 20 May 2003 14:06:42 -0000 1.2
@@ -50,11 +50,7 @@
*/
package org.apache.cocoon.portal.layout.impl;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-import org.apache.cocoon.portal.layout.LayoutAspectDescription;
+import org.apache.cocoon.portal.factory.impl.AbstractProducibleDescription;
import org.apache.cocoon.portal.layout.LayoutDescription;
@@ -66,93 +62,11 @@
* @version CVS $Id$
*/
public class DefaultLayoutDescription
+ extends AbstractProducibleDescription
implements LayoutDescription {
- protected String name;
-
- protected String className;
-
protected String rendererName;
- protected List aspects = new ArrayList();
-
- /**
- * toString
- * @return
- */
- public String toString() {
- StringBuffer buffer = new StringBuffer();
-
buffer.append("LayoutDescription(").append(super.toString()).append(")\n");
- buffer.append(" Name=").append(this.name).append('\n');
- buffer.append(" ClassName=").append(this.className).append('\n');
- buffer.append("
RendererName=").append(this.rendererName).append('\n');
- buffer.append(" Aspects=(\n");
- Iterator i = this.aspects.iterator();
- while ( i.hasNext() ) {
- DefaultLayoutAspectDescription d =
(DefaultLayoutAspectDescription)i.next();
- buffer.append("
Aspect(").append(d.toString()).append(")\n");
- buffer.append("
Name=").append(d.getName()).append('\n');
- buffer.append("
ClassName=").append(d.getClassName()).append('\n');
- buffer.append("
Persistence=").append(d.getPersistence()).append('\n');
- }
- buffer.append(" )\n");
- return buffer.toString();
- }
-
- /**
- * @return
- */
- public List getAspects() {
- return aspects;
- }
-
- public void addAspect(LayoutAspectDescription aspect) {
- this.aspects.add(aspect);
- }
-
- /**
- * Return the description for an aspect
- */
- public LayoutAspectDescription getAspect(String name) {
- LayoutAspectDescription desc = null;
- Iterator i = this.aspects.iterator();
- while (desc == null && i.hasNext() ) {
- LayoutAspectDescription current =
(LayoutAspectDescription)i.next();
- if ( name.equals(current.getName())) {
- desc = current;
- }
- }
- return desc;
- }
-
- /**
- * @return
- */
- public String getClassName() {
- return className;
- }
-
- /**
- * @return
- */
- public String getName() {
- return name;
- }
-
- /**
- * @param string
- */
- public void setClassName(String string) {
- className = string;
- }
-
- /**
- * @param string
- */
- public void setName(String string) {
- name = string;
- }
-
/**
* @return
*/
1.1
cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/factory/impl/AbstractProducibleDescription.java
Index: AbstractProducibleDescription.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.portal.factory.impl;
import org.apache.cocoon.portal.aspect.impl.AbstractAspectalizableDescription;
import org.apache.cocoon.portal.factory.ProducibleDescription;
/**
* This is a description of a [EMAIL PROTECTED] Producible} object.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
*
* @version CVS $Id: AbstractProducibleDescription.java,v 1.1 2003/05/20
14:06:42 cziegeler Exp $
*/
public abstract class AbstractProducibleDescription
extends AbstractAspectalizableDescription
implements ProducibleDescription {
protected String className;
protected String name;
/**
* @return
*/
public String getClassName() {
return className;
}
/**
* @return
*/
public String getName() {
return name;
}
/**
* @param string
*/
public void setClassName(String string) {
className = string;
}
/**
* @param string
*/
public void setName(String string) {
name = string;
}
}
1.1
cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/factory/impl/AbstractProducible.java
Index: AbstractProducible.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.portal.factory.impl;
import org.apache.cocoon.portal.aspect.impl.AbstractAspectalizable;
import org.apache.cocoon.portal.factory.Producible;
import org.apache.cocoon.portal.factory.ProducibleDescription;
/**
* This interface marks an object that can be created by a factory.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
*
* @version CVS $Id: AbstractProducible.java,v 1.1 2003/05/20 14:06:42
cziegeler Exp $
*/
public abstract class AbstractProducible
extends AbstractAspectalizable
implements Producible {
protected String name;
transient protected ProducibleDescription description;
/**
* @return
*/
public String getName() {
return name;
}
/**
* @param string
*/
public void setName(String string) {
name = string;
}
/**
* Set the layout description
*/
public void setDescription(ProducibleDescription description) {
this.description = description;
}
}
1.6 +13 -4
cocoon-2.1/src/blocks/portal/samples/profiles/mapping/layout.xml
Index: layout.xml
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/portal/samples/profiles/mapping/layout.xml,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- layout.xml 19 May 2003 13:16:34 -0000 1.5
+++ layout.xml 20 May 2003 14:06:42 -0000 1.6
@@ -2,7 +2,19 @@
<mapping>
<description>Portalprofile mapping file</description>
- <class name="org.apache.cocoon.portal.layout.AbstractParameters">
+
+ <class
name="org.apache.cocoon.portal.aspect.impl.AbstractAspectalizable">
+ </class>
+
+ <class name="org.apache.cocoon.portal.factory.impl.AbstractProducible"
+
extends="org.apache.cocoon.portal.aspect.impl.AbstractAspectalizable">
+ <field name="name" type="java.lang.String">
+ <bind-xml name="name" node="attribute" />
+ </field>
+ </class>
+
+ <class name="org.apache.cocoon.portal.layout.AbstractParameters"
+
extends="org.apache.cocoon.portal.factory.impl.AbstractProducible">
<field name="parameters"
type="org.apache.cocoon.portal.layout.impl.Parameter" collection="map">
<bind-xml auto-naming="deriveByClass" />
</field>
@@ -12,9 +24,6 @@
extends="org.apache.cocoon.portal.layout.AbstractParameters">
<field name="layoutRendererName" type="java.lang.String">
<bind-xml name="layout-renderer-name" node="attribute" />
- </field>
- <field name="name" type="java.lang.String">
- <bind-xml name="name" node="attribute" />
</field>
<field name="static" type="boolean">
<bind-xml name="static" node="attribute" />
1.5 +3 -11
cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/Layout.java
Index: Layout.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/Layout.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- Layout.java 19 May 2003 12:50:59 -0000 1.4
+++ Layout.java 20 May 2003 14:06:43 -0000 1.5
@@ -50,7 +50,7 @@
*/
package org.apache.cocoon.portal.layout;
-import org.apache.cocoon.portal.aspect.Aspectalizable;
+import org.apache.cocoon.portal.factory.Producible;
/**
@@ -61,7 +61,7 @@
* @version CVS $Id$
*/
public interface Layout
- extends Parameters, Aspectalizable {
+ extends Parameters, Producible {
/**
* Get the name of the [EMAIL PROTECTED] Renderer} to draw this layout.
@@ -83,14 +83,6 @@
*/
String getId();
- /**
- * Get the name of the layout.
- * This is the corresponding name of the configured layout
- * in the [EMAIL PROTECTED] LayoutFactory}.
- * @return String the configured layout name
- */
- String getName();
-
Item getParent();
void setParent(Item item);
1.6 +3 -44
cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/AbstractLayout.java
Index: AbstractLayout.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/AbstractLayout.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- AbstractLayout.java 19 May 2003 13:16:34 -0000 1.5
+++ AbstractLayout.java 20 May 2003 14:06:43 -0000 1.6
@@ -50,9 +50,6 @@
*/
package org.apache.cocoon.portal.layout;
-import java.util.List;
-
-import org.apache.cocoon.portal.aspect.AspectDataHandler;
/**
@@ -68,23 +65,18 @@
protected String rendererName;
- protected String name;
-
protected String id;
protected Item parent;
protected boolean _static;
- transient protected AspectDataHandler aspectDataHandler;
-
/**
* @see org.apache.cocoon.portal.layout.Layout#getRendererName()
*/
public String getRendererName() {
if ( this.rendererName == null ) {
- LayoutDescription desc =
(LayoutDescription)this.aspectDataHandler.getDescription();
- return desc.getRendererName();
+ return ((LayoutDescription)this.description).getRendererName();
}
return this.rendererName;
}
@@ -130,40 +122,7 @@
this._static = value;
}
-
- public Object getAspectData(String aspectName) {
- return this.aspectDataHandler.getAspectData(this, aspectName);
- }
-
- public void setAspectData(String aspectName, Object data) {
- this.aspectDataHandler.setAspectData(this, aspectName, data);
- }
-
- public List getAspectDatas() {
- return this.aspectDataHandler.getAspectDatas(this);
- }
-
- /**
- * This method is invoked once to set the handler
- */
- public void setAspectDataHandler(AspectDataHandler handler) {
- this.aspectDataHandler = handler;
- }
-
- /**
- * @return the name of the layout
- */
- public String getName() {
- return name;
- }
-
- /**
- * @param string the layout name
- */
- public void setName(String string) {
- name = string;
- }
-
+
/* (non-Javadoc)
* @see org.apache.cocoon.portal.layout.Layout#getLayoutRendererName()
*/
1.2 +4 -23
cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/LayoutDescription.java
Index: LayoutDescription.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/LayoutDescription.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- LayoutDescription.java 19 May 2003 12:50:59 -0000 1.1
+++ LayoutDescription.java 20 May 2003 14:06:43 -0000 1.2
@@ -50,7 +50,7 @@
*/
package org.apache.cocoon.portal.layout;
-import java.util.List;
+import org.apache.cocoon.portal.factory.ProducibleDescription;
@@ -61,27 +61,8 @@
*
* @version CVS $Id$
*/
-public interface LayoutDescription {
-
- /**
- * @return
- */
- List getAspects();
-
- /**
- * Return the description for an aspect
- */
- LayoutAspectDescription getAspect(String name);
-
- /**
- * @return
- */
- String getClassName();
-
- /**
- * @return
- */
- String getName();
+public interface LayoutDescription
+ extends ProducibleDescription {
/**
* @return
1.2 +5 -2
cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/AbstractParameters.java
Index: AbstractParameters.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/AbstractParameters.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AbstractParameters.java 7 May 2003 06:22:24 -0000 1.1
+++ AbstractParameters.java 20 May 2003 14:06:43 -0000 1.2
@@ -52,6 +52,7 @@
import java.util.Map;
+import org.apache.cocoon.portal.factory.impl.AbstractProducible;
import org.apache.commons.collections.SequencedHashMap;
/**
@@ -61,7 +62,9 @@
*
* @version CVS $Id$
*/
-public abstract class AbstractParameters implements Parameters {
+public abstract class AbstractParameters
+ extends AbstractProducible
+ implements Parameters {
protected Map parameters = new SequencedHashMap();
1.2 +31 -1
cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/aspect/impl/AbstractAspectalizable.java
Index: AbstractAspectalizable.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/aspect/impl/AbstractAspectalizable.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- AbstractAspectalizable.java 7 May 2003 06:22:30 -0000 1.1
+++ AbstractAspectalizable.java 20 May 2003 14:06:43 -0000 1.2
@@ -50,6 +50,9 @@
*/
package org.apache.cocoon.portal.aspect.impl;
+import java.util.List;
+
+import org.apache.cocoon.portal.aspect.AspectDataHandler;
import org.apache.cocoon.portal.aspect.Aspectalizable;
/**
@@ -62,5 +65,32 @@
public abstract class AbstractAspectalizable
implements Aspectalizable {
+ transient protected AspectDataHandler aspectDataHandler;
+
+ /**
+ * Is this aspect supported
+ */
+ public boolean isAspectSupported(String aspectName) {
+ return this.aspectDataHandler.isAspectSupported( aspectName );
+ }
+
+ public Object getAspectData(String aspectName) {
+ return this.aspectDataHandler.getAspectData(this, aspectName);
+ }
+
+ public void setAspectData(String aspectName, Object data) {
+ this.aspectDataHandler.setAspectData(this, aspectName, data);
+ }
+
+ public List getAspectDatas(){
+ return this.aspectDataHandler.getAspectDatas(this);
+ }
+
+ /**
+ * This method is invoked once to set the handler
+ */
+ public void setAspectDataHandler(AspectDataHandler handler) {
+ this.aspectDataHandler = handler;
+ }
}
1.1
cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/aspect/impl/SessionAspectDataStore.java
Index: SessionAspectDataStore.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.portal.aspect.impl;
import java.util.HashMap;
import java.util.Map;
import org.apache.avalon.framework.component.Component;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.thread.ThreadSafe;
import org.apache.cocoon.components.CocoonComponentManager;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.portal.aspect.AspectDataStore;
import org.apache.cocoon.portal.aspect.Aspectalizable;
/**
* An aspect data store is a component that manages aspect data objects.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
*
* @version CVS $Id: SessionAspectDataStore.java,v 1.1 2003/05/20 14:06:43
cziegeler Exp $
*/
public class SessionAspectDataStore
extends AbstractLogEnabled
implements Component, ThreadSafe, AspectDataStore {
protected Map getMap(Aspectalizable owner) {
final Map objectModel =
CocoonComponentManager.getCurrentEnvironment().getObjectModel();
final Request request = ObjectModelHelper.getRequest( objectModel );
Map componentMap =
(Map)request.getSession().getAttribute(this.getClass().getName());
if ( componentMap == null) {
componentMap = new HashMap(3);
request.getSession().setAttribute(this.getClass().getName(),
componentMap);
}
Map ownerMap = (Map)componentMap.get( owner );
if ( ownerMap == null ) {
ownerMap = new HashMap(3);
componentMap.put( owner, ownerMap );
}
return ownerMap;
}
public Object getAspectData(Aspectalizable owner, String aspectName) {
return this.getMap(owner).get( aspectName );
}
public void setAspectData(Aspectalizable owner, String aspectName, Object
data) {
this.getMap(owner).put(aspectName, data);
}
}
1.1
cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/aspect/impl/AbstractAspectalizableDescription.java
Index: AbstractAspectalizableDescription.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.portal.aspect.impl;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.apache.cocoon.portal.aspect.AspectDescription;
import org.apache.cocoon.portal.aspect.AspectalizableDescription;
/**
*
*
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
*
* @version CVS $Id: AbstractAspectalizableDescription.java,v 1.1 2003/05/20
14:06:43 cziegeler Exp $
*/
public abstract class AbstractAspectalizableDescription
implements AspectalizableDescription {
protected List aspects = new ArrayList();
/**
* @return
*/
public List getAspects() {
return this.aspects;
}
public void addAspect(AspectDescription aspect) {
this.aspects.add(aspect);
}
/**
* Return the description for an aspect
*/
public AspectDescription getAspect(String name) {
AspectDescription desc = null;
Iterator i = this.aspects.iterator();
while (desc == null && i.hasNext() ) {
AspectDescription current = (AspectDescription)i.next();
if ( name.equals(current.getName())) {
desc = current;
}
}
return desc;
}
}
1.1
cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/aspect/impl/DefaultAspectDataHandler.java
Index: DefaultAspectDataHandler.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2003 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.portal.aspect.impl;
import java.util.List;
import org.apache.avalon.framework.CascadingRuntimeException;
import org.apache.avalon.framework.component.Component;
import org.apache.avalon.framework.component.ComponentException;
import org.apache.avalon.framework.component.ComponentSelector;
import org.apache.cocoon.portal.aspect.AspectDataHandler;
import org.apache.cocoon.portal.aspect.AspectDataStore;
import org.apache.cocoon.portal.aspect.AspectDescription;
import org.apache.cocoon.portal.aspect.Aspectalizable;
import org.apache.cocoon.portal.aspect.AspectalizableDescription;
/**
*
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
*
* @version CVS $Id: DefaultAspectDataHandler.java,v 1.1 2003/05/20 14:06:43
cziegeler Exp $
*/
public class DefaultAspectDataHandler
implements AspectDataHandler {
protected AspectalizableDescription description;
// TODO - Implement persistence
protected ComponentSelector storeSelector;
/**
* Constructor
*/
public DefaultAspectDataHandler(AspectalizableDescription desc,
ComponentSelector storeSelector) {
this.description = desc;
this.storeSelector = storeSelector;
}
/* (non-Javadoc)
* @see
org.apache.cocoon.portal.aspect.AspectDataHandler#getAspectData(org.apache.cocoon.portal.aspect.Aspectalizable,
java.lang.String)
*/
public Object getAspectData(Aspectalizable owner, String aspectName) {
// is this aspect allowed?
AspectDescription aspectDesc = this.description.getAspect( aspectName
);
if ( aspectDesc == null ) return null;
// lookup storage
AspectDataStore store = null;
Object data = null;
try {
store =
(AspectDataStore)this.storeSelector.select(aspectDesc.getStoreName());
data = store.getAspectData(owner, aspectName);
if ( data == null && aspectDesc.isAutoCreate() ) {
data = AspectUtil.createNewInstance(aspectDesc);
store.setAspectData( owner, aspectName, data );
}
} catch (ComponentException ce) {
throw new CascadingRuntimeException("Unable to lookup aspect data
store " + aspectDesc.getStoreName(), ce);
} finally {
this.storeSelector.release( (Component)store );
}
return data;
}
/* (non-Javadoc)
* @see
org.apache.cocoon.portal.aspect.AspectDataHandler#getAspectDatas(org.apache.cocoon.portal.aspect.Aspectalizable)
*/
public List getAspectDatas(Aspectalizable owner) {
// TODO Auto-generated method stub
return null;
}
/* (non-Javadoc)
* @see
org.apache.cocoon.portal.aspect.AspectDataHandler#setAspectData(org.apache.cocoon.portal.aspect.Aspectalizable,
java.lang.String, java.lang.Object)
*/
public void setAspectData(Aspectalizable owner,
String aspectName,
Object data) {
// is this aspect allowed?
AspectDescription aspectDesc = this.description.getAspect( aspectName
);
if ( aspectDesc == null ) return;
// lookup storage
AspectDataStore store = null;
try {
store =
(AspectDataStore)this.storeSelector.select(aspectDesc.getStoreName());
store.setAspectData(owner, aspectName, data);
} catch (ComponentException ce) {
throw new CascadingRuntimeException("Unable to lookup aspect data
store " + aspectDesc.getStoreName(), ce);
} finally {
this.storeSelector.release( (Component)store );
}
}
/**
* Is this supported
*/
public boolean isAspectSupported(String aspectName) {
return (this.description.getAspect(aspectName) != null);
}
}
1.1
cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/aspect/impl/DefaultAspectDescription.java
Index: DefaultAspectDescription.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.portal.aspect.impl;
import org.apache.cocoon.portal.aspect.AspectDescription;
/**
* A configured aspect
*
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
*
* @version CVS $Id: DefaultAspectDescription.java,v 1.1 2003/05/20 14:06:43
cziegeler Exp $
*/
public class DefaultAspectDescription
implements AspectDescription {
protected String name;
protected String className;
protected String persistence;
protected boolean autoCreate;
/**
* @return
*/
public String getClassName() {
return className;
}
/**
* @return
*/
public String getName() {
return name;
}
/**
* @param string
*/
public void setClassName(String string) {
className = string;
}
/**
* @param string
*/
public void setName(String string) {
name = string;
}
/**
* @return
*/
public String getStoreName() {
return persistence;
}
/**
* @param string
*/
public void setPersistence(String string) {
persistence = string;
}
/**
* If the data is not available, create it automatically (or not)
*/
public boolean isAutoCreate() {
return autoCreate;
}
/**
* Set auto create
*/
public void setAutoCreate(boolean b) {
autoCreate = b;
}
}
1.1
cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/aspect/impl/RequestAspectDataStore.java
Index: RequestAspectDataStore.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.portal.aspect.impl;
import java.util.HashMap;
import java.util.Map;
import org.apache.avalon.framework.component.Component;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
import org.apache.avalon.framework.thread.ThreadSafe;
import org.apache.cocoon.components.CocoonComponentManager;
import org.apache.cocoon.environment.ObjectModelHelper;
import org.apache.cocoon.environment.Request;
import org.apache.cocoon.portal.aspect.AspectDataStore;
import org.apache.cocoon.portal.aspect.Aspectalizable;
/**
* An aspect data store is a component that manages aspect data objects.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
*
* @version CVS $Id: RequestAspectDataStore.java,v 1.1 2003/05/20 14:06:43
cziegeler Exp $
*/
public class RequestAspectDataStore
extends AbstractLogEnabled
implements Component, ThreadSafe, AspectDataStore {
protected Map getMap(Aspectalizable owner) {
final Map objectModel =
CocoonComponentManager.getCurrentEnvironment().getObjectModel();
final Request request = ObjectModelHelper.getRequest( objectModel );
Map componentMap =
(Map)request.getAttribute(this.getClass().getName());
if ( componentMap == null) {
componentMap = new HashMap(3);
request.setAttribute(this.getClass().getName(), componentMap);
}
Map ownerMap = (Map)componentMap.get( owner );
if ( ownerMap == null ) {
ownerMap = new HashMap(3);
componentMap.put( owner, ownerMap );
}
return ownerMap;
}
public Object getAspectData(Aspectalizable owner, String aspectName) {
return this.getMap(owner).get( aspectName );
}
public void setAspectData(Aspectalizable owner, String aspectName, Object
data) {
this.getMap(owner).put(aspectName, data);
}
}
1.1
cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/aspect/impl/AspectUtil.java
Index: AspectUtil.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.portal.aspect.impl;
import java.lang.reflect.Constructor;
import org.apache.cocoon.portal.aspect.AspectDescription;
import org.apache.cocoon.util.ClassUtils;
/**
* Utility class for aspects
*
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
*
* @version CVS $Id: AspectUtil.java,v 1.1 2003/05/20 14:06:43 cziegeler Exp $
*/
public class AspectUtil {
/**
* Create a new instance
*/
public static Object createNewInstance(AspectDescription desc) {
// TODO - cache class
try {
Class clazz = ClassUtils.loadClass(desc.getClassName());
if ( clazz.getName().startsWith("java.lang.")) {
Constructor constructor = clazz.getConstructor(new Class[]
{String.class});
return constructor.newInstance(new String[] {"0"});
} else {
return clazz.newInstance();
}
} catch (Exception ignore) {
return null;
}
}
}
1.1
cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/factory/ProducibleDescription.java
Index: ProducibleDescription.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.portal.factory;
import org.apache.cocoon.portal.aspect.AspectalizableDescription;
/**
* This is a description of a [EMAIL PROTECTED] Producible} object.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
*
* @version CVS $Id: ProducibleDescription.java,v 1.1 2003/05/20 14:06:43
cziegeler Exp $
*/
public interface ProducibleDescription
extends AspectalizableDescription {
/**
* @return
*/
String getClassName();
/**
* @return
*/
String getName();
}
1.1
cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/factory/Producible.java
Index: Producible.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.portal.factory;
import org.apache.cocoon.portal.aspect.Aspectalizable;
/**
* This interface marks an object that can be created by a factory.
*
* TODO - perhaps we should add an id here as well
*
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
*
* @version CVS $Id: Producible.java,v 1.1 2003/05/20 14:06:43 cziegeler Exp $
*/
public interface Producible
extends Aspectalizable {
/**
* The name given from the factory
*/
String getName();
/**
* Set the layout description
*/
void setDescription(ProducibleDescription description);
}
1.5 +9 -1 cocoon-2.1/src/blocks/portal/conf/portal.xconf
Index: portal.xconf
===================================================================
RCS file: /home/cvs/cocoon-2.1/src/blocks/portal/conf/portal.xconf,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- portal.xconf 19 May 2003 14:10:12 -0000 1.4
+++ portal.xconf 20 May 2003 14:06:43 -0000 1.5
@@ -122,6 +122,14 @@
<renderer name="link"
class="org.apache.cocoon.portal.layout.renderer.impl.DefaultLinkRenderer"
logger="portal"/>
</component>
+
+ <!-- Aspect Storage configuration -->
+ <component class="org.apache.cocoon.components.ExtendedComponentSelector"
+ role="org.apache.cocoon.portal.aspect.AspectDataStoreSelector">
+ <store name="request"
class="org.apache.cocoon.portal.aspect.impl.RequestAspectDataStore"/>
+ <store name="session"
class="org.apache.cocoon.portal.aspect.impl.SessionAspectDataStore"/>
+ </component>
+
<!-- Layout factory configuration -->
<component class="org.apache.cocoon.portal.layout.impl.DefaultLayoutFactory"
role="org.apache.cocoon.portal.layout.LayoutFactory">
@@ -138,7 +146,7 @@
class="org.apache.cocoon.portal.layout.impl.TabLayout"
renderer="tab">
<aspects>
- <aspect name="tab" class="java.lang.Integer"
persistence="session"/>
+ <aspect name="tab" class="java.lang.Integer" store="session"
auto-create="true"/>
</aspects>
</layout>
<layout name="frame"
1.4 +21 -3
cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/aspect/Aspectalizable.java
Index: Aspectalizable.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/aspect/Aspectalizable.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- Aspectalizable.java 7 May 2003 20:24:02 -0000 1.3
+++ Aspectalizable.java 20 May 2003 14:06:43 -0000 1.4
@@ -57,8 +57,6 @@
* This interface marks an object that can be used by aspects.
* An aspect can store any arbitrary information in an aspectalizable object.
*
- * TODO - check if this is ok
- *
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Volker Schmitt</a>
*
@@ -66,12 +64,32 @@
*/
public interface Aspectalizable {
+ /**
+ * Get the data associated with an aspect
+ * @param aspectName The aspect name
+ * @return The data or null if the aspect is not associated with this
object
+ */
Object getAspectData(String aspectName);
+ /**
+ * Set the data associated with an aspect
+ * The data is only set if the object is associated with the given aspect
+ * @param aspectName The aspect name
+ * @param data The data
+ */
void setAspectData(String aspectName, Object data);
+ /**
+ * Return all aspect datas
+ * @return A list of objects
+ */
List getAspectDatas();
+ /**
+ * Is this aspect supported
+ */
+ boolean isAspectSupported(String aspectName);
+
/**
* This method is invoked once to set the handler
*/
1.4 +2 -4
cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/aspect/AspectDataHandler.java
Index: AspectDataHandler.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/aspect/AspectDataHandler.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- AspectDataHandler.java 19 May 2003 13:16:33 -0000 1.3
+++ AspectDataHandler.java 20 May 2003 14:06:43 -0000 1.4
@@ -55,8 +55,6 @@
/**
* This interface is able to get a stored aspect
*
- * TODO - check if this is ok
- *
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
* @author <a href="mailto:[EMAIL PROTECTED]">Volker Schmitt</a>
*
@@ -70,6 +68,6 @@
List getAspectDatas(Aspectalizable owner);
- Object getDescription();
+ boolean isAspectSupported(String aspectName);
}
1.1
cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/aspect/AspectDescription.java
Index: AspectDescription.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.portal.aspect;
/**
* A configured aspect for an [EMAIL PROTECTED] Aspectalizable} object
*
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
*
* @version CVS $Id: AspectDescription.java,v 1.1 2003/05/20 14:06:43
cziegeler Exp $
*/
public interface AspectDescription {
/**
* @return The class name of the data
*/
String getClassName();
/**
* @return The name of the aspect
*/
String getName();
/**
* @return The name (role) of the store to store the data
*/
String getStoreName();
/**
* If the data is not available, create it automatically (or not)
*/
boolean isAutoCreate();
}
1.1
cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/aspect/AspectalizableDescription.java
Index: AspectalizableDescription.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.portal.aspect;
import java.util.List;
/**
* This is a description of an [EMAIL PROTECTED] Aspectalizable} object.
* An aspectalizable object can have a number of aspects.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
*
* @version CVS $Id: AspectalizableDescription.java,v 1.1 2003/05/20 14:06:43
cziegeler Exp $
*/
public interface AspectalizableDescription {
/**
* @return All [EMAIL PROTECTED] AspectDescription}s
*/
List getAspects();
/**
* Return the description for an aspect
*/
AspectDescription getAspect(String name);
}
1.1
cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/aspect/AspectDataStore.java
Index: AspectDataStore.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Apache Cocoon" and "Apache Software Foundation" must not be
used to endorse or promote products derived from this software without
prior written permission. For written permission, please contact
[EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation and was originally created by
Stefano Mazzocchi <[EMAIL PROTECTED]>. For more information on the Apache
Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.cocoon.portal.aspect;
/**
* An aspect data store is a component that manages aspect data objects.
* For example, one implementation stores them temporary for the current
* request, another one in the session and a third one persistent.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
*
* @version CVS $Id: AspectDataStore.java,v 1.1 2003/05/20 14:06:43 cziegeler
Exp $
*/
public interface AspectDataStore {
String ROLE = AspectDataStore.class.getName();
Object getAspectData(Aspectalizable owner, String aspectName);
void setAspectData(Aspectalizable owner, String aspectName, Object data);
}