net.larsan.norna.util
Class ThreadScope

java.lang.Object
  |
  +--net.larsan.norna.util.ThreadScope

public class ThreadScope
extends java.lang.Object

The thread scope is used by Norna framework implementations to distinguish between the owners of excuting threads. The scope keeps executing IDs in a stack which can be entered and exited before and after calling any method.

The ID used by the thread scope is a Namespace ID (please refer to the Namespace documentation for more information if framework IDs.

A service is be required by the Norna specification to enter a thread scope using its Namespace ID as soon as it call a method on any object outside its own namespace. In particular a service should enter the thread scope when dealing with: 1) Other services; 2) The ServiceRegistry, and; 3) When calling methods on its Context.

A service get its Namespace ID from the Context. The thread scope is only used when services access each other and the registry, and any service that does so must implement the Loadable interface. The thread scope uses the ThreadScopePermission to access to the methods of this class. In particual, no service should have access to the clear method.

Version:
Alpha-0.2 / 2002-10-06 21:37
Author:
Lars J. Nilsson
See Also:
net.larsan.norna.Context

Method Summary
static void clear()
          Clear the current execution stack of all IDs.
static java.lang.String current()
          Get the ID of the current executing service.
static void enter(java.lang.String nuid)
          Enter thread scope from a particular ID.
static void exit(java.lang.String nuid)
          Exit current ID scope.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

enter

public static void enter(java.lang.String nuid)
Enter thread scope from a particular ID. This ID can later be retrieved by the context in which the thread executes and thus limit the need for tedious ID passing in method arguments.

Parameters:
nuid - Namespace unique ID for the service entering the scope

current

public static java.lang.String current()
Get the ID of the current executing service. This will return the ID of the latest entered scope or null if no scope is entered.

Returns:
The ID of the executing service

exit

public static void exit(java.lang.String nuid)
Exit current ID scope. If the given ID is not the one on top of the execution stack nothing will happend.

Parameters:
nuid - namespace unique ID to exit from

clear

public static void clear()
Clear the current execution stack of all IDs. This method should be called nby the framework as soon as an thread returns from executing on a service.