/** * Set the <code>MBeanServer</code> object to which incoming * requests are sent. This must be either the MBean server in * which this connector is registered, or an * <code>MBeanServerForwarder</code> leading to that server. An * <code>MBeanServerForwarder</code> <code>mbsf</code> leads to an * MBean server <code>mbs</code> if * <code>mbsf.getMBeanServer()</code> is either <code>mbs</code> * or an <code>MBeanServerForwarder</code> leading to * <code>mbs</code>. * * @exception IllegalArgumentException if <code>newMBS</code> is neither * the MBean server in which this connector is registered nor an * <code>MBeanServerForwarder</code> leading to that server. * * @exception IllegalStateException This method has been invoked * while the communicator was ONLINE or STARTING. */ public synchronized void setMBeanServer(MBeanServer newMBS) throws IllegalArgumentException, IllegalStateException { synchronized (stateLock) { if (state == ONLINE || state == STARTING) throw new IllegalStateException("Stop server before " + "carrying out this operation"); } final String error = "MBeanServer argument must be MBean server where this " + "server is registered, or an MBeanServerForwarder " + "leading to that server"; Vector<MBeanServer> seenMBS = new Vector<>(); for (MBeanServer mbs = newMBS; mbs != bottomMBS; mbs = ((MBeanServerForwarder) mbs).getMBeanServer()) { if (!(mbs instanceof MBeanServerForwarder)) throw new IllegalArgumentException(error); if (seenMBS.contains(mbs)) throw new IllegalArgumentException("MBeanServerForwarder " + "loop"); seenMBS.addElement(mbs); } topMBS = newMBS; }
/** * Set the <code>MBeanServer</code> object to which incoming * requests are sent. This must be either the MBean server in * which this connector is registered, or an * <code>MBeanServerForwarder</code> leading to that server. An * <code>MBeanServerForwarder</code> <code>mbsf</code> leads to an * MBean server <code>mbs</code> if * <code>mbsf.getMBeanServer()</code> is either <code>mbs</code> * or an <code>MBeanServerForwarder</code> leading to * <code>mbs</code>. * * @exception IllegalArgumentException if <code>newMBS</code> is neither * the MBean server in which this connector is registered nor an * <code>MBeanServerForwarder</code> leading to that server. * * @exception IllegalStateException This method has been invoked * while the communicator was ONLINE or STARTING. */ public synchronized void setMBeanServer(MBeanServer newMBS) throws IllegalArgumentException, IllegalStateException { synchronized (stateLock) { if (state == ONLINE || state == STARTING) throw new IllegalStateException("Stop server before " + "carrying out this operation"); } final String error = "MBeanServer argument must be MBean server where this " + "server is registered, or an MBeanServerForwarder " + "leading to that server"; Vector<MBeanServer> seenMBS = new Vector<MBeanServer>(); for (MBeanServer mbs = newMBS; mbs != bottomMBS; mbs = ((MBeanServerForwarder) mbs).getMBeanServer()) { if (!(mbs instanceof MBeanServerForwarder)) throw new IllegalArgumentException(error); if (seenMBS.contains(mbs)) throw new IllegalArgumentException("MBeanServerForwarder " + "loop"); seenMBS.addElement(mbs); } topMBS = newMBS; }
@Override public synchronized void setMBeanServerForwarder(MBeanServerForwarder mbsf) { super.setMBeanServerForwarder(mbsf); if (rmiServerImpl != null) rmiServerImpl.setMBeanServer(getMBeanServer()); }
public MBeanServer newMBeanServer( String defaultDomain, MBeanServer outer, MBeanServerDelegate delegate) { final MBeanServerForwarder mbsf = MBeanServerForwarderInvocationHandler.newProxyInstance(); final MBeanServer innerMBeanServer = inner.newMBeanServer(defaultDomain, (outer == null ? mbsf : outer), delegate); mbsf.setMBeanServer(innerMBeanServer); return mbsf; }
public static MBeanServerForwarder newProxyInstance() { final InvocationHandler handler = new MBeanServerForwarderInvocationHandler(); final Class[] interfaces = new Class[] {MBeanServerForwarder.class}; Object proxy = Proxy.newProxyInstance( MBeanServerForwarder.class.getClassLoader(), interfaces, handler); return MBeanServerForwarder.class.cast(proxy); }
public static MBeanServerForwarder newProxyInstance() { final InvocationHandler handler = new MBSFInvocationHandler(); final Class[] interfaces = new Class[] {MBeanServerForwarder.class}; Object proxy = Proxy.newProxyInstance( MBeanServerForwarder.class.getClassLoader(), interfaces, handler); return MBeanServerForwarder.class.cast(proxy); }
public MBeanServer newMBeanServer(String defaultDomain, MBeanServer outer, MBeanServerDelegate delegate) { final MBeanServerForwarder mbsf = MBeanServerForwarderInvocationHandler.newProxyInstance(); final MBeanServer innerMBeanServer = inner.newMBeanServer(defaultDomain, (outer == null ? mbsf : outer), delegate); mbsf.setMBeanServer(innerMBeanServer); return mbsf; }