Code example for MalformedObjectNameException

Methods: getLocalizedMessage

0
    public static String getCanonicalName(String objectName) {
        ObjectName on;
        try { 
            on = new ObjectName(objectName);
        } catch (MalformedObjectNameException e) {
            throw new IllegalStateException("Malformed JMX object name: " + objectName + " - " + e.getLocalizedMessage());
        } 
        return on.getCanonicalName();
    } 
 
    public static void setResourceName(CreateResourceReport report, String baseName) {
        String resourceName;
        if (report.getUserSpecifiedResourceName() != null) {
            resourceName = report.getUserSpecifiedResourceName();
        } else { 
            resourceName = report.getResourceType().getName() + " (" + baseName + ")";
        } 
        report.setResourceName(resourceName);
    } 
 
Experience pair programming with AI  Get Codota for Java