-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #74 from dhilpipre/datefix
adds support for java.lang.Date and fixes problem related java.sql.Time
- Loading branch information
Showing
4 changed files
with
636 additions
and
514 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
} | ||
} | ||
} |
Oops, something went wrong.