org.nakedobjects.metamodel.specloader.internal
Class NakedObjectActionImpl

java.lang.Object
  extended by org.nakedobjects.metamodel.runtimecontext.spec.feature.NakedObjectMemberAbstract
      extended by org.nakedobjects.metamodel.specloader.internal.NakedObjectActionImpl
All Implemented Interfaces:
FacetHolder, NakedObjectAction, NakedObjectFeature, NakedObjectMember, Identified, NamedAndDescribed, Specification, TypedSpecification

public class NakedObjectActionImpl
extends NakedObjectMemberAbstract
implements NakedObjectAction


Nested Class Summary
 
Nested classes/interfaces inherited from class org.nakedobjects.metamodel.runtimecontext.spec.feature.NakedObjectMemberAbstract
NakedObjectMemberAbstract.MemberType
 
Field Summary
 
Fields inherited from class org.nakedobjects.metamodel.runtimecontext.spec.feature.NakedObjectMemberAbstract
defaultName
 
Constructor Summary
NakedObjectActionImpl(java.lang.String methodId, NakedObjectActionPeer nakedObjectActionPeer, RuntimeContext runtimeContext)
           
 
Method Summary
 ActionInvocationContext createActionInvocationInteractionContext(AuthenticationSession session, InteractionInvocationMethod invocationMethod, NakedObject targetObject, NakedObject[] proposedArguments)
          Creates an interaction context representing an attempt to invoke this action.
 UsabilityContext<?> createUsableInteractionContext(AuthenticationSession session, InteractionInvocationMethod invocationMethod, NakedObject targetNakedObject)
          Create an InteractionContext to represent an attempt to use this member (that is, to check if it is usable or not).
 VisibilityContext<?> createVisibleInteractionContext(AuthenticationSession session, InteractionInvocationMethod invocationMethod, NakedObject targetNakedObject)
          Create an InteractionContext to represent an attempt to view this member (that is, to check if it is visible or not).
 java.lang.String debugData()
           
 NakedObject execute(NakedObject object, NakedObject[] parameters)
          Invokes the action's method on the target object given the specified set of parameters.
 NakedObjectAction[] getActions()
          Lists the sub-actions that are available under this name.
 NakedObject[][] getChoices(NakedObject target)
          Returns a list of possible references/values for each parameter, which the user can choose from.
 NakedObject[] getDefaults(NakedObject target)
          Returns the defaults references/values to be used for the action.
 Instance getInstance(NakedObject nakedObject)
          Return an Instance of this Specification with respect to the provided NakedObject.
 NakedObjectSpecification getOnType()
          Returns the specification for the type of object that this action can be invoked upon.
 int getParameterCount()
          Returns the number of parameters used by this method.
 NakedObjectActionParameter[] getParameters()
          Build lazily by getParameters().
 NakedObjectActionParameter[] getParameters(Filter<NakedObjectActionParameter> filter)
          Returns set of parameter information matching the supplied filter.
 NakedObjectSpecification[] getParameterTypes()
          Returns the type of each of the parameters.
 NakedObjectSpecification getReturnType()
          Returns the specifications for the return type.
 NakedObjectSpecification getSpecification()
          Always returns null.
 Target getTarget()
          Returns where the action should be executed: explicitly locally on the client; explicitly remotely on the server; or where it normally should be executed.
 NakedObjectActionType getType()
          Returns the type of action: user, exploration or debug, or that it is a set of actions.
static NakedObjectActionType getType(java.lang.String typeStr)
           
 boolean hasReturn()
          Returns true if the represented action returns something, else returns false.
 boolean isContributed()
          Return true if the action is run on a service object using the target object as a parameter.
 Consent isProposedArgumentSetValid(NakedObject object, NakedObject[] proposedArguments)
          TODO: currently this method is hard-coded to assume all interactions are initiated by user.
 Consent isUsable(AuthenticationSession session, NakedObject target)
          Loops over all DisablingInteractionAdvisor Facets and returns true only if none disables the member.
 Consent isVisible(AuthenticationSession session, NakedObject target)
          Loops over all HidingInteractionAdvisor Facets and returns true only if none hide the member.
 boolean promptForParameters(NakedObject target)
           
 NakedObject realTarget(NakedObject target)
          Previously (prior to 3.0.x) this method had a check to see if the action was on an instance.
 java.lang.String toString()
           
 
Methods inherited from class org.nakedobjects.metamodel.runtimecontext.spec.feature.NakedObjectMemberAbstract
addFacet, addFacet, containsFacet, getAuthenticationSession, getDescription, getFacet, getFacets, getFacetTypes, getHelp, getId, getIdentifier, getName, getRuntimeContext, isAction, isAssociation, isOneToManyAssociation, isOneToOneAssociation, removeFacet, removeFacet
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.nakedobjects.metamodel.spec.feature.NakedObjectMember
getHelp, getId, isAction, isAssociation, isOneToManyAssociation, isOneToOneAssociation
 
Methods inherited from interface org.nakedobjects.metamodel.spec.identifier.Identified
getIdentifier
 
Methods inherited from interface org.nakedobjects.metamodel.facets.FacetHolder
addFacet, addFacet, containsFacet, getFacet, getFacets, getFacetTypes, removeFacet, removeFacet
 
Methods inherited from interface org.nakedobjects.metamodel.spec.NamedAndDescribed
getDescription, getName
 

Constructor Detail

NakedObjectActionImpl

public NakedObjectActionImpl(java.lang.String methodId,
                             NakedObjectActionPeer nakedObjectActionPeer,
                             RuntimeContext runtimeContext)
Method Detail

getType

public static NakedObjectActionType getType(java.lang.String typeStr)

getSpecification

public NakedObjectSpecification getSpecification()
Always returns null.

Specified by:
getSpecification in interface TypedSpecification

getReturnType

public NakedObjectSpecification getReturnType()
Description copied from interface: NakedObjectAction
Returns the specifications for the return type.

Specified by:
getReturnType in interface NakedObjectAction

hasReturn

public boolean hasReturn()
Returns true if the represented action returns something, else returns false.

Specified by:
hasReturn in interface NakedObjectAction

getOnType

public NakedObjectSpecification getOnType()
Description copied from interface: NakedObjectAction
Returns the specification for the type of object that this action can be invoked upon.

Specified by:
getOnType in interface NakedObjectAction

getActions

public NakedObjectAction[] getActions()
Description copied from interface: NakedObjectAction
Lists the sub-actions that are available under this name.

If any actions are returned then this action is only a set and not an action itself.

Specified by:
getActions in interface NakedObjectAction

getInstance

public Instance getInstance(NakedObject nakedObject)
Description copied from interface: Specification
Return an Instance of this Specification with respect to the provided NakedObject.

For example, if the Specification is a OneToOneAssociation, then is an Instance implementation representing the { NakedObject/ OneToOneAssociation } tuple.

Implementations are expected to use a double-dispatch back to the provided NakedObject (passing themselves as a parameter), using NakedObjectMM.getInstance(Specification).

Note: this method may throw an UnsupportedOperationException; see NakedObjectMM.getInstance(Specification) for details.

Specified by:
getInstance in interface Specification

getTarget

public Target getTarget()
Description copied from interface: NakedObjectAction
Returns where the action should be executed: explicitly locally on the client; explicitly remotely on the server; or where it normally should be executed. By default instance methods should execute on the server, static methods should execute on the client.

Specified by:
getTarget in interface NakedObjectAction
See Also:
NakedObjectActionConstants.LOCAL, NakedObjectActionConstants.REMOTE, NakedObjectActionConstants.DEFAULT

getType

public NakedObjectActionType getType()
Description copied from interface: NakedObjectAction
Returns the type of action: user, exploration or debug, or that it is a set of actions.

Specified by:
getType in interface NakedObjectAction
See Also:
NakedObjectActionConstants.USER, NakedObjectActionConstants.EXPLORATION, NakedObjectActionConstants.DEBUG, NakedObjectActionConstants.SET

isContributed

public boolean isContributed()
Description copied from interface: NakedObjectAction
Return true if the action is run on a service object using the target object as a parameter.

Specified by:
isContributed in interface NakedObjectAction

getParameterCount

public int getParameterCount()
Description copied from interface: NakedObjectAction
Returns the number of parameters used by this method.

Specified by:
getParameterCount in interface NakedObjectAction

promptForParameters

public boolean promptForParameters(NakedObject target)
Specified by:
promptForParameters in interface NakedObjectAction

getParameters

public NakedObjectActionParameter[] getParameters()
Build lazily by getParameters().

Although this is lazily loaded, the method is also synchronized so there shouldn't be any thread race conditions.

Specified by:
getParameters in interface NakedObjectAction
Returns:

getParameterTypes

public NakedObjectSpecification[] getParameterTypes()
Description copied from interface: NakedObjectAction
Returns the type of each of the parameters.

Specified by:
getParameterTypes in interface NakedObjectAction

getParameters

public NakedObjectActionParameter[] getParameters(Filter<NakedObjectActionParameter> filter)
Description copied from interface: NakedObjectAction
Returns set of parameter information matching the supplied filter.

Specified by:
getParameters in interface NakedObjectAction
Returns:

createVisibleInteractionContext

public VisibilityContext<?> createVisibleInteractionContext(AuthenticationSession session,
                                                            InteractionInvocationMethod invocationMethod,
                                                            NakedObject targetNakedObject)
Description copied from interface: NakedObjectMember
Create an InteractionContext to represent an attempt to view this member (that is, to check if it is visible or not).

Typically it is easier to just call NakedObjectMember.isVisible(AuthenticationSession, NakedObject) or #isVisibleResult(AuthenticationSession, NakedObject); this is provided as API for symmetry with interactions (such as AccessContext accesses) have no corresponding vetoing methods.

Specified by:
createVisibleInteractionContext in interface NakedObjectMember
Returns:

isVisible

public Consent isVisible(AuthenticationSession session,
                         NakedObject target)
Description copied from class: NakedObjectMemberAbstract
Loops over all HidingInteractionAdvisor Facets and returns true only if none hide the member.

TODO: currently this method is hard-coded to assume all interactions are initiated by user.

Specified by:
isVisible in interface NakedObjectMember
Overrides:
isVisible in class NakedObjectMemberAbstract
target - may be null if just checking for authorization.
See Also:
#isVisibleResult(AuthenticationSession, NakedObject)

createUsableInteractionContext

public UsabilityContext<?> createUsableInteractionContext(AuthenticationSession session,
                                                          InteractionInvocationMethod invocationMethod,
                                                          NakedObject targetNakedObject)
Description copied from interface: NakedObjectMember
Create an InteractionContext to represent an attempt to use this member (that is, to check if it is usable or not).

Typically it is easier to just call NakedObjectMember.isUsable(AuthenticationSession, NakedObject) or #isUsableResult(AuthenticationSession, NakedObject); this is provided as API for symmetry with interactions (such as AccessContext accesses) have no corresponding vetoing methods.

Specified by:
createUsableInteractionContext in interface NakedObjectMember
Returns:

isUsable

public Consent isUsable(AuthenticationSession session,
                        NakedObject target)
Description copied from class: NakedObjectMemberAbstract
Loops over all DisablingInteractionAdvisor Facets and returns true only if none disables the member.

TODO: currently this method is hard-coded to assume all interactions are initiated by user.

Specified by:
isUsable in interface NakedObjectMember
Overrides:
isUsable in class NakedObjectMemberAbstract
target - may be null if just checking for authorization.
See Also:
#isUsableResult(AuthenticationSession, NakedObject)

isProposedArgumentSetValid

public Consent isProposedArgumentSetValid(NakedObject object,
                                          NakedObject[] proposedArguments)
TODO: currently this method is hard-coded to assume all interactions are initiated by user.

Specified by:
isProposedArgumentSetValid in interface NakedObjectAction

createActionInvocationInteractionContext

public ActionInvocationContext createActionInvocationInteractionContext(AuthenticationSession session,
                                                                        InteractionInvocationMethod invocationMethod,
                                                                        NakedObject targetObject,
                                                                        NakedObject[] proposedArguments)
Description copied from interface: NakedObjectAction
Creates an interaction context representing an attempt to invoke this action.

Typically it is easier to just call #isProposedArgumentSetValid(NakedObject, NakedObject[]) {@link #isProposedArgumentSetValidResultSet(NakedObject, NakedObject[])}; this is provided as API for symmetry with interactions (such as {@link AccessContext} accesses) have no corresponding vetoing methods.

Specified by:
createActionInvocationInteractionContext in interface NakedObjectAction

execute

public NakedObject execute(NakedObject object,
                           NakedObject[] parameters)
Description copied from interface: NakedObjectAction
Invokes the action's method on the target object given the specified set of parameters.

Specified by:
execute in interface NakedObjectAction

realTarget

public NakedObject realTarget(NakedObject target)
Previously (prior to 3.0.x) this method had a check to see if the action was on an instance. With the reflector redesign this has been removed, because NOF 3.x only supports instance methods, not class-level methods.

Specified by:
realTarget in interface NakedObjectAction

getDefaults

public NakedObject[] getDefaults(NakedObject target)
Description copied from interface: NakedObjectAction
Returns the defaults references/values to be used for the action.

Specified by:
getDefaults in interface NakedObjectAction

getChoices

public NakedObject[][] getChoices(NakedObject target)
Description copied from interface: NakedObjectAction
Returns a list of possible references/values for each parameter, which the user can choose from.

Specified by:
getChoices in interface NakedObjectAction

debugData

public java.lang.String debugData()
Specified by:
debugData in interface NakedObjectMember

toString

public java.lang.String toString()
Overrides:
toString in class NakedObjectMemberAbstract


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