本文整理汇总了Java中com.sun.jmx.remote.internal.RMIExporter类的典型用法代码示例。如果您正苦于以下问题:Java RMIExporter类的具体用法?Java RMIExporter怎么用?Java RMIExporter使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
RMIExporter类属于com.sun.jmx.remote.internal包,在下文中一共展示了RMIExporter类的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: export
import com.sun.jmx.remote.internal.RMIExporter; //导入依赖的package包/类
private void export(Remote obj) throws RemoteException {
final RMIExporter exporter =
(RMIExporter) env.get(RMIExporter.EXPORTER_ATTRIBUTE);
final boolean daemon = EnvHelp.isServerDaemon(env);
if (daemon && exporter != null) {
throw new IllegalArgumentException("If "+EnvHelp.JMX_SERVER_DAEMON+
" is specified as true, "+RMIExporter.EXPORTER_ATTRIBUTE+
" cannot be used to specify an exporter!");
}
if (daemon) {
if (csf == null && ssf == null) {
new UnicastServerRef(port).exportObject(obj, null, true);
} else {
new UnicastServerRef2(port, csf, ssf).exportObject(obj, null, true);
}
} else if (exporter != null) {
exporter.exportObject(obj, port, csf, ssf);
} else {
UnicastRemoteObject.exportObject(obj, port, csf, ssf);
}
}
示例2: unexport
import com.sun.jmx.remote.internal.RMIExporter; //导入依赖的package包/类
private void unexport(Remote obj, boolean force)
throws NoSuchObjectException {
RMIExporter exporter =
(RMIExporter) env.get(RMIExporter.EXPORTER_ATTRIBUTE);
if (exporter == null)
UnicastRemoteObject.unexportObject(obj, force);
else
exporter.unexportObject(obj, force);
}
示例3: startLocalConnectorServer
import com.sun.jmx.remote.internal.RMIExporter; //导入依赖的package包/类
public static JMXConnectorServer startLocalConnectorServer() {
// Ensure cryptographically strong random number generater used
// to choose the object number - see java.rmi.server.ObjID
System.setProperty("java.rmi.server.randomIDs", "true");
// This RMI server should not keep the VM alive
Map<String, Object> env = new HashMap<>();
env.put(RMIExporter.EXPORTER_ATTRIBUTE, new PermanentExporter());
env.put(RMIConnectorServer.CREDENTIAL_TYPES, new String[]{
String[].class.getName(), String.class.getName()
});
// The local connector server need only be available via the
// loopback connection.
String localhost = "localhost";
InetAddress lh = null;
try {
lh = InetAddress.getByName(localhost);
localhost = lh.getHostAddress();
} catch (UnknownHostException x) {
}
// localhost unknown or (somehow) didn't resolve to
// a loopback address.
if (lh == null || !lh.isLoopbackAddress()) {
localhost = "127.0.0.1";
}
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
try {
JMXServiceURL url = new JMXServiceURL("rmi", localhost, 0);
// Do we accept connections from local interfaces only?
Properties props = Agent.getManagementProperties();
if (props == null) {
props = new Properties();
}
String useLocalOnlyStr = props.getProperty(
PropertyNames.USE_LOCAL_ONLY, DefaultValues.USE_LOCAL_ONLY);
boolean useLocalOnly = Boolean.valueOf(useLocalOnlyStr).booleanValue();
if (useLocalOnly) {
env.put(RMIConnectorServer.RMI_SERVER_SOCKET_FACTORY_ATTRIBUTE,
new LocalRMIServerSocketFactory());
}
JMXConnectorServer server =
JMXConnectorServerFactory.newJMXConnectorServer(url, env, mbs);
server.start();
return server;
} catch (Exception e) {
throw new AgentConfigurationError(AGENT_EXCEPTION, e, e.toString());
}
}
示例4: startLocalConnectorServer
import com.sun.jmx.remote.internal.RMIExporter; //导入依赖的package包/类
public static JMXConnectorServer startLocalConnectorServer() {
// Ensure cryptographically strong random number generater used
// to choose the object number - see java.rmi.server.ObjID
System.setProperty("java.rmi.server.randomIDs", "true");
// This RMI server should not keep the VM alive
Map<String, Object> env = new HashMap<>();
env.put(RMIExporter.EXPORTER_ATTRIBUTE, new PermanentExporter());
env.put(EnvHelp.CREDENTIAL_TYPES, new String[]{
String[].class.getName(), String.class.getName()
});
// The local connector server need only be available via the
// loopback connection.
String localhost = "localhost";
InetAddress lh = null;
try {
lh = InetAddress.getByName(localhost);
localhost = lh.getHostAddress();
} catch (UnknownHostException x) {
}
// localhost unknown or (somehow) didn't resolve to
// a loopback address.
if (lh == null || !lh.isLoopbackAddress()) {
localhost = "127.0.0.1";
}
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
try {
JMXServiceURL url = new JMXServiceURL("rmi", localhost, 0);
// Do we accept connections from local interfaces only?
Properties props = Agent.getManagementProperties();
if (props == null) {
props = new Properties();
}
String useLocalOnlyStr = props.getProperty(
PropertyNames.USE_LOCAL_ONLY, DefaultValues.USE_LOCAL_ONLY);
boolean useLocalOnly = Boolean.valueOf(useLocalOnlyStr).booleanValue();
if (useLocalOnly) {
env.put(RMIConnectorServer.RMI_SERVER_SOCKET_FACTORY_ATTRIBUTE,
new LocalRMIServerSocketFactory());
}
JMXConnectorServer server =
JMXConnectorServerFactory.newJMXConnectorServer(url, env, mbs);
server.start();
return server;
} catch (Exception e) {
throw new AgentConfigurationError(AGENT_EXCEPTION, e, e.toString());
}
}
示例5: startLocalConnectorServer
import com.sun.jmx.remote.internal.RMIExporter; //导入依赖的package包/类
public static JMXConnectorServer startLocalConnectorServer() {
// Ensure cryptographically strong random number generater used
// to choose the object number - see java.rmi.server.ObjID
System.setProperty("java.rmi.server.randomIDs", "true");
// This RMI server should not keep the VM alive
Map<String, Object> env = new HashMap<>();
env.put(RMIExporter.EXPORTER_ATTRIBUTE, new PermanentExporter());
// The local connector server need only be available via the
// loopback connection.
String localhost = "localhost";
InetAddress lh = null;
try {
lh = InetAddress.getByName(localhost);
localhost = lh.getHostAddress();
} catch (UnknownHostException x) {
}
// localhost unknown or (somehow) didn't resolve to
// a loopback address.
if (lh == null || !lh.isLoopbackAddress()) {
localhost = "127.0.0.1";
}
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
try {
JMXServiceURL url = new JMXServiceURL("rmi", localhost, 0);
// Do we accept connections from local interfaces only?
Properties props = Agent.getManagementProperties();
if (props == null) {
props = new Properties();
}
String useLocalOnlyStr = props.getProperty(
PropertyNames.USE_LOCAL_ONLY, DefaultValues.USE_LOCAL_ONLY);
boolean useLocalOnly = Boolean.valueOf(useLocalOnlyStr).booleanValue();
if (useLocalOnly) {
env.put(RMIConnectorServer.RMI_SERVER_SOCKET_FACTORY_ATTRIBUTE,
new LocalRMIServerSocketFactory());
}
JMXConnectorServer server =
JMXConnectorServerFactory.newJMXConnectorServer(url, env, mbs);
server.start();
return server;
} catch (Exception e) {
throw new AgentConfigurationError(AGENT_EXCEPTION, e, e.toString());
}
}
示例6: startLocalConnectorServer
import com.sun.jmx.remote.internal.RMIExporter; //导入依赖的package包/类
public static JMXConnectorServer startLocalConnectorServer() {
// Ensure cryptographically strong random number generater used
// to choose the object number - see java.rmi.server.ObjID
System.setProperty("java.rmi.server.randomIDs", "true");
// This RMI server should not keep the VM alive
Map<String, Object> env = new HashMap<String, Object>();
env.put(RMIExporter.EXPORTER_ATTRIBUTE, new PermanentExporter());
// The local connector server need only be available via the
// loopback connection.
String localhost = "localhost";
InetAddress lh = null;
try {
lh = InetAddress.getByName(localhost);
localhost = lh.getHostAddress();
} catch (UnknownHostException x) {
}
// localhost unknown or (somehow) didn't resolve to
// a loopback address.
if (lh == null || !lh.isLoopbackAddress()) {
localhost = "127.0.0.1";
}
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
try {
JMXServiceURL url = new JMXServiceURL("rmi", localhost, 0);
// Do we accept connections from local interfaces only?
Properties props = Agent.getManagementProperties();
if (props == null) {
props = new Properties();
}
String useLocalOnlyStr = props.getProperty(
PropertyNames.USE_LOCAL_ONLY, DefaultValues.USE_LOCAL_ONLY);
boolean useLocalOnly = Boolean.valueOf(useLocalOnlyStr).booleanValue();
if (useLocalOnly) {
env.put(RMIConnectorServer.RMI_SERVER_SOCKET_FACTORY_ATTRIBUTE,
new LocalRMIServerSocketFactory());
}
JMXConnectorServer server =
JMXConnectorServerFactory.newJMXConnectorServer(url, env, mbs);
server.start();
return server;
} catch (Exception e) {
throw new AgentConfigurationError(AGENT_EXCEPTION, e, e.toString());
}
}