cocoon-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From cziege...@apache.org
Subject svn commit: r382823 - in /cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal: event/impl/DefaultEventManager.java portal.roles spring/ spring/ReceiverBeanPostProcessor.java
Date Fri, 03 Mar 2006 13:58:51 GMT
Author: cziegeler
Date: Fri Mar  3 05:58:50 2006
New Revision: 382823

URL: http://svn.apache.org/viewcvs?rev=382823&view=rev
Log:
Add bean post processor for adding event receivers

Added:
    cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/spring/
    cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/spring/ReceiverBeanPostProcessor.java
  (with props)
Modified:
    cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/event/impl/DefaultEventManager.java
    cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/portal.roles

Modified: cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/event/impl/DefaultEventManager.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/event/impl/DefaultEventManager.java?rev=382823&r1=382822&r2=382823&view=diff
==============================================================================
--- cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/event/impl/DefaultEventManager.java
(original)
+++ cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/event/impl/DefaultEventManager.java
Fri Mar  3 05:58:50 2006
@@ -168,9 +168,7 @@
         }
         DefaultEventAspectContext context = new DefaultEventAspectContext(this.chain);
         EventConverter converter = null;
-        PortalService service = null;
         try {
-            service = (PortalService)this.manager.lookup(PortalService.ROLE);
             converter = (EventConverter) this.manager.lookup(EventConverter.ROLE);
 
             converter.start();
@@ -178,7 +176,7 @@
             // Invoke aspects
             context.setObjectModel(this.getObjectModel());
             context.setEventConverter(converter);
-            context.invokeNext( service );
+            context.invokeNext( this.portalService );
 
             converter.finish();
 
@@ -186,7 +184,6 @@
             throw new ProcessingException("Unable to lookup component.", ce);
         } finally {
             this.manager.release(converter);
-            this.manager.release(service);
         }
     }
 

Modified: cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/portal.roles
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/portal.roles?rev=382823&r1=382822&r2=382823&view=diff
==============================================================================
--- cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/portal.roles
(original)
+++ cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/portal.roles
Fri Mar  3 05:58:50 2006
@@ -15,6 +15,11 @@
 -->
 <!-- $Id$ -->
 <role-list>
+  <!--+
+      | Spring Bean Post Processors:
+      +-->
+    <role name="org.apache.cocoon.portal.spring.ReceiverBeanPostProcessor"
+          default-class="org.apache.cocoon.portal.spring.ReceiverBeanPostProcessor"/>
 
   <!--+ 
       | Event Aspects

Added: cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/spring/ReceiverBeanPostProcessor.java
URL: http://svn.apache.org/viewcvs/cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/spring/ReceiverBeanPostProcessor.java?rev=382823&view=auto
==============================================================================
--- cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/spring/ReceiverBeanPostProcessor.java
(added)
+++ cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/spring/ReceiverBeanPostProcessor.java
Fri Mar  3 05:58:50 2006
@@ -0,0 +1,60 @@
+/*
+ * Copyright 2006 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.spring;
+
+import org.apache.cocoon.portal.event.EventManager;
+import org.apache.cocoon.portal.event.Receiver;
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.BeanFactory;
+import org.springframework.beans.factory.BeanFactoryAware;
+import org.springframework.beans.factory.config.BeanPostProcessor;
+
+/**
+ * This is a Spring bean post processor for adding all registered beans
+ * implementing the {@link Receiver} interface to the {@link EventManager}.
+ *
+ * @version $Id$
+ */
+public class ReceiverBeanPostProcessor
+    implements BeanPostProcessor, BeanFactoryAware {
+
+    protected BeanFactory beanFactory;
+
+    /**
+     * @see org.springframework.beans.factory.BeanFactoryAware#setBeanFactory(org.springframework.beans.factory.BeanFactory)
+     */
+    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
+        this.beanFactory = beanFactory;
+    }
+
+    /**
+     * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessAfterInitialization(java.lang.Object,
java.lang.String)
+     */
+    public Object postProcessAfterInitialization(Object bean, String beanName) throws BeansException
{
+        if ( bean instanceof Receiver ) {
+            ((EventManager)this.beanFactory.getBean(EventManager.ROLE)).subscribe((Receiver)bean);
+        }
+        return bean;
+    }
+
+    /**
+     * @see org.springframework.beans.factory.config.BeanPostProcessor#postProcessBeforeInitialization(java.lang.Object,
java.lang.String)
+     */
+    public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException
{
+        // nothing to do
+        return bean;
+    }
+}

Propchange: cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/spring/ReceiverBeanPostProcessor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cocoon/trunk/cocoon-portal/cocoon-portal-impl/src/main/java/org/apache/cocoon/portal/spring/ReceiverBeanPostProcessor.java
------------------------------------------------------------------------------
    svn:keywords = Id



Mime
View raw message