cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r506488 - in /cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main: java/org/apache/cocoon/portal/event/impl/ java/org/apache/cocoon/portal/services/ java/org/apache/cocoon/portal/services/impl/ resources/org/apache/cocoon/portal/
Date Mon, 12 Feb 2007 15:32:53 GMT
Author: cziegeler
Date: Mon Feb 12 07:32:52 2007
New Revision: 506488

URL: http://svn.apache.org/viewvc?view=rev&rev=506488
Log:
Convert the link service from avalon to spring bean

Modified:
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/event/impl/DefaultEventConverter.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/LinkService.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultLinkService.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/PageLabelLinkService.java
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/cocoon-portal-components.xml
    cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/portal.roles

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/event/impl/DefaultEventConverter.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/event/impl/DefaultEventConverter.java?view=diff&rev=506488&r1=506487&r2=506488
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/event/impl/DefaultEventConverter.java
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/event/impl/DefaultEventConverter.java
Mon Feb 12 07:32:52 2007
@@ -39,9 +39,6 @@
  * the current user session. Each event is then converted to a string just containing
  * the index of the event in this list. This list is cleared when the session is closed.
  *
- * In addition, this component can be configured with additional event converters
- * that convert a specific event.
- *
  * TODO - What happens if two event classes have the same hash?
  *
  * @version $Id$
@@ -63,9 +60,6 @@
      */
     protected Map factories = new HashMap();
 
-    /** All configured event converters. */
-    protected Map converters = new HashMap();
-
     /** The configured mappings. */
     protected Map mappings;
 
@@ -95,57 +89,6 @@
         }
     }
 
-    /**
-     * @see org.apache.avalon.framework.configuration.Configurable#configure(org.apache.avalon.framework.configuration.Configuration)
-    public void configure(Configuration config) throws ConfigurationException {
-        Configuration[] mappings = config.getChild("mappings").getChildren("mapping");
-        for( int i=0; i<mappings.length; i++) {
-            final Configuration current = mappings[i];
-            final String key = current.getAttribute("name");
-            final String eventClass = current.getAttribute("event-class");
-            final Constructor c = this.getConstructor(eventClass);
-            final long hash = HashUtil.hash(eventClass);
-            final String hashKey = Long.toString(hash);
-            this.factories.put(hashKey, key);
-            this.factories.put(key, c);
-        }
-        Configuration[] helpers = config.getChild("converters").getChildren("converter");
-        for( int i=0; i<helpers.length; i++) {
-            final Configuration current = helpers[i];
-            final String role = current.getAttribute("role");
-            final String eventClass = current.getAttribute("event-class");
-            final String name = current.getAttribute("name", null);
-            try {
-                final EventConverter converter = (EventConverter)this.manager.lookup(role);
-                final long hash = HashUtil.hash(eventClass);
-                final String hashKey = Long.toString(hash);
-                if ( name != null ) {
-                    this.factories.put(name, converter);
-                    this.factories.put(hashKey, name);                    
-                } else {
-                    this.factories.put(hashKey, converter);                    
-                }
-                this.converters.put(eventClass, converter);
-            } catch (ServiceException e) {
-                throw new ConfigurationException("Unable to lookup event converter: " + role,
e);
-            }
-        }
-    }
-    */
-
-    /**
-     * @see org.apache.cocoon.portal.impl.AbstractComponent#dispose()
-    public void dispose() {
-        if ( this.manager != null ) {
-            final Iterator i = this.converters.values().iterator();
-            while ( i.hasNext() ) {
-                this.manager.release(i.next());
-            }
-        }
-        super.dispose();
-    }
-     */
-
     protected Constructor getConstructor(String factory) {
         try {
             final Class factoryClass = ClassUtils.loadClass(factory);
@@ -163,11 +106,6 @@
     public String encode(Event event) {
         final String eventClassName = event.getClass().getName();
         String data = null;
-        // first check if we have a converter registered for this event
-        EventConverter registeredConverter = (EventConverter)this.converters.get(eventClassName);
-        if ( registeredConverter != null ) {
-            data = registeredConverter.encode(event);
-        }
         // if this is a convertable event just return
         // the used factory and the data.
         if ( data == null && event instanceof ConvertableEvent ) {

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/LinkService.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/LinkService.java?view=diff&rev=506488&r1=506487&r2=506488
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/LinkService.java
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/LinkService.java
Mon Feb 12 07:32:52 2007
@@ -125,15 +125,6 @@
     String encodeURL(String url);
 
     /**
-     * A list of parameters that should be filtered when
-     * coplets are called. The list might consist of either
-     * a parameter name (string) or a prefix (string). A prefix
-     * ends with a '*'.
-     * @return A list of strings. This method always returns a list.
-     */
-    List getInternalParameterNames();
-
-    /**
      * Test if the parameter is an internal one.
      */
     boolean isInternalParameterName(String name);

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultLinkService.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultLinkService.java?view=diff&rev=506488&r1=506487&r2=506488
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultLinkService.java
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/DefaultLinkService.java
Mon Feb 12 07:32:52 2007
@@ -22,15 +22,12 @@
 import java.util.List;
 import java.util.StringTokenizer;
 
-import org.apache.avalon.framework.parameters.ParameterException;
-import org.apache.avalon.framework.parameters.Parameterizable;
-import org.apache.avalon.framework.parameters.Parameters;
 import org.apache.cocoon.environment.ObjectModelHelper;
 import org.apache.cocoon.environment.Request;
 import org.apache.cocoon.environment.Response;
 import org.apache.cocoon.portal.event.ComparableEvent;
 import org.apache.cocoon.portal.event.Event;
-import org.apache.cocoon.portal.impl.AbstractComponent;
+import org.apache.cocoon.portal.impl.AbstractBean;
 import org.apache.cocoon.portal.services.LinkService;
 import org.apache.cocoon.util.NetUtils;
 
@@ -39,9 +36,8 @@
  * @version $Id$
  */
 public class DefaultLinkService 
-    extends AbstractComponent
-    implements LinkService,
-               Parameterizable {
+    extends AbstractBean
+    implements LinkService {
 
     /** Default port used for http. */
     protected int defaultPort = 80;
@@ -49,28 +45,34 @@
     /** Default port used for https. */
     protected int defaultSecurePort = 443;
 
-    /** List of internal parameters. */
-    protected List internalParameters = new ArrayList();
-
     /** List of matchers for internal parameters. */
     protected List internalParametersMatchers = new ArrayList();
 
-    /**
-     * @see org.apache.avalon.framework.parameters.Parameterizable#parameterize(org.apache.avalon.framework.parameters.Parameters)
-     */
-    public void parameterize(Parameters params) throws ParameterException {
-        this.defaultPort = params.getParameterAsInteger("defaultPort", this.defaultPort);
-        this.defaultSecurePort = params.getParameterAsInteger("defaultSecurePort", this.defaultSecurePort);
-        final String internalParams = params.getParameter("internalParameters", "cocoon-*");
-        final StringTokenizer st = new StringTokenizer(internalParams, ",");
-        while ( st.hasMoreTokens() ) {
-            final String parameter = st.nextToken();
-            this.internalParameters.add(parameter);
-            if ( parameter.endsWith("*") ) {
-                this.internalParametersMatchers.add(new PrefixParameterMatcher(parameter));
-            } else {
-                this.internalParametersMatchers.add(new ConstantParameterMatcher(parameter));
-            }
+    public DefaultLinkService() {
+        this.setInternalParameters("cocoon-*");
+    }
+
+    public void setDefaultPort(int defaultPort) {
+        this.defaultPort = defaultPort;
+    }
+
+    public void setDefaultSecurePort(int defaultSecurePort) {
+        this.defaultSecurePort = defaultSecurePort;
+    }
+
+    public void setInternalParameters(String internalParams) {
+        if ( internalParams == null ) {
+            this.internalParametersMatchers.clear();
+        } else {
+            final StringTokenizer st = new StringTokenizer(internalParams, ",");
+            while ( st.hasMoreTokens() ) {
+                final String parameter = st.nextToken();
+                if ( parameter.endsWith("*") ) {
+                    this.internalParametersMatchers.add(new PrefixParameterMatcher(parameter));
+                } else {
+                    this.internalParametersMatchers.add(new ConstantParameterMatcher(parameter));
+                }
+            }            
         }
     }
 
@@ -318,13 +320,6 @@
         return buffer.toString();
     }
     
-    /**
-     * @see org.apache.cocoon.portal.services.LinkService#getInternalParameterNames()
-     */
-    public List getInternalParameterNames() {
-        return this.internalParameters;
-    }
-
     /**
      * @see org.apache.cocoon.portal.services.LinkService#isInternalParameterName(java.lang.String)
      */

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/PageLabelLinkService.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/PageLabelLinkService.java?view=diff&rev=506488&r1=506487&r2=506488
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/PageLabelLinkService.java
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/services/impl/PageLabelLinkService.java
Mon Feb 12 07:32:52 2007
@@ -45,11 +45,11 @@
 
     /**
      * @see org.apache.avalon.framework.service.Serviceable#service(org.apache.avalon.framework.service.ServiceManager)
-     */
     public void service(ServiceManager aManager) throws ServiceException {
         super.service(aManager);
         this.labelManager = (PageLabelManager)this.manager.lookup(PageLabelManager.ROLE);
     }
+     */
 
     /**
      * Get the uri for the coplet containing event
@@ -202,7 +202,6 @@
 
     /**
      * @see org.apache.avalon.framework.activity.Disposable#dispose()
-     */
     public void dispose() {
         if (this.manager != null) {
             if (this.labelManager != null) {
@@ -212,6 +211,7 @@
         }
         super.dispose();
     }
+     */
 
     /**
      * Generates the page label.

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/cocoon-portal-components.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/cocoon-portal-components.xml?view=diff&rev=506488&r1=506487&r2=506488
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/cocoon-portal-components.xml
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/cocoon-portal-components.xml
Mon Feb 12 07:32:52 2007
@@ -26,9 +26,20 @@
        xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
                            http://www.springframework.org/schema/util http://www.springframework.org/schema/util/spring-util-2.0.xsd">
 
-  <!-- Event Converter -->
-  <bean name="org.apache.cocoon.portal.event.EventConverter"
-        class="org.apache.cocoon.portal.event.impl.DefaultEventConverter"
-        init-method="init" scope="singleton"/>
+  <!--+
+      | Portal Event Converter.
+      |
+      +-->
+    <bean name="org.apache.cocoon.portal.event.EventConverter"
+          class="org.apache.cocoon.portal.event.impl.DefaultEventConverter"
+          init-method="init" scope="singleton"/>
+  
+  <!--+
+      | Portal Link Service.
+      |
+      +-->
+    <bean name="org.apache.cocoon.portal.services.LinkService"
+          class="org.apache.cocoon.portal.services.LinkService"
+          scope="singleton"/>
 
 </beans>

Modified: cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/portal.roles
URL: http://svn.apache.org/viewvc/cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/portal.roles?view=diff&rev=506488&r1=506487&r2=506488
==============================================================================
--- cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/portal.roles
(original)
+++ cocoon/trunk/blocks/cocoon-portal/cocoon-portal-impl/src/main/resources/org/apache/cocoon/portal/portal.roles
Mon Feb 12 07:32:52 2007
@@ -209,14 +209,6 @@
           shorthand="page-label-manager"/>
 
   <!--+
-      | Portal Link Service.
-      |
-      +-->
-    <role name="org.apache.cocoon.portal.services.LinkService"
-          default-class="org.apache.cocoon.portal.services.impl.DefaultLinkService"
-          shorthand="portal-link-service"/>
-
-  <!--+
       | Layout Factory.
       |
       +-->



Mime
View raw message