Fix issue Felix-866
The 'interface attribute of the 'provides' element becomes 'specifications' The semantic doesn't change.

Fix issue Felix-867
The ServiceProperty annotation was able to target Method. However this is not possible. Service properties can only be attached to fields.

Fix issue Felix-868
The Component annontation did'nt support the factory methods. So, the 'factory_method' attribute was added to support the configuration of factory methods.



git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@729971 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/core/src/main/java/org/apache/felix/ipojo/architecture/InstanceDescription.java b/ipojo/core/src/main/java/org/apache/felix/ipojo/architecture/InstanceDescription.java
index 02df5e0..e7b0c59 100644
--- a/ipojo/core/src/main/java/org/apache/felix/ipojo/architecture/InstanceDescription.java
+++ b/ipojo/core/src/main/java/org/apache/felix/ipojo/architecture/InstanceDescription.java
@@ -60,7 +60,7 @@
     private ComponentTypeDescription m_type;
 
     /**
-     * COntained instance list.
+     * Contained instance list.
      */
     private InstanceDescription[] m_containedInstances = new InstanceDescription[0];
 
diff --git a/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedService.java b/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedService.java
index 92d80d0..58f8091 100644
--- a/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedService.java
+++ b/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedService.java
@@ -62,23 +62,23 @@
     /**
      * Factory Policy : SINGLETON_FACTORY.
      */
-    public static final int SINGLETON_FACTORY = 0;
+    public static final int SINGLETON_STRATEGY = 0;
 
     /**
      * Factory policy : SERVICE_FACTORY.
      */
-    public static final int SERVICE_FACTORY = 1;
+    public static final int SERVICE_STRATEGY = 1;
     
     /**
      * Factory policy : STATIC_FACTORY.
      */
-    public static final int STATIC_FACTORY = 2;
+    public static final int STATIC_STRATEGY = 2;
     
     /**
      * Factory policy : INSTANCE.
      * Creates one service object per instance consuming the service.
      */
-    public static final int INSTANCE = 3;
+    public static final int INSTANCE_STRATEGY = 3;
 
     /**
      * At this time, it is only the java interface full name.
@@ -86,11 +86,6 @@
     private String[] m_serviceSpecification = new String[0];
 
     /**
-     * Factory policy.
-     */
-    private int m_factoryPolicy = SINGLETON_FACTORY;
-
-    /**
      * The service registration. is null when the service is not registered.
      * m_serviceRegistration : ServiceRegistration
      */
@@ -123,7 +118,6 @@
         m_handler = handler;
 
         m_serviceSpecification = specification;
-        m_factoryPolicy = factoryPolicy;
         
         // Add instance name & factory name
         try {
@@ -153,17 +147,17 @@
                 return;
             }
         } else {
-            switch (m_factoryPolicy) {
-                case SINGLETON_FACTORY:
+            switch (factoryPolicy) {
+                case SINGLETON_STRATEGY:
                     m_strategy = new SingletonStrategy();
                     break;
-                case SERVICE_FACTORY:
-                case STATIC_FACTORY:
+                case SERVICE_STRATEGY:
+                case STATIC_STRATEGY:
                     // In this case, we need to try to create a new pojo object,
                     // the factory method will handle the creation.
                     m_strategy = new FactoryStrategy();
                     break;
-                case INSTANCE:
+                case INSTANCE_STRATEGY:
                     m_strategy = new PerInstanceStrategy();
                     break;
                 // Other policies:
@@ -174,7 +168,7 @@
                     m_handler.error("["
                             + m_handler.getInstanceManager().getInstanceName()
                             + "] Unknown creation policy for " + specs + " : "
-                            + m_factoryPolicy);
+                            + factoryPolicy);
                     getInstanceManager().stop();
                     break;
             }
@@ -394,7 +388,7 @@
      * @return the list of provided service specifications (i.e. java
      * interface).
      */
-    public String[] getServiceSpecification() {
+    public String[] getServiceSpecifications() {
         return m_serviceSpecification;
     }
 
diff --git a/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceHandler.java b/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceHandler.java
index 93d19bd..587701d 100644
--- a/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceHandler.java
+++ b/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceHandler.java
@@ -82,7 +82,7 @@
      * Get the array of provided service.
      * @return the list of the provided service.
      */
-    public ProvidedService[] getProvidedService() {
+    public ProvidedService[] getProvidedServices() {
         return m_providedServices;
     }
 
@@ -98,22 +98,24 @@
         // Create the dependency according to the component metadata
         Element[] providedServices = componentMetadata.getElements("Provides");
         for (int i = 0; i < providedServices.length; i++) {
-            String[] serviceSpecifications = ParseUtils.parseArrays(providedServices[i].getAttribute("interface")); // Set by the initialize component factory.
-            
+            String[] serviceSpecifications = ParseUtils.parseArrays(providedServices[i].getAttribute("specifications")); // Set by the initialize component factory.
+
             // Get the factory policy
-            int factory = ProvidedService.SINGLETON_FACTORY;
+            int factory = ProvidedService.SINGLETON_STRATEGY;
             Class custom = null;
             String strategy = providedServices[i].getAttribute("strategy");
             if (strategy == null) {
                 strategy = providedServices[i].getAttribute("factory");
             }
             if (strategy != null) {
-                if ("service".equalsIgnoreCase(strategy)) {
-                    factory = ProvidedService.SERVICE_FACTORY;
+                if ("singleton".equalsIgnoreCase(strategy)) {
+                    factory = ProvidedService.SINGLETON_STRATEGY;
+                } else if ("service".equalsIgnoreCase(strategy)) {
+                    factory = ProvidedService.SERVICE_STRATEGY;
                 } else if ("method".equalsIgnoreCase(strategy)) {
-                    factory = ProvidedService.STATIC_FACTORY;
+                    factory = ProvidedService.STATIC_STRATEGY;
                 } else if ("instance".equalsIgnoreCase(strategy)) {
-                    factory = ProvidedService.INSTANCE;
+                    factory = ProvidedService.INSTANCE_STRATEGY;
                 } else {
                     // Customized policy
                     try {
@@ -245,8 +247,8 @@
      * @throws ConfigurationException : the checked provided service is not correct.
      */
     private boolean checkProvidedService(ProvidedService svc) throws ConfigurationException {        
-        for (int i = 0; i < svc.getServiceSpecification().length; i++) {
-            String specName = svc.getServiceSpecification()[i];
+        for (int i = 0; i < svc.getServiceSpecifications().length; i++) {
+            String specName = svc.getServiceSpecifications()[i];
             
             // Check service level dependencies
             try {
@@ -265,18 +267,18 @@
                         isDependencyCorrect(dep, deps[j]);
                     }
                 } else {
-                    throw new ConfigurationException("Service Providing: The specification field of the service specification " + svc.getServiceSpecification()[i] + " needs to be a String");
+                    throw new ConfigurationException("Service Providing: The specification field of the service specification " + svc.getServiceSpecifications()[i] + " needs to be a String");
                 }
             } catch (NoSuchFieldException e) {
                 return true; // No specification field
             } catch (ClassNotFoundException e) {
-                throw new ConfigurationException("Service Providing: The service specification " + svc.getServiceSpecification()[i] + " cannot be load");
+                throw new ConfigurationException("Service Providing: The service specification " + svc.getServiceSpecifications()[i] + " cannot be load");
             } catch (IllegalArgumentException e) {
-                throw new ConfigurationException("Service Providing: The field 'specification' of the service specification " + svc.getServiceSpecification()[i] + " is not accessible : " + e.getMessage());
+                throw new ConfigurationException("Service Providing: The field 'specification' of the service specification " + svc.getServiceSpecifications()[i] + " is not accessible : " + e.getMessage());
             } catch (IllegalAccessException e) {
-                throw new ConfigurationException("Service Providing: The field 'specification' of the service specification " + svc.getServiceSpecification()[i] + " is not accessible : " + e.getMessage());
+                throw new ConfigurationException("Service Providing: The field 'specification' of the service specification " + svc.getServiceSpecifications()[i] + " is not accessible : " + e.getMessage());
             } catch (ParseException e) {
-                throw new ConfigurationException("Service Providing: The field 'specification' of the service specification " + svc.getServiceSpecification()[i] + " does not contain a valid String : " + e.getMessage());
+                throw new ConfigurationException("Service Providing: The field 'specification' of the service specification " + svc.getServiceSpecifications()[i] + " does not contain a valid String : " + e.getMessage());
             }
         }
 
@@ -466,9 +468,9 @@
     public HandlerDescription getDescription() {
         ProvidedServiceHandlerDescription pshd = new ProvidedServiceHandlerDescription(this);
 
-        for (int j = 0; j < getProvidedService().length; j++) {
-            ProvidedService svc = getProvidedService()[j];
-            ProvidedServiceDescription psd = new ProvidedServiceDescription(svc.getServiceSpecification(), svc.getState(), svc.getServiceReference());
+        for (int j = 0; j < getProvidedServices().length; j++) {
+            ProvidedService svc = getProvidedServices()[j];
+            ProvidedServiceDescription psd = new ProvidedServiceDescription(svc.getServiceSpecifications(), svc.getState(), svc.getServiceReference());
 
             Properties props = new Properties();
             for (int k = 0; k < svc.getProperties().length; k++) {
@@ -489,8 +491,8 @@
      * @see org.apache.felix.ipojo.Handler#reconfigure(java.util.Dictionary)
      */
     public void reconfigure(Dictionary dict) {
-        for (int j = 0; j < getProvidedService().length; j++) {
-            ProvidedService svc = getProvidedService()[j];
+        for (int j = 0; j < getProvidedServices().length; j++) {
+            ProvidedService svc = getProvidedServices()[j];
             Property[] props = svc.getProperties();
             boolean update = false;
             for (int k = 0; k < props.length; k++) {
@@ -528,7 +530,14 @@
                 throw new ConfigurationException("An interface cannot be loaded : " + e.getMessage());
             }
             
-            String serviceSpecificationStr = provides[i].getAttribute("interface");
+            String serviceSpecificationStr = provides[i].getAttribute("specifications");
+            if (serviceSpecificationStr == null) {
+                serviceSpecificationStr = provides[i].getAttribute("interface");
+                if (serviceSpecificationStr != null) {
+                    warn("The 'interface' attribute is deprecated, use the 'specifications' attribute instead of 'interface'");
+                }
+            }
+
             if (serviceSpecificationStr != null) {
                 List itfs = ParseUtils.parseArraysAsList(serviceSpecificationStr);
                 for (int j = 0; j < itfs.size(); j++) {
@@ -559,7 +568,7 @@
             }
             
             specs.append('}');
-            provides[i].addAttribute(new Attribute("interface", specs.toString())); // Add interface attribute to avoid checking in the configure method
+            provides[i].addAttribute(new Attribute("specifications", specs.toString())); // Add interface attribute to avoid checking in the configure method
 
             Element[] props = provides[i].getElements("property");
             for (int j = 0; props != null && j < props.length; j++) {
diff --git a/ipojo/core/src/main/resources/core.xsd b/ipojo/core/src/main/resources/core.xsd
index 9bb7014..3099b8e 100644
--- a/ipojo/core/src/main/resources/core.xsd
+++ b/ipojo/core/src/main/resources/core.xsd
@@ -319,9 +319,13 @@
 					<xs:documentation>List of service specific properties.</xs:documentation>
 				</xs:annotation></xs:element>
 		</xs:sequence>
-		<xs:attribute name="interface" type="xs:string" use="optional">
+		<xs:attribute name="interface" type="xs:string" use="prohibited">
 			<xs:annotation>
-				<xs:documentation>The list of interfaces of the service to expose. By default, all interfaces implemented by the component implementation class are published.</xs:documentation>
+				<xs:documentation>Deprecated attribute, use 'specifications' instead of 'interface'</xs:documentation>
+			</xs:annotation></xs:attribute>
+		<xs:attribute name="specifications" type="xs:string" use="optional">
+			<xs:annotation>
+				<xs:documentation>The list of service specifications (i.e. interfaces) to expose. By default, all interfaces implemented by the component implementation class are published.</xs:documentation>
 			</xs:annotation></xs:attribute>
 		<xs:attribute name="factory" type="xs:string" use="prohibited">
 			<xs:annotation>
diff --git a/ipojo/core/src/main/resources/metadata.xml b/ipojo/core/src/main/resources/metadata.xml
index 6e49d69..2ba587c 100644
--- a/ipojo/core/src/main/resources/metadata.xml
+++ b/ipojo/core/src/main/resources/metadata.xml
@@ -40,7 +40,7 @@
 	<handler

 		classname="org.apache.felix.ipojo.handlers.architecture.ArchitectureHandler"

 		name="architecture" architecture="false">

-		<provides interface="org.apache.felix.ipojo.architecture.Architecture">

+		<provides specifications="org.apache.felix.ipojo.architecture.Architecture">

 			<property field="m_name" name="architecture.instance"/>

 		</provides>

 	</handler>