/** * Obtains the ServiceMetaData class loader from the * getClassLoaderName value if there is an mbeanServer. * * @param md - the mbean metadata * @return the ServiceMetaData.ClassLoaderName class loader if * the mbeanServer has been set, the current TCL otherwise. * @throws InstanceNotFoundException if no mbean class loader can be * found by the ServiceMetaData.ClassLoaderName */ private ClassLoader getServiceMetaDataCL(ServiceMetaData md) throws InstanceNotFoundException { ClassLoader loader = null; if(mbeanServer != null) loader = mbeanServer.getClassLoader(md.getClassLoaderName()); // Fallback to TCL if there is no mbeanServer if(loader == null) loader = Thread.currentThread().getContextClassLoader(); return loader; }
public ClassLoader getClassLoader() throws Throwable { if (serviceMetaData != null) { return getMBeanServer().getClassLoader(serviceMetaData.getClassLoaderName()); } else { return getMBeanServer().getClassLoaderFor(objectName); } }
public ClassLoader getClassLoader() throws Throwable { if (serviceMetaData != null) { return getMBeanServer().getClassLoader(serviceMetaData.getClassLoaderName()); } else { return getMBeanServer().getClassLoaderFor(objectName); } }
/** * Install a StandardMBean * * @param server the mbean server * @param objectName the object name * @param metadata the service metadata * @return the installed instance * @throws Exception for any error */ private static ServiceInstance installStandardMBean(MBeanServer server, ObjectName objectName, ServiceMetaData metaData) throws Exception { ObjectName loaderName = metaData.getClassLoaderName(); ClassLoader loader = server.getClassLoader(loaderName); String code = metaData.getCode(); ServiceConstructorMetaData constructor = metaData.getConstructor(); String interfaceName = metaData.getInterfaceName(); Class<?> intf = loader.loadClass(interfaceName); log.debug("About to create bean resource: " + objectName + " with code: " + code + " and interface " + interfaceName); Object resource = server.instantiate(code, loaderName, constructor.getParameters(loader), constructor.getSignature()); log.debug("About to register StandardMBean : " + objectName); ObjectInstance instance = server.createMBean(StandardMBean.class.getName(), objectName, loaderName, new Object[] { resource, intf }, new String[] { Object.class.getName() , Class.class.getName() }); return new ServiceInstance(instance, resource); }
public void installAction(ServiceControllerContext context) throws Throwable { ServiceController controller = context.getServiceController(); ObjectName objectName = context.getObjectName(); // Configure any attributes ServiceMetaData metaData = context.getServiceMetaData(); if (metaData != null) { List<ServiceAttributeMetaData> attrs = metaData.getAttributes(); if (attrs.size() > 0) { ObjectName classLoaderName = metaData.getClassLoaderName(); ServiceConfigurator.configure(null, controller, objectName, classLoaderName, attrs); } } context.getServiceContext().state = ServiceContext.CONFIGURED; }
ObjectName loaderName = metaData.getClassLoaderName(); ClassLoader loader = server.getClassLoader(loaderName); String code = metaData.getCode();
/** * Unconfigure the mbean. * Unget values - releasing potential injections. * * @param context The ServiceControllerContext we are uninstalling */ public void uninstallAction(ServiceControllerContext context) { // Unconfigure any attributes ServiceMetaData metaData = context.getServiceMetaData(); if (metaData != null) { ServiceController controller = context.getServiceController(); ObjectName objectName = context.getObjectName(); List<ServiceAttributeMetaData> attrs = metaData.getAttributes(); if (attrs.size() > 0) { ObjectName classLoaderName = metaData.getClassLoaderName(); try { ServiceConfigurator.unconfigure(null, controller, objectName, classLoaderName, attrs); } catch (Exception ignored) { } } } } }
/** * Configures the MBean instance with values from the ServiceMetaData. * * @param context The ServiceControllerContext we are installing */ public void installAction(ServiceControllerContext context) throws Throwable { // Configure any attributes ServiceMetaData metaData = context.getServiceMetaData(); if (metaData != null) { ServiceController controller = context.getServiceController(); ObjectName objectName = context.getObjectName(); List<ServiceAttributeMetaData> attrs = metaData.getAttributes(); if (attrs.size() > 0) { ObjectName classLoaderName = metaData.getClassLoaderName(); ServiceConfigurator.configure(null, controller, objectName, classLoaderName, attrs); } } context.getServiceContext().state = ServiceContext.CONFIGURED; }
ObjectName loaderName = metaData.getClassLoaderName(); ClassLoader loader = server.getClassLoader(loaderName); String code = metaData.getCode();
ObjectName loaderName = metaData.getClassLoaderName(); ClassLoader loader = server.getClassLoader(loaderName); String code = metaData.getCode();
ObjectName loaderName = metaData.getClassLoaderName(); ClassLoader loader = server.getClassLoader(loaderName); String code = metaData.getCode();
ObjectName loaderName = metaData.getClassLoaderName(); ClassLoader loader = server.getClassLoader(loaderName); String code = metaData.getCode();
/** * Install a StandardMBean * * @param server the mbean server * @param objectName the object name * @param metadata the service metadata * @return the installed instance * @throws Exception for any error */ private static ServiceInstance installStandardMBean(MBeanServer server, ObjectName objectName, ServiceMetaData metaData) throws Exception { ObjectName loaderName = metaData.getClassLoaderName(); ClassLoader loader = server.getClassLoader(loaderName); String code = metaData.getCode(); ServiceConstructorMetaData constructor = metaData.getConstructor(); String interfaceName = metaData.getInterfaceName(); Class<?> intf = loader.loadClass(interfaceName); log.debugf("About to create bean resource:%1s with code: %2s and interface %3s", objectName, code, interfaceName); Object resource = server.instantiate(code, loaderName, constructor.getParameters(loader), constructor.getSignature()); log.debugf("About to register StandardMBean : %1s", objectName); ObjectInstance instance = server.createMBean(StandardMBean.class.getName(), objectName, loaderName, new Object[] { resource, intf }, new String[] { Object.class.getName() , Class.class.getName() }); return new ServiceInstance(instance, resource); }
ObjectName loaderName = metaData.getClassLoaderName(); ClassLoader loader = server.getClassLoader(loaderName); String code = metaData.getCode();
try ObjectName loaderName = deployment.getClassLoaderName(); if (loaderName == null) loaderName = findLoaderName(unit.getClassLoader());