/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
*
*
* The contents of this file are subject to the terms of either the GNU
* General Public License Version 2 only ("GPL") or the Common Development
* and Distribution License("CDDL") (collectively, the "License"). You
* may not use this file except in compliance with the License. You can
* obtain a copy of the License at
* or packager/legal/LICENSE.txt. See the License for the specific
* language governing permissions and limitations under the License.
*
* When distributing the software, include this License Header Notice in each
* file and include the License file at packager/legal/LICENSE.txt.
*
* GPL Classpath Exception:
* Oracle designates this particular file as subject to the "Classpath"
* exception as provided by Oracle in the GPL Version 2 section of the License
* file that accompanied this code.
*
* Modifications:
* If applicable, add the following below the License Header, with the fields
* enclosed by brackets [] replaced by your own identifying information:
* "Portions Copyright [year] [name of copyright owner]"
*
* Contributor(s):
* If you wish your version of this file to be governed by only the CDDL or
* only the GPL Version 2, indicate your decision by adding "[Contributor]
* elects to include this software in this distribution under the [CDDL or GPL
* Version 2] license." If you don't indicate a single choice of license, a
* recipient has the option to distribute your version of this file under
* either the CDDL, the GPL Version 2 or to extend the choice of license to
* its licensees as provided above. However, if you add GPL Version 2 code
* and therefore, elected the GPL Version 2 license, then the option applies
* only if the new code is made subject to such option by the copyright
* holder.
*/
//----------------------------------------------------------------------------
//
// Module: ControlImpl.java
//
// Description: Transaction Control object implementation.
//
// Product: com.sun.jts.CosTransactions
//
// Author: Simon Holdsworth
//
// Date: March, 1997
//
// Copyright (c): 1995-1997 IBM Corp.
//
// The source code for this program is not published or otherwise divested
// of its trade secrets, irrespective of what has been deposited with the
// U.S. Copyright Office.
//
// This software contains confidential and proprietary information of
// IBM Corp.
//----------------------------------------------------------------------------
// Import required classes.
/**The ControlImpl interface is our implementation of the standard Control
* interface. It provides operations to set and subsequently obtain the
* Terminator and Coordinator objects from the given context. Our
* implementation also provides a method to obtain the corresponding
* transaction identifiers, and stacking methods.
*
* @version 0.01
*
* @author Simon Holdsworth, IBM Corporation
*
* @see
*/
//----------------------------------------------------------------------------
// CHANGE HISTORY
//
// Version By Change Description
// 0.01 SAJH Initial implementation.
//------------------------------------------------------------------------------
protected boolean temporary = false;
protected boolean inSuspended = false;
protected boolean representsRemote = false;
// Transaction checking values
/**
* Logger to log transaction messages
*/
/**Default ControlImpl constructor.
*
* @param
*
* @return
*
* @see
*/
ControlImpl() {
// Add the Control object to the set of
// suspended ones for this process.
inSuspended = true;
CurrentTransaction.addSuspended(this);
}
/**Creates and initialises a new ControlImpl, given the TerminatorImpl and
* CoordinatorImpl objects, and the corresponding global and local identifiers.
*
* @param term The Terminator for the transaction.
* @param coord The Coordinator for the transaction.
* @param globalTID The global identifier for the transaction.
* @param localTID The local identifier for the transaction.
*
* @return
*
* @see
*/
// Set up the instance variables.
// Add the Control object to the set of suspended ones for this process.
inSuspended = true;
CurrentTransaction.addSuspended(this);
// pass this control obj to the terminator to cleanup properly (Ram J)
term.setControl(this);
}
}
/**Creates and initialises a new ControlImpl, given a Control object.
* This constructor is used to create a local ControlImpl when a remote factory
* has been used to create the Control object.
*
* @param ref The Control object for the transaction.
*
* @return
*
* @exception Unavailable The required information to set up the Control object
* is not available.
*
* @see
*/
throws Unavailable {
// Set up the instance variables.
representsRemote = true;
// Get a PropagationContext from the Coordinator, which will contain the
// global TID for the transaction.
try {
}
// Don't add the Control object to the set of suspended ones for this process,
// as we may never get the opportunity to remove it.
//$ CurrentTransaction.addSuspended(this);
}
/**Cleans up the state of the object.
*
* @param
*
* @return
*
* @see
*/
synchronized public void doFinalize() {
// Ensure that this object does not appear in the suspended set.
if( inSuspended )
inSuspended = false;
// If there is a Terminator reference, destroy the Terminator.
// Remove the reference from the map.
/* TN - do not nullify the references yet
thisRef = null;
coord = null;
coordRef = null;
term = null;
termRef = null;
stacked = null;
globalTID = null;
localTID = null;
*/
}
/**Returns the identifier that globally represents the transaction
*
* @param
*
* @return The global identifier.
*
* @see
*/
return globalTID;
}
/**Returns the identifier that globally represents the transaction, and a
* value that indicates the state of the transaction.
*
* @param status An object to hold the status value, or null.
*
* @return The global identifier.
*
* @exception SystemException An error occurred. The minor code indicates
* the reason for the exception.
*
* @see
*/
throws SystemException {
// Return the transaction state.
// If the object is asked for its OMGtid and has none, raise an exception.
throw exc;
}
else
return result;
}
/**Returns the identifier that locally represents the transaction, and a value
* that indicates the state of the transaction.
* <p>
* If the transaction represented by the Control object has been completed,
* the identifier is still returned if possible.
*
* @param status An object to hold the status value, or null.
*
* @return The local transaction identifier.
*
* @exception SystemException An error occurred. The minor code indicates
* the reason for the exception.
*
* @see
*/
throws SystemException {
long result = 0;
// Return the transaction state.
// If the internal id has not been defined, raise an exception.
throw exc;
} else {
}
return result;
}
/**Returns a reference to the stacked ControlImpl if there is one, otherwise
* returns a NULL reference.
* <p>
* A value is returned that indicates the state of the transaction.
* <p>
* If the transaction represented by the Control object has been completed,
* the reference is still returned if possible.
* The stacked Control object is removed from the stack.
*
* @param status An object to hold the status value, or null.
*
* @return The stacked Control object.
*
* @see
*/
// Return the transaction state.
// Get the value of the stacked Control object.
// Remove the stacked Control object (if any).
return result;
}
/**Stacks the given ControlImpl on the target of the operation, so that it can
* later be restored, and returns a value that indicates the state of the
* transaction.
* If there is already a stacked ControlImpl object, the operation throws an
* exception. If the transaction has already completed, no stacking is done.
*
* @param control The Control object to be stacked.
* @param status An object to hold the status value, or null.
*
* @return
*
* @exception SystemException An error occurred. The minor code indicates
* the reason for the exception.
*
* @see
*/
throws SystemException {
// If a Control object is already stacked on this one, raise an exception.
throw exc;
}
// Make the stacked Control object the given one.
else
}
// Return the transaction state.
}
/**Returns the Terminator object for the transaction.
* We raise the Unavailable exception when there is no Terminator.
* If the transaction has been completed, an appropriate exception is raised.
*
* This operation is part of the OMG interface and must not return any
* exceptions other than those defined in the OMG interface.
*
* @param
*
* @return The Terminator for the transaction.
*
* @exception Unavailable The Terminator object is not available.
* @exception SystemException The operation failed.
*
* @see
*/
throws Unavailable, SystemException {
// If the transaction has been completed, then raise an exception.
// Raise either TRANSACTION_ROLLEDBACK or INVALID_TRANSACTION depending on
// whether the transaction has aborted.
throw exc;
}
throw exc;
}
// If there is no Terminator reference, but a local Terminator, then get its
// reference and remember it.
}
// If there is no reference available, throw the Unavailable exception.
throw exc;
}
return result;
}
throws Unavailable, SystemException {
// If the transaction has been completed, then raise an exception.
// Raise either TRANSACTION_ROLLEDBACK or INVALID_TRANSACTION depending on
// whether the transaction has aborted.
throw exc;
}
throw exc;
}
// If there is no reference available, throw the Unavailable exception.
throw exc;
}
return result;
}
/**
* Returns the Coordinator for the transaction.
* If the transaction has been completed, an appropriate exception is raised.
*
* This operation is part of the OMG interface and must not return
* any exceptions other than those defined in the OMG interface.
*
* @param
*
* @return The Coordinator for the transaction.
*
* @exception Unavailable The Coordinator is not available.
* @exception SystemException The operation failed.
*
* @see
*/
throws Unavailable, SystemException {
// If the transaction has been completed, then raise an exception.
// Raise either TRANSACTION_ROLLEDBACK or INVALID_TRANSACTION depending on
// whether the transaction has aborted.
throw exc;
}
throw exc;
}
// If there is no Coordinator reference, but a local Coordinator, then get its
// reference and remember it.
}
// If there is no reference available, throw the Unavailable exception.
throw exc;
}
return result;
}
/**
* Returns the Coordinator for the transaction.
* If the transaction has been completed, an appropriate exception is raised.
*
* This operation is part of the OMG interface and must not return
* any exceptions other than those defined in the OMG interface.
*
* @param
*
* @return The Coordinator for the transaction.
*
* @exception Unavailable The Coordinator is not available.
* @exception SystemException The operation failed.
*
* @see
*/
throws Unavailable, SystemException {
// If the transaction has been completed, then raise an exception.
// Raise either TRANSACTION_ROLLEDBACK or INVALID_TRANSACTION depending on
// whether the transaction has aborted.
throw exc;
}
throw exc;
}
// If there is no reference available, throw the Unavailable exception.
throw exc;
}
return result;
}
/**This operation returns a value indicating that asynchonrous requests issued
* within the context of the current ControlImpl instance have not yet
* completed.
*
* @param
*
* @return Indicates there are outgoing requests.
*
* @see
*/
synchronized boolean isOutgoing() {
return result;
}
/**This operation returns a value which indicates that this ControlImpl instance
* is associated with one or more threads.
*
* @param
*
* @return Indicates an exisiting association.
*
* @see
*/
synchronized boolean isAssociated() {
return result;
}
/**This operation returns the number of thread associations
*
* @param
*
* @return Indicates the number of thread associations.
*
* @see
*/
synchronized int numAssociated() {
int result = association;
return result;
}
/**Increment the thread association count.
*
* @param
*
* @return
*
* @see
*/
synchronized void incrementAssociation() {
association++;
}
/**Decrement the thread association count.
*
* @param
*
* @return Indicates the association count was above zero.
*
* @see
*/
synchronized boolean decrementAssociation() {
if( result ) association--;
return result;
}
/**Increment the incomplete asynchronous request counter.
*
* @param
*
* @return
*
* @see
*/
synchronized void incrementOutgoing() {
outgoing++;
}
/**Decrement the incomplete asynchronous request counter.
*
* @param
*
* @return Indicates the request counter was above zero.
*
* @see
*/
synchronized boolean decrementOutgoing() {
return result;
}
/**Returns the state of the transaction as the Control object knows it.
*
* @param
*
* @return The transaction state.
*
* @see
*/
return result;
}
/**Sets the state of the transaction as the Control object knows it.
* No checking is done to verify the state change is valid.
*
* @param int The new state.
*
* @return
*
* @see
*/
}
/**Locates the first stacked ancestor which has not aborted. If there is no
* such ancestor the operation returns null.
*
* @param
*
* @return The first stacked Control which does not represent an aborted
* transaction.
*
* @see
*/
// Start with this object's stacked Control.
boolean validTID = false;
// Get the local transaction identifier for the stacked Control object,
// and ask the RecoveryManager if it represents a valid transaction.
try {
// If the transaction identifier is not valid, then the transaction must have
// rolled back, so discard it and get its stacked Control object, if any.
if( !validTID ) {
// Get the stacked Control object from the one that represents a rolled
// back transaction, and try to resume that one instead.
// Discard the rolled-back Control object and continue until a valid one, or
// no stacked Control is found.
}
}
return result;
}
/**Determines whether the ControlImpl object represents a remote Control object
* or a local one.
*
* @param
*
* @return Indicates whether the ControlImpl represents a remote Control.
*
* @see
*/
synchronized boolean representsRemoteControl() {
boolean result = representsRemote;
return result;
}
/**Returns the transaction context for the Coordinator.
*
* @param
*
* @return The transaction context.
*
* @exception Unavailable No transaction context is available.
*
* @see
*/
throws Unavailable {
// If the ControlImpl represents a remote transaction, then use the cached
// context, or get one from the Coordinator if there is no cached context.
if( representsRemote ) {
if( cachedContext == null )
try {
} catch( OBJECT_NOT_EXIST exc ) {
throw ex2;
}
}
// For local transactions, get the context from the Coordinator.
else
return result;
}
/**Dumps the state of the object.
*
* @param
*
* @return
*
* @see
*/
void dump() {
}
/**Returns the CORBA Object which represents this object.
*
* @param
*
* @return The CORBA object.
*
* @see
*/
try {
poa.activate_object(this);
} catch( ServantAlreadyActive sexc ) {
"jts.create_control_object_error");
} catch( ServantNotActive snexc ) {
"jts.create_control_object_error");
"jts.create_control_object_error");
}
}
return thisRef;
}
/**Returns the ControlImpl which serves the given object.
*
* @param The CORBA Object.
*
* @return The ControlImpl object which serves it.
*
* @see
*/
// GDH we will not be able to obtain the
// servant from our local POA for a proxy control object.
// so return null
return result;
}
if( control instanceof ControlImpl ) {
try {
}
return result;
}
/**Destroys the ControlImpl object.
*
* @param
*
* @return
*
* @see
*/
synchronized final void destroy() {
// GDH: We have no desire to destroy an underlying remote control object, instead we
// release it. We will finalise the local control wrapper below
} else {
try {
}
}
doFinalize();
}
/**Added to prevent null delegate problem.
*
* @param
*
* @return
*
* @see
*/
return this == o;
}
/**Added because this class overrides equals() method.
*
*/
public int hashCode() {
return System.identityHashCode(this);
}
/*
* These methods are there to satisy the compiler. At some point
* when we move towards a tie based model, the org.omg.Corba.Object
* interface method implementation below shall be discarded.
*/
}
public void _release() {
}
}
}
public boolean _non_existent() {
}
}
}
NamedValue result) {
}
}
}
}
}
}
}