00001 /* 00002 * Copyright (c) 2000, 2020, Oracle and/or its affiliates. 00003 * 00004 * Licensed under the Universal Permissive License v 1.0 as shown at 00005 * http://oss.oracle.com/licenses/upl. 00006 */ 00007 #ifndef COH_INVOCABLE_HPP 00008 #define COH_INVOCABLE_HPP 00009 00010 #include "coherence/lang.ns" 00011 00012 COH_OPEN_NAMESPACE2(coherence,net) 00013 00014 class InvocationService; 00015 00016 00017 /** 00018 * The Invocable object is a cluster-portable object that can be invoked on 00019 * any set of remote members and each can optionally register a return value 00020 * for the invocation. 00021 * 00022 * When an Invocable object is received for execution, the order of execution 00023 * is: 00024 * <ul> 00025 * <li>the Invocable object is deserialized by the InvocationService; 00026 * <li>the InvocationService provides a reference to itself to the Invocable 00027 * object by calling the init method; 00028 * <li>the InvocationService invokes the Invocable object by calling the run 00029 * method; 00030 * <li>if the InvocationService is responsible for returning a value from the 00031 * invocation, it obtains the value by calling the getResult method. 00032 * </ul> 00033 * 00034 * @author jh 2007.12.21 00035 */ 00036 class COH_EXPORT Invocable 00037 : public interface_spec<Invocable, 00038 implements<Runnable> > 00039 { 00040 // ----- handle definitions --------------------------------------------- 00041 00042 public: 00043 /** 00044 * InvocationService Handle definition. 00045 */ 00046 typedef TypedHandle<InvocationService> InvocationServiceHandle; 00047 00048 /** 00049 * InvocationService View definition. 00050 */ 00051 typedef TypedHandle<const InvocationService> InvocationServiceView; 00052 00053 00054 // ----- Invocable interface -------------------------------------------- 00055 00056 public: 00057 /** 00058 * Called by the InvocationService exactly once on this Invocable 00059 * object as part of its initialization. 00060 * <p> 00061 * <b>Note:</b> implementations of the Invocable interface that store 00062 * the service reference must do so only in a transient field. 00063 * 00064 * @param hService the containing InvocationService 00065 */ 00066 virtual void init(InvocationServiceHandle hService) = 0; 00067 00068 /** 00069 * Determine the result from the invocation of this object. This 00070 * method is called by the InvocationService after the run() method 00071 * returns. 00072 * 00073 * @return the invocation result, if any 00074 */ 00075 virtual Object::Holder getResult() const = 0; 00076 }; 00077 00078 COH_CLOSE_NAMESPACE2 00079 00080 #endif // COH_INVOCABLE_HPP