Methods Summary |
---|
protected void | checkLegalOptions(java.util.Map options)
if ( options != null )
{
final Set<String> legalKeys = getLegalOptionalCreateKeys();
if ( legalKeys != null )
{
debug( "Legal optional keys: " + stringify( legalKeys ) );
}
if ( legalKeys != null )
{
// remove all legal Attribute keys
final Map<String,String> remaining = new HashMap<String,String>( options );
remaining.keySet().removeAll( legalKeys );
final HashMap<String,String> illegal = new HashMap<String,String>();
// find all non-properties; these are illegal
final Iterator iter = remaining.keySet().iterator();
while ( iter.hasNext() )
{
final String key = (String)iter.next();
if ( ! key.startsWith( PropertiesAccess.PROPERTY_PREFIX ) )
{
illegal.put( key, remaining.get( key ) );
}
}
if ( illegal.size() != 0 )
{
final String msg = "Illegal optional keys: " +
MapUtil.toString( illegal, ",");
debug( msg );
throw new IllegalArgumentException( msg );
}
}
}
else
{
// no options, so they're legal!
}
|
protected void | checkNonEmptyString(java.lang.String s, java.lang.String name)
if ( s == null || s.length() == 0 )
{
throw new IllegalArgumentException( "Parameter may not be null or empty: " +
quote( name ) );
}
|
protected final javax.management.ObjectName | createChild(java.util.Map params)
return( createNamedChild( null, params ) );
|
protected final javax.management.ObjectName | createChildByType(java.lang.String childJ2EEType, java.util.Map params)
//assert getChildInfos().contains (childJ2EEType) :
//childJ2EEType + " is not a valid child of " + getSelfJ2EEType ();
final String oldType = getOldTypeToJ2EETypeMapper().j2eeTypeToOldType( childJ2EEType );
assert oldType != null;
final Properties props = new Properties();
final AttributeList attrs = new AttributeList();
translateParams( params, attrs, props );
ObjectName oldObjectName = null;
boolean propertiesHandled = false;
if ( findAnyMethod( "createOldChildByType", TYPE_AND_ATTRS_AND_PROPS_SIG ) != null )
{
oldObjectName = createOldChildByType( oldType, attrs, props );
propertiesHandled = true;
}
else if ( findAnyMethod( "createOldChildByType", TYPE_AND_ATTRS_SIG ) != null )
{
oldObjectName = createOldChildByType( oldType, attrs );
}
else if ( findAnyMethod( "createOldChildByType", ATTRS_ONLY_SIG ) != null )
{
oldObjectName = createOldChildConfig( attrs );
}
else
{
throw new UnsupportedOperationException( "createOldChildByType" );
}
assert( oldObjectName != null );
debug( "createChildByType: oldObjectName: " + StringUtil.quote( oldObjectName.toString() ) );
// need the new AMX name to set properties
final ObjectName amxName = getCallbacks().getLoader().sync( oldObjectName );
debug( "createChildByType: amx object name: " + StringUtil.quote( amxName.toString() ) );
if ( props.size() > 0 && !propertiesHandled )
{
setAllProperties( amxName, props );
}
getCallbacks().sendConfigCreatedNotification( amxName );
return( amxName );
|
protected final javax.management.ObjectName | createNamedChild(java.lang.String name, java.util.Map params)Create an "old" child MBean of the specified name using the specified parameters,
and then create a corresponding AMX MBean.
The parameters need not include the name; it will be added.
The parameters are first translated to an AttributeList and Properties. See
translateParams() for details.
debug( "createNamedChild: " + name + ":\n{\n" + stringify( params ) + "\n}");
final AttributeList attrs = new AttributeList();
final Properties props = new Properties();
translateParams( params, attrs, props );
debug( "createNamedChild: translated attrs:\n{\n" + stringify( attrs ) + "\n}");
if ( props.keySet().size() != 0 )
{
debug( "createNamedChild: translated props:\n" + stringify( props ) );
}
ObjectName oldObjectName = null;
boolean propertiesHandled = false;
if ( findAnyMethod( "createOldChildConfig", ATTRS_AND_PROPS_SIG ) != null )
{
debug( "createNamedChild: calling createOldChildConfig using attrs\n" +
stringify( attrs ) + "\nand props \n" + stringify( props ) );
oldObjectName = createOldChildConfig( attrs, props );
propertiesHandled = true;
}
else if ( findAnyMethod( "createOldChildConfig", ATTRS_ONLY_SIG ) != null )
{
debug( "createNamedChild: calling createOldChildConfig using attrs\n" +
stringify( attrs ));
oldObjectName = createOldChildConfig( attrs );
}
else
{
throw new UnsupportedOperationException( "createOldChildConfig" );
}
return finish( oldObjectName, propertiesHandled ? null : props );
|
protected javax.management.ObjectName | createOldChildByType(java.lang.String oldChildType, javax.management.AttributeList translatedAttrs)Given a set of translated Attributes, create the appropriate type of child
and return its "old" config ObjectName
throw new UnsupportedOperationException( "createOldChildByType( String, AttributeList )" );
|
protected javax.management.ObjectName | createOldChildByType(java.lang.String oldChildType, javax.management.AttributeList translatedAttrs, java.util.Properties props)Given a set of translated Attributes, create the appropriate type of child
and return its "old" config ObjectName
throw new UnsupportedOperationException( "createOldChildByType( String, AttributeList, Properties )" );
|
protected javax.management.ObjectName | createOldChildConfig(javax.management.AttributeList translatedAttrs)Given a set of translated Attributes, create the appropriate type of child
and return its "old" config ObjectName
throw new UnsupportedOperationException( "createOldChildConfig( AttributeList )" );
|
protected javax.management.ObjectName | createOldChildConfig(javax.management.AttributeList translatedAttrs, java.util.Properties props)Given a set of translated Attributes, create the appropriate type of child
and return its "old" config ObjectName
throw new UnsupportedOperationException( "createOldChildConfig( AttributeList, Properties)" );
|
protected final void | debug(java.lang.Object o)
mDebug.println( o );
|
protected final java.lang.reflect.Method | findAnyMethod(java.lang.String methodName, java.lang.Class[] sig)
Method m = null;
try
{
m = this.getClass().getDeclaredMethod( methodName, sig );
}
catch( NoSuchMethodException e )
{
// ok, doesn't exist
}
return( m );
|
protected final javax.management.ObjectName | finish(javax.management.ObjectName oldObjectName, java.util.Properties props)
assert( oldObjectName != null );
debug( "createNamedChild: created: " + StringUtil.quote( oldObjectName.toString() ) );
if ( ! getMBeanServer().isRegistered( oldObjectName ) )
{
throw new RuntimeException( new InstanceNotFoundException( oldObjectName.toString() ) );
}
// need the new AMX name to set properties
final ObjectName amxName = getCallbacks().getLoader().sync( oldObjectName );
debug( "createNamedChild: amx object name: " + StringUtil.quote( amxName.toString() ) );
if ( props != null && props.size() > 0)
{
debug( "Setting properties: " + stringify( props ) );
setAllProperties( amxName, props );
}
// ensure that all sub-elements are also present
getCallbacks().getLoader().waitAll();
getCallbacks().sendConfigCreatedNotification( amxName );
return( amxName );
|
protected final java.lang.Boolean | getBoolean(java.util.Map m, java.lang.String key, java.lang.Boolean defaultValue)
final Object value = getValue( m, key );
return (value == null) ? defaultValue : Boolean.valueOf( "" + value );
|
protected boolean | getBooleanOption(java.util.Map m, java.lang.String key)
boolean value = false;
final Object obj = (m == null) ? null : m.get( key );
if ( obj != null )
{
if ( obj instanceof Boolean )
{
value = ((Boolean)obj).booleanValue();
}
else if ( obj instanceof String )
{
value = Boolean.valueOf( (String)obj ).booleanValue();
}
else
{
throw new IllegalArgumentException( "Illegal value for Boolean " + key );
}
}
return( value );
|
protected final ConfigFactoryCallback | getCallbacks()
return( mCallbacks );
|
protected final java.lang.String | getConfigName()
return( getCallbacks().getConfigName() );
|
protected final java.lang.String | getContainerName()
final String name = getFactoryContainer().getName();
if ( name == null )
{
throw new IllegalArgumentException();
}
return name;
|
protected final com.sun.appserv.management.config.DomainConfig | getDomainConfig()
return( getDomainRoot().getDomainConfig() );
|
protected final com.sun.appserv.management.DomainRoot | getDomainRoot()
return( getCallbacks().getDomainRoot() );
|
protected final com.sun.appserv.management.base.Container | getFactoryContainer()
return( getCallbacks().getFactoryContainer() );
|
protected java.util.Set | getLegalOptionalCreateKeys()By default, assume there are no optional keys.
return( NO_OPTIONAL_KEYS );
|
protected final java.util.logging.Logger | getLogger()
return( getCallbacks().getLogger() );
|
protected final javax.management.MBeanServer | getMBeanServer()
return getCallbacks().getMBeanServer();
|
protected final com.sun.enterprise.management.support.oldconfig.OldConfigProxies | getOldConfigProxies()
return( getCallbacks().getOldConfigProxies() );
|
final com.sun.enterprise.management.support.oldconfig.OldResourcesMBean | getOldResourcesMBean()
return( getOldConfigProxies().getOldResourcesMBean( ) );
|
protected com.sun.enterprise.management.support.OldTypeToJ2EETypeMapper | getOldTypeToJ2EETypeMapper()
return OldConfigTypes.getInstance();
|
protected synchronized com.sun.enterprise.management.support.ParamNameMapper | getParamNameMapper()
if ( mParamNameMapper == null )
{
mParamNameMapper =
new ParamNameMapper( getParamNameOverrides() );
}
return( mParamNameMapper );
|
protected java.util.Map | getParamNameOverrides()Get the names of parameters that don't map via the default algorithms.
// none, by default
return( Collections.emptyMap() );
|
protected final com.sun.appserv.management.base.QueryMgr | getQueryMgr()
return( getDomainRoot().getQueryMgr() );
|
protected final java.lang.String | getString(java.util.Map m, java.lang.String key)
return (String)getValue( m, key );
|
protected final java.lang.Object | getValue(java.util.Map m, java.lang.String key)
return (m == null) ? null : m.get( key );
|
protected final java.util.Map | initParams(java.lang.String name, java.lang.String[] required, java.util.Map optional)Initialize a Map of parameters consisting of attributes and properties.
First the optional parameters are inserted.
Then the name/value pairs in the Object[] are added, possibly overwriting any
values that were redundantly specified in the optional map.
checkLegalOptions( optional );
final Map<String,String> m = initParams( required, optional );
if ( name == null || name.length() == 0 )
{
throw new IllegalArgumentException( "Illegal to have null or empty name" );
}
m.put( CONFIG_NAME_KEY, name );
return( m );
|
protected final java.util.Map | initParams(java.lang.String[] required, java.util.Map optionalIn)Initalize parameters, no name supplied.
// guarantee that all arguments are Strings;
// clients can be using old version of the interfaces and/or non-generic
// versions of Map
final Map<String,String> optional = MapUtil.toStringStringMap( optionalIn );
final Map<String,String> m = new HashMap<String,String>();
if ( optional != null )
{
m.putAll( optional );
m.remove( CommonConfigKeys.IGNORE_MISSING_REFERENCES_KEY );
}
if ( required != null )
{
m.putAll( MapUtil.newMap( required ) );
}
validateParams( m );
return( m );
|
protected final java.util.Map | initParams(java.util.Map optional)Initalize parameters, no name supplied.
return( initParams( (String[])null, optional ) );
|
protected void | internalRemove(javax.management.ObjectName objectName)
removeByName( Util.getName( objectName ) );
|
protected com.sun.enterprise.management.config.ConfigFactory$WaitForUnregistrationListener | newWaitForUnregistrationListener(javax.management.ObjectName objectName)
WaitForUnregistrationListener listener = null;
try
{
final String name =
"WaitForUnregistrationListener for " + JMXUtil.toString(objectName);
listener = new WaitForUnregistrationListener( name, objectName );
listener.startListening();
return listener;
}
catch( Exception e )
{
throw new RuntimeException( e );
}
|
protected static void | putNonNull(java.util.Map m, java.lang.String key, java.lang.Object value)
if ( value != null )
{
m.put( key, "" + value );
}
|
protected static java.lang.String | quote(java.lang.Object o)
return( StringUtil.quote( o.toString() ) );
|
protected final void | remove()
throw new RuntimeException( "form 'remove()' no longer supported" );
|
public final void | remove(javax.management.ObjectName objectName)Remove the config represented by the AMX MBean with the
specified ObjectName.
if ( objectName == null )
{
throw new RuntimeException( new InstanceNotFoundException() );
}
final WaitForUnregistrationListener l =
newWaitForUnregistrationListener( objectName );
internalRemove( objectName );
// do not return to caller until the MBean actually is unregistered!
l.waitForUnregistration();
getCallbacks().sendConfigRemovedNotification( objectName );
|
protected void | removeByName(java.lang.String name)
throw new UnsupportedOperationException( "removeByNameInternal" );
|
protected com.sun.appserv.management.base.AMX | requireItem(java.lang.String j2eeType, java.lang.String name)
final AMX item = getFactoryContainer().getContainee( j2eeType, name );
if ( item == null )
{
throw new IllegalArgumentException( j2eeType + "=" + name );
}
return item;
|
protected boolean | requireValidReferences(java.util.Map options)
return ! getBooleanOption( options, CommonConfigKeys.IGNORE_MISSING_REFERENCES_KEY );
|
protected final void | setAllProperties(javax.management.ObjectName amxObjectName, java.util.Properties props)
final PropertiesAccess proxy = PropertiesAccess.class.cast(
getCallbacks().getProxyFactory().getProxy( amxObjectName, AMX.class) );
setAllProperties( proxy, props );
|
protected final void | setAllProperties(com.sun.appserv.management.config.PropertiesAccess target, java.util.Properties props)For each property in props , call setPropertyValue()
final Iterator iter = props.keySet().iterator();
while ( iter.hasNext() )
{
final String key = (String)iter.next();
target.setPropertyValue( key, (String)props.get( key ) );
}
|
protected boolean | sleepMillis(long millis)
boolean interrupted = false;
try
{
Thread.sleep( millis );
}
catch( InterruptedException e )
{
Thread.interrupted();
interrupted = true;
}
return interrupted;
|
protected java.lang.String | stringify(java.lang.Object o)
return( SmartStringifier.toString( o ) );
|
protected javax.management.ObjectName | syncNewAMXMBeanWithOld(javax.management.ObjectName oldObjectName)
final ObjectName amxName = getCallbacks().getLoader().sync( oldObjectName );
getCallbacks().sendConfigCreatedNotification( amxName );
return amxName;
|
protected final void | trace(java.lang.Object o)
debug( o );
|
protected final void | translateParams(java.util.Map paramsToTranslate, javax.management.AttributeList attrsOut, java.util.Properties propsOut)Translate the Map of parameters to Attributes and Properties. AttibuteNames
are mapped to the underlying names. Property names are not mapped, but the
PROPERTY_PREFIX is stripped.
final ParamNameMapper mapper = getParamNameMapper();
final Iterator iter = paramsToTranslate.keySet().iterator();
final String propertyPrefix = PropertiesAccess.PROPERTY_PREFIX;
while( iter.hasNext() )
{
final String key = (String)iter.next();
final Object value = paramsToTranslate.get( key );
if ( key.startsWith( propertyPrefix ) )
{
final String name =
key.substring( propertyPrefix.length(), key.length() );
propsOut.put( name, value );
}
else
{
final String translatedName = mapper.mangleAttributeName( key );
final Attribute attr = new Attribute( translatedName, value );
attrsOut.add( attr );
}
}
|
protected final void | validateParam(java.lang.String name, java.lang.Object value)Validate a parameter to a create() or createAbc() method.
Subclasses should verify that the parameter name is legal,
and optionally validate its value as well.
if ( name == null || name.length() == 0 )
{
throw new IllegalArgumentException( "parameter name must be non-null and non-empty" );
}
if ( name.startsWith( PropertiesAccess.PROPERTY_PREFIX ) )
{
if ( ! (value instanceof String) )
{
throw new IllegalArgumentException( "Property value must be string: " +
name + ", class =" + value.getClass().getName() );
}
}
|
protected final void | validateParams(java.util.Map params)Validate parameters. The params Map contains all parameters, including
Attributes and properties as
for( final String name : params.keySet() )
{
final Object value = params.get( name );
validateParam( name, value );
}
|