Index: modules/pvm/src/main/java/org/jbpm/pvm/internal/processengine/SpringProcessEngine.java =================================================================== --- modules/pvm/src/main/java/org/jbpm/pvm/internal/processengine/SpringProcessEngine.java (revision 6377) +++ modules/pvm/src/main/java/org/jbpm/pvm/internal/processengine/SpringProcessEngine.java (working copy) @@ -36,23 +36,23 @@ /** * this environment factory will see only the singleton beans. - * + * * The created {@link SpringEnvironment}s will see the prototype beans and it * will cache them. - * + * * @author Andries Inze */ public class SpringProcessEngine extends ProcessEngineImpl implements EnvironmentFactory, ProcessEngine { private static final Log log = Log.getLog(SpringProcessEngine.class.getName()); - + private static final long serialVersionUID = 1L; private ApplicationContext applicationContext; public static ProcessEngine create(ConfigurationImpl configuration) { SpringProcessEngine springProcessEngine = null; - + ApplicationContext applicationContext = null; if (configuration.isInstantiatedFromSpring()) { applicationContext = (ApplicationContext) configuration.getApplicationContext(); @@ -66,7 +66,7 @@ springProcessEngine.processEngineWireContext .getWireDefinition() .addDescriptor(new ProvidedObjectDescriptor(hibernateConfiguration, true)); - + springProcessEngine.checkDb(configuration); } else { @@ -77,7 +77,7 @@ applicationContext = new ClassPathXmlApplicationContext(springCfg); springProcessEngine = (SpringProcessEngine) applicationContext.getBean("processEngine"); } - + return springProcessEngine; } @@ -99,18 +99,24 @@ @SuppressWarnings("unchecked") @Override public T get(Class type) { + T candidateComponent = super.get(type); + + if (candidateComponent != null) { + return candidateComponent; + } + String[] names = applicationContext.getBeanNamesForType(type); - + if (names.length >= 1) { - + if (names.length > 1 && log.isWarnEnabled()) { log.warn("Multiple beans for type " + type + " found. Returning the first result."); } - + return (T) applicationContext.getBean(names[0]); } - return super.get(type); + return null; } @Override Index: modules/test-cfg/src/test/java/org/jbpm/test/spring/circularreference/CircularReferenceTest.java =================================================================== --- modules/test-cfg/src/test/java/org/jbpm/test/spring/circularreference/CircularReferenceTest.java (revision 0) +++ modules/test-cfg/src/test/java/org/jbpm/test/spring/circularreference/CircularReferenceTest.java (revision 0) @@ -0,0 +1,35 @@ +/* + * JBoss, Home of Professional Open Source + * Copyright 2005, JBoss Inc., and individual contributors as indicated + * by the @authors tag. See the copyright.txt in the distribution for a + * full listing of individual contributors. + * + * This is free software; you can redistribute it and/or modify it + * under the terms of the GNU Lesser General Public License as + * published by the Free Software Foundation; either version 2.1 of + * the License, or (at your option) any later version. + * + * This software is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this software; if not, write to the Free + * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA + * 02110-1301 USA, or see the FSF site: http://www.fsf.org. + */ +package org.jbpm.test.spring.circularreference; + +import java.util.HashMap; +import java.util.Map; + +import org.jbpm.api.JbpmException; +import org.jbpm.api.ProcessInstance; +import org.jbpm.test.AbstractTransactionalSpringJbpmTestCase; + +public class CircularReferenceTest extends AbstractTransactionalSpringJbpmTestCase { + public void testGetRepositoryService() { + assertNotNull(repositoryService); + } +} Index: modules/test-cfg/src/test/resources/org/jbpm/test/spring/circularreference/applicationContext.xml =================================================================== --- modules/test-cfg/src/test/resources/org/jbpm/test/spring/circularreference/applicationContext.xml (revision 0) +++ modules/test-cfg/src/test/resources/org/jbpm/test/spring/circularreference/applicationContext.xml (revision 0) @@ -0,0 +1,38 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + Index: modules/test-cfg/src/test/resources/org/jbpm/test/spring/circularreference/jbpm.cfg.xml =================================================================== --- modules/test-cfg/src/test/resources/org/jbpm/test/spring/circularreference/jbpm.cfg.xml (revision 0) +++ modules/test-cfg/src/test/resources/org/jbpm/test/spring/circularreference/jbpm.cfg.xml (revision 0) @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + Index: modules/test-cfg/src/test/resources/org/jbpm/test/spring/circularreference/jbpm.hibernate.cfg.xml =================================================================== --- modules/test-cfg/src/test/resources/org/jbpm/test/spring/circularreference/jbpm.hibernate.cfg.xml (revision 0) +++ modules/test-cfg/src/test/resources/org/jbpm/test/spring/circularreference/jbpm.hibernate.cfg.xml (revision 0) @@ -0,0 +1,22 @@ + + + + + + + + org.hibernate.dialect.HSQLDialect + true + + create-drop + + + + + + + + + Index: modules/test-cfg/src/test/resources/org/jbpm/test/spring/circularreference/log4j.properties =================================================================== --- modules/test-cfg/src/test/resources/org/jbpm/test/spring/circularreference/log4j.properties (revision 0) +++ modules/test-cfg/src/test/resources/org/jbpm/test/spring/circularreference/log4j.properties (revision 0) @@ -0,0 +1,4 @@ +log4j.appender.stdout=org.apache.log4j.ConsoleAppender +log4j.appender.stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %c{1}:%L - %m%n +log4j.rootLogger=info, stdout