src/share/classes/com/sun/jmx/remote/internal/IIOPHelper.java

Print this page




  35 import java.rmi.RemoteException;
  36 import java.rmi.NoSuchObjectException;
  37 
  38 import java.security.AccessController;
  39 import java.security.PrivilegedAction;
  40 
  41 /**
  42  * A helper class for RMI-IIOP and CORBA APIs.
  43  */
  44 
  45 public final class IIOPHelper {
  46     private IIOPHelper() { }
  47 
  48     // loads IIOPProxy implementation class if available
  49     private static final String IMPL_CLASS =
  50         "com.sun.jmx.remote.protocol.iiop.IIOPProxyImpl";
  51     private static final IIOPProxy proxy =
  52         AccessController.doPrivileged(new PrivilegedAction<IIOPProxy>() {
  53             public IIOPProxy run() {
  54                 try {
  55                     Class<?> c = Class.forName(IMPL_CLASS, true, null);
  56                     return (IIOPProxy)c.newInstance();
  57                 } catch (ClassNotFoundException cnf) {
  58                     return null;
  59                 } catch (InstantiationException e) {
  60                     throw new AssertionError(e);
  61                 } catch (IllegalAccessException e) {
  62                     throw new AssertionError(e);
  63                 }
  64             }});
  65 
  66     /**
  67      * Returns true if RMI-IIOP and CORBA is available.
  68      */
  69     public static boolean isAvailable() {
  70         return proxy != null;
  71     }
  72 
  73     private static void ensureAvailable() {
  74         if (proxy == null)
  75             throw new AssertionError("Should not here");




  35 import java.rmi.RemoteException;
  36 import java.rmi.NoSuchObjectException;
  37 
  38 import java.security.AccessController;
  39 import java.security.PrivilegedAction;
  40 
  41 /**
  42  * A helper class for RMI-IIOP and CORBA APIs.
  43  */
  44 
  45 public final class IIOPHelper {
  46     private IIOPHelper() { }
  47 
  48     // loads IIOPProxy implementation class if available
  49     private static final String IMPL_CLASS =
  50         "com.sun.jmx.remote.protocol.iiop.IIOPProxyImpl";
  51     private static final IIOPProxy proxy =
  52         AccessController.doPrivileged(new PrivilegedAction<IIOPProxy>() {
  53             public IIOPProxy run() {
  54                 try {
  55                     Class<?> c = Class.forName(IMPL_CLASS);
  56                     return (IIOPProxy)c.newInstance();
  57                 } catch (ClassNotFoundException cnf) {
  58                     return null;
  59                 } catch (InstantiationException e) {
  60                     throw new AssertionError(e);
  61                 } catch (IllegalAccessException e) {
  62                     throw new AssertionError(e);
  63                 }
  64             }});
  65 
  66     /**
  67      * Returns true if RMI-IIOP and CORBA is available.
  68      */
  69     public static boolean isAvailable() {
  70         return proxy != null;
  71     }
  72 
  73     private static void ensureAvailable() {
  74         if (proxy == null)
  75             throw new AssertionError("Should not here");