001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, 013 * software distributed under the License is distributed on an 014 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY 015 * KIND, either express or implied. See the License for the 016 * specific language governing permissions and limitations 017 * under the License. 018 */ 019 020package org.apache.isis.core.metamodel.facets.actions.invoke; 021 022import java.util.Arrays; 023import java.util.List; 024 025import org.apache.isis.applib.services.command.Command; 026import org.apache.isis.applib.services.command.CommandContext; 027import org.apache.isis.core.metamodel.adapter.ObjectAdapter; 028import org.apache.isis.core.metamodel.facetapi.Facet; 029import org.apache.isis.core.metamodel.facetapi.IdentifiedHolder; 030import org.apache.isis.core.metamodel.spec.ObjectSpecification; 031import org.apache.isis.core.metamodel.spec.feature.ObjectAction; 032 033/** 034 * Represents the mechanism by which the action should be invoked. 035 * 036 * <p> 037 * In the standard Apache Isis Programming Model, corresponds to invoking the 038 * actual action method itself (a <tt>public</tt> method that does not represent 039 * a property, a collection or any of the supporting methods). 040 */ 041public interface ActionInvocationFacet extends Facet { 042 043 @Deprecated 044 public ObjectAdapter invoke(ObjectAdapter target, ObjectAdapter[] parameters); 045 046 public ObjectAdapter invoke(ObjectAction owningAction, ObjectAdapter target, ObjectAdapter[] arguments); 047 048 public ObjectSpecification getReturnType(); 049 050 public ObjectSpecification getOnType(); 051 052 public static class CurrentInvocation { 053 054 private final Command command; 055 056 private final ObjectAdapter target; 057 private final IdentifiedHolder action; 058 private final List<ObjectAdapter> parameters; 059 private final ObjectAdapter result; 060 061 public CurrentInvocation( 062 final ObjectAdapter target, final IdentifiedHolder action, final ObjectAdapter[] parameters, 063 final ObjectAdapter result, 064 final Command command) { 065 this(target, action, Arrays.asList(parameters), result, command); 066 } 067 068 public CurrentInvocation( 069 final ObjectAdapter target, final IdentifiedHolder action, final List<ObjectAdapter> parameters, 070 final ObjectAdapter result, 071 final Command command) { 072 this.target = target; 073 this.action = action; 074 this.parameters = parameters; 075 this.result = result; 076 this.command = command; 077 } 078 079 /** 080 * deprecated since part of {@link #getCommand()} 081 */ 082 @Deprecated 083 public ObjectAdapter getTarget() { 084 return target; 085 } 086 /** 087 * deprecated since part of {@link #getCommand()} 088 */ 089 @Deprecated 090 public IdentifiedHolder getAction() { 091 return action; 092 } 093 094 public List<ObjectAdapter> getParameters() { 095 return parameters; 096 } 097 098 /** 099 * deprecated since part of {@link #getCommand()} 100 */ 101 @Deprecated 102 public ObjectAdapter getResult() { 103 return result; 104 } 105 106 public Command getCommand() { 107 return command; 108 } 109 } 110 111 /** 112 * TODO... 113 * @deprecated - should instead use the {@link CommandContext} request. 114 */ 115 @Deprecated 116 public static ThreadLocal<CurrentInvocation> currentInvocation = new ThreadLocal<CurrentInvocation>(); 117 118 119}