PageRenderTime 28ms CodeModel.GetById 17ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/interpreter/tags/at2dist170907/src/edu/vub/at/actors/ATActorMirror.java

http://ambienttalk.googlecode.com/
Java | 151 lines | 16 code | 14 blank | 121 comment | 0 complexity | 2917871cf170e20e431b5c769f14ee52 MD5 | raw file
  1/**
  2 * AmbientTalk/2 Project
  3 * ATActorMirror.java created on Aug 21, 2006
  4 * (c) Programming Technology Lab, 2006 - 2007
  5 * Authors: Tom Van Cutsem & Stijn Mostinckx
  6 * 
  7 * Permission is hereby granted, free of charge, to any person
  8 * obtaining a copy of this software and associated documentation
  9 * files (the "Software"), to deal in the Software without
 10 * restriction, including without limitation the rights to use,
 11 * copy, modify, merge, publish, distribute, sublicense, and/or
 12 * sell copies of the Software, and to permit persons to whom the
 13 * Software is furnished to do so, subject to the following
 14 * conditions:
 15 *
 16 * The above copyright notice and this permission notice shall be
 17 * included in all copies or substantial portions of the Software.
 18 *
 19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 20 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 21 * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 22 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 23 * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 24 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 25 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 26 * OTHER DEALINGS IN THE SOFTWARE.
 27 */
 28
 29package edu.vub.at.actors;
 30
 31import edu.vub.at.exceptions.InterpreterException;
 32import edu.vub.at.objects.ATBoolean;
 33import edu.vub.at.objects.ATClosure;
 34import edu.vub.at.objects.ATObject;
 35import edu.vub.at.objects.ATTypeTag;
 36import edu.vub.at.objects.ATTable;
 37import edu.vub.at.objects.grammar.ATSymbol;
 38
 39/**
 40 * The class ATActorMirror prescribes the minimal set of methods to be provided by the default 
 41 * implementation of an actor mirror. Since new actor mirrors can be installed dynamically, 
 42 * ATActorMirror defines the dependencies of the lexically scoped objects on the dynamic 'actor 
 43 * context' to perform their duties. The hooks defined in this class relate to:
 44 * 
 45 * <ul>
 46 *   <li>Asynchronous message creation and sending to influence the communication protocol</li>
 47 *   <li>Service advertising and requesting to influence the service discovery protocol</li>
 48 *   <li>Mirror creation to provide support for true stratification</li>
 49 *   <li>Actor protocol installation to deal with actor mirror interaction and to allow freezing
 50 *   an actor with a given protocol</li>
 51 * </ul>
 52 *
 53 * @author smostinc
 54 */
 55public interface ATActorMirror extends ATObject {
 56		
 57    /* ---------------------------------------------------
 58     * -- Language Construct to NATActorMirror Protocol --
 59     * --------------------------------------------------- */
 60
 61	/**
 62	 * Creates a first-class message in the language. Note that upon creation the
 63	 * message does not have a receiver yet. This field will be set once the message
 64	 * is actually being sent, a fact which can be intercepted by overriding the sendTo
 65	 * base-level method.
 66	 * 
 67	 * @param selector the name of the method to trigger remotely
 68	 * @param arguments the actual arguments of the message
 69	 * @param types the types with which the message will be born
 70	 */
 71	public ATAsyncMessage base_createMessage(ATSymbol selector, ATTable arguments, ATTable types) throws InterpreterException;
 72	
 73	/**
 74	 * Creates a mirror on the given object. This method serves as the 'mirror factory'
 75	 * for the current actor.
 76	 */
 77	public ATObject base_createMirror(ATObject onObject) throws InterpreterException;
 78	
 79	/**
 80	 * This method implements the default asynchronous message sending semantics for
 81	 * this particular actor. In addition to the ability to override the send meta-
 82	 * operation on a single object to have specific adaptions, this hook allows the
 83	 * programmer to modify the message sending semantics for all objects inside an 
 84	 * actor. The default implementation ensures the correct passing of messages when
 85	 * they transgress the boundaries of the sending actor. 
 86	 * 
 87	 * @throws InterpreterException
 88	 */
 89	public ATObject base_send(ATObject receiver, ATAsyncMessage message) throws InterpreterException;
 90	
 91	/**
 92	 * This mechanism is the most basic mechanism to provide a service. It requires 
 93	 * a separate service description and an object offering the service. The return
 94	 * value is a publication object which allows cancelling the service offer.
 95	 */
 96	public ATObject base_provide(ATTypeTag topic, ATObject service) throws InterpreterException;
 97	
 98	/**
 99	 * This mechanism is the most basic mechanism to require a service. The return
100	 * value is a subscription object which allows cancelling the service offer.
101	 * @param bool - if true, the subscription is permanent, if false, once the subscription
102	 * has been satisfied, it is automatically cancelled.
103	 */
104	public ATObject base_require(ATTypeTag topic, ATClosure handler, ATBoolean bool) throws InterpreterException;
105	
106	/**
107	 * def oldprotocol := actor.install: newprotocol
108	 * 
109	 * Installs a new meta-object protocol into this actor.
110	 * 
111	 * @param protocol meta-level code that overrides an actor's MOP methods
112	 * @return the previously installed meta-object protocol
113	 */
114	public ATObject base_install_(ATActorMirror protocol) throws InterpreterException;
115	
116    /* -------------------------------------
117     * -- Object Passing Protocol Support --
118     * ------------------------------------- */
119
120	/**
121	 * This mechanism interacts with the built-in receptionists set of the actor to 
122	 * produce a new far object reference to a local object. The created far object
123	 * is by no means unique within the actor that created it. 
124	 * 
125	 * Creating such far references is performed when passing objects by reference
126	 * in the meta_pass method of scoped objects such as closures, objects and fields.
127	 * 
128	 * @param object the local object to be given a reference to
129	 * @return a newly created far object reference
130	 * 
131	 * @see edu.vub.at.objects.ATObject#meta_pass(ATFarReference)
132	 */
133	//public ATFarReference base_export(ATObject object) throws InterpreterException;
134	
135	/**
136	 * This mechanism interacts with the built-in receptionists set of the actor to 
137	 * resolve far references (which were received as part of an async message). The
138	 * method returns a local object whenever the far object denotes an object 
139	 * hosted by this actor. 
140	 * 
141	 * If the denoted object is not hosted by this actor, a far object (possibly but
142	 * not necessarily the passed one) is returned which is the local and unique 
143	 * representative of the remote object. This object will contain the queue of 
144	 * messages to be transmitted to the remote object. 
145	 * 
146	 * @param farReference the far reference to be resolved
147	 * @return a local object | a unique far reference for this actor
148	 */
149	//public ATObject base_resolve(ATFarReference farReference) throws InterpreterException;
150
151}