You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by be...@apache.org on 2007/07/15 23:34:49 UTC
svn commit: r556458 [1/2] - in /james/server/sandbox/spring-integration: ./
src/main/config/ src/main/java/org/apache/james/container/spring/
src/main/java/org/apache/james/container/spring/adaptor/
src/main/java/org/apache/james/container/spring/beanf...
Author: berndf
Date: Sun Jul 15 14:34:46 2007
New Revision: 556458
URL: http://svn.apache.org/viewvc?view=rev&rev=556458
Log:
- read james-assembly.xml and build own spring application context from contained components
- add unit tests
- add ant build
Added:
james/server/sandbox/spring-integration/build.xml
james/server/sandbox/spring-integration/src/main/config/beans-base-config.xml
james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/adaptor/DefaultServiceManagerFactory.java
- copied, changed from r490077, james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/adaptor/ServiceManagerBridge.java
james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/adaptor/ServiceManagerFactory.java
james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/beanfactory/
james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/beanfactory/AvalonApplicationContext.java
james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/beanfactory/AvalonBeanDefinition.java
james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/beanfactory/AvalonBeanDefinitionReader.java
james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/beanfactory/AvalonServiceReference.java
james/server/sandbox/spring-integration/src/main/test/
james/server/sandbox/spring-integration/src/main/test/org/
james/server/sandbox/spring-integration/src/main/test/org/apache/
james/server/sandbox/spring-integration/src/main/test/org/apache/james/
james/server/sandbox/spring-integration/src/main/test/org/apache/james/container/
james/server/sandbox/spring-integration/src/main/test/org/apache/james/container/spring/
james/server/sandbox/spring-integration/src/main/test/org/apache/james/container/spring/adaptor/
james/server/sandbox/spring-integration/src/main/test/org/apache/james/container/spring/adaptor/DefaultServiceManagerFactoryTestCase.java
james/server/sandbox/spring-integration/src/main/test/org/apache/james/container/spring/beanfactory/
james/server/sandbox/spring-integration/src/main/test/org/apache/james/container/spring/beanfactory/AvalonApplicationContextTestCase.java
james/server/sandbox/spring-integration/src/main/test/org/apache/james/container/spring/beanfactory/BeanFactoryTestCase.java
james/server/sandbox/spring-integration/src/main/test/org/apache/james/container/spring/beanfactory/james-assembly.xml
Modified:
james/server/sandbox/spring-integration/src/main/config/james-config.xml
james/server/sandbox/spring-integration/src/main/config/spring-config.xml
james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/Main.java
james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/adaptor/AvalonConfigurationFileProvider.java
james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/adaptor/ServiceManagerBridge.java
james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/lifecycle/AbstractPropagator.java
james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/lifecycle/ConfigurationPropagator.java
james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/lifecycle/ContextPropagator.java
james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/lifecycle/InitializationPropagator.java
james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/lifecycle/LoggerPropagator.java
james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/lifecycle/ServicePropagator.java
james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/processor/LoggerProcessor.java
james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/processor/ServiceProcessor.java
Added: james/server/sandbox/spring-integration/build.xml
URL: http://svn.apache.org/viewvc/james/server/sandbox/spring-integration/build.xml?view=auto&rev=556458
==============================================================================
--- james/server/sandbox/spring-integration/build.xml (added)
+++ james/server/sandbox/spring-integration/build.xml Sun Jul 15 14:34:46 2007
@@ -0,0 +1,190 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+
+<!--
+ 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.
+-->
+<project name="spring_integration" default="all">
+
+ <!-- Compiler options -->
+
+ <property name="compiler.debug" value="on"/>
+ <property name="compiler.generate.no.warnings" value="off"/>
+ <property name="compiler.args" value=""/>
+ <property name="compiler.max.memory" value="128m"/>
+ <patternset id="ignored.files">
+ <exclude name="**/CVS/**"/>
+ <exclude name="**/SCCS/**"/>
+ <exclude name="**/RCS/**"/>
+ <exclude name="**/rcs/**"/>
+ <exclude name="**/.DS_Store/**"/>
+ <exclude name="**/.svn/**"/>
+ </patternset>
+ <patternset id="compiler.resources">
+ <include name="**/?*.properties"/>
+ <include name="**/?*.xml"/>
+ <include name="**/?*.gif"/>
+ <include name="**/?*.png"/>
+ <include name="**/?*.jpeg"/>
+ <include name="**/?*.jpg"/>
+ <include name="**/?*.html"/>
+ <include name="**/?*.dtd"/>
+ <include name="**/?*.tld"/>
+ </patternset>
+
+ <dirname property="basedir" file="${ant.file}"/>
+
+ <property name="compiler.args" value="${compiler.args}"/>
+
+ <property name="output.dir" value="${basedir}/build/classes"/>
+
+ <path id="bootclasspath">
+ <!-- Paths to be included in compilation bootclasspath -->
+ </path>
+
+ <path id="classpath">
+ <pathelement location="${basedir}/lib/concurrent-1.3.4.jar"/>
+ <pathelement location="${basedir}/lib/cornerstone-sockets-impl-2.1-patched.jar"/>
+ <pathelement location="${basedir}/lib/phoenix-engine.jar"/>
+ <pathelement location="${basedir}/lib/cornerstone-store-impl-2.1.jar"/>
+ <pathelement location="${basedir}/lib/commons-discovery.jar"/>
+ <pathelement location="${basedir}/lib/avalon-framework-impl-4.3.jar"/>
+ <pathelement location="${basedir}/lib/commons-pool-1.2.jar"/>
+ <pathelement location="${basedir}/lib/commons-io.jar"/>
+ <pathelement location="${basedir}/lib/jakarta-oro-2.0.8.jar"/>
+ <pathelement location="${basedir}/lib/cornerstone-store-api-2.1.jar"/>
+ <pathelement location="${basedir}/lib/excalibur-thread-impl-2.1.jar"/>
+ <pathelement location="${basedir}/lib/avalon-logkit-2.1.jar"/>
+ <pathelement location="${basedir}/lib/commons-validator.jar"/>
+ <pathelement location="${basedir}/lib/excalibur-instrument-manager-1.0.jar"/>
+ <pathelement location="${basedir}/lib/commons-javaflow.jar"/>
+ <pathelement location="${basedir}/lib/phoenix-client.jar"/>
+ <pathelement location="${basedir}/lib/bcmail-jdk14-129.jar"/>
+ <pathelement location="${basedir}/lib/dnsjava-2.0.1.jar"/>
+ <pathelement location="${basedir}/lib/commons-digester.jar"/>
+ <pathelement location="${basedir}/lib/spice-loggerstore-0.5.jar"/>
+ <pathelement location="${basedir}/lib/cornerstone-connection-api-2.1.jar"/>
+ <pathelement location="${basedir}/lib/mail-1.4.jar"/>
+ <pathelement location="${basedir}/lib/excalibur-pool-impl-2.1.jar"/>
+ <pathelement location="${basedir}/lib/spice-xmlpolicy-1.0.jar"/>
+ <pathelement location="${basedir}/lib/cornerstone-scheduler-api-2.1.jar"/>
+ <pathelement location="${basedir}/lib/spring.jar"/>
+ <pathelement location="${basedir}/lib/excalibur-extension-1.0a.jar"/>
+ <pathelement location="${basedir}/lib/commons-beanutils.jar"/>
+ <pathelement location="${basedir}/lib/mailet-api-2.3.jar"/>
+ <pathelement location="${basedir}/lib/commons-lang.jar"/>
+ <pathelement location="${basedir}/lib/excalibur-pool-api-2.1.jar"/>
+ <pathelement location="${basedir}/lib/excalibur-cli-1.0.jar"/>
+ <pathelement location="${basedir}/lib/commons-httpclient.jar"/>
+ <pathelement location="${basedir}/lib/commons-dbcp-1.2.1.jar"/>
+ <pathelement location="${basedir}/lib/commons-codec.jar"/>
+ <pathelement location="${basedir}/lib/spice-salt-0.8.jar"/>
+ <pathelement location="${basedir}/lib/excalibur-monitor-2.1.jar"/>
+ <pathelement location="${basedir}/lib/excalibur-datasource-2.1.jar"/>
+ <pathelement location="${basedir}/lib/cornerstone-connection-impl-2.1.jar"/>
+ <pathelement location="${basedir}/lib/spice-configkit-1.1.2.jar"/>
+ <pathelement location="${basedir}/lib/commons-attributes-api.jar"/>
+ <pathelement location="${basedir}/lib/excalibur-thread-api-2.1.jar"/>
+ <pathelement location="${basedir}/lib/activation-1.1.jar"/>
+ <pathelement location="${basedir}/lib/excalibur-logger-2.1.jar"/>
+ <pathelement location="${basedir}/lib/commons-attributes-compiler.jar"/>
+ <pathelement location="${basedir}/lib/cornerstone-datasources-api-2.1.jar"/>
+ <pathelement location="${basedir}/lib/cornerstone-sockets-api-2.1.jar"/>
+ <pathelement location="${basedir}/lib/commons-fileupload.jar"/>
+ <pathelement location="${basedir}/lib/cornerstone-datasources-impl-2.1-patched.jar"/>
+ <pathelement location="${basedir}/lib/excalibur-io-1.1.jar"/>
+ <pathelement location="${basedir}/lib/mx4j-tools.jar"/>
+ <pathelement location="${basedir}/lib/excalibur-instrument-api-2.1.jar"/>
+ <pathelement location="${basedir}/lib/commons-collections-2.1.1.jar"/>
+ <pathelement location="${basedir}/lib/bcmail-jdk14-129-workaround.jar"/>
+ <pathelement location="${basedir}/lib/cornerstone-scheduler-impl-2.1.jar"/>
+ <pathelement location="${basedir}/lib/cornerstone-threads-api-2.1.jar"/>
+ <pathelement location="${basedir}/lib/spice-classman-1.0.jar"/>
+ <pathelement location="${basedir}/lib/mx4j-jmx.jar"/>
+ <pathelement location="${basedir}/lib/james-2.3.0.jar"/>
+ <pathelement location="${basedir}/lib/avalon-framework-api-4.3.jar"/>
+ <pathelement location="${basedir}/lib/derby.jar"/>
+ <pathelement location="${basedir}/lib/cornerstone-threads-impl-2.1.jar"/>
+ <pathelement location="${basedir}/lib/mailet-2.3.jar"/>
+ <pathelement location="${basedir}/lib/commons-logging.jar"/>
+ </path>
+
+ <path id="runclasspath">
+ <path refid="classpath" />
+ <pathelement location="${basedir}/src/main/config/"/>
+ </path>
+
+ <patternset id="excluded.from">
+ <patternset refid="ignored.files"/>
+ </patternset>
+
+ <patternset id="excluded.from.compilation">
+ <patternset refid="excluded.from"/>
+ </patternset>
+
+ <path id="sourcepath">
+ <dirset dir="${basedir}">
+ <include name="src/main/java"/>
+ </dirset>
+ </path>
+
+
+ <target name="clean">
+ <delete dir="${output.dir}"/>
+ </target>
+
+ <target name="init" description="Build initialization">
+ <!-- Perform any build initialization in this target -->
+ </target>
+
+ <target name="all" depends="init, clean, compile" description="build all"/>
+
+ <target name="compile" description="compile .java">
+ <mkdir dir="${output.dir}"/>
+ <javac destdir="${output.dir}" debug="${compiler.debug}" nowarn="${compiler.generate.no.warnings}"
+ memoryMaximumSize="${compiler.max.memory}" fork="true">
+ <compilerarg line="${compiler.args}"/>
+ <bootclasspath refid="bootclasspath"/>
+ <classpath refid="classpath"/>
+ <src refid="sourcepath"/>
+ </javac>
+
+ <copy todir="${output.dir}">
+ <fileset dir="${basedir}/src/main/java">
+ <patternset refid="compiler.resources"/>
+ <type type="file"/>
+ </fileset>
+ </copy>
+ </target>
+
+ <target name="copy-configuration">
+ <mkdir dir="${output.dir}"/>
+ <copy todir="${output.dir}">
+ <fileset dir="${basedir}/src/main/config">
+ <include name="*.xml"/>
+ </fileset>
+ </copy>
+ </target>
+
+ <target name="run" depends="compile, copy-configuration">
+ <java classname="org.apache.james.container.spring.Main"
+ classpath="${output.dir}"
+ classpathref="runclasspath"
+ fork="true" />
+ </target>
+
+</project>
\ No newline at end of file
Added: james/server/sandbox/spring-integration/src/main/config/beans-base-config.xml
URL: http://svn.apache.org/viewvc/james/server/sandbox/spring-integration/src/main/config/beans-base-config.xml?view=auto&rev=556458
==============================================================================
--- james/server/sandbox/spring-integration/src/main/config/beans-base-config.xml (added)
+++ james/server/sandbox/spring-integration/src/main/config/beans-base-config.xml Sun Jul 15 14:34:46 2007
@@ -0,0 +1,87 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
+
+<!--
+ ! 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>
+
+ <!--
+ beans which replace Avalon specific container logic
+ -->
+
+ <bean id="serviceManager" class="org.apache.james.container.spring.adaptor.DefaultServiceManagerFactory" />
+
+ <bean name="logWorker" class="org.apache.james.container.spring.logging.SystemConsoleLogWorker" />
+
+ <bean name="logger, loggerMap" class="org.apache.james.container.spring.adaptor.LoggingBridge" >
+ <property name="logWorker" ref="logWorker" />
+ </bean>
+
+ <bean id="configurationProvider" class="org.apache.james.container.spring.adaptor.AvalonConfigurationFileProvider" >
+ <property name="configurationPath" value="src/main/config/james-config.xml" />
+ </bean>
+
+ <bean id="avalonContext" class="org.apache.james.container.spring.adaptor.AvalonContext" >
+ <property name="applicationHome" value="data" />
+ </bean>
+
+ <!--
+ JMX part
+ -->
+
+ <!-- <bean id="exporter" class="org.springframework.jmx.export.MBeanExporter" >
+ <property name="autodetect" value="true" />
+ <property name="namingStrategy" ref="namingStrategy" />
+ </bean>
+
+ <bean id="namingStrategy" class="org.springframework.jmx.export.naming.KeyNamingStrategy" >
+ <property name="mappings" ><props>
+ <prop key="fetchmail" >bean:name=fetchmail</prop>
+ <prop key="smtpserver" >bean:name=smtpserver</prop>
+ <prop key="James" >bean:name=James</prop>
+ <prop key="dnsserver" >bean:name=dnsserver</prop>
+ <prop key="remotemanager" >bean:name=remotemanager</prop>
+ <prop key="pop3server" >bean:name=pop3server</prop>
+ <prop key="nntpserver" >bean:name=nntpserver</prop>
+ </props></property>
+ </bean>
+ -->
+
+ <bean id="mbeanServer" class="org.springframework.jmx.support.MBeanServerFactoryBean" />
+
+ <!--
+ beans managing bootstrapping and component lifecycle
+ -->
+ <bean id="loggerPropagator" class="org.apache.james.container.spring.lifecycle.LoggerPropagator" />
+
+ <bean id="contextPropagator" class="org.apache.james.container.spring.lifecycle.ContextPropagator" />
+
+ <bean id="servicePropagator" class="org.apache.james.container.spring.lifecycle.ServicePropagator" />
+
+ <bean id="configurationManager" class="org.apache.james.container.spring.lifecycle.ConfigurationPropagator" />
+
+ <bean id="initializationManager" class="org.apache.james.container.spring.lifecycle.InitializationPropagator" />
+
+</beans>
+
+
+
+
Modified: james/server/sandbox/spring-integration/src/main/config/james-config.xml
URL: http://svn.apache.org/viewvc/james/server/sandbox/spring-integration/src/main/config/james-config.xml?view=diff&rev=556458&r1=556457&r2=556458
==============================================================================
--- james/server/sandbox/spring-integration/src/main/config/james-config.xml (original)
+++ james/server/sandbox/spring-integration/src/main/config/james-config.xml Sun Jul 15 14:34:46 2007
@@ -801,7 +801,7 @@
<pop3server enabled="true">
<!-- port 995 is the well-known/IANA registered port for POP3S ie over SSL/TLS -->
<!-- port 110 is the well-known/IANA registered port for Standard POP3 -->
- <port>110</port>
+ <port>10110</port>
<!-- Uncomment this if you want to bind to a specific inetaddress -->
<!--
@@ -828,7 +828,7 @@
<!-- but does not free as many resources as removing them would -->
<smtpserver enabled="true">
<!-- port 25 is the well-known/IANA registered port for SMTP -->
- <port>25</port>
+ <port>10025</port>
<!-- Uncomment this if you want to bind to a specific inetaddress -->
<!-- Please NOTE: you should add this IP also to your RemoteAddrNotInNetwork -->
@@ -922,7 +922,7 @@
service. -->
<!-- port 563 is the well-known/IANA registered port for NNTP over SSL/TLS -->
<!-- port 119 is the well-known/IANA registered port for Standard NNTP -->
- <port>119</port>
+ <port>10119</port>
<!-- Uncomment this if you want to bind to a specific inetaddress -->
<!--
Modified: james/server/sandbox/spring-integration/src/main/config/spring-config.xml
URL: http://svn.apache.org/viewvc/james/server/sandbox/spring-integration/src/main/config/spring-config.xml?view=diff&rev=556458&r1=556457&r2=556458
==============================================================================
--- james/server/sandbox/spring-integration/src/main/config/spring-config.xml (original)
+++ james/server/sandbox/spring-integration/src/main/config/spring-config.xml Sun Jul 15 14:34:46 2007
@@ -69,7 +69,6 @@
<!--
beans which manage bootstrapping and component lifecycle
-->
-
<bean id="loggerPropagator" class="org.apache.james.container.spring.lifecycle.LoggerPropagator" />
<bean id="contextPropagator" class="org.apache.james.container.spring.lifecycle.ContextPropagator" />
@@ -79,7 +78,6 @@
<bean id="configurationManager" class="org.apache.james.container.spring.lifecycle.ConfigurationPropagator" />
<bean id="initializationManager" class="org.apache.james.container.spring.lifecycle.InitializationPropagator" />
-
<!--
JAMES components starting from here
Modified: james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/Main.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/Main.java?view=diff&rev=556458&r1=556457&r2=556458
==============================================================================
--- james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/Main.java (original)
+++ james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/Main.java Sun Jul 15 14:34:46 2007
@@ -18,8 +18,9 @@
****************************************************************/
package org.apache.james.container.spring;
-import org.springframework.context.support.AbstractApplicationContext;
-import org.springframework.context.support.ClassPathXmlApplicationContext;
+import org.apache.james.container.spring.beanfactory.AvalonApplicationContext;
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
/**
* Bootstraps James using a Spring container
@@ -27,7 +28,9 @@
public class Main {
public static void main(String[] args) {
- AbstractApplicationContext applicationContext = new ClassPathXmlApplicationContext("spring-config.xml");
+ Resource containerResource = new ClassPathResource("beans-base-config.xml");
+ Resource applicationResource = new ClassPathResource("james-assembly.xml");
+ AvalonApplicationContext context = new AvalonApplicationContext(containerResource, applicationResource);
}
}
Modified: james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/adaptor/AvalonConfigurationFileProvider.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/adaptor/AvalonConfigurationFileProvider.java?view=diff&rev=556458&r1=556457&r2=556458
==============================================================================
--- james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/adaptor/AvalonConfigurationFileProvider.java (original)
+++ james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/adaptor/AvalonConfigurationFileProvider.java Sun Jul 15 14:34:46 2007
@@ -23,7 +23,9 @@
import org.xml.sax.InputSource;
/**
- * loads the well-known classic James configuration file
+ * loads the well-known classic James configuration file
+ *
+ * TODO make this thing be based on Resource class and inject resource.getInputStream() into InputSource
*/
public class AvalonConfigurationFileProvider implements ConfigurationProvider {
Copied: james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/adaptor/DefaultServiceManagerFactory.java (from r490077, james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/adaptor/ServiceManagerBridge.java)
URL: http://svn.apache.org/viewvc/james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/adaptor/DefaultServiceManagerFactory.java?view=diff&rev=556458&p1=james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/adaptor/ServiceManagerBridge.java&r1=490077&p2=james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/adaptor/DefaultServiceManagerFactory.java&r2=556458
==============================================================================
--- james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/adaptor/ServiceManagerBridge.java (original)
+++ james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/adaptor/DefaultServiceManagerFactory.java Sun Jul 15 14:34:46 2007
@@ -18,72 +18,65 @@
****************************************************************/
package org.apache.james.container.spring.adaptor;
-import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.ServiceException;
-import org.springframework.context.ApplicationContextAware;
-import org.springframework.context.ApplicationContext;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.james.container.spring.beanfactory.AvalonBeanDefinition;
+import org.apache.james.container.spring.beanfactory.AvalonServiceReference;
import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import java.util.List;
import java.util.Map;
+import java.util.HashMap;
+import java.util.Iterator;
/**
* provides a Avalon-style service manager to all James components
*/
-public class ServiceManagerBridge implements ApplicationContextAware {
+public class DefaultServiceManagerFactory implements ApplicationContextAware, ServiceManagerFactory {
private ApplicationContext applicationContext;
- private Map beanBlockInfos;
+ private class ServiceManagerBridge implements ServiceManager {
- private class ServiceManagerInstance implements ServiceManager {
-
- private Map beanBlockInfo;
+ private final Map avalonServices = new HashMap();
- public ServiceManagerInstance(Map beanBlockInfo) {
- this.beanBlockInfo=beanBlockInfo;
- }
+ public ServiceManagerBridge(List avalonServiceReferences) {
+ populateServiceMap(avalonServiceReferences);
+ }
+
+ private void populateServiceMap(List avalonServiceReferences) {
+ Iterator iterator = avalonServiceReferences.iterator();
+ while (iterator.hasNext()) {
+ AvalonServiceReference serviceReference = (AvalonServiceReference) iterator.next();
+ String name = serviceReference.getName();
+ String rolename = serviceReference.getRolename();
+
+ // the interface to be injected
+ Class roleClass = null;
+ try {
+ roleClass = Class.forName(rolename);
+ } catch (ClassNotFoundException e) {
+ throw new RuntimeException("cannot load class for role " + roleClass, e);
+ }
+ // the object to be injected (reduced to roleClass)
+ Object injectionCandidate = applicationContext.getBean(name);
+ if (!roleClass.isInstance(injectionCandidate)) throw new RuntimeException("cannot assign object as role as specified");
+
+ if (avalonServices.containsKey(rolename)) {
+ throw new IllegalStateException("avalon service references role name not unique: " + rolename);
+ }
+ avalonServices.put(rolename, injectionCandidate);
+ }
+ }
- public Object lookup(String componentIdentifier)
+ public Object lookup(String componentIdentifier)
throws ServiceException {
- Object component = lookupByClassname(componentIdentifier);
- if (component == null)
- component = lookupByBeanname(componentIdentifier);
-
- if (component == null)
- throw new ServiceException("could not resolve dependency "
- + componentIdentifier); // adhere to avalon service
- // manager contract
- return component;
- }
-
- private Object lookupByClassname(String className) {
-
- String beanName = getBeanName(className);
-
- if (beanName!=null) {
- System.out.println("Lookup configured "+beanName);
- return lookupByBeanname(beanName);
- }
-
- Class lookupClass = null;
- try {
- lookupClass = Class.forName(className);
- } catch (ClassNotFoundException e) {
- return null;
- }
-
- Map beansOfType = applicationContext.getBeansOfType(lookupClass);
- if (beansOfType.size() > 1) {
- System.err.println("not yet supported");
- Thread.dumpStack();
- System.exit(1);
- throw new RuntimeException("not yet supported");
- }
- if (beansOfType.size() == 0)
- return null; // try other method
- Object bean = beansOfType.values().iterator().next();
- return bean;
- }
+ Object service = avalonServices.get(componentIdentifier);
+ return service;
+ }
public boolean hasService(String componentIdentifier) {
try {
@@ -97,39 +90,18 @@
throw new IllegalStateException("not yet implemented");
}
- protected String getBeanName(String className) {
- String beanName = null;
- if (beanBlockInfo!=null) {
-
- beanName= (String) beanBlockInfo.get(className);
- System.out.println("We have a blockInfo! " +className+" -> "+beanName);
- }
- return beanName;
- }
}
- private Object lookupByBeanname(String componentIdentifier) {
- return applicationContext.getBean(componentIdentifier);
- }
-
- public void setApplicationContext(ApplicationContext applicationContext)
- throws BeansException {
+ public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
this.applicationContext = applicationContext;
}
- public ServiceManager getInstance(String beanName) {
- return new ServiceManagerInstance(getBeanBlockInfo(beanName));
- }
-
- protected Map getBeanBlockInfo(String beanName) {
- Map blockInfo = null;
- if (beanBlockInfos!=null) {
- blockInfo= (Map) beanBlockInfos.get(beanName);
- }
- return blockInfo;
- }
+ public ServiceManager getInstanceFor(String beanName, BeanDefinition beanDefinition) {
+ if (beanDefinition == null || !(beanDefinition instanceof AvalonBeanDefinition)) return null;
- public void setBeanBlockInfos(Map beanBlockInfos) {
- this.beanBlockInfos = beanBlockInfos;
+ AvalonBeanDefinition avalonBeanDefinition = (AvalonBeanDefinition) beanDefinition;
+
+ return new DefaultServiceManagerFactory.ServiceManagerBridge(avalonBeanDefinition.getServiceReferences());
}
-}
+
+}
\ No newline at end of file
Modified: james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/adaptor/ServiceManagerBridge.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/adaptor/ServiceManagerBridge.java?view=diff&rev=556458&r1=556457&r2=556458
==============================================================================
--- james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/adaptor/ServiceManagerBridge.java (original)
+++ james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/adaptor/ServiceManagerBridge.java Sun Jul 15 14:34:46 2007
@@ -23,19 +23,20 @@
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.ApplicationContext;
import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.config.BeanDefinition;
import java.util.Map;
/**
* provides a Avalon-style service manager to all James components
*/
-public class ServiceManagerBridge implements ApplicationContextAware {
+public class ServiceManagerBridge implements ApplicationContextAware, ServiceManagerFactory {
private ApplicationContext applicationContext;
private Map beanBlockInfos;
- private class ServiceManagerInstance implements ServiceManager {
+ private class ServiceManagerInstance implements ServiceManager {
private Map beanBlockInfo;
@@ -74,13 +75,9 @@
Map beansOfType = applicationContext.getBeansOfType(lookupClass);
if (beansOfType.size() > 1) {
- System.err.println("not yet supported");
- Thread.dumpStack();
- System.exit(1);
- throw new RuntimeException("not yet supported");
+ throw new RuntimeException("cannot resolve ambiguous beans for type \"" + lookupClass + "\". instead of at most 1, found: " + beansOfType.size());
}
- if (beansOfType.size() == 0)
- return null; // try other method
+ if (beansOfType.size() == 0) return null; // try other method
Object bean = beansOfType.values().iterator().next();
return bean;
}
@@ -117,7 +114,7 @@
this.applicationContext = applicationContext;
}
- public ServiceManager getInstance(String beanName) {
+ public ServiceManager getInstanceFor(String beanName, BeanDefinition beanDefinition) {
return new ServiceManagerInstance(getBeanBlockInfo(beanName));
}
Added: james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/adaptor/ServiceManagerFactory.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/adaptor/ServiceManagerFactory.java?view=auto&rev=556458
==============================================================================
--- james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/adaptor/ServiceManagerFactory.java (added)
+++ james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/adaptor/ServiceManagerFactory.java Sun Jul 15 14:34:46 2007
@@ -0,0 +1,29 @@
+/****************************************************************
+ * 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.adaptor;
+
+import org.apache.avalon.framework.service.ServiceManager;
+import org.springframework.beans.factory.config.BeanDefinition;
+
+/**
+ */
+public interface ServiceManagerFactory {
+
+ ServiceManager getInstanceFor(String beanName, BeanDefinition beanDefinition);
+}
Added: james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/beanfactory/AvalonApplicationContext.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/beanfactory/AvalonApplicationContext.java?view=auto&rev=556458
==============================================================================
--- james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/beanfactory/AvalonApplicationContext.java (added)
+++ james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/beanfactory/AvalonApplicationContext.java Sun Jul 15 14:34:46 2007
@@ -0,0 +1,64 @@
+/****************************************************************
+ * 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.beanfactory;
+
+import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.support.DefaultListableBeanFactory;
+import org.springframework.beans.factory.xml.XmlBeanDefinitionReader;
+import org.springframework.context.support.AbstractRefreshableApplicationContext;
+import org.springframework.context.ApplicationContext;
+import org.springframework.core.io.Resource;
+
+import java.io.IOException;
+
+/**
+ * loads an Avalon/Phoenix configuration.
+ * this is done by using a two step approach:
+ * 1. loading the avalon mocking beans from a spring xml beans configuration
+ * 2. loading the James beans from a james-assembly.xml
+ */
+public class AvalonApplicationContext extends AbstractRefreshableApplicationContext {
+
+ private Resource containerConfigurationResource;
+ private Resource applicationConfigurationResource;
+
+ public AvalonApplicationContext(ApplicationContext parent,
+ Resource containerConfigurationResource,
+ Resource applicationConfigurationResource) {
+ super(parent);
+ this.containerConfigurationResource = containerConfigurationResource;
+ this.applicationConfigurationResource = applicationConfigurationResource;
+ refresh();
+ }
+
+ public AvalonApplicationContext(Resource containerConfigurationResource,
+ Resource applicationConfigurationResource) {
+ this(null, containerConfigurationResource, applicationConfigurationResource);
+ }
+
+ protected void loadBeanDefinitions(DefaultListableBeanFactory defaultListableBeanFactory) throws IOException, BeansException {
+ XmlBeanDefinitionReader containerBeanDefinitionReader = new XmlBeanDefinitionReader(defaultListableBeanFactory);
+ int containerBeanCount = containerBeanDefinitionReader.loadBeanDefinitions(containerConfigurationResource);
+
+ AvalonBeanDefinitionReader applicationBeanDefinitionReader = new AvalonBeanDefinitionReader(defaultListableBeanFactory);
+ int applicationBeanCount = applicationBeanDefinitionReader.loadBeanDefinitions(applicationConfigurationResource);
+
+ int totalBeanCount = containerBeanCount + applicationBeanCount;
+ }
+}
Added: james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/beanfactory/AvalonBeanDefinition.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/beanfactory/AvalonBeanDefinition.java?view=auto&rev=556458
==============================================================================
--- james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/beanfactory/AvalonBeanDefinition.java (added)
+++ james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/beanfactory/AvalonBeanDefinition.java Sun Jul 15 14:34:46 2007
@@ -0,0 +1,46 @@
+/****************************************************************
+ * 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.beanfactory;
+
+import org.springframework.beans.factory.support.RootBeanDefinition;
+
+import java.util.List;
+import java.util.ArrayList;
+
+/**
+ */
+public class AvalonBeanDefinition extends RootBeanDefinition {
+
+ protected final List serviceReferences = new ArrayList();
+
+ public AvalonBeanDefinition() {
+ super();
+ }
+
+ public void addAllServiceReferences(List serviceReferences) {
+ this.serviceReferences.addAll(serviceReferences);
+ }
+ public void addServiceReference(AvalonServiceReference serviceReference) {
+ serviceReferences.add(serviceReference);
+ }
+
+ public List getServiceReferences() {
+ return serviceReferences;
+ }
+}
Added: james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/beanfactory/AvalonBeanDefinitionReader.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/beanfactory/AvalonBeanDefinitionReader.java?view=auto&rev=556458
==============================================================================
--- james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/beanfactory/AvalonBeanDefinitionReader.java (added)
+++ james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/beanfactory/AvalonBeanDefinitionReader.java Sun Jul 15 14:34:46 2007
@@ -0,0 +1,151 @@
+/****************************************************************
+ * 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.beanfactory;
+
+import org.apache.avalon.framework.configuration.Configuration;
+import org.apache.avalon.framework.configuration.ConfigurationException;
+import org.apache.avalon.phoenix.tools.configuration.ConfigurationBuilder;
+import org.apache.james.container.spring.adaptor.ConfigurationProvider;
+import org.springframework.beans.factory.BeanDefinitionStoreException;
+import org.springframework.beans.factory.config.BeanDefinitionHolder;
+import org.springframework.beans.factory.support.AbstractBeanDefinitionReader;
+import org.springframework.beans.factory.support.BeanDefinitionRegistry;
+import org.springframework.core.io.Resource;
+import org.springframework.core.io.ResourceLoader;
+import org.springframework.util.ClassUtils;
+import org.xml.sax.InputSource;
+
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ */
+public class AvalonBeanDefinitionReader extends AbstractBeanDefinitionReader {
+
+ private ConfigurationProvider configurationProvider;
+ private ResourceLoader resourceLoader;
+ private ClassLoader beanClassLoader;
+
+ public AvalonBeanDefinitionReader(BeanDefinitionRegistry beanDefinitionRegistry) {
+ super(beanDefinitionRegistry);
+ }
+
+ public int loadBeanDefinitions(Resource resource) throws BeanDefinitionStoreException {
+ Configuration configuration = null;
+ try {
+ configuration = getConfiguration(resource);
+ } catch (IOException e) {
+ throw new BeanDefinitionStoreException("could not read input resource", e);
+ }
+
+ configuration.getChildren("assembly");
+ if (configuration == null) return 0;
+
+ Configuration[] blocks = configuration.getChildren("block");
+ if (blocks == null) return 0;
+
+ for (int i = 0; i < blocks.length; i++) {
+ Configuration block = blocks[i];
+ BeanDefinitionHolder definitionHolder = loadBeanDefinition(block);
+ getBeanFactory().registerBeanDefinition(definitionHolder.getBeanName(), definitionHolder.getBeanDefinition());
+ }
+
+ return blocks.length;
+ }
+
+ private BeanDefinitionHolder loadBeanDefinition(Configuration block) throws BeanDefinitionStoreException {
+ String name = null;
+ String className = null;
+ try {
+ name = block.getAttribute("name");
+ } catch (ConfigurationException e) {
+ throw new BeanDefinitionStoreException("avalon assembly block mandatory name attribute missing", e);
+ }
+ try {
+ className = block.getAttribute("class");
+ } catch (ConfigurationException e) {
+ throw new BeanDefinitionStoreException("avalon assembly block mandatory class attribute missing", e);
+ }
+
+
+ AvalonBeanDefinition beanDefinition = null;
+ try {
+ beanDefinition = createBeanDefinition(className);
+ } catch (ClassNotFoundException e) {
+ throw new BeanDefinitionStoreException("bean class not found", e);
+ }
+
+ beanDefinition.addAllServiceReferences(loadServiceReferences(block));
+
+ return new BeanDefinitionHolder(beanDefinition, name);
+ }
+
+ public AvalonBeanDefinition createBeanDefinition(String className) throws ClassNotFoundException {
+ AvalonBeanDefinition bd = new AvalonBeanDefinition();
+ if (className != null) {
+ if (getBeanClassLoader() != null) {
+ bd.setBeanClass(ClassUtils.forName(className, getBeanClassLoader()));
+ }
+ else {
+ bd.setBeanClassName(className);
+ }
+ }
+ return bd;
+ }
+
+ private List loadServiceReferences(Configuration block) {
+ List serviceReferences = new ArrayList();
+ Configuration[] referencedComponentDefs = block.getChildren("provide");
+ if (referencedComponentDefs == null) return serviceReferences;
+
+ String name = null;
+ String roleClassname = null;
+ for (int i = 0; i < referencedComponentDefs.length; i++) {
+ Configuration referencedComponentDef = referencedComponentDefs[i];
+
+ try {
+ name = referencedComponentDef.getAttribute("name");
+ } catch (ConfigurationException e) {
+ throw new BeanDefinitionStoreException("avalon assembly provide mandatory name attribute missing", e);
+ }
+ try {
+ roleClassname = referencedComponentDef.getAttribute("role");
+ } catch (ConfigurationException e) {
+ throw new BeanDefinitionStoreException("avalon assembly provide mandatory role attribute missing", e);
+ }
+ AvalonServiceReference avalonServiceReference = new AvalonServiceReference(name, roleClassname);
+ serviceReferences.add(avalonServiceReference);
+ }
+ return serviceReferences;
+ }
+
+ private Configuration getConfiguration(Resource resource) throws IOException {
+ InputSource inputSource = new InputSource(resource.getInputStream());
+ try
+ {
+ Configuration configuration = ConfigurationBuilder.build(inputSource, null, null);
+ return configuration;
+ }
+ catch( final Exception e )
+ {
+ throw new RuntimeException("failed loading configuration ", e);
+ }
+ }
+}
Added: james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/beanfactory/AvalonServiceReference.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/beanfactory/AvalonServiceReference.java?view=auto&rev=556458
==============================================================================
--- james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/beanfactory/AvalonServiceReference.java (added)
+++ james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/beanfactory/AvalonServiceReference.java Sun Jul 15 14:34:46 2007
@@ -0,0 +1,44 @@
+/****************************************************************
+ * 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.beanfactory;
+
+/**
+ * content of a "provide" XML element from an james-assembly file.
+ * occurs within a block element like this:
+ * <provide name="domainlist" role="org.apache.james.services.DomainList"/>
+ *
+ */
+public class AvalonServiceReference {
+
+ private String name;
+ private String rolename; // in James, this is the service interface name (per convention)
+
+ public AvalonServiceReference(String name, String rolename) {
+ this.name = name;
+ this.rolename = rolename;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public String getRolename() {
+ return rolename;
+ }
+}
Modified: james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/lifecycle/AbstractPropagator.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/lifecycle/AbstractPropagator.java?view=diff&rev=556458&r1=556457&r2=556458
==============================================================================
--- james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/lifecycle/AbstractPropagator.java (original)
+++ james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/lifecycle/AbstractPropagator.java Sun Jul 15 14:34:46 2007
@@ -21,11 +21,12 @@
import java.util.Collection;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.BeanFactoryUtils;
import org.springframework.beans.BeansException;
/**
- * basis for iterating over all spring beans having some specific implementation
+ * visitor. iterating over all spring beans having some specific implementation
*/
public abstract class AbstractPropagator {
@@ -38,8 +39,9 @@
for (int i = 0; i < beanNames.length; i++) {
String beanName = beanNames[i];
if (excludeBeans == null || !excludeBeans.contains(beanName)) {
- Object bean = configurableListableBeanFactory.getBean(beanName);
- invokeLifecycleWorker(beanName, bean);
+ BeanDefinition beanDefinition = configurableListableBeanFactory.getBeanDefinition(beanName);
+ Object bean = configurableListableBeanFactory.getBean(beanName);
+ invokeLifecycleWorker(beanName, bean, beanDefinition);
}
}
}
@@ -50,6 +52,6 @@
protected abstract Class getLifecycleInterface();
- protected abstract void invokeLifecycleWorker(String beanName, Object bean);
+ protected abstract void invokeLifecycleWorker(String beanName, Object bean, BeanDefinition beanDefinition);
}
Modified: james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/lifecycle/ConfigurationPropagator.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/lifecycle/ConfigurationPropagator.java?view=diff&rev=556458&r1=556457&r2=556458
==============================================================================
--- james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/lifecycle/ConfigurationPropagator.java (original)
+++ james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/lifecycle/ConfigurationPropagator.java Sun Jul 15 14:34:46 2007
@@ -25,6 +25,7 @@
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.core.Ordered;
/**
@@ -55,7 +56,7 @@
super.postProcessBeanFactory(configurableListableBeanFactory);
}
- protected void invokeLifecycleWorker(String beanName, Object bean) {
+ protected void invokeLifecycleWorker(String beanName, Object bean, BeanDefinition beanDefinition) {
Configurable configurable = (Configurable)bean;
try {
Configuration componentConfiguration = configuration.getChild(beanName);
Modified: james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/lifecycle/ContextPropagator.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/lifecycle/ContextPropagator.java?view=diff&rev=556458&r1=556457&r2=556458
==============================================================================
--- james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/lifecycle/ContextPropagator.java (original)
+++ james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/lifecycle/ContextPropagator.java Sun Jul 15 14:34:46 2007
@@ -24,6 +24,7 @@
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.core.Ordered;
/**
@@ -43,7 +44,7 @@
return Contextualizable.class;
}
- protected void invokeLifecycleWorker(String beanName, Object bean) {
+ protected void invokeLifecycleWorker(String beanName, Object bean, BeanDefinition beanDefinition) {
Contextualizable contextualizable = (Contextualizable) bean;
try {
contextualizable.contextualize(context);
Modified: james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/lifecycle/InitializationPropagator.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/lifecycle/InitializationPropagator.java?view=diff&rev=556458&r1=556457&r2=556458
==============================================================================
--- james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/lifecycle/InitializationPropagator.java (original)
+++ james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/lifecycle/InitializationPropagator.java Sun Jul 15 14:34:46 2007
@@ -20,6 +20,7 @@
import org.apache.avalon.framework.activity.Initializable;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
+import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.core.Ordered;
/**
@@ -31,7 +32,7 @@
return Initializable.class;
}
- protected void invokeLifecycleWorker(String beanName, Object bean) {
+ protected void invokeLifecycleWorker(String beanName, Object bean, BeanDefinition beanDefinition) {
Initializable initializable = (Initializable) bean;
try {
initializable.initialize();
Modified: james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/lifecycle/LoggerPropagator.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/lifecycle/LoggerPropagator.java?view=diff&rev=556458&r1=556457&r2=556458
==============================================================================
--- james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/lifecycle/LoggerPropagator.java (original)
+++ james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/lifecycle/LoggerPropagator.java Sun Jul 15 14:34:46 2007
@@ -23,6 +23,7 @@
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
+import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.core.Ordered;
/**
@@ -42,7 +43,7 @@
return LogEnabled.class;
}
- protected void invokeLifecycleWorker(String beanName, Object bean) {
+ protected void invokeLifecycleWorker(String beanName, Object bean, BeanDefinition beanDefinition) {
LogEnabled logEnabled = (LogEnabled) bean;
logEnabled.enableLogging(loggerToComponentMapper.getComponentLogger(beanName));
}
Modified: james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/lifecycle/ServicePropagator.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/lifecycle/ServicePropagator.java?view=diff&rev=556458&r1=556457&r2=556458
==============================================================================
--- james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/lifecycle/ServicePropagator.java (original)
+++ james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/lifecycle/ServicePropagator.java Sun Jul 15 14:34:46 2007
@@ -1,9 +1,11 @@
package org.apache.james.container.spring.lifecycle;
import org.apache.avalon.framework.service.ServiceException;
+import org.apache.avalon.framework.service.ServiceManager;
import org.apache.avalon.framework.service.Serviceable;
-import org.apache.james.container.spring.adaptor.ServiceManagerBridge;
+import org.apache.james.container.spring.adaptor.ServiceManagerFactory;
import org.springframework.beans.BeansException;
+import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.core.Ordered;
@@ -13,11 +15,11 @@
*/
public class ServicePropagator extends AbstractPropagator implements BeanFactoryPostProcessor, Ordered {
- private ServiceManagerBridge serviceManager;
+ private ServiceManagerFactory serviceManagerFactory;
public void postProcessBeanFactory(ConfigurableListableBeanFactory configurableListableBeanFactory) throws BeansException {
- serviceManager = (ServiceManagerBridge) configurableListableBeanFactory.getBean("serviceManager");
+ serviceManagerFactory = (ServiceManagerFactory) configurableListableBeanFactory.getBean("serviceManager");
super.postProcessBeanFactory(configurableListableBeanFactory);
}
@@ -26,11 +28,18 @@
return Serviceable.class;
}
- protected void invokeLifecycleWorker(String beanName, Object bean) {
+ protected void invokeLifecycleWorker(String beanName, Object bean, BeanDefinition beanDefinition) {
+
Serviceable serviceable = (Serviceable) bean;
try {
- serviceable.service(serviceManager.getInstance(beanName));
+ ServiceManager serviceManager = serviceManagerFactory.getInstanceFor(beanName, beanDefinition);
+ if (serviceManager == null) {
+ throw new RuntimeException("failed to create service manager for " + beanName);
+ }
+ serviceable.service(serviceManager);
} catch (ServiceException e) {
+ throw new RuntimeException("could not successfully run service method on component of type " + serviceable.getClass(), e);
+ } catch (Exception e) {
throw new RuntimeException("could not successfully run service method on component of type " + serviceable.getClass(), e);
}
}
Modified: james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/processor/LoggerProcessor.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/processor/LoggerProcessor.java?view=diff&rev=556458&r1=556457&r2=556458
==============================================================================
--- james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/processor/LoggerProcessor.java (original)
+++ james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/processor/LoggerProcessor.java Sun Jul 15 14:34:46 2007
@@ -36,7 +36,7 @@
}
public void setLoggerToComponentMapper(LoggerToComponentMapper loggerToComponentMapper) {
- this.loggerToComponentMapper=loggerToComponentMapper;
+ this.loggerToComponentMapper = loggerToComponentMapper;
}
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
Modified: james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/processor/ServiceProcessor.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/processor/ServiceProcessor.java?view=diff&rev=556458&r1=556457&r2=556458
==============================================================================
--- james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/processor/ServiceProcessor.java (original)
+++ james/server/sandbox/spring-integration/src/main/java/org/apache/james/container/spring/processor/ServiceProcessor.java Sun Jul 15 14:34:46 2007
@@ -22,7 +22,7 @@
if (bean instanceof Serviceable && isIncluded(beanName)) {
Serviceable serviceable = (Serviceable) bean;
try {
- serviceable.service(serviceManagerBridge.getInstance(beanName));
+ serviceable.service(serviceManagerBridge.getInstanceFor(beanName, null));
} catch (ServiceException e) {
throw new RuntimeException("could not successfully run service method on component of type " + serviceable.getClass(), e);
}
Added: james/server/sandbox/spring-integration/src/main/test/org/apache/james/container/spring/adaptor/DefaultServiceManagerFactoryTestCase.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/spring-integration/src/main/test/org/apache/james/container/spring/adaptor/DefaultServiceManagerFactoryTestCase.java?view=auto&rev=556458
==============================================================================
--- james/server/sandbox/spring-integration/src/main/test/org/apache/james/container/spring/adaptor/DefaultServiceManagerFactoryTestCase.java (added)
+++ james/server/sandbox/spring-integration/src/main/test/org/apache/james/container/spring/adaptor/DefaultServiceManagerFactoryTestCase.java Sun Jul 15 14:34:46 2007
@@ -0,0 +1,161 @@
+/****************************************************************
+ * 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.adaptor;
+
+import junit.framework.TestCase;
+import org.apache.james.container.spring.beanfactory.AvalonBeanDefinition;
+import org.apache.james.container.spring.beanfactory.AvalonServiceReference;
+import org.apache.avalon.framework.service.ServiceManager;
+import org.apache.avalon.framework.service.ServiceException;
+import org.springframework.util.ClassUtils;
+import org.springframework.context.support.AbstractRefreshableApplicationContext;
+import org.springframework.beans.factory.support.DefaultListableBeanFactory;
+import org.springframework.beans.factory.support.RootBeanDefinition;
+import org.springframework.beans.factory.config.BeanDefinition;
+import org.springframework.beans.BeansException;
+
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Iterator;
+
+/**
+ */
+public class DefaultServiceManagerFactoryTestCase extends TestCase {
+
+ private class TestApplicationContext extends AbstractRefreshableApplicationContext {
+
+ private HashMap beannameToDefinitionMap = new HashMap();
+
+ public void addBean(String beanName, BeanDefinition beanDefinition) {
+ beannameToDefinitionMap.put(beanName, beanDefinition);
+ }
+
+ protected void loadBeanDefinitions(DefaultListableBeanFactory defaultListableBeanFactory) throws IOException, BeansException {
+ Iterator iterator = beannameToDefinitionMap.keySet().iterator();
+ while (iterator.hasNext()) {
+ String beanname = (String) iterator.next();
+ BeanDefinition beanDefinition = (BeanDefinition) beannameToDefinitionMap.get(beanname);
+ defaultListableBeanFactory.registerBeanDefinition(beanname, beanDefinition);
+ }
+ }
+ }
+
+ public void testTrivialCase() throws ClassNotFoundException {
+ AvalonBeanDefinition definition = new AvalonBeanDefinition();
+
+ DefaultServiceManagerFactory managerFactory = new DefaultServiceManagerFactory();
+ managerFactory.setApplicationContext(new TestApplicationContext());
+ ServiceManager manager = managerFactory.getInstanceFor("referencesNothingBean", definition);
+ assertNotNull(manager);
+ }
+
+ public void testRejectNonAvalonBeanDefs() throws ClassNotFoundException {
+ BeanDefinition definition = new RootBeanDefinition();
+
+ DefaultServiceManagerFactory managerFactory = new DefaultServiceManagerFactory();
+ managerFactory.setApplicationContext(new TestApplicationContext());
+ ServiceManager manager = managerFactory.getInstanceFor("referencesNothingBean", definition);
+ assertNull(manager);
+ }
+
+ public void testReferenceResolving() throws ClassNotFoundException, ServiceException {
+
+ // bean "referencingBean" of type Date references bean "referenced" of type StringBuffer
+
+ AvalonBeanDefinition referencingBeanDefinition = new AvalonBeanDefinition();
+ referencingBeanDefinition.setBeanClass(ClassUtils.forName("java.util.Date", getClass().getClassLoader()));
+ referencingBeanDefinition.addServiceReference(new AvalonServiceReference("referenced", "java.lang.StringBuffer"));
+
+ RootBeanDefinition referencedBeanDefinition = new RootBeanDefinition();
+ referencedBeanDefinition.setBeanClass(ClassUtils.forName("java.lang.StringBuffer", getClass().getClassLoader()));
+
+ TestApplicationContext testApplicationContext = new TestApplicationContext();
+ testApplicationContext.addBean("referenced", referencedBeanDefinition);
+ testApplicationContext.refresh();
+
+ DefaultServiceManagerFactory managerFactory = new DefaultServiceManagerFactory();
+ managerFactory.setApplicationContext(testApplicationContext);
+ ServiceManager manager = managerFactory.getInstanceFor("referencingBean", referencingBeanDefinition);
+ assertNotNull(manager);
+ Object referencedInstance = manager.lookup("java.lang.StringBuffer");
+ assertNotNull(referencedInstance);
+ assertTrue(referencedInstance instanceof StringBuffer);
+ }
+
+ public void testRolenameCheck() throws ClassNotFoundException, ServiceException {
+
+ AvalonBeanDefinition referencingBeanDefinition = new AvalonBeanDefinition();
+ referencingBeanDefinition.setBeanClass(ClassUtils.forName("java.util.Date", getClass().getClassLoader()));
+ referencingBeanDefinition.addServiceReference(new AvalonServiceReference("referenced1", "java.lang.StringBuffer"));
+ referencingBeanDefinition.addServiceReference(new AvalonServiceReference("referenced2", "java.lang.StringBuffer"));
+
+ RootBeanDefinition referencedBeanDefinition1 = new RootBeanDefinition();
+ referencedBeanDefinition1.setBeanClass(ClassUtils.forName("java.lang.StringBuffer", getClass().getClassLoader()));
+
+ RootBeanDefinition referencedBeanDefinition2 = new RootBeanDefinition();
+ referencedBeanDefinition2.setBeanClass(ClassUtils.forName("java.lang.StringBuffer", getClass().getClassLoader()));
+
+ TestApplicationContext testApplicationContext = new TestApplicationContext();
+ testApplicationContext.addBean("referenced1", referencedBeanDefinition1);
+ testApplicationContext.addBean("referenced2", referencedBeanDefinition2);
+ testApplicationContext.refresh();
+
+
+ DefaultServiceManagerFactory managerFactory = new DefaultServiceManagerFactory();
+ managerFactory.setApplicationContext(testApplicationContext);
+ try {
+ ServiceManager manager = managerFactory.getInstanceFor("referencingBean", referencingBeanDefinition);
+ fail("must throw exception");
+ } catch (Exception e) {
+ assertTrue("cannot have 2 references of same type!", true);
+ }
+ }
+
+ public void testTwoRoles() throws ClassNotFoundException, ServiceException {
+
+ AvalonBeanDefinition referencingBeanDefinition = new AvalonBeanDefinition();
+ referencingBeanDefinition.setBeanClass(ClassUtils.forName("java.util.Date", getClass().getClassLoader()));
+ referencingBeanDefinition.addServiceReference(new AvalonServiceReference("referenced1", "java.lang.StringBuffer"));
+ referencingBeanDefinition.addServiceReference(new AvalonServiceReference("referenced2", "java.util.Random"));
+
+ RootBeanDefinition referencedBeanDefinition1 = new RootBeanDefinition();
+ referencedBeanDefinition1.setBeanClass(ClassUtils.forName("java.lang.StringBuffer", getClass().getClassLoader()));
+
+ RootBeanDefinition referencedBeanDefinition2 = new RootBeanDefinition();
+ referencedBeanDefinition2.setBeanClass(ClassUtils.forName("java.util.Random", getClass().getClassLoader()));
+
+ TestApplicationContext testApplicationContext = new TestApplicationContext();
+ testApplicationContext.addBean("referenced1", referencedBeanDefinition1);
+ testApplicationContext.addBean("referenced2", referencedBeanDefinition2);
+ testApplicationContext.refresh();
+
+
+ DefaultServiceManagerFactory managerFactory = new DefaultServiceManagerFactory();
+ managerFactory.setApplicationContext(testApplicationContext);
+ ServiceManager manager = managerFactory.getInstanceFor("referencingBean", referencingBeanDefinition);
+ assertNotNull(manager);
+ Object referencedInstance1 = manager.lookup("java.lang.StringBuffer");
+ assertNotNull(referencedInstance1);
+ assertTrue(referencedInstance1 instanceof StringBuffer);
+
+ Object referencedInstance2 = manager.lookup("java.util.Random");
+ assertNotNull(referencedInstance2);
+ assertTrue(referencedInstance2 instanceof java.util.Random);
+ }
+}
Added: james/server/sandbox/spring-integration/src/main/test/org/apache/james/container/spring/beanfactory/AvalonApplicationContextTestCase.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/spring-integration/src/main/test/org/apache/james/container/spring/beanfactory/AvalonApplicationContextTestCase.java?view=auto&rev=556458
==============================================================================
--- james/server/sandbox/spring-integration/src/main/test/org/apache/james/container/spring/beanfactory/AvalonApplicationContextTestCase.java (added)
+++ james/server/sandbox/spring-integration/src/main/test/org/apache/james/container/spring/beanfactory/AvalonApplicationContextTestCase.java Sun Jul 15 14:34:46 2007
@@ -0,0 +1,36 @@
+/****************************************************************
+ * 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.beanfactory;
+
+import org.springframework.core.io.ClassPathResource;
+import org.springframework.core.io.Resource;
+import org.apache.james.James;
+import junit.framework.TestCase;
+
+/**
+ */
+public class AvalonApplicationContextTestCase extends TestCase {
+
+ public void testJointLoadingContainerAndApplicationConfig() {
+ Resource containerResource = new ClassPathResource("beans-base-config.xml");
+ Resource applicationResource = new ClassPathResource("org/apache/james/container/spring/beanfactory/james-assembly.xml");
+ AvalonApplicationContext context = new AvalonApplicationContext(containerResource, applicationResource);
+ James james = (James)context.getBean("James");
+ }
+}
Added: james/server/sandbox/spring-integration/src/main/test/org/apache/james/container/spring/beanfactory/BeanFactoryTestCase.java
URL: http://svn.apache.org/viewvc/james/server/sandbox/spring-integration/src/main/test/org/apache/james/container/spring/beanfactory/BeanFactoryTestCase.java?view=auto&rev=556458
==============================================================================
--- james/server/sandbox/spring-integration/src/main/test/org/apache/james/container/spring/beanfactory/BeanFactoryTestCase.java (added)
+++ james/server/sandbox/spring-integration/src/main/test/org/apache/james/container/spring/beanfactory/BeanFactoryTestCase.java Sun Jul 15 14:34:46 2007
@@ -0,0 +1,42 @@
+/****************************************************************
+ * 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.beanfactory;
+
+import junit.framework.TestCase;
+import org.springframework.context.support.GenericApplicationContext;
+import org.springframework.core.io.ClassPathResource;
+import org.apache.james.James;
+
+/**
+ */
+public class BeanFactoryTestCase extends TestCase {
+
+ public void testAvalonBeanDefinitionXMLReader() {
+ GenericApplicationContext ctx = new GenericApplicationContext();
+
+ AvalonBeanDefinitionReader xmlReader = new AvalonBeanDefinitionReader(ctx);
+ int count = xmlReader.loadBeanDefinitions(new ClassPathResource("org/apache/james/container/spring/beanfactory/james-assembly.xml"));
+// assertTrue("all blocks loaded", count == 34);
+
+ ctx.refresh();
+ James james = (James)ctx.getBean("James");
+ assertNotNull("James bean definition", james);
+ }
+
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org
Re: svn commit: r556458 [1/2] - in /james/server/sandbox/spring-integration:
./ src/main/config/ src/main/java/org/apache/james/container/spring/ src/main/java/org/apache/james/container/spring/adaptor/
src/main/java/org/apache/james/container/spring/beanf...
Posted by Stefano Bagnara <ap...@bago.org>.
berndf@apache.org ha scritto:
> Author: berndf
> Date: Sun Jul 15 14:34:46 2007
> New Revision: 556458
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=556458
> Log:
> - read james-assembly.xml and build own spring application context from contained components
> - add unit tests
> - add ant build
Cool stuff Bernd!
I'm looking forward to see this code as a server module now that we have
a modular build system!
And I think that around the world other Avalon based projects would be
happy to reuse some of your work!
Stefano
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org