protected static ObjectName removeObject(MBeanServer pServer, String pSearchCriteria) throws JMException { ObjectName lSearch = ObjectNameConverter.convert(pSearchCriteria); log.debug("removeObject(), search for: " + pSearchCriteria + ", search criteria: " + lSearch); Set lNames = pServer.queryNames(lSearch, null); if (!lNames.isEmpty()) { ObjectName lName = (ObjectName) lNames.iterator().next(); pServer.unregisterMBean(lName); return lName; } return null; }
private static Hashtable reverseProperties( Hashtable pProperties ) { Hashtable lReturn = new Hashtable( pProperties.size() ); Iterator i = pProperties.keySet().iterator(); while( i.hasNext() ) { String lKey = (String) i.next(); String lValue = (String) pProperties.get( lKey ); lKey = convertCharacters( lKey, false ); lValue = convertCharacters( lValue, false ); lReturn.put( lKey, lValue ); } return lReturn; }
/** * Check the keys and values of the properties and convert invalid characters * * @param pDomainName Name of the Domain * @param pProperites Hashtable containing the properties of the Object Name * * @return Created Object Name with the converted keays and values * * @throws javax.management.MalformedObjectNameException If the given Object Name * is not correct **/ public static ObjectName convert( String pDomainName, Hashtable pProperties ) throws MalformedObjectNameException { if( pDomainName == null ) { throw new MalformedObjectNameException( "missing domain" ); } if( pProperties == null || pProperties.size() == 0 ) { throw new MalformedObjectNameException(" null or empty properties" ); } return createObjectName(pDomainName, pProperties, false); }
/** * Takes the properties from the given Object Name and convert * special characters back * * @param pObjectName Given Object Name * * @return Hashtable with the back converted properties in it * and will contain a "*" as key if the given object * name is a property pattern for queries. **/ public static Hashtable getProperties( ObjectName pObjectName ) { Hashtable lReturn = reverseProperties( pObjectName.getKeyPropertyList() ); if( pObjectName.isPropertyPattern() ) { lReturn.put( "*", "*" ); } return lReturn; }
/** * Takes the properties from the given Object Name and convert * special characters back * * @param pObjectName Given Object Name * * @return String with the original Object Name String representation and * when a property pattern Object Name for queries it contains a ",*" * at the end. **/ public static String getString( ObjectName pObjectName ) { String lReturn = pObjectName.getDomain() + ":" + reverseString( pObjectName.getKeyPropertyList() ); if( pObjectName.isPropertyPattern() ) { lReturn = lReturn + ",*"; } return lReturn; }
return createObjectName(domain, ptable, lPattern);
/** * Constructor for the root J2EEDomain object * * @param domainName domain portion to use for the JMX ObjectName * @param j2eeType JSR77 j2ee-type of the resource being created * @param resName Name of the managed resource * @throws InvalidParameterException If the given Domain Name, Type or Name is null */ public J2EEManagedObject(String domainName, String j2eeType, String resName) throws MalformedObjectNameException { log = Logger.getLogger(getClass()); if (domainName == null) { throw new InvalidParameterException("Domain Name must be set"); } Hashtable lProperties = new Hashtable(); lProperties.put(TYPE, j2eeType); lProperties.put(NAME, resName); name = ObjectNameConverter.convert(domainName, lProperties); log.debug("ctor, name: " + name); }
protected static ObjectName removeObject(MBeanServer pServer, String pName, String pSearchCriteria) throws JMException { String lEncryptedName = ObjectNameConverter.convertCharacters(pName, true); ObjectName lSearch = new ObjectName(pSearchCriteria + "," + NAME + "=" + lEncryptedName); log.debug("removeObject(), name: " + pName + ", encrypted name: " + lEncryptedName + ", search criteria: " + lSearch); Set lNames = pServer.queryNames(lSearch, null); if (!lNames.isEmpty()) { ObjectName lName = (ObjectName) lNames.iterator().next(); pServer.unregisterMBean(lName); return lName; } return null; }
return createObjectName(lDomain, pObjectName.substring( lIndex + 1 )); } else { throw new MalformedObjectNameException( "properties missing" );
public ObjectName getJmxName() { ObjectName jmxName = null; String jndiName = ProxyFactoryHelper.getLocalJndiName(this); // The name must be escaped since the jndiName may be arbitrary String name = org.jboss.ejb.Container.BASE_EJB_CONTAINER_NAME + ",jndiName=" + jndiName; try { jmxName = org.jboss.mx.util.ObjectNameConverter.convert(name); } catch (MalformedObjectNameException e) { e.printStackTrace(); throw new RuntimeException("Failed to create ObjectName, msg=" + e.getMessage()); } return jmxName; }
private static String reverseString( Hashtable pProperties ) { StringBuffer lReturn = new StringBuffer(); Iterator i = pProperties.keySet().iterator(); while( i.hasNext() ) { String lKey = (String) i.next(); String lValue = (String) pProperties.get( lKey ); lKey = convertCharacters( lKey, false ); lValue = convertCharacters( lValue, false ); if( lReturn.length() > 0 ) { lReturn.append( "," ); } lReturn.append( lKey ); lReturn.append( "=" ); lReturn.append( lValue ); } return lReturn.toString(); } }
/** * Constructor for any Managed Object except the root J2EEMangement. * * @param j2eeType JSR77 j2ee-type of the resource being created * @param resName name of the resource * @param jsr77ParentName Object Name of the parent of this Managed Object * which must be defined * @throws InvalidParameterException If the given Type, Name or Parent is null */ public J2EEManagedObject(String j2eeType, String resName, ObjectName jsr77ParentName) throws MalformedObjectNameException, InvalidParentException { log = Logger.getLogger(getClass()); Hashtable lProperties = getParentKeys(jsr77ParentName); lProperties.put(TYPE, j2eeType); lProperties.put(NAME, resName); name = ObjectNameConverter.convert(J2EEDomain.getDomainName(), lProperties); setparent(jsr77ParentName.getCanonicalName()); }
String lKey = convertCharacters( key, true ); String lValue = convertCharacters( val, true );
public ObjectName getJmxName() { ObjectName jmxName = null; String jndiName = ProxyFactoryHelper.getLocalJndiName(this); // The name must be escaped since the jndiName may be arbitrary String name = org.jboss.ejb.Container.BASE_EJB_CONTAINER_NAME + ",jndiName=" + jndiName; try { jmxName = org.jboss.mx.util.ObjectNameConverter.convert(name); } catch (MalformedObjectNameException e) { e.printStackTrace(); throw new RuntimeException("Failed to create ObjectName, msg=" + e.getMessage()); } return jmxName; }
try jmxName = ObjectNameConverter.convert(name);