1 25 package org.objectweb.jonas_ear.deployment.lib.wrapper; 26 27 import java.lang.reflect.InvocationTargetException ; 28 import java.lang.reflect.Method ; 29 30 import org.objectweb.jonas_ear.deployment.api.EarDeploymentDesc; 31 import org.objectweb.jonas_ear.deployment.api.EarDeploymentDescException; 32 33 import org.objectweb.jonas.common.Log; 34 import org.objectweb.jonas.server.LoaderManager; 35 36 import org.objectweb.util.monolog.api.BasicLevel; 37 import org.objectweb.util.monolog.api.Logger; 38 39 40 45 public class EarManagerWrapper { 46 47 50 private static final String EAR_MANAGER_CLASSNAME = "org.objectweb.jonas_ear.deployment.lib.EarDeploymentDescManager"; 51 52 55 private static Logger logger = Log.getLogger(Log.JONAS_EAR_PREFIX); 56 57 60 private EarManagerWrapper() { } 61 62 72 public static EarDeploymentDesc getDeploymentDesc(String ear, ClassLoader cl) 73 throws EarDeploymentDescException { 74 LoaderManager lm = LoaderManager.getInstance(); 75 EarDeploymentDesc earDD = null; 76 try { 77 ClassLoader tools = lm.getToolsLoader(); 78 Class manager = tools.loadClass(EAR_MANAGER_CLASSNAME); 79 Method m = manager.getDeclaredMethod("getDeploymentDesc", new Class [] {String .class, ClassLoader .class}); 80 earDD = (EarDeploymentDesc) m.invoke(null, new Object [] {ear, cl}); 81 } catch (InvocationTargetException ite) { 82 Throwable t = ite.getTargetException(); 83 if (EarDeploymentDescException.class.isInstance(t)) { 84 throw (EarDeploymentDescException) ite.getTargetException(); 85 } else { 86 throw new EarDeploymentDescException("EarDeploymentDescManager.getDeploymentDesc fails", t); 87 } 88 } catch (Exception e) { 89 throw new EarDeploymentDescException("Problems when using reflection on EarDeploymentDescManager", e); 91 } 92 93 return earDD; 94 } 95 96 101 public static void setParsingWithValidation(boolean b) { 102 LoaderManager lm = LoaderManager.getInstance(); 103 104 try { 105 ClassLoader tools = lm.getToolsLoader(); 106 Class manager = tools.loadClass(EAR_MANAGER_CLASSNAME); 107 Method m = manager.getDeclaredMethod("setParsingWithValidation", new Class [] {boolean.class}); 108 m.invoke(null, new Object [] {new Boolean (b)}); 109 } catch (Exception e) { 110 logger.log(BasicLevel.ERROR, e); 112 } 113 } 114 115 } 116 | Popular Tags |