org/objectweb/proactive/core/component/adl/types/ProActiveTypeLoader.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.types;
00032 
00033 import java.util.Map;
00034 
00035 import org.objectweb.fractal.adl.ADLException;
00036 import org.objectweb.fractal.adl.Node;
00037 import org.objectweb.fractal.adl.interfaces.Interface;
00038 import org.objectweb.fractal.adl.interfaces.InterfaceContainer;
00039 import org.objectweb.fractal.adl.types.TypeInterface;
00040 import org.objectweb.fractal.adl.types.TypeLoader;
00041 
00048 public class ProActiveTypeLoader extends TypeLoader {
00049 
00050 
00051     protected void checkInterfaceContainer(
00052             final InterfaceContainer container,
00053             final boolean extend,
00054             final Map context) throws ADLException {
00055         Interface[] itfs = container.getInterfaces();
00056         for (int i = 0; i < itfs.length; i++) {
00057             Interface itf = itfs[i];
00058             if (itf instanceof TypeInterface) {
00059                 String signature = ((TypeInterface) itf).getSignature();
00060                 if (signature == null) {
00061                     if (!extend) {
00062                         throw new ADLException("Signature missing", (Node) itf);
00063                     }
00064                 } else {
00065                     try {
00066                         getClassLoader(context).loadClass(signature);
00067                     } catch (ClassNotFoundException e) {
00068                         throw new ADLException(
00069                                 "Invalid signature '" + signature + "'", (Node) itf, e);
00070                     }
00071                 }
00072                 String role = ((TypeInterface) itf).getRole();
00073                 if (role == null) {
00074                     if (!extend) {
00075                         throw new ADLException("Role missing", (Node) itf);
00076                     }
00077                 } else {
00078                     if (!role.equals("client") && !role.equals("server")) {
00079                         throw new ADLException("Invalid role '" + role + "'", (Node) itf);
00080                     }
00081                 }
00082                 String contingency = ((TypeInterface) itf).getContingency();
00083                 if (contingency != null) {
00084                     if (!contingency.equals("mandatory") && !contingency.equals("optional")) {
00085                         throw new ADLException("Invalid contingency '" + contingency + "'", (Node) itf);
00086                     }
00087                 }
00088 
00089                 String cardinality = ((TypeInterface) itf).getCardinality();
00090                 if (cardinality != null) {
00091                     if (!cardinality.equals("singleton") && !cardinality
00092                             .equals("collection") && !cardinality
00093                             .equals(ProActiveTypeInterface.MULTICAST_CARDINALITY)
00094                             && !cardinality.equals(ProActiveTypeInterface.GATHER_CARDINALITY)) {
00095                         throw new ADLException("Invalid cardinality '" + cardinality + "'", (Node) itf);
00096                     }
00097                 }
00098             }
00099         }
00100     }
00101 }

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