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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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   View source code 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();
}