00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00026 
00027 
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 }