com.sun.sgs.impl.kernel
Class ContextResolver

java.lang.Object
  extended by com.sun.sgs.impl.kernel.ContextResolver

final class ContextResolver
extends Object

This class is used to resolve the state associated with the current task's context, including its owner and active transaction.


Method Summary
(package private) static void clearCurrentTransaction(Transaction transaction)
          Clears the currently active Transaction.
static ChannelManager getChannelManager()
          Returns the ChannelManager used in this context.
(package private) static KernelContext getContext()
          Package-private method used to get the current context.
(package private) static Identity getCurrentOwner()
          Returns the current owner of the work being done by this thread.
(package private) static Transaction getCurrentTransaction()
          Returns the current Transaction, throwing an exception if there is no currently active transaction or if the currently active transaction has timed out.
static DataManager getDataManager()
          Returns the DataManager used in this context.
static
<T> T
getManager(Class<T> type)
          Returns the manager in this context that matches the given type.
static TaskManager getTaskManager()
          Returns the TaskManager used in this context.
(package private) static boolean inTransaction()
          Returns true if there is a current transaction, no matter the state of that transaction.
(package private) static boolean isCurrentTransaction()
          Returns whether there is a currently active transaction.
(package private) static void setCurrentTransaction(Transaction transaction)
          Sets the current Transaction, throwing an exception if there is already an active transaction.
(package private) static void setTaskState(KernelContext ctx, Identity owner)
          Package-private method used to set task state.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getChannelManager

public static ChannelManager getChannelManager()
Returns the ChannelManager used in this context.

Returns:
the context's ChannelManager.
Throws:
IllegalStateException - if there is no available ChannelManager in this context

getDataManager

public static DataManager getDataManager()
Returns the DataManager used in this context.

Returns:
the context's DataManager.
Throws:
IllegalStateException - if there is no available DataManager in this context

getTaskManager

public static TaskManager getTaskManager()
Returns the TaskManager used in this context.

Returns:
the context's TaskManager.
Throws:
IllegalStateException - if there is no available TaskManager in this context

getManager

public static <T> T getManager(Class<T> type)
Returns the manager in this context that matches the given type.

Type Parameters:
T - the type of the manager
Parameters:
type - the Class of the requested manager
Returns:
the matching manager
Throws:
ManagerNotFoundException - if no manager is found that matches the given type
IllegalStateException - if there are no available managers in this context

setTaskState

static void setTaskState(KernelContext ctx,
                         Identity owner)
Package-private method used to set task state. This is called each time a task is run through a Scheduler

Parameters:
ctx - the KernelContext for the current task
owner - the Identity that owns the current task

getContext

static KernelContext getContext()
Package-private method used to get the current context.

Returns:
the current AppKernelAppContext

getCurrentOwner

static Identity getCurrentOwner()
Returns the current owner of the work being done by this thread.

Returns:
the Identity that owns the current task

getCurrentTransaction

static Transaction getCurrentTransaction()
Returns the current Transaction, throwing an exception if there is no currently active transaction or if the currently active transaction has timed out.

Returns:
the currently active Transaction
Throws:
TransactionNotActiveException - if there is no currently active transaction
TransactionTimeoutException - if the transaction has timed out

inTransaction

static boolean inTransaction()
Returns true if there is a current transaction, no matter the state of that transaction.

Returns:
true if there is a current transaction

setCurrentTransaction

static void setCurrentTransaction(Transaction transaction)
Sets the current Transaction, throwing an exception if there is already an active transaction.

Parameters:
transaction - the Transaction to set as currently active
Throws:
IllegalStateException - if there is already an active transaction

clearCurrentTransaction

static void clearCurrentTransaction(Transaction transaction)
Clears the currently active Transaction. This is typically done once a transaction has finished.

Parameters:
transaction - the Transaction to clear, which must be the currently active transaction
Throws:
IllegalStateException - if there is no currently active transaction to clear
IllegalArgumentException - if the given Transaction is not the active transaction

isCurrentTransaction

static boolean isCurrentTransaction()
Returns whether there is a currently active transaction.

Returns:
true if there is currently an active transaction, false otherwise

RedDwarf, Version 0.10.1
2010-03-14 10:56:12

Copyright © 2010 The RedDwarf Authors. All rights reserved
Copyright © 2007-2010 Sun Microsystems, Inc. All rights reserved