PageRenderTime 33ms CodeModel.GetById 23ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/interpreter/tags/at2-build060407/src/edu/vub/at/actors/ATActorMirror.java

http://ambienttalk.googlecode.com/
Java | 158 lines | 21 code | 20 blank | 117 comment | 0 complexity | 7f319567b2f1cd6ab1fa6ceac631b91f 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.ATStripe;
 36import edu.vub.at.objects.ATTable;
 37import edu.vub.at.objects.grammar.ATSymbol;
 38import edu.vub.at.objects.natives.grammar.AGSymbol;
 39
 40/**
 41 *  
 42 */
 43public interface ATActorMirror extends ATObject {
 44	
 45	public static final ATSymbol _IN_ = AGSymbol.jAlloc("inbox");
 46
 47	public static final ATSymbol _OUT_ = AGSymbol.jAlloc("outbox");
 48
 49	public static final ATSymbol _REQUIRED_ = AGSymbol.jAlloc("required");
 50
 51	public static final ATSymbol _PROVIDED_ = AGSymbol.jAlloc("provided");
 52
 53	/**
 54	 * Accept an incoming asynchronous message. By default, such messages are scheduled
 55	 * in an inbox.
 56	 * @param message - the async base-level message to accept
 57	 */
 58	//public ATObject base_accept(ATAsyncMessage message) throws InterpreterException;
 59
 60	/**
 61	 * Processes a message from the base-level inbox if it is non-empty.
 62	 */
 63	//public ATObject base_process() throws InterpreterException;
 64	
 65    /* ---------------------------------------------------
 66     * -- Language Construct to NATActorMirror Protocol --
 67     * --------------------------------------------------- */
 68
 69	/**
 70	 * Creates a first-class message in the language. Note that upon creation the
 71	 * message does not have a receiver yet. This field will be set once the message
 72	 * is actually being sent, a fact which can be intercepted by overriding the sendTo
 73	 * base-level method.
 74	 * 
 75	 * @param selector the name of the method to trigger remotely
 76	 * @param arguments the actual arguments of the message
 77	 * @param stripes the stripes with which the message will be born
 78	 */
 79	public ATAsyncMessage base_createMessage(ATSymbol selector, ATTable arguments, ATTable stripes) throws InterpreterException;
 80	
 81	/**
 82	 * Creates a mirror on the given object. This method serves as the 'mirror factory'
 83	 * for the current actor.
 84	 */
 85	public ATObject base_createMirror(ATObject onObject) throws InterpreterException;
 86	
 87	/**
 88	 * This method implements the default asynchronous message sending semantics for
 89	 * this particular actor. In addition to the ability to override the send meta-
 90	 * operation on a single object to have specific adaptions, this hook allows the
 91	 * programmer to modify the message sending semantics for all objects inside an 
 92	 * actor. The default implementation ensures the correct passing of messages when
 93	 * they transgress the boundaries of the sending actor. 
 94	 * @throws InterpreterException
 95	 */
 96	public ATObject base_send(ATAsyncMessage message) throws InterpreterException;
 97	
 98	/**
 99	 * This mechanism is the most basic mechanism to provide a service. It requires 
100	 * a separate service description and an object offering the service. The return
101	 * value is a publication object which allows cancelling the service offer.
102	 */
103	public ATObject base_provide(ATStripe topic, ATObject service) throws InterpreterException;
104	
105	/**
106	 * This mechanism is the most basic mechanism to require a service. The return
107	 * value is a subscription object which allows cancelling the service offer.
108	 * @param bool - if true, the subscription is permanent, if false, once the subscription
109	 * has been satisfied, it is automatically cancelled.
110	 */
111	public ATObject base_require(ATStripe topic, ATClosure handler, ATBoolean bool) throws InterpreterException;
112	
113	/**
114	 * def oldprotocol := actor.install: newprotocol
115	 * 
116	 * Installs a new meta-object protocol into this actor.
117	 * 
118	 * @param code meta-level code that overrides an actor's MOP methods
119	 * @return an the previously installed meta-object protocol
120	 */
121	public ATObject base_install_(ATActorMirror protocol) throws InterpreterException;
122	
123    /* -------------------------------------
124     * -- Object Passing Protocol Support --
125     * ------------------------------------- */
126
127	/**
128	 * This mechanism interacts with the built-in receptionists set of the actor to 
129	 * produce a new far object reference to a local object. The created far object
130	 * is by no means unique within the actor that created it. 
131	 * 
132	 * Creating such far references is performed when passing objects by reference
133	 * in the meta_pass method of scoped objects such as closures, objects and fields.
134	 * 
135	 * @param object the local object to be given a reference to
136	 * @return a newly created far object reference
137	 * 
138	 * @see edu.vub.at.objects.ATObject#meta_pass(ATFarReference)
139	 */
140	//public ATFarReference base_export(ATObject object) throws InterpreterException;
141	
142	/**
143	 * This mechanism interacts with the built-in receptionists set of the actor to 
144	 * resolve far references (which were received as part of an async message). The
145	 * method returns a local object whenever the far object denotes an object 
146	 * hosted by this actor. 
147	 * 
148	 * If the denoted object is not hosted by this actor, a far object (possibly but
149	 * not necessarily the passed one) is returned which is the local and unique 
150	 * representative of the remote object. This object will contain the queue of 
151	 * messages to be transmitted to the remote object. 
152	 * 
153	 * @param farReference the far reference to be resolved
154	 * @return a local object | a unique far reference for this actor
155	 */
156	//public ATObject base_resolve(ATFarReference farReference) throws InterpreterException;
157
158}