cziegeler 2003/05/19 07:10:13
Modified:
src/blocks/portal/java/org/apache/cocoon/portal/event/subscriber/impl
DefaultLayoutEventSubscriber.java
src/blocks/portal/java/org/apache/cocoon/portal/event/impl
DefaultEventManager.java
src/blocks/portal/conf portal.xconf
src/blocks/portal/java/org/apache/cocoon/portal/layout/impl
DefaultLayoutAspectDescription.java
src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl
TabContentAspect.java
Added:
src/blocks/portal/java/org/apache/cocoon/portal/event/subscriber/impl
DefaultLayoutAspectDataEventSubscriber.java
src/blocks/portal/java/org/apache/cocoon/portal/event/impl
LayoutAspectDataEvent.java
Removed: src/blocks/portal/java/org/apache/cocoon/portal/layout/aspect
TabLayoutStatus.java
src/blocks/portal/java/org/apache/cocoon/portal/event/impl
LayoutEventImpl.java
Log:
Using layout factory for aspect data
Primitive data types as aspect data is possible as well
Revision Changes Path
1.4 +1 -26
cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/event/subscriber/impl/DefaultLayoutEventSubscriber.java
Index: DefaultLayoutEventSubscriber.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/event/subscriber/impl/DefaultLayoutEventSubscriber.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- DefaultLayoutEventSubscriber.java 19 May 2003 13:06:06 -0000 1.3
+++ DefaultLayoutEventSubscriber.java 19 May 2003 14:10:12 -0000 1.4
@@ -50,17 +50,13 @@
*/
package org.apache.cocoon.portal.event.subscriber.impl;
-import org.apache.avalon.framework.component.ComponentException;
import org.apache.avalon.framework.component.ComponentManager;
import org.apache.cocoon.portal.event.Event;
import org.apache.cocoon.portal.event.Filter;
import org.apache.cocoon.portal.event.LayoutEvent;
import org.apache.cocoon.portal.event.Subscriber;
import org.apache.cocoon.portal.event.impl.LayoutRemoveEvent;
-import org.apache.cocoon.portal.layout.CompositeLayout;
import org.apache.cocoon.portal.layout.Layout;
-import org.apache.cocoon.portal.layout.aspect.TabLayoutStatus;
-import org.apache.cocoon.portal.profile.ProfileManager;
/**
*
@@ -100,27 +96,6 @@
LayoutRemoveEvent removeEvent = (LayoutRemoveEvent)event;
Layout layout = (Layout)removeEvent.getTarget();
layout.getParent().getParent().removeItem(layout.getParent());
- } else {
- LayoutEvent statusEvent = (LayoutEvent)event;
- Layout layout = (Layout)statusEvent.getTarget();
- // TODO should not depend on special Layout
- if (layout instanceof CompositeLayout) {
- ProfileManager profileManager = null;
- try {
- profileManager = (ProfileManager)
this.componentManager.lookup(ProfileManager.ROLE);
- TabLayoutStatus status = (TabLayoutStatus)
profileManager.getAspectStatus(TabLayoutStatus.class,
ProfileManager.SESSION_STATUS, layout.getId());
- if ( status == null ) {
- // FIXME
- status = new TabLayoutStatus();
-
profileManager.setAspectStatus(ProfileManager.SESSION_STATUS, layout.getId(),
status);
- }
- status.setSelectedItem(statusEvent.getAction());
- } catch (ComponentException ce) {
- // ignore
- } finally {
- this.componentManager.release(profileManager);
- }
- }
}
}
1.1
cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/event/subscriber/impl/DefaultLayoutAspectDataEventSubscriber.java
Index: DefaultLayoutAspectDataEventSubscriber.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.event.subscriber.impl;
import org.apache.avalon.framework.component.ComponentManager;
import org.apache.cocoon.portal.event.Event;
import org.apache.cocoon.portal.event.Filter;
import org.apache.cocoon.portal.event.Subscriber;
import org.apache.cocoon.portal.event.impl.LayoutAspectDataEvent;
import org.apache.cocoon.portal.layout.Layout;
/**
*
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
*
* @version CVS $Id: DefaultLayoutAspectDataEventSubscriber.java,v 1.1
2003/05/19 14:10:12 cziegeler Exp $
*/
public final class DefaultLayoutAspectDataEventSubscriber
implements Subscriber {
private ComponentManager manager;
public DefaultLayoutAspectDataEventSubscriber(ComponentManager manager) {
this.manager = manager;
}
/* (non-Javadoc)
* @see org.apache.cocoon.portal.event.Subscriber#getEventType()
*/
public Class getEventType() {
return LayoutAspectDataEvent.class;
}
/* (non-Javadoc)
* @see org.apache.cocoon.portal.event.Subscriber#getFilter()
*/
public Filter getFilter() {
return null;
}
/* (non-Javadoc)
* @see
org.apache.cocoon.portal.event.Subscriber#inform(org.apache.cocoon.portal.event.Event)
*/
public void inform(Event e) {
final LayoutAspectDataEvent event = (LayoutAspectDataEvent)e;
final Layout layout = event.getTarget();
layout.setAspectData(event.getAspectName(), event.getData());
}
}
1.3 +3 -1
cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/event/impl/DefaultEventManager.java
Index: DefaultEventManager.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/event/impl/DefaultEventManager.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DefaultEventManager.java 7 May 2003 09:06:51 -0000 1.2
+++ DefaultEventManager.java 19 May 2003 14:10:12 -0000 1.3
@@ -78,6 +78,7 @@
import org.apache.cocoon.portal.event.aspect.EventAspect;
import org.apache.cocoon.portal.event.aspect.EventAspectChain;
import org.apache.cocoon.portal.event.aspect.impl.SizingEventSubscriber;
+import
org.apache.cocoon.portal.event.subscriber.impl.DefaultLayoutAspectDataEventSubscriber;
import
org.apache.cocoon.portal.event.subscriber.impl.DefaultLayoutEventSubscriber;
/**
@@ -146,6 +147,7 @@
// FIXME (CZ,HIGH) : Make this configurable
this.subscribe(new DefaultLayoutEventSubscriber(this.manager));
+ this.subscribe(new
DefaultLayoutAspectDataEventSubscriber(this.manager));
this.subscribe(new SizingEventSubscriber(this.manager));
}
1.1
cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/event/impl/LayoutAspectDataEvent.java
Index: LayoutAspectDataEvent.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.event.impl;
import org.apache.cocoon.portal.event.Event;
import org.apache.cocoon.portal.layout.Layout;
/**
* This events set the aspect data for a layout object
*
* @author <a href="mailto:[EMAIL PROTECTED]">Carsten Ziegeler</a>
*
* @version CVS $Id: LayoutAspectDataEvent.java,v 1.1 2003/05/19 14:10:12
cziegeler Exp $
*/
public final class LayoutAspectDataEvent
implements Event {
private Layout target;
private String aspectName;
private Object data;
public LayoutAspectDataEvent(Layout target, String aspectName, Object
data) {
this.target = target;
this.aspectName = aspectName;
this.data = data;
}
/**
* @return
*/
public String getAspectName() {
return aspectName;
}
/**
* @return
*/
public Object getData() {
return data;
}
/**
* @return
*/
public Layout getTarget() {
return target;
}
}
1.4 +3 -0 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.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- portal.xconf 19 May 2003 12:50:59 -0000 1.3
+++ portal.xconf 19 May 2003 14:10:12 -0000 1.4
@@ -137,6 +137,9 @@
<layout name="tab"
class="org.apache.cocoon.portal.layout.impl.TabLayout"
renderer="tab">
+ <aspects>
+ <aspect name="tab" class="java.lang.Integer"
persistence="session"/>
+ </aspects>
</layout>
<layout name="frame"
class="org.apache.cocoon.portal.layout.impl.FrameLayout"
1.2 +10 -2
cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/impl/DefaultLayoutAspectDescription.java
Index: DefaultLayoutAspectDescription.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/impl/DefaultLayoutAspectDescription.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DefaultLayoutAspectDescription.java 19 May 2003 12:50:58 -0000
1.1
+++ DefaultLayoutAspectDescription.java 19 May 2003 14:10:12 -0000
1.2
@@ -50,6 +50,8 @@
*/
package org.apache.cocoon.portal.layout.impl;
+import java.lang.reflect.Constructor;
+
import org.apache.cocoon.portal.layout.LayoutAspectDescription;
import org.apache.cocoon.util.ClassUtils;
@@ -119,7 +121,13 @@
public Object createNewInstance() {
// TODO - cache class
try {
- return ClassUtils.loadClass(this.className).newInstance();
+ Class clazz = ClassUtils.loadClass(this.className);
+ if ( this.className.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.4 +6 -8
cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/TabContentAspect.java
Index: TabContentAspect.java
===================================================================
RCS file:
/home/cvs/cocoon-2.1/src/blocks/portal/java/org/apache/cocoon/portal/layout/renderer/aspect/impl/TabContentAspect.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- TabContentAspect.java 19 May 2003 13:06:06 -0000 1.3
+++ TabContentAspect.java 19 May 2003 14:10:13 -0000 1.4
@@ -55,14 +55,12 @@
import org.apache.avalon.framework.component.ComponentException;
import org.apache.cocoon.portal.PortalService;
-import org.apache.cocoon.portal.event.impl.LayoutEventImpl;
+import org.apache.cocoon.portal.event.impl.LayoutAspectDataEvent;
import org.apache.cocoon.portal.layout.CompositeLayout;
import org.apache.cocoon.portal.layout.Layout;
import org.apache.cocoon.portal.layout.NamedItem;
-import org.apache.cocoon.portal.layout.aspect.TabLayoutStatus;
import org.apache.cocoon.portal.layout.impl.Parameter;
import org.apache.cocoon.portal.layout.renderer.aspect.RendererAspectContext;
-import org.apache.cocoon.portal.profile.ProfileManager;
import org.apache.cocoon.xml.AttributesImpl;
import org.apache.cocoon.xml.XMLUtils;
import org.xml.sax.ContentHandler;
@@ -101,9 +99,9 @@
CompositeLayout tabLayout = (CompositeLayout) layout;
// selected tab
- TabLayoutStatus status = (TabLayoutStatus) this.getStatus(
TabLayoutStatus.class, ProfileManager.SESSION_STATUS, tabLayout.getId() );
- int selected = (status == null ? 0 :
status.getSelectedItem());
-
+ Integer data = (Integer) layout.getAspectData("tab");
+ int selected = data.intValue();
+
// loop over all tabs
for (int j = 0; j < tabLayout.getSize(); j++) {
NamedItem tab = (NamedItem) tabLayout.getItem(j);
@@ -114,7 +112,7 @@
if (j == selected) {
attributes.addCDATAAttribute("selected", "true");
} else {
- LayoutEventImpl event = new
LayoutEventImpl(tabLayout, j);
+ LayoutAspectDataEvent event = new
LayoutAspectDataEvent(tabLayout, "tab", new Integer(j));
attributes.addCDATAAttribute("parameter",
portalService.getLinkService().getLinkURI(event));
}
XMLUtils.startElement(handler, "named-item", attributes);