@Override public ClassLoaderRepository getClassLoaderRepository() { Throwable error = null; MBeanServerPlugin delegate = rootMBeanServer; final boolean readOnly = true; try { //Special authorization authorizeClassloadingOperation(delegate, GET_CLASSLOADER_REPOSITORY); return delegate.getClassLoaderRepository(); } catch (Exception e) { error = e; throw makeRuntimeException(e); } finally { if (shouldAuditLog(delegate, readOnly)) { new MBeanServerAuditLogRecordFormatter(this, error, readOnly).getClassLoaderRepository(); } } }
/** * <b>Package:</b> Creates an MBeanServer. * @param domain The default domain name used by this MBeanServer. * @param outer A pointer to the MBeanServer object that must be * passed to the MBeans when invoking their * {@link javax.management.MBeanRegistration} interface. * @param delegate A pointer to the MBeanServerDelegate associated * with the new MBeanServer. The new MBeanServer must register * this MBean in its MBean repository. * @param instantiator The MBeanInstantiator that will be used to * instantiate MBeans and take care of class loading issues. * @param metadata The MetaData object that will be used by the * MBean server in order to invoke the MBean interface of * the registered MBeans. * @param interceptors If <code>true</code>, * {@link MBeanServerInterceptor} will be enabled (default is * <code>false</code>). * @param fairLock If {@code true}, the MBean repository will use a {@link * java.util.concurrent.locks.ReentrantReadWriteLock#ReentrantReadWriteLock(boolean) * fair locking} policy. */ JmxMBeanServer(String domain, MBeanServer outer, MBeanServerDelegate delegate, MBeanInstantiator instantiator, boolean interceptors, boolean fairLock) { if (instantiator == null) { final ModifiableClassLoaderRepository clr = new ClassLoaderRepositorySupport(); instantiator = new MBeanInstantiator(clr); } final MBeanInstantiator fInstantiator = instantiator; this.secureClr = new SecureClassLoaderRepository(AccessController.doPrivileged(new PrivilegedAction<ClassLoaderRepository>() { @Override public ClassLoaderRepository run() { return fInstantiator.getClassLoaderRepository(); } }) ); if (delegate == null) delegate = new MBeanServerDelegateImpl(); if (outer == null) outer = this; this.instantiator = instantiator; this.mBeanServerDelegateObject = delegate; this.outerShell = outer; final Repository repository = new Repository(domain); this.mbsInterceptor = new DefaultMBeanServerInterceptor(outer, delegate, instantiator, repository); this.interceptorsEnabled = interceptors; initialize(); }
/** * De-serializes a byte array in the context of a given MBean class loader. * The class loader is the one that loaded the class with name "className". * * @param className The name of the class whose class loader should be * used for the de-serialization. * @param data The byte array to be de-sererialized. * * @return The de-serialized object stream. * * @exception OperationsException Any of the usual Input/Output * related exceptions. * @exception ReflectionException The specified class could not be * loaded by the default loader repository * */ @Deprecated public ObjectInputStream deserialize(String className, byte[] data) throws OperationsException, ReflectionException { if (className == null) { throw new RuntimeOperationsException( new IllegalArgumentException(), "Null className passed in parameter"); } /* Permission check */ // This call requires MBeanPermission 'getClassLoaderRepository' final ClassLoaderRepository clr = getClassLoaderRepository(); Class<?> theClass; try { if (clr == null) throw new ClassNotFoundException(className); theClass = clr.loadClass(className); } catch (ClassNotFoundException e) { throw new ReflectionException(e, "The given class could not be " + "loaded by the default loader " + "repository"); } return instantiator.deserialize(theClass.getClassLoader(), data); }
public ClassLoaderWithRepository(ClassLoaderRepository clr, ClassLoader cl2) { if (clr == null) throw new IllegalArgumentException("Null ClassLoaderRepository object."); repository = clr; this.cl2 = cl2; }
private Class<?> loadClass(final String className) throws ClassNotFoundException { AccessControlContext stack = AccessController.getContext(); final ClassNotFoundException[] caughtException = new ClassNotFoundException[1]; Class c = javaSecurityAccess.doIntersectionPrivilege(new PrivilegedAction<Class<?>>() { @Override public Class<?> run() { try { ReflectUtil.checkPackageAccess(className); return Class.forName(className); } catch (ClassNotFoundException e) { final ClassLoaderRepository clr = getClassLoaderRepository(); try { if (clr == null) throw new ClassNotFoundException(className); return clr.loadClass(className); } catch (ClassNotFoundException ex) { caughtException[0] = ex; } } return null; } }, stack, acc); if (caughtException[0] != null) { throw caughtException[0]; } return c; }
private Class<?> loadClass(final String className) throws ClassNotFoundException { AccessControlContext stack = AccessController.getContext(); final ClassNotFoundException[] caughtException = new ClassNotFoundException[1]; Class<?> c = javaSecurityAccess.doIntersectionPrivilege(new PrivilegedAction<Class<?>>() { @Override public Class<?> run() { try { ReflectUtil.checkPackageAccess(className); return Class.forName(className); } catch (ClassNotFoundException e) { final ClassLoaderRepository clr = getClassLoaderRepository(); try { if (clr == null) throw new ClassNotFoundException(className); return clr.loadClass(className); } catch (ClassNotFoundException ex) { caughtException[0] = ex; } } return null; } }, stack, acc); if (caughtException[0] != null) { throw caughtException[0]; } return c; }
protected ClassLoaderRepository getClassLoaderRepository() { if (m_mbeanServer != null) return m_mbeanServer.getClassLoaderRepository(); else return null; }
/** * Load a class using the default loader repository **/ Class loadClass(String className) throws ClassNotFoundException { try { return Class.forName(className); } catch (ClassNotFoundException e) { final ClassLoaderRepository clr = MBeanServerFactory.getClassLoaderRepository(bottomMBS); if (clr == null) throw new ClassNotFoundException(className); return clr.loadClass(className); } }
private Class<?> loadClass(String className) throws ClassNotFoundException { try { return Class.forName(className); } catch (ClassNotFoundException e) { final ClassLoaderRepository clr = getClassLoaderRepository(); if (clr == null) throw new ClassNotFoundException(className); return clr.loadClass(className); } }