javax.slee.profile
Interface ProfileContext


public interface ProfileContext

The ProfileContext interface provides a Profile object with access to SLEE-managed state that is dependent on the Profile objects's currently executing context.

A ProfileContext object is given to a Profile object after the Profile object is created via the setProfileContext method. The ProfileContext object remains associated with the Profile object for the lifetime of that Profile object. Note that the information that the Profile object obtains from the ProfileContext object may change as the SLEE assigns the Profile object to different profiles during the Profile object's lifecycle.

Since:
SLEE 1.1

Method Summary
 ProfileLocalObject getProfileLocalObject()
          Get a ProfileLocalObject which represents the profile that the Profile object owning this ProfileContext is currently assigned to.
 java.lang.String getProfileName()
          Get the name of the profile that the Profile object owning this ProfileContext is currently assigned to.
 ProfileTable getProfileTable()
          Get an object that implements the Profile Table Interface of the profile table that this ProfileContext is associated with.
 ProfileTable getProfileTable(java.lang.String profileTableName)
          Get a ProfileTable object for a profile table.
 java.lang.String getProfileTableName()
          Get the name of the profile table in which the profile that this Profile object is assigned to exists.
 boolean getRollbackOnly()
          Test if the current transaction has been marked for rollback only.
 Tracer getTracer(java.lang.String tracerName)
          Get a tracer for the specified tracer name.
 void setRollbackOnly()
          Mark the current transaction for rollback.
 

Method Detail

getProfileLocalObject

ProfileLocalObject getProfileLocalObject()
                                         throws java.lang.IllegalStateException,
                                                SLEEException
Get a ProfileLocalObject which represents the profile that the Profile object owning this ProfileContext is currently assigned to.

This method is a non-transactional method. The Profile object must be in the Ready state when it invokes this method as otherwise it is not assigned to any particular profile.

Returns:
a ProfileLocalObject which represents the profile that the Profile object owning this ProfileContext is currently assigned to.
Throws:
java.lang.IllegalStateException - if the Profile object invoking this method is not in the Ready state.
SLEEException - if the local object reference could not be obtained due to a system-level failure.

getProfileTableName

java.lang.String getProfileTableName()
                                     throws SLEEException
Get the name of the profile table in which the profile that this Profile object is assigned to exists.

This method is a non-transactional method.

Returns:
the profile table name.
Throws:
SLEEException - if the profile table name could not be obtained due to a system-level failure.

getProfileName

java.lang.String getProfileName()
                                throws java.lang.IllegalStateException,
                                       SLEEException
Get the name of the profile that the Profile object owning this ProfileContext is currently assigned to.

This method is a non-transactional method. The Profile object must be in the Ready state when it invokes this method as otherwise it is not assigned to any particular profile, with the exception that this method may also be successfully called by a profile object during Profile.profilePostCreate().

Returns:
the profile name, or null if the Profile object is associated with the profile table's default profile.
Throws:
java.lang.IllegalStateException - if the Profile object invoking this method is not in the Ready state, with the exception of the Profile.profilePostCreate() method.
SLEEException - if the profile name could not be obtained due to a system-level failure.

getProfileTable

ProfileTable getProfileTable()
                             throws SLEEException
Get an object that implements the Profile Table Interface of the profile table that this ProfileContext is associated with. If the profile specification of the profile table has defined a Profile Table Interface that extends ProfileTable then the object returned from this method may be safely typecast to the subinterface declared in the Profile Specification.

This method is a non-transactional method.

Returns:
a Profile Table Interface object.
Throws:
SLEEException - if the Profile Table Interface object could not be obtained due to a system-level failure.

getProfileTable

ProfileTable getProfileTable(java.lang.String profileTableName)
                             throws java.lang.NullPointerException,
                                    UnrecognizedProfileTableNameException,
                                    SLEEException
Get a ProfileTable object for a profile table. The object returned by this method may be safely typecast to the Profile Table interface defined by the profile specification of the profile table if the profile specification of the profile that this ProfileContext is associated with has the appropriate classes in its classloader to do so, for example by declaring a profile-spec-ref in its deployment descriptor for the profile specification of the Profile Table.

This method is a non-transactional method.

Parameters:
profileTableName - the name of the profile table.
Returns:
a ProfileTable object for the profile table.
Throws:
java.lang.NullPointerException - if profileTableName is null.
UnrecognizedProfileTableNameException - if a profile table with the specified name does not exist.
SLEEException - if the ProfileTable object could not be obtained due to a system-level-failure.

setRollbackOnly

void setRollbackOnly()
                     throws TransactionRequiredLocalException,
                            SLEEException
Mark the current transaction for rollback. The transaction will become permanently marked for rollback. A transaction marked for rollback can never commit.

A Profile object invokes this method when it does not want the current transaction to commit.

This method is a mandatory transactional method.

Throws:
TransactionRequiredLocalException - if this method is invoked without a valid transaction context.
SLEEException - if the current transaction could not be marked for rollback due to a system-level failure.

getRollbackOnly

boolean getRollbackOnly()
                        throws TransactionRequiredLocalException,
                               SLEEException
Test if the current transaction has been marked for rollback only. A Profile object invokes this method while executing within a transaction to determine if the transaction has been marked for rollback.

This method is a mandatory transactional method.

Returns:
true if the current transaction has been marked for rollback, false otherwise.
Throws:
TransactionRequiredLocalException - if this method is invoked without a valid transaction context.
SLEEException - if the current state of the transaction could not be obtained due to a system-level failure.

getTracer

Tracer getTracer(java.lang.String tracerName)
                 throws java.lang.NullPointerException,
                        java.lang.IllegalArgumentException,
                        SLEEException
Get a tracer for the specified tracer name. The notification source used by the tracer is a ProfileTableNotification that contains the profile table name as identified by getProfileTableName().

Refer Tracer for a complete discussion on tracers and tracer names.

Trace notifications generated by a tracer obtained using this method are of the type ProfileTableNotification.TRACE_NOTIFICATION_TYPE.

This method is a non-transactional method.

Parameters:
tracerName - the name of the tracer.
Returns:
a tracer for the specified tracer name. Trace messages generated by this tracer will contain a notification source that is a ProfileTableNotification object containing a profile table name equal to that obtained from the getProfileTableName() method on this ProfileContext.
Throws:
java.lang.NullPointerException - if tracerName is null.
java.lang.IllegalArgumentException - if tracerName is an invalid name. Name components within a tracer name must have at least one character. For example, "com.mycompany" is a valid tracer name, whereas "com..mycompany" is not.
SLEEException - if the Tracer could not be obtained due to a system-level failure.


Copyright © 2009. All Rights Reserved.