/* An extension of TypedCompositeActor for distributed environments. @Copyright (c) 2005 The Regents of Aalborg University. All rights reserved. Permission is hereby granted, without written agreement and without license or royalty fees, to use, copy, modify, and distribute this software and its documentation for any purpose, provided that the above copyright notice and the following two paragraphs appear in all copies of this software. IN NO EVENT SHALL AALBORG UNIVERSITY BE LIABLE TO ANY PARTY FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF AALBORG UNIVERSITY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. AALBORG UNIVERSITY SPECIFICALLY DISCLAIMS ANY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND AALBORG UNIVERSITY HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. */ package ptolemy.distributed.actor; import ptolemy.actor.TypedCompositeActor; import ptolemy.kernel.ComponentRelation; import ptolemy.kernel.CompositeEntity; import ptolemy.kernel.util.IllegalActionException; import ptolemy.kernel.util.InternalErrorException; import ptolemy.kernel.util.NameDuplicationException; import ptolemy.kernel.util.Workspace; ////////////////////////////////////////////////////////////////////////// //// DistributedTypedCompositeActor /** An extension of TypedCompositeActor for distributed environments. It basically overrides the newRelation method to create DistributedTypedIORelations. @author Daniel Lazaro Cuadrado (kapokasa@kom.aau.dk) @version $Id$ @since Ptolemy II 5.1 @Pt.ProposedRating Red (kapokasa) @Pt.AcceptedRating Red (cxh) @see ptolemy.actor.TypedCompositeActor */ public class DistributedTypedCompositeActor extends TypedCompositeActor { /** Construct a Distributed TypedCompositeActor in the default workspace * with no container and an empty string as its name. Add the actor to the * workspace directory. You should set the local director or * executive director before attempting to send data to the actor or * to execute it. Increment the version number of the workspace. */ public DistributedTypedCompositeActor() { super(); } /** Construct a DistributedTypedCompositeActor in the specified workspace * with no container and an empty string as a name. You can then change * the name with setName(). If the workspace argument is null, then * use the default workspace. You should set the local director or * executive director before attempting to send data to the actor * or to execute it. Add the actor to the workspace directory. * Increment the version number of the workspace. * @param workspace The workspace that will list the actor. */ public DistributedTypedCompositeActor(Workspace workspace) { super(workspace); } /** Construct a DistributedTypedCompositeActor with a name and a container. * The container argument must not be null, or a * NullPointerException will be thrown. This actor will use the * workspace of the container for synchronization and version counts. * If the name argument is null, then the name is set to the empty string. * Increment the version of the workspace. This actor will have no * local director initially, and its executive director will be simply * the director of the container. * * @param container The container. * @param name The name of this actor. * @exception IllegalActionException If the container is incompatible * with this actor. * @exception NameDuplicationException If the name coincides with * an actor already in the container. */ public DistributedTypedCompositeActor(CompositeEntity container, String name) throws IllegalActionException, NameDuplicationException { super(container, name); } /** Create a new DistributedTypedIORelation with the specified name, add it * to the relation list, and return it. Derived classes can override * this to create domain-specific subclasses of TypedIORelation. * This method is write-synchronized on the workspace. * * @param name The name for the new TypedIORelation. * @return A new TypedIORelation. * @exception NameDuplicationException If name collides with a name * already on the container's contents list. */ public ComponentRelation newRelation(String name) throws NameDuplicationException { try { workspace().getWriteAccess(); DistributedTypedIORelation relation = new DistributedTypedIORelation( this, name); return relation; } catch (IllegalActionException ex) { // This exception should not occur, so we throw a runtime // exception. throw new InternalErrorException(this, ex, null); } finally { workspace().doneWriting(); } } }