@ -27,6 +27,7 @@ import org.hornetq.core.remoting.impl.invm.InVMConnectorFactory;
import org.hornetq.core.remoting.impl.netty.NettyConnectorFactory ;
import org.hornetq.core.remoting.impl.netty.NettyConnectorFactory ;
import org.hornetq.core.remoting.impl.netty.TransportConstants ;
import org.hornetq.core.remoting.impl.netty.TransportConstants ;
import org.hornetq.jms.client.HornetQConnectionFactory ;
import org.hornetq.jms.client.HornetQConnectionFactory ;
import org.springframework.beans.factory.ListableBeanFactory ;
import org.springframework.util.Assert ;
import org.springframework.util.Assert ;
import org.springframework.util.ClassUtils ;
import org.springframework.util.ClassUtils ;
@ -44,14 +45,20 @@ class HornetQConnectionFactoryFactory {
private final HornetQProperties properties ;
private final HornetQProperties properties ;
public HornetQConnectionFactoryFactory ( HornetQProperties properties ) {
private final ListableBeanFactory beanFactory ;
public HornetQConnectionFactoryFactory ( ListableBeanFactory beanFactory ,
HornetQProperties properties ) {
Assert . notNull ( beanFactory , "BeanFactory must not be null" ) ;
Assert . notNull ( properties , "Properties must not be null" ) ;
Assert . notNull ( properties , "Properties must not be null" ) ;
this . beanFactory = beanFactory ;
this . properties = properties ;
this . properties = properties ;
}
}
public < T extends HornetQConnectionFactory > T createConnectionFactory (
public < T extends HornetQConnectionFactory > T createConnectionFactory (
Class < T > factoryClass ) {
Class < T > factoryClass ) {
try {
try {
startEmbededJms ( ) ;
return doCreateConnectionFactory ( factoryClass ) ;
return doCreateConnectionFactory ( factoryClass ) ;
}
}
catch ( Exception ex ) {
catch ( Exception ex ) {
@ -60,6 +67,17 @@ class HornetQConnectionFactoryFactory {
}
}
}
}
private void startEmbededJms ( ) {
if ( ClassUtils . isPresent ( EMBEDDED_JMS_CLASS , null ) ) {
try {
this . beanFactory . getBeansOfType ( Class . forName ( EMBEDDED_JMS_CLASS ) ) ;
}
catch ( Exception ex ) {
// Ignore
}
}
}
private < T extends HornetQConnectionFactory > T doCreateConnectionFactory (
private < T extends HornetQConnectionFactory > T doCreateConnectionFactory (
Class < T > factoryClass ) throws Exception {
Class < T > factoryClass ) throws Exception {
HornetQMode mode = this . properties . getMode ( ) ;
HornetQMode mode = this . properties . getMode ( ) ;