1 22 23 package org.objectweb.petals.system.launch; 24 25 import org.objectweb.fractal.api.Component; 26 import org.objectweb.fractal.api.NoSuchInterfaceException; 27 import org.objectweb.fractal.api.control.ContentController; 28 import org.objectweb.fractal.api.control.IllegalLifeCycleException; 29 import org.objectweb.fractal.api.control.LifeCycleController; 30 import org.objectweb.fractal.util.Fractal; 31 32 import org.objectweb.petals.jbi.transport.Transporter; 33 34 40 public class FractalHelper { 41 42 52 public static void stopPetalsComponents(ContentController rootContentController) 53 throws NoSuchInterfaceException, IllegalLifeCycleException { 54 55 57 59 stopComponent(rootContentController, "jndi-server"); 60 61 } 62 63 69 public static boolean stopTransporter(ContentController rootContentController) { 70 71 boolean result = false; 72 73 try { 74 Component jbi = getComponentByName(rootContentController, "jbi"); 76 77 ((Transporter) jbi.getFcInterface("transporter")).stop(); 82 83 result = true; 84 } catch (Exception e) { 85 } 87 return result; 88 } 89 90 97 public static boolean stopInstallationService( 98 ContentController rootContentController) { 99 100 boolean result = false; 101 102 try { 103 Component jbi = getComponentByName(rootContentController, "jbi"); 105 ContentController jbiController = Fractal.getContentController(jbi); 106 107 stopComponent(jbiController, "installation-impl"); 109 result = true; 110 } catch (NoSuchInterfaceException e) { 111 } 113 return result; 114 } 115 116 125 protected static Component getComponentByName( 126 ContentController parentContentController, String name) { 127 128 Component c = null; 130 131 for (Component component : parentContentController.getFcSubComponents()) { 133 134 try { 135 String componentName = Fractal.getNameController(component) 136 .getFcName(); 137 if (componentName.equals(name)) { 138 c = component; 139 break; 140 } 141 } catch (NoSuchInterfaceException e) { 142 } 144 } 145 return c; 146 } 147 148 156 protected static LifeCycleController getLifeCycleControllerByName( 157 ContentController parentContentController, String name) { 158 159 LifeCycleController lifeCycleController = null; 160 161 Component comp = getComponentByName(parentContentController, name); 162 163 if (comp != null) { 164 try { 165 lifeCycleController = Fractal.getLifeCycleController(comp); 166 } catch (NoSuchInterfaceException e) { 167 } 169 } 170 return lifeCycleController; 171 } 172 173 181 protected static boolean stopComponent( 182 ContentController parentContentController, String name) { 183 184 boolean result = false; 185 186 LifeCycleController lifeCycleController = getLifeCycleControllerByName( 187 parentContentController, name); 188 189 if (lifeCycleController != null) { 190 try { 191 lifeCycleController.stopFc(); 192 result = true; 193 } catch (IllegalLifeCycleException e) { 194 } 196 } 197 return result; 198 } 199 200 } 201 | Popular Tags |