本文整理汇总了Java中javax.management.ObjectName.getKeyProperty方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectName.getKeyProperty方法的具体用法?Java ObjectName.getKeyProperty怎么用?Java ObjectName.getKeyProperty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.management.ObjectName
的用法示例。
在下文中一共展示了ObjectName.getKeyProperty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: computeFolders
import javax.management.ObjectName; //导入方法依赖的package包/类
@Override
protected Folder[] computeFolders(DynamicProxy object) throws IntrospectionException {
try {
ObjectName objName = object.getObjectName();
ObjectName pattern = new ObjectName(objName.getDomain() +
":type=" + objName.getKeyProperty("type") + "." + objName.getKeyProperty("name") +
",name=*");
Set<ObjectName> names = object.getMBeanServerConnection().queryNames(pattern, null);
List<Folder> subfolders = new ArrayList<Folder>();
for (ObjectName n : names) {
subfolders.add(new DynamicMBeanToFolderAdapter(
new DynamicProxy(
n,
object.getMBeanServerConnection())));
}
return subfolders.toArray(new Folder[0]);
} catch (Exception ex) {
throw new IntrospectionException(ex);
}
}
示例2: toXml
import javax.management.ObjectName; //导入方法依赖的package包/类
public Element toXml(ObjectName rootOn, Set<ObjectName> childRbeOns, Document document, String instanceIndex,
Element parentElement, String namespace, final EnumResolver enumResolver) {
Element xml = instanceMapping.toXml(rootOn, namespace, document, parentElement, enumResolver);
if (instanceIndex != null) {
xml.setAttribute(KEY_ATTRIBUTE_KEY, instanceIndex);
}
for (Entry<String, InstanceRuntime> childMappingEntry : childrenMappings.entrySet()) {
Set<ObjectName> innerRootBeans = getRootBeans(childRbeOns, childMappingEntry.getKey(),
rootOn.getKeyPropertyList().size());
for (ObjectName objectName : innerRootBeans) {
Set<ObjectName> innerChildRbeOns = findChildren(objectName, childRbeOns);
String runtimeInstanceIndex = objectName.getKeyProperty(childMappingEntry.getKey());
String elementName = jmxToYangChildRbeMapping.get(childMappingEntry.getKey());
Element innerXml = XmlUtil.createElement(document, elementName, Optional.of(namespace));
childMappingEntry.getValue().toXml(objectName, innerChildRbeOns, document, runtimeInstanceIndex,
innerXml, namespace, enumResolver);
xml.appendChild(innerXml);
}
}
return xml;
}
示例3: preRegister
import javax.management.ObjectName; //导入方法依赖的package包/类
public ObjectName preRegister(MBeanServer server,
ObjectName name) throws Exception {
oname=name;
mserver=server;
if (name == null ){
return null;
}
domain=name.getDomain();
type=name.getKeyProperty("type");
if( type==null ) {
type=name.getKeyProperty("j2eeType");
}
String j2eeApp=name.getKeyProperty("J2EEApplication");
String j2eeServer=name.getKeyProperty("J2EEServer");
if( j2eeApp==null ) {
j2eeApp="none";
}
if( j2eeServer==null ) {
j2eeServer="none";
}
suffix=",J2EEApplication=" + j2eeApp + ",J2EEServer=" + j2eeServer;
return name;
}
示例4: registerHost
import javax.management.ObjectName; //导入方法依赖的package包/类
/**
* Register host.
*/
private void registerHost(ObjectName objectName)
throws Exception {
String name=objectName.getKeyProperty("host");
if( name != null ) {
Host host = (Host) ServerFactory.getServer().findService(
domain).getContainer().findChild(name);
String[] aliases = host.findAliases();
mapper.addHost(name, aliases, objectName);
host.addContainerListener(this);
if(log.isDebugEnabled())
log.debug(sm.getString
("mapperListener.registerHost", name, domain));
}
}
示例5: removeHost
import javax.management.ObjectName; //导入方法依赖的package包/类
/**
* Remove an existing Host.
*
* @param name MBean Name of the comonent to remove
*
* @exception Exception if a component cannot be removed
*/
public void removeHost(String name) throws Exception {
// Acquire a reference to the component to be removed
ObjectName oname = new ObjectName(name);
String serviceName = oname.getKeyProperty("service");
String hostName = oname.getKeyProperty("host");
Server server = ServerFactory.getServer();
Service service = server.findService(serviceName);
Engine engine = (Engine) service.getContainer();
Host host = (Host) engine.findChild(hostName);
// Remove this component from its parent component
engine.removeChild(host);
}
示例6: createDefaultContext
import javax.management.ObjectName; //导入方法依赖的package包/类
/**
* Create a new DefaultContext.
*
* @param parent MBean Name of the associated parent component
*
* @exception Exception if an MBean cannot be created or registered
*/
public String createDefaultContext(String parent)
throws Exception {
// Create a new StandardDefaultContext instance
StandardDefaultContext context = new StandardDefaultContext();
// Add the new instance to its parent component
ObjectName pname = new ObjectName(parent);
String type = pname.getKeyProperty("type");
Server server = ServerFactory.getServer();
String serviceName = pname.getKeyProperty("service");
if (serviceName == null) {
serviceName = pname.getKeyProperty("name");
}
Service service = server.findService(serviceName);
Engine engine = (Engine) service.getContainer();
String hostName = pname.getKeyProperty("host");
if (hostName == null) { //if DefaultContext is nested in Engine
context.setParent(engine);
engine.addDefaultContext(context);
} else { // if DefaultContext is nested in Host
Host host = (Host) engine.findChild(hostName);
context.setParent(host);
host.addDefaultContext(context);
}
// Return the corresponding MBean name
ManagedBean managed = registry.findManagedBean("DefaultContext");
ObjectName oname =
MBeanUtils.createObjectName(managed.getDomain(), context);
return (oname.toString());
}
示例7: getObjectName
import javax.management.ObjectName; //导入方法依赖的package包/类
/**
* Creates hierarchical ObjectNames given a parent and name of the MBean.
* Extra elements can be inserted into the path through typeExtra param.
*
* @param parent
* parent's ObjectName
* @param childName
* name of this object, if null no name element will be appended
* @return ObjectName of form: domain=[parent's domain],type=[parent's
* type].[parent's name],name=[name]
* @throws PogamutJMXNameException
*/
public static ObjectName getObjectName(ObjectName parent, String childName) throws PogamutJMXNameException {
NullCheck.check(parent, "parent");
NullCheck.check(childName, "childName");
String parentDomain = parent.getKeyProperty("domain");
String parentType = parent.getKeyProperty("type");
String parentName = parent.getKeyProperty("name");
String childType = parentType + "." + parentName;
return getObjectName(parentDomain, childType, childName);
}
示例8: preRegister
import javax.management.ObjectName; //导入方法依赖的package包/类
public ObjectName preRegister(MBeanServer server, ObjectName oname )
throws Exception
{
ObjectName res=super.preRegister(server, oname);
String name=oname.getKeyProperty("host");
if( name != null )
setName( name );
return res;
}
示例9: removeService
import javax.management.ObjectName; //导入方法依赖的package包/类
/**
* Remove an existing Service.
*
* @param name MBean Name of the component to remove
*
* @exception Exception if a component cannot be removed
*/
public void removeService(String name) throws Exception {
// Acquire a reference to the component to be removed
ObjectName oname = new ObjectName(name);
String serviceName = oname.getKeyProperty("serviceName");
Server server = ServerFactory.getServer();
Service service = server.findService(serviceName);
// Remove this component from its parent component
server.removeService(service);
}
示例10: createObjectName
import javax.management.ObjectName; //导入方法依赖的package包/类
/**
* Creates the ObjectName for the ConnectionPoolMBean object to be registered
* @param original the ObjectName for the DataSource
* @return the ObjectName for the ConnectionPoolMBean
* @throws MalformedObjectNameException
*/
public ObjectName createObjectName(ObjectName original) throws MalformedObjectNameException {
String domain = ConnectionPool.POOL_JMX_DOMAIN;
Hashtable<String,String> properties = original.getKeyPropertyList();
String origDomain = original.getDomain();
properties.put("type", "ConnectionPool");
properties.put("class", this.getClass().getName());
if (original.getKeyProperty("path")!=null || properties.get("context")!=null) {
//this ensures that if the registration came from tomcat, we're not losing
//the unique domain, but putting that into as an engine attribute
properties.put("engine", origDomain);
}
ObjectName name = new ObjectName(domain,properties);
return name;
}
示例11: removeConnector
import javax.management.ObjectName; //导入方法依赖的package包/类
/**
* Remove an existing Connector.
*
* @param name
* MBean Name of the component to remove
*
* @exception Exception
* if a component cannot be removed
*/
public void removeConnector(String name) throws Exception {
// Acquire a reference to the component to be removed
ObjectName oname = new ObjectName(name);
Service service = getService(oname);
String port = oname.getKeyProperty("port");
// String address = oname.getKeyProperty("address");
Connector conns[] = service.findConnectors();
for (int i = 0; i < conns.length; i++) {
String connAddress = String.valueOf(conns[i].getProperty("address"));
String connPort = "" + conns[i].getPort();
// if (((address.equals("null")) &&
if ((connAddress == null) && port.equals(connPort)) {
service.removeConnector(conns[i]);
conns[i].destroy();
break;
}
// } else if (address.equals(connAddress))
if (port.equals(connPort)) {
// Remove this component from its parent component
service.removeConnector(conns[i]);
conns[i].destroy();
break;
}
}
}
示例12: removeValve
import javax.management.ObjectName; //导入方法依赖的package包/类
/**
* Remove an existing Valve.
*
* @param name MBean Name of the comonent to remove
*
* @exception Exception if a component cannot be removed
*/
public void removeValve(String name) throws Exception {
// Acquire a reference to the component to be removed
ObjectName oname = new ObjectName(name);
ContainerBase container = getParentContainerFromChild(oname);
String sequence = oname.getKeyProperty("seq");
Valve[] valves = (Valve[])container.getValves();
for (int i = 0; i < valves.length; i++) {
ObjectName voname = ((ValveBase) valves[i]).getObjectName();
if (voname.equals(oname)) {
container.removeValve(valves[i]);
}
}
}
示例13: removeContext
import javax.management.ObjectName; //导入方法依赖的package包/类
/**
* Remove an existing Context.
*
* @param contextName
* MBean Name of the component to remove
*
* @exception Exception
* if a component cannot be removed
*/
public void removeContext(String contextName) throws Exception {
// Acquire a reference to the component to be removed
ObjectName oname = new ObjectName(contextName);
String domain = oname.getDomain();
StandardService service = (StandardService) getService(oname);
Engine engine = (Engine) service.getContainer();
String name = oname.getKeyProperty("name");
name = name.substring(2);
int i = name.indexOf('/');
String hostName = name.substring(0, i);
String path = name.substring(i);
ObjectName deployer = new ObjectName(domain + ":type=Deployer,host=" + hostName);
String pathStr = getPathStr(path);
if (mserver.isRegistered(deployer)) {
mserver.invoke(deployer, "addServiced", new Object[] { pathStr }, new String[] { "java.lang.String" });
mserver.invoke(deployer, "unmanageApp", new Object[] { pathStr }, new String[] { "java.lang.String" });
mserver.invoke(deployer, "removeServiced", new Object[] { pathStr }, new String[] { "java.lang.String" });
} else {
log.warn("Deployer not found for " + hostName);
Host host = (Host) engine.findChild(hostName);
Context context = (Context) host.findChild(pathStr);
// Remove this component from its parent component
host.removeChild(context);
if (context instanceof StandardContext)
try {
((StandardContext) context).destroy();
} catch (Exception e) {
log.warn("Error during context [" + context.getName() + "] destroy ", e);
}
}
}
示例14: createStandardContext
import javax.management.ObjectName; //导入方法依赖的package包/类
/**
* Create a new StandardContext.
*
* @param parent MBean Name of the associated parent component
* @param path The context path for this Context
* @param docBase Document base directory (or WAR) for this Context
*
* @exception Exception if an MBean cannot be created or registered
*/
public String createStandardContext(String parent,
String path,
String docBase,
boolean xmlValidation,
boolean xmlNamespaceAware,
boolean tldValidation,
boolean tldNamespaceAware)
throws Exception {
// Create a new StandardContext instance
StandardContext context = new StandardContext();
path = getPathStr(path);
context.setPath(path);
context.setDocBase(docBase);
context.setXmlValidation(xmlValidation);
context.setXmlNamespaceAware(xmlNamespaceAware);
context.setTldValidation(tldValidation);
context.setTldNamespaceAware(tldNamespaceAware);
ContextConfig contextConfig = new ContextConfig();
context.addLifecycleListener(contextConfig);
// Add the new instance to its parent component
ObjectName pname = new ObjectName(parent);
ObjectName deployer = new ObjectName(pname.getDomain()+
":type=Deployer,host="+
pname.getKeyProperty("host"));
if(mserver.isRegistered(deployer)) {
String contextName = context.getName();
mserver.invoke(deployer, "addServiced",
new Object [] {contextName},
new String [] {"java.lang.String"});
String configPath = (String)mserver.getAttribute(deployer,
"configBaseName");
String baseName = context.getBaseName();
File configFile = new File(new File(configPath), baseName+".xml");
if (configFile.isFile()) {
context.setConfigFile(configFile.toURI().toURL());
}
mserver.invoke(deployer, "manageApp",
new Object[] {context},
new String[] {"org.apache.catalina.Context"});
mserver.invoke(deployer, "removeServiced",
new Object [] {contextName},
new String [] {"java.lang.String"});
} else {
log.warn("Deployer not found for "+pname.getKeyProperty("host"));
Service service = getService(pname);
Engine engine = (Engine) service.getContainer();
Host host = (Host) engine.findChild(pname.getKeyProperty("host"));
host.addChild(context);
}
// Return the corresponding MBean name
return context.getObjectName().toString();
}
示例15: matchKeys
import javax.management.ObjectName; //导入方法依赖的package包/类
/**
* Return true if the given ObjectName matches the ObjectName pattern
* for which this object has been built.
* WARNING: domain name is not considered here because it is supposed
* not to be wildcard when called. PropertyList is also
* supposed not to be zero-length.
* @param name The ObjectName we want to match against the pattern.
* @return true if <code>name</code> matches the pattern.
**/
public boolean matchKeys(ObjectName name) {
// If key property value pattern but not key property list
// pattern, then the number of key properties must be equal
//
if (isPropertyValuePattern &&
!isPropertyListPattern &&
(name.getKeyPropertyList().size() != keys.length))
return false;
// If key property value pattern or key property list pattern,
// then every property inside pattern should exist in name
//
if (isPropertyValuePattern || isPropertyListPattern) {
for (int i = keys.length - 1; i >= 0 ; i--) {
// Find value in given object name for key at current
// index in receiver
//
String v = name.getKeyProperty(keys[i]);
// Did we find a value for this key ?
//
if (v == null) return false;
// If this property is ok (same key, same value), go to next
//
if (isPropertyValuePattern &&
pattern.isPropertyValuePattern(keys[i])) {
// wildmatch key property values
// values[i] is the pattern;
// v is the string
if (Util.wildmatch(v,values[i]))
continue;
else
return false;
}
if (v.equals(values[i])) continue;
return false;
}
return true;
}
// If no pattern, then canonical names must be equal
//
final String p1 = name.getCanonicalKeyPropertyListString();
final String p2 = properties;
return (p1.equals(p2));
}