@Test(expected = IllegalArgumentException.class) public void testFactoryRejectsNonConnectionFactorySet() throws Exception { cf.setConnectionFactory(""); }
public void setConnectionFactory(final Object factory) { if (factory instanceof ConnectionFactory) { String logMessage = "JMS ConnectionFactory on classpath is not a JMS 2.0+ version."; try { ConnectionFactory.class.getMethod("createContext", int.class); logMessage = "Provided ConnectionFactory implementation is not JMS 2.0+ capable."; factory.getClass().getMethod("createContext", int.class); logMessage = "Provided ConnectionFactory implementation is JMS 2.0+ capable."; jmsContextSupported = true; } catch (NoSuchMethodException | SecurityException e) { } finally { LOG.info(logMessage); } this.connectionFactory = factory; } else { throw new IllegalArgumentException("connectionFactory should implement javax.jms.ConnectionFactory"); } }
JmsPoolConnectionFactory implements ConnectionFactory, QueueConnectionFactory, TopicConnectionFactory { public void setConnectionFactory(final Object factory) { if (factory instanceof ConnectionFactory) { String logMessage = "JMS ConnectionFactory on classpath is not a JMS 2.0+ version."; try { ConnectionFactory.class.getMethod("createContext", int.class); logMessage = "Provided ConnectionFactory implementation is not JMS 2.0+ capable."; factory.getClass().getMethod("createContext", int.class); logMessage = "Provided ConnectionFactory implementation is JMS 2.0+ capable."; jmsContextSupported = true; } catch (NoSuchMethodException | SecurityException e) { } finally { LOG.info(logMessage); } this.connectionFactory = factory; } else { throw new IllegalArgumentException("connectionFactory should implement javax.jms.ConnectionFactory"); } } }
JmsPoolConnectionFactory implements ConnectionFactory, QueueConnectionFactory, TopicConnectionFactory { public void setConnectionFactory(final Object factory) { if (factory instanceof ConnectionFactory) { String logMessage = "JMS ConnectionFactory on classpath is not a JMS 2.0+ version."; try { ConnectionFactory.class.getMethod("createContext", int.class); logMessage = "Provided ConnectionFactory implementation is not JMS 2.0+ capable."; factory.getClass().getMethod("createContext", int.class); logMessage = "Provided ConnectionFactory implementation is JMS 2.0+ capable."; jmsContextSupported = true; } catch (NoSuchMethodException | SecurityException e) { } finally { LOG.info(logMessage); } this.connectionFactory = factory; } else { throw new IllegalArgumentException("connectionFactory should implement javax.jms.ConnectionFactory"); } }  }
JmsPoolConnectionFactory implements ConnectionFactory, QueueConnectionFactory, TopicConnectionFactory { public void setConnectionFactory(final Object factory) { if (factory instanceof ConnectionFactory) { String logMessage = "JMS ConnectionFactory on classpath is not a JMS 2.0+ version."; try { ConnectionFactory.class.getMethod("createContext", int.class); logMessage = "Provided ConnectionFactory implementation is not JMS 2.0+ capable."; factory.getClass().getMethod("createContext", int.class); logMessage = "Provided ConnectionFactory implementation is JMS 2.0+ capable."; jmsContextSupported = true; } catch (NoSuchMethodException | SecurityException e) { } finally { LOG.info(logMessage); } this.connectionFactory = factory; } else { throw new IllegalArgumentException("connectionFactory should implement javax.jms.ConnectionFactory"); } }  void initConnectionsPool(); Object getConnectionFactory(); void setConnectionFactory(final Object factory); @Override QueueConnection createQueueConnection(); @Override QueueConnection createQueueConnection(String userName, String password); @Override TopicConnection createTopicConnection(); @Override TopicConnection createTopicConnection(String userName, String password); @Override Connection createConnection(); @Override Connection createConnection(String userName, String password); @Override JMSContext createContext(); @Override JMSContext createContext(int sessionMode); @Override JMSContext createContext(String username, String password); @Override JMSContext createContext(String username, String password, int sessionMode); void start(); void stop(); void clear(); int getMaxSessionsPerConnection(); void setMaxSessionsPerConnection(int maxSessionsPerConnection); void setBlockIfSessionPoolIsFull(boolean block); boolean isBlockIfSessionPoolIsFull(); int getMaxConnections(); void setMaxConnections(int maxConnections); int getConnectionIdleTimeout(); void setConnectionIdleTimeout(int connectionIdleTimeout); boolean isUseAnonymousProducers(); void setUseAnonymousProducers(boolean value); int getExplicitProducerCacheSize(); void setExplicitProducerCacheSize(int cacheSize); void setConnectionCheckInterval(long connectionCheckInterval); long getConnectionCheckInterval(); int getNumConnections(); long getBlockIfSessionPoolIsFullTimeout(); void setBlockIfSessionPoolIsFullTimeout(long blockIfSessionPoolIsFullTimeout); boolean isUseProviderJMSContext(); void setUseProviderJMSContext(boolean useProviderJMSContext); }
JmsPoolConnectionFactory implements ConnectionFactory, QueueConnectionFactory, TopicConnectionFactory { public void setConnectionFactory(final Object factory) { if (factory instanceof ConnectionFactory) { String logMessage = "JMS ConnectionFactory on classpath is not a JMS 2.0+ version."; try { ConnectionFactory.class.getMethod("createContext", int.class); logMessage = "Provided ConnectionFactory implementation is not JMS 2.0+ capable."; factory.getClass().getMethod("createContext", int.class); logMessage = "Provided ConnectionFactory implementation is JMS 2.0+ capable."; jmsContextSupported = true; } catch (NoSuchMethodException | SecurityException e) { } finally { LOG.info(logMessage); } this.connectionFactory = factory; } else { throw new IllegalArgumentException("connectionFactory should implement javax.jms.ConnectionFactory"); } }  void initConnectionsPool(); Object getConnectionFactory(); void setConnectionFactory(final Object factory); @Override QueueConnection createQueueConnection(); @Override QueueConnection createQueueConnection(String userName, String password); @Override TopicConnection createTopicConnection(); @Override TopicConnection createTopicConnection(String userName, String password); @Override Connection createConnection(); @Override Connection createConnection(String userName, String password); @Override JMSContext createContext(); @Override JMSContext createContext(int sessionMode); @Override JMSContext createContext(String username, String password); @Override JMSContext createContext(String username, String password, int sessionMode); void start(); void stop(); void clear(); int getMaxSessionsPerConnection(); void setMaxSessionsPerConnection(int maxSessionsPerConnection); void setBlockIfSessionPoolIsFull(boolean block); boolean isBlockIfSessionPoolIsFull(); int getMaxConnections(); void setMaxConnections(int maxConnections); int getConnectionIdleTimeout(); void setConnectionIdleTimeout(int connectionIdleTimeout); boolean isUseAnonymousProducers(); void setUseAnonymousProducers(boolean value); int getExplicitProducerCacheSize(); void setExplicitProducerCacheSize(int cacheSize); void setConnectionCheckInterval(long connectionCheckInterval); long getConnectionCheckInterval(); int getNumConnections(); long getBlockIfSessionPoolIsFullTimeout(); void setBlockIfSessionPoolIsFullTimeout(long blockIfSessionPoolIsFullTimeout); boolean isUseProviderJMSContext(); void setUseProviderJMSContext(boolean useProviderJMSContext); static final int DEFAULT_MAX_CONNECTIONS; }