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.bindings;
00032
00033 import java.lang.reflect.Method;
00034 import java.util.HashSet;
00035 import java.util.Map;
00036 import java.util.Set;
00037
00038 import org.objectweb.fractal.adl.ADLException;
00039 import org.objectweb.fractal.adl.Node;
00040 import org.objectweb.fractal.adl.bindings.Binding;
00041 import org.objectweb.fractal.adl.bindings.BindingContainer;
00042 import org.objectweb.fractal.adl.bindings.TypeBindingLoader;
00043 import org.objectweb.fractal.adl.interfaces.Interface;
00044 import org.objectweb.fractal.adl.types.TypeInterface;
00045 import org.objectweb.proactive.core.component.adl.types.ProActiveTypeInterface;
00046
00050 public class ProActiveTypeBindingLoader extends TypeBindingLoader {
00051
00052 protected void checkNode(final Object node, final Map context) throws ADLException {
00053 try {
00054 super.checkNode(node, context);
00055 } catch (ADLException e) {
00056 Binding[] bindings = ((BindingContainer) node).getBindings();
00057 Set fromItfs = new HashSet();
00058 for (int i = 0; i < bindings.length; i++) {
00059 if (fromItfs.contains(bindings[i].getFrom())) {
00060
00061 }
00062
00063 }
00064 }
00065 }
00066
00067 protected void checkBinding(final Binding binding,
00068 final Interface fromItf,
00069 final Interface toItf,
00070 final Map context) throws ADLException {
00071
00072 try {
00073 super.checkBinding(binding, fromItf, toItf, context);
00074 } catch (ADLException e) {
00075
00076 TypeInterface cItf = (TypeInterface) fromItf;
00077 TypeInterface sItf = (TypeInterface) toItf;
00078
00079 try {
00080 ClassLoader cl = getClassLoader(context);
00081 Class clientSideItfClass = cl.loadClass(cItf.getSignature());
00082 Class serverSideItfClass = cl.loadClass(sItf.getSignature());
00083
00084
00085 if (!clientSideItfClass.isAssignableFrom(serverSideItfClass)) {
00086
00087 if (ProActiveTypeInterface.MULTICAST_CARDINALITY.equals(cItf.getCardinality())) {
00088
00089 Method[] clientSideItfMethods = clientSideItfClass.getMethods();
00090 Method[] serverSideItfMethods = serverSideItfClass.getMethods();
00091
00092 if (clientSideItfMethods.length != serverSideItfMethods.length) {
00093 throw new ADLException("incompatible binding between multicast client interface " + cItf
00094 .getName() + " (" + cItf.getSignature()
00095 + ") and server interface " + sItf.getName() + " (" + sItf
00096 .getSignature() + ") : there is not the same number of methods (including those inherited) " +
00097 "in both interfaces !", (Node) binding);
00098 }
00099
00100
00101
00102
00103
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116
00117
00118
00119
00120
00121
00122 }
00123 }
00124
00125 } catch (ClassNotFoundException e1) {
00126 throw new ADLException(
00127 "incompatible binding between multicast client interface " + cItf
00128 .getName() + " (" + cItf.getSignature()
00129 + ") and server interface " + sItf.getName() + " (" + sItf
00130 .getSignature() + ") : cannot find interface " +
00131 e1.getMessage(), (Node) binding);
00132 }
00133 }
00134 }
00135 }
00136