FileDocCategorySizeDatePackage
ModelMBeanConstructorInfo.javaAPI DocJava SE 5 API17090Fri Aug 26 14:57:34 BST 2005javax.management.modelmbean

ModelMBeanConstructorInfo

public class ModelMBeanConstructorInfo extends MBeanConstructorInfo implements Cloneable, DescriptorAccess
The ModelMBeanConstructorInfo object describes a constructor of the ModelMBean. It is a subclass of MBeanConstructorInfo with the addition of an associated Descriptor and an implementation of the DescriptorAccess interface.

The fields in the descriptor are defined, but not limited to, the following: 

name : constructor name descriptorType : must be "operation" role : must be "constructor" displayName : human readable name of constructor visibility : 1-4 where 1: always visible 4: rarely visible presentationString : xml formatted string to describe how to present operation

The persistPolicy and currencyTimeLimit fields are not valid for the constructor. The default descriptor will have the name, descriptorType, displayName and role fields.
since
1.5

Fields Summary
private static final long
oldSerialVersionUID
private static final long
newSerialVersionUID
private static final ObjectStreamField[]
oldSerialPersistentFields
private static final ObjectStreamField[]
newSerialPersistentFields
private static final long
serialVersionUID
private static final ObjectStreamField[]
serialPersistentFields
private static boolean
compat
private Descriptor
consDescriptor
private static final String
currClass
Constructors Summary
public ModelMBeanConstructorInfo(String description, Constructor constructorMethod)
Constructs a MBeanConstructorInfo object with a default descriptor.

param
description A human readable description of the constructor.
param
constructorMethod The java.lang.reflect.Method object describing the MBean constructor.



	                          	
	  
					  
    
		super(description, constructorMethod);

		if (tracing())
		{
			trace("ModelMBeanConstructorInfo(String, Method)","Executed");
		}
		consDescriptor = createDefaultDescriptor();

		// put getter and setter methods in constructors list 
		// create default descriptor

	
public ModelMBeanConstructorInfo(String description, Constructor constructorMethod, Descriptor descriptor)
Constructs a MBeanConstructorInfo object.

param
description A human readable description of the constructor.
param
constructorMethod The java.lang.reflect.Method object describing the ModelMBean constructor.
param
descriptor An instance of Descriptor containing the appropriate metadata for this instance of the ModelMBeanConstructorInfo. If it is null, then a default descriptor will be created.If the descriptor does not contain the field "displayName" this fields is added in the descriptor with its default value.
exception
RuntimeOperationsException Wraps an IllegalArgumentException. The descriptor is invalid, or descriptor field "name" is not equal to name parameter, or descriptor field "DescriptorType" is not equal to "operation" or descriptor field "role" is not equal to "constructor".


		super(description, constructorMethod);
		// put getter and setter methods in constructors list
		if (tracing())
		{
			trace("ModelMBeanConstructorInfo(String, Method, Descriptor)","Executed");
		}
		if (descriptor == null)
		{
			if (tracing())
			{
				trace("ModelMBeanConstructorInfo(String, Method, Descriptor)","Descriptor passed in is null, setting descriptor to default values");
			}

			consDescriptor = createDefaultDescriptor();
		} else
		{
			if (isValid(descriptor))
			{
				consDescriptor = (Descriptor) descriptor.clone();
			} else
			{  // exception
			    consDescriptor = createDefaultDescriptor();
			    throw new RuntimeOperationsException(new IllegalArgumentException("Invalid descriptor passed in parameter"), ("Exception occured in ModelMBeanConstructorInfo constructor"));	

			}

		}
	
public ModelMBeanConstructorInfo(String name, String description, MBeanParameterInfo[] signature)
Constructs a ModelMBeanConstructorInfo object with a default descriptor.

param
name The name of the constructor.
param
description A human readable description of the constructor.
param
signature MBeanParameterInfo object array describing the parameters(arguments) of the constructor.


		super(name, description, signature);
		// create default descriptor
		if (tracing())
		{
			trace("ModelMBeanConstructorInfo(String, String, MBeanParameterInfo[])","Executed");
		}
		consDescriptor = createDefaultDescriptor();
	
public ModelMBeanConstructorInfo(String name, String description, MBeanParameterInfo[] signature, Descriptor descriptor)
Constructs a MBeanConstructorInfo object.

param
name The name of the constructor.
param
description A human readable description of the constructor.
param
signature MBeanParameterInfo objects describing the parameters(arguments) of the constructor.
param
descriptor An instance of Descriptor containing the appropriate metadata for this instance of the MBeanConstructorInfo. If it is null then a default descriptor will be created. If the descriptor does not contain the field "displayName" this field is added in the descriptor with its default value.
exception
RuntimeOperationsException Wraps an IllegalArgumentException. The descriptor is invalid, or descriptor field "name" is not equal to name parameter, or descriptor field "DescriptorType" is not equal to "operation" or descriptor field "role" is not equal to "constructor".

		super(name, description, signature);
		if (tracing())
		{
			trace("ModelMBeanConstructorInfo(String, String, MBeanParameterInfo[], Descriptor)","Executed");
		}
		if (descriptor == null)
		{
			if (tracing())
			{
				trace("ModelMBeanConstructorInfo(String, Method, Descriptor)","Descriptor passed in is null, setting descriptor to default values");
			}
			consDescriptor = createDefaultDescriptor();
		} else
		{
			if (isValid(descriptor))
			{
				consDescriptor = (Descriptor) descriptor.clone();
			} else
			{  // exception
				consDescriptor = createDefaultDescriptor();
				throw new RuntimeOperationsException(new IllegalArgumentException("Invalid descriptor passed in parameter"), ("Exception occured in ModelMBeanConstructorInfo constructor"));								

			}
		}
	
ModelMBeanConstructorInfo(ModelMBeanConstructorInfo old)
Constructs a new ModelMBeanConstructorInfo object from this ModelMBeanConstructor Object.

param
old the ModelMBeanConstructorInfo to be duplicated

		super(old.getName(), old.getDescription(), old.getSignature());
		if (tracing())
		{
			trace("ModelMBeanConstructorInfo(ModelMBeanConstructorInfo)","Executed");
		}
		if (old.consDescriptor == null)
		{
			if (tracing())
			{
				trace("ModelMBeanConstructorInfo(String, Method, Descriptor)","Existing descriptor passed in is null, setting new descriptor to default values");
			}
			consDescriptor = createDefaultDescriptor();
		} else
		{
			if (isValid(consDescriptor))
			{
				consDescriptor = (Descriptor) old.consDescriptor.clone();
			} else
			{  // exception
				consDescriptor = createDefaultDescriptor();
				throw new RuntimeOperationsException(new IllegalArgumentException("Invalid descriptor passed in parameter"), ("Exception occured in ModelMBeanConstructorInfo constructor"));	

			}

		}
	
Methods Summary
public java.lang.Objectclone()
Creates and returns a new ModelMBeanConstructorInfo which is a duplicate of this ModelMBeanConstructorInfo.

		if (tracing())
		{
			trace("ModelMBeanConstructorInfo.clone()","Executed");
		}
		return(new ModelMBeanConstructorInfo(this)) ;
	
private javax.management.DescriptorcreateDefaultDescriptor()
Creates default descriptor for constructor as follows: descriptorType=operation,role=constructor, name=this.getName(),displayname=this.getName(),visibility=1

		if (tracing())
		{
			trace("ModelMBeanConstructorInfo.createDefaultDescriptor()","Executed");
		}
		return new DescriptorSupport(new String[] {"descriptorType=operation",
							       "role=constructor",
							       ("name=" + this.getName()),
							       ("displayname=" + this.getName())});
	
public javax.management.DescriptorgetDescriptor()
Returns a copy of the associated Descriptor.

return
Descriptor associated with the ModelMBeanConstructorInfo object.
see
#setDescriptor

		if (tracing())
		{
			trace("ModelMBeanConstructorInfo.getDescriptor()","Executed");
		}
		if (consDescriptor == null)
		{
			consDescriptor = createDefaultDescriptor();
		}
		return((Descriptor)consDescriptor.clone());
	
private booleanisValid(javax.management.Descriptor inDesc)
Tests that the descriptor is valid and adds appropriate default fields not already specified. Field values must be correct for field names. Descriptor must have the same name as the operation,the descriptorType field must be "operation", the role field must be set to "constructor". The following fields will be defaulted if they are not already set: displayName=this.getName()

		boolean results = true;
		String badField="none";
		// if name != this.getName
		// if (descriptorType != operation)
		// look for displayName, persistPolicy, visibility and add in
		if (inDesc == null)
		{
			badField="nullDescriptor";
			results = false;
		}

		else if (!inDesc.isValid())
		{	 // checks for empty descriptors, null,
			// checks for empty name and descriptorType adn valid values for fields.
			badField="invalidDescriptor";
			results = false;
		}

		else
		{
			if (! ((String)inDesc.getFieldValue("name")).equalsIgnoreCase(this.getName()))
			{
				badField="name";
				results = false;
			}
			if (! ((String)inDesc.getFieldValue("descriptorType")).equalsIgnoreCase("operation"))
			{
				badField="descriptorType";
				results = false;
			}
			if (inDesc.getFieldValue("role") == null)
			{
				inDesc.setField("role","constructor");
			}
			if (! ((String)inDesc.getFieldValue("role")).equalsIgnoreCase("constructor"))
			{
				badField = "role";
				results = false;
			} else if ((inDesc.getFieldValue("displayName")) == null)
			{
				inDesc.setField("displayName",this.getName());
			}
		}
		if (tracing()) trace("isValid()",("Returning " + results + ": Invalid field is " + badField));
		return results;
	
private voidreadObject(java.io.ObjectInputStream in)
Deserializes a {@link ModelMBeanConstructorInfo} from an {@link ObjectInputStream}.

      // New serial form ignores extra field "currClass"
      in.defaultReadObject();
    
public voidsetDescriptor(javax.management.Descriptor inDescriptor)
Sets associated Descriptor (full replace) of ModelMBeanConstructorInfo. If the new Descriptor is null, then the associated Descriptor reverts to a default descriptor. The Descriptor is validated before it is assigned. If the new Descriptor is invalid, then a RuntimeOperationsException wrapping an IllegalArgumentException is thrown.

param
inDescriptor replaces the Descriptor associated with the ModelMBeanConstructor. If the descriptor does not contain the field "displayName" this field is added in the descriptor with its default value.
exception
RuntimeOperationsException Wraps an IllegalArgumentException. The descriptor is invalid, or descriptor field "name" is not equal to name parameter, or descriptor field "DescriptorType" is not equal to "operation" or descriptor field "role" is not equal to "constructor".
see
#getDescriptor

		if (tracing())
		{
			trace("ModelMBeanConstructorInfo.setDescriptor()","Executed");
		}
		if (inDescriptor == null)
		{
			if (tracing())
			{
				trace("ModelMBeanConstructorInfo(String, Method, Descriptor)","Descriptor passed in is null, setting descriptor to default values");
			}
			consDescriptor = createDefaultDescriptor();
		} else
		{
			if (isValid(inDescriptor))
			{
				consDescriptor = (Descriptor) inDescriptor.clone();
			} else
			{
			    throw new RuntimeOperationsException(new IllegalArgumentException("Invalid descriptor passed in parameter"), ("Exception occured in ModelMBeanConstructorInfo setDescriptor"));
			}
		}
	
public java.lang.StringtoString()
Returns a string containing the entire contents of the ModelMBeanConstructorInfo in human readable form.

		if (tracing())
		{
			trace("ModelMBeanConstructorInfo.toString()","Executed");
		}
		String retStr =
		    "ModelMBeanConstructorInfo: " + this.getName() +
		    " ; Description: " + this.getDescription() +
		    " ; Descriptor: " + this.getDescriptor() +
		    " ; Signature: ";
		MBeanParameterInfo[] pTypes = this.getSignature();
		for (int i=0; i < pTypes.length; i++)
		{
			retStr = retStr.concat((pTypes[i]).getType() + ", ");
		}
		return retStr;
	
private voidtrace(java.lang.String inClass, java.lang.String inMethod, java.lang.String inText)

		//        System.out.println("TRACE: " + inClass + ":" + inMethod + ": " + inText);
		Trace.send(Trace.LEVEL_TRACE, Trace.INFO_MODELMBEAN, inClass, 
				   inMethod,  Integer.toHexString(this.hashCode()) + " " + inText); 
	
private voidtrace(java.lang.String inMethod, java.lang.String inText)

		trace(currClass, inMethod, inText);
	
private booleantracing()

		//        return false;
		return Trace.isSelected(Trace.LEVEL_TRACE, Trace.INFO_MODELMBEAN);
	
private voidwriteObject(java.io.ObjectOutputStream out)
Serializes a {@link ModelMBeanConstructorInfo} to an {@link ObjectOutputStream}.

      if (compat)
      {
        // Serializes this instance in the old serial form
        //
        ObjectOutputStream.PutField fields = out.putFields();
	fields.put("consDescriptor", consDescriptor);
	fields.put("currClass", currClass);
	out.writeFields();
      }
      else
      {
        // Serializes this instance in the new serial form
        //
        out.defaultWriteObject();
      }