Skip to content

Commit

Permalink
Merge pull request #74 from dhilpipre/datefix
Browse files Browse the repository at this point in the history
adds support for java.lang.Date and fixes problem related java.sql.Time
  • Loading branch information
cristianciutea authored Sep 17, 2021
2 parents 6f7ddc4 + 001d5b1 commit bb65c21
Show file tree
Hide file tree
Showing 4 changed files with 636 additions and 514 deletions.
114 changes: 61 additions & 53 deletions src/main/java/org/newrelic/nrjmx/Application.java
Original file line number Diff line number Diff line change
@@ -1,69 +1,77 @@
/*
* Copyright 2020 New Relic Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/
* Copyright 2020 New Relic Corporation. All rights reserved.
* SPDX-License-Identifier: Apache-2.0
*/

package org.newrelic.nrjmx;

import org.apache.commons.cli.HelpFormatter;

import java.util.logging.Logger;
import org.apache.commons.cli.HelpFormatter;

public class Application {
public static void printHelp() {
new HelpFormatter().printHelp("nrjmx", Arguments.options());
}

public static void main(String[] args) {
Arguments cliArgs = null;
try {
cliArgs = Arguments.from(args);
} catch (Exception e) {
System.err.println(e.getMessage());
printHelp();
System.exit(1);
}
public static void printHelp() {
new HelpFormatter().printHelp("nrjmx", Arguments.options());
}

if (cliArgs.isHelp()) {
printHelp();
System.exit(0);
}
public static void main(String[] args) {
Arguments cliArgs = null;
try {
cliArgs = Arguments.from(args);
} catch (Exception e) {
System.err.println(e.getMessage());
printHelp();
System.exit(1);
}

if (cliArgs.isHelp()) {
printHelp();
System.exit(0);
}

Logger logger = Logger.getLogger("nrjmx");
Logging.setup(logger, cliArgs.isVerbose());
Logger logger = Logger.getLogger("nrjmx");
Logging.setup(logger, cliArgs.isVerbose());

// Instantiate a JMXFetcher from the configuration arguments
JMXFetcher fetcher = cliArgs.getConnectionURL().equals("") ?
new JMXFetcher(
cliArgs.getHostname(), cliArgs.getPort(), cliArgs.getUriPath(),
cliArgs.getUsername(), cliArgs.getPassword(),
cliArgs.getKeyStore(), cliArgs.getKeyStorePassword(),
cliArgs.getTrustStore(), cliArgs.getTrustStorePassword(),
cliArgs.getIsRemoteJMX(), cliArgs.getIsRemoteJBossStandalone()
) :
new JMXFetcher(
cliArgs.getConnectionURL(),
cliArgs.getUsername(), cliArgs.getPassword(),
cliArgs.getKeyStore(), cliArgs.getKeyStorePassword(),
cliArgs.getTrustStore(), cliArgs.getTrustStorePassword()
);
// Instantiate a JMXFetcher from the configuration arguments
JMXFetcher fetcher =
cliArgs.getConnectionURL().equals("")
? new JMXFetcher(
cliArgs.getHostname(),
cliArgs.getPort(),
cliArgs.getUriPath(),
cliArgs.getUsername(),
cliArgs.getPassword(),
cliArgs.getKeyStore(),
cliArgs.getKeyStorePassword(),
cliArgs.getTrustStore(),
cliArgs.getTrustStorePassword(),
cliArgs.getIsRemoteJMX(),
cliArgs.getIsRemoteJBossStandalone())
: new JMXFetcher(
cliArgs.getConnectionURL(),
cliArgs.getUsername(),
cliArgs.getPassword(),
cliArgs.getKeyStore(),
cliArgs.getKeyStorePassword(),
cliArgs.getTrustStore(),
cliArgs.getTrustStorePassword());

try {
fetcher.run(System.in, System.out);
} catch (JMXFetcher.ConnectionError e) {
logger.severe("jmx connection error: " + e.getMessage());
logTrace(cliArgs, logger, e);
System.exit(1);
} catch (Exception e) {
logger.severe("error running nrjmx: " + e.getMessage());
logTrace(cliArgs, logger, e);
System.exit(1);
}
try {
fetcher.run(System.in, System.out);
} catch (JMXFetcher.ConnectionError e) {
logger.severe("jmx connection error: " + e.getMessage());
logTrace(cliArgs, logger, e);
System.exit(1);
} catch (Exception e) {
logger.severe("error running nrjmx: " + e.getMessage());
logTrace(cliArgs, logger, e);
System.exit(1);
}
}

private static void logTrace(Arguments cliArgs, Logger logger, Exception e) {
if (cliArgs.isDebugMode()) {
logger.info("exception trace for " + e.getClass().getCanonicalName() + ": " + e);
}
private static void logTrace(Arguments cliArgs, Logger logger, Exception e) {
if (cliArgs.isDebugMode()) {
logger.info("exception trace for " + e.getClass().getCanonicalName() + ": " + e);
}
}
}
Loading

0 comments on commit bb65c21

Please sign in to comment.