validateCnctorConnPoolAttrList(attrList);
ObjectName mbean = null;
final Target target = TargetBuilder.INSTANCE.createTarget(
VALID_CREATE_DELETE_TYPES,
tgtName, getConfigContext()); // This method call fails as getConfigContext is returning null.
boolean hasReferences = isResourceReferenceValid(resourceType, target.getType());
boolean enabled = true;
String resName = getResourceName(resourceType, attrList);
int idxEnabled = -1;
if (attrList != null)
{
for(int i=0; i<attrList.size(); i++)
{
Attribute attr = (Attribute)attrList.get(i);
if (attr.getName().equals("enabled"))
{
enabled = Boolean.valueOf(attr.getValue().toString()).booleanValue();
idxEnabled = i;
}
}
}
Attribute saveEnabledAtttr = null;
if(!enabled && hasReferences)
{ //change original "enabled" value to true
saveEnabledAtttr = (Attribute)attrList.get(idxEnabled);
attrList.set(idxEnabled, new Attribute("enabled", "true"));
}
mbean = (ObjectName)super.invoke( "create" + ConfigMBeanHelper.convertTagName(resourceType),
new Object[] {attrList},
new String[] {AttributeList.class.getName()});
if(!enabled && hasReferences)
{ //restore original enabled value
attrList.set(idxEnabled, saveEnabledAtttr);
}
// Add properties
if (props != null)
{
setProperties(mbean, props);
}
/*
No need to create resource-ref if
- resource is a jdbc-connection-pool or connector-connection-pool
or resource-adapter-config
- target is domain
*/
if (!hasReferences)
{
return mbean;
}
// If target is server or cluster, resource-ref should also be
// created inside server or group/cluster element
if (target.getType() == TargetType.SERVER ||
target.getType() == TargetType.CLUSTER ||
target.getType() == TargetType.DAS)
{
if ( (resName != null) && !(resName.equals("")) && createResourceRefs )
{
//System.out.println("ResourcesMBean - default creation of resource refs "+ target.getName() + " " + resName);
getResourceReferenceHelper().createResourceReference(
target.getName(), enabled, resName);
}
}
return mbean;
}