package com.sybase.jaguar.beans.enterprise;public interface InstanceContext extends Object
An InstanceContext object allows a Java component to influence the outcome of the transaction in which it is participating. A component method’s calls to the InstanceContext state primitives also determine the component’s state after the method completes. See “ServerBean lifecycle” for more information.
None. A component that implements the ServerBean interface receives an InstanceContext object as a parameter to the method activate(InstanceContext, String). A component that does not implement the ServerBean interface can call Jaguar.getInstanceContext() to obtain an InstanceContext object.
completeWork() – For transactional components, indicate that the transaction in which a component is participating should be committed. For any component, indicate that the instance should be deactivated.
continueWork() – Indicate that the current component instance cannot be deactivated automatically when control returns from the current component method invocation.
getSharedObjects() – Get a SharedObjects object that allows access to data shared among instances of a component.
inTransaction() – Determine whether the current component instance is executing in the context of a transaction.
isRollbackOnly() – Determine if the current transaction is doomed.
rollbackWork() – For transactional components, indicate that the transaction in which a component is participating should be aborted and rolled back. For any component, indicate that the instance should be deactivated.
See Chapter 2, “Understanding Transactions and Component Lifecycles,” in the EAServer Programmer’s Guide for a description of how components participate in transactions.
jaguar.beans.enterprise.ServerBean interface, jaguar.beans.enterprise.SharedObjects interface
For transactional components, indicate that the transaction in which a component is participating should be committed. For any component, indicate that the instance should be deactivated.
Package |
|
Interface |
public abstract void completeWork();
For a transactional component, completeWork() indicates that the component’s contribution to the current transaction has been successfully completed. For any component, completeWork() indicates that the component instance should be deactivated when control returns from the current component method invocation.
If the component is transactional and the component instance is the initiator of the transaction (that is, it was instantiated directly by a base client), then EAServer attempts to commit the transaction. The transaction commits unless the commit is vetoed. Depending on the components that are participating, a veto can happen in any of the following ways:
A participating Java component throws an exception from its ServerBean.deactivate() method.
A participating C component has called JagDisallowCommit.
A participating ActiveX component has called IObjectContext.disableCommit().
If the component instance is not the initiator of the transaction, the transaction may be rolled back when another participating instance calls rollbackWork() in addition to any of the cases listed above.
You can call completeWork(), continueWork(), and rollbackWork() many times in one method. Only the last call to execute takes effect. If you call none of these, the default behavior is that specified by continueWork().
continueWork(), rollbackWork(), isRollbackOnly(), inTransaction()
Indicate that the current component instance cannot be deactivated automatically when control returns from the current component method invocation.
Package |
|
Interface |
public abstract void continueWork();
Calling continueWork() indicates that the component instance should not be deactivated when the method returns. The component instance is not deactivated until one of the following happens:
The transaction times out or the client’s instance reference expires. In either case, the current transaction is rolled back.
The transaction’s root component calls completeWork() or rollbackWork(). If your component implements the ServerBean interface, it can veto the transaction by throwing an exception in the deactivate() method.
The component instance calls completeWork() or rollbackWork() during a subsequent method invocation.
You can call completeWork(), continueWork(), and rollbackWork() many times in one method. Only the last call to execute takes effect. If you call none of these, the default behavior is that specified by continueWork().
completeWork(), rollbackWork(), isRollbackOnly(), inTransaction()
Get a SharedObjects object that allows access to data shared among instances of a component.
Package |
|
Interface |
public abstract SharedObjects getSharedObjects();
jaguar.beans.enterprise.SharedObjects interface
Determine whether the current component instance is executing in the context of a transaction.
Package |
|
Interface |
public abstract boolean inTransaction();
true
if the current component
instance is executing as part of a transaction; false
otherwise.
Java component methods can call inTransaction() to determine whether they are executing within a transaction. Methods in components that are declared to be transactional always execute as part of a transaction. See Chapter 2, “Understanding Transactions and Component Lifecycles,” in the EAServer Programmer’s Guide for more information.
completeWork(), continueWork(), isRollbackOnly(), rollbackWork()
Determine if the current transaction is doomed.
Package |
|
Interface |
public abstract boolean isRollbackOnly();
true
if the current transaction
is doomed; false
if the transaction
is in a committable state or if the current component instance is
not executing as part of a transaction.
Call isRollbackOnly() to determine whether the current transaction is still viable.
If a component participates in a multi-component transaction, you should call isRollbackOnly() in the following places:
After issuing intercomponent calls
At the start of methods that can be executed by intercomponent calls.
If the transaction is no longer viable, there is no point in continuing execution. The method should clean up and call rollbackWork() to deactivate the component instance.
completeWork(), continueWork(), inTransaction(), rollbackWork()
For transactional components, indicate that the transaction in which a component is participating should be aborted and rolled back. For any component, indicate that the instance should be deactivated.
Package |
|
Interface |
public abstract void rollbackWork();
For a transactional component, rollbackWork() indicates that the component cannot complete its contribution to the current transaction. After the method returns, the transaction is doomed: the transaction flow continues until all participating components are deactivated. At that point, the transaction is rolled back. In any component, rollbackWork() indicates that the component instance should be deactivated when control returns from the current component method invocation.You can call rollbackWork(), continueWork(), and completeWork() many times in one method; only the last call to execute takes effect. If you call none of these, the default behavior is that specified by continueWork().
Transactional components that make intercomponent method calls can call isRollbackOnly() to determine whether the current transaction is still viable or has been set to rollback only.
completeWork(), continueWork(), inTransaction(), isRollbackOnly()
Copyright © 2005. Sybase Inc. All rights reserved. |