@Override public JMSSpecificContext createChildContext(Mode mode) { return new JMSContext(this.jmsConnection, broker(), mode, isRemote(), this); }
@Override public void acknowledge() { JMSContext.this.acknowledge(); }
@Override public void addCloseable(Object closeable) { JMSContext.this.addCloseable(closeable); }
@Override public void afterCompletion(int status) { try { super.close(); } catch (Exception e) { throw new RuntimeException("Error after tx complete", e); } }
@Override public void closeCloseables() throws Exception { JMSContext.this.closeCloseables(); }
@Override public void commit() { JMSContext.this.commit(); }
@Override public boolean enlist() throws Exception { return JMSContext.this.enlist(); }
@Override public Messaging broker() { return JMSContext.this.broker(); }
@Override public JMSSpecificContext createChildContext(Mode mode) { return JMSContext.this.createChildContext(mode); }
@Override public Object call() throws Exception { jmsConnection.start(); return createJMSSession(); } });
protected JMSSpecificContext createContext(final ConnectionFactory cf, final Options<CreateContextOption> options) { Connection connection = (Connection) DestinationUtil.mightThrow(new Callable() { @Override public Object call() throws Exception { Connection connection; if (options.has(CreateContextOption.USERNAME)) { connection = cf.createConnection(options.getString(CreateContextOption.USERNAME), options.getString(CreateContextOption.PASSWORD)); } else { connection = cf.createConnection(); } return connection; } }); return new JMSContext(connection, this, (Context.Mode)options.get(CreateContextOption.MODE), options.has(CreateContextOption.HOST)); }
@Override public void close() throws Exception { if (!closed) { closed = true; if (TransactionUtil.isTransactionActive()) { TransactionUtil.tm.getTransaction().registerSynchronization(this); } else { super.close(); } } }
@Override public void close() throws Exception { closeCloseables(); }
@Override public Session jmsSession() { if (this.jmsSession == null) { this.jmsSession = (Session) DestinationUtil.mightThrow(new Callable() { @Override public Object call() throws Exception { jmsConnection.start(); return createJMSSession(); } }); addCloseable(this.jmsSession); } return this.jmsSession; }
public JMSContext(final Connection jmsConnection, final Messaging broker, final Mode mode, final boolean remote, final JMSSpecificContext parent) { this.mode = mode; this.id = UUID.randomUUID().toString(); this.parentContext = parent; this.broker = broker; this.remote = remote; this.jmsConnection = jmsConnection; if (parentContext != null) { parentContext.addCloseable(this); } else { addCloseable(jmsConnection); } }