Top Description Fields Methods
org.osgi.service.transaction.control.jpa

public Interface JPAEntityManagerProviderFactory

Annotations
@ProviderType
Imports
java.util.Map, javax.persistence.EntityManager, .EntityManagerFactory, org.osgi.annotation.versioning.ProviderType, org.osgi.service.jpa.EntityManagerFactoryBuilder, org.osgi.service.transaction.control.TransactionException, org.osgi.service.transaction.control.jdbc.JDBCConnectionProvider

A factory for creating JPAEntityManagerProvider instances

This factory can be used if the JPAEntityManagerProvider should not be a public service, for example to protect a username/password.

Field Summary

Modifier and TypeField and Description
public static final String
CONNECTION_LIFETIME

The property used to set the maximum amount of time that connections in the pool should remain open

public static final String
CONNECTION_POOLING_ENABLED

The property used to determine whether connection pooling is enabled for this resource provider

public static final String
CONNECTION_TIMEOUT

The property used to set the maximum amount of time that the pool should wait for a connection

public static final String
IDLE_TIMEOUT

The property used to set the maximum amount of time that connections in the pool should remain idle before being closed

public static final String
LOCAL_ENLISTMENT_ENABLED

The property used to determine whether local enlistment is enabled for this resource provider

public static final String
MAX_CONNECTIONS

The property used to set the maximum number of connections that should be held in the pool

public static final String
MIN_CONNECTIONS

The property used to set the minimum number of connections that should be held in the pool

public static final String
OSGI_RECOVERY_IDENTIFIER

The property used to set the recovery identifier that should be used by this resource

public static final String
PRE_ENLISTED_DB_CONNECTION

The property used to indicate that database connections will be automatically enlisted in ongoing transactions without intervention from the JPA resource provider

public static final String
TRANSACTIONAL_DB_CONNECTION

The property used to provide a JDBCConnectionProvider to the resource provider.

public static final String
XA_ENLISTMENT_ENABLED

The property used to determine whether XA enlistment is enabled for this resource provider

public static final String
XA_RECOVERY_ENABLED

The property used to determine whether XA recovery is enabled for this resource provider

Method Summary

Modifier and TypeMethod and Description
public JPAEntityManagerProvider

Returns:

A JPAEntityManagerProvider that can be used in transactions
getProviderFor
(EntityManagerFactoryBuilder emfb, Map<String, Object>
The properties to pass to the EntityManagerFactoryBuilder in order to create the underlying EntityManagerFactory and EntityManager instances
jpaProperties
,
Map<String, Object>
Configuration properties to pass to the JPA Resource Provider runtime
resourceProviderProperties
)

Create a private JPAEntityManagerProvider using an EntityManagerFactoryBuilder.

public JPAEntityManagerProvider

Returns:

A JPAEntityManagerProvider that can be used in transactions
getProviderFor
(EntityManagerFactory emf, Map<String, Object>
Configuration properties to pass to the JDBC Resource Provider runtime
resourceProviderProperties
)

Create a private JPAEntityManagerProvider using an existing EntityManagerFactory.

public void
releaseProvider(JPAEntityManagerProvider provider)

Release a JPAEntityManagerProvider instance that has been created by this factory.

Field Detail

CONNECTION_LIFETIMEback to summary
public static final String CONNECTION_LIFETIME

The property used to set the maximum amount of time that connections in the pool should remain open

CONNECTION_POOLING_ENABLEDback to summary
public static final String CONNECTION_POOLING_ENABLED

The property used to determine whether connection pooling is enabled for this resource provider

CONNECTION_TIMEOUTback to summary
public static final String CONNECTION_TIMEOUT

The property used to set the maximum amount of time that the pool should wait for a connection

IDLE_TIMEOUTback to summary
public static final String IDLE_TIMEOUT

The property used to set the maximum amount of time that connections in the pool should remain idle before being closed

LOCAL_ENLISTMENT_ENABLEDback to summary
public static final String LOCAL_ENLISTMENT_ENABLED

The property used to determine whether local enlistment is enabled for this resource provider

MAX_CONNECTIONSback to summary
public static final String MAX_CONNECTIONS

The property used to set the maximum number of connections that should be held in the pool

MIN_CONNECTIONSback to summary
public static final String MIN_CONNECTIONS

The property used to set the minimum number of connections that should be held in the pool

OSGI_RECOVERY_IDENTIFIERback to summary
public static final String OSGI_RECOVERY_IDENTIFIER

The property used to set the recovery identifier that should be used by this resource

PRE_ENLISTED_DB_CONNECTIONback to summary
public static final String PRE_ENLISTED_DB_CONNECTION

The property used to indicate that database connections will be automatically enlisted in ongoing transactions without intervention from the JPA resource provider

TRANSACTIONAL_DB_CONNECTIONback to summary
public static final String TRANSACTIONAL_DB_CONNECTION

The property used to provide a JDBCConnectionProvider to the resource provider. This will be converted into a DataSource by the factory, and passed to the EntityManagerFactoryBuilder using the javax.persistence.jtaDataSource property

XA_ENLISTMENT_ENABLEDback to summary
public static final String XA_ENLISTMENT_ENABLED

The property used to determine whether XA enlistment is enabled for this resource provider

XA_RECOVERY_ENABLEDback to summary
public static final String XA_RECOVERY_ENABLED

The property used to determine whether XA recovery is enabled for this resource provider

Method Detail

getProviderForback to summary
public JPAEntityManagerProvider getProviderFor(EntityManagerFactoryBuilder emfb, Map<String, Object> jpaProperties, Map<String, Object> resourceProviderProperties)

Create a private JPAEntityManagerProvider using an EntityManagerFactoryBuilder. This call may fail with a TransactionException if the supplied configuration is invalid. Examples of invalid configuration include:

  • The properties request XA enlistment, but the provider implementation only supports local enlistment
  • The properties attempt to set a recovery alias, but the provider does not support recovery.

If XA transactions are used then this factory will provide configuration to ensure that the JPA Provider can participate correctly in ongoing transactions.

Parameters
jpaProperties:Map<String, Object>

The properties to pass to the EntityManagerFactoryBuilder in order to create the underlying EntityManagerFactory and EntityManager instances

resourceProviderProperties:Map<String, Object>

Configuration properties to pass to the JPA Resource Provider runtime

Returns:JPAEntityManagerProvider

A JPAEntityManagerProvider that can be used in transactions

getProviderForback to summary
public JPAEntityManagerProvider getProviderFor(EntityManagerFactory emf, Map<String, Object> resourceProviderProperties)

Create a private JPAEntityManagerProvider using an existing EntityManagerFactory. This call may fail with a TransactionException if the supplied configuration is invalid. Examples of invalid configuration include:

  • The properties request XA enlistment, but the provider implementation only supports local enlistment
  • The properties attempt to set a recovery alias, but the provider does not support recovery.

When using this method the client is responsible for all configuration of the EntityManagerFactory. This includes setting any relevant integration plugins for ensuring that the JPA provider can participate in the ongoing transaction context.

Parameters
resourceProviderProperties:Map<String, Object>

Configuration properties to pass to the JDBC Resource Provider runtime

Returns:JPAEntityManagerProvider

A JPAEntityManagerProvider that can be used in transactions

releaseProviderback to summary
public void releaseProvider(JPAEntityManagerProvider provider)

Release a JPAEntityManagerProvider instance that has been created by this factory. Released instances are eligible to be shut down and have any remaining open connections closed.

Note that all JPAEntityManagerProvider instances created by this factory service are implicitly released when the factory service is released by this bundle.

Exceptions
IllegalArgumentException:
if the supplied resource was not created by this factory service instance.