You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cl...@apache.org on 2008/10/06 19:08:45 UTC

svn commit: r702202 [2/4] - in /felix/trunk/ipojo: ant/src/main/java/org/apache/felix/ipojo/task/ core/src/main/java/org/apache/felix/ipojo/ handler/eventadmin/src/main/java/org/apache/felix/ipojo/handlers/event/ handler/eventadmin/src/main/java/org/ap...

Modified: felix/trunk/ipojo/handler/jmx/src/main/java/org/apache/felix/ipojo/handlers/jmx/DynamicMBeanWRegisterImpl.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/handler/jmx/src/main/java/org/apache/felix/ipojo/handlers/jmx/DynamicMBeanWRegisterImpl.java?rev=702202&r1=702201&r2=702202&view=diff
==============================================================================
--- felix/trunk/ipojo/handler/jmx/src/main/java/org/apache/felix/ipojo/handlers/jmx/DynamicMBeanWRegisterImpl.java (original)
+++ felix/trunk/ipojo/handler/jmx/src/main/java/org/apache/felix/ipojo/handlers/jmx/DynamicMBeanWRegisterImpl.java Mon Oct  6 10:08:45 2008
@@ -38,41 +38,35 @@
         MBeanRegistration {
 
     /**
-     * preRegister method of MBeanRegistration interface.
+     * The preRegister method of MBeanRegistration interface.
      */
     private MethodMetadata m_preRegisterMeth;
     /**
-     * postRegister method of MBeanRegistration interface.
+     * The postRegister method of MBeanRegistration interface.
      */
     private MethodMetadata m_postRegisterMeth;
     /**
-     * preDeregister method of MBeanRegistration interface.
+     * The preDeregister method of MBeanRegistration interface.
      */
     private MethodMetadata m_preDeregisterMeth;
     /**
-     * postDeregister method of MBeanRegistration interface.
+     * The postDeregister method of MBeanRegistration interface.
      */
     private MethodMetadata m_postDeregisterMeth;
     /**
-     * Effective name of the MBean.
+     * The effective name of the MBean.
      */
     private ObjectName m_objName;
 
     /**
      * Constructs a new DynamicMBeanWRegisterImpl.
      * 
-     * @param properties
-     *            data extracted from the metadata.xml
-     * @param instanceManager
-     *            the instance manager
-     * @param preRegisterMeth
-     *            the method to call before MBean registration
-     * @param postRegisterMeth
-     *            the method to call after MBean registration
-     * @param preDeregisterMeth
-     *            the method to call before MBean deregistration
-     * @param postDeregisterMeth
-     *            the method to call after MBean registration
+     * @param properties the data extracted from the metadata.xml
+     * @param instanceManager the instance manager
+     * @param preRegisterMeth the method to call before MBean registration
+     * @param postRegisterMeth the method to call after MBean registration
+     * @param preDeregisterMeth the method to call before MBean deregistration
+     * @param postDeregisterMeth the method to call after MBean registration
      */
     public DynamicMBeanWRegisterImpl(JmxConfigFieldMap properties,
             InstanceManager instanceManager, MethodMetadata preRegisterMeth,
@@ -87,7 +81,7 @@
     }
 
     /**
-     * Return the MBean name used to register it.
+     * Returns the MBean name used to register it.
      * 
      * @return the MBean name used to register it.
      */
@@ -98,13 +92,9 @@
     /**
      * This method is executed before the MBean registration.
      * 
-     * @param server
-     *            the server on which the MBean will be registered
-     * @param name
-     *            the name of the MBean to expose
-     * @throws Exception
-     *             This exception will be caught by the MBean server and
-     *             re-thrown as an MBeanRegistrationException.
+     * @param server the server on which the MBean will be registered
+     * @param name the name of the MBean to expose
+     * @throws Exception This exception will be caught by the MBean server and re-thrown as an MBeanRegistrationException.
      * @return the name with which the MBean will be registered
      */
     public ObjectName preRegister(MBeanServer server, ObjectName name)
@@ -117,9 +107,7 @@
     /**
      * This method is executed after the MBean registration.
      * 
-     * @param registrationDone
-     *            Indicates whether or not the MBean has been successfully
-     *            registered in the MBean server.
+     * @param registrationDone indicates whether or not the MBean has been successfully registered in the MBean server.
      */
     public void postRegister(Boolean registrationDone) {
         callMethod(m_postRegisterMeth, MBeanHandler.POST_REGISTER_METH_NAME,
@@ -129,9 +117,7 @@
     /**
      * This method is before after the MBean deregistration.
      * 
-     * @throws Exception
-     *             This exception will be caught by the MBean server and
-     *             re-thrown as an MBeanRegistrationException.
+     * @throws Exception This exception will be caught by the MBean server and re-thrown as an MBeanRegistrationException.
      */
     public void preDeregister() throws Exception {
         callMethod(m_preDeregisterMeth, MBeanHandler.PRE_DEREGISTER_METH_NAME,
@@ -149,14 +135,10 @@
     /**
      * Private method used to execute a given callback.
      * 
-     * @param methodMetadata
-     *            the metadata description of the callback
-     * @param methodName
-     *            the name of the callback
-     * @param params
-     *            the parameters of the callback
-     * @return the object eventually returned by the callback, or null if
-     *         nothing's returned
+     * @param methodMetadata  the metadata description of the callback
+     * @param methodName the name of the callback
+     * @param params the parameters of the callback
+     * @return the object eventually returned by the callback, or null if nothing's returned
      */
     private Object callMethod(MethodMetadata methodMetadata, String methodName,
             Object[] params) {
@@ -169,7 +151,7 @@
             }
         } catch (NoSuchMethodException e) {
             // should never happen : method exists
-            System.err.println("No such method!: " + methodName);
+            System.err.println("No such method : " + methodName);
             e.printStackTrace();
         } catch (IllegalAccessException e) {
             System.err.println("Illegal Access Exception");

Modified: felix/trunk/ipojo/handler/jmx/src/main/java/org/apache/felix/ipojo/handlers/jmx/JMXHandlerDescription.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/handler/jmx/src/main/java/org/apache/felix/ipojo/handlers/jmx/JMXHandlerDescription.java?rev=702202&r1=702201&r2=702202&view=diff
==============================================================================
--- felix/trunk/ipojo/handler/jmx/src/main/java/org/apache/felix/ipojo/handlers/jmx/JMXHandlerDescription.java (original)
+++ felix/trunk/ipojo/handler/jmx/src/main/java/org/apache/felix/ipojo/handlers/jmx/JMXHandlerDescription.java Mon Oct  6 10:08:45 2008
@@ -35,10 +35,9 @@
     private MBeanHandler m_handler;
 
     /**
-     * Construct a new handler description for the given handler.
+     * Constructs a new handler description for the given handler.
      * 
-     * @param handler
-     *            the handler to describe
+     * @param handler the handler to describe
      */
     public JMXHandlerDescription(MBeanHandler handler) {
         super(handler);
@@ -46,7 +45,7 @@
     }
 
     /**
-     * Get handler information.
+     * Gets handler information.
      * 
      * @return the handler information.
      */

Modified: felix/trunk/ipojo/handler/jmx/src/main/java/org/apache/felix/ipojo/handlers/jmx/JmxConfigFieldMap.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/handler/jmx/src/main/java/org/apache/felix/ipojo/handlers/jmx/JmxConfigFieldMap.java?rev=702202&r1=702201&r2=702202&view=diff
==============================================================================
--- felix/trunk/ipojo/handler/jmx/src/main/java/org/apache/felix/ipojo/handlers/jmx/JmxConfigFieldMap.java (original)
+++ felix/trunk/ipojo/handler/jmx/src/main/java/org/apache/felix/ipojo/handlers/jmx/JmxConfigFieldMap.java Mon Oct  6 10:08:45 2008
@@ -33,64 +33,61 @@
 public class JmxConfigFieldMap {
 
     /**
-     * m_properties : use to store the attributes exposed.
+     * The exposed attributes.
      */
     private Map < String, PropertyField > m_properties = new HashMap < String, PropertyField >();
     /**
-     * m_methods : use to store the methods exposed.
+     * The exposed methods.
      */
     private Map < String, MethodField[] > m_methods = new HashMap < String, MethodField[] >();
     /**
-     * m_notification : use to store the notification allowed.
+     * The allowed notifications.
      */
     private Map < String, NotificationField > m_notifications = new HashMap < String, NotificationField >();
     /**
-     * m_description : description of the Mbean.
+     * The description of the Mbean.
      */
     private String m_description;
 
     /**
-     * JmxConfigFieldMap : constructor.
+     * Constructor.
      */
     public JmxConfigFieldMap() {
 
     }
 
     /**
-     * getDescription : get the descritpion of the MBean.
+     * Gets the description of the MBean.
      * 
-     * @return String : Decription of the MBean
+     * @return the description of the MBean
      */
     public String getDecription() {
         return m_description;
     }
 
     /**
-     * setDescription : set the descritpion of the MBean.
+     * Sets the description of the MBean.
      * 
-     * @param description
-     *            : String which describe the Mbean
+     * @param description a String which describes the Mbean
      */
     public void setDescription(String description) {
         this.m_description = description;
     }
 
     /**
-     * addPropertyFromName : add a new attribute exposed in the Mbean.
+     * Adds a new attribute exposed in the Mbean.
      * 
-     * @param name
-     *            : name of the new property
-     * @param propertyField
-     *            : Field which describe the property
+     * @param name the name of the new property
+     * @param propertyField the field which describes the property
      */
     public void addPropertyFromName(String name, PropertyField propertyField) {
         m_properties.put(name, propertyField);
     }
 
     /**
-     * getProperties : get all of the properties exposed.
+     * Gets all of the properties exposed.
      * 
-     * @return : collection of all properties
+     * @return the collection of all properties
      */
     public Collection < PropertyField > getProperties() {
         if (m_properties != null) {
@@ -101,11 +98,10 @@
     }
 
     /**
-     * getPropertyFromName : get the property by the name.
+     * Gets the property by the name.
      * 
-     * @param name
-     *            : name of the requiered property
-     * @return PropertyField : the field requiered or null if is not found
+     * @param name the name of the required property
+     * @return the field required or null if is not found
      */
     public PropertyField getPropertyFromName(String name) {
         PropertyField prop = m_properties.get(name);
@@ -113,11 +109,10 @@
     }
 
     /**
-     * getPropertyFromField : get the property by the field.
+     * Gets the property by the field.
      * 
-     * @param field
-     *            : the requiered field
-     * @return PropertyField :
+     * @param field the required field
+     * @return the property by the field
      */
     public PropertyField getPropertyFromField(String field) {
         PropertyField property = null;
@@ -126,7 +121,7 @@
             PropertyField p = it.next();
             if (p.getField().compareTo(field) == 0) {
                 if (property != null) {
-                    System.err.println("a field already exist");
+                    System.err.println("a field already exists");
                 } else {
                     property = p;
                 }
@@ -136,12 +131,10 @@
     }
 
     /**
-     * addMethodFromName : add a new method descriptor from its name.
+     * Adds a new method descriptor from its name.
      * 
-     * @param name
-     *            : name of the method
-     * @param methodField
-     *            : descritpion of the method
+     * @param name the name of the method
+     * @param methodField the description of the method
      */
     public void addMethodFromName(String name, MethodField methodField) {
         MethodField[] mf;
@@ -160,13 +153,10 @@
     }
 
     /**
-     * addMethodFromName : add new methods descriptors from one name. (the
-     * method muste have the same name but different signature).
+     * Adds new methods descriptors from one name. (the method must have the same name but different signature).
      * 
-     * @param name
-     *            : name of the method
-     * @param methodsField
-     *            : descritpion of the methods
+     * @param name the name of the method
+     * @param methodsField the description of the methods
      */
     public void addMethodFromName(String name, MethodField[] methodsField) {
         MethodField[] mf;
@@ -186,12 +176,10 @@
     }
 
     /**
-     * DynamicMBeanImpl : add methods from name and erase the older if exist.
+     * Adds a method from name and erases the older if exists.
      * 
-     * @param name
-     *            : name of the method
-     * @param methodField
-     *            : method to be added
+     * @param name the name of the method
+     * @param methodField the method to be added
      */
     public void overrideMethodFromName(String name, MethodField methodField) {
         MethodField[] mf = new MethodField[1];
@@ -200,23 +188,20 @@
     }
 
     /**
-     * DynamicMBeanImpl : add methods from name and erase the older if exist.
+     * Add methods from name and erases the olders if exists.
      * 
-     * @param name
-     *            : name of the method
-     * @param methodsField
-     *            : array of methods to be added
+     * @param name the name of the method
+     * @param methodsField the array of methods to be added
      */
     public void overrideMethodFromName(String name, MethodField[] methodsField) {
         m_methods.put(name, methodsField);
     }
 
     /**
-     * getMethodFromName : return the metod(s) which are similar.
+     * Returns the method(s) with the given name.
      * 
-     * @param name
-     *            : name of requiered method
-     * @return MethodField[] : list of returned methods
+     * @param name the name of the methods
+     * @return the list of methods with the given name
      */
     public MethodField[] getMethodFromName(String name) {
         MethodField[] prop = m_methods.get(name);
@@ -224,14 +209,11 @@
     }
 
     /**
-     * getMethodFromName : get the method which the good signature.
+     * Gets the method with the good signature.
      * 
-     * @param operationName
-     *            : name of the method requiered
-     * @param signature
-     *            : signature requiered
-     * @return MethodField : the method which the same signature or null if not
-     *         found
+     * @param operationName the name of the method requiered
+     * @param signature the required signature
+     * @return the method which the same signature or null if not found
      */
     public MethodField getMethodFromName(String operationName,
             String[] signature) {
@@ -245,13 +227,11 @@
     }
 
     /**
-     * isSameSignature : compare two method signature.
+     * Compares two method signature.
      * 
-     * @param sig1
-     *            : first signature
-     * @param sig2
-     *            : second signature
-     * @return boolean : return true if the signature are similar fale else
+     * @param sig1 the first signature
+     * @param sig2 the second signature
+     * @return true if the signature are similar false otherwise
      */
     private boolean isSameSignature(String[] sig1, String[] sig2) {
         if (sig1.length != sig2.length) {
@@ -268,9 +248,9 @@
     }
 
     /**
-     * getMethods : return all methods store.
+     * Returns all methods store.
      * 
-     * @return Collection : collection of methodField[]
+     * @return the collection of methodField[]
      */
     public Collection < MethodField[] > getMethods() {
         if (m_methods != null) {
@@ -281,12 +261,10 @@
     }
 
     /**
-     * addNotificationFromName : add a notification .
+     * Adds a notification.
      * 
-     * @param name
-     *            :
-     * @param notificationField
-     *            :
+     * @param name the name of the notification
+     * @param notificationField the field involved with the notification.
      */
     public void addNotificationFromName(String name,
             NotificationField notificationField) {
@@ -294,11 +272,10 @@
     }
 
     /**
-     * getNotificationFromName : return the notification with requiered name.
+     * Returns the notification with the given name.
      * 
-     * @param name
-     *            : name requiered
-     * @return NotificationField : return the notification if exist, null else
+     * @param name the name of the notification to return
+     * @return the notification if it exists, {@code null} otherwise
      */
     public NotificationField getNotificationFromName(String name) {
         NotificationField prop = m_notifications.get(name);
@@ -306,9 +283,9 @@
     }
 
     /**
-     * getNotification : get all notifications define.
+     * Gets all notifications defined.
      * 
-     * @return Collection : return collection of NotificationField
+     * @return the collection of NotificationField
      */
     public Collection < NotificationField > getNotifications() {
         if (m_notifications != null) {

Modified: felix/trunk/ipojo/handler/jmx/src/main/java/org/apache/felix/ipojo/handlers/jmx/MBeanHandler.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/handler/jmx/src/main/java/org/apache/felix/ipojo/handlers/jmx/MBeanHandler.java?rev=702202&r1=702201&r2=702202&view=diff
==============================================================================
--- felix/trunk/ipojo/handler/jmx/src/main/java/org/apache/felix/ipojo/handlers/jmx/MBeanHandler.java (original)
+++ felix/trunk/ipojo/handler/jmx/src/main/java/org/apache/felix/ipojo/handlers/jmx/MBeanHandler.java Mon Oct  6 10:08:45 2008
@@ -28,6 +28,7 @@
 import javax.management.ObjectInstance;
 import javax.management.ObjectName;
 
+import org.apache.felix.ipojo.FieldInterceptor;
 import org.apache.felix.ipojo.InstanceManager;
 import org.apache.felix.ipojo.PrimitiveHandler;
 import org.apache.felix.ipojo.architecture.HandlerDescription;
@@ -48,164 +49,156 @@
 public class MBeanHandler extends PrimitiveHandler {
 
     /**
-     * Name of the MBeanRegistration postDeregister method.
+     * The name of the MBeanRegistration postDeregister method.
      */
     public static final String POST_DEREGISTER_METH_NAME = "postDeregister";
 
     /**
-     * Name of the MBeanRegistration preDeregister method.
+     * The name of the MBeanRegistration preDeregister method.
      */
     public static final String PRE_DEREGISTER_METH_NAME = "preDeregister";
 
     /**
-     * Name of the MBeanRegistration postRegister method.
+     * The name of the MBeanRegistration postRegister method.
      */
     public static final String POST_REGISTER_METH_NAME = "postRegister";
 
     /**
-     * Name of the MBeanRegistration preRegister method.
+     * The name of the MBeanRegistration preRegister method.
      */
     public static final String PRE_REGISTER_METH_NAME = "preRegister";
 
     /**
-     * Name of the global configuration element.
+     * The name of the global configuration element.
      */
     private static final String JMX_CONFIG_ELT = "config";
 
     /**
-     * Name of the component object full name attribute.
+     * The name of the component object full name attribute.
      */
     private static final String JMX_OBJ_NAME_ELT = "objectName";
 
     /**
-     * Name of the component object name domain attribute.
+     * The name of the component object name domain attribute.
      */
     private static final String JMX_OBJ_NAME_DOMAIN_ELT = "domain";
 
     /**
-     * Name of the component object name attribute.
+     * The name of the component object name attribute.
      */
     private static final String JMX_OBJ_NAME_WO_DOMAIN_ELT = "name";
 
     /**
-     * Name of the attribute indicating if the handler uses MOSGi MBean server.
+     * The name of the attribute indicating if the handler uses MOSGi MBean server.
      */
     private static final String JMX_USES_MOSGI_ELT = "usesMOSGi";
 
     /**
-     * Name of a method element.
+     * The name of a method element.
      */
     private static final String JMX_METHOD_ELT = "method";
 
     /**
-     * Name of the property or method name attribute.
+     * The name of the property or method name attribute.
      */
     private static final String JMX_NAME_ELT = "name";
 
     /**
-     * Name of a method description attribute.
+     * The name of a method description attribute.
      */
     private static final String JMX_DESCRIPTION_ELT = "description";
 
     /**
-     * Name of a property element.
+     * The name of a property element.
      */
     private static final String JMX_PROPERTY_ELT = "property";
 
     /**
-     * Name of the field attribute.
+     * The name of the field attribute.
      */
     private static final String JMX_FIELD_ELT = "field";
 
     /**
-     * Name of the notification attribute.
+     * The name of the notification attribute.
      */
     private static final String JMX_NOTIFICATION_ELT = "notification";
 
     /**
-     * Name of the rights attribute.
+     * The name of the rights attribute.
      */
     private static final String JMX_RIGHTS_ELT = "rights";
 
     /**
-     * InstanceManager: use to store the InstanceManager instance.
+     * The instance manager. Used to store the InstanceManager instance.
      */
     private InstanceManager m_instanceManager;
     /**
-     * ServiceRegistration : use to register and unregister the Dynamic MBean.
+     * The service registration. Used to register and unregister the Dynamic MBean.
      */
     private ServiceRegistration m_serviceRegistration;
     /**
-     * JmxConfigFieldMap : use to store data when parsing metadata.xml.
+     * Stores data when parsing metadata.xml.
      */
     private JmxConfigFieldMap m_jmxConfigFieldMap;
     /**
-     * DynamicMBeanImpl : store the Dynamic MBean.
+     * Stores the Dynamic MBean.
      */
     private DynamicMBeanImpl m_MBean;
     /**
-     * String : constant which store the name of the class.
+     * Constant storing the name of the class.
      */
     private String m_namespace = "org.apache.felix.ipojo.handlers.jmx";
     /**
-     * Flag used to say if we use MOSGi framework.
+     * The flag used to inform if we use the MOSGi framework.
      */
     private boolean m_usesMOSGi = false;
     /**
-     * ObjectName used to register the MBean.
+     * The ObjectName used to register the MBean.
      */
     private ObjectName m_objectName;
     /**
-     * Flag used to say if the MBean is registered.
+     * The flag used to inform if the MBean is registered.
      */
     private boolean m_registered = false;
     /**
-     * object name specified in handler configuration. It can be null.
+     * The ObjectName specified in handler configuration. It can be null.
      */
     private String m_completeObjNameElt;
     /**
-     * object name without domain specified in handler configuration. It can be
-     * null.
+     * The ObjectName without domain specified in handler configuration. It can be null.
      */
     private String m_objNameWODomainElt;
     
     /**
-     * object name domain specified in handler configuration. It can be null.
+     * The ObjectName domain specified in handler configuration. It can be null.
      */
     private String m_domainElt;
     /**
-     * flag representing if the Pojo implements MBeanRegistration interface.
+     * The flag informing if the POJO implements the MBeanRegistration interface.
      */
     private boolean m_registerCallbacks;
     /**
-     * preRegister method of MBeanRegistration interface. It is null if pojo
-     * doesn't implement MBeanRegistration interface.
+     * The preRegister method of MBeanRegistration interface. It is null if POJO doesn't implement MBeanRegistration interface.
      */
     private MethodMetadata m_preRegisterMeth;
     /**
-     * postRegister method of MBeanRegistration interface. It is null if pojo
-     * doesn't implement MBeanRegistration interface.
+     * The postRegister method of MBeanRegistration interface. It is null if POJO doesn't implement MBeanRegistration interface.
      */
     private MethodMetadata m_postRegisterMeth;
     /**
-     * preDeregister method of MBeanRegistration interface. It is null if pojo
-     * doesn't implement MBeanRegistration interface.
+     * The preDeregister method of MBeanRegistration interface. It is null if POJO doesn't implement MBeanRegistration interface.
      */
     private MethodMetadata m_preDeregisterMeth;
     /**
-     * postDeregister method of MBeanRegistration interface. It is null if pojo
-     * doesn't implement MBeanRegistration interface.
+     * The postDeregister method of MBeanRegistration interface. It is null if POJO doesn't implement MBeanRegistration interface.
      */
     private MethodMetadata m_postDeregisterMeth;
 
     /**
-     * configure : construct the structure JmxConfigFieldMap.and the Dynamic
-     * Mbean.
+     * Constructs the structure JmxConfigFieldMap and the Dynamic Mbean.
      * 
-     * @param metadata
-     *            Element
-     * @param dict
-     *            Dictionary
+     * @param metadata the component metadata
+     * @param dict the instance configuration
      */
     public void configure(Element metadata, Dictionary dict) {
 
@@ -325,7 +318,7 @@
     }
 
     /**
-     * start : register the Dynamic Mbean.
+     * Registers the Dynamic Mbean.
      */
     public void start() {
         // create the corresponding MBean
@@ -383,7 +376,7 @@
     }
 
     /**
-     * Return the object name of the exposed component.
+     * Returns the object name of the exposed component.
      * 
      * @return the object name of the exposed component.
      */
@@ -415,10 +408,9 @@
     }
 
     /**
-     * Extract the package name from of given type.
+     * Extracts the package name from of given type.
      * 
-     * @param className
-     *            the type.
+     * @param className the type name.
      * @return the package name of the given type.
      */
     private String getPackageName(String className) {
@@ -433,7 +425,7 @@
     }
 
     /**
-     * stop : unregister the Dynamic Mbean.
+     * Unregisters the Dynamic Mbean.
      */
     public void stop() {
         if (m_usesMOSGi) {
@@ -457,14 +449,12 @@
     }
 
     /**
-     * setterCallback : call when a POJO member is modified externally.
+     * Called when a POJO member is modified externally.
      * 
-     * @param pojo
-     *            : the POJO object
-     * @param fieldName
-     *            : name of the modified field
-     * @param value
-     *            : new value of the field
+     * @param pojo the modified POJO object
+     * @param fieldName the name of the modified field
+     * @param value the new value of the field
+     * @see FieldInterceptor#onSet(Object, String, Object)
      */
     public void onSet(Object pojo, String fieldName, Object value) {
         // Check if the field is a configurable property
@@ -484,15 +474,13 @@
     }
 
     /**
-     * getterCallback : call when a POJO member is modified by the MBean.
+     * Called when a POJO member is read by the MBean.
      * 
-     * @param pojo
-     *            : pojo object.
-     * @param fieldName
-     *            : name of the modified field
-     * @param value
-     *            : old value of the field
-     * @return : new value of the field
+     * @param pojo the read POJO object.
+     * @param fieldName the name of the modified field
+     * @param value the old value of the field
+     * @return the (injected) value of the field
+     * @see FieldInterceptor#onGet(Object, String, Object)
      */
     public Object onGet(Object pojo, String fieldName, Object value) {
 
@@ -503,18 +491,15 @@
             m_instanceManager.onSet(pojo, fieldName, propertyField.getValue());
             return propertyField.getValue();
         }
-        // m_instanceManager.onSet(pojo, fieldName, value);
         return value;
     }
 
     /**
-     * getTypeFromAttributeField : get the type from a field name.
+     * Gets the type from a field name.
      * 
-     * @param fieldRequire
-     *            : name of the requiered field
-     * @param manipulation
-     *            : metadata extract from metadata.xml file
-     * @return : type of the field or null if it wasn't found
+     * @param fieldRequire the name of the required field
+     * @param manipulation the metadata extracted from metadata.xml file
+     * @return the type of the field or {@code null} if it wasn't found
      */
     private static String getTypeFromAttributeField(String fieldRequire,
             PojoMetadata manipulation) {
@@ -528,15 +513,12 @@
     }
 
     /**
-     * getMethodsFromName : get all the methods available which get this name.
+     * Gets all the methods available which get this name.
      * 
-     * @param methodName
-     *            : name of the requiered methods
-     * @param manipulation
-     *            : metadata extract from metadata.xml file
-     * @param description
-     *            : description which appears in jmx console
-     * @return : array of methods with the right name
+     * @param methodName the name of the required methods
+     * @param manipulation the metadata extract from metadata.xml file
+     * @param description the description which appears in JMX console
+     * @return the array of methods with the right name
      */
     private MethodField[] getMethodsFromName(String methodName,
             PojoMetadata manipulation, String description) {
@@ -560,9 +542,9 @@
     }
 
     /**
-     * Get the jmx handler description.
+     * Gets the JMX handler description.
      * 
-     * @return the jmx handler description.
+     * @return the JMX handler description.
      * @see org.apache.felix.ipojo.Handler#getDescription()
      */
     public HandlerDescription getDescription() {
@@ -570,8 +552,7 @@
     }
 
     /**
-     * Return the objectName used to register the MBean. If the MBean is not
-     * registered, return an empty string.
+     * Returns the objectName used to register the MBean. If the MBean is not registered, return an empty string.
      * 
      * @return the objectName used to register the MBean.
      * @see org.apache.felix.ipojo.Handler#getDescription()
@@ -585,7 +566,7 @@
     }
 
     /**
-     * Return true if the MBean is registered.
+     * Returns true if the MBean is registered.
      * 
      * @return true if the MBean is registered.
      */
@@ -594,20 +575,18 @@
     }
 
     /**
-     * Return true if the MBean must be registered thanks to whiteboard pattern
-     * of MOSGi.
+     * Returns true if the MBean must be registered thanks to white board pattern of MOSGi.
      * 
-     * @return true if the MBean must be registered thanks to whiteboard pattern
-     *         of MOSGi.
+     * @return {@code true} if the MBean must be registered thanks to white board pattern of MOSGi, false otherwise.
      */
     public boolean isUsesMOSGi() {
         return m_usesMOSGi;
     }
 
     /**
-     * Return true if the MOSGi framework is present on the OSGi plateforme.
+     * Returns true if the MOSGi framework is present on the OSGi platform.
      * 
-     * @return true if the MOSGi framework is present on the OSGi plateforme.
+     * @return {@code true} if the MOSGi framework is present on the OSGi platform, false otherwise.
      */
     public boolean isMOSGiExists() {
         for (Bundle bundle : m_instanceManager.getContext().getBundles()) {

Modified: felix/trunk/ipojo/handler/jmx/src/main/java/org/apache/felix/ipojo/handlers/jmx/MethodField.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/handler/jmx/src/main/java/org/apache/felix/ipojo/handlers/jmx/MethodField.java?rev=702202&r1=702201&r2=702202&view=diff
==============================================================================
--- felix/trunk/ipojo/handler/jmx/src/main/java/org/apache/felix/ipojo/handlers/jmx/MethodField.java (original)
+++ felix/trunk/ipojo/handler/jmx/src/main/java/org/apache/felix/ipojo/handlers/jmx/MethodField.java Mon Oct  6 10:08:45 2008
@@ -24,28 +24,26 @@
 import org.apache.felix.ipojo.parser.MethodMetadata;
 
 /**
- * this class build a method JMX description.
+ * This class builds a method JMX description.
  * 
  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
  */
 public class MethodField {
 
     /**
-     * m_description : store the method descritpion.
+     * Stores the method description.
      */
     private String m_description;
     /**
-     * m_method : store the method properties.
+     * Stores the method properties.
      */
     private MethodMetadata m_method;
 
     /**
-     * MethodField : constructor.
+     * Constructor.
      * 
-     * @param method
-     *            : the metod properties
-     * @param description
-     *            : thes method description
+     * @param method the method properties
+     * @param description the method description
      */
     public MethodField(MethodMetadata method, String description) {
         this.m_method = method;
@@ -53,22 +51,34 @@
 
     }
 
+    /**
+     * Gets the method
+     * @return the method
+     */
     public MethodMetadata getMethod() {
         return m_method;
     }
 
+    /**
+     * Gets the description
+     * @return the description
+     */
     public String getDescription() {
         return m_description;
     }
 
+    /**
+     * Gets the name
+     * @return the name
+     */
     public String getName() {
         return m_method.getMethodName();
     }
 
     /**
-     * getParams : get the parameter in JMX format.
+     * Gets the parameter in JMX format.
      * 
-     * @return MBeanParameterInfo : return info on JMX format
+     * @return info on JMX format
      */
     public MBeanParameterInfo[] getParams() {
         MBeanParameterInfo[] mbean = new MBeanParameterInfo[m_method

Modified: felix/trunk/ipojo/handler/jmx/src/main/java/org/apache/felix/ipojo/handlers/jmx/NotificationField.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/handler/jmx/src/main/java/org/apache/felix/ipojo/handlers/jmx/NotificationField.java?rev=702202&r1=702201&r2=702202&view=diff
==============================================================================
--- felix/trunk/ipojo/handler/jmx/src/main/java/org/apache/felix/ipojo/handlers/jmx/NotificationField.java (original)
+++ felix/trunk/ipojo/handler/jmx/src/main/java/org/apache/felix/ipojo/handlers/jmx/NotificationField.java Mon Oct  6 10:08:45 2008
@@ -22,33 +22,30 @@
 import javax.management.MBeanNotificationInfo;
 
 /**
- * this calss build the notification descritpion structure.
+ * This class builds the notification description structure.
  * 
  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
  */
 public class NotificationField {
     /**
-     * m_name : name of the notification.
+     * The name of the notification.
      */
     private String m_name;
     /**
-     * m_description : description of the notification.
+     * The description of the notification.
      */
     private String m_description;
     /**
-     * m_description : field of the notification.
+     * The field of the notification.
      */
     private String m_field;
 
     /**
-     * NotificationField : constructor.
+     * Constructor.
      * 
-     * @param name
-     *            : name of the notification
-     * @param field
-     *            : field which send a notification when it is modified
-     * @param description
-     *            : descritpion which appears in jmx console
+     * @param name the name of the notification
+     * @param field the field which send a notification when it is modified
+     * @param description the description which appears in JMX console
      */
 
     public NotificationField(String name, String field, String description) {
@@ -58,9 +55,9 @@
     }
 
     /**
-     * getNotificationInfo : return the MBeanNotificationInfo from this class.
+     * Returns the MBeanNotificationInfo from this class.
      * 
-     * @return : type of the field or null if it wasn't found
+     * @return the type of the field or {@code null} if it wasn't found
      */
     public MBeanNotificationInfo getNotificationInfo() {
         String[] notificationTypes = new String[1];

Modified: felix/trunk/ipojo/handler/jmx/src/main/java/org/apache/felix/ipojo/handlers/jmx/PropertyField.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/handler/jmx/src/main/java/org/apache/felix/ipojo/handlers/jmx/PropertyField.java?rev=702202&r1=702201&r2=702202&view=diff
==============================================================================
--- felix/trunk/ipojo/handler/jmx/src/main/java/org/apache/felix/ipojo/handlers/jmx/PropertyField.java (original)
+++ felix/trunk/ipojo/handler/jmx/src/main/java/org/apache/felix/ipojo/handlers/jmx/PropertyField.java Mon Oct  6 10:08:45 2008
@@ -20,48 +20,44 @@
 package org.apache.felix.ipojo.handlers.jmx;
 
 /**
- * this calss build the notification descritpion structure.
+ * This class build the notification description structure.
  * 
  * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
  */
 public class PropertyField {
 
     /**
-     * m_name : name of the notification.
+     * The name of the notification.
      */
     private String m_name;
     /**
-     * m_name : name of the notification.
+     *  The name of the notification.
      */
     private String m_field;
     /**
-     * m_name : name of the notification.
+     * The name of the notification.
      */
     private String m_rights;
     /**
-     * m_name : name of the notification.
+     * The name of the notification.
      */
     private String m_type;
     /**
-     * m_name : name of the notification.
+     * The name of the notification.
      */
     private Object m_value;
     /**
-     * m_name : name of the notification.
+     * The name of the notification.
      */
     private boolean m_notification = false;
 
     /**
-     * PropertyField : constructor.
+     * Constructor.
      * 
-     * @param name
-     *            : name of the properety
-     * @param field
-     *            : field which send a notification when it is modified
-     * @param rights
-     *            : the rights of the attribute (ie: 'r' or 'w')
-     * @param type
-     *            : the type of the attribute
+     * @param name the name of the properety
+     * @param field the field which send a notification when it is modified
+     * @param rights the rights of the attribute (ie: 'r' or 'w')
+     * @param type the type of the attribute
      */
     public PropertyField(String name, String field, String rights, String type) {
         this.setName(name);
@@ -74,69 +70,124 @@
         }
     }
 
+    /**
+     * Returns the field
+     * @return the field
+     */
     public String getField() {
         return m_field;
     }
 
+    /**
+     * Modify the field
+     * @param field the new field
+     */
     public void setField(String field) {
         this.m_field = field;
     }
 
+    /**
+     * Returns the name
+     * @return the name
+     */
     public String getName() {
         return m_name;
     }
 
+    /**
+     * Modify the name
+     * @param name the new name
+     */
     public void setName(String name) {
         this.m_name = name;
     }
 
+    /**
+     * Returns the rights
+     * @return the rights
+     */
     public String getRights() {
         return m_rights;
     }
 
+    /**
+     * Modify the rights
+     * @param rights the new rights
+     */
     public void setRights(String rights) {
         this.m_rights = rights;
     }
 
+    /**
+     * Returns the value
+     * @return the value
+     */
     public Object getValue() {
         return m_value;
     }
 
+    /**
+     * Modify the value
+     * @param value the new value
+     */
     public void setValue(Object value) {
         this.m_value = value;
     }
 
+    /**
+     * Returns the type
+     * @return the type
+     */
     public String getType() {
         return this.m_type;
     }
 
+    /**
+     * Returns the description
+     * @return the description
+     */
     public String getDescription() {
         // TODO Auto-generated method stub
         return null;
     }
 
+    /**
+     * Returns true if this property field is readable, false otherwise.
+     * @return {@code true} if this property field is readable, {@code false} otherwise.
+     */
     public boolean isReadable() {
         return this.getRights().equals("r") || this.getRights().equals("w");
     }
 
+    /**
+     * Returns true if this property field is writable, false otherwise.
+     * @return {@code true} if this property field is writable, {@code false} otherwise.
+     */
     public boolean isWritable() {
         return this.getRights().equals("w");
     }
 
+    /**
+     * Returns true if this property field is notifiable, false otherwise.
+     * @return {@code true} if this property field is notifiable, {@code false} otherwise.
+     */
     public boolean isNotifiable() {
         return this.m_notification;
     }
 
+    /**
+     * Modify the notifiability of this property field.
+     * @param value the new notifiability of this property field.
+     */
     public void setNotifiable(boolean value) {
         this.m_notification = value;
     }
 
     /**
-     * isRightsValid : return is the rights is valid or not (ie = 'r' || 'w').
+     * Is the rights is valid or not ? (ie = 'r' || 'w').
      * 
-     * @param rights
-     *            : string represents the rights
-     * @return boolean : return true if rights = 'r' or 'w'
+     * @param rights string representing the rights
+     * @return boolean : return {@code true} if rights = 'r' or 'w'
      */
     public static boolean isRightsValid(String rights) {
         return rights != null && (rights.equals("r") || rights.equals("w"));

Modified: felix/trunk/ipojo/handler/temporal/src/main/java/org/apache/felix/ipojo/handler/temporal/TemporalDependency.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/handler/temporal/src/main/java/org/apache/felix/ipojo/handler/temporal/TemporalDependency.java?rev=702202&r1=702201&r2=702202&view=diff
==============================================================================
--- felix/trunk/ipojo/handler/temporal/src/main/java/org/apache/felix/ipojo/handler/temporal/TemporalDependency.java (original)
+++ felix/trunk/ipojo/handler/temporal/src/main/java/org/apache/felix/ipojo/handler/temporal/TemporalDependency.java Mon Oct  6 10:08:45 2008
@@ -1,297 +1,293 @@
-/* 
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.handler.temporal;
-
-import java.lang.reflect.Array;
-import java.lang.reflect.Proxy;
-
-import org.apache.felix.ipojo.FieldInterceptor;
-import org.apache.felix.ipojo.Nullable;
-import org.apache.felix.ipojo.PrimitiveHandler;
-import org.apache.felix.ipojo.handlers.dependency.NullableObject;
-import org.apache.felix.ipojo.util.DependencyModel;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.Filter;
-import org.osgi.framework.ServiceReference;
-
-/**
- * Temporal dependency. A temporal dependency waits (block) for the availability
- * of the service. If no provider arrives in the specified among of time, a
- * runtime exception is thrown.
- * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
- */
-public class TemporalDependency extends DependencyModel implements
-        FieldInterceptor {
-
-    /**
-     * Timeout.
-     */
-    private long m_timeout;
-
-    /**
-     * Default-Implementation.
-     */
-    private String m_di;
-
-    /**
-     * Nullable object / Default-Implementation instance if used.
-     */
-    private Object m_nullableObject;
-
-    /**
-     * Handler managing this dependency.
-     */
-    private PrimitiveHandler m_handler;
-
-    /**
-     * Timetout policy. Null inject null Nullable injects a nullable object or
-     * an array with a nullable object Default-Implementation inject an object
-     * created from the specified injected implementation or an array with it
-     * Empty array inject an empty array (must be an aggregate dependency) No
-     * policy (0) throw a runtime exception when the timeout occurs *
-     */
-    private int m_policy;
-
-    /**
-     * Constructor.
-     * @param spec : service specification
-     * @param agg : is the dependency aggregate ?
-     * @param filter : LDAP filter
-     * @param context : service context
-     * @param timeout : timeout
-     * @param handler : Handler managing this dependency
-     * @param defaultImpl : class used as default-implementation
-     * @param policy : onTimeout policy
-     */
-    public TemporalDependency(Class spec, boolean agg, Filter filter,
-            BundleContext context, long timeout, int policy,
-            String defaultImpl, TemporalHandler handler) {
-        super(spec, agg, true, filter, null,
-                DependencyModel.DYNAMIC_BINDING_POLICY, context, handler);
-        m_di = defaultImpl;
-        m_policy = policy;
-        m_timeout = timeout;
-        m_handler = handler;
-    }
-
-    /**
-     * The dependency has been reconfigured.
-     * @param arg0 : new service references
-     * @param arg1 : old service references
-     * @see org.apache.felix.ipojo.util.DependencyModel#onDependencyReconfiguration(org.osgi.framework.ServiceReference[],
-     *      org.osgi.framework.ServiceReference[])
-     */
-    public void onDependencyReconfiguration(ServiceReference[] arg0,
-            ServiceReference[] arg1) {
-        throw new UnsupportedOperationException(
-                "Reconfiguration not yet supported");
-    }
-
-    /**
-     * A provider arrives.
-     * @param arg0 : service reference of the new provider.
-     * @see org.apache.felix.ipojo.util.DependencyModel#onServiceArrival(org.osgi.framework.ServiceReference)
-     */
-    public void onServiceArrival(ServiceReference arg0) {
-        // Notify if a thread is waiting.
-        synchronized (this) {
-            notifyAll();
-        }
-    }
-
-    /**
-     * A provider leaves. Nothing to do.
-     * @param arg0 : leaving service references.
-     * @see org.apache.felix.ipojo.util.DependencyModel#onServiceDeparture(org.osgi.framework.ServiceReference)
-     */
-    public synchronized void onServiceDeparture(ServiceReference arg0) {
-    }
-
-    /**
-     * The code require a value of the monitored field. If providers are
-     * available, the method return service object(s) immediately. Else, the
-     * thread is blocked until an arrival. If no provider arrives during the
-     * among of time specified, the method throws a Runtime Exception.
-     * @param arg0 : POJO instance asking for the service
-     * @param arg1 : field name
-     * @param arg2 : previous value
-     * @return the object to inject.
-     * @see org.apache.felix.ipojo.FieldInterceptor#onGet(java.lang.Object,
-     *      java.lang.String, java.lang.Object)
-     */
-    public synchronized Object onGet(Object arg0, String arg1, Object arg2) {
-        ServiceReference[] refs = getServiceReferences();
-        if (refs != null) {
-            // Immediate return.
-            if (isAggregate()) {
-                Object[] svc = (Object[]) Array.newInstance(getSpecification(),
-                        refs.length);
-                for (int i = 0; i < svc.length; i++) {
-                    svc[i] = getService(refs[i]);
-                }
-                return svc;
-            } else {
-                return getService(refs[0]);
-            }
-        } else {
-            // Begin to wait ...
-            long enter = System.currentTimeMillis();
-            boolean exhausted = false;
-            ServiceReference ref = null;
-            synchronized (this) {
-                while (getServiceReference() == null && !exhausted) {
-                    try {
-                        wait(1);
-                    } catch (InterruptedException e) {
-                        // We was interrupted ....
-                    } finally {
-                        long end = System.currentTimeMillis();
-                        exhausted = (end - enter) > m_timeout;
-                    }
-                }
-            }
-            // Check
-            if (exhausted) {
-                return onTimeout();
-            } else {
-                ref = getServiceReference();
-                if (isAggregate()) {
-                    Object[] svc = (Object[]) Array.newInstance(
-                            getSpecification(), 1);
-                    svc[0] = getService(ref);
-                    return svc;
-                } else {
-                    return getService(ref);
-                }
-            }
-        }
-    }
-
-    /**
-     * Start method.
-     * Initializes the nullable object.
-     * @see org.apache.felix.ipojo.util.DependencyModel#start()
-     */
-    public void start() {
-        super.start();
-        switch (m_policy) {
-            case TemporalHandler.NULL:
-                m_nullableObject = null;
-                break;
-            case TemporalHandler.NULLABLE:
-                // To load the proxy we use the POJO class loader. Indeed, this
-                // classloader imports iPOJO (so can access to Nullable) and has
-                // access to the service specification.
-                try {
-                    m_nullableObject = Proxy.newProxyInstance(m_handler
-                            .getInstanceManager().getClazz().getClassLoader(),
-                            new Class[] { getSpecification(), Nullable.class },
-                            new NullableObject()); // NOPMD
-                    if (isAggregate()) {
-                        Object[] array = (Object[]) Array.newInstance(
-                                getSpecification(), 1);
-                        array[0] = m_nullableObject;
-                        m_nullableObject = array;
-                    }
-                } catch (NoClassDefFoundError e) {
-                    // A NoClassDefFoundError is thrown if the specification
-                    // uses a
-                    // class not accessible by the actual instance.
-                    // It generally comes from a missing import.
-                    throw new IllegalStateException(
-                            "Cannot create the Nullable object, a referenced class cannot be loaded: "
-                                    + e.getMessage());
-                }
-
-                break;
-            case TemporalHandler.DEFAULT_IMPLEMENTATION:
-                // Create the default-implementation object.
-                try {
-                    Class clazz = m_handler.getInstanceManager().getContext()
-                            .getBundle().loadClass(m_di);
-                    m_nullableObject = clazz.newInstance();
-                } catch (IllegalAccessException e) {
-                    throw new IllegalStateException(
-                            "Cannot load the default-implementation " + m_di
-                                    + " : " + e.getMessage());
-                } catch (InstantiationException e) {
-                    throw new IllegalStateException(
-                            "Cannot load the default-implementation " + m_di
-                                    + " : " + e.getMessage());
-                } catch (ClassNotFoundException e) {
-                    throw new IllegalStateException(
-                            "Cannot load the default-implementation " + m_di
-                                    + " : " + e.getMessage());
-                }
-                if (isAggregate()) {
-                    Object[] array = (Object[]) Array.newInstance(
-                            getSpecification(), 1);
-                    array[0] = m_nullableObject;
-                    m_nullableObject = array;
-                }
-                break;
-            case TemporalHandler.EMPTY_ARRAY:
-                m_nullableObject = Array.newInstance(getSpecification(), 0);
-                break;
-            default: // Cannot occurs
-                break;
-        }
-    }
-
-    /**
-     * Stop method.
-     * Just release the reference on the nullable object.
-     * @see org.apache.felix.ipojo.util.DependencyModel#stop()
-     */
-    public void stop() {
-        super.stop();
-        m_nullableObject = null;
-    }
-
-    /**
-     * The monitored field receives a value. Nothing to do.
-     * @param arg0 : POJO setting the value.
-     * @param arg1 : field name
-     * @param arg2 : received value
-     * @see org.apache.felix.ipojo.FieldInterceptor#onSet(java.lang.Object,
-     *      java.lang.String, java.lang.Object)
-     */
-    public void onSet(Object arg0, String arg1, Object arg2) {
-    }
-
-    /**
-     * Implements the timeout policy according to the specified configuration.
-     * @return the object to return when the timeout occurs.
-     */
-    private Object onTimeout() {
-        switch (m_policy) {
-            case TemporalHandler.NULL:
-            case TemporalHandler.NULLABLE:
-            case TemporalHandler.DEFAULT_IMPLEMENTATION:
-            case TemporalHandler.EMPTY_ARRAY:
-                return m_nullableObject;
-            default:
-                // Throws a runtime exception
-                throw new RuntimeException("Service "
-                        + getSpecification().getName()
-                        + " unavailable : timeout");
-        }
-    }
-
-}
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.handler.temporal;
+
+import java.lang.reflect.Array;
+import java.lang.reflect.Proxy;
+
+import org.apache.felix.ipojo.FieldInterceptor;
+import org.apache.felix.ipojo.Nullable;
+import org.apache.felix.ipojo.PrimitiveHandler;
+import org.apache.felix.ipojo.handlers.dependency.NullableObject;
+import org.apache.felix.ipojo.util.DependencyModel;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.Filter;
+import org.osgi.framework.ServiceReference;
+
+/**
+ * Temporal dependency. A temporal dependency waits (block) for the availability
+ * of the service. If no provider arrives in the specified among of time, a
+ * runtime exception is thrown.
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+public class TemporalDependency extends DependencyModel implements
+        FieldInterceptor {
+
+    /**
+     * The timeout.
+     */
+    private long m_timeout;
+
+    /**
+     * The default implementation.
+     */
+    private String m_di;
+
+    /**
+     * The {@link Nullable} object or Default-Implementation instance if used.
+     */
+    private Object m_nullableObject;
+
+    /**
+     * The handler managing this dependency.
+     */
+    private PrimitiveHandler m_handler;
+
+    /**
+     * The timeout policy. Null injects null, {@link Nullable} injects a nullable object or
+     * an array with a nullable object, Default-Implementation injects an object
+     * created from the specified injected implementation or an array with it
+     * Empty array inject an empty array (must be an aggregate dependency) No
+     * policy (0) throw a runtime exception when the timeout occurs *
+     */
+    private int m_policy;
+
+    /**
+     * Constructor.
+     * @param spec service specification
+     * @param agg is the dependency aggregate ?
+     * @param filter LDAP filter
+     * @param context service context
+     * @param timeout timeout
+     * @param handler Handler managing this dependency
+     * @param defaultImpl class used as default-implementation
+     * @param policy onTimeout policy
+     */
+    public TemporalDependency(Class spec, boolean agg, Filter filter,
+            BundleContext context, long timeout, int policy,
+            String defaultImpl, TemporalHandler handler) {
+        super(spec, agg, true, filter, null,
+                DependencyModel.DYNAMIC_BINDING_POLICY, context, handler);
+        m_di = defaultImpl;
+        m_policy = policy;
+        m_timeout = timeout;
+        m_handler = handler;
+    }
+
+    /**
+     * The dependency has been reconfigured.
+     * @param arg0 new service references
+     * @param arg1 old service references
+     * @see org.apache.felix.ipojo.util.DependencyModel#onDependencyReconfiguration(org.osgi.framework.ServiceReference[],
+     *      org.osgi.framework.ServiceReference[])
+     */
+    public void onDependencyReconfiguration(ServiceReference[] arg0,
+            ServiceReference[] arg1) {
+        throw new UnsupportedOperationException(
+                "Reconfiguration not yet supported");
+    }
+
+    /**
+     * A provider arrives.
+     * @param arg0 service reference of the new provider.
+     * @see org.apache.felix.ipojo.util.DependencyModel#onServiceArrival(org.osgi.framework.ServiceReference)
+     */
+    public void onServiceArrival(ServiceReference arg0) {
+        // Notify if a thread is waiting.
+        synchronized (this) {
+            notifyAll();
+        }
+    }
+
+    /**
+     * A provider leaves. Nothing to do.
+     * @param arg0 leaving service references.
+     * @see org.apache.felix.ipojo.util.DependencyModel#onServiceDeparture(org.osgi.framework.ServiceReference)
+     */
+    public synchronized void onServiceDeparture(ServiceReference arg0) {
+    }
+
+    /**
+     * The code require a value of the monitored field. If providers are
+     * available, the method return service object(s) immediately. Else, the
+     * thread is blocked until an arrival. If no provider arrives during the
+     * among of time specified, the method throws a Runtime Exception.
+     * @param arg0 POJO instance asking for the service
+     * @param arg1 field name
+     * @param arg2 previous value
+     * @return the object to inject.
+     * @see org.apache.felix.ipojo.FieldInterceptor#onGet(java.lang.Object, java.lang.String, java.lang.Object)
+     */
+    public synchronized Object onGet(Object arg0, String arg1, Object arg2) {
+        ServiceReference[] refs = getServiceReferences();
+        if (refs != null) {
+            // Immediate return.
+            if (isAggregate()) {
+                Object[] svc = (Object[]) Array.newInstance(getSpecification(),
+                        refs.length);
+                for (int i = 0; i < svc.length; i++) {
+                    svc[i] = getService(refs[i]);
+                }
+                return svc;
+            } else {
+                return getService(refs[0]);
+            }
+        } else {
+            // Begin to wait ...
+            long enter = System.currentTimeMillis();
+            boolean exhausted = false;
+            ServiceReference ref = null;
+            synchronized (this) {
+                while (getServiceReference() == null && !exhausted) {
+                    try {
+                        wait(1);
+                    } catch (InterruptedException e) {
+                        // We was interrupted ....
+                    } finally {
+                        long end = System.currentTimeMillis();
+                        exhausted = (end - enter) > m_timeout;
+                    }
+                }
+            }
+            // Check
+            if (exhausted) {
+                return onTimeout();
+            } else {
+                ref = getServiceReference();
+                if (isAggregate()) {
+                    Object[] svc = (Object[]) Array.newInstance(
+                            getSpecification(), 1);
+                    svc[0] = getService(ref);
+                    return svc;
+                } else {
+                    return getService(ref);
+                }
+            }
+        }
+    }
+
+    /**
+     * Start method. Initializes the nullable object.
+     * @see org.apache.felix.ipojo.util.DependencyModel#start()
+     */
+    public void start() {
+        super.start();
+        switch (m_policy) {
+            case TemporalHandler.NULL:
+                m_nullableObject = null;
+                break;
+            case TemporalHandler.NULLABLE:
+                // To load the proxy we use the POJO class loader. Indeed, this
+                // classloader imports iPOJO (so can access to Nullable) and has
+                // access to the service specification.
+                try {
+                    m_nullableObject = Proxy.newProxyInstance(m_handler
+                            .getInstanceManager().getClazz().getClassLoader(),
+                            new Class[] { getSpecification(), Nullable.class },
+                            new NullableObject()); // NOPMD
+                    if (isAggregate()) {
+                        Object[] array = (Object[]) Array.newInstance(
+                                getSpecification(), 1);
+                        array[0] = m_nullableObject;
+                        m_nullableObject = array;
+                    }
+                } catch (NoClassDefFoundError e) {
+                    // A NoClassDefFoundError is thrown if the specification
+                    // uses a
+                    // class not accessible by the actual instance.
+                    // It generally comes from a missing import.
+                    throw new IllegalStateException(
+                            "Cannot create the Nullable object, a referenced class cannot be loaded: "
+                                    + e.getMessage());
+                }
+
+                break;
+            case TemporalHandler.DEFAULT_IMPLEMENTATION:
+                // Create the default-implementation object.
+                try {
+                    Class clazz = m_handler.getInstanceManager().getContext()
+                            .getBundle().loadClass(m_di);
+                    m_nullableObject = clazz.newInstance();
+                } catch (IllegalAccessException e) {
+                    throw new IllegalStateException(
+                            "Cannot load the default-implementation " + m_di
+                                    + " : " + e.getMessage());
+                } catch (InstantiationException e) {
+                    throw new IllegalStateException(
+                            "Cannot load the default-implementation " + m_di
+                                    + " : " + e.getMessage());
+                } catch (ClassNotFoundException e) {
+                    throw new IllegalStateException(
+                            "Cannot load the default-implementation " + m_di
+                                    + " : " + e.getMessage());
+                }
+                if (isAggregate()) {
+                    Object[] array = (Object[]) Array.newInstance(
+                            getSpecification(), 1);
+                    array[0] = m_nullableObject;
+                    m_nullableObject = array;
+                }
+                break;
+            case TemporalHandler.EMPTY_ARRAY:
+                m_nullableObject = Array.newInstance(getSpecification(), 0);
+                break;
+            default: // Cannot occurs
+                break;
+        }
+    }
+
+    /**
+     * Stop method. Just releases the reference on the nullable object.
+     * @see org.apache.felix.ipojo.util.DependencyModel#stop()
+     */
+    public void stop() {
+        super.stop();
+        m_nullableObject = null;
+    }
+
+    /**
+     * The monitored field receives a value. Nothing to do.
+     * @param arg0 POJO setting the value.
+     * @param arg1 field name
+     * @param arg2 received value
+     * @see org.apache.felix.ipojo.FieldInterceptor#onSet(java.lang.Object, java.lang.String, java.lang.Object)
+     */
+    public void onSet(Object arg0, String arg1, Object arg2) {
+    }
+
+    /**
+     * Implements the timeout policy according to the specified configuration.
+     * @return the object to return when the timeout occurs.
+     */
+    private Object onTimeout() {
+        switch (m_policy) {
+            case TemporalHandler.NULL:
+            case TemporalHandler.NULLABLE:
+            case TemporalHandler.DEFAULT_IMPLEMENTATION:
+            case TemporalHandler.EMPTY_ARRAY:
+                return m_nullableObject;
+            default:
+                // Throws a runtime exception
+                throw new RuntimeException("Service "
+                        + getSpecification().getName()
+                        + " unavailable : timeout");
+        }
+    }
+
+}

Modified: felix/trunk/ipojo/handler/temporal/src/main/java/org/apache/felix/ipojo/handler/temporal/TemporalHandler.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/handler/temporal/src/main/java/org/apache/felix/ipojo/handler/temporal/TemporalHandler.java?rev=702202&r1=702201&r2=702202&view=diff
==============================================================================
--- felix/trunk/ipojo/handler/temporal/src/main/java/org/apache/felix/ipojo/handler/temporal/TemporalHandler.java (original)
+++ felix/trunk/ipojo/handler/temporal/src/main/java/org/apache/felix/ipojo/handler/temporal/TemporalHandler.java Mon Oct  6 10:08:45 2008
@@ -1,197 +1,196 @@
-/* 
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements.  See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership.  The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License.  You may obtain a copy of the License at
- *
- *   http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied.  See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.felix.ipojo.handler.temporal;
-
-import java.util.ArrayList;
-import java.util.Dictionary;
-import java.util.List;
-
-import org.apache.felix.ipojo.ConfigurationException;
-import org.apache.felix.ipojo.PrimitiveHandler;
-import org.apache.felix.ipojo.metadata.Element;
-import org.apache.felix.ipojo.parser.FieldMetadata;
-import org.apache.felix.ipojo.parser.PojoMetadata;
-import org.apache.felix.ipojo.util.DependencyModel;
-import org.apache.felix.ipojo.util.DependencyStateListener;
-import org.osgi.framework.Filter;
-import org.osgi.framework.InvalidSyntaxException;
-
-/**
-* Temporal dependency handler.
-* A temporal dependency waits (block) for the availability of the service.
-* If no provider arrives in the specified among of time, a runtime exception is thrown.
-* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
-*/
-public class TemporalHandler extends PrimitiveHandler implements DependencyStateListener {
-    
-    /**
-     * Default timeout if not specified.
-     */
-    public static final int DEFAULT_TIMEOUT = 3000;
-    
-    /**
-     * No policy.
-     */
-    public static final int NO_POLICY = 0;
-    /**
-     * Use a nullable object.
-     */
-    public static final int NULLABLE = 1;
-    /**
-     * Use a default-implementation object.
-     */
-    public static final int DEFAULT_IMPLEMENTATION = 2;
-    /**
-     * Use an empty array.
-     */
-    public static final int EMPTY_ARRAY = 3;
-    /**
-     * Use null. 
-     */
-    public static final int NULL = 4;
-    
-    /**
-     * Handler namespace.
-     */
-    public static final String NAMESPACE = "org.apache.felix.ipojo.handler.temporal";
-    
-    /**
-     * List of managed dependencies.
-     */
-    private List/*<deps>*/ m_dependencies = new ArrayList(1);
-
-    /**
-     * Start method. Starts managed dependencies.
-     * @see org.apache.felix.ipojo.Handler#start()
-     */
-    public void start() {
-        for (int i = 0; i < m_dependencies.size(); i++) {
-            ((TemporalDependency) m_dependencies.get(i)).start();
-        }
-    }
-    
-    /**
-     * Stop  method. Stops managed dependencies.
-     * @see org.apache.felix.ipojo.Handler#stop()
-     */
-    public void stop() {
-        for (int i = 0; i < m_dependencies.size(); i++) {
-            ((TemporalDependency) m_dependencies.get(i)).stop();
-        }
-        m_dependencies.clear();
-    }
-
-    /**
-     * Configure method.
-     * Create managed dependencies.
-     * @param meta : component type metadata.
-     * @param dictionary : instance configuration.
-     * @throws ConfigurationException : the dependency is not configured correctly
-     * @see org.apache.felix.ipojo.Handler#configure(org.apache.felix.ipojo.metadata.Element, java.util.Dictionary)
-     */
-    public void configure(Element meta, Dictionary dictionary) throws ConfigurationException {
-        PojoMetadata manipulation = getFactory().getPojoMetadata();
-        Element[] deps = meta.getElements("requires", NAMESPACE);
-        for (int i = 0; i < deps.length; i++) {
-            if (!deps[i].containsAttribute("field") || m_dependencies.contains(deps[i].getAttribute("field"))) {
-                error("One temporal dependency must be attached to a field or the field is already used");
-                return;
-            }
-            String field = deps[i].getAttribute("field");
-
-            FieldMetadata fieldmeta = manipulation.getField(field);
-            if (fieldmeta == null) {
-                error("The field " + field + " does not exist in the class " + getInstanceManager().getClassName());
-                return;
-            }             
-                        
-            String fil = deps[i].getAttribute("filter");
-            Filter filter = null; 
-            if (fil != null) {
-                try {
-                    filter = getInstanceManager().getContext().createFilter(fil);
-                } catch (InvalidSyntaxException e) {
-                    error("Cannot create the field from " + fil + ": " + e.getMessage());
-                    return;
-                }
-            }
-            
-            boolean agg = false;
-            String spec = fieldmeta.getFieldType();
-            if (spec.endsWith("[]")) {
-                agg = true;
-                spec = spec.substring(0, spec.length() - 2);
-            }
-            
-            long timeout = DEFAULT_TIMEOUT;
-            if (deps[i].containsAttribute("timeout")) {
-                String to = deps[i].getAttribute("timeout");
-                if (to.equalsIgnoreCase("infinite")  || to.equalsIgnoreCase("-1")) {
-                    timeout = Long.MAX_VALUE; // Infinite wait time ...
-                } else {
-                    timeout = new Long(deps[i].getAttribute("timeout")).longValue();
-                }
-            }
-            
-            int policy = NO_POLICY;
-            String di = null;
-            String onTimeout = deps[i].getAttribute("onTimeout");
-            if (onTimeout != null) {
-                if (onTimeout.equalsIgnoreCase("nullable")) {
-                    policy = NULLABLE;
-                } else if (onTimeout.equalsIgnoreCase("empty-array")) {
-                    policy = EMPTY_ARRAY;
-                    if (! agg) {
-                        // The empty array policy can only be used on aggregate dependencies
-                        error("Cannot use the empty array policy for " + field + " : non aggregate dependency.");
-                    }
-                } else if (onTimeout.equalsIgnoreCase("null")) {
-                    policy = NULL;
-                } else if (onTimeout.length() > 0) {
-                    di = onTimeout;
-                    policy = DEFAULT_IMPLEMENTATION;
-                }
-            }
-         
-            Class specification = DependencyModel.loadSpecification(spec, getInstanceManager().getContext());
-            TemporalDependency dep = new TemporalDependency(specification, agg, filter, getInstanceManager().getContext(), timeout, policy, di, this);
-            m_dependencies.add(dep);
-            
-            getInstanceManager().register(fieldmeta, dep);
-        }        
-    }
-
-    /**
-     * Nothing to do.
-     * A temporal dependency is always valid.
-     * @param dependencymodel : dependency.
-     * @see org.apache.felix.ipojo.util.DependencyStateListener#invalidate(org.apache.felix.ipojo.util.DependencyModel)
-     */
-    public void invalidate(DependencyModel dependencymodel) {    }
-
-    /**
-     * Nothing to do.
-     * A temporal dependency is always valid.
-     * @param dependencymodel : dependency.
-     * @see org.apache.felix.ipojo.util.DependencyStateListener#validate(org.apache.felix.ipojo.util.DependencyModel)
-     */
-    public void validate(DependencyModel dependencymodel) {    }
-    
-
-}
+/* 
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.felix.ipojo.handler.temporal;
+
+import java.util.ArrayList;
+import java.util.Dictionary;
+import java.util.List;
+
+import org.apache.felix.ipojo.ConfigurationException;
+import org.apache.felix.ipojo.PrimitiveHandler;
+import org.apache.felix.ipojo.metadata.Element;
+import org.apache.felix.ipojo.parser.FieldMetadata;
+import org.apache.felix.ipojo.parser.PojoMetadata;
+import org.apache.felix.ipojo.util.DependencyModel;
+import org.apache.felix.ipojo.util.DependencyStateListener;
+import org.osgi.framework.Filter;
+import org.osgi.framework.InvalidSyntaxException;
+
+/**
+* Temporal dependency handler.
+* A temporal dependency waits (block) for the availability of the service.
+* If no provider arrives in the specified among of time, a runtime exception is thrown.
+* @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+*/
+public class TemporalHandler extends PrimitiveHandler implements DependencyStateListener {
+    
+    /**
+     * Default timeout if not specified.
+     */
+    public static final int DEFAULT_TIMEOUT = 3000;
+    
+    /**
+     * No policy.
+     */
+    public static final int NO_POLICY = 0;
+    /**
+     * Uses a nullable object.
+     */
+    public static final int NULLABLE = 1;
+    /**
+     * Uses a default-implementation object.
+     */
+    public static final int DEFAULT_IMPLEMENTATION = 2;
+    /**
+     * Uses an empty array.
+     */
+    public static final int EMPTY_ARRAY = 3;
+    /**
+     * Uses {@code null}. 
+     */
+    public static final int NULL = 4;
+    
+    /**
+     * The handler namespace.
+     */
+    public static final String NAMESPACE = "org.apache.felix.ipojo.handler.temporal";
+    
+    /**
+     * The list of managed dependencies.
+     */
+    private List/*<deps>*/ m_dependencies = new ArrayList(1);
+
+    /**
+     * Start method. Starts managed dependencies.
+     * @see org.apache.felix.ipojo.Handler#start()
+     */
+    public void start() {
+        for (int i = 0; i < m_dependencies.size(); i++) {
+            ((TemporalDependency) m_dependencies.get(i)).start();
+        }
+    }
+    
+    /**
+     * Stop method. Stops managed dependencies.
+     * @see org.apache.felix.ipojo.Handler#stop()
+     */
+    public void stop() {
+        for (int i = 0; i < m_dependencies.size(); i++) {
+            ((TemporalDependency) m_dependencies.get(i)).stop();
+        }
+        m_dependencies.clear();
+    }
+
+    /**
+     * Configure method. Creates managed dependencies.
+     * @param meta the component type metadata.
+     * @param dictionary the instance configuration.
+     * @throws ConfigurationException if the dependency is not configured correctly
+     * @see org.apache.felix.ipojo.Handler#configure(org.apache.felix.ipojo.metadata.Element, java.util.Dictionary)
+     */
+    public void configure(Element meta, Dictionary dictionary) throws ConfigurationException {
+        PojoMetadata manipulation = getFactory().getPojoMetadata();
+        Element[] deps = meta.getElements("requires", NAMESPACE);
+        for (int i = 0; i < deps.length; i++) {
+            if (!deps[i].containsAttribute("field") || m_dependencies.contains(deps[i].getAttribute("field"))) {
+                error("One temporal dependency must be attached to a field or the field is already used");
+                return;
+            }
+            String field = deps[i].getAttribute("field");
+
+            FieldMetadata fieldmeta = manipulation.getField(field);
+            if (fieldmeta == null) {
+                error("The field " + field + " does not exist in the class " + getInstanceManager().getClassName());
+                return;
+            }             
+                        
+            String fil = deps[i].getAttribute("filter");
+            Filter filter = null; 
+            if (fil != null) {
+                try {
+                    filter = getInstanceManager().getContext().createFilter(fil);
+                } catch (InvalidSyntaxException e) {
+                    error("Cannot create the field from " + fil + ": " + e.getMessage());
+                    return;
+                }
+            }
+            
+            boolean agg = false;
+            String spec = fieldmeta.getFieldType();
+            if (spec.endsWith("[]")) {
+                agg = true;
+                spec = spec.substring(0, spec.length() - 2);
+            }
+            
+            long timeout = DEFAULT_TIMEOUT;
+            if (deps[i].containsAttribute("timeout")) {
+                String to = deps[i].getAttribute("timeout");
+                if (to.equalsIgnoreCase("infinite")  || to.equalsIgnoreCase("-1")) {
+                    timeout = Long.MAX_VALUE; // Infinite wait time ...
+                } else {
+                    timeout = new Long(deps[i].getAttribute("timeout")).longValue();
+                }
+            }
+            
+            int policy = NO_POLICY;
+            String di = null;
+            String onTimeout = deps[i].getAttribute("onTimeout");
+            if (onTimeout != null) {
+                if (onTimeout.equalsIgnoreCase("nullable")) {
+                    policy = NULLABLE;
+                } else if (onTimeout.equalsIgnoreCase("empty-array")) {
+                    policy = EMPTY_ARRAY;
+                    if (! agg) {
+                        // The empty array policy can only be used on aggregate dependencies
+                        error("Cannot use the empty array policy for " + field + " : non aggregate dependency.");
+                    }
+                } else if (onTimeout.equalsIgnoreCase("null")) {
+                    policy = NULL;
+                } else if (onTimeout.length() > 0) {
+                    di = onTimeout;
+                    policy = DEFAULT_IMPLEMENTATION;
+                }
+            }
+         
+            Class specification = DependencyModel.loadSpecification(spec, getInstanceManager().getContext());
+            TemporalDependency dep = new TemporalDependency(specification, agg, filter, getInstanceManager().getContext(), timeout, policy, di, this);
+            m_dependencies.add(dep);
+            
+            getInstanceManager().register(fieldmeta, dep);
+        }        
+    }
+
+    /**
+     * Nothing to do.
+     * A temporal dependency is always valid.
+     * @param dependencymodel dependency.
+     * @see org.apache.felix.ipojo.util.DependencyStateListener#invalidate(org.apache.felix.ipojo.util.DependencyModel)
+     */
+    public void invalidate(DependencyModel dependencymodel) {    }
+
+    /**
+     * Nothing to do.
+     * A temporal dependency is always valid.
+     * @param dependencymodel dependency.
+     * @see org.apache.felix.ipojo.util.DependencyStateListener#validate(org.apache.felix.ipojo.util.DependencyModel)
+     */
+    public void validate(DependencyModel dependencymodel) {    }
+    
+
+}