/*
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
package sun.management;
/**
* This Agent is started by the VM when -Dcom.sun.management.snmp
* or -Dcom.sun.management.jmxremote is set. This class will be
* loaded by the system class loader. Also jmx framework could
* be started by jcmd
*/
public class Agent {
// management properties
"com.sun.management.config.file";
"com.sun.management.snmp.port";
"com.sun.management.jmxremote";
"com.sun.management.jmxremote.port";
"com.sun.management.jmxremote.rmi.port";
"com.sun.management.enableThreadContentionMonitoring";
"com.sun.management.jmxremote.localConnectorAddress";
"sun.management.snmp.AdaptorBootstrap";
// The only active agent allowed
// Parse string com.sun.management.prop=xxx,com.sun.management.prop=yyyy
// and return property set if args is null or empty
// return empty property set
}
}
}
return argProps;
}
// invoked by -javaagent or -Dcom.sun.management.agent.class
}
// invoked by attach mechanism
}
// Read properties from the config file
// Arguments override config file
}
// jcmd ManagementAgent.start_local entry point
// Also called due to command-line via startAgent()
private static synchronized void startLocalManagementAgent(){
// start local connector if not started
// Add the local connector address to the agent properties
try {
// export the address to the instrumentation buffer
} catch (Exception x) {
// Connector server started but unable to export address
// to instrumentation buffer - non-fatal error.
}
}
}
// jcmd ManagementAgent.start entry point
// This method starts the remote JMX agent and starts neither
// the local JMX agent nor the SNMP agent
// @see #startLocalManagementAgent and also @see #startAgent.
}
// Load the management properties from the config file
// if config file is not specified readConfiguration implicitly
// reads <java.home>/lib/management/management.properties
// management properties can be overridden by system properties
// which take precedence
synchronized(sysProps){
}
// if user specifies config file into command line for either
// jcmd utilities or attach command it overrides properties set in
// command line at the time of VM start
}
// arguments specified in command line of jcmd utilities
// override both system properties and one set by config file
// specified in jcmd command line
// jcmd doesn't allow to change ThreadContentionMonitoring, but user
// can specify this property inside config file, so enable optional
// monitoring functionality if this property is set
if (enableThreadContentionMonitoring != null) {
}
if (jmxremotePort != null) {
}
}
// Attempt to stop already stopped agent
// Don't cause any errors.
}
}
// Enable optional monitoring functionality if requested
if (enableThreadContentionMonitoring != null) {
}
try {
}
/*
* If the jmxremote.port property is set then we start the
* RMIConnectorServer for remote M&M.
*
* If the jmxremote or jmxremote.port properties are set then
* we start a RMIConnectorServer for local M&M. The address
* of this "local" server is exported as a counter to the jstat
* instrumentation buffer.
*/
if (jmxremotePort != null) {
}
}
} catch (AgentConfigurationError e) {
} catch (Exception e) {
error(e);
}
}
throws IOException {
// Start discovery service if requested
// Decide whether we should start autodicovery service.
// To start autodiscovery following conditions should be met:
// autodiscovery==true OR (autodicovery==null AND jdp.port != NULL)
boolean shouldStart = false;
if (discoveryShouldStart == null){
}
else{
try{
} catch (NumberFormatException e) {
throw new AgentConfigurationError("Couldn't parse autodiscovery argument");
}
}
if (shouldStart) {
// port and address are required arguments and have no default values
try {
} catch (UnknownHostException e) {
throw new AgentConfigurationError("Unable to broadcast to requested address", e);
}
int port = JDP_DEFAULT_PORT;
if (discoveryPort != null) {
try {
} catch (NumberFormatException e) {
throw new AgentConfigurationError("Couldn't parse JDP port argument");
}
}
// Rebuilding service URL to broadcast it
try{
}
catch(JdpException e){
throw new AgentConfigurationError("Couldn't start JDP service", e);
}
}
}
// Load the management properties from the config file
// management properties can be overridden by system properties
// which take precedence
synchronized(sysProps){
}
return props;
}
// return if out-of-the-management option is not specified
return null;
}
}
return mgmtProps;
}
try {
// invoke the following through reflection:
// AdaptorBootstrap.initialize(snmpPort, props);
final Class<?> adaptorClass =
final Method initializeMethod =
String.class, Properties.class);
} catch (ClassNotFoundException x) {
// The SNMP packages are not present: throws an exception.
} catch (NoSuchMethodException x) {
// should not happen...
} catch (InvocationTargetException x) {
if (cause instanceof RuntimeException)
throw (RuntimeException) cause;
// should not happen...
} catch (IllegalAccessException x) {
// should not happen...
}
}
// read config file and initialize the properties
throw new Error("Can't find java.home ??");
}
// Set file name
}
if (!configFile.exists()) {
}
try {
} catch (FileNotFoundException e) {
} catch (IOException e) {
} catch (SecurityException e) {
} finally {
try {
} catch (IOException e) {
}
}
}
}
// -Dcom.sun.management.agent.class not set so read management
// properties and start agent
// initialize management properties
}
return;
}
// -Dcom.sun.management.agent.class=<agent classname>:<agent args>
}
}
try {
// Instantiate the named class.
// invoke the premain(String args) method
} catch (ClassNotFoundException ex) {
} catch (NoSuchMethodException ex) {
} catch (SecurityException ex) {
? ex.getMessage()
}
}
}
throw new RuntimeException(keyText);
}
} else {
}
}
}
throw new RuntimeException(keyText);
}
e.printStackTrace();
throw new RuntimeException(e);
}
}
private static void initResource() {
try {
} catch (MissingResourceException e) {
throw new Error("Fatal: Resource for management agent is missing");
}
}
initResource();
}
try {
} catch (MissingResourceException e) {
}
}
initResource();
}
"arguments = \"{0}\", \"{1}\", \"{2}\"";
}
}
}