1 23 24 package org.objectweb.dream.control.lifecycle; 25 26 import java.util.ArrayList ; 27 import java.util.Iterator ; 28 import java.util.List ; 29 30 import org.objectweb.fractal.api.Component; 31 import org.objectweb.fractal.api.NoSuchInterfaceException; 32 import org.objectweb.fractal.api.control.IllegalLifeCycleException; 33 import org.objectweb.fractal.julia.control.content.Util; 34 import org.objectweb.fractal.julia.control.lifecycle.ChainedIllegalLifeCycleException; 35 import org.objectweb.fractal.julia.control.lifecycle.LifeCycleCoordinator; 36 import org.objectweb.util.monolog.api.BasicLevel; 37 import org.objectweb.util.monolog.api.Logger; 38 39 56 public abstract class FullLifeCycleMixin 57 { 58 59 63 66 public void stopFc() throws IllegalLifeCycleException 67 { 68 if (_this_weaveableFcState == 2) 69 { 70 _this_weaveableLCCLogger.log(BasicLevel.DEBUG, "Stop component"); 71 _this_stopFc(getFcLifeCycleControllers()); 72 _this_setFcState(false); 73 } 74 } 75 76 80 86 public LifeCycleCoordinator[] getFcLifeCycleControllers() 87 throws IllegalLifeCycleException 88 { 89 Component thisComponent; 90 try 91 { 92 thisComponent = (Component) _this_weaveableC.getFcInterface("component"); 93 } 94 catch (NoSuchInterfaceException e) 95 { 96 throw new ChainedIllegalLifeCycleException(e, _this_weaveableC, 97 "The DreamLifeCycleCoordinatorMixin requires components to provide " 98 + "the Component interface"); 99 } 100 List allSubComponents = Util.getAllSubComponents(thisComponent); 101 List result = new ArrayList (); 102 Iterator iterator = allSubComponents.iterator(); 103 while (iterator.hasNext()) 104 { 105 Component c = (Component) iterator.next(); 106 try 107 { 108 result.add((LifeCycleCoordinator) c 109 .getFcInterface("lifecycle-controller")); 110 } 111 catch (Exception ignored) 112 { 113 } 115 } 116 return (LifeCycleCoordinator[]) result 117 .toArray(new LifeCycleCoordinator[result.size()]); 118 } 119 120 124 129 public Component _this_weaveableC; 130 131 137 public int _this_weaveableFcState; 138 139 143 public Logger _this_weaveableLCCLogger; 144 145 158 public abstract void _this_setFcState(boolean started) 159 throws IllegalLifeCycleException; 160 161 169 public abstract void _this_stopFc(LifeCycleCoordinator[] components) 170 throws IllegalLifeCycleException; 171 } | Popular Tags |