Author: norman
Date: Sun Jul  3 13:16:44 2011
New Revision: 1142431

URL: http://svn.apache.org/viewvc?rev=1142431&view=rev
Log:
Make sure the lifecycle BeanPostProcessor get added automatic. See JAMES-835

Added:
    
james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/osgi/OsgiLifecycleBeanFactoryPostProcessor.java
    
james/server/trunk/container-spring/src/main/resources/META-INF/spring/extender/
    
james/server/trunk/container-spring/src/main/resources/META-INF/spring/extender/james-extender.xml

Added: 
james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/osgi/OsgiLifecycleBeanFactoryPostProcessor.java
URL: 
http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/osgi/OsgiLifecycleBeanFactoryPostProcessor.java?rev=1142431&view=auto
==============================================================================
--- 
james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/osgi/OsgiLifecycleBeanFactoryPostProcessor.java
 (added)
+++ 
james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/osgi/OsgiLifecycleBeanFactoryPostProcessor.java
 Sun Jul  3 13:16:44 2011
@@ -0,0 +1,61 @@
+/****************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one   *
+ * or more contributor license agreements.  See the NOTICE file *
+ * distributed with this work for additional information        *
+ * regarding copyright ownership.  The ASF licenses this file   *
+ * to you 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.james.container.spring.osgi;
+
+import 
org.apache.james.container.spring.bean.postprocessor.ConfigurableBeanPostProcessor;
+import 
org.apache.james.container.spring.bean.postprocessor.LogEnabledBeanPostProcessor;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.BundleException;
+import org.osgi.framework.InvalidSyntaxException;
+import org.springframework.beans.BeansException;
+import 
org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import 
org.springframework.context.annotation.CommonAnnotationBeanPostProcessor;
+import org.springframework.osgi.extender.OsgiBeanFactoryPostProcessor;
+
+
+public class OsgiLifecycleBeanFactoryPostProcessor implements 
OsgiBeanFactoryPostProcessor {
+
+    private ConfigurableBeanPostProcessor configurationProcessor;
+    private LogEnabledBeanPostProcessor loggingProcessor;
+    private CommonAnnotationBeanPostProcessor annotationProcessor;
+
+    public void setConfigurationProcessor(ConfigurableBeanPostProcessor 
configurationProcessor) {
+        this.configurationProcessor = configurationProcessor;
+    }
+
+    public void setLoggingProcessor(LogEnabledBeanPostProcessor 
loggingProcessor) {
+        this.loggingProcessor = loggingProcessor;
+    }
+
+    public void setAnnotationProcessor(CommonAnnotationBeanPostProcessor 
annotationProcessor) {
+        this.annotationProcessor = annotationProcessor;
+    }
+
+    @Override
+    public void postProcessBeanFactory(BundleContext context, 
ConfigurableListableBeanFactory factory) throws BeansException, 
InvalidSyntaxException, BundleException {
+        // We need to set the beanfactory by hand. This MAY be a bug in 
spring-dm but I'm not sure yet
+        loggingProcessor.setBeanFactory(factory);
+        factory.addBeanPostProcessor(loggingProcessor);
+        configurationProcessor.setBeanFactory(factory);
+        annotationProcessor.setBeanFactory(factory);
+        factory.addBeanPostProcessor(annotationProcessor);
+
+    }
+
+}

Added: 
james/server/trunk/container-spring/src/main/resources/META-INF/spring/extender/james-extender.xml
URL: 
http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/resources/META-INF/spring/extender/james-extender.xml?rev=1142431&view=auto
==============================================================================
--- 
james/server/trunk/container-spring/src/main/resources/META-INF/spring/extender/james-extender.xml
 (added)
+++ 
james/server/trunk/container-spring/src/main/resources/META-INF/spring/extender/james-extender.xml
 Sun Jul  3 13:16:44 2011
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you 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.    
+-->
+
+<beans xmlns="http://www.springframework.org/schema/beans"; 
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+       xsi:schemaLocation="http://www.springframework.org/schema/beans 
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd";>
+
+    <!-- 
+    ===========================================================================
+       Annotation - Bean Post-Processors
+    ===========================================================================
+    -->
+          
+    <!-- 
+      Enable Java Annotations processing.
+     -->
+    <bean id="annotationProcessor" 
class="org.springframework.context.annotation.CommonAnnotationBeanPostProcessor">
+        <property name="order" value="3" />
+    </bean>
+
+    <!-- 
+      Spring "Bean-Post-Processor" for LogEnabled interface.
+     -->
+    <bean id="loggingProcessor" 
class="org.apache.james.container.spring.bean.postprocessor.LogEnabledBeanPostProcessor">
+        <property name="logProvider" ref="logprovider" />
+        <property name="order" value="0" />
+    </bean>
+    <bean id="logprovider" 
class="org.apache.james.container.spring.provider.log.LogProviderImpl">
+    </bean>
+
+    <!-- 
+      Spring "Bean-Post-Processor" for Configurable interface.
+     -->
+    <bean id="configurationProcessor" 
class="org.apache.james.container.spring.bean.postprocessor.ConfigurableBeanPostProcessor">
+        <property name="configurationProvider" ref="configurationprovider" />
+        <property name="order" value="1" />
+    </bean>
+    <bean id="configurationprovider" 
class="org.apache.james.container.spring.osgi.OSGIConfigurationProvider">
+    <!--  
+        <property name="configurationMappings">
+            <map>
+                <entry key="mailprocessor" value="mailetcontainer.processors"/>
+                <entry key="mailspooler" value="mailetcontainer.spooler"/>
+                <entry key="mailetcontext" value="mailetcontainer.context"/>
+             </map>
+        </property>
+    -->
+    </bean>
+    
+    <bean 
class="org.apache.james.container.spring.osgi.OsgiLifecycleBeanFactoryPostProcessor">
+        <property name="loggingProcessor" ref="loggingProcessor" />
+        <property name="configurationProcessor" ref="configurationProcessor" />
+        <property name="annotationProcessor" ref="annotationProcessor" />
+    </bean>
+  
+</beans>



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to