User: squirest
Date: 02/03/08 14:09:20
Modified: src/main/javax/management/modelmbean
ModelMBeanAttributeInfo.java
ModelMBeanNotificationInfo.java
ModelMBeanOperationInfo.java
Log:
stuck in basic implementation of copy constructors
Revision Changes Path
1.3 +27 -25
jmx/src/main/javax/management/modelmbean/ModelMBeanAttributeInfo.java
Index: ModelMBeanAttributeInfo.java
===================================================================
RCS file:
/cvsroot/jboss/jmx/src/main/javax/management/modelmbean/ModelMBeanAttributeInfo.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ModelMBeanAttributeInfo.java 8 Mar 2002 15:28:16 -0000 1.2
+++ ModelMBeanAttributeInfo.java 8 Mar 2002 22:09:20 -0000 1.3
@@ -21,8 +21,8 @@
* @see javax.management.MBeanAttributeInfo
*
* @author <a href="mailto:[EMAIL PROTECTED]">Juha Lindfors</a>.
- * @version $Revision: 1.2 $
- *
+ * @version $Revision: 1.3 $
+ *
*/
public class ModelMBeanAttributeInfo
extends MBeanAttributeInfo
@@ -32,9 +32,9 @@
// Attributes ----------------------------------------------------
/**
* The descriptor associated with this attribute.
- */
+ */
private Descriptor descriptor = null;
-
+
// Constructors --------------------------------------------------
/**
* Creates a new attribute info with a default descriptor.
@@ -68,13 +68,13 @@
throws IntrospectionException
{
this(name, description, getter, setter);
-
+
if (descriptor == null || !descriptor.isValid())
setDescriptor(createDefaultDescriptor());
else
setDescriptor(descriptor);
}
-
+
/**
* Creates a new attribute info object with a default descriptor.
*
@@ -91,15 +91,15 @@
// JPL: As far as I can tell, the isIs boolean has no use in the Model MBean
// attribute info (since attributes will map to methods through
operations)
// I'm setting this boolean to false, until someone complains.
-
+
super(name, type, description, isReadable, isWritable, false /*isIs*/);
setDescriptor(createDefaultDescriptor());
-
+
if (isIs == true)
// FIXME: log this
System.out.println("WARNING: supplied isIS=true, set to false");
}
-
+
/**
* Creates a new attribute info object with a given descriptor. If a
<tt>null</tt> or invalid
* descriptor is passed as a parameter, a default descriptor will be created for
the attribute.
@@ -118,7 +118,7 @@
// attribute info (since attributes will map to methods through
operations)
// I'm setting this boolean to false, until someone complains.
super(name, type, description, isReadable, isWritable, false/*isIs*/);
-
+
if (descriptor == null || !descriptor.isValid())
setDescriptor(createDefaultDescriptor());
else
@@ -128,19 +128,21 @@
// FIXME: log this
System.out.println("WARNING: supplied isIS=true, set to false");
}
-
+
/**
* Copy constructor.
*
* @param inInfo the attribute info to copy
*/
- public ModelMBeanAttributeInfo(ModelMBeanAttributeInfo inInfo)
+ public ModelMBeanAttributeInfo(ModelMBeanAttributeInfo info)
{
- super("", "", "", false, false, false);
- // FIXME: NYI
- throw new Error("NYI");
+ // THS - javadoc says a default descriptor will be created but that's not
+ // consistent with the other *Info classes.
+ // I'm also assuming that getDescriptor returns a clone.
+ this(info.getName(), info.getType(), info.getDescription(), info.isReadable(),
+ info.isWritable(), info.isIs(), info.getDescriptor());
}
-
+
// DescriptorAccess implementation -------------------------------
/**
* Returns a copy of the descriptor associated with this attribute.
@@ -149,21 +151,21 @@
*/
public Descriptor getDescriptor()
{
- return (Descriptor)descriptor.clone();
+ return (Descriptor)descriptor.clone();
}
-
+
public void setDescriptor(Descriptor inDescriptor)
{
if (inDescriptor == null)
inDescriptor = createDefaultDescriptor();
-
+
if (!inDescriptor.isValid())
// FIXME: give more detailed error
throw new IllegalArgumentException("Invalid descriptor.");
-
+
this.descriptor = inDescriptor;
}
-
+
// Cloneable implementation --------------------------------------
/**
* Creates a copy of this object.
@@ -175,10 +177,10 @@
{
ModelMBeanAttributeInfo clone = (ModelMBeanAttributeInfo)super.clone();
clone.descriptor = (Descriptor)this.descriptor.clone();
-
+
return clone;
}
-
+
// Object override -----------------------------------------------
public String toString()
{
@@ -192,9 +194,9 @@
DescriptorSupport descr = new DescriptorSupport();
descr.setField(ModelMBeanConstants.NAME, super.getName());
descr.setField(ModelMBeanConstants.DESCRIPTOR_TYPE,
ModelMBeanConstants.ATTRIBUTE_DESCRIPTOR);
-
+
// FIXME: check the spec for all required descriptor fields!
-
+
return descr;
}
1.3 +3 -5
jmx/src/main/javax/management/modelmbean/ModelMBeanNotificationInfo.java
Index: ModelMBeanNotificationInfo.java
===================================================================
RCS file:
/cvsroot/jboss/jmx/src/main/javax/management/modelmbean/ModelMBeanNotificationInfo.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- ModelMBeanNotificationInfo.java 8 Mar 2002 17:04:42 -0000 1.2
+++ ModelMBeanNotificationInfo.java 8 Mar 2002 22:09:20 -0000 1.3
@@ -18,7 +18,7 @@
* @see javax.management.modelmbean.ModelMBeanAttributeInfo
*
* @author <a href="mailto:[EMAIL PROTECTED]">Juha Lindfors</a>.
- * @version $Revision: 1.2 $
+ * @version $Revision: 1.3 $
*/
public class ModelMBeanNotificationInfo
extends MBeanNotificationInfo
@@ -48,11 +48,9 @@
setDescriptor(descriptor);
}
- public ModelMBeanNotificationInfo(ModelMBeanNotificationInfo inInfo)
+ public ModelMBeanNotificationInfo(ModelMBeanNotificationInfo info)
{
- super(null, "", "");
- // FIXME: why do we need a copy constructor if we implement Cloneable? This
ain't C++.
- throw new Error("NYI");
+ this(info.getNotifTypes(), info.getName(), info.getDescription(),
info.getDescriptor());
}
// Public --------------------------------------------------------
1.5 +17 -18
jmx/src/main/javax/management/modelmbean/ModelMBeanOperationInfo.java
Index: ModelMBeanOperationInfo.java
===================================================================
RCS file:
/cvsroot/jboss/jmx/src/main/javax/management/modelmbean/ModelMBeanOperationInfo.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- ModelMBeanOperationInfo.java 8 Mar 2002 15:36:27 -0000 1.4
+++ ModelMBeanOperationInfo.java 8 Mar 2002 22:09:20 -0000 1.5
@@ -22,15 +22,15 @@
* @see javax.management.modelmbean.ModelMBeanInfoSupport
*
* @author <a href="mailto:[EMAIL PROTECTED]">Juha Lindfors</a>.
- * @version $Revision: 1.4 $
+ * @version $Revision: 1.5 $
*/
public class ModelMBeanOperationInfo
extends MBeanOperationInfo
implements DescriptorAccess, Cloneable
{
-
+
// Attributes ----------------------------------------------------
-
+
/**
* The descriptor associated with this operation.
*/
@@ -49,7 +49,7 @@
super(description, operationMethod);
setDescriptor(createDefaultDescriptor());
}
-
+
/**
* Creates a new operation info with a given descriptor. If a <tt>null</tt> or
* invalid descriptor is passed as a paramter, a default descriptor will be
created
@@ -63,7 +63,7 @@
public ModelMBeanOperationInfo(String description, Method operationMethod,
Descriptor descriptor)
{
this(description, operationMethod);
-
+
if (descriptor == null || !descriptor.isValid())
setDescriptor(createDefaultDescriptor());
else
@@ -77,7 +77,7 @@
* @param description human readable description string
* @param signature operation signature
* @param type a fully qualified name of the operations return type
- * @param impact operation impact: {@link #INFO INFO}, {@link #ACTION ACTION},
{@link #ACTION_INFO ACTION_INFO}, {@link #UNKNOWN UNKNOWN}
+ * @param impact operation impact: {@link #INFO INFO}, {@link #ACTION ACTION},
{@link #ACTION_INFO ACTION_INFO}, {@link #UNKNOWN UNKNOWN}
*/
public ModelMBeanOperationInfo(String name, String description,
MBeanParameterInfo[] signature,
String type, int impact)
@@ -94,14 +94,14 @@
* @param description human readable description string
* @param signature operation signature
* @param type a fully qualified name of the oeprations return type
- * @param impact operation impact: {@link #INFO INFO}, {@link #ACTION ACTION},
{@link #ACTION_INFO ACTION_INFO}, {@link #UNKNOWN UNKNOWN}
+ * @param impact operation impact: {@link #INFO INFO}, {@link #ACTION ACTION},
{@link #ACTION_INFO ACTION_INFO}, {@link #UNKNOWN UNKNOWN}
* @param descriptor a descriptor to associate with this operation
*/
public ModelMBeanOperationInfo(String name, String description,
MBeanParameterInfo[] signature,
String type, int impact, Descriptor descriptor)
{
this(name, description, signature, type, impact);
-
+
if (descriptor == null || !descriptor.isValid())
setDescriptor(createDefaultDescriptor());
else
@@ -113,15 +113,14 @@
*
* @param inInfo the operation info to copy
*/
- public ModelMBeanOperationInfo(ModelMBeanOperationInfo inInfo)
+ public ModelMBeanOperationInfo(ModelMBeanOperationInfo info)
{
- // FIXME: NYI
- super("", "", null, "", 0);
- throw new Error("NYI");
+ this(info.getName(), info.getDescription(), info.getSignature(),
+ info.getReturnType(), info.getImpact(), info.getDescriptor());
}
// DescriptorAccess implementation -------------------------------
-
+
/**
* Returns a copy of the descriptor associated with this operation.
*
@@ -144,11 +143,11 @@
{
if (inDescriptor == null)
inDescriptor = createDefaultDescriptor();
-
+
if (!inDescriptor.isValid())
// FIXME: give more detailed error
throw new IllegalArgumentException("Invalid descriptor.");
-
+
this.descriptor = inDescriptor;
}
@@ -163,7 +162,7 @@
{
ModelMBeanOperationInfo clone = (ModelMBeanOperationInfo)super.clone();
clone.descriptor = (Descriptor)this.descriptor.clone();
-
+
return clone;
}
@@ -180,9 +179,9 @@
DescriptorSupport descr = new DescriptorSupport();
descr.setField(ModelMBeanConstants.NAME, super.getName());
descr.setField(ModelMBeanConstants.DESCRIPTOR_TYPE,
ModelMBeanConstants.OPERATION_DESCRIPTOR);
-
+
// FIXME: check the spec for all required descriptor fields!
-
+
return descr;
}
}
_______________________________________________
Jboss-development mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/jboss-development