Top Description Fields Constructors Methods
org.springframework.jca.support

public Class ResourceAdapterFactoryBean

extends Object
implements FactoryBean<ResourceAdapter>, InitializingBean, DisposableBean
Class Inheritance
All Implemented Interfaces
org.springframework.beans.factory.DisposableBean, org.springframework.beans.factory.InitializingBean, org.springframework.beans.factory.FactoryBean
Imports
jakarta.resource.ResourceException, jakarta.resource.spi.BootstrapContext, .ResourceAdapter, .XATerminator, jakarta.resource.spi.work.WorkManager, org.springframework.beans.BeanUtils, org.springframework.beans.factory.DisposableBean, .FactoryBean, .InitializingBean, org.springframework.lang.Nullable

org.springframework.beans.factory.FactoryBean that bootstraps the specified JCA 1.7 jakarta.resource.spi.ResourceAdapter, starting it with a local jakarta.resource.spi.BootstrapContext and exposing it for bean references. It will also stop the ResourceAdapter on context shutdown. This corresponds to 'non-managed' bootstrap in a local environment, according to the JCA 1.7 specification.

This is essentially an adapter for bean-style bootstrapping of a JCA ResourceAdapter, allowing the BootstrapContext or its elements (such as the JCA WorkManager) to be specified through bean properties.

Author
Juergen Hoeller
Since
2.0.3
See Also
setResourceAdapter, setBootstrapContext, setWorkManager, jakarta.resource.spi.ResourceAdapter#start(jakarta.resource.spi.BootstrapContext), jakarta.resource.spi.ResourceAdapter#stop()

Field Summary

Modifier and TypeField and Description
private BootstrapContext
private ResourceAdapter
private WorkManager
private XATerminator

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
afterPropertiesSet()

Implements org.springframework.beans.factory.InitializingBean.afterPropertiesSet.

Builds the BootstrapContext and starts the ResourceAdapter with it.
public void
destroy()

Implements org.springframework.beans.factory.DisposableBean.destroy.

Stops the ResourceAdapter.
public ResourceAdapter
getObject()

Implements org.springframework.beans.factory.FactoryBean.getObject.

Return an instance (possibly shared or independent) of the object managed by this factory.
public Class<? extends ResourceAdapter>
getObjectType()

Implements org.springframework.beans.factory.FactoryBean.getObjectType.

Return the type of object that this FactoryBean creates, or null if not known in advance.
public boolean
isSingleton()

Overrides default org.springframework.beans.factory.FactoryBean.isSingleton.

Is the object managed by this factory a singleton?
public void
setBootstrapContext(BootstrapContext bootstrapContext)

Specify the JCA BootstrapContext to use for starting the ResourceAdapter.

public void
setResourceAdapter(ResourceAdapter resourceAdapter)

Specify the target JCA ResourceAdapter, passed in as configured instance which hasn't been started yet.

public void
setResourceAdapterClass(Class<? extends ResourceAdapter> resourceAdapterClass)

Specify the target JCA ResourceAdapter as class, to be instantiated with its default configuration.

public void
setWorkManager(WorkManager workManager)

Specify the JCA WorkManager to use for bootstrapping the ResourceAdapter.

public void
setXaTerminator(XATerminator xaTerminator)

Specify the JCA XATerminator to use for bootstrapping the ResourceAdapter.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

bootstrapContextback to summary
private BootstrapContext bootstrapContext
Annotations
@Nullable
resourceAdapterback to summary
private ResourceAdapter resourceAdapter
Annotations
@Nullable
workManagerback to summary
private WorkManager workManager
Annotations
@Nullable
xaTerminatorback to summary
private XATerminator xaTerminator
Annotations
@Nullable

Constructor Detail

ResourceAdapterFactoryBeanback to summary
public ResourceAdapterFactoryBean()

Method Detail

afterPropertiesSetback to summary
public void afterPropertiesSet() throws ResourceException

Implements org.springframework.beans.factory.InitializingBean.afterPropertiesSet.

Builds the BootstrapContext and starts the ResourceAdapter with it.

Annotations
@Override
See Also
jakarta.resource.spi.ResourceAdapter#start(jakarta.resource.spi.BootstrapContext)
destroyback to summary
public void destroy()

Implements org.springframework.beans.factory.DisposableBean.destroy.

Stops the ResourceAdapter.

Annotations
@Override
See Also
jakarta.resource.spi.ResourceAdapter#stop()
getObjectback to summary
public ResourceAdapter getObject()

Implements org.springframework.beans.factory.FactoryBean.getObject.

Doc from org.springframework.beans.factory.FactoryBean.getObject.

Return an instance (possibly shared or independent) of the object managed by this factory.

As with a BeanFactory, this allows support for both the Singleton and Prototype design pattern.

If this FactoryBean is not fully initialized yet at the time of the call (for example because it is involved in a circular reference), throw a corresponding FactoryBeanNotInitializedException.

As of Spring 2.0, FactoryBeans are allowed to return null objects. The factory will consider this as normal value to be used; it will not throw a FactoryBeanNotInitializedException in this case anymore. FactoryBean implementations are encouraged to throw FactoryBeanNotInitializedException themselves now, as appropriate.

Returns:ResourceAdapter

an instance of the bean (can be null)

Annotations
@Override
@Nullable
getObjectTypeback to summary
public Class<? extends ResourceAdapter> getObjectType()

Implements org.springframework.beans.factory.FactoryBean.getObjectType.

Doc from org.springframework.beans.factory.FactoryBean.getObjectType.

Return the type of object that this FactoryBean creates, or null if not known in advance.

This allows one to check for specific types of beans without instantiating objects, for example on autowiring.

In the case of implementations that are creating a singleton object, this method should try to avoid singleton creation as far as possible; it should rather estimate the type in advance. For prototypes, returning a meaningful type here is advisable too.

This method can be called before this FactoryBean has been fully initialized. It must not rely on state created during initialization; of course, it can still use such state if available.

Note

Autowiring will simply ignore FactoryBeans that return null here. Therefore, it is highly recommended to implement this method properly, using the current state of the FactoryBean.

Returns:Class<? extends ResourceAdapter>

the type of object that this FactoryBean creates, or null if not known at the time of the call

Annotations
@Override
isSingletonback to summary
public boolean isSingleton()

Overrides default org.springframework.beans.factory.FactoryBean.isSingleton.

Doc from org.springframework.beans.factory.FactoryBean.isSingleton.

Is the object managed by this factory a singleton? That is, will getObject() always return the same object (a reference that can be cached)?

Note

If a FactoryBean indicates to hold a singleton object, the object returned from getObject() might get cached by the owning BeanFactory. Hence, do not return true unless the FactoryBean always exposes the same reference.

The singleton status of the FactoryBean itself will generally be provided by the owning BeanFactory; usually, it has to be defined as singleton there.

Note

This method returning false does not necessarily indicate that returned objects are independent instances. An implementation of the extended SmartFactoryBean interface may explicitly indicate independent instances through its SmartFactoryBean#isPrototype() method. Plain FactoryBean implementations which do not implement this extended interface are simply assumed to always return independent instances if the isSingleton() implementation returns false.

The default implementation returns true, since a FactoryBean typically manages a singleton instance.

Returns:boolean

whether the exposed object is a singleton

Annotations
@Override
setBootstrapContextback to summary
public void setBootstrapContext(BootstrapContext bootstrapContext)

Specify the JCA BootstrapContext to use for starting the ResourceAdapter.

Alternatively, you can specify the individual parts (such as the JCA WorkManager) as individual references.

See Also
setWorkManager, setXaTerminator
setResourceAdapterback to summary
public void setResourceAdapter(ResourceAdapter resourceAdapter)

Specify the target JCA ResourceAdapter, passed in as configured instance which hasn't been started yet. This will typically happen as an inner bean definition, configuring the ResourceAdapter instance through its vendor-specific bean properties.

setResourceAdapterClassback to summary
public void setResourceAdapterClass(Class<? extends ResourceAdapter> resourceAdapterClass)

Specify the target JCA ResourceAdapter as class, to be instantiated with its default configuration.

Alternatively, specify a pre-configured ResourceAdapter instance through the "resourceAdapter" property.

See Also
setResourceAdapter
setWorkManagerback to summary
public void setWorkManager(WorkManager workManager)

Specify the JCA WorkManager to use for bootstrapping the ResourceAdapter.

See Also
setBootstrapContext
setXaTerminatorback to summary
public void setXaTerminator(XATerminator xaTerminator)

Specify the JCA XATerminator to use for bootstrapping the ResourceAdapter.

See Also
setBootstrapContext