Java Code Examples for javax.management.MalformedObjectNameException

The following are top voted examples for showing how to use javax.management.MalformedObjectNameException. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: monarch   File: LauncherLifecycleCommands.java   Source Code and License 6 votes vote down vote up
private String getCurrentLocators() throws MalformedObjectNameException {
  String delimitedLocators = "";
  try {
    if (isConnectedAndReady()) {
      final DistributedSystemMXBean dsMBeanProxy = getDistributedSystemMXBean();
      if (dsMBeanProxy != null) {
        final String[] locators = dsMBeanProxy.listLocators();
        if (locators != null && locators.length > 0) {
          final StringBuilder sb = new StringBuilder();
          for (int i = 0; i < locators.length; i++) {
            if (i > 0) {
              sb.append(",");
            }
            sb.append(locators[i]);
          }
          delimitedLocators = sb.toString();
        }
      }
    }
  } catch (IOException e) { // thrown by getDistributedSystemMXBean
    // leave delimitedLocators = ""
    getGfsh().logWarning("DistributedSystemMXBean is unavailable\n", e);
  }
  return delimitedLocators;
}
 
Example 2
Project: hadoop   File: ClusterJspHelper.java   Source Code and License 6 votes vote down vote up
public NamenodeStatus getNamenodeStatus(String props) throws IOException,
    MalformedObjectNameException, NumberFormatException {
  NamenodeStatus nn = new NamenodeStatus();
  nn.host = host;
  nn.filesAndDirectories = getProperty(props, "TotalFiles").getLongValue();
  nn.capacity = getProperty(props, "Total").getLongValue();
  nn.free = getProperty(props, "Free").getLongValue();
  nn.bpUsed = getProperty(props, "BlockPoolUsedSpace").getLongValue();
  nn.nonDfsUsed = getProperty(props, "NonDfsUsedSpace").getLongValue();
  nn.blocksCount = getProperty(props, "TotalBlocks").getLongValue();
  nn.missingBlocksCount = getProperty(props, "NumberOfMissingBlocks")
      .getLongValue();
  nn.httpAddress = httpAddress.toURL();
  getLiveNodeCount(getProperty(props, "LiveNodes").asText(), nn);
  getDeadNodeCount(getProperty(props, "DeadNodes").asText(), nn);
  nn.softwareVersion = getProperty(props, "SoftwareVersion").getTextValue();
  return nn;
}
 
Example 3
Project: lazycat   File: MemoryUserDatabaseMBean.java   Source Code and License 6 votes vote down vote up
/**
 * Return the MBean Name for the specified group name (if any); otherwise
 * return <code>null</code>.
 *
 * @param groupname
 *            Group name to look up
 */
public String findGroup(String groupname) {

	UserDatabase database = (UserDatabase) this.resource;
	Group group = database.findGroup(groupname);
	if (group == null) {
		return (null);
	}
	try {
		ObjectName oname = MBeanUtils.createObjectName(managedGroup.getDomain(), group);
		return (oname.toString());
	} catch (MalformedObjectNameException e) {
		IllegalArgumentException iae = new IllegalArgumentException(
				"Cannot create object name for group [" + groupname + "]");
		iae.initCause(e);
		throw iae;
	}

}
 
Example 4
Project: lazycat   File: GroupMBean.java   Source Code and License 6 votes vote down vote up
/**
 * Return the MBean Names of all authorized roles for this group.
 */
public String[] getRoles() {

	Group group = (Group) this.resource;
	ArrayList<String> results = new ArrayList<String>();
	Iterator<Role> roles = group.getRoles();
	while (roles.hasNext()) {
		Role role = null;
		try {
			role = roles.next();
			ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), role);
			results.add(oname.toString());
		} catch (MalformedObjectNameException e) {
			IllegalArgumentException iae = new IllegalArgumentException(
					"Cannot create object name for role " + role);
			iae.initCause(e);
			throw iae;
		}
	}
	return results.toArray(new String[results.size()]);

}
 
Example 5
Project: sepatools   File: Engine.java   Source Code and License 6 votes vote down vote up
public boolean init() throws MalformedObjectNameException, InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException, FileNotFoundException, NoSuchElementException, IOException {			
	//Initialize SPARQL 1.1 processing service properties
	endpointProperties = new SPARQL11Properties("endpoint.jpar");
	
	//Initialize SPARQL 1.1 SE processing service properties
	engineProperties = new EngineProperties("engine.jpar");
	
	//SPARQL 1.1 SE request processor
	processor = new Processor(endpointProperties);
	
	//SPARQL 1.1 SE request scheduler
	scheduler = new Scheduler(engineProperties,processor);
	
	//SPARQL 1.1 Protocol handlers
	httpGate = new HTTPGate(engineProperties,scheduler);
	httpsGate = new HTTPSGate(engineProperties,scheduler,am);
	
	//SPARQL 1.1 SE Protocol handler for WebSocket based subscriptions
	websocketApp = new WSGate(engineProperties,scheduler);
	secureWebsocketApp = new WSSGate(engineProperties,scheduler,am);
	        
       return true;
}
 
Example 6
Project: Pogamut3   File: Test01_Jmx.java   Source Code and License 6 votes vote down vote up
@Test
public void changeExportedFolderRemotely() throws MalformedURLException, IOException, MalformedObjectNameException, IntrospectionException {
    // connect through RMI and get the proxy
    JMXServiceURL url = new JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:9999/server");
    JMXConnector jmxc = JMXConnectorFactory.connect(url, null);
    MBeanServerConnection mbsc = jmxc.getMBeanServerConnection();
    ObjectName agentName = ObjectName.getInstance("myDomain:name=Alice,type=tutorial");
    /*DynamicMBean proxy = JMX.newMBeanProxy(mbs, 
            agentName,
            DynamicMBean.class);
    */
    DynamicProxy proxy = new DynamicProxy(agentName, mbsc);
     // convert the proxy to standard Folder
    
    Folder jmxFolder = new DynamicMBeanToFolderAdapter(proxy);
    //jmxFolder.getProperty("name").setValue("Cecil Corn");
    String newName = "Cecil Corn";
    jmxFolder.getFolder("knows").getProperty("name").setValue(newName);
    //mbsc.setAttribute(agentName, new Attribute("name", "Bob"));

   // waitForEnterPressed();
    assertTrue(person.knows.name.equals(newName));
    System.out.println("---/// TEST OK ///---");
}
 
Example 7
Project: apache-tomcat-7.0.73-with-comment   File: MemoryUserDatabaseMBean.java   Source Code and License 6 votes vote down vote up
/**
 * Return the MBean Name for the specified role name (if any);
 * otherwise return <code>null</code>.
 *
 * @param rolename Role name to look up
 */
public String findRole(String rolename) {

    UserDatabase database = (UserDatabase) this.resource;
    Role role = database.findRole(rolename);
    if (role == null) {
        return (null);
    }
    try {
        ObjectName oname =
            MBeanUtils.createObjectName(managedRole.getDomain(), role);
        return (oname.toString());
    } catch (MalformedObjectNameException e) {
        IllegalArgumentException iae = new IllegalArgumentException
            ("Cannot create object name for role [" + rolename + "]");
        iae.initCause(e);
        throw iae;
    }

}
 
Example 8
Project: apache-tomcat-7.0.73-with-comment   File: MemoryUserDatabaseMBean.java   Source Code and License 6 votes vote down vote up
/**
 * Return the MBean Name for the specified user name (if any);
 * otherwise return <code>null</code>.
 *
 * @param username User name to look up
 */
public String findUser(String username) {

    UserDatabase database = (UserDatabase) this.resource;
    User user = database.findUser(username);
    if (user == null) {
        return (null);
    }
    try {
        ObjectName oname =
            MBeanUtils.createObjectName(managedUser.getDomain(), user);
        return (oname.toString());
    } catch (MalformedObjectNameException e) {
        IllegalArgumentException iae = new IllegalArgumentException
            ("Cannot create object name for user [" + username + "]");
        iae.initCause(e);
        throw iae;
    }

}
 
Example 9
Project: jerrydog   File: NamingResourcesMBean.java   Source Code and License 6 votes vote down vote up
/**
 * Return the MBean Names of all the defined resource references for this
 * application.
 */
public String[] getResources() {
    
    ContextResource[] resources = 
                        ((NamingResources)this.resource).findResources();
    ArrayList results = new ArrayList();
    for (int i = 0; i < resources.length; i++) {
        try {
            ObjectName oname =
                MBeanUtils.createObjectName(managed.getDomain(), resources[i]);
            results.add(oname.toString());
        } catch (MalformedObjectNameException e) {
            throw new IllegalArgumentException
                ("Cannot create object name for resource " + resources[i]);
        }
    }
    return ((String[]) results.toArray(new String[results.size()]));

}
 
Example 10
Project: uavstack   File: BaseJMXMonitorDataCatchWorker.java   Source Code and License 6 votes vote down vote up
/**
 * scan out all monitor MBeans
 *
 * @param mbsc
 * @return
 * @throws IOException
 */
protected Set<ObjectInstance> scanMBeans(MBeanServerConnection mbsc, String pattern) throws IOException {

    Set<ObjectInstance> monitorMBeans = null;
    int count = 2;
    while (count > 0) {
        try {
            monitorMBeans = mbsc.queryMBeans(new ObjectName(pattern), null);

            if (monitorMBeans == null || monitorMBeans.isEmpty()) {
                ThreadHelper.suspend(2000);
            }
            else {
                break;
            }

        }
        catch (MalformedObjectNameException e) {
            // ignore
        }
        count--;
    }

    return monitorMBeans;
}
 
Example 11
Project: apache-tomcat-7.0.73-with-comment   File: MemoryUserDatabaseMBean.java   Source Code and License 6 votes vote down vote up
/**
 * Return the MBean Name for the specified group name (if any);
 * otherwise return <code>null</code>.
 *
 * @param groupname Group name to look up
 */
public String findGroup(String groupname) {

    UserDatabase database = (UserDatabase) this.resource;
    Group group = database.findGroup(groupname);
    if (group == null) {
        return (null);
    }
    try {
        ObjectName oname =
            MBeanUtils.createObjectName(managedGroup.getDomain(), group);
        return (oname.toString());
    } catch (MalformedObjectNameException e) {
        IllegalArgumentException iae = new IllegalArgumentException
            ("Cannot create object name for group [" + groupname + "]");
        iae.initCause(e);
        throw iae;
    }

}
 
Example 12
Project: apache-tomcat-7.0.73-with-comment   File: AbstractProtocol.java   Source Code and License 6 votes vote down vote up
private ObjectName createObjectName() throws MalformedObjectNameException {
    // Use the same domain as the connector
    domain = adapter.getDomain();

    if (domain == null) {
        return null;
    }

    StringBuilder name = new StringBuilder(getDomain());
    name.append(":type=ProtocolHandler,port=");
    int port = getPort();
    if (port > 0) {
        name.append(getPort());
    } else {
        name.append("auto-");
        name.append(getNameIndex());
    }
    InetAddress address = getAddress();
    if (address != null) {
        name.append(",address=");
        name.append(ObjectName.quote(address.getHostAddress()));
    }
    return new ObjectName(name.toString());
}
 
Example 13
Project: tomcat7   File: NamingResourcesMBean.java   Source Code and License 6 votes vote down vote up
/**
 * Return the MBean Names of the set of defined environment entries for  
 * this web application
 */
public String[] getEnvironments() {
    ContextEnvironment[] envs = 
                        ((NamingResources)this.resource).findEnvironments();
    ArrayList<String> results = new ArrayList<String>();
    for (int i = 0; i < envs.length; i++) {
        try {
            ObjectName oname =
                MBeanUtils.createObjectName(managed.getDomain(), envs[i]);
            results.add(oname.toString());
        } catch (MalformedObjectNameException e) {
            IllegalArgumentException iae = new IllegalArgumentException
                ("Cannot create object name for environment " + envs[i]);
            iae.initCause(e);
            throw iae;
        }
    }
    return results.toArray(new String[results.size()]);

}
 
Example 14
Project: tomcat7   File: NamingResourcesMBean.java   Source Code and License 6 votes vote down vote up
/**
 * Return the MBean Names of all the defined resource references for this
 * application.
 */
public String[] getResources() {
    
    ContextResource[] resources = 
                        ((NamingResources)this.resource).findResources();
    ArrayList<String> results = new ArrayList<String>();
    for (int i = 0; i < resources.length; i++) {
        try {
            ObjectName oname =
                MBeanUtils.createObjectName(managed.getDomain(), resources[i]);
            results.add(oname.toString());
        } catch (MalformedObjectNameException e) {
            IllegalArgumentException iae = new IllegalArgumentException
                ("Cannot create object name for resource " + resources[i]);
            iae.initCause(e);
            throw iae;
        }
    }
    return results.toArray(new String[results.size()]);

}
 
Example 15
Project: tomcat7   File: NamingResourcesMBean.java   Source Code and License 6 votes vote down vote up
/**
 * Return the MBean Names of all the defined resource link references for 
 * this application.
 */
public String[] getResourceLinks() {
    
    ContextResourceLink[] resourceLinks = 
                        ((NamingResources)this.resource).findResourceLinks();
    ArrayList<String> results = new ArrayList<String>();
    for (int i = 0; i < resourceLinks.length; i++) {
        try {
            ObjectName oname =
                MBeanUtils.createObjectName(managed.getDomain(), resourceLinks[i]);
            results.add(oname.toString());
        } catch (MalformedObjectNameException e) {
            IllegalArgumentException iae = new IllegalArgumentException
                ("Cannot create object name for resource " + resourceLinks[i]);
            iae.initCause(e);
            throw iae;
        }
    }
    return results.toArray(new String[results.size()]);

}
 
Example 16
Project: tomcat7   File: GroupMBean.java   Source Code and License 6 votes vote down vote up
/**
 * Return the MBean Names of all authorized roles for this group.
 */
public String[] getRoles() {

    Group group = (Group) this.resource;
    ArrayList<String> results = new ArrayList<String>();
    Iterator<Role> roles = group.getRoles();
    while (roles.hasNext()) {
        Role role = null;
        try {
            role = roles.next();
            ObjectName oname =
                MBeanUtils.createObjectName(managed.getDomain(), role);
            results.add(oname.toString());
        } catch (MalformedObjectNameException e) {
            IllegalArgumentException iae = new IllegalArgumentException
                ("Cannot create object name for role " + role);
            iae.initCause(e);
            throw iae;
        }
    }
    return results.toArray(new String[results.size()]);

}
 
Example 17
Project: tomcat7   File: UserMBean.java   Source Code and License 6 votes vote down vote up
/**
 * Return the MBean Names of all groups this user is a member of.
 */
public String[] getGroups() {

    User user = (User) this.resource;
    ArrayList<String> results = new ArrayList<String>();
    Iterator<Group> groups = user.getGroups();
    while (groups.hasNext()) {
        Group group = null;
        try {
            group = groups.next();
            ObjectName oname =
                MBeanUtils.createObjectName(managed.getDomain(), group);
            results.add(oname.toString());
        } catch (MalformedObjectNameException e) {
            IllegalArgumentException iae = new IllegalArgumentException
                ("Cannot create object name for group " + group);
            iae.initCause(e);
            throw iae;
        }
    }
    return results.toArray(new String[results.size()]);

}
 
Example 18
Project: tomcat7   File: UserMBean.java   Source Code and License 6 votes vote down vote up
/**
 * Return the MBean Names of all roles assigned to this user.
 */
public String[] getRoles() {

    User user = (User) this.resource;
    ArrayList<String> results = new ArrayList<String>();
    Iterator<Role> roles = user.getRoles();
    while (roles.hasNext()) {
        Role role = null;
        try {
            role = roles.next();
            ObjectName oname =
                MBeanUtils.createObjectName(managed.getDomain(), role);
            results.add(oname.toString());
        } catch (MalformedObjectNameException e) {
            IllegalArgumentException iae = new IllegalArgumentException
                ("Cannot create object name for role " + role);
            iae.initCause(e);
            throw iae;
        }
    }
    return results.toArray(new String[results.size()]);

}
 
Example 19
Project: tomcat7   File: MemoryUserDatabaseMBean.java   Source Code and License 6 votes vote down vote up
/**
 * Return the MBean Name for the specified group name (if any);
 * otherwise return <code>null</code>.
 *
 * @param groupname Group name to look up
 */
public String findGroup(String groupname) {

    UserDatabase database = (UserDatabase) this.resource;
    Group group = database.findGroup(groupname);
    if (group == null) {
        return (null);
    }
    try {
        ObjectName oname =
            MBeanUtils.createObjectName(managedGroup.getDomain(), group);
        return (oname.toString());
    } catch (MalformedObjectNameException e) {
        IllegalArgumentException iae = new IllegalArgumentException
            ("Cannot create object name for group [" + groupname + "]");
        iae.initCause(e);
        throw iae;
    }

}
 
Example 20
Project: tomcat7   File: MemoryUserDatabaseMBean.java   Source Code and License 6 votes vote down vote up
/**
 * Return the MBean Name for the specified user name (if any);
 * otherwise return <code>null</code>.
 *
 * @param username User name to look up
 */
public String findUser(String username) {

    UserDatabase database = (UserDatabase) this.resource;
    User user = database.findUser(username);
    if (user == null) {
        return (null);
    }
    try {
        ObjectName oname =
            MBeanUtils.createObjectName(managedUser.getDomain(), user);
        return (oname.toString());
    } catch (MalformedObjectNameException e) {
        IllegalArgumentException iae = new IllegalArgumentException
            ("Cannot create object name for user [" + username + "]");
        iae.initCause(e);
        throw iae;
    }

}
 
Example 21
Project: apache-tomcat-7.0.73-with-comment   File: NamingResourcesMBean.java   Source Code and License 6 votes vote down vote up
/**
 * Return the MBean Names of all the defined resource references for this
 * application.
 */
public String[] getResources() {
    
    ContextResource[] resources = 
                        ((NamingResources)this.resource).findResources();
    ArrayList<String> results = new ArrayList<String>();
    for (int i = 0; i < resources.length; i++) {
        try {
            ObjectName oname =
                MBeanUtils.createObjectName(managed.getDomain(), resources[i]);
            results.add(oname.toString());
        } catch (MalformedObjectNameException e) {
            IllegalArgumentException iae = new IllegalArgumentException
                ("Cannot create object name for resource " + resources[i]);
            iae.initCause(e);
            throw iae;
        }
    }
    return results.toArray(new String[results.size()]);

}
 
Example 22
Project: apache-tomcat-7.0.73-with-comment   File: NamingResourcesMBean.java   Source Code and License 6 votes vote down vote up
/**
 * Return the MBean Names of the set of defined environment entries for  
 * this web application
 */
public String[] getEnvironments() {
    ContextEnvironment[] envs = 
                        ((NamingResources)this.resource).findEnvironments();
    ArrayList<String> results = new ArrayList<String>();
    for (int i = 0; i < envs.length; i++) {
        try {
            ObjectName oname =
                MBeanUtils.createObjectName(managed.getDomain(), envs[i]);
            results.add(oname.toString());
        } catch (MalformedObjectNameException e) {
            IllegalArgumentException iae = new IllegalArgumentException
                ("Cannot create object name for environment " + envs[i]);
            iae.initCause(e);
            throw iae;
        }
    }
    return results.toArray(new String[results.size()]);

}
 
Example 23
Project: tomcat7   File: AbstractProtocol.java   Source Code and License 6 votes vote down vote up
private ObjectName createObjectName() throws MalformedObjectNameException {
    // Use the same domain as the connector
    domain = adapter.getDomain();

    if (domain == null) {
        return null;
    }

    StringBuilder name = new StringBuilder(getDomain());
    name.append(":type=ProtocolHandler,port=");
    int port = getPort();
    if (port > 0) {
        name.append(getPort());
    } else {
        name.append("auto-");
        name.append(getNameIndex());
    }
    InetAddress address = getAddress();
    if (address != null) {
        name.append(",address=");
        name.append(ObjectName.quote(address.getHostAddress()));
    }
    return new ObjectName(name.toString());
}
 
Example 24
Project: monarch   File: MBeanServerConnectionRule.java   Source Code and License 6 votes vote down vote up
/**
 * Retrieve a new proxy MBean
 *
 * @return A new proxy MBean of the same type with which the class was constructed
 */
public <T> T getProxyMBean(Class<T> proxyClass, String beanQueryName)
    throws MalformedObjectNameException, IOException {
  ObjectName name = null;
  QueryExp query = null;

  if (proxyClass != null) {
    query = Query.isInstanceOf(Query.value(proxyClass.getName()));
  }

  if (beanQueryName != null) {
    name = ObjectName.getInstance(beanQueryName);
  }

  Set<ObjectInstance> beans = con.queryMBeans(name, query);
  assertEquals("failed to find only one instance of type " + proxyClass.getName() + " with name "
      + beanQueryName, 1, beans.size());

  return JMX.newMXBeanProxy(con, ((ObjectInstance) beans.toArray()[0]).getObjectName(),
      proxyClass);
}
 
Example 25
Project: jerrydog   File: MemoryUserDatabaseMBean.java   Source Code and License 6 votes vote down vote up
/**
 * Return the MBean Name for the specified user name (if any);
 * otherwise return <code>null</code>.
 *
 * @param username User name to look up
 */
public String findUser(String username) {

    UserDatabase database = (UserDatabase) this.resource;
    User user = database.findUser(username);
    if (user == null) {
        return (null);
    }
    try {
        ObjectName oname =
            MBeanUtils.createObjectName(managedUser.getDomain(), user);
        return (oname.toString());
    } catch (MalformedObjectNameException e) {
        throw new IllegalArgumentException
            ("Cannot create object name for user " + user);
    }

}
 
Example 26
Project: lazycat   File: UserMBean.java   Source Code and License 6 votes vote down vote up
/**
 * Return the MBean Names of all groups this user is a member of.
 */
public String[] getGroups() {

	User user = (User) this.resource;
	ArrayList<String> results = new ArrayList<String>();
	Iterator<Group> groups = user.getGroups();
	while (groups.hasNext()) {
		Group group = null;
		try {
			group = groups.next();
			ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), group);
			results.add(oname.toString());
		} catch (MalformedObjectNameException e) {
			IllegalArgumentException iae = new IllegalArgumentException(
					"Cannot create object name for group " + group);
			iae.initCause(e);
			throw iae;
		}
	}
	return results.toArray(new String[results.size()]);

}
 
Example 27
Project: lazycat   File: AbstractProtocol.java   Source Code and License 6 votes vote down vote up
private ObjectName createObjectName() throws MalformedObjectNameException {
	// Use the same domain as the connector
	domain = adapter.getDomain();

	if (domain == null) {
		return null;
	}

	StringBuilder name = new StringBuilder(getDomain());
	name.append(":type=ProtocolHandler,port=");
	int port = getPort();
	if (port > 0) {
		name.append(getPort());
	} else {
		name.append("auto-");
		name.append(getNameIndex());
	}
	InetAddress address = getAddress();
	if (address != null) {
		name.append(",address=");
		name.append(ObjectName.quote(address.getHostAddress()));
	}
	return new ObjectName(name.toString());
}
 
Example 28
Project: apache-tomcat-7.0.73-with-comment   File: GroupMBean.java   Source Code and License 6 votes vote down vote up
/**
 * Return the MBean Names of all authorized roles for this group.
 */
public String[] getRoles() {

    Group group = (Group) this.resource;
    ArrayList<String> results = new ArrayList<String>();
    Iterator<Role> roles = group.getRoles();
    while (roles.hasNext()) {
        Role role = null;
        try {
            role = roles.next();
            ObjectName oname =
                MBeanUtils.createObjectName(managed.getDomain(), role);
            results.add(oname.toString());
        } catch (MalformedObjectNameException e) {
            IllegalArgumentException iae = new IllegalArgumentException
                ("Cannot create object name for role " + role);
            iae.initCause(e);
            throw iae;
        }
    }
    return results.toArray(new String[results.size()]);

}
 
Example 29
Project: lazycat   File: NamingResourcesMBean.java   Source Code and License 6 votes vote down vote up
/**
 * Return the MBean Names of the set of defined environment entries for this
 * web application
 */
public String[] getEnvironments() {
	ContextEnvironment[] envs = ((NamingResources) this.resource).findEnvironments();
	ArrayList<String> results = new ArrayList<String>();
	for (int i = 0; i < envs.length; i++) {
		try {
			ObjectName oname = MBeanUtils.createObjectName(managed.getDomain(), envs[i]);
			results.add(oname.toString());
		} catch (MalformedObjectNameException e) {
			IllegalArgumentException iae = new IllegalArgumentException(
					"Cannot create object name for environment " + envs[i]);
			iae.initCause(e);
			throw iae;
		}
	}
	return results.toArray(new String[results.size()]);

}
 
Example 30
Project: lams   File: NamingResourcesMBean.java   Source Code and License 6 votes vote down vote up
/**
 * Return the MBean Names of all the defined resource references for this
 * application.
 */
public String[] getResources() {
    
    ContextResource[] resources = 
                        ((NamingResources)this.resource).findResources();
    ArrayList results = new ArrayList();
    for (int i = 0; i < resources.length; i++) {
        try {
            ObjectName oname =
                MBeanUtils.createObjectName(managed.getDomain(), resources[i]);
            results.add(oname.toString());
        } catch (MalformedObjectNameException e) {
            IllegalArgumentException iae = new IllegalArgumentException
                ("Cannot create object name for resource " + resources[i]);
            iae.initCause(e);
            throw iae;
        }
    }
    return ((String[]) results.toArray(new String[results.size()]));

}
 
Example 31
Project: lams   File: StandardContextMBean.java   Source Code and License 6 votes vote down vote up
/**
 * Return the MBean Names of the set of defined environment entries for  
 * this web application
 */
public String[] getEnvironments() {
    ContextEnvironment[] envs = getNamingResources().findEnvironments();
    ArrayList results = new ArrayList();
    for (int i = 0; i < envs.length; i++) {
        try {
            ObjectName oname =
                MBeanUtils.createObjectName(managed.getDomain(), envs[i]);
            results.add(oname.toString());
        } catch (MalformedObjectNameException e) {
            IllegalArgumentException iae = new IllegalArgumentException
                ("Cannot create object name for environment " + envs[i]);
            iae.initCause(e);
            throw iae;
        }
    }
    return ((String[]) results.toArray(new String[results.size()]));

}
 
Example 32
Project: lams   File: StandardContextMBean.java   Source Code and License 6 votes vote down vote up
/**
 * Return the MBean Names of all the defined resource links for this 
 * application
 */
public String[] getResourceLinks() {
    
    ContextResourceLink[] links = getNamingResources().findResourceLinks();
    ArrayList results = new ArrayList();
    for (int i = 0; i < links.length; i++) {
        try {
            ObjectName oname =
                MBeanUtils.createObjectName(managed.getDomain(), links[i]);
            results.add(oname.toString());
        } catch (MalformedObjectNameException e) {
            IllegalArgumentException iae = new IllegalArgumentException
                ("Cannot create object name for resource " + links[i]);
            iae.initCause(e);
            throw iae;
        }
    }
    return ((String[]) results.toArray(new String[results.size()]));

}
 
Example 33
Project: ZooKeeper   File: MBeanRegistry.java   Source Code and License 6 votes vote down vote up
/**
 * Builds an MBean path and creates an ObjectName instance using the path. 
 * @param path MBean path
 * @param bean the MBean instance
 * @return ObjectName to be registered with the platform MBean server
 */
protected ObjectName makeObjectName(String path, ZKMBeanInfo bean)
    throws MalformedObjectNameException
{
    if(path==null)
        return null;
    StringBuilder beanName = new StringBuilder(CommonNames.DOMAIN + ":");
    int counter=0;
    counter=tokenize(beanName,path,counter);
    tokenize(beanName,bean.getName(),counter);
    beanName.deleteCharAt(beanName.length()-1);
    try {
        return new ObjectName(beanName.toString());
    } catch (MalformedObjectNameException e) {
        LOG.warn("Invalid name \"" + beanName.toString() + "\" for class "
                + bean.getClass().toString());
        throw e;
    }
}
 
Example 34
Project: lams   File: JmxServiceImpl.java   Source Code and License 6 votes vote down vote up
@Override
public void registerService(Manageable service, Class<? extends Service> serviceRole) {
	final String domain = service.getManagementDomain() == null
			? AvailableSettings.JMX_DEFAULT_OBJ_NAME_DOMAIN
			: service.getManagementDomain();
	final String serviceType = service.getManagementServiceType() == null
			? service.getClass().getName()
			: service.getManagementServiceType();
	try {
		final ObjectName objectName = new ObjectName(
				String.format(
						OBJ_NAME_TEMPLATE,
						domain,
						sessionFactoryName,
						serviceRole.getName(),
						serviceType
				)
		);
		registerMBean( objectName, service.getManagementBean() );
	}
	catch ( MalformedObjectNameException e ) {
		throw new HibernateException( "Unable to generate service IbjectName", e );
	}
}
 
Example 35
Project: https-github.com-apache-zookeeper   File: MBeanRegistry.java   Source Code and License 6 votes vote down vote up
/**
 * Builds an MBean path and creates an ObjectName instance using the path. 
 * @param path MBean path
 * @param bean the MBean instance
 * @return ObjectName to be registered with the platform MBean server
 */
protected ObjectName makeObjectName(String path, ZKMBeanInfo bean)
    throws MalformedObjectNameException
{
    if(path==null)
        return null;
    StringBuilder beanName = new StringBuilder(CommonNames.DOMAIN + ":");
    int counter=0;
    counter=tokenize(beanName,path,counter);
    tokenize(beanName,bean.getName(),counter);
    beanName.deleteCharAt(beanName.length()-1);
    try {
        return new ObjectName(beanName.toString());
    } catch (MalformedObjectNameException e) {
        LOG.warn("Invalid name \"" + beanName.toString() + "\" for class "
                + bean.getClass().toString());
        throw e;
    }
}
 
Example 36
Project: jerrydog   File: NamingResourcesMBean.java   Source Code and License 6 votes vote down vote up
/**
 * Return the MBean Names of the set of defined environment entries for  
 * this web application
 */
public String[] getEnvironments() {
    ContextEnvironment[] envs = 
                        ((NamingResources)this.resource).findEnvironments();
    ArrayList results = new ArrayList();
    for (int i = 0; i < envs.length; i++) {
        try {
            ObjectName oname =
                MBeanUtils.createObjectName(managed.getDomain(), envs[i]);
            results.add(oname.toString());
        } catch (MalformedObjectNameException e) {
            throw new IllegalArgumentException
                ("Cannot create object name for environment " + envs[i]);
        }
    }
    return ((String[]) results.toArray(new String[results.size()]));

}
 
Example 37
Project: pooled-jms   File: QpidJmsPoolTestSupport.java   Source Code and License 5 votes vote down vote up
protected BrokerViewMBean getProxyToBroker() throws MalformedObjectNameException, JMSException {
    ObjectName brokerViewMBean = new ObjectName(
        "org.apache.activemq:type=Broker,brokerName=" + brokerService.getBrokerName());
    BrokerViewMBean proxy = (BrokerViewMBean) brokerService.getManagementContext()
            .newProxyInstance(brokerViewMBean, BrokerViewMBean.class, true);
    return proxy;
}
 
Example 38
Project: pooled-jms   File: ActiveMQJmsPoolTestSupport.java   Source Code and License 5 votes vote down vote up
protected BrokerViewMBean getProxyToBroker() throws MalformedObjectNameException, JMSException {
    ObjectName brokerViewMBean = new ObjectName(
        "org.apache.activemq:type=Broker,brokerName=" + brokerService.getBrokerName());
    BrokerViewMBean proxy = (BrokerViewMBean) brokerService.getManagementContext()
            .newProxyInstance(brokerViewMBean, BrokerViewMBean.class, true);
    return proxy;
}
 
Example 39
Project: sepatools   File: Scheduler.java   Source Code and License 5 votes vote down vote up
public Scheduler(EngineProperties properties,Processor processor) throws MalformedObjectNameException, InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException {
	requestHandler = new RequestResponseHandler(properties);
	tokenHandler = new TokenHandler(properties);
	
	if (processor == null) logger.error("Processor is null");
	else {
		this.processor = processor;
		this.processor.addObserver(this);
	}
}
 
Example 40
Project: sepatools   File: Engine.java   Source Code and License 5 votes vote down vote up
public static void main(String[] args) throws MalformedObjectNameException, InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException, FileNotFoundException, NoSuchElementException, IOException {
	System.out.println("##########################################################################################");
	System.out.println("# SEPA Engine Ver 0.6  Copyright (C) 2016-2017                                           #");
	System.out.println("# University of Bologna (Italy)                                                          #");
	System.out.println("#                                                                                        #");
	System.out.println("# This program comes with ABSOLUTELY NO WARRANTY                                         #");                                    
	System.out.println("# This is free software, and you are welcome to redistribute it under certain conditions #");
	System.out.println("# GNU GENERAL PUBLIC LICENSE, Version 3, 29 June 2007                                    #");
	System.out.println("#                                                                                        #");
	System.out.println("# GitHub: https://github.com/vaimee/sepatools                                            #");
	System.out.println("# Web: http://wot.arces.unibo.it                                                         #");
	System.out.println("##########################################################################################");
	System.out.println("");		
	System.out.println("Dependencies");
	System.out.println("com.google.code.gson          2.8.0       Apache 2.0");
	System.out.println("com.nimbusds                  4.34.2      The Apache Software License, Version 2.0");
	System.out.println("commons-io                    2.5         Apache License, Version 2.0");
	System.out.println("commons-logging               1.2         The Apache Software License, Version 2.0");
	System.out.println("org.apache.httpcomponents     4.5.3       Apache License, Version 2.0");
	System.out.println("org.apache.httpcomponents     4.4.6       Apache License, Version 2.0");
	System.out.println("org.apache.logging.log4j      2.8.1       Apache License, Version 2.0");
	System.out.println("org.bouncycastle              1.56        Bouncy Castle Licence");
	System.out.println("org.eclipse.paho              1.1.1       Eclipse Public License - Version 1.0");
	System.out.println("org.glassfish.grizzly         2.3.30      CDDL+GPL");
	System.out.println("org.glassfish.tyrus.bundles   1.13.1      Dual license consisting of the CDDL v1.1 and GPL v2");
	System.out.println("org.jdom                      2.0.6       Similar to Apache License but with the acknowledgment clause removed");
	System.out.println("");
	
	//Engine creation and initialization
	Engine engine = new Engine();
	engine.init();
	
	//Starting main engine thread
	engine.start();
}
 
Example 41
Project: Pogamut3   File: GhostAgentJMXProxy.java   Source Code and License 5 votes vote down vote up
public GhostAgentJMXProxy(String agentJMXAddress) throws MalformedURLException, IOException, MalformedObjectNameException {
     super(agentJMXAddress);
     final ObjectName actMBeanName = PogamutJMX.getObjectName(getObjectName(), PogamutJMX.ACT_NAME);
     act = new IAct() {

     	Token componentId = Tokens.get(PogamutJMX.ACT_NAME);
     	
         @Override
         public void act(CommandMessage command) throws CommunicationException {
             try {
                 getMBeanServerConnection().invoke(actMBeanName, "act", new Object[]{command}, null);
             } catch (Exception ex) {
                 throw  new CommunicationException("JMX error sending command.", ex, this);
             }
         }

         @Override
         public void addCommandListener(Class commandClass, ICommandListener listener) {
             throw new UnsupportedOperationException("Not supported yet.");
         }

         @Override
         public void removeCommandListener(Class commandClass, ICommandListener listener) {
             throw new UnsupportedOperationException("Not supported yet.");
         }

@Override
public Token getComponentId() {
	return componentId;
}

@Override
public boolean isCommandListening(Class commandClass,
		ICommandListener listener) {
	throw new UnsupportedOperationException("Not supported yet.");
}

     };
 }
 
Example 42
Project: Pogamut3   File: JMXFlagDecorator.java   Source Code and License 5 votes vote down vote up
/**
 * 
 * @param flag Flag to be exposed through JMX.
 * @param source MBean or ObjectName of the object where the flag resides.
 * @param nbs NotificationBroadcasterSupport through which the events will be send.
 */
public JMXFlagDecorator(Flag<T> flag, ObjectName source, MBeanServer mbs, String flagName) throws MalformedObjectNameException, InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException {
    this.flag = flag;
    this.source = source;
    this.flagName = flagName;
    ObjectName name = PogamutJMX.getObjectName(source, flagName, PogamutJMX.FLAGS_SUBTYPE);
    mbs.registerMBean(this, name);
    flag.addListener(listener);
}
 
Example 43
Project: Byter   File: Server.java   Source Code and License 5 votes vote down vote up
/**
 * Tutorial MBean for master thesis.
 */
private void buildExampleStaticMBean(){
    try{
        final ExampleStatic exampleStatic = new ExampleStatic("HOST",42);
        this.mBeanHelper.registerStaticElement(exampleStatic,exampleStatic.getObjectName());
    } catch (final MalformedObjectNameException e) {
        log.log(Level.WARNING,"Could not create static example mbean due to Malformed ObjectName Exception");
    }
}
 
Example 44
Project: qpid-jms-spring-boot   File: QpidJMSSpringBootHelloWorldTest.java   Source Code and License 5 votes vote down vote up
protected BrokerViewMBean getProxyToBroker() throws MalformedObjectNameException, JMSException {
    ObjectName brokerViewMBean = new ObjectName(
        "org.apache.activemq:type=Broker,brokerName=localhost");
    BrokerViewMBean proxy = (BrokerViewMBean) brokerService.getManagementContext()
            .newProxyInstance(brokerViewMBean, BrokerViewMBean.class, true);
    return proxy;
}
 
Example 45
Project: jdk8u-jdk   File: Util.java   Source Code and License 5 votes vote down vote up
public static ObjectName newObjectName(String name) {
    try {
        return ObjectName.getInstance(name);
    } catch (MalformedObjectNameException e) {
        throw new IllegalArgumentException(e);
    }
}
 
Example 46
Project: openjdk-jdk10   File: AMXClient.java   Source Code and License 5 votes vote down vote up
private static ObjectName makeObjectName( String str ) {
    try {
        return new ObjectName(str);
    } catch (MalformedObjectNameException ex) {
        return null ;
    }
}
 
Example 47
Project: openjdk-jdk10   File: CompressedStorageTest.java   Source Code and License 5 votes vote down vote up
/**
 * Test for rejecting value exceeding the maximum allowed length
 * being passed as argument to {@linkplain ObjectName#setDomainLength(int)}.
 */
private static void testMaxLength() throws Exception {
    try {
        setDomainNameLength(Integer.MAX_VALUE / 4 + 1);
    } catch (MalformedObjectNameException e) {
        return;
    }
    fail("Maximum domain name length is not respected");
}
 
Example 48
Project: apache-tomcat-7.0.73-with-comment   File: DataSource.java   Source Code and License 5 votes vote down vote up
/**
 * If the connection pool MBean exists, it will be registered during this operation.<br/>
 * {@inheritDoc}
 */
@Override
public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception {
    try {
        if ( isJmxEnabled() ) { 
            this.oname = createObjectName(name);
            if (oname!=null) registerJmx();
        }
    }catch (MalformedObjectNameException x) {
        log.error("Unable to create object name for JDBC pool.",x);
    }
    return name;
}
 
Example 49
Project: monarch   File: LauncherLifecycleCommands.java   Source Code and License 5 votes vote down vote up
protected void addCurrentLocators(final List<String> commandLine,
    final Properties gemfireProperties) throws MalformedObjectNameException {
  if (StringUtils.isBlank(gemfireProperties.getProperty(LOCATORS))) {
    String currentLocators = getCurrentLocators();

    if (!StringUtils.isBlank(currentLocators)) {
      commandLine.add("-D".concat(ProcessLauncherContext.OVERRIDDEN_DEFAULTS_PREFIX)
          .concat(LOCATORS).concat("=").concat(currentLocators));
    }
  }
}
 
Example 50
Project: fuck_zookeeper   File: JMXEnv.java   Source Code and License 5 votes vote down vote up
public static void dump() throws IOException {
    LOG.info("JMXEnv.dump() follows");
    Set<ObjectName> beans;
    try {
        beans = conn().queryNames(
                new ObjectName(CommonNames.DOMAIN + ":*"), null);
    } catch (MalformedObjectNameException e) {
        throw new RuntimeException(e);
    }
    for (ObjectName bean : beans) {
        LOG.info("bean:" + bean.toString());
    }
}
 
Example 51
Project: fuck_zookeeper   File: JMXEnv.java   Source Code and License 5 votes vote down vote up
/**
 * Ensure that the specified parent names are registered. Note that these
 * are components of the name. It waits in a loop up to 60 seconds before
 * failing if there is a mismatch. This will return the beans which are not
 * matched.
 * 
 * {@link https://issues.apache.org/jira/browse/ZOOKEEPER-1858}
 * 
 * @param expectedNames
 *            - expected beans
 * @return the beans which are not matched with the given expected names
 * 
 * @throws IOException
 * @throws InterruptedException
 * 
 */
public static Set<ObjectName> ensureParent(String... expectedNames)
        throws IOException, InterruptedException {
    LOG.info("ensureParent:" + Arrays.toString(expectedNames));

    Set<ObjectName> beans;
    int nTry = 0;
    Set<ObjectName> found = new HashSet<ObjectName>();
    do {
        if (nTry++ > 0) {
            Thread.sleep(500);
        }
        try {
            beans = conn().queryNames(
                    new ObjectName(CommonNames.DOMAIN + ":*"), null);
        } catch (MalformedObjectNameException e) {
            throw new RuntimeException(e);
        }
        found.clear();
        for (String name : expectedNames) {
            LOG.info("expect:" + name);
            for (ObjectName bean : beans) {
                // check the existence of name in bean
                if (compare(bean.toString(), name)) {
                    LOG.info("found:" + name + " " + bean);
                    found.add(bean);
                    break;
                }
            }
            beans.removeAll(found);
        }
    } while (expectedNames.length != found.size() && nTry < 120);
    TestCase.assertEquals("expected " + Arrays.toString(expectedNames),
            expectedNames.length, found.size());
    return beans;
}
 
Example 52
Project: jwala   File: JwalaAuthenticationProvider.java   Source Code and License 5 votes vote down vote up
/**
 *
 * @return Tomcat Realms
 * @throws AttributeNotFoundException
 * @throws InstanceNotFoundException
 * @throws MBeanException
 * @throws ReflectionException
 */
public Realm getTomcatContextRealm() throws AttributeNotFoundException, InstanceNotFoundException, MBeanException, ReflectionException {
    try {
        ObjectName name = new ObjectName("Catalina", "type", "Engine");
        Engine engine = (Engine) JwalaAuthenticationProvider.getmBeanServer().getAttribute(name, "managedResource");
        return engine.getRealm();
    } catch (MalformedObjectNameException ex) {
        LOGGER.error("Invalid Realm", ex);
    }
    return null;
}
 
Example 53
Project: openjdk-jdk10   File: CompressedStorageTest.java   Source Code and License 5 votes vote down vote up
/**
 * Test for rejecting negative value being passed as argument to
 * {@linkplain ObjectName#setDomainLength(int)}.
 */
private static void testNegativeLength() throws Exception {
    try {
        setDomainNameLength(-1);
    } catch (MalformedObjectNameException e) {
        return;
    }
    fail("Allowing negative domain name length");
}
 
Example 54
Project: tomcat7   File: Registry.java   Source Code and License 5 votes vote down vote up
/** Unregister a component. We'll first check if it is registered,
 * and mask all errors. This is mostly a helper.
 * 
 * @param oname
 * 
 * @since 1.1
 */ 
@Override
public void unregisterComponent( String oname ) {
    try {
        unregisterComponent(new ObjectName(oname));
    } catch (MalformedObjectNameException e) {
        log.info("Error creating object name " + e );
    }
}
 
Example 55
Project: tomcat7   File: DataSource.java   Source Code and License 5 votes vote down vote up
/**
 * If the connection pool MBean exists, it will be registered during this operation.<br/>
 * {@inheritDoc}
 */
@Override
public ObjectName preRegister(MBeanServer server, ObjectName name) throws Exception {
    try {
        if ( isJmxEnabled() ) { 
            this.oname = createObjectName(name);
            if (oname!=null) registerJmx();
        }
    }catch (MalformedObjectNameException x) {
        log.error("Unable to create object name for JDBC pool.",x);
    }
    return name;
}
 
Example 56
Project: hashsdn-controller   File: ConfigRegistryConstants.java   Source Code and License 5 votes vote down vote up
public static ObjectName createON(final String name, final String key, final String value) {
    try {
        return new ObjectName(name, key, value);
    } catch (final MalformedObjectNameException e) {
        throw new IllegalArgumentException(e);
    }

}
 
Example 57
Project: lams   File: NotificationListenerHolder.java   Source Code and License 5 votes vote down vote up
/**
 * Return the list of {@link javax.management.ObjectName} String representations for
 * which the encapsulated {@link #getNotificationFilter() NotificationFilter} will
 * be registered as a listener for {@link javax.management.Notification Notifications}.
 * @throws MalformedObjectNameException if an {@code ObjectName} is malformed
 */
public ObjectName[] getResolvedObjectNames() throws MalformedObjectNameException {
	if (this.mappedObjectNames == null) {
		return null;
	}
	ObjectName[] resolved = new ObjectName[this.mappedObjectNames.size()];
	int i = 0;
	for (Object objectName : this.mappedObjectNames) {
		resolved[i] = ObjectNameManager.getInstance(objectName);
		i++;
	}
	return resolved;
}
 
Example 58
Project: Byter   File: JmxEntity.java   Source Code and License 5 votes vote down vote up
/**
 * public constructor with base initialisation.
 * init-style= packageName:type=type
 * @param packageName desired packageName
 * @param type desired type of mbean
 */
public JmxEntity(final String packageName, final String type) {
    try{
        this.objectName = new ObjectName( packageName+":type="+type);
    } catch (MalformedObjectNameException e) {
        log.log(Level.WARNING, "ObjectName is malformed!");
    }
}
 
Example 59
Project: lams   File: KeyNamingStrategy.java   Source Code and License 5 votes vote down vote up
/**
 * Attempts to retrieve the {@code ObjectName} via the given key, trying to
 * find a mapped value in the mappings first.
 */
@Override
public ObjectName getObjectName(Object managedBean, String beanKey) throws MalformedObjectNameException {
	String objectName = null;
	if (this.mergedMappings != null) {
		objectName = this.mergedMappings.getProperty(beanKey);
	}
	if (objectName == null) {
		objectName = beanKey;
	}
	return ObjectNameManager.getInstance(objectName);
}
 
Example 60
Project: monarch   File: AgentImpl.java   Source Code and License 5 votes vote down vote up
/**
 * Constructs a new Agent using the specified configuration.
 *
 * @param agentConfig instance of configuration for Agent
 * @throws org.apache.geode.admin.AdminException TODO-javadocs
 * @throws IllegalArgumentException if agentConfig is null
 */
public AgentImpl(AgentConfigImpl agentConfig) throws AdminException, IllegalArgumentException {
  addShutdownHook();
  if (agentConfig == null) {
    throw new IllegalArgumentException(
        LocalizedStrings.AgentImpl_AGENTCONFIG_MUST_NOT_BE_NULL.toLocalizedString());
  }
  this.agentConfig = (AgentConfigImpl) agentConfig;
  this.mbeanName = MBEAN_NAME_PREFIX + MBeanUtil.makeCompliantMBeanNameProperty("Agent");

  try {
    this.objectName = new ObjectName(this.mbeanName);
  } catch (MalformedObjectNameException ex) {
    String s = LocalizedStrings.AgentImpl_WHILE_CREATING_OBJECTNAME_0
        .toLocalizedString(new Object[] {this.mbeanName});
    throw new AdminException(s, ex);
  }

  this.propertyFile = this.agentConfig.getPropertyFile().getAbsolutePath();

  // bind address only affects how the Agent VM connects to the system...
  // It should be set only once in the agent lifecycle
  this.agentConfig.setBindAddress(getBindAddress());

  // LOG: create LogWriterAppender and LogWriterLogger
  initLogWriter();

  mBeanServer = MBeanUtil.start();

  MBeanUtil.createMBean(this);

  initializeHelperMbean();
}