HHH-4816 - Cleanup JPA setting name constants
git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@18577 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
parent
c9b7d112b8
commit
6eb54445aa
|
@ -73,7 +73,6 @@ import org.hibernate.engine.SessionImplementor;
|
|||
import org.hibernate.proxy.HibernateProxy;
|
||||
import org.hibernate.transaction.TransactionFactory;
|
||||
import org.hibernate.transform.BasicTransformerAdapter;
|
||||
import org.hibernate.transform.ResultTransformer;
|
||||
import org.hibernate.util.CollectionHelper;
|
||||
import org.hibernate.util.JTAHelper;
|
||||
|
||||
|
@ -85,8 +84,6 @@ import org.hibernate.util.JTAHelper;
|
|||
@SuppressWarnings("unchecked")
|
||||
public abstract class AbstractEntityManagerImpl implements HibernateEntityManagerImplementor, Serializable {
|
||||
private static final Logger log = LoggerFactory.getLogger( AbstractEntityManagerImpl.class );
|
||||
private static final String PESSIMISTICLOCKSCOPE = "javax.persistence.lock.scope";
|
||||
private static final String PESSIMISTICLOCKTIMEOUT= "javax.persistence.lock.timeout";
|
||||
|
||||
private EntityManagerFactoryImpl entityManagerFactory;
|
||||
protected transient TransactionImpl tx = new TransactionImpl( this );
|
||||
|
@ -688,12 +685,12 @@ public abstract class AbstractEntityManagerImpl implements HibernateEntityManage
|
|||
lockOptions.setLockMode(getLockMode(lockModeType));
|
||||
if ( properties != null ) {
|
||||
// lockOptions scope will default to false (PessimisticLockScope.NORMAL)
|
||||
Object value = properties.get(PESSIMISTICLOCKSCOPE);
|
||||
Object value = properties.get( AvailableSettings.LOCK_SCOPE );
|
||||
if ( value instanceof String && PessimisticLockScope.valueOf((String) value) == PessimisticLockScope.EXTENDED) {
|
||||
lockOptions.setScope(true);
|
||||
}
|
||||
// lockOptions timeout will default to LockOptions.FOREVER_WAIT
|
||||
value = properties.get(PESSIMISTICLOCKTIMEOUT);
|
||||
value = properties.get( AvailableSettings.LOCK_TIMEOUT );
|
||||
if ( value instanceof String ) {
|
||||
int timeout = Integer.parseInt((String) value);
|
||||
if ( timeout < 0 ) {
|
||||
|
|
|
@ -0,0 +1,241 @@
|
|||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010, Red Hat Inc. or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
* Lesser General Public License, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this distribution; if not, write to:
|
||||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.ejb;
|
||||
|
||||
/**
|
||||
* Defines the available HEM settings, both JPA-defined as well as Hibernate-specific
|
||||
* <p/>
|
||||
* NOTE : Does *not* include {@link org.hibernate.cfg.Environment} values.
|
||||
*
|
||||
* @author Steve Ebersole
|
||||
*/
|
||||
public class AvailableSettings {
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// JPA defined settings
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
/**
|
||||
* THe name of the {@link javax.persistence.spi.PersistenceProvider} implementor
|
||||
* <p/>
|
||||
* See JPA 2 sections 9.4.3 and 8.2.1.4
|
||||
*/
|
||||
public static final String PROVIDER = "javax.persistence.provider";
|
||||
|
||||
/**
|
||||
* The type of transactions supported by the entity managers.
|
||||
* <p/>
|
||||
* See JPA 2 sections 9.4.3 and 8.2.1.2
|
||||
*/
|
||||
public static final String TRANSACTION_TYPE = "javax.persistence.transactionType";
|
||||
|
||||
/**
|
||||
* The JNDI name of a JTA {@link javax.sql.DataSource}.
|
||||
* <p/>
|
||||
* See JPA 2 sections 9.4.3 and 8.2.1.5
|
||||
*/
|
||||
public static final String JTA_DATASOURCE = "javax.persistence.jtaDataSource";
|
||||
|
||||
/**
|
||||
* The JNDI name of a non-JTA {@link javax.sql.DataSource}.
|
||||
* <p/>
|
||||
* See JPA 2 sections 9.4.3 and 8.2.1.5
|
||||
*/
|
||||
public static final String NON_JTA_DATASOURCE = "javax.persistence.nonJtaDataSource";
|
||||
|
||||
/**
|
||||
* The name of a JDBC driver to use to connect to the database.
|
||||
* <p/>
|
||||
* Used in conjunction with {@link #JDBC_URL}, {@link #JDBC_USER} and {@link #JDBC_PASSWORD}
|
||||
* to define how to make connections to the database in lieu of
|
||||
* a datasource (either {@link #JTA_DATASOURCE} or {@link #NON_JTA_DATASOURCE}).
|
||||
* <p/>
|
||||
* See section 8.2.1.9
|
||||
*/
|
||||
public static final String JDBC_DRIVER = "javax.persistence.jdbc.driver";
|
||||
|
||||
/**
|
||||
* The JDBC connection url to use to connect to the database.
|
||||
* <p/>
|
||||
* Used in conjunction with {@link #JDBC_DRIVER}, {@link #JDBC_USER} and {@link #JDBC_PASSWORD}
|
||||
* to define how to make connections to the database in lieu of
|
||||
* a datasource (either {@link #JTA_DATASOURCE} or {@link #NON_JTA_DATASOURCE}).
|
||||
* <p/>
|
||||
* See section 8.2.1.9
|
||||
*/
|
||||
public static final String JDBC_URL = "javax.persistence.jdbc.url";
|
||||
|
||||
/**
|
||||
* The JDBC connection user name.
|
||||
* <p/>
|
||||
* Used in conjunction with {@link #JDBC_DRIVER}, {@link #JDBC_URL} and {@link #JDBC_PASSWORD}
|
||||
* to define how to make connections to the database in lieu of
|
||||
* a datasource (either {@link #JTA_DATASOURCE} or {@link #NON_JTA_DATASOURCE}).
|
||||
* <p/>
|
||||
* See section 8.2.1.9
|
||||
*/
|
||||
public static final String JDBC_USER = "javax.persistence.jdbc.user";
|
||||
|
||||
/**
|
||||
* The JDBC connection password.
|
||||
* <p/>
|
||||
* Used in conjunction with {@link #JDBC_DRIVER}, {@link #JDBC_URL} and {@link #JDBC_USER}
|
||||
* to define how to make connections to the database in lieu of
|
||||
* a datasource (either {@link #JTA_DATASOURCE} or {@link #NON_JTA_DATASOURCE}).
|
||||
* <p/>
|
||||
* See JPA 2 section 8.2.1.9
|
||||
*/
|
||||
public static final String JDBC_PASSWORD = "javax.persistence.jdbc.password";
|
||||
|
||||
/**
|
||||
* Used to indicate whether second-level (what JPA terms shared cache) caching is
|
||||
* enabled as per the rules defined in JPA 2 section 3.1.7.
|
||||
* <p/>
|
||||
* See JPA 2 sections 9.4.3 and 8.2.1.7
|
||||
*/
|
||||
public static final String SHARED_CACHE_MODE = "javax.persistence.sharedCache.mode";
|
||||
|
||||
/**
|
||||
* Used to indicate what form of automatic validation is in effect as per rules defined
|
||||
* in JPA 2 section 3.6.1.1
|
||||
* <p/>
|
||||
* See JPA 2 sections 9.4.3 and 8.2.1.8
|
||||
*/
|
||||
public static final String VALIDATION_MODE = "javax.persistence.validation.mode";
|
||||
|
||||
/**
|
||||
* Used to request (hint) a pessimistic lock scope.
|
||||
* <p/>
|
||||
* See JPA 2 sections 8.2.1.9 and 3.4.4.3
|
||||
*/
|
||||
public static final String LOCK_SCOPE = "javax.persistence.lock.scope";
|
||||
|
||||
/**
|
||||
* Used to request (hint) a pessimistic lock timeout (in milliseconds).
|
||||
* <p/>
|
||||
* See JPA 2 sections 8.2.1.9 and 3.4.4.3
|
||||
*/
|
||||
public static final String LOCK_TIMEOUT = "javax.persistence.lock.timeout";
|
||||
|
||||
/**
|
||||
* Used to coordinate with bean validators
|
||||
* <p/>
|
||||
* See JPA 2 section 8.2.1.9
|
||||
*/
|
||||
public static final String PERSIST_VALIDATION_GROUP = "javax.persistence.validation.group.pre-persist";
|
||||
|
||||
/**
|
||||
* Used to coordinate with bean validators
|
||||
* <p/>
|
||||
* See JPA 2 section 8.2.1.9
|
||||
*/
|
||||
public static final String UPDATE_VALIDATION_GROUP = "javax.persistence.validation.group.pre-update";
|
||||
|
||||
/**
|
||||
* Used to coordinate with bean validators
|
||||
* <p/>
|
||||
* See JPA 2 section 8.2.1.9
|
||||
*/
|
||||
public static final String REMOVE_VALIDATION_GROUP = "javax.persistence.validation.group.pre-remove";
|
||||
|
||||
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
// Hibernate specific settings
|
||||
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
/**
|
||||
* JAR autodetection artifacts class, hbm
|
||||
*/
|
||||
public static final String AUTODETECTION = "hibernate.archive.autodetection";
|
||||
/**
|
||||
* cfg.xml configuration file used
|
||||
*/
|
||||
public static final String CFG_FILE = "hibernate.ejb.cfgfile";
|
||||
/**
|
||||
* Caching configuration should follow the following pattern
|
||||
* hibernate.ejb.classcache.<fully.qualified.Classname> usage[, region]
|
||||
* where usage is the cache strategy used and region the cache region name
|
||||
*/
|
||||
public static final String CLASS_CACHE_PREFIX = "hibernate.ejb.classcache";
|
||||
/**
|
||||
* Caching configuration should follow the following pattern
|
||||
* hibernate.ejb.collectioncache.<fully.qualified.Classname>.<role> usage[, region]
|
||||
* where usage is the cache strategy used and region the cache region name
|
||||
*/
|
||||
public static final String COLLECTION_CACHE_PREFIX = "hibernate.ejb.collectioncache";
|
||||
/**
|
||||
* Interceptor class name, the class has to have a no-arg constructor
|
||||
* the interceptor instance is shared amongst all EntityManager of a given EntityManagerFactory
|
||||
*/
|
||||
public static final String INTERCEPTOR = "hibernate.ejb.interceptor";
|
||||
/**
|
||||
* Interceptor class name, the class has to have a no-arg constructor
|
||||
*/
|
||||
public static final String SESSION_INTERCEPTOR = "hibernate.ejb.interceptor.session_scoped";
|
||||
/**
|
||||
* Naming strategy class name, the class has to have a no-arg constructor
|
||||
*/
|
||||
public static final String NAMING_STRATEGY = "hibernate.ejb.naming_strategy";
|
||||
/**
|
||||
* Event configuration should follow the following pattern
|
||||
* hibernate.ejb.event.[eventType] f.q.c.n.EventListener1, f.q.c.n.EventListener12 ...
|
||||
*/
|
||||
public static final String EVENT_LISTENER_PREFIX = "hibernate.ejb.event";
|
||||
/**
|
||||
* Enable the class file enhancement
|
||||
*/
|
||||
public static final String USE_CLASS_ENHANCER = "hibernate.ejb.use_class_enhancer";
|
||||
/**
|
||||
* Whether or not discard persistent context on entityManager.close()
|
||||
* The EJB3 compliant and default choice is false
|
||||
*/
|
||||
public static final String DISCARD_PC_ON_CLOSE = "hibernate.ejb.discard_pc_on_close";
|
||||
/**
|
||||
* Consider this as experimental
|
||||
* It is not recommended to set up this property, the configuration is stored
|
||||
* in the JNDI in a serialized form
|
||||
*/
|
||||
public static final String CONFIGURATION_JNDI_NAME = "hibernate.ejb.configuration_jndi_name";
|
||||
/**
|
||||
* List of classes names
|
||||
* Internal use only
|
||||
*/
|
||||
public static final String CLASS_NAMES = "hibernate.ejb.classes";
|
||||
/**
|
||||
* List of annotated packages
|
||||
* Internal use only
|
||||
*/
|
||||
public static final String PACKAGE_NAMES = "hibernate.ejb.packages";
|
||||
/**
|
||||
* List of classes names
|
||||
* Internal use only
|
||||
*/
|
||||
public static final String XML_FILE_NAMES = "hibernate.ejb.xml_files";
|
||||
public static final String HBXML_FILES = "hibernate.hbmxml.files";
|
||||
public static final String LOADED_CLASSES = "hibernate.ejb.loaded.classes";
|
||||
public static final String JACC_CONTEXT_ID = "hibernate.jacc.ctx.id";
|
||||
public static final String JACC_PREFIX = "hibernate.jacc";
|
||||
public static final String JACC_ENABLED = "hibernate.jacc.enabled";
|
||||
public static final String PERSISTENCE_UNIT_NAME = "hibernate.ejb.persistenceUnitName";
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
// $Id:$
|
||||
// $Id$
|
||||
/*
|
||||
* Copyright (c) 2009, Red Hat Middleware LLC or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
|
@ -178,7 +178,7 @@ public class Ejb3Configuration implements Serializable, Referenceable {
|
|||
log.debug( "Creating Factory: {}", metadata.getName() );
|
||||
|
||||
Map workingVars = new HashMap();
|
||||
workingVars.put( HibernatePersistence.PERSISTENCE_UNIT_NAME, metadata.getName() );
|
||||
workingVars.put( AvailableSettings.PERSISTENCE_UNIT_NAME, metadata.getName() );
|
||||
this.persistenceUnitName = metadata.getName();
|
||||
|
||||
if ( StringHelper.isNotEmpty( metadata.getJtaDatasource() ) ) {
|
||||
|
@ -189,22 +189,22 @@ public class Ejb3Configuration implements Serializable, Referenceable {
|
|||
}
|
||||
defineTransactionType( metadata.getTransactionType(), workingVars );
|
||||
if ( metadata.getClasses().size() > 0 ) {
|
||||
workingVars.put( HibernatePersistence.CLASS_NAMES, metadata.getClasses() );
|
||||
workingVars.put( AvailableSettings.CLASS_NAMES, metadata.getClasses() );
|
||||
}
|
||||
if ( metadata.getPackages().size() > 0 ) {
|
||||
workingVars.put( HibernatePersistence.PACKAGE_NAMES, metadata.getPackages() );
|
||||
workingVars.put( AvailableSettings.PACKAGE_NAMES, metadata.getPackages() );
|
||||
}
|
||||
if ( metadata.getMappingFiles().size() > 0 ) {
|
||||
workingVars.put( HibernatePersistence.XML_FILE_NAMES, metadata.getMappingFiles() );
|
||||
workingVars.put( AvailableSettings.XML_FILE_NAMES, metadata.getMappingFiles() );
|
||||
}
|
||||
if ( metadata.getHbmfiles().size() > 0 ) {
|
||||
workingVars.put( HibernatePersistence.HBXML_FILES, metadata.getHbmfiles() );
|
||||
workingVars.put( AvailableSettings.HBXML_FILES, metadata.getHbmfiles() );
|
||||
}
|
||||
if ( metadata.getValidationMode() != null) {
|
||||
workingVars.put( HibernatePersistence.VALIDATION_MODE, metadata.getValidationMode() );
|
||||
workingVars.put( AvailableSettings.VALIDATION_MODE, metadata.getValidationMode() );
|
||||
}
|
||||
if ( metadata.getSharedCacheMode() != null) {
|
||||
workingVars.put( HibernatePersistence.SHARED_CACHE_MODE, metadata.getSharedCacheMode() );
|
||||
workingVars.put( AvailableSettings.SHARED_CACHE_MODE, metadata.getSharedCacheMode() );
|
||||
}
|
||||
Properties props = new Properties();
|
||||
props.putAll( metadata.getProps() );
|
||||
|
@ -410,7 +410,7 @@ public class Ejb3Configuration implements Serializable, Referenceable {
|
|||
}
|
||||
|
||||
integration = integration != null ? Collections.unmodifiableMap( integration ) : CollectionHelper.EMPTY_MAP;
|
||||
String provider = (String) integration.get( HibernatePersistence.PROVIDER );
|
||||
String provider = (String) integration.get( AvailableSettings.PROVIDER );
|
||||
if ( provider == null ) provider = info.getPersistenceProviderClassName();
|
||||
if ( provider != null && ! provider.trim().startsWith( IMPLEMENTATION_NAME ) ) {
|
||||
log.info( "Required a different provider: {}", provider );
|
||||
|
@ -435,7 +435,7 @@ public class Ejb3Configuration implements Serializable, Referenceable {
|
|||
|
||||
try {
|
||||
Map workingVars = new HashMap();
|
||||
workingVars.put( HibernatePersistence.PERSISTENCE_UNIT_NAME, info.getPersistenceUnitName() );
|
||||
workingVars.put( AvailableSettings.PERSISTENCE_UNIT_NAME, info.getPersistenceUnitName() );
|
||||
this.persistenceUnitName = info.getPersistenceUnitName();
|
||||
List<String> entities = new ArrayList<String>( 50 );
|
||||
if ( info.getManagedClassNames() != null ) entities.addAll( info.getManagedClassNames() );
|
||||
|
@ -473,38 +473,38 @@ public class Ejb3Configuration implements Serializable, Referenceable {
|
|||
addXMLEntities( xmlFiles, info, entities );
|
||||
|
||||
//FIXME send the appropriate entites.
|
||||
if ( "true".equalsIgnoreCase( properties.getProperty( HibernatePersistence.USE_CLASS_ENHANCER ) ) ) {
|
||||
if ( "true".equalsIgnoreCase( properties.getProperty( AvailableSettings.USE_CLASS_ENHANCER ) ) ) {
|
||||
info.addTransformer( new InterceptFieldClassFileTransformer( entities ) );
|
||||
}
|
||||
|
||||
workingVars.put( HibernatePersistence.CLASS_NAMES, entities );
|
||||
workingVars.put( HibernatePersistence.PACKAGE_NAMES, packages );
|
||||
workingVars.put( HibernatePersistence.XML_FILE_NAMES, xmlFiles );
|
||||
if ( hbmFiles.size() > 0 ) workingVars.put( HibernatePersistence.HBXML_FILES, hbmFiles );
|
||||
workingVars.put( AvailableSettings.CLASS_NAMES, entities );
|
||||
workingVars.put( AvailableSettings.PACKAGE_NAMES, packages );
|
||||
workingVars.put( AvailableSettings.XML_FILE_NAMES, xmlFiles );
|
||||
if ( hbmFiles.size() > 0 ) workingVars.put( AvailableSettings.HBXML_FILES, hbmFiles );
|
||||
|
||||
//validation-mode
|
||||
final Object validationMode = info.getValidationMode();
|
||||
if ( validationMode != null) {
|
||||
workingVars.put( HibernatePersistence.VALIDATION_MODE, validationMode );
|
||||
workingVars.put( AvailableSettings.VALIDATION_MODE, validationMode );
|
||||
}
|
||||
|
||||
//shared-cache-mode
|
||||
final Object sharedCacheMode = info.getSharedCacheMode();
|
||||
if ( sharedCacheMode != null) {
|
||||
workingVars.put( HibernatePersistence.SHARED_CACHE_MODE, sharedCacheMode );
|
||||
workingVars.put( AvailableSettings.SHARED_CACHE_MODE, sharedCacheMode );
|
||||
}
|
||||
|
||||
//datasources
|
||||
Boolean isJTA = null;
|
||||
boolean overridenDatasource = false;
|
||||
if ( integration.containsKey( HibernatePersistence.JTA_DATASOURCE ) ) {
|
||||
String dataSource = (String) integration.get( HibernatePersistence.JTA_DATASOURCE );
|
||||
if ( integration.containsKey( AvailableSettings.JTA_DATASOURCE ) ) {
|
||||
String dataSource = (String) integration.get( AvailableSettings.JTA_DATASOURCE );
|
||||
overridenDatasource = true;
|
||||
properties.setProperty( Environment.DATASOURCE, dataSource );
|
||||
isJTA = Boolean.TRUE;
|
||||
}
|
||||
if ( integration.containsKey( HibernatePersistence.NON_JTA_DATASOURCE ) ) {
|
||||
String dataSource = (String) integration.get( HibernatePersistence.NON_JTA_DATASOURCE );
|
||||
if ( integration.containsKey( AvailableSettings.NON_JTA_DATASOURCE ) ) {
|
||||
String dataSource = (String) integration.get( AvailableSettings.NON_JTA_DATASOURCE );
|
||||
overridenDatasource = true;
|
||||
properties.setProperty( Environment.DATASOURCE, dataSource );
|
||||
if (isJTA == null) isJTA = Boolean.FALSE;
|
||||
|
@ -640,7 +640,7 @@ public class Ejb3Configuration implements Serializable, Referenceable {
|
|||
}
|
||||
else {
|
||||
throw new PersistenceException( getExceptionHeader() +
|
||||
HibernatePersistence.TRANSACTION_TYPE + " of the wrong class type"
|
||||
AvailableSettings.TRANSACTION_TYPE + " of the wrong class type"
|
||||
+ ": " + overridenTxType.getClass()
|
||||
);
|
||||
}
|
||||
|
@ -663,10 +663,10 @@ public class Ejb3Configuration implements Serializable, Referenceable {
|
|||
boolean detectClasses = false;
|
||||
boolean detectHbm = false;
|
||||
String detectSetting = overridenProperties != null ?
|
||||
(String) overridenProperties.get( HibernatePersistence.AUTODETECTION ) :
|
||||
(String) overridenProperties.get( AvailableSettings.AUTODETECTION ) :
|
||||
null;
|
||||
detectSetting = detectSetting == null ?
|
||||
properties.getProperty( HibernatePersistence.AUTODETECTION) :
|
||||
properties.getProperty( AvailableSettings.AUTODETECTION) :
|
||||
detectSetting;
|
||||
if ( detectSetting == null && excludeIfNotOverriden) {
|
||||
//not overriden through HibernatePersistence.AUTODETECTION so we comply with the spec excludeUnlistedClasses
|
||||
|
@ -719,10 +719,10 @@ public class Ejb3Configuration implements Serializable, Referenceable {
|
|||
if ( workingVars != null ) {
|
||||
props.putAll( workingVars );
|
||||
//remove huge non String elements for a clean props
|
||||
props.remove( HibernatePersistence.CLASS_NAMES );
|
||||
props.remove( HibernatePersistence.PACKAGE_NAMES );
|
||||
props.remove( HibernatePersistence.HBXML_FILES );
|
||||
props.remove( HibernatePersistence.LOADED_CLASSES );
|
||||
props.remove( AvailableSettings.CLASS_NAMES );
|
||||
props.remove( AvailableSettings.PACKAGE_NAMES );
|
||||
props.remove( AvailableSettings.HBXML_FILES );
|
||||
props.remove( AvailableSettings.LOADED_CLASSES );
|
||||
}
|
||||
configure( props, workingVars );
|
||||
return buildEntityManagerFactory();
|
||||
|
@ -767,7 +767,7 @@ public class Ejb3Configuration implements Serializable, Referenceable {
|
|||
}
|
||||
|
||||
private Class getSessionInterceptorClass(Properties properties) {
|
||||
String sessionInterceptorClassname = (String) properties.get( HibernatePersistence.SESSION_INTERCEPTOR );
|
||||
String sessionInterceptorClassname = (String) properties.get( AvailableSettings.SESSION_INTERCEPTOR );
|
||||
if ( StringHelper.isNotEmpty( sessionInterceptorClassname ) ) {
|
||||
try {
|
||||
Class interceptorClass = ReflectHelper.classForName( sessionInterceptorClassname, Ejb3Configuration.class );
|
||||
|
@ -776,15 +776,15 @@ public class Ejb3Configuration implements Serializable, Referenceable {
|
|||
}
|
||||
catch (ClassNotFoundException e) {
|
||||
throw new PersistenceException( getExceptionHeader() + "Unable to load "
|
||||
+ HibernatePersistence.SESSION_INTERCEPTOR + ": " + sessionInterceptorClassname, e);
|
||||
+ AvailableSettings.SESSION_INTERCEPTOR + ": " + sessionInterceptorClassname, e);
|
||||
}
|
||||
catch (IllegalAccessException e) {
|
||||
throw new PersistenceException( getExceptionHeader() + "Unable to instanciate "
|
||||
+ HibernatePersistence.SESSION_INTERCEPTOR + ": " + sessionInterceptorClassname, e);
|
||||
+ AvailableSettings.SESSION_INTERCEPTOR + ": " + sessionInterceptorClassname, e);
|
||||
}
|
||||
catch (InstantiationException e) {
|
||||
throw new PersistenceException( getExceptionHeader() + "Unable to instanciate "
|
||||
+ HibernatePersistence.SESSION_INTERCEPTOR + ": " + sessionInterceptorClassname, e);
|
||||
+ AvailableSettings.SESSION_INTERCEPTOR + ": " + sessionInterceptorClassname, e);
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -831,8 +831,8 @@ public class Ejb3Configuration implements Serializable, Referenceable {
|
|||
Properties preparedProperties = prepareProperties( properties, workingVars );
|
||||
if ( workingVars == null ) workingVars = CollectionHelper.EMPTY_MAP;
|
||||
|
||||
if ( preparedProperties.containsKey( HibernatePersistence.CFG_FILE ) ) {
|
||||
String cfgFileName = preparedProperties.getProperty( HibernatePersistence.CFG_FILE );
|
||||
if ( preparedProperties.containsKey( AvailableSettings.CFG_FILE ) ) {
|
||||
String cfgFileName = preparedProperties.getProperty( AvailableSettings.CFG_FILE );
|
||||
cfg.configure( cfgFileName );
|
||||
}
|
||||
|
||||
|
@ -853,24 +853,24 @@ public class Ejb3Configuration implements Serializable, Referenceable {
|
|||
//had to be safe
|
||||
if ( uncastObject != null && uncastObject instanceof String ) {
|
||||
String propertyKey = (String) uncastObject;
|
||||
if ( propertyKey.startsWith( HibernatePersistence.CLASS_CACHE_PREFIX ) ) {
|
||||
if ( propertyKey.startsWith( AvailableSettings.CLASS_CACHE_PREFIX ) ) {
|
||||
setCacheStrategy( propertyKey, preparedProperties, true, workingVars );
|
||||
}
|
||||
else if ( propertyKey.startsWith( HibernatePersistence.COLLECTION_CACHE_PREFIX ) ) {
|
||||
else if ( propertyKey.startsWith( AvailableSettings.COLLECTION_CACHE_PREFIX ) ) {
|
||||
setCacheStrategy( propertyKey, preparedProperties, false, workingVars );
|
||||
}
|
||||
else if ( propertyKey.startsWith( HibernatePersistence.JACC_PREFIX )
|
||||
&& ! ( propertyKey.equals( HibernatePersistence.JACC_CONTEXT_ID )
|
||||
|| propertyKey.equals( HibernatePersistence.JACC_ENABLED ) ) ) {
|
||||
else if ( propertyKey.startsWith( AvailableSettings.JACC_PREFIX )
|
||||
&& ! ( propertyKey.equals( AvailableSettings.JACC_CONTEXT_ID )
|
||||
|| propertyKey.equals( AvailableSettings.JACC_ENABLED ) ) ) {
|
||||
jaccKeys.add( propertyKey );
|
||||
}
|
||||
}
|
||||
}
|
||||
if ( preparedProperties.containsKey( HibernatePersistence.INTERCEPTOR )
|
||||
if ( preparedProperties.containsKey( AvailableSettings.INTERCEPTOR )
|
||||
&& ( cfg.getInterceptor() == null
|
||||
|| cfg.getInterceptor().equals( defaultInterceptor ) ) ) {
|
||||
//cfg.setInterceptor has precedence over configuration file
|
||||
String interceptorName = preparedProperties.getProperty( HibernatePersistence.INTERCEPTOR );
|
||||
String interceptorName = preparedProperties.getProperty( AvailableSettings.INTERCEPTOR );
|
||||
try {
|
||||
Class interceptor = classForName( interceptorName );
|
||||
cfg.setInterceptor( (Interceptor) interceptor.newInstance() );
|
||||
|
@ -896,11 +896,11 @@ public class Ejb3Configuration implements Serializable, Referenceable {
|
|||
);
|
||||
}
|
||||
}
|
||||
if ( preparedProperties.containsKey( HibernatePersistence.NAMING_STRATEGY )
|
||||
if ( preparedProperties.containsKey( AvailableSettings.NAMING_STRATEGY )
|
||||
&& ( cfg.getNamingStrategy() == null
|
||||
|| cfg.getNamingStrategy().equals( defaultNamingStrategy ) ) ) {
|
||||
//cfg.setNamingStrategy has precedence over configuration file
|
||||
String namingStrategyName = preparedProperties.getProperty( HibernatePersistence.NAMING_STRATEGY );
|
||||
String namingStrategyName = preparedProperties.getProperty( AvailableSettings.NAMING_STRATEGY );
|
||||
try {
|
||||
Class namingStragegy = classForName( namingStrategyName );
|
||||
cfg.setNamingStrategy( (NamingStrategy) namingStragegy.newInstance() );
|
||||
|
@ -941,36 +941,36 @@ public class Ejb3Configuration implements Serializable, Referenceable {
|
|||
if ( ! "true".equalsIgnoreCase( cfg.getProperty( Environment.AUTOCOMMIT ) ) ) {
|
||||
log.warn( "{} = false break the EJB3 specification", Environment.AUTOCOMMIT );
|
||||
}
|
||||
discardOnClose = preparedProperties.getProperty( HibernatePersistence.DISCARD_PC_ON_CLOSE )
|
||||
discardOnClose = preparedProperties.getProperty( AvailableSettings.DISCARD_PC_ON_CLOSE )
|
||||
.equals( "true" );
|
||||
return this;
|
||||
}
|
||||
|
||||
private void addClassesToSessionFactory(Map workingVars) {
|
||||
if ( workingVars.containsKey( HibernatePersistence.CLASS_NAMES ) ) {
|
||||
if ( workingVars.containsKey( AvailableSettings.CLASS_NAMES ) ) {
|
||||
Collection<String> classNames = (Collection<String>) workingVars.get(
|
||||
HibernatePersistence.CLASS_NAMES
|
||||
AvailableSettings.CLASS_NAMES
|
||||
);
|
||||
addNamedAnnotatedClasses( this, classNames, workingVars );
|
||||
}
|
||||
//TODO apparently only used for Tests, get rid of it?
|
||||
if ( workingVars.containsKey( HibernatePersistence.LOADED_CLASSES ) ) {
|
||||
Collection<Class> classes = (Collection<Class>) workingVars.get( HibernatePersistence.LOADED_CLASSES );
|
||||
if ( workingVars.containsKey( AvailableSettings.LOADED_CLASSES ) ) {
|
||||
Collection<Class> classes = (Collection<Class>) workingVars.get( AvailableSettings.LOADED_CLASSES );
|
||||
for ( Class clazz : classes ) {
|
||||
cfg.addAnnotatedClass( clazz );
|
||||
}
|
||||
}
|
||||
if ( workingVars.containsKey( HibernatePersistence.PACKAGE_NAMES ) ) {
|
||||
if ( workingVars.containsKey( AvailableSettings.PACKAGE_NAMES ) ) {
|
||||
Collection<String> packages = (Collection<String>) workingVars.get(
|
||||
HibernatePersistence.PACKAGE_NAMES
|
||||
AvailableSettings.PACKAGE_NAMES
|
||||
);
|
||||
for ( String pkg : packages ) {
|
||||
cfg.addPackage( pkg );
|
||||
}
|
||||
}
|
||||
if ( workingVars.containsKey( HibernatePersistence.XML_FILE_NAMES ) ) {
|
||||
if ( workingVars.containsKey( AvailableSettings.XML_FILE_NAMES ) ) {
|
||||
Collection<String> xmlFiles = (Collection<String>) workingVars.get(
|
||||
HibernatePersistence.XML_FILE_NAMES
|
||||
AvailableSettings.XML_FILE_NAMES
|
||||
);
|
||||
for ( String xmlFile : xmlFiles ) {
|
||||
Boolean useMetaInf = null;
|
||||
|
@ -1002,9 +1002,9 @@ public class Ejb3Configuration implements Serializable, Referenceable {
|
|||
}
|
||||
}
|
||||
}
|
||||
if ( workingVars.containsKey( HibernatePersistence.HBXML_FILES ) ) {
|
||||
if ( workingVars.containsKey( AvailableSettings.HBXML_FILES ) ) {
|
||||
Collection<NamedInputStream> hbmXmlFiles = (Collection<NamedInputStream>) workingVars.get(
|
||||
HibernatePersistence.HBXML_FILES
|
||||
AvailableSettings.HBXML_FILES
|
||||
);
|
||||
for ( NamedInputStream is : hbmXmlFiles ) {
|
||||
try {
|
||||
|
@ -1043,9 +1043,9 @@ public class Ejb3Configuration implements Serializable, Referenceable {
|
|||
preparedProperties.setProperty( Environment.AUTOCOMMIT, "true" );
|
||||
preparedProperties.setProperty( Environment.USE_IDENTIFIER_ROLLBACK, "false" );
|
||||
preparedProperties.setProperty( Environment.FLUSH_BEFORE_COMPLETION, "false" );
|
||||
preparedProperties.setProperty( HibernatePersistence.DISCARD_PC_ON_CLOSE, "false" );
|
||||
preparedProperties.setProperty( AvailableSettings.DISCARD_PC_ON_CLOSE, "false" );
|
||||
if (cfgXmlResource != null) {
|
||||
preparedProperties.setProperty( HibernatePersistence.CFG_FILE, cfgXmlResource );
|
||||
preparedProperties.setProperty( AvailableSettings.CFG_FILE, cfgXmlResource );
|
||||
cfgXmlResource = null;
|
||||
}
|
||||
|
||||
|
@ -1061,7 +1061,7 @@ public class Ejb3Configuration implements Serializable, Referenceable {
|
|||
transactionType = PersistenceUnitTransactionType.RESOURCE_LOCAL;
|
||||
}
|
||||
defineTransactionType(
|
||||
preparedProperties.getProperty( HibernatePersistence.TRANSACTION_TYPE ),
|
||||
preparedProperties.getProperty( AvailableSettings.TRANSACTION_TYPE ),
|
||||
workingVars
|
||||
);
|
||||
boolean hasTxStrategy = StringHelper.isNotEmpty(
|
||||
|
@ -1094,8 +1094,8 @@ public class Ejb3Configuration implements Serializable, Referenceable {
|
|||
|
||||
private void setCacheStrategy(String propertyKey, Map properties, boolean isClass, Map workingVars) {
|
||||
String role = propertyKey.substring(
|
||||
( isClass ? HibernatePersistence.CLASS_CACHE_PREFIX
|
||||
.length() : HibernatePersistence.COLLECTION_CACHE_PREFIX.length() )
|
||||
( isClass ? AvailableSettings.CLASS_CACHE_PREFIX
|
||||
.length() : AvailableSettings.COLLECTION_CACHE_PREFIX.length() )
|
||||
+ 1
|
||||
);
|
||||
//dot size added
|
||||
|
@ -1104,7 +1104,7 @@ public class Ejb3Configuration implements Serializable, Referenceable {
|
|||
if ( !params.hasMoreTokens() ) {
|
||||
StringBuilder error = new StringBuilder( "Illegal usage of " );
|
||||
error.append(
|
||||
isClass ? HibernatePersistence.CLASS_CACHE_PREFIX : HibernatePersistence.COLLECTION_CACHE_PREFIX
|
||||
isClass ? AvailableSettings.CLASS_CACHE_PREFIX : AvailableSettings.COLLECTION_CACHE_PREFIX
|
||||
);
|
||||
error.append( ": " ).append( propertyKey ).append( " " ).append( value );
|
||||
throw new PersistenceException( getExceptionHeader() + error.toString() );
|
||||
|
@ -1128,17 +1128,17 @@ public class Ejb3Configuration implements Serializable, Referenceable {
|
|||
|
||||
private void addSecurity(List<String> keys, Map properties, Map workingVars) {
|
||||
log.debug( "Adding security" );
|
||||
if ( !properties.containsKey( HibernatePersistence.JACC_CONTEXT_ID ) ) {
|
||||
if ( !properties.containsKey( AvailableSettings.JACC_CONTEXT_ID ) ) {
|
||||
throw new PersistenceException( getExceptionHeader() +
|
||||
"Entities have been configured for JACC, but "
|
||||
+ HibernatePersistence.JACC_CONTEXT_ID
|
||||
+ AvailableSettings.JACC_CONTEXT_ID
|
||||
+ " has not been set"
|
||||
);
|
||||
}
|
||||
String contextId = (String) properties.get( HibernatePersistence.JACC_CONTEXT_ID );
|
||||
String contextId = (String) properties.get( AvailableSettings.JACC_CONTEXT_ID );
|
||||
setProperty( Environment.JACC_CONTEXTID, contextId );
|
||||
|
||||
int roleStart = HibernatePersistence.JACC_PREFIX.length() + 1;
|
||||
int roleStart = AvailableSettings.JACC_PREFIX.length() + 1;
|
||||
|
||||
for ( String key : keys ) {
|
||||
JACCConfiguration jaccCfg = new JACCConfiguration( contextId );
|
||||
|
@ -1151,7 +1151,7 @@ public class Ejb3Configuration implements Serializable, Referenceable {
|
|||
}
|
||||
catch (IndexOutOfBoundsException e) {
|
||||
throw new PersistenceException( getExceptionHeader() +
|
||||
"Illegal usage of " + HibernatePersistence.JACC_PREFIX + ": " + key );
|
||||
"Illegal usage of " + AvailableSettings.JACC_PREFIX + ": " + key );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
//$Id$
|
||||
package org.hibernate.ejb;
|
||||
|
||||
import java.util.Map;
|
||||
|
@ -63,7 +61,7 @@ public class EntityManagerImpl extends AbstractEntityManagerImpl {
|
|||
this.discardOnClose = discardOnClose;
|
||||
Object localSessionInterceptor = null;
|
||||
if (properties != null) {
|
||||
localSessionInterceptor = properties.get( HibernatePersistence.SESSION_INTERCEPTOR );
|
||||
localSessionInterceptor = properties.get( AvailableSettings.SESSION_INTERCEPTOR );
|
||||
}
|
||||
if ( localSessionInterceptor != null ) {
|
||||
if (localSessionInterceptor instanceof Class) {
|
||||
|
|
|
@ -19,8 +19,6 @@
|
|||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
//$Id$
|
||||
package org.hibernate.ejb;
|
||||
|
||||
import java.beans.BeanInfo;
|
||||
|
@ -168,15 +166,15 @@ public class EventListenerConfigurator {
|
|||
}
|
||||
|
||||
public void setProperties(Properties properties) {
|
||||
if ( properties.containsKey( HibernatePersistence.JACC_ENABLED ) ) {
|
||||
if ( properties.containsKey( AvailableSettings.JACC_ENABLED ) ) {
|
||||
isSecurity = true;
|
||||
}
|
||||
//override events if needed
|
||||
Enumeration<?> enumeration = properties.propertyNames();
|
||||
while ( enumeration.hasMoreElements() ) {
|
||||
String name = (String) enumeration.nextElement();
|
||||
if ( name.startsWith( HibernatePersistence.EVENT_LISTENER_PREFIX ) ) {
|
||||
String type = name.substring( HibernatePersistence.EVENT_LISTENER_PREFIX.length() + 1 );
|
||||
if ( name.startsWith( AvailableSettings.EVENT_LISTENER_PREFIX ) ) {
|
||||
String type = name.substring( AvailableSettings.EVENT_LISTENER_PREFIX.length() + 1 );
|
||||
StringTokenizer st = new StringTokenizer( properties.getProperty( name ), " ,", false );
|
||||
List<String> listeners = new ArrayList<String>();
|
||||
while ( st.hasMoreElements() ) {
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
// $Id:$
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
|
@ -39,110 +38,11 @@ import org.hibernate.ejb.util.PersistenceUtilHelper;
|
|||
*/
|
||||
public class HibernatePersistence implements javax.persistence.spi.PersistenceProvider {
|
||||
|
||||
/**
|
||||
* Provider
|
||||
*/
|
||||
public static final String PROVIDER = "javax.persistence.provider";
|
||||
/**
|
||||
* transaction type
|
||||
*/
|
||||
public static final String TRANSACTION_TYPE = "javax.persistence.transactionType";
|
||||
/**
|
||||
* JTA datasource name
|
||||
*/
|
||||
public static final String JTA_DATASOURCE = "javax.persistence.jtaDataSource";
|
||||
/**
|
||||
* Non JTA datasource name
|
||||
*/
|
||||
public static final String NON_JTA_DATASOURCE = "javax.persistence.nonJtaDataSource";
|
||||
/**
|
||||
* Validation mode
|
||||
*/
|
||||
public static final String VALIDATION_MODE = "javax.persistence.validation.mode";
|
||||
/**
|
||||
* Shared cache mode
|
||||
*/
|
||||
public static final String SHARED_CACHE_MODE = "javax.persistence.sharedCache.mode";
|
||||
/**
|
||||
* JAR autodetection artifacts class, hbm
|
||||
*/
|
||||
public static final String AUTODETECTION = "hibernate.archive.autodetection";
|
||||
/**
|
||||
* cfg.xml configuration file used
|
||||
*/
|
||||
public static final String CFG_FILE = "hibernate.ejb.cfgfile";
|
||||
/**
|
||||
* Caching configuration should follow the following pattern
|
||||
* hibernate.ejb.classcache.<fully.qualified.Classname> usage[, region]
|
||||
* where usage is the cache strategy used and region the cache region name
|
||||
*/
|
||||
public static final String CLASS_CACHE_PREFIX = "hibernate.ejb.classcache";
|
||||
/**
|
||||
* Caching configuration should follow the following pattern
|
||||
* hibernate.ejb.collectioncache.<fully.qualified.Classname>.<role> usage[, region]
|
||||
* where usage is the cache strategy used and region the cache region name
|
||||
*/
|
||||
public static final String COLLECTION_CACHE_PREFIX = "hibernate.ejb.collectioncache";
|
||||
/**
|
||||
* Interceptor class name, the class has to have a no-arg constructor
|
||||
* the interceptor instance is shared amongst all EntityManager of a given EntityManagerFactory
|
||||
*/
|
||||
public static final String INTERCEPTOR = "hibernate.ejb.interceptor";
|
||||
/**
|
||||
* Interceptor class name, the class has to have a no-arg constructor
|
||||
*/
|
||||
public static final String SESSION_INTERCEPTOR = "hibernate.ejb.interceptor.session_scoped";
|
||||
/**
|
||||
* Naming strategy class name, the class has to have a no-arg constructor
|
||||
*/
|
||||
public static final String NAMING_STRATEGY = "hibernate.ejb.naming_strategy";
|
||||
/**
|
||||
* Event configuration should follow the following pattern
|
||||
* hibernate.ejb.event.[eventType] f.q.c.n.EventListener1, f.q.c.n.EventListener12 ...
|
||||
*/
|
||||
public static final String EVENT_LISTENER_PREFIX = "hibernate.ejb.event";
|
||||
/**
|
||||
* Enable the class file enhancement
|
||||
*/
|
||||
public static final String USE_CLASS_ENHANCER = "hibernate.ejb.use_class_enhancer";
|
||||
/**
|
||||
* Whether or not discard persistent context on entityManager.close()
|
||||
* The EJB3 compliant and default choice is false
|
||||
*/
|
||||
public static final String DISCARD_PC_ON_CLOSE = "hibernate.ejb.discard_pc_on_close";
|
||||
/**
|
||||
* Consider this as experimental
|
||||
* It is not recommended to set up this property, the configuration is stored
|
||||
* in the JNDI in a serialized form
|
||||
*/
|
||||
public static final String CONFIGURATION_JNDI_NAME = "hibernate.ejb.configuration_jndi_name";
|
||||
|
||||
//The following properties are for Internal use only
|
||||
/**
|
||||
* link to the alternative Hibernate configuration file
|
||||
* Internal use only
|
||||
*/
|
||||
/**
|
||||
* List of classes names
|
||||
* Internal use only
|
||||
*/
|
||||
public static final String CLASS_NAMES = "hibernate.ejb.classes";
|
||||
/**
|
||||
* List of annotated packages
|
||||
* Internal use only
|
||||
*/
|
||||
public static final String PACKAGE_NAMES = "hibernate.ejb.packages";
|
||||
/**
|
||||
* List of classes names
|
||||
* Internal use only
|
||||
*/
|
||||
public static final String XML_FILE_NAMES = "hibernate.ejb.xml_files";
|
||||
public static final String HBXML_FILES = "hibernate.hbmxml.files";
|
||||
public static final String LOADED_CLASSES = "hibernate.ejb.loaded.classes";
|
||||
public static final String JACC_CONTEXT_ID = "hibernate.jacc.ctx.id";
|
||||
public static final String JACC_PREFIX = "hibernate.jacc";
|
||||
public static final String JACC_ENABLED = "hibernate.jacc.enabled";
|
||||
public static final String PERSISTENCE_UNIT_NAME = "hibernate.ejb.persistenceUnitName";
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,9 +1,10 @@
|
|||
// $Id:$
|
||||
/*
|
||||
* Copyright (c) 2009, Red Hat Middleware LLC or third-party contributors as
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010, Red Hat Inc. or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Middleware LLC.
|
||||
* distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
|
@ -40,6 +41,10 @@ import javax.xml.validation.Schema;
|
|||
import javax.xml.validation.SchemaFactory;
|
||||
import javax.xml.validation.Validator;
|
||||
|
||||
import org.hibernate.ejb.AvailableSettings;
|
||||
import org.hibernate.ejb.util.ConfigurationHelper;
|
||||
import org.hibernate.util.StringHelper;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.w3c.dom.Document;
|
||||
|
@ -51,10 +56,6 @@ import org.xml.sax.ErrorHandler;
|
|||
import org.xml.sax.InputSource;
|
||||
import org.xml.sax.SAXParseException;
|
||||
|
||||
import org.hibernate.ejb.HibernatePersistence;
|
||||
import org.hibernate.ejb.util.ConfigurationHelper;
|
||||
import org.hibernate.util.StringHelper;
|
||||
|
||||
/**
|
||||
* Handler for persistence.xml files.
|
||||
*
|
||||
|
@ -179,20 +180,20 @@ public final class PersistenceXmlLoader {
|
|||
PersistenceMetadata metadata = parsePersistenceUnit( element );
|
||||
metadata.setVersion(version);
|
||||
//override properties of metadata if needed
|
||||
if ( overrides.containsKey( HibernatePersistence.PROVIDER ) ) {
|
||||
String provider = (String) overrides.get( HibernatePersistence.PROVIDER );
|
||||
if ( overrides.containsKey( AvailableSettings.PROVIDER ) ) {
|
||||
String provider = (String) overrides.get( AvailableSettings.PROVIDER );
|
||||
metadata.setProvider( provider );
|
||||
}
|
||||
if ( overrides.containsKey( HibernatePersistence.TRANSACTION_TYPE ) ) {
|
||||
String transactionType = (String) overrides.get( HibernatePersistence.TRANSACTION_TYPE );
|
||||
if ( overrides.containsKey( AvailableSettings.TRANSACTION_TYPE ) ) {
|
||||
String transactionType = (String) overrides.get( AvailableSettings.TRANSACTION_TYPE );
|
||||
metadata.setTransactionType( PersistenceXmlLoader.getTransactionType( transactionType ) );
|
||||
}
|
||||
if ( overrides.containsKey( HibernatePersistence.JTA_DATASOURCE ) ) {
|
||||
String dataSource = (String) overrides.get( HibernatePersistence.JTA_DATASOURCE );
|
||||
if ( overrides.containsKey( AvailableSettings.JTA_DATASOURCE ) ) {
|
||||
String dataSource = (String) overrides.get( AvailableSettings.JTA_DATASOURCE );
|
||||
metadata.setJtaDatasource( dataSource );
|
||||
}
|
||||
if ( overrides.containsKey( HibernatePersistence.NON_JTA_DATASOURCE ) ) {
|
||||
String dataSource = (String) overrides.get( HibernatePersistence.NON_JTA_DATASOURCE );
|
||||
if ( overrides.containsKey( AvailableSettings.NON_JTA_DATASOURCE ) ) {
|
||||
String dataSource = (String) overrides.get( AvailableSettings.NON_JTA_DATASOURCE );
|
||||
metadata.setNonJtaDatasource( dataSource );
|
||||
}
|
||||
/*
|
||||
|
|
|
@ -1,8 +1,10 @@
|
|||
/*
|
||||
* Copyright (c) 2009, Red Hat Middleware LLC or third-party contributors as
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010, Red Hat Inc. or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Middleware LLC.
|
||||
* distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
|
@ -30,8 +32,9 @@ import javax.naming.event.NamingEvent;
|
|||
import javax.naming.event.NamingExceptionEvent;
|
||||
import javax.naming.event.NamingListener;
|
||||
|
||||
import org.hibernate.ejb.AvailableSettings;
|
||||
import org.hibernate.ejb.Ejb3Configuration;
|
||||
import org.hibernate.ejb.HibernatePersistence;
|
||||
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
@ -45,7 +48,7 @@ public class NamingHelper {
|
|||
|
||||
/** bind the configuration to the JNDI */
|
||||
public static void bind(Ejb3Configuration cfg) {
|
||||
String name = cfg.getHibernateConfiguration().getProperty( HibernatePersistence.CONFIGURATION_JNDI_NAME );
|
||||
String name = cfg.getHibernateConfiguration().getProperty( AvailableSettings.CONFIGURATION_JNDI_NAME );
|
||||
if ( name == null ) {
|
||||
log.debug( "No JNDI name configured for binding Ejb3Configuration" );
|
||||
}
|
||||
|
|
|
@ -1,4 +1,26 @@
|
|||
//$Id$
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010, Red Hat Inc. or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
* Lesser General Public License, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this distribution; if not, write to:
|
||||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.ejb.test;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
@ -10,8 +32,8 @@ import javax.persistence.EntityManagerFactory;
|
|||
import javax.persistence.Persistence;
|
||||
import javax.persistence.PersistenceException;
|
||||
|
||||
import org.hibernate.ejb.AvailableSettings;
|
||||
import org.hibernate.ejb.HibernateEntityManagerFactory;
|
||||
import org.hibernate.ejb.HibernatePersistence;
|
||||
import org.hibernate.ejb.test.pack.cfgxmlpar.Morito;
|
||||
import org.hibernate.ejb.test.pack.defaultpar.ApplicationServer;
|
||||
import org.hibernate.ejb.test.pack.defaultpar.IncrementListener;
|
||||
|
@ -232,7 +254,7 @@ public class PackagedEntityManagerTest extends TestCase {
|
|||
|
||||
public void testOverridenPar() throws Exception {
|
||||
HashMap properties = new HashMap();
|
||||
properties.put( HibernatePersistence.JTA_DATASOURCE, null );
|
||||
properties.put( AvailableSettings.JTA_DATASOURCE, null );
|
||||
Properties p=new Properties();
|
||||
p.load( ConfigHelper.getResourceAsStream( "/overridenpar.properties" ) );
|
||||
properties.putAll( p );
|
||||
|
|
|
@ -1,4 +1,26 @@
|
|||
//$Id$
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010, Red Hat Inc. or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
* Lesser General Public License, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this distribution; if not, write to:
|
||||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.ejb.test;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -16,6 +38,7 @@ import org.apache.commons.logging.Log;
|
|||
import org.apache.commons.logging.LogFactory;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.dialect.Dialect;
|
||||
import org.hibernate.ejb.AvailableSettings;
|
||||
import org.hibernate.ejb.HibernatePersistence;
|
||||
|
||||
|
||||
|
@ -125,16 +148,16 @@ public abstract class TestCase extends junit.framework.TestCase {
|
|||
for ( Class clazz : getAnnotatedClasses() ) {
|
||||
classes.add( clazz );
|
||||
}
|
||||
config.put( HibernatePersistence.LOADED_CLASSES, classes );
|
||||
config.put( AvailableSettings.LOADED_CLASSES, classes );
|
||||
for ( Map.Entry<Class, String> entry : getCachedClasses().entrySet() ) {
|
||||
config.put(
|
||||
HibernatePersistence.CLASS_CACHE_PREFIX + "." + entry.getKey().getName(),
|
||||
AvailableSettings.CLASS_CACHE_PREFIX + "." + entry.getKey().getName(),
|
||||
entry.getValue()
|
||||
);
|
||||
}
|
||||
for ( Map.Entry<String, String> entry : getCachedCollections().entrySet() ) {
|
||||
config.put(
|
||||
HibernatePersistence.COLLECTION_CACHE_PREFIX + "." + entry.getKey(),
|
||||
AvailableSettings.COLLECTION_CACHE_PREFIX + "." + entry.getKey(),
|
||||
entry.getValue()
|
||||
);
|
||||
}
|
||||
|
@ -143,7 +166,7 @@ public abstract class TestCase extends junit.framework.TestCase {
|
|||
for ( String dd : getEjb3DD() ) {
|
||||
dds.add( dd );
|
||||
}
|
||||
config.put( HibernatePersistence.XML_FILE_NAMES, dds );
|
||||
config.put( AvailableSettings.XML_FILE_NAMES, dds );
|
||||
}
|
||||
return config;
|
||||
}
|
||||
|
|
|
@ -1,10 +1,32 @@
|
|||
//$Id$
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010, Red Hat Inc. or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
* Lesser General Public License, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this distribution; if not, write to:
|
||||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.ejb.test.ejb3configuration;
|
||||
|
||||
import javax.persistence.EntityManager;
|
||||
import javax.persistence.EntityManagerFactory;
|
||||
|
||||
import org.hibernate.ejb.HibernatePersistence;
|
||||
import org.hibernate.ejb.AvailableSettings;
|
||||
import org.hibernate.ejb.test.Distributor;
|
||||
import org.hibernate.ejb.test.Item;
|
||||
|
||||
|
@ -35,7 +57,7 @@ public class InterceptorTest extends TestCase {
|
|||
}
|
||||
|
||||
public void testConfiguredInterceptor() {
|
||||
configuration.setProperty( HibernatePersistence.INTERCEPTOR, ExceptionInterceptor.class.getName() );
|
||||
configuration.setProperty( AvailableSettings.INTERCEPTOR, ExceptionInterceptor.class.getName() );
|
||||
EntityManagerFactory emf = configuration.createEntityManagerFactory();
|
||||
EntityManager em = emf.createEntityManager();
|
||||
Item i = new Item();
|
||||
|
@ -57,7 +79,7 @@ public class InterceptorTest extends TestCase {
|
|||
}
|
||||
|
||||
public void testConfiguredSessionInterceptor() {
|
||||
configuration.setProperty( HibernatePersistence.SESSION_INTERCEPTOR, LocalExceptionInterceptor.class.getName() );
|
||||
configuration.setProperty( AvailableSettings.SESSION_INTERCEPTOR, LocalExceptionInterceptor.class.getName() );
|
||||
configuration.setProperty( "aaaaaaaaaaaaaaaaaaaaa", "bbbbbbbbbbbbbbbbbbbb" );
|
||||
EntityManagerFactory emf = configuration.createEntityManagerFactory();
|
||||
EntityManager em = emf.createEntityManager();
|
||||
|
@ -80,7 +102,7 @@ public class InterceptorTest extends TestCase {
|
|||
}
|
||||
|
||||
public void testEmptyCreateEntityManagerFactoryAndPropertyUse() {
|
||||
configuration.setProperty( HibernatePersistence.INTERCEPTOR, ExceptionInterceptor.class.getName() );
|
||||
configuration.setProperty( AvailableSettings.INTERCEPTOR, ExceptionInterceptor.class.getName() );
|
||||
EntityManagerFactory emf = configuration.createEntityManagerFactory();
|
||||
EntityManager em = emf.createEntityManager();
|
||||
Item i = new Item();
|
||||
|
|
|
@ -1,4 +1,26 @@
|
|||
//$Id$
|
||||
/*
|
||||
* Hibernate, Relational Persistence for Idiomatic Java
|
||||
*
|
||||
* Copyright (c) 2010, Red Hat Inc. or third-party contributors as
|
||||
* indicated by the @author tags or express copyright attribution
|
||||
* statements applied by the authors. All third-party contributions are
|
||||
* distributed under license by Red Hat Inc.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use, modify,
|
||||
* copy, or redistribute it subject to the terms and conditions of the GNU
|
||||
* Lesser General Public License, as published by the Free Software Foundation.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
|
||||
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
|
||||
* for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this distribution; if not, write to:
|
||||
* Free Software Foundation, Inc.
|
||||
* 51 Franklin Street, Fifth Floor
|
||||
* Boston, MA 02110-1301 USA
|
||||
*/
|
||||
package org.hibernate.ejb.test.ejb3configuration;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -9,8 +31,8 @@ import java.util.Properties;
|
|||
import javax.persistence.Persistence;
|
||||
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.ejb.AvailableSettings;
|
||||
import org.hibernate.ejb.Ejb3Configuration;
|
||||
import org.hibernate.ejb.HibernatePersistence;
|
||||
|
||||
/**
|
||||
* @author Emmanuel Bernard
|
||||
|
@ -54,13 +76,13 @@ public abstract class TestCase extends junit.framework.TestCase {
|
|||
|
||||
for ( Map.Entry<Class, String> entry : getCachedClasses().entrySet() ) {
|
||||
configuration.setProperty(
|
||||
HibernatePersistence.CLASS_CACHE_PREFIX + "." + entry.getKey().getName(),
|
||||
AvailableSettings.CLASS_CACHE_PREFIX + "." + entry.getKey().getName(),
|
||||
entry.getValue()
|
||||
);
|
||||
}
|
||||
for ( Map.Entry<String, String> entry : getCachedCollections().entrySet() ) {
|
||||
configuration.setProperty(
|
||||
HibernatePersistence.COLLECTION_CACHE_PREFIX + "." + entry.getKey(),
|
||||
AvailableSettings.COLLECTION_CACHE_PREFIX + "." + entry.getKey(),
|
||||
entry.getValue()
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue