org.apache.qpid.management.wsdm.capabilities
Class MBeanCapabilityBuilder

java.lang.Object
  extended by org.apache.qpid.management.wsdm.capabilities.MBeanCapabilityBuilder
All Implemented Interfaces:
IArtifactBuilder

public class MBeanCapabilityBuilder
extends Object
implements IArtifactBuilder

Builder for capability class that will implements the interface and the behaviour of the underlying JMX Entity. The product of this builder (capability class) will be used for create a new instance of the corresponding capability. It will be the "adapter" between WS-Resource and JMX MBean.


Nested Class Summary
(package private) static interface MBeanCapabilityBuilder.EndAttributesHandler
          Handler interface definining operation needed to be peformed (by a concrete implementor) when the "endAttributes" director callback happens.
 
Field Summary
(package private)  MBeanCapabilityBuilder.EndAttributesHandler _atLeastThereIsOneProperty
          This is the concrete implementation of the internal interface EndAttributesHandler that is activated when this builder detects the presence of at least one property on the capability class.
(package private)  javassist.CtClass _capabilityClassDefinition
           
(package private)  IArtifactBuilder _classNotAvailable
          This is the active state for this builder when the requested class has never been built.
(package private)  MBeanCapabilityBuilder.EndAttributesHandler _endAttributeHandler
           
(package private)  MBeanCapabilityBuilder.EndAttributesHandler _noPropertyHasBeenDefined
          This is the concrete implementation of the internal interface EndAttributesHandler that is activated when this builder detects that there are no properties defined for the capability class.
(package private)  StringBuilder _properties
           
(package private)  IArtifactBuilder _state
           
 
Constructor Summary
MBeanCapabilityBuilder()
           
 
Method Summary
 void begin(ObjectName objectName)
          First callback : this method is called at the begin of the director process.
 void endAttributes()
          Determines what needs to be done when all attributes metadata has been notified to this builder.
 void endOperations()
          Director callback.
(package private)  String generateGetter(String type, String name, String plainName)
          Generates the get accessor method for the given property.
(package private)  String generateSetter(String type, String name, String plainName)
          Generates the set accessor method for the given property.
(package private)  Class<MBeanCapability> getCapabilityClass()
          Returns the capability class (the product of this builder).
(package private)  String getNameForAccessors(String name)
          Returns a name that will be used in accessor methods.
 void onAttribute(MBeanAttributeInfo attribute)
          Director callback.
 void onOperation(MBeanOperationInfo operation)
          Director callback.
 void setEnvironment(org.apache.muse.core.Environment environment)
          Injects the module environment on this builder.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

_atLeastThereIsOneProperty

final MBeanCapabilityBuilder.EndAttributesHandler _atLeastThereIsOneProperty
This is the concrete implementation of the internal interface EndAttributesHandler that is activated when this builder detects the presence of at least one property on the capability class.


_noPropertyHasBeenDefined

final MBeanCapabilityBuilder.EndAttributesHandler _noPropertyHasBeenDefined
This is the concrete implementation of the internal interface EndAttributesHandler that is activated when this builder detects that there are no properties defined for the capability class.


_classNotAvailable

IArtifactBuilder _classNotAvailable
This is the active state for this builder when the requested class has never been built.


_properties

StringBuilder _properties

_capabilityClassDefinition

javassist.CtClass _capabilityClassDefinition

_endAttributeHandler

MBeanCapabilityBuilder.EndAttributesHandler _endAttributeHandler

_state

IArtifactBuilder _state
Constructor Detail

MBeanCapabilityBuilder

public MBeanCapabilityBuilder()
Method Detail

onAttribute

public void onAttribute(MBeanAttributeInfo attribute)
                 throws BuilderException
Director callback. Attrbute metadata notification. With this callback the director informs this builder that the currently processed MBean has an attribute with the given metadata. This builder uses this information in order to add a property and the corresponding accessors to the capability class that is going to be built.

Specified by:
onAttribute in interface IArtifactBuilder
Parameters:
attribute - the attribute metadata.
Throws:
BuilderException - bytecode manipulation / creation failure.

begin

public void begin(ObjectName objectName)
           throws BuilderException
First callback : this method is called at the begin of the director process. Contains builder initialization code.

Specified by:
begin in interface IArtifactBuilder
Parameters:
objectName - the name of the target JMX entity of this capability.
Throws:
BuilderException - when the initialization fails.

onOperation

public void onOperation(MBeanOperationInfo operation)
                 throws BuilderException
Director callback. Operation metadata notification. With this callback the director informs this builder that the currently processed MBean has an operation with the given metadata. This builder uses this information in order to add a method to the capability class that is going to be built. For example, let's suppose that an operation like that is detected on the MBean : public void purge(int request) then the capability will be enrichied with the following method : public void purge(int request) throws QManFault { invoke( "purge", new Object[]{request}, new String[]{int.class.getName()}); }

Specified by:
onOperation in interface IArtifactBuilder
Parameters:
operation - the operation metadata.
Throws:
BuilderException - bytecode manipulation / creation failure.

getCapabilityClass

Class<MBeanCapability> getCapabilityClass()
Returns the capability class (the product of this builder).

Returns:
the capability class (the product of this builder).

endAttributes

public void endAttributes()
                   throws BuilderException
Determines what needs to be done when all attributes metadata has been notified to this builder. Capability class must have an array member with all defined properties and a getter method that returns it. In this method those two members are declared (obviously only if this capability has at least one property).

Specified by:
endAttributes in interface IArtifactBuilder
Throws:
BuilderException - when something fails during this phase.

endOperations

public void endOperations()
                   throws BuilderException
Director callback. This method is notified when all operations metadata has been notified to this builder. This is the place where the capability class is created, defined and loaded by the JVM.

Specified by:
endOperations in interface IArtifactBuilder
Throws:
BuilderException - issues on this method are basically class loading related.

setEnvironment

public void setEnvironment(org.apache.muse.core.Environment environment)
Injects the module environment on this builder.

Specified by:
setEnvironment in interface IArtifactBuilder
Parameters:
environment - the module environment.

generateGetter

String generateGetter(String type,
                      String name,
                      String plainName)
Generates the get accessor method for the given property.

Parameters:
type - the type of the property.
name - the name of the property with the first letter capitalized.
plainName - the plain name of the property.
Returns:
the getter method (as a string).

generateSetter

String generateSetter(String type,
                      String name,
                      String plainName)
Generates the set accessor method for the given property.

Parameters:
type - the type of the property.
name - the name of the property with the first letter capitalized.
plainName - the plain name of the property.
Returns:
the setter method (as a string).

getNameForAccessors

String getNameForAccessors(String name)
Returns a name that will be used in accessor methods. That name will differ from the given one because the first letter will be capitalized. For example, if the given name is "name" the return value will be "Name".

Parameters:
name - the plain name of the attribute.
Returns:
a capitalized version of the given name to be used in accessors.


Licensed to the Apache Software Foundation