/** * Create a message listener container for the given {@link JmsListenerEndpoint}. * <p>This create the necessary infrastructure to honor that endpoint * with regards to its configuration. * <p>The {@code startImmediately} flag determines if the container should be * started immediately. * @param endpoint the endpoint to add * @param factory the listener factory to use * @param startImmediately start the container immediately if necessary * @see #getListenerContainers() * @see #getListenerContainer(String) */ public void registerListenerContainer(JmsListenerEndpoint endpoint, JmsListenerContainerFactory<?> factory, boolean startImmediately) { Assert.notNull(endpoint, "Endpoint must not be null"); Assert.notNull(factory, "Factory must not be null"); String id = endpoint.getId(); Assert.hasText(id, "Endpoint id must be set"); synchronized (this.listenerContainers) { if (this.listenerContainers.containsKey(id)) { throw new IllegalStateException("Another endpoint is already registered with id '" + id + "'"); } MessageListenerContainer container = createListenerContainer(endpoint, factory); this.listenerContainers.put(id, container); if (startImmediately) { startIfNecessary(container); } } }
@Override public JmsMessageEndpointManager createListenerContainer(JmsListenerEndpoint endpoint) { if (this.destinationResolver != null && this.activationSpecFactory != null) { throw new IllegalStateException("Specify either 'activationSpecFactory' or " + "'destinationResolver', not both. If you define a dedicated JmsActivationSpecFactory bean, " + "specify the custom DestinationResolver there (if possible)"); } JmsMessageEndpointManager instance = createContainerInstance(); if (this.resourceAdapter != null) { instance.setResourceAdapter(this.resourceAdapter); } if (this.activationSpecFactory != null) { instance.setActivationSpecFactory(this.activationSpecFactory); } if (this.destinationResolver != null) { instance.setDestinationResolver(this.destinationResolver); } if (this.transactionManager != null) { instance.setTransactionManager(this.transactionManager); } if (this.phase != null) { instance.setPhase(this.phase); } instance.setActivationSpecConfig(this); endpoint.setupListenerContainer(instance); return instance; }
/** * Register a new {@link JmsListenerEndpoint} alongside the * {@link JmsListenerContainerFactory} to use to create the underlying container. * <p>The {@code factory} may be {@code null} if the default factory has to be * used for that endpoint. */ public void registerEndpoint(JmsListenerEndpoint endpoint, @Nullable JmsListenerContainerFactory<?> factory) { Assert.notNull(endpoint, "Endpoint must not be null"); Assert.hasText(endpoint.getId(), "Endpoint id must be set"); // Factory may be null, we defer the resolution right before actually creating the container JmsListenerEndpointDescriptor descriptor = new JmsListenerEndpointDescriptor(endpoint, factory); synchronized (this.mutex) { if (this.startImmediately) { // register and start immediately Assert.state(this.endpointRegistry != null, "No JmsListenerEndpointRegistry set"); this.endpointRegistry.registerListenerContainer(descriptor.endpoint, resolveContainerFactory(descriptor), true); } else { this.endpointDescriptors.add(descriptor); } } }
endpoint.setupListenerContainer(instance);
@Override public MessageListenerTestContainer createListenerContainer(JmsListenerEndpoint endpoint) { MessageListenerTestContainer container = new MessageListenerTestContainer(endpoint); container.setAutoStartup(this.autoStartup); this.listenerContainers.put(endpoint.getId(), container); return container; }
@Override public JmsMessageEndpointManager createListenerContainer(JmsListenerEndpoint endpoint) { if (this.destinationResolver != null && this.activationSpecFactory != null) { throw new IllegalStateException("Specify either 'activationSpecFactory' or " + "'destinationResolver', not both. If you define a dedicated JmsActivationSpecFactory bean, " + "specify the custom DestinationResolver there (if possible)"); } JmsMessageEndpointManager instance = createContainerInstance(); if (this.resourceAdapter != null) { instance.setResourceAdapter(this.resourceAdapter); } if (this.activationSpecFactory != null) { instance.setActivationSpecFactory(this.activationSpecFactory); } if (this.destinationResolver != null) { instance.setDestinationResolver(this.destinationResolver); } if (this.transactionManager != null) { instance.setTransactionManager(this.transactionManager); } if (this.phase != null) { instance.setPhase(this.phase); } instance.setActivationSpecConfig(this); endpoint.setupListenerContainer(instance); return instance; }
/** * Create a message listener container for the given {@link JmsListenerEndpoint}. * <p>This create the necessary infrastructure to honor that endpoint * with regards to its configuration. * <p>The {@code startImmediately} flag determines if the container should be * started immediately. * @param endpoint the endpoint to add * @param factory the listener factory to use * @param startImmediately start the container immediately if necessary * @see #getListenerContainers() * @see #getListenerContainer(String) */ public void registerListenerContainer(JmsListenerEndpoint endpoint, JmsListenerContainerFactory<?> factory, boolean startImmediately) { Assert.notNull(endpoint, "Endpoint must not be null"); Assert.notNull(factory, "Factory must not be null"); String id = endpoint.getId(); Assert.hasText(id, "Endpoint id must be set"); synchronized (this.listenerContainers) { if (this.listenerContainers.containsKey(id)) { throw new IllegalStateException("Another endpoint is already registered with id '" + id + "'"); } MessageListenerContainer container = createListenerContainer(endpoint, factory); this.listenerContainers.put(id, container); if (startImmediately) { startIfNecessary(container); } } }
@Override public JmsMessageEndpointManager createListenerContainer(JmsListenerEndpoint endpoint) { if (this.destinationResolver != null && this.activationSpecFactory != null) { throw new IllegalStateException("Specify either 'activationSpecFactory' or " + "'destinationResolver', not both. If you define a dedicated JmsActivationSpecFactory bean, " + "specify the custom DestinationResolver there (if possible)"); } JmsMessageEndpointManager instance = createContainerInstance(); if (this.resourceAdapter != null) { instance.setResourceAdapter(this.resourceAdapter); } if (this.activationSpecFactory != null) { instance.setActivationSpecFactory(this.activationSpecFactory); } if (this.destinationResolver != null) { instance.setDestinationResolver(this.destinationResolver); } if (this.transactionManager != null) { instance.setTransactionManager(this.transactionManager); } if (this.phase != null) { instance.setPhase(this.phase); } instance.setActivationSpecConfig(this); endpoint.setupListenerContainer(instance); return instance; }
/** * Create a message listener container for the given {@link JmsListenerEndpoint}. * <p>This create the necessary infrastructure to honor that endpoint * with regards to its configuration. * <p>The {@code startImmediately} flag determines if the container should be * started immediately. * @param endpoint the endpoint to add * @param factory the listener factory to use * @param startImmediately start the container immediately if necessary * @see #getListenerContainers() * @see #getListenerContainer(String) */ public void registerListenerContainer(JmsListenerEndpoint endpoint, JmsListenerContainerFactory<?> factory, boolean startImmediately) { Assert.notNull(endpoint, "Endpoint must not be null"); Assert.notNull(factory, "Factory must not be null"); String id = endpoint.getId(); Assert.notNull(id, "Endpoint id must not be null"); synchronized (this.listenerContainers) { if (this.listenerContainers.containsKey(id)) { throw new IllegalStateException("Another endpoint is already registered with id '" + id + "'"); } MessageListenerContainer container = createListenerContainer(endpoint, factory); this.listenerContainers.put(id, container); if (startImmediately) { startIfNecessary(container); } } }
endpoint.setupListenerContainer(instance);
/** * Register a new {@link JmsListenerEndpoint} alongside the * {@link JmsListenerContainerFactory} to use to create the underlying container. * <p>The {@code factory} may be {@code null} if the default factory has to be * used for that endpoint. */ public void registerEndpoint(JmsListenerEndpoint endpoint, @Nullable JmsListenerContainerFactory<?> factory) { Assert.notNull(endpoint, "Endpoint must not be null"); Assert.hasText(endpoint.getId(), "Endpoint id must be set"); // Factory may be null, we defer the resolution right before actually creating the container JmsListenerEndpointDescriptor descriptor = new JmsListenerEndpointDescriptor(endpoint, factory); synchronized (this.mutex) { if (this.startImmediately) { // register and start immediately Assert.state(this.endpointRegistry != null, "No JmsListenerEndpointRegistry set"); this.endpointRegistry.registerListenerContainer(descriptor.endpoint, resolveContainerFactory(descriptor), true); } else { this.endpointDescriptors.add(descriptor); } } }
endpoint.setupListenerContainer(instance);
Assert.hasText(endpoint.getId(), "Endpoint id must be set");