wt.method
Class MethodContext

java.lang.Object
  extended by java.util.Dictionary<K,V>
      extended by java.util.Hashtable
          extended by wt.method.MethodContext
All Implemented Interfaces:
Serializable, Cloneable, Map, wt.method.MethodLocalSource

public final class MethodContext
extends Hashtable
implements wt.method.MethodLocalSource

Context corresponding to an active method invocation in the method server. This class maintains an association between threads and resources currently assigned to the threads such as a database connections.

This class extends java.util.Hashtable so it can be used to maintain thread local storage that pertains to a particular method invocation. Methods are free to store whatever values they need under unique keys with confidence that the references will be freed when this context is unregistered.

For RMI calls, it is created immediately before argument unmarshaling begins and is unregisted after the reply has been marshaled back to the client. For non-RMI contexts (CORBA or internal), the context must be explicitly constructed and unregistered.

Supported API: true
Extendable: false

See Also:
Serialized Form

Nested Class Summary
static interface wt.method.MethodContext.Listener
           
 
Constructor Summary
MethodContext(String client_host, Object authentication)
          Public constructor for use by non-RMI threads Associates the current thread with a new context.
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener listener)
          Add a PropertyChangeListener to the listener list.
 Object[] getArgObjects()
          Get the argument array for the method invoked by this context.
 Class[] getArgTypes()
          Get the argument class array for the method invoked by this context.
 Object getAuthentication()
          Get the authentication object associated with this context.
 String getClientHost()
          Get the client host name for this context.
static MethodContext getContext()
          Get the current thread's method context.
 String getTargetClassName()
          Get the name of the target class invoked by this context.
 String getTargetMethodName()
          Get the name of the target method invoked by this context.
 Object getTargetObject()
          Get the target object of the method invoked by this context.
 Object put(Object key, Object value)
          Override Hashtable.put to add property change support.
 Object remove(Object key)
          Override Hashtable.remove to add property change support.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Remove a PropertyChangeListener from the listener list.
 boolean sendFeedback(MethodFeedback feedback)
          Send feedback objects to RMI client while call is being processed A return value of false indicates that the client has disconnected.
 void setAuthentication(Object auth)
          Set the authentication object associated with this context.
 void setThread(Thread thread)
          Set the thread associated with this context.
 void unregister()
          Unregister this method context.
 
Methods inherited from class java.util.Hashtable
clear, clone, contains, containsKey, containsValue, elements, entrySet, equals, get, hashCode, isEmpty, keys, keySet, putAll, rehash, size, toString, values
 
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

MethodContext

public MethodContext(String client_host,
                     Object authentication)
Public constructor for use by non-RMI threads Associates the current thread with a new context. The thread is responsible for unregistering itself before termination.

Supported API: true

Parameters:
client_host - calling client hostname - may be needed to validate authentication
authentication - opaque authentication object
See Also:
Authenticator
Method Detail

unregister

public void unregister()
Unregister this method context. Active database connection is automatically freed.

Supported API: true


setThread

public void setThread(Thread thread)
Set the thread associated with this context. This can be used to hand control of this operation to another thread. The current thread will no longer have an associated method context. Thread priorities are not changed.

Supported API: true

Parameters:
thread - the thread for this context

getContext

public static MethodContext getContext()
Get the current thread's method context. Throws a runtime exception if there is no active context.

Supported API: true


getTargetMethodName

public String getTargetMethodName()
Get the name of the target method invoked by this context. Returns null if this context is not associated with a client call.

Supported API: true


getTargetClassName

public String getTargetClassName()
Get the name of the target class invoked by this context. Returns null if this context is not associated with a client call.

Supported API: true


getTargetObject

public Object getTargetObject()
Get the target object of the method invoked by this context. Returns null if this context is not associated with a client call. Throws a NullPointerException if called before the object is completely unmarshaled from the caller.

Supported API: true


getArgObjects

public Object[] getArgObjects()
Get the argument array for the method invoked by this context. Returns null if this context is not associated with a client call or there were no arguments. If called during argument unmarshaling, the array will exist but all elements may not have been set.

Supported API: true


getArgTypes

public Class[] getArgTypes()
Get the argument class array for the method invoked by this context. Returns null if this context is not associated with a client call or there were no arguments. If called during argument unmarshaling, the array will exist but all elements may not have been set.

Supported API: true


getClientHost

public String getClientHost()
Get the client host name for this context. Returns null if this is not a client call (internal context).

Supported API: true


getAuthentication

public Object getAuthentication()
Get the authentication object associated with this context. Returns null if no authentication is associated with this call.

Supported API: true


setAuthentication

public void setAuthentication(Object auth)
Set the authentication object associated with this context.

Supported API: true


sendFeedback

public boolean sendFeedback(MethodFeedback feedback)
Send feedback objects to RMI client while call is being processed A return value of false indicates that the client has disconnected. Operations may wish to abort if the client is no longer waiting for a response.

Supported API: true

Parameters:
feedback - the feedback object
Returns:
true if successfully written, false if an IOException was caught

addPropertyChangeListener

public void addPropertyChangeListener(PropertyChangeListener listener)
Add a PropertyChangeListener to the listener list. Property change events will be fired to all registered listeners whenever a value in this hashtable is added, changed, or removed.

Supported API: true

Parameters:
listener - the PropertyChangeListener to be added

removePropertyChangeListener

public void removePropertyChangeListener(PropertyChangeListener listener)
Remove a PropertyChangeListener from the listener list.

Supported API: true

Parameters:
listener - the PropertyChangeListener to be removed

put

public Object put(Object key,
                  Object value)
Override Hashtable.put to add property change support.

Supported API: true

Specified by:
put in interface Map
Overrides:
put in class Hashtable
Parameters:
key - the hashtable key
value - the value
Returns:
the previous value of the specified key in this hashtable, or null if it did not have one.
See Also:
Hashtable

remove

public Object remove(Object key)
Override Hashtable.remove to add property change support.

Supported API: true

Specified by:
remove in interface Map
Overrides:
remove in class Hashtable
Parameters:
key - the key that needs to be removed
Returns:
the value to which the key had been mapped in this hashtable, or null if the key did not have a mapping.
See Also:
Hashtable