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 2004/11/18 16:18:59 UTC
svn commit: r76243 - in cocoon/trunk/src: blocks/portal/java/org/apache/cocoon/portal/acting blocks/portal/java/org/apache/cocoon/portal/acting/helpers core/java/org/apache/cocoon/components core/java/org/apache/cocoon/core/container core/test/org/apache/cocoon/core/container
Author: cziegeler
Date: Thu Nov 18 07:18:58 2004
New Revision: 76243
Added:
cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/acting/helpers/FullScreenMapping.java
Modified:
cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/acting/BookmarkAction.java
cocoon/trunk/src/core/java/org/apache/cocoon/components/ServiceInfo.java
cocoon/trunk/src/core/java/org/apache/cocoon/core/container/AbstractComponentHandler.java
cocoon/trunk/src/core/java/org/apache/cocoon/core/container/CocoonServiceManager.java
cocoon/trunk/src/core/java/org/apache/cocoon/core/container/CocoonServiceSelector.java
cocoon/trunk/src/core/java/org/apache/cocoon/core/container/RoleManager.java
cocoon/trunk/src/core/test/org/apache/cocoon/core/container/RoleManagerTestCase.java
Log:
Start using service info
Add fullscreen support to bookmark
Modified: cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/acting/BookmarkAction.java
==============================================================================
--- cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/acting/BookmarkAction.java (original)
+++ cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/acting/BookmarkAction.java Thu Nov 18 07:18:58 2004
@@ -42,6 +42,7 @@
import org.apache.cocoon.portal.PortalManager;
import org.apache.cocoon.portal.PortalService;
import org.apache.cocoon.portal.acting.helpers.CopletMapping;
+import org.apache.cocoon.portal.acting.helpers.FullScreenMapping;
import org.apache.cocoon.portal.acting.helpers.LayoutMapping;
import org.apache.cocoon.portal.acting.helpers.Mapping;
import org.apache.excalibur.source.Source;
@@ -58,6 +59,10 @@
* <targettype>layout|coplet</targettype>
* <path/>
* </event>
+ * <event type="fullscreen" id="ID">
+ * <targetid>copletId</targetid>
+ * <layoutid>layoutId</layoutid>
+ * </event>
* </events>
* </bookmarks>
*
@@ -110,27 +115,38 @@
try {
final String type = events[i].getAttribute("type");
final String id = events[i].getAttribute("id");
- if ( !"jxpath".equals(type) ) {
- throw new ParameterException("Unknown event type for event " + id + ": " + type);
- }
- if ( this.eventMap.containsKey(id)) {
- throw new ParameterException("The id for the event " + id + " is not unique.");
- }
- final String targetType = events[i].getChild("targettype").getValue();
- final String targetId = events[i].getChild("targetid").getValue();
- final String path = events[i].getChild("path").getValue();
- if ( "layout".equals(targetType) ) {
- LayoutMapping mapping = new LayoutMapping();
- mapping.layoutId = targetId;
- mapping.path = path;
- this.eventMap.put(id, mapping);
- } else if ( "coplet".equals(targetType) ) {
- CopletMapping mapping = new CopletMapping();
+ if ( "jxpath".equals(type) ) {
+ if ( this.eventMap.containsKey(id)) {
+ throw new ParameterException("The id for the event " + id + " is not unique.");
+ }
+ final String targetType = events[i].getChild("targettype").getValue();
+ final String targetId = events[i].getChild("targetid").getValue();
+ final String path = events[i].getChild("path").getValue();
+ if ( "layout".equals(targetType) ) {
+ LayoutMapping mapping = new LayoutMapping();
+ mapping.layoutId = targetId;
+ mapping.path = path;
+ this.eventMap.put(id, mapping);
+ } else if ( "coplet".equals(targetType) ) {
+ CopletMapping mapping = new CopletMapping();
+ mapping.copletId = targetId;
+ mapping.path = path;
+ this.eventMap.put(id, mapping);
+ } else {
+ throw new ParameterException("Unknown target type " + targetType);
+ }
+ } else if ( "fullscreen".equals(type) ) {
+ if ( this.eventMap.containsKey(id)) {
+ throw new ParameterException("The id for the event " + id + " is not unique.");
+ }
+ final String targetId = events[i].getChild("targetid").getValue();
+ final String layoutId = events[i].getChild("layoutid").getValue();
+ FullScreenMapping mapping = new FullScreenMapping();
mapping.copletId = targetId;
- mapping.path = path;
- this.eventMap.put(id, mapping);
+ mapping.layoutId = layoutId;
+ this.eventMap.put(id, mapping);
} else {
- throw new ParameterException("Unknown target type " + targetType);
+ throw new ParameterException("Unknown event type for event " + id + ": " + type);
}
} catch (ConfigurationException ce) {
throw new ParameterException("Configuration exception" ,ce);
Added: cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/acting/helpers/FullScreenMapping.java
==============================================================================
--- (empty file)
+++ cocoon/trunk/src/blocks/portal/java/org/apache/cocoon/portal/acting/helpers/FullScreenMapping.java Thu Nov 18 07:18:58 2004
@@ -0,0 +1,44 @@
+/*
+ * Copyright 1999-2004 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.cocoon.portal.acting.helpers;
+
+import org.apache.cocoon.portal.PortalService;
+import org.apache.cocoon.portal.coplet.CopletInstanceData;
+import org.apache.cocoon.portal.event.Event;
+import org.apache.cocoon.portal.event.impl.FullScreenCopletEvent;
+import org.apache.cocoon.portal.layout.Layout;
+import org.apache.cocoon.portal.profile.ProfileManager;
+
+/**
+ * Helper class for a full screen event
+ *
+ * @author <a href="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
+ * @version CVS $Id: CopletMapping.java 30941 2004-07-29 19:56:58Z vgritsenko $
+*/
+public class FullScreenMapping extends Mapping {
+ public String copletId;
+ public String layoutId;
+
+ public Event getEvent(PortalService service, Object data) {
+ final ProfileManager manager = service.getComponentManager().getProfileManager();
+ final CopletInstanceData cid = manager.getCopletInstanceData(this.copletId);
+ final Layout layout = manager.getPortalLayout(null, layoutId) ;
+
+ Event e = new FullScreenCopletEvent(cid, layout);
+ return e;
+ }
+
+}
Modified: cocoon/trunk/src/core/java/org/apache/cocoon/components/ServiceInfo.java
==============================================================================
--- cocoon/trunk/src/core/java/org/apache/cocoon/components/ServiceInfo.java (original)
+++ cocoon/trunk/src/core/java/org/apache/cocoon/components/ServiceInfo.java Thu Nov 18 07:18:58 2004
@@ -36,6 +36,7 @@
private String poolInMethodName;
private String poolOutMethodName;
private Class serviceClass;
+ private String serviceClassName;
private Method initMethod;
private Method destroyMethod;
private Method poolInMethod;
@@ -164,6 +165,20 @@
}
/**
+ * @return Returns the serviceClassName.
+ */
+ public String getServiceClassName() {
+ return serviceClassName;
+ }
+
+ /**
+ * @param serviceClassName The serviceClassName to set.
+ */
+ public void setServiceClassName(String serviceClassName) {
+ this.serviceClassName = serviceClassName;
+ }
+
+ /**
* @param serviceClass The serviceClass to set.
*/
public void setServiceClass(Class serviceClass) {
@@ -181,5 +196,27 @@
*/
public void setConfiguration(Configuration configuration) {
this.configuration = configuration;
+ }
+
+
+ /* (non-Javadoc)
+ * @see java.lang.Object#toString()
+ */
+ public String toString() {
+ return "ServiceInfo: {class=" + this.getServiceClassName()+"}";
+ }
+
+ public void fill(Configuration attr) {
+ // test model
+ final String model = attr.getAttribute("model", null);
+ if ( "pooled".equals(model) ) {
+ this.setModel(ServiceInfo.MODEL_POOLED);
+ this.setPoolInMethodName(attr.getAttribute("pool-in", null));
+ this.setPoolOutMethodName(attr.getAttribute("pool-out", null));
+ } else if ( "singleton".equals(model) ) {
+ this.setModel(ServiceInfo.MODEL_SINGLETON);
+ }
+ this.setInitMethodName(attr.getAttribute("init", null));
+ this.setDestroyMethodName(attr.getAttribute("destroy", null));
}
}
Modified: cocoon/trunk/src/core/java/org/apache/cocoon/core/container/AbstractComponentHandler.java
==============================================================================
--- cocoon/trunk/src/core/java/org/apache/cocoon/core/container/AbstractComponentHandler.java (original)
+++ cocoon/trunk/src/core/java/org/apache/cocoon/core/container/AbstractComponentHandler.java Thu Nov 18 07:18:58 2004
@@ -75,6 +75,7 @@
final ServiceInfo info = new ServiceInfo();
info.setServiceClass(componentClass);
+ info.setServiceClassName(componentClass.getName());
info.setConfiguration(configuration);
// Early check for Composable
@@ -105,13 +106,8 @@
}
if ( numInterfaces == 0 ) {
- // test configuration
- final String model = configuration.getAttribute("model", null);
- if ( "pooled".equals(model) ) {
- info.setModel(ServiceInfo.MODEL_POOLED);
- } else if ( "singleton".equals(model) ) {
- info.setModel(ServiceInfo.MODEL_SINGLETON);
- }
+ // this component does not use avalon interfaces, so get the info from the configuration
+ info.fill(configuration);
}
// Create the factory to use to create the instances of the Component.
Modified: cocoon/trunk/src/core/java/org/apache/cocoon/core/container/CocoonServiceManager.java
==============================================================================
--- cocoon/trunk/src/core/java/org/apache/cocoon/core/container/CocoonServiceManager.java (original)
+++ cocoon/trunk/src/core/java/org/apache/cocoon/core/container/CocoonServiceManager.java Thu Nov 18 07:18:58 2004
@@ -27,6 +27,7 @@
import org.apache.avalon.framework.context.Context;
import org.apache.avalon.framework.service.ServiceException;
import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.cocoon.components.ServiceInfo;
/**
* Default service manager for Cocoon's components.
@@ -103,16 +104,16 @@
}
if( this.roleManager != null ) {
- final String className = this.roleManager.getDefaultClassNameForRole( role );
+ final ServiceInfo info = this.roleManager.getDefaultServiceInfoForRole( role );
- if( className != null ) {
+ if( info != null ) {
if( this.getLogger().isDebugEnabled() ) {
this.getLogger().debug( "Could not find ComponentHandler, attempting to create "
+ "one for role [" + role + "]" );
}
try {
- final Class componentClass = this.loader.loadClass( className );
+ final Class componentClass = this.loader.loadClass( info.getServiceClassName() );
final Configuration configuration = new DefaultConfiguration( "", "-" );
@@ -288,7 +289,8 @@
if( null != role && !role.equals( "" ) ) {
if( className.equals( "" ) ) {
- className = roleManager.getDefaultClassNameForRole( role );
+ final ServiceInfo info = roleManager.getDefaultServiceInfoForRole( role );
+ className = info.getServiceClassName();
}
this.addComponent(className, role, configurations[i]);
Modified: cocoon/trunk/src/core/java/org/apache/cocoon/core/container/CocoonServiceSelector.java
==============================================================================
--- cocoon/trunk/src/core/java/org/apache/cocoon/core/container/CocoonServiceSelector.java (original)
+++ cocoon/trunk/src/core/java/org/apache/cocoon/core/container/CocoonServiceSelector.java Thu Nov 18 07:18:58 2004
@@ -27,6 +27,7 @@
import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.ServiceSelector;
import org.apache.avalon.framework.service.Serviceable;
+import org.apache.cocoon.components.ServiceInfo;
/**
* Default component selector for Cocoon's components.
@@ -243,7 +244,8 @@
if (compInstanceName == null) {
// component-instance implicitly defined by the presence of the 'class' attribute
if (classAttr == null) {
- className = this.roleManager.getDefaultClassNameForKey(roleName, instance.getName());
+ final ServiceInfo info = this.roleManager.getDefaultServiceInfoForKey(roleName, instance.getName());
+ className = info.getServiceClassName();
} else {
className = classAttr.trim();
}
@@ -253,7 +255,8 @@
if (compInstanceName.equals(instance.getName())) {
className = (classAttr == null) ? null : classAttr.trim();
} else {
- className = this.roleManager.getDefaultClassNameForKey(roleName, instance.getName());
+ final ServiceInfo info = this.roleManager.getDefaultServiceInfoForKey(roleName, instance.getName());
+ className = info.getServiceClassName();
}
}
Modified: cocoon/trunk/src/core/java/org/apache/cocoon/core/container/RoleManager.java
==============================================================================
--- cocoon/trunk/src/core/java/org/apache/cocoon/core/container/RoleManager.java (original)
+++ cocoon/trunk/src/core/java/org/apache/cocoon/core/container/RoleManager.java Thu Nov 18 07:18:58 2004
@@ -24,6 +24,7 @@
import org.apache.avalon.framework.configuration.Configuration;
import org.apache.avalon.framework.configuration.ConfigurationException;
import org.apache.avalon.framework.logger.AbstractLogEnabled;
+import org.apache.cocoon.components.ServiceInfo;
/**
* Default RoleManager implementation. It populates the RoleManager
@@ -98,14 +99,14 @@
* @param role The role that has a default implementation.
* @return the Fully Qualified Class Name (FQCN) for the role.
*/
- public final String getDefaultClassNameForRole( final String role ) {
- final String className = (String)this.classNames.get( role );
+ public final ServiceInfo getDefaultServiceInfoForRole( final String role ) {
+ final ServiceInfo info = (ServiceInfo)this.classNames.get( role );
- if( null == className && null != this.parent ) {
- return this.parent.getDefaultClassNameForRole( role );
+ if( info == null && this.parent != null ) {
+ return this.parent.getDefaultServiceInfoForRole( role );
}
- return className;
+ return info;
}
/**
@@ -120,8 +121,8 @@
* @param shorthand The shorthand name for the type of component
* @return the FQCN for the role/key combination.
*/
- public final String getDefaultClassNameForKey( final String role,
- final String shorthand ) {
+ public final ServiceInfo getDefaultServiceInfoForKey( final String role,
+ final String shorthand ) {
if( this.getLogger().isDebugEnabled() ) {
this.getLogger().debug( "looking up keymap for role " + role );
}
@@ -130,19 +131,19 @@
if( null == keyMap ) {
if( null != this.parent ) {
- return this.parent.getDefaultClassNameForKey( role, shorthand );
+ return this.parent.getDefaultServiceInfoForKey( role, shorthand );
}
- return "";
+ return null;
}
if( this.getLogger().isDebugEnabled() ) {
this.getLogger().debug( "looking up classname for key " + shorthand );
}
- final String s = ( String ) keyMap.get( shorthand );
+ final ServiceInfo s = ( ServiceInfo ) keyMap.get( shorthand );
- if( s == null && null != this.parent ) {
- return this.parent.getDefaultClassNameForKey( role, shorthand );
+ if( s == null && this.parent != null ) {
+ return this.parent.getDefaultServiceInfoForKey( role, shorthand );
}
return s;
}
@@ -169,8 +170,11 @@
shorts.put( shorthand, name );
- if( null != defaultClassName ) {
- classes.put( name, defaultClassName );
+ if( defaultClassName != null ) {
+ final ServiceInfo info = new ServiceInfo();
+ info.setServiceClassName(defaultClassName);
+ info.fill(roles[ i ]);
+ classes.put( name, info );
}
final Configuration[] keys = roles[ i ].getChildren( "hint" );
@@ -179,9 +183,13 @@
for( int j = 0; j < keys.length; j++ ) {
final String shortHand = keys[ j ].getAttribute( "shorthand" ).trim();
- String className = keys[ j ].getAttribute( "class" ).trim();
+ final String className = keys[ j ].getAttribute( "class" ).trim();
- keyMap.put( shortHand, className );
+ final ServiceInfo info = new ServiceInfo();
+ info.setServiceClassName(className);
+ info.fill(keys[ j ]);
+
+ keyMap.put( shortHand, info );
if( this.getLogger().isDebugEnabled() ) {
this.getLogger().debug( "Adding key type " + shortHand +
" associated with role " + name +
Modified: cocoon/trunk/src/core/test/org/apache/cocoon/core/container/RoleManagerTestCase.java
==============================================================================
--- cocoon/trunk/src/core/test/org/apache/cocoon/core/container/RoleManagerTestCase.java (original)
+++ cocoon/trunk/src/core/test/org/apache/cocoon/core/container/RoleManagerTestCase.java Thu Nov 18 07:18:58 2004
@@ -38,12 +38,6 @@
super(name);
}
- /*
- * @see TestCase#setUp()
- */
- protected void setUp() throws Exception {
- }
-
public void testConfigureWithoutHints() throws ConfigurationException {
Mock conf = new Mock(Configuration.class);
Mock child0 = new Mock(Configuration.class);
@@ -68,8 +62,8 @@
conf.verify();
child0.verify();
assertEquals("Role name for shorthand incorrect", "testName", rm.getRoleForName("testShorthand"));
- assertEquals("Default class for role incorrect", "testClass", rm.getDefaultClassNameForRole("testName"));
- assertEquals("Default class for key must be empty", "", rm.getDefaultClassNameForKey("testName", "testShorthand"));
+ assertEquals("Default service info for role incorrect", "testClass", rm.getDefaultServiceInfoForRole("testName"));
+ assertNull("Default service info for key must be null", rm.getDefaultServiceInfoForKey("testName", "testShorthand"));
}
}