org/objectweb/proactive/core/component/adl/vnexportation/ExportedVirtualNodesBuilderImpl.java

00001 /* 
00002  * ################################################################
00003  * 
00004  * ProActive: The Java(TM) library for Parallel, Distributed, 
00005  *            Concurrent computing with Security and Mobility
00006  * 
00007  * Copyright (C) 1997-2007 INRIA/University of Nice-Sophia Antipolis
00008  * Contact: proactive@objectweb.org
00009  * 
00010  * This library is free software; you can redistribute it and/or
00011  * modify it under the terms of the GNU Lesser General Public
00012  * License as published by the Free Software Foundation; either
00013  * version 2.1 of the License, or any later version.
00014  *  
00015  * This library is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018  * Lesser General Public License for more details.
00019  * 
00020  * You should have received a copy of the GNU Lesser General Public
00021  * License along with this library; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
00023  * USA
00024  *  
00025  *  Initial developer(s):               The ProActive Team
00026  *                        http://www.inria.fr/oasis/ProActive/contacts.html
00027  *  Contributor(s): 
00028  * 
00029  * ################################################################
00030  */ 
00031 package org.objectweb.proactive.core.component.adl.vnexportation;
00032 
00033 import org.objectweb.fractal.adl.ADLException;
00034 import org.objectweb.proactive.core.component.adl.nodes.VirtualNode;
00035 
00036 
00046 public class ExportedVirtualNodesBuilderImpl
00047     implements ExportedVirtualNodesBuilder {
00048     // implementation of ExportedVirtualNodesBuilder
00049     public void compose(String componentName,
00050         ExportedVirtualNode[] exportedVirtualNodes,
00051         VirtualNode currentComponentVN) throws ADLException {
00052         for (int i = 0; i < exportedVirtualNodes.length; i++) {
00053             ComposingVirtualNode[] composing_vns = exportedVirtualNodes[i].getComposedFrom()
00054                                                                           .getComposingVirtualNodes();
00055 
00056             for (int j = 0; j < composing_vns.length; j++) {
00057                 boolean composing_vn_is_multiple = false;
00058                 if ("this".equals(composing_vns[j].getComponent())) {
00059                     if (currentComponentVN == null) {
00060                         throw new ADLException(
00061                             "Trying to compose a virtual node from " +
00062                             composing_vns[j].getName() +
00063                             ", which is declared to be in the component " +
00064                             componentName +
00065                             " , but there is no virtual node defined in this component",
00066                             null);
00067                     }
00068                     if (!currentComponentVN.getName().equals(composing_vns[j].getName())) {
00069                         throw new ADLException(
00070                             "Trying to compose a virtual node from " +
00071                             composing_vns[i].getName() +
00072                             ", which is declared to be in the component " +
00073                             componentName + ", but " +
00074                             currentComponentVN.getName() + " is not defined " +
00075                             "in this component", null);
00076                     }
00077 
00078                     // change "this" into the name of the component
00079                     composing_vns[j].setComponent(componentName);
00080                 }
00081                 if ((currentComponentVN != null) &&
00082                         currentComponentVN.getCardinality().equals(VirtualNode.MULTIPLE)) {
00083                     composing_vn_is_multiple = true;
00084                 }
00085 
00086                 //                /System.out.println("COMPOSING : " + componentName + "." + exportedVirtualNodes[i].getName() + "--> " + composing_vns[j].getComponent() + "." + composing_vns[j].getName());
00087                 ExportedVirtualNodesList.instance().compose(componentName,
00088                     exportedVirtualNodes[i], composing_vns[j],
00089                     composing_vn_is_multiple);
00090                 //System.out.println("COMPOSED VN LIST : " +ExportedVirtualNodesList.instance().toString());
00091             }
00092         }
00093     }
00094 }

Generated on Mon Jan 22 15:16:06 2007 for ProActive by  doxygen 1.5.1