/** * Stops the ResourceAdapter. * @see javax.resource.spi.ResourceAdapter#stop() */ @Override public void destroy() { if (this.resourceAdapter != null) { this.resourceAdapter.stop(); } }
@Override public void afterPropertiesSet() throws ResourceException { if (this.managedConnectionFactory == null) { throw new IllegalArgumentException("Property 'managedConnectionFactory' is required"); } if (this.connectionManager != null) { this.connectionFactory = this.managedConnectionFactory.createConnectionFactory(this.connectionManager); } else { this.connectionFactory = this.managedConnectionFactory.createConnectionFactory(); } }
/** * Specify the JCA BootstrapContext that contains the * WorkManager to delegate to. */ @Override public void setBootstrapContext(BootstrapContext bootstrapContext) { Assert.notNull(bootstrapContext, "BootstrapContext must not be null"); this.workManager = bootstrapContext.getWorkManager(); }
/** * Prepares the message endpoint, and automatically activates it * if the "autoStartup" flag is set to "true". */ @Override public void afterPropertiesSet() throws ResourceException { if (getResourceAdapter() == null) { throw new IllegalArgumentException("Property 'resourceAdapter' is required"); } if (getMessageEndpointFactory() == null) { throw new IllegalArgumentException("Property 'messageEndpointFactory' is required"); } ActivationSpec activationSpec = getActivationSpec(); if (activationSpec == null) { throw new IllegalArgumentException("Property 'activationSpec' is required"); } if (activationSpec.getResourceAdapter() == null) { activationSpec.setResourceAdapter(getResourceAdapter()); } else if (activationSpec.getResourceAdapter() != getResourceAdapter()) { throw new IllegalArgumentException("ActivationSpec [" + activationSpec + "] is associated with a different ResourceAdapter: " + activationSpec.getResourceAdapter()); } }
/** * Deactivates the configured message endpoint. */ @Override public void stop() { synchronized (this.lifecycleMonitor) { if (this.running) { ResourceAdapter resourceAdapter = getResourceAdapter(); Assert.state(resourceAdapter != null, "No ResourceAdapter set"); resourceAdapter.endpointDeactivation(getMessageEndpointFactory(), getActivationSpec()); this.running = false; } } }
@Override public Xid[] recover(int flag) throws XAException { return contextXATerminator.recover(flag); }
/** * Activates the configured message endpoint. */ @Override public void start() { synchronized (this.lifecycleMonitor) { if (!this.running) { ResourceAdapter resourceAdapter = getResourceAdapter(); Assert.state(resourceAdapter != null, "No ResourceAdapter set"); try { resourceAdapter.endpointActivation(getMessageEndpointFactory(), getActivationSpec()); } catch (ResourceException ex) { throw new IllegalStateException("Could not activate message endpoint", ex); } this.running = true; } } }
/** * Builds the BootstrapContext and starts the ResourceAdapter with it. * @see javax.resource.spi.ResourceAdapter#start(javax.resource.spi.BootstrapContext) */ @Override public void afterPropertiesSet() throws ResourceException { if (this.resourceAdapter == null) { throw new IllegalArgumentException("'resourceAdapter' or 'resourceAdapterClass' is required"); } if (this.bootstrapContext == null) { this.bootstrapContext = new SimpleBootstrapContext(this.workManager, this.xaTerminator); } this.resourceAdapter.start(this.bootstrapContext); }
@Override public void commit(Xid xid, boolean onePhase) throws XAException { contextXATerminator.commit(xid, onePhase); }
public void forget(final Xid xid) throws XAException { xaTerminator.forget(xid); } };
@Override public int prepare(Xid xid) throws XAException { return contextXATerminator.prepare(xid); }
@Override public void rollback(Xid xid) throws XAException { contextXATerminator.rollback(xid); }
@Override public void afterPropertiesSet() throws ResourceException { if (this.managedConnectionFactory == null) { throw new IllegalArgumentException("Property 'managedConnectionFactory' is required"); } if (this.connectionManager != null) { this.connectionFactory = this.managedConnectionFactory.createConnectionFactory(this.connectionManager); } else { this.connectionFactory = this.managedConnectionFactory.createConnectionFactory(); } }
/** * Specify the JCA BootstrapContext that contains the * WorkManager to delegate to. */ @Override public void setBootstrapContext(BootstrapContext bootstrapContext) { Assert.notNull(bootstrapContext, "BootstrapContext must not be null"); this.workManager = bootstrapContext.getWorkManager(); }
/** * Stops the ResourceAdapter. * @see javax.resource.spi.ResourceAdapter#stop() */ @Override public void destroy() { if (this.resourceAdapter != null) { this.resourceAdapter.stop(); } }
public Xid[] recover(final int flag, final String parentName) throws XAException { return xaTerminator.recover(flag); }
public void commit(final Xid xid, final boolean onePhase) throws XAException { xaTerminator.commit(xid, onePhase); }
@Override public void forget(Xid xid) throws XAException { contextXATerminator.forget(xid); }
@Test public void testCreatesManagedConnectionFactoryIfAConnectionManagerHasBeenConfigured() throws Exception { ManagedConnectionFactory managedConnectionFactory = mock(ManagedConnectionFactory.class); ConnectionManager connectionManager = mock(ConnectionManager.class); LocalConnectionFactoryBean factory = new LocalConnectionFactoryBean(); factory.setManagedConnectionFactory(managedConnectionFactory); factory.setConnectionManager(connectionManager); factory.afterPropertiesSet(); verify(managedConnectionFactory).createConnectionFactory(connectionManager); }
@Test public void testCreatesVanillaConnectionFactoryIfNoConnectionManagerHasBeenConfigured() throws Exception { final Object CONNECTION_FACTORY = new Object(); ManagedConnectionFactory managedConnectionFactory = mock(ManagedConnectionFactory.class); given(managedConnectionFactory.createConnectionFactory()).willReturn(CONNECTION_FACTORY); LocalConnectionFactoryBean factory = new LocalConnectionFactoryBean(); factory.setManagedConnectionFactory(managedConnectionFactory); factory.afterPropertiesSet(); assertEquals(CONNECTION_FACTORY, factory.getObject()); }