We are using GlassFish 2.1 and have 2 questions about the behavior of the
‘createResource’ method in
‘com.sun.enterprise.admin.mbeans.ResourcesMBean’ class. The source code
can be located at
https://fisheye4.atlassian.com/browse/glassfish-svn/trunk/v2/admin/mbeans/src/java/com/sun/enterprise/admin/mbeans/ResourcesMBean.java
Line# 692 Method name: [php] private ObjectName createResource( String
resourceType, AttributeList attrList, Properties props, String tgtName,
boolean createResourceRefs ) throws Exception { ... ...[/php] The first
question we have is about the following logic which set the disabled
attribute to ‘enabled’ before creating the ‘mbean’ object and restore
it back afterword. Why the attribute must be enabled before creating the
resource? [php] ... ... 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); } ... ... [/php] The second
question is about the following code which creates resource reference the
same method. If the method call
‘getResourceReferenceHelper().createResourceReference()’ fails with
exception, will the resource be displayed on the Admin Console as the
‘mbean’ object has been created successfully in above code? [php] ... ...
// 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; ... ... [/php]
--
[Message sent by forum member 'jasonw401']
View Post: http://forums.java.net/node/801358