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;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
|
@ -5,8 +28,8 @@ import org.hibernate.HibernateException;
|
|||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Defines the contract for implementations which know how to
|
||||
* scope the notion of a {@link org.hibernate.SessionFactory#getCurrentSession() current session}.
|
||||
* Defines the contract for implementations which know how to scope the notion
|
||||
* of a {@link org.hibernate.SessionFactory#getCurrentSession() current session}.
|
||||
* <p/>
|
||||
* Implementations should adhere to the following:
|
||||
* <ul>
|
||||
|
@ -22,7 +45,7 @@ import java.io.Serializable;
|
|||
* Note that there will be exactly one instance of the configured
|
||||
* 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 {
|
||||
/**
|
||||
|
@ -30,7 +53,7 @@ public interface CurrentSessionContext extends Serializable {
|
|||
* by this implementation.
|
||||
*
|
||||
* @return The current session.
|
||||
* @throws org.hibernate.HibernateException Typically indicates an issue
|
||||
* @throws HibernateException Typically indicates an issue
|
||||
* locating or creating the current session.
|
||||
*/
|
||||
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;
|
||||
|
||||
import org.hibernate.HibernateException;
|
||||
|
@ -48,13 +71,16 @@ public class JTASessionContext implements CurrentSessionContext {
|
|||
this.factory = factory;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Session currentSession() throws HibernateException {
|
||||
TransactionManager transactionManager = factory.getTransactionManager();
|
||||
if ( transactionManager == null ) {
|
||||
throw new HibernateException( "No TransactionManagerLookup specified" );
|
||||
}
|
||||
|
||||
Transaction txn = null;
|
||||
Transaction txn;
|
||||
try {
|
||||
txn = transactionManager.getTransaction();
|
||||
if ( txn == null ) {
|
||||
|
@ -158,9 +184,15 @@ public class JTASessionContext implements CurrentSessionContext {
|
|||
this.context = context;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void beforeCompletion() {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void afterCompletion(int i) {
|
||||
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;
|
||||
|
||||
import org.hibernate.classic.Session;
|
||||
|
@ -42,7 +65,7 @@ public class ManagedSessionContext implements CurrentSessionContext {
|
|||
}
|
||||
|
||||
/**
|
||||
* @see CurrentSessionContext#currentSession
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Session currentSession() {
|
||||
Session current = existingSession( factory );
|
||||
|
|
|
@ -42,9 +42,9 @@ import org.hibernate.engine.SessionFactoryImplementor;
|
|||
* The {@link #buildOrObtainSession}, {@link #isAutoCloseEnabled},
|
||||
* {@link #isAutoFlushEnabled}, {@link #getConnectionReleaseMode}, and
|
||||
* {@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 {
|
||||
|
||||
|
@ -70,6 +70,9 @@ public class ThreadLocalSessionContext implements CurrentSessionContext {
|
|||
this.factory = factory;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public final Session currentSession() throws HibernateException {
|
||||
Session current = existingSession( factory );
|
||||
if (current == null) {
|
||||
|
@ -94,6 +97,11 @@ public class ThreadLocalSessionContext implements CurrentSessionContext {
|
|||
&& ! ( Proxy.getInvocationHandler( session ) instanceof TransactionProtectionWrapper ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Getter for property 'factory'.
|
||||
*
|
||||
* @return Value for property 'factory'.
|
||||
*/
|
||||
protected SessionFactoryImplementor getFactory() {
|
||||
return factory;
|
||||
}
|
||||
|
@ -244,9 +252,15 @@ public class ThreadLocalSessionContext implements CurrentSessionContext {
|
|||
this.factory = factory;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void beforeCompletion() {
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public void afterCompletion(int i) {
|
||||
unbind( factory );
|
||||
}
|
||||
|
@ -260,6 +274,9 @@ public class ThreadLocalSessionContext implements CurrentSessionContext {
|
|||
this.realSession = realSession;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
|
||||
try {
|
||||
// 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) {
|
||||
this.wrappedSession = wrapped;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue