copyright headers
git-svn-id: https://svn.jboss.org/repos/hibernate/core/trunk@14450 1b8cb986-b30d-0410-93ca-fae66ebed9b2
This commit is contained in:
parent
f2ccf54a49
commit
9a024e2cdf
|
@ -1,3 +1,26 @@
|
||||||
|
/*
|
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
|
*
|
||||||
|
* Copyright (c) 2008, Red Hat Middleware LLC 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.
|
||||||
|
*
|
||||||
|
* 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.context;
|
package org.hibernate.context;
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
|
@ -5,8 +28,8 @@ import org.hibernate.HibernateException;
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Defines the contract for implementations which know how to
|
* Defines the contract for implementations which know how to scope the notion
|
||||||
* scope the notion of a {@link org.hibernate.SessionFactory#getCurrentSession() current session}.
|
* of a {@link org.hibernate.SessionFactory#getCurrentSession() current session}.
|
||||||
* <p/>
|
* <p/>
|
||||||
* Implementations should adhere to the following:
|
* Implementations should adhere to the following:
|
||||||
* <ul>
|
* <ul>
|
||||||
|
@ -22,7 +45,7 @@ import java.io.Serializable;
|
||||||
* Note that there will be exactly one instance of the configured
|
* Note that there will be exactly one instance of the configured
|
||||||
* CurrentSessionContext implementation per {@link org.hibernate.SessionFactory}.
|
* CurrentSessionContext implementation per {@link org.hibernate.SessionFactory}.
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:steve@hibernate.org">Steve Ebersole </a>
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public interface CurrentSessionContext extends Serializable {
|
public interface CurrentSessionContext extends Serializable {
|
||||||
/**
|
/**
|
||||||
|
@ -30,7 +53,7 @@ public interface CurrentSessionContext extends Serializable {
|
||||||
* by this implementation.
|
* by this implementation.
|
||||||
*
|
*
|
||||||
* @return The current session.
|
* @return The current session.
|
||||||
* @throws org.hibernate.HibernateException Typically indicates an issue
|
* @throws HibernateException Typically indicates an issue
|
||||||
* locating or creating the current session.
|
* locating or creating the current session.
|
||||||
*/
|
*/
|
||||||
public org.hibernate.classic.Session currentSession() throws HibernateException;
|
public org.hibernate.classic.Session currentSession() throws HibernateException;
|
||||||
|
|
|
@ -1,3 +1,26 @@
|
||||||
|
/*
|
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
|
*
|
||||||
|
* Copyright (c) 2008, Red Hat Middleware LLC 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.
|
||||||
|
*
|
||||||
|
* 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.context;
|
package org.hibernate.context;
|
||||||
|
|
||||||
import org.hibernate.HibernateException;
|
import org.hibernate.HibernateException;
|
||||||
|
@ -48,13 +71,16 @@ public class JTASessionContext implements CurrentSessionContext {
|
||||||
this.factory = factory;
|
this.factory = factory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
public Session currentSession() throws HibernateException {
|
public Session currentSession() throws HibernateException {
|
||||||
TransactionManager transactionManager = factory.getTransactionManager();
|
TransactionManager transactionManager = factory.getTransactionManager();
|
||||||
if ( transactionManager == null ) {
|
if ( transactionManager == null ) {
|
||||||
throw new HibernateException( "No TransactionManagerLookup specified" );
|
throw new HibernateException( "No TransactionManagerLookup specified" );
|
||||||
}
|
}
|
||||||
|
|
||||||
Transaction txn = null;
|
Transaction txn;
|
||||||
try {
|
try {
|
||||||
txn = transactionManager.getTransaction();
|
txn = transactionManager.getTransaction();
|
||||||
if ( txn == null ) {
|
if ( txn == null ) {
|
||||||
|
@ -158,9 +184,15 @@ public class JTASessionContext implements CurrentSessionContext {
|
||||||
this.context = context;
|
this.context = context;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
public void beforeCompletion() {
|
public void beforeCompletion() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
public void afterCompletion(int i) {
|
public void afterCompletion(int i) {
|
||||||
context.currentSessionMap.remove( txn );
|
context.currentSessionMap.remove( txn );
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,3 +1,26 @@
|
||||||
|
/*
|
||||||
|
* Hibernate, Relational Persistence for Idiomatic Java
|
||||||
|
*
|
||||||
|
* Copyright (c) 2008, Red Hat Middleware LLC 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.
|
||||||
|
*
|
||||||
|
* 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.context;
|
package org.hibernate.context;
|
||||||
|
|
||||||
import org.hibernate.classic.Session;
|
import org.hibernate.classic.Session;
|
||||||
|
@ -42,7 +65,7 @@ public class ManagedSessionContext implements CurrentSessionContext {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @see CurrentSessionContext#currentSession
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public Session currentSession() {
|
public Session currentSession() {
|
||||||
Session current = existingSession( factory );
|
Session current = existingSession( factory );
|
||||||
|
|
|
@ -42,9 +42,9 @@ import org.hibernate.engine.SessionFactoryImplementor;
|
||||||
* The {@link #buildOrObtainSession}, {@link #isAutoCloseEnabled},
|
* The {@link #buildOrObtainSession}, {@link #isAutoCloseEnabled},
|
||||||
* {@link #isAutoFlushEnabled}, {@link #getConnectionReleaseMode}, and
|
* {@link #isAutoFlushEnabled}, {@link #getConnectionReleaseMode}, and
|
||||||
* {@link #buildCleanupSynch} methods are all provided to allow easy
|
* {@link #buildCleanupSynch} methods are all provided to allow easy
|
||||||
* subclassing (for long- running session scenarios, for example).
|
* subclassing (for long-running session scenarios, for example).
|
||||||
*
|
*
|
||||||
* @author <a href="mailto:steve@hibernate.org">Steve Ebersole </a>
|
* @author Steve Ebersole
|
||||||
*/
|
*/
|
||||||
public class ThreadLocalSessionContext implements CurrentSessionContext {
|
public class ThreadLocalSessionContext implements CurrentSessionContext {
|
||||||
|
|
||||||
|
@ -70,6 +70,9 @@ public class ThreadLocalSessionContext implements CurrentSessionContext {
|
||||||
this.factory = factory;
|
this.factory = factory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
public final Session currentSession() throws HibernateException {
|
public final Session currentSession() throws HibernateException {
|
||||||
Session current = existingSession( factory );
|
Session current = existingSession( factory );
|
||||||
if (current == null) {
|
if (current == null) {
|
||||||
|
@ -94,6 +97,11 @@ public class ThreadLocalSessionContext implements CurrentSessionContext {
|
||||||
&& ! ( Proxy.getInvocationHandler( session ) instanceof TransactionProtectionWrapper ) );
|
&& ! ( Proxy.getInvocationHandler( session ) instanceof TransactionProtectionWrapper ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Getter for property 'factory'.
|
||||||
|
*
|
||||||
|
* @return Value for property 'factory'.
|
||||||
|
*/
|
||||||
protected SessionFactoryImplementor getFactory() {
|
protected SessionFactoryImplementor getFactory() {
|
||||||
return factory;
|
return factory;
|
||||||
}
|
}
|
||||||
|
@ -244,9 +252,15 @@ public class ThreadLocalSessionContext implements CurrentSessionContext {
|
||||||
this.factory = factory;
|
this.factory = factory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
public void beforeCompletion() {
|
public void beforeCompletion() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
public void afterCompletion(int i) {
|
public void afterCompletion(int i) {
|
||||||
unbind( factory );
|
unbind( factory );
|
||||||
}
|
}
|
||||||
|
@ -260,6 +274,9 @@ public class ThreadLocalSessionContext implements CurrentSessionContext {
|
||||||
this.realSession = realSession;
|
this.realSession = realSession;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* {@inheritDoc}
|
||||||
|
*/
|
||||||
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
|
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
|
||||||
try {
|
try {
|
||||||
// If close() is called, guarantee unbind()
|
// If close() is called, guarantee unbind()
|
||||||
|
@ -310,6 +327,11 @@ public class ThreadLocalSessionContext implements CurrentSessionContext {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Setter for property 'wrapped'.
|
||||||
|
*
|
||||||
|
* @param wrapped Value to set for property 'wrapped'.
|
||||||
|
*/
|
||||||
public void setWrapped(Session wrapped) {
|
public void setWrapped(Session wrapped) {
|
||||||
this.wrappedSession = wrapped;
|
this.wrappedSession = wrapped;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue