1 23 24 package org.objectweb.fractal.julia.control.binding; 25 26 import org.objectweb.fractal.api.Component; 27 import org.objectweb.fractal.api.Interface; 28 import org.objectweb.fractal.api.NoSuchInterfaceException; 29 import org.objectweb.fractal.api.control.BindingController; 30 import org.objectweb.fractal.api.control.ContentController; 31 import org.objectweb.fractal.api.control.IllegalBindingException; 32 import org.objectweb.fractal.api.control.IllegalLifeCycleException; 33 import org.objectweb.fractal.api.control.SuperController; 34 import org.objectweb.fractal.api.type.InterfaceType; 35 36 53 54 public abstract class ContentBindingMixin implements BindingController { 55 56 60 private ContentBindingMixin () { 61 } 62 63 67 81 82 public void bindFc ( 83 final InterfaceType clientItfType, 84 final String clientItfName, 85 final Object serverItf) 86 throws 87 NoSuchInterfaceException, 88 IllegalBindingException, 89 IllegalLifeCycleException 90 { 91 checkFcLocalBinding(clientItfType, clientItfName, serverItf); 92 _super_bindFc(clientItfType, clientItfName, serverItf); 93 } 94 95 104 105 public void checkFcLocalBinding ( 106 final InterfaceType clientItfType, 107 final String clientItfName, 108 final Object serverItf) throws IllegalBindingException 109 { 110 Interface sItf; 111 Component sComp; 112 try { 113 sItf = (Interface)serverItf; 114 sComp = sItf.getFcItfOwner(); 115 } catch (ClassCastException e) { 116 return; 119 } 120 121 Component[] cParents = _this_weaveableSC.getFcSuperComponents(); 122 123 String msg; 124 if (!clientItfType.isFcClientItf()) { 125 ContentController cc; 127 try { 128 cc = (ContentController)_this_weaveableC. 129 getFcInterface("content-controller"); 130 } catch (NoSuchInterfaceException e) { 131 return; 132 } 133 Component[] cSubComps = cc.getFcSubComponents(); 136 for (int i = 0; i < cSubComps.length; ++i) { 137 if (cSubComps[i].equals(sComp)) { 138 return; 139 } 140 } 141 Component thisComp; 143 try { 144 thisComp = (Component)_this_weaveableC.getFcInterface("component"); 145 } catch (NoSuchInterfaceException e) { 146 throw new ChainedIllegalBindingException( 147 e, _this_weaveableC, 148 sItf.getFcItfOwner(), 149 clientItfName, 150 sItf.getFcItfName(), 151 "Cannot get the Component interface of the client component"); 152 } 153 if (sComp.equals(thisComp) && sItf.isFcInternalItf()) { 154 return; 155 } 156 msg = "Invalid export binding"; 157 } else if (sItf.isFcInternalItf()) { 158 for (int i = 0; i < cParents.length; ++i) { 160 if (sComp.equals(cParents[i])) { 161 return; 162 } 163 } 164 msg = "Invalid import binding"; 165 } else { 166 SuperController sCompSC; 167 try { 168 sCompSC = (SuperController)sComp.getFcInterface("super-controller"); 169 } catch (NoSuchInterfaceException e) { 170 return; 173 } 174 Component[] sParents = sCompSC.getFcSuperComponents(); 175 for (int i = 0; i < cParents.length; ++i) { 177 for (int j = 0; j < sParents.length; ++j) { 178 if (cParents[i].equals(sParents[j])) { 179 return; 180 } 181 } 182 } 183 msg = "Not a local binding"; 184 } 185 throw new ChainedIllegalBindingException( 186 null, 187 _this_weaveableC, 188 sItf.getFcItfOwner(), 189 clientItfName, 190 sItf.getFcItfName(), 191 msg); 192 } 193 194 198 203 204 public Component _this_weaveableC; 205 206 211 212 public SuperController _this_weaveableSC; 213 214 228 229 public abstract void _super_bindFc ( 230 InterfaceType clientItfType, 231 String clientItfName, 232 Object serverItf) 233 throws 234 NoSuchInterfaceException, 235 IllegalBindingException, 236 IllegalLifeCycleException; 237 } 238 | Popular Tags |