org.nakedobjects.metamodel.interactions
Class InteractionContext<T extends InteractionEvent>

java.lang.Object
  extended by org.nakedobjects.metamodel.interactions.InteractionContext<T>
Direct Known Subclasses:
AccessContext, UsabilityContext, ValidityContext, VisibilityContext

public abstract class InteractionContext<T extends InteractionEvent>
extends java.lang.Object

Represents an interaction between the framework and (a Facet of) the domain object.

There are two main responsibilities:

The InteractionContext hierarchy is parallel to the InteractionEvent hierarchy. Having parallel hierarchies is a bit of a code-smell. However, it is required because the context hierarchy is internal to the framework (with references to NakedObjects, AuthenticationSessions and so forth), whereas the event hierarchy is part of the corelib, that is public API.

The class is genericized so that the factory method can return the correct subclass without having to downcast.


Constructor Summary
InteractionContext(InteractionContextType interactionType, AuthenticationSession session, InteractionInvocationMethod invocationMethod, Identifier identifier, NakedObject target)
           
 
Method Summary
abstract  T createInteractionEvent()
          Factory method to create corresponding InteractionEvent.
 Identifier getIdentifier()
          The identifier of the object or member that is being identified with.
 InteractionContextType getInteractionType()
          The type of interaction.
 InteractionInvocationMethod getInvocationMethod()
          How the interaction was initiated.
 AuthenticationSession getSession()
          The user or role that is performing this interaction.
 NakedObject getTarget()
          The target object that this interaction is with.
 boolean isProgrammatic()
          Convenience method that indicates whether the interaction was invoked programmatically.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

InteractionContext

public InteractionContext(InteractionContextType interactionType,
                          AuthenticationSession session,
                          InteractionInvocationMethod invocationMethod,
                          Identifier identifier,
                          NakedObject target)
Method Detail

getInteractionType

public InteractionContextType getInteractionType()
The type of interaction.

Available for use by Facets that apply only in certain conditions. For example, some facets for collections will care only when an object is being added to the collection, but won't care when an object is being removed from the collection.

Alternatively, Facets can use instanceof.


getIdentifier

public Identifier getIdentifier()
The identifier of the object or member that is being identified with.

If the type is InteractionContextType.OBJECT_VALIDATE, will be the identifier of the target object's specification. Otherwise will be the identifier of the member.


getSession

public AuthenticationSession getSession()
The user or role that is performing this interaction.


getInvocationMethod

public InteractionInvocationMethod getInvocationMethod()
How the interaction was initiated.


isProgrammatic

public boolean isProgrammatic()
Convenience method that indicates whether the interaction was invoked programmatically.


getTarget

public NakedObject getTarget()
The target object that this interaction is with.


createInteractionEvent

public abstract T createInteractionEvent()
Factory method to create corresponding InteractionEvent.

Returns:


Copyright © 2001-2009 Naked Objects Group Ltd.. All Rights Reserved.