Provides methods that allow your component to influence the transaction outcome. Nontransactional components can call the IObjectContext methods to cause early deactivation of an instance.
DisableCommit – Indicates that the current transaction cannot be committed because the component’s work has not been completed; the instance remains active after the current method returns.
EnableCommit – Indicates that the component should not be deactivated after the current method invocation; allow the current transaction to be committed if the component instance is deactivated.
IsInTransaction – Determines whether the current method is executing in a transaction.
IsSecurityEnabled – Determines whether login security and component authorization are enabled for the server.
SetAbort – Indicates that the component cannot complete its work for the current transaction and that the transaction should be rolled back. The component instance will be deactivated when the method returns.
SetComplete – Indicates that the component’s work for the current transaction was successfully finished and that this component instance should be deactivated when the method returns.
The following methods are not supported and always return an HRESULT status of DISP_E_NOTIMPLEMENTED:
CreateInstance
IsCallerInRole
SafeRef
The IObjectContext interface contains methods that allow your component to influence the transaction outcome.
Call the GetObjectContext routine to obtain an IObjectContext interface pointer.
GetObjectContext routine, IObjectControl interface
Indicates that the current transaction cannot be committed because the component’s work has not been completed; the instance remains active after the current method returns.
#include <jagctx.h> HRESULT IObjectContext::DisableCommit (void);
Return value |
To indicate |
---|---|
S_OK |
Successfully set transactional state. |
CONTEXT_E_NOCONTEXT |
DisableCommit was called from code that was not executing as part of a component method invocation. |
DisableCommit specifies that the component instance should not be automatically deactivated after the current method completes. If the instance is deactivated before the next method invocation, the current transaction is rolled back.
When a method calls DisableCommit, the component instance is not deactivated until one of the following happens:
The component’s stub is destroyed explicitly by the client.
The client disconnects without explicitly destroying the stub (the current transaction is always rolled back in this case).
The component instance calls IObjectContext::SetComplete or IObjectContext::SetAbort during a subsequent method invocation.
EnableCommit and DisableCommit allow a component maintain state between method calls. If a component is not transactional, these two methods have the same effect: both prevent immediate deactivation of the component.
If a method calls none of DisableCommit, EnableCommit, SetAbort, or SetComplete, the default behavior is that of EnableCommit.
EnableCommit, SetAbort, SetComplete
Chapter 2, “Understanding Transactions and Component Lifecycles,” in the EAServer Programmer’s Guide
Indicates that the component should not be deactivated after the current method invocation; allow the current transaction to be committed if the component instance is deactivated.
#include <jagctx.h> HRESULT IObjectContext::EnableCommit (void);
Return value |
To indicate |
---|---|
S_OK |
Successfully set transactional state. |
CONTEXT_E_NOCONTEXT |
EnableCommit was called from code that was not executing as part of a component method invocation. |
EnableCommit specifies that the component instance should not be automatically deactivated after the current method completes. If the instance is deactivated before the next method invocation, the current transaction is committed.
When a method calls EnableCommit, 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 SetComplete or SetAbort.
The component instance calls SetComplete or SetAbort during a subsequent method invocation.
EnableCommit and DisableCommit allow a component maintain state between method calls. If a component is not transactional, these two methods have the same effect: both prevent immediate deactivation of the component.
If a method calls none of DisableCommit, EnableCommit, SetAbort, or SetComplete, the default behavior is that of EnableCommit.
DisableCommit, SetAbort, SetComplete
Chapter 2, “Understanding Transactions and Component Lifecycles,” in the EAServer Programmer’s Guide
Determines whether the current method is executing in a transaction.
#include <jagctx.h> BOOL IObjectContext::IsInTransaction (void);
Return value |
To indicate |
---|---|
TRUE |
The current method invocation is executing within a EAServer transaction. |
FALSE |
The current method invocation is not executing within a EAServer transaction. |
Methods can call IsInTransaction 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.
Chapter 2, “Understanding Transactions and Component Lifecycles,” in the EAServer Programmer’s Guide
Determines whether login security and component authorization are enabled for the server.
#include <jagctx.h> BOOL IObjectContext::IsSecurityEnabled (void);
Return value |
To indicate |
---|---|
TRUE |
Security is enabled. |
FALSE |
Security is not enabled. |
By default, login security and component authorization are disabled for newly installed servers.
Note
In the current release, IsSecurityEnabled returns
TRUE regardless of whether security has been enabled in the server
configuration.
Indicates that the component cannot complete its work for the current transaction and that the transaction should be rolled back. The component instance will be deactivated when the method returns.
#include <jagctx.h> HRESULT IObjectContext::SetAbort (void);
Return value |
To indicate |
---|---|
S_OK |
Successfully set transactional state. |
CONTEXT_E_NOCONTEXT |
SetAbort was called from code that was not executing as part of a component method invocation. |
SetAbort specifies that the component cannot complete its work for the current transaction. The transaction will be rolled back when the initiating component is deactivated.
If a component is not transactional, then SetAbort and SetComplete have the same effect: both cause the component instance to deactivate after the currently executing method returns.
If a method calls none of DisableCommit, EnableCommit, SetAbort, or SetComplete, the default behavior is that of EnableCommit.
DisableCommit, EnableCommit, IsInTransaction, SetComplete
Chapter 2, “Understanding Transactions and Component Lifecycles,” in the EAServer Programmer’s Guide
Indicates that the component’s work for the current transaction was successfully finished and that this component instance should be deactivated when the method returns.
#include <jagctx.h> HRESULT IObjectContext::SetComplete (void);
Return value |
To indicate |
---|---|
S_OK |
Successfully set transactional state. |
CONTEXT_E_NOCONTEXT |
SetComplete was called from code that was not executing as part of a component method invocation. |
SetComplete specifies that the component has successfully completed its contribution to the current transaction. The component instance deactivates when control returns from the current component method invocation.
If 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 disallowed or vetoed; depending on the components that are participating, this can happen in any of the following ways:
A participating C component has called JagDisallowCommit.
A participating Java component throws an exception from its ServerBean.deactivate() method.
A participating ActiveX component has called IObjectContext::DisableCommit.
If a component is not transactional, then SetAbort and SetComplete have the same effect: both cause the component instance to deactivate after the currently executing method returns.
If a method calls none of DisableCommit, EnableCommit, SetAbort, or SetComplete, the default behavior is that of EnableCommit.
DisableCommit, EnableCommit, IsInTransaction, SetAbort
Chapter 2, “Understanding Transactions and Component Lifecycles,” in the EAServer Programmer’s Guide
Copyright © 2005. Sybase Inc. All rights reserved. |
![]() |