Fix issue FELIX-2132
Provides Service Controller (XSD, Annotation, API, Core and Tests)
Also update several tests to the new pax exam.
git-svn-id: https://svn.apache.org/repos/asf/felix/trunk@915909 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/ipojo/annotations/src/main/java/org/apache/felix/ipojo/annotations/ServiceController.java b/ipojo/annotations/src/main/java/org/apache/felix/ipojo/annotations/ServiceController.java
new file mode 100644
index 0000000..06e238e
--- /dev/null
+++ b/ipojo/annotations/src/main/java/org/apache/felix/ipojo/annotations/ServiceController.java
@@ -0,0 +1,36 @@
+/*
+ * 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.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Target;
+
+/**
+ * This annotation declares a service controller.
+ * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
+ */
+@Target(ElementType.FIELD)
+public @interface ServiceController {
+
+ /**
+ * Sets the initial value of the controller.
+ */
+ boolean value() default true;
+
+}
diff --git a/ipojo/api/src/main/java/org/apache/felix/ipojo/api/Service.java b/ipojo/api/src/main/java/org/apache/felix/ipojo/api/Service.java
index 3ce062e..10ffd66 100644
--- a/ipojo/api/src/main/java/org/apache/felix/ipojo/api/Service.java
+++ b/ipojo/api/src/main/java/org/apache/felix/ipojo/api/Service.java
@@ -76,6 +76,16 @@
private List m_properties = new ArrayList();
/**
+ * Service controller.
+ */
+ private String m_controller;
+
+ /**
+ * Service Controller value.
+ */
+ private boolean m_controllerValue;
+
+ /**
* Gets the provided service element.
* @return the 'provides' element.
*/
@@ -89,6 +99,14 @@
for (int i = 0; i < m_properties.size(); i++) {
element.addElement(((ServiceProperty) m_properties.get(i)).getElement());
}
+
+ if (m_controller != null) {
+ Element ctrl = new Element("controller", "");
+ ctrl.addAttribute(new Attribute("field", m_controller));
+ ctrl.addAttribute(new Attribute("value", String.valueOf(m_controllerValue)));
+ element.addElement(ctrl);
+ }
+
return element;
}
@@ -208,6 +226,19 @@
}
/**
+ * Sets the service controller.
+ * @param field the controller field
+ * @param initialValue the initial value
+ * @return the current servic object
+ */
+ public Service setServiceController(String field,
+ boolean initialValue) {
+ m_controller = field;
+ m_controllerValue = initialValue;
+ return this;
+ }
+
+ /**
* Gets the string-form of the creation strategy.
* @return the creation strategy string form
*/
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 fa2fef8..559b2c2 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
@@ -112,6 +112,11 @@
* Were the properties updated during the processing.
*/
private volatile boolean m_wasUpdated;
+
+ /**
+ * Service Controller.
+ */
+ private ServiceController m_controller;
/**
* Creates a provided service object.
@@ -311,7 +316,8 @@
* This method also notifies the creation strategy of the publication.
*/
protected synchronized void registerService() {
- if (m_serviceRegistration == null) {
+ if (m_handler.getInstanceManager().getState() == ComponentInstance.VALID
+ && m_serviceRegistration == null && (m_controller == null || m_controller.getValue())) {
// Build the service properties list
BundleContext bc = m_handler.getInstanceManager().getContext();
@@ -450,6 +456,67 @@
}
/**
+ * Sets the service controller on this provided service.
+ * @param field the field attached to this controller
+ * @param value the value the initial value
+ */
+ public void setController(String field, boolean value) {
+ m_controller = new ServiceController(field, value);
+ }
+
+ public ServiceController getController() {
+ return m_controller;
+ }
+
+ /**
+ * Service Controller.
+ */
+ class ServiceController {
+ /**
+ * The controller value.
+ */
+ private volatile boolean m_value;
+ /**
+ * The field attached to this controller.
+ */
+ private final String m_field;
+
+ /**
+ * Creates a ServiceController.
+ * @param field the field
+ * @param value the initial value
+ */
+ public ServiceController(String field, boolean value) {
+ m_field = field;
+ m_value = value;
+ }
+
+ public String getField() {
+ return m_field;
+ }
+
+ public boolean getValue() {
+ synchronized (ProvidedService.this) {
+ return m_value;
+ }
+ }
+
+ public void setValue(Boolean value) {
+ synchronized (ProvidedService.this) {
+ if (value.booleanValue() != m_value) {
+ m_value = value.booleanValue();
+ if (m_value) {
+ registerService();
+ } else {
+ unregisterService();
+ }
+ }
+ }
+ }
+
+ }
+
+ /**
* Singleton creation strategy.
* This strategy just creates one service object and
* returns always the same.
diff --git a/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceDescription.java b/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceDescription.java
index ed17f32..f1f91c4 100644
--- a/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceDescription.java
+++ b/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceDescription.java
@@ -103,6 +103,14 @@
public int getState() {
return m_ps.getState();
}
+
+ public String getController() {
+ if (m_ps.getController() == null) {
+ return null;
+ } else {
+ return String.valueOf(m_ps.getController().getValue());
+ }
+ }
/**
* Gets the service reference.
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 00cc4d2..547fd35 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
@@ -161,13 +161,32 @@
if (field != null) {
getInstanceManager().register(new FieldMetadata(field, type), this);
- // Cannot register the property as the interception is necessary to deal with registration update.
+ // Cannot register the property as the interception is necessary
+ // to deal with registration update.
}
}
// Attach to properties to the provided service
svc.setProperties(properties);
}
+
+ Element[] controllers = providedServices[i].getElements("Controller");
+ if (controllers != null) {
+ if (controllers.length > 1) {
+ throw new ConfigurationException("Cannot have several controller per 'provides' element");
+ }
+
+ String field = controllers[0].getAttribute("field");
+ if (field == null) {
+ throw new ConfigurationException("The field attribute of a controller is mandatory");
+ }
+
+ String v = controllers[0].getAttribute("value");
+ boolean value = ! (v != null && v.equalsIgnoreCase("false"));
+ svc.setController(field, value);
+
+ getInstanceManager().register(new FieldMetadata(field, "boolean"), this);
+ }
if (checkProvidedService(svc)) {
addProvidedService(svc);
@@ -392,6 +411,13 @@
if (update) {
svc.update();
}
+ if (svc.getController() != null && svc.getController().getField().equals(fieldName) ) {
+ if (value instanceof Boolean) {
+ svc.getController().setValue((Boolean) value);
+ } else {
+ warn ("Boolean value expected for the service controler " + fieldName);
+ }
+ }
}
// Else do nothing
}
@@ -416,6 +442,9 @@
return prop.onGet(pojo, fieldName, value);
}
}
+ if (svc.getController() != null && svc.getController().getField().equals(fieldName) ) {
+ return new Boolean(svc.getController().getValue());
+ }
}
// Else it is not a property
return value;
diff --git a/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceHandlerDescription.java b/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceHandlerDescription.java
index 7298cd9..fa080f9 100644
--- a/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceHandlerDescription.java
+++ b/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/providedservice/ProvidedServiceHandlerDescription.java
@@ -82,11 +82,13 @@
if (m_providedServices[i].getState() == ProvidedService.REGISTERED) {
service.addAttribute(new Attribute("state", "registered"));
- service.addAttribute(new Attribute("service.id", m_providedServices[i].getServiceReference().getProperty(Constants.SERVICE_ID).toString()));
+ service.addAttribute(new Attribute("service.id", m_providedServices[i].getServiceReference()
+ .getProperty(Constants.SERVICE_ID).toString()));
} else {
service.addAttribute(new Attribute("state", "unregistered"));
}
+ // Service Properties.
Properties props = m_providedServices[i].getProperties();
Iterator iterator = props.keySet().iterator();
while (iterator.hasNext()) {
@@ -101,6 +103,14 @@
}
service.addElement(prop);
}
+
+ // Service Controller.
+ if (m_providedServices[i].getController() != null) {
+ Element controller = new Element("controller", null);
+ controller.addAttribute(new Attribute("value", m_providedServices[i].getController()));
+ service.addElement(controller);
+ }
+
services.addElement(service);
}
return services;
diff --git a/ipojo/core/src/main/resources/core.xsd b/ipojo/core/src/main/resources/core.xsd
index 5d51779..c330d80 100644
--- a/ipojo/core/src/main/resources/core.xsd
+++ b/ipojo/core/src/main/resources/core.xsd
@@ -18,262 +18,289 @@
-->
<xs:schema elementFormDefault="qualified" targetNamespace="org.apache.felix.ipojo"
xmlns="org.apache.felix.ipojo" xmlns:xs="http://www.w3.org/2001/XMLSchema">
- <xs:annotation>
- <xs:documentation>iPOJO Core XML-Schema. This grammars models iPOJO descriptor using core features. It provides several extensibility mechanism in order to compose this schema with external handlers and other component implementation type such as compositions.</xs:documentation></xs:annotation>
- <xs:element name="ipojo">
+ <xs:annotation>
+ <xs:documentation>iPOJO Core XML-Schema. This grammars models iPOJO descriptor using core
+ features. It provides several extensibility mechanism in order to compose this schema with
+ external handlers and other component implementation type such as
+ compositions.</xs:documentation>
+ </xs:annotation>
+ <xs:element name="ipojo">
<xs:complexType>
- <xs:annotation>
- <xs:documentation>iPOJO top level element.</xs:documentation>
- </xs:annotation>
- <xs:choice minOccurs="0" maxOccurs="unbounded">
+ <xs:annotation>
+ <xs:documentation>iPOJO top level element.</xs:documentation>
+ </xs:annotation>
+ <xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="handler" minOccurs="0" maxOccurs="unbounded">
- <xs:annotation>
- <xs:documentation>The handler declarations.</xs:documentation>
- </xs:annotation>
+ <xs:annotation>
+ <xs:documentation>The handler declarations.</xs:documentation>
+ </xs:annotation>
</xs:element>
<xs:element ref="instance" minOccurs="0" maxOccurs="unbounded">
- <xs:annotation>
- <xs:documentation>The instance declarations.</xs:documentation>
- </xs:annotation>
+ <xs:annotation>
+ <xs:documentation>The instance declarations.</xs:documentation>
+ </xs:annotation>
</xs:element>
<xs:element ref="component" minOccurs="0" maxOccurs="unbounded">
- <xs:annotation>
- <xs:documentation>The component type declarations.</xs:documentation>
- </xs:annotation>
+ <xs:annotation>
+ <xs:documentation>The component type declarations.</xs:documentation>
+ </xs:annotation>
</xs:element>
- <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded">
- </xs:any>
+ <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"
+ > </xs:any>
</xs:choice>
</xs:complexType>
</xs:element>
<xs:complexType name="HandlerType">
- <xs:annotation>
- <xs:documentation>Description of the handler.</xs:documentation>
- </xs:annotation>
- <xs:complexContent>
+ <xs:annotation>
+ <xs:documentation>Description of the handler.</xs:documentation>
+ </xs:annotation>
+ <xs:complexContent>
<xs:extension base="RootElementType">
<xs:sequence maxOccurs="unbounded" minOccurs="0">
- <xs:any minOccurs="0" maxOccurs="unbounded" namespace="##any"
- processContents="skip">
- </xs:any>
+ <xs:any minOccurs="0" maxOccurs="unbounded" namespace="##any" processContents="skip"
+ > </xs:any>
</xs:sequence>
<xs:attribute name="classname" type="xs:string" use="required">
- <xs:annotation>
- <xs:documentation>The implementation class of the handler. The specified class must implement (direcly or not) the "org.apache.felix.ipojo.Handler" interface.</xs:documentation>
- </xs:annotation>
+ <xs:annotation>
+ <xs:documentation>The implementation class of the handler. The specified class must
+ implement (direcly or not) the "org.apache.felix.ipojo.Handler"
+ interface.</xs:documentation>
+ </xs:annotation>
</xs:attribute>
<xs:attribute name="name" type="xs:string" use="required">
- <xs:annotation>
- <xs:documentation>The name of the handler.</xs:documentation>
- </xs:annotation>
+ <xs:annotation>
+ <xs:documentation>The name of the handler.</xs:documentation>
+ </xs:annotation>
</xs:attribute>
<xs:attribute name="namespace" type="xs:string" use="optional">
- <xs:annotation>
- <xs:documentation>The XML namespace of the handler.</xs:documentation>
- </xs:annotation>
+ <xs:annotation>
+ <xs:documentation>The XML namespace of the handler.</xs:documentation>
+ </xs:annotation>
</xs:attribute>
- <xs:attribute name="architecture" type="xs:boolean"
- use="optional" fixed="false">
- <xs:annotation>
- <xs:documentation>Enables or disables the architecture exposition. By default, the architecture is not exposed. This allows handler introspection.</xs:documentation>
- </xs:annotation>
+ <xs:attribute name="architecture" type="xs:boolean" use="optional" fixed="false">
+ <xs:annotation>
+ <xs:documentation>Enables or disables the architecture exposition. By default, the
+ architecture is not exposed. This allows handler introspection.</xs:documentation>
+ </xs:annotation>
</xs:attribute>
<xs:attribute name="level" type="xs:int" use="optional">
- <xs:annotation>
- <xs:documentation>The start level of the handler.</xs:documentation>
- </xs:annotation>
+ <xs:annotation>
+ <xs:documentation>The start level of the handler.</xs:documentation>
+ </xs:annotation>
</xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="InstanceType">
- <xs:annotation>
- <xs:documentation>Describes an instance of a component.</xs:documentation>
- </xs:annotation>
- <xs:complexContent>
+ <xs:annotation>
+ <xs:documentation>Describes an instance of a component.</xs:documentation>
+ </xs:annotation>
+ <xs:complexContent>
<xs:extension base="RootElementType">
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="property" type="InstancePropertyType">
<xs:annotation>
<xs:documentation>The instance properties.</xs:documentation>
- </xs:annotation></xs:element>
+ </xs:annotation>
+ </xs:element>
</xs:sequence>
<xs:attribute name="component" type="xs:string">
<xs:annotation>
<xs:documentation>The name of the instance component type.</xs:documentation>
- </xs:annotation></xs:attribute>
+ </xs:annotation>
+ </xs:attribute>
<xs:attribute name="name" type="xs:string" use="optional">
- <xs:annotation>
- <xs:documentation>The (unique) name of the instance.</xs:documentation>
- </xs:annotation>
+ <xs:annotation>
+ <xs:documentation>The (unique) name of the instance.</xs:documentation>
+ </xs:annotation>
</xs:attribute>
<xs:attribute name="version" type="xs:string" use="optional">
- <xs:annotation>
- <xs:documentation>The version of the factory to use.</xs:documentation>
- </xs:annotation>
+ <xs:annotation>
+ <xs:documentation>The version of the factory to use.</xs:documentation>
+ </xs:annotation>
</xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="InstancePropertyType">
- <xs:annotation>
- <xs:documentation>Defines a property of an instance configuration.</xs:documentation>
- </xs:annotation>
- <xs:sequence>
- <xs:element name="property" type="InstancePropertyType" minOccurs="0" maxOccurs="unbounded"></xs:element>
+ <xs:annotation>
+ <xs:documentation>Defines a property of an instance configuration.</xs:documentation>
+ </xs:annotation>
+ <xs:sequence>
+ <xs:element name="property" type="InstancePropertyType" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation>Name of the property. Can be optional if a property is inside a structure.
-The 'instance.name' property has a special semantic as it will be used as the instance name.</xs:documentation>
- </xs:annotation></xs:attribute>
+ The 'instance.name' property has a special semantic as it will be used as the instance
+ name.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
<xs:attribute name="value" type="xs:string" use="optional">
<xs:annotation>
- <xs:documentation>Value of the property. Can be null for property containing other properties.</xs:documentation>
- </xs:annotation></xs:attribute>
+ <xs:documentation>Value of the property. Can be null for property containing other
+ properties.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
<xs:attribute name="type" type="xs:string" use="optional">
<xs:annotation>
- <xs:documentation>Type of the property, used to create the adequate object. Supported values are list, array, dictionary and map.</xs:documentation>
- </xs:annotation></xs:attribute>
+ <xs:documentation>Type of the property, used to create the adequate object. Supported values
+ are list, array, dictionary and map.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
</xs:complexType>
- <xs:complexType name="RootElementType"></xs:complexType>
+ <xs:complexType name="RootElementType"/>
<xs:complexType name="ComponentType">
<xs:annotation>
<xs:documentation>Declares an atomic (i.e. primitive) component type.</xs:documentation>
</xs:annotation>
<xs:choice minOccurs="0" maxOccurs="unbounded">
- <xs:element ref="callback" minOccurs="0"
- maxOccurs="unbounded">
- <xs:annotation>
- <xs:documentation>Describes the method(s) to invoke when the component's state changes.</xs:documentation>
- </xs:annotation>
+ <xs:element ref="callback" minOccurs="0" maxOccurs="unbounded">
+ <xs:annotation>
+ <xs:documentation>Describes the method(s) to invoke when the component's state
+ changes.</xs:documentation>
+ </xs:annotation>
</xs:element>
- <xs:element ref="provides" minOccurs="0"
- maxOccurs="unbounded">
- <xs:annotation>
- <xs:documentation>Indicates the component provided service(s). By default, all implemented interfaces are published.</xs:documentation>
- </xs:annotation>
+ <xs:element ref="provides" minOccurs="0" maxOccurs="unbounded">
+ <xs:annotation>
+ <xs:documentation>Indicates the component provided service(s). By default, all implemented
+ interfaces are published.</xs:documentation>
+ </xs:annotation>
</xs:element>
- <xs:element ref="requires" minOccurs="0"
- maxOccurs="unbounded">
- <xs:annotation>
- <xs:documentation>Indicates the service requirements of the component.</xs:documentation>
- </xs:annotation>
+ <xs:element ref="requires" minOccurs="0" maxOccurs="unbounded">
+ <xs:annotation>
+ <xs:documentation>Indicates the service requirements of the component.</xs:documentation>
+ </xs:annotation>
</xs:element>
- <xs:element ref="properties" minOccurs="0"
- maxOccurs="unbounded">
- <xs:annotation>
- <xs:documentation>Describes the properties of the component.</xs:documentation>
- </xs:annotation>
+ <xs:element ref="properties" minOccurs="0" maxOccurs="unbounded">
+ <xs:annotation>
+ <xs:documentation>Describes the properties of the component.</xs:documentation>
+ </xs:annotation>
</xs:element>
<xs:element ref="controller" minOccurs="0" maxOccurs="1">
<xs:annotation>
<xs:documentation>Lifecycle controller for this component.</xs:documentation>
- </xs:annotation></xs:element>
- <xs:any namespace="##other" processContents="lax"
- minOccurs="0" maxOccurs="unbounded">
- </xs:any>
+ </xs:annotation>
+ </xs:element>
+ <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"
+ > </xs:any>
</xs:choice>
<xs:attribute name="name" type="xs:string" use="optional">
<xs:annotation>
- <xs:documentation>Specifies the name of the component type. This name is used to identify the factory attached to this type. If not specified, the factory name is the implementation class name.</xs:documentation>
+ <xs:documentation>Specifies the name of the component type. This name is used to identify
+ the factory attached to this type. If not specified, the factory name is the
+ implementation class name.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="public" type="xs:boolean" use="optional">
<xs:annotation>
- <xs:documentation>Determines if the component type is public or private. A public factory (default) can be used from any bundles.</xs:documentation>
+ <xs:documentation>Determines if the component type is public or private. A public factory
+ (default) can be used from any bundles.</xs:documentation>
</xs:annotation>
</xs:attribute>
- <xs:attribute name="classname" type="xs:string"
- use="required">
+ <xs:attribute name="classname" type="xs:string" use="required">
<xs:annotation>
- <xs:documentation>Specifies the implementation class of the component type.</xs:documentation>
+ <xs:documentation>Specifies the implementation class of the component
+ type.</xs:documentation>
</xs:annotation>
</xs:attribute>
- <xs:attribute name="architecture" type="xs:boolean"
- use="optional">
+ <xs:attribute name="architecture" type="xs:boolean" use="optional">
<xs:annotation>
- <xs:documentation>Enables or disables the architecture exposition. By default, the architecture is exposed. This allows instance introspection.</xs:documentation>
+ <xs:documentation>Enables or disables the architecture exposition. By default, the
+ architecture is exposed. This allows instance introspection.</xs:documentation>
</xs:annotation>
</xs:attribute>
- <xs:attribute name="immediate" type="xs:boolean"
- use="optional">
- <xs:annotation>
- <xs:documentation>Creates the object of the component implementation type as soon as the component instance becomes valid. The default value is "true" if the component doesn't provide any service, "false" otherwise.</xs:documentation>
- </xs:annotation>
+ <xs:attribute name="immediate" type="xs:boolean" use="optional">
+ <xs:annotation>
+ <xs:documentation>Creates the object of the component implementation type as soon as the
+ component instance becomes valid. The default value is "true" if the component doesn't
+ provide any service, "false" otherwise.</xs:documentation>
+ </xs:annotation>
</xs:attribute>
<xs:attribute name="factory-method" type="xs:string" use="optional">
<xs:annotation>
- <xs:documentation>Factory method called to create POJO objects instead of the constructor. The specified method must be a static method of the implementation class returning an instance of this implementation class. The factory method can receive the bundle context in argument.</xs:documentation>
- </xs:annotation></xs:attribute>
+ <xs:documentation>Factory method called to create POJO objects instead of the constructor.
+ The specified method must be a static method of the implementation class returning an
+ instance of this implementation class. The factory method can receive the bundle context
+ in argument.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
<xs:attribute name="version" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation>Set the version of this component type</xs:documentation>
- </xs:annotation></xs:attribute>
+ </xs:annotation>
+ </xs:attribute>
</xs:complexType>
<xs:complexType name="RequiresType">
- <xs:annotation>
- <xs:documentation>Description of component services requirements.</xs:documentation>
- </xs:annotation>
- <xs:complexContent>
+ <xs:annotation>
+ <xs:documentation>Description of component services requirements.</xs:documentation>
+ </xs:annotation>
+ <xs:complexContent>
<xs:extension base="ServiceDependencyType">
<xs:sequence minOccurs="0" maxOccurs="unbounded">
- <xs:element name="callback"
- type="DependencyCallbackType">
- <xs:annotation>
- <xs:documentation>Service requirement method invocation description. Here can be specified a bind method called when a service appears and an unbind method called when a service disappears.</xs:documentation>
- </xs:annotation>
+ <xs:element name="callback" type="DependencyCallbackType">
+ <xs:annotation>
+ <xs:documentation>Service requirement method invocation description. Here can be
+ specified a bind method called when a service appears and an unbind method called
+ when a service disappears.</xs:documentation>
+ </xs:annotation>
</xs:element>
</xs:sequence>
- <xs:attribute name="interface" type="xs:string"
- use="prohibited">
- <xs:annotation>
- <xs:documentation>The interface describing the required service type. This attribute is needed only when using aggregate dependencies with field injection and when the type of this field is a list, vector, collection and set. This attribute is deprecated, use 'specification'.</xs:documentation>
- </xs:annotation>
+ <xs:attribute name="interface" type="xs:string" use="prohibited">
+ <xs:annotation>
+ <xs:documentation>The interface describing the required service type. This attribute is
+ needed only when using aggregate dependencies with field injection and when the type
+ of this field is a list, vector, collection and set. This attribute is deprecated, use
+ 'specification'.</xs:documentation>
+ </xs:annotation>
</xs:attribute>
- <xs:attribute name="field" type="xs:string"
- use="optional">
- <xs:annotation>
- <xs:documentation>The name of the field representing the service dependency in the implementation class.</xs:documentation>
- </xs:annotation>
+ <xs:attribute name="field" type="xs:string" use="optional">
+ <xs:annotation>
+ <xs:documentation>The name of the field representing the service dependency in the
+ implementation class.</xs:documentation>
+ </xs:annotation>
</xs:attribute>
- <xs:attribute name="nullable" type="xs:boolean"
- use="optional">
- <xs:annotation>
- <xs:documentation>Enable or disable the Nullable pattern on optional service dependencies. By default, Nullable pattern is enabled. If disabled, iPOJO will inject null instead of a Nullable object.</xs:documentation>
- </xs:annotation>
+ <xs:attribute name="nullable" type="xs:boolean" use="optional">
+ <xs:annotation>
+ <xs:documentation>Enable or disable the Nullable pattern on optional service
+ dependencies. By default, Nullable pattern is enabled. If disabled, iPOJO will inject
+ null instead of a Nullable object.</xs:documentation>
+ </xs:annotation>
</xs:attribute>
- <xs:attribute name="default-implementation"
- type="xs:string" use="optional">
- <xs:annotation>
- <xs:documentation>Specifies the default implementation class for an optional service dependency. If no providers are found, iPOJO creates an instance of the default-implementation (nullary constructor) and injects it. The given class must implement the required service interface.</xs:documentation>
- </xs:annotation>
+ <xs:attribute name="default-implementation" type="xs:string" use="optional">
+ <xs:annotation>
+ <xs:documentation>Specifies the default implementation class for an optional service
+ dependency. If no providers are found, iPOJO creates an instance of the
+ default-implementation (nullary constructor) and injects it. The given class must
+ implement the required service interface.</xs:documentation>
+ </xs:annotation>
</xs:attribute>
- <xs:attribute name="from" type="xs:string"
- use="optional">
- <xs:annotation>
- <xs:documentation>Specific service provider. The dependency can only be fulfilled by the component with the matching name, or by the service with a matching PID.</xs:documentation>
- </xs:annotation>
+ <xs:attribute name="from" type="xs:string" use="optional">
+ <xs:annotation>
+ <xs:documentation>Specific service provider. The dependency can only be fulfilled by the
+ component with the matching name, or by the service with a matching
+ PID.</xs:documentation>
+ </xs:annotation>
</xs:attribute>
-
- <xs:attribute name="proxy" type="xs:boolean"
- use="optional">
- <xs:annotation>
- <xs:documentation>Enables or Disable the proxy injection (on field injection)</xs:documentation>
- </xs:annotation>
+
+ <xs:attribute name="proxy" type="xs:boolean" use="optional">
+ <xs:annotation>
+ <xs:documentation>Enables or Disable the proxy injection (on field
+ injection)</xs:documentation>
+ </xs:annotation>
</xs:attribute>
<xs:attribute name="scope" use="optional">
<xs:simpleType>
<xs:restriction base="xs:string">
- <xs:enumeration value="global"></xs:enumeration>
- <xs:enumeration value="composite"></xs:enumeration>
- <xs:enumeration value="composite+global"></xs:enumeration>
+ <xs:enumeration value="global"/>
+ <xs:enumeration value="composite"/>
+ <xs:enumeration value="composite+global"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
@@ -282,213 +309,269 @@
</xs:complexContent>
</xs:complexType>
<xs:complexType name="DependencyCallbackType">
- <xs:annotation>
- <xs:documentation>Dependency callbacks are used to receive notification when service providers arrive and leave.</xs:documentation>
- </xs:annotation>
- <xs:attribute name="method" type="xs:string" use="required">
- <xs:annotation>
- <xs:documentation>Method to call</xs:documentation>
- </xs:annotation></xs:attribute>
+ <xs:annotation>
+ <xs:documentation>Dependency callbacks are used to receive notification when service providers
+ arrive and leave.</xs:documentation>
+ </xs:annotation>
+ <xs:attribute name="method" type="xs:string" use="required">
+ <xs:annotation>
+ <xs:documentation>Method to call</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
<xs:attribute name="type" use="required">
- <xs:annotation>
- <xs:documentation>
- Type of callback (bind, unbind, or updated). Bind means that the method will be called when a provider arrives. Unbind means that the method will be called when a provider leaves.
- Updated means that a service was modified but is still valid for the service dependency.
- </xs:documentation>
- </xs:annotation>
- <xs:simpleType>
+ <xs:annotation>
+ <xs:documentation> Type of callback (bind, unbind, or updated). Bind means that the method
+ will be called when a provider arrives. Unbind means that the method will be called when a
+ provider leaves. Updated means that a service was modified but is still valid for the
+ service dependency. </xs:documentation>
+ </xs:annotation>
+ <xs:simpleType>
<xs:restriction base="xs:string">
- <xs:enumeration value="bind"></xs:enumeration>
- <xs:enumeration value="unbind"></xs:enumeration>
- <xs:enumeration value="modified"></xs:enumeration>
+ <xs:enumeration value="bind"/>
+ <xs:enumeration value="unbind"/>
+ <xs:enumeration value="modified"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
<xs:complexType name="CallbackType">
- <xs:annotation>
- <xs:documentation>Lifecycle Callback. Allows a POJO to be notified when the instance becomes valid or invalid.</xs:documentation>
- </xs:annotation>
- <xs:attribute name="method" type="xs:string" use="required">
- <xs:annotation>
- <xs:documentation>Specifies the method to call on the transition.</xs:documentation>
- </xs:annotation></xs:attribute>
+ <xs:annotation>
+ <xs:documentation>Lifecycle Callback. Allows a POJO to be notified when the instance becomes
+ valid or invalid.</xs:documentation>
+ </xs:annotation>
+ <xs:attribute name="method" type="xs:string" use="required">
+ <xs:annotation>
+ <xs:documentation>Specifies the method to call on the transition.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
<xs:attribute name="transition" use="required">
- <xs:annotation>
- <xs:documentation>Specifies the transition when the callback needs to be invoked.</xs:documentation>
- </xs:annotation>
- <xs:simpleType>
- <xs:annotation>
- <xs:documentation>Lifecycle transition state. "validate" means that the component's instance was invalid and becomes valid, "invalidate" means that the component's intance was valid and becomes invalid.</xs:documentation>
- </xs:annotation>
- <xs:restriction base="xs:string">
- <xs:enumeration value="validate"></xs:enumeration>
- <xs:enumeration value="invalidate"></xs:enumeration>
+ <xs:annotation>
+ <xs:documentation>Specifies the transition when the callback needs to be
+ invoked.</xs:documentation>
+ </xs:annotation>
+ <xs:simpleType>
+ <xs:annotation>
+ <xs:documentation>Lifecycle transition state. "validate" means that the component's
+ instance was invalid and becomes valid, "invalidate" means that the component's intance
+ was valid and becomes invalid.</xs:documentation>
+ </xs:annotation>
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="validate"/>
+ <xs:enumeration value="invalidate"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
- <xs:element name="provides" type="ProvidesType" id="provides"></xs:element>
- <xs:complexType name="ProvidesType">
- <xs:annotation>
- <xs:documentation>Provided service(s) description.</xs:documentation>
- </xs:annotation>
- <xs:sequence minOccurs="0" maxOccurs="unbounded">
+ <xs:element name="provides" type="ProvidesType" id="provides"/>
+ <xs:complexType name="ProvidesType">
+ <xs:annotation>
+ <xs:documentation>Provided service(s) description.</xs:documentation>
+ </xs:annotation>
+ <xs:sequence minOccurs="0" maxOccurs="unbounded">
+ <xs:choice>
<xs:element name="property" type="PropertyType">
<xs:annotation>
<xs:documentation>List of service specific properties.</xs:documentation>
- </xs:annotation></xs:element>
+ </xs:annotation>
+ </xs:element>
+ <xs:element name="controller" minOccurs="0" maxOccurs="1" type="ServiceControllerType">
+ <xs:annotation>
+ <xs:documentation>Service Controller impacting the current provided
+ service</xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ </xs:choice>
</xs:sequence>
<xs:attribute name="interface" type="xs:string" use="prohibited">
<xs:annotation>
- <xs:documentation>Deprecated attribute, use 'specifications' instead of 'interface'</xs:documentation>
- </xs:annotation></xs:attribute>
+ <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: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>
<xs:documentation>Use 'strategy' instead of 'factory'</xs:documentation>
- </xs:annotation></xs:attribute>
+ </xs:annotation>
+ </xs:attribute>
<xs:attribute name="strategy" type="xs:string" use="optional">
<xs:annotation>
- <xs:documentation>POJO creation strategy. By default, the POJO object is created once (singleton). If the factory is set to "SERVICE", the creation policy follows the OSGi service factory policy (one object object per asking bundle).
- INSTANCE allows creating one different POJO object per asking instance. Finally, a custom strategy can be used by specifying the qualified name of the class extending CreationPolicy</xs:documentation>
- </xs:annotation></xs:attribute>
+ <xs:documentation>POJO creation strategy. By default, the POJO object is created once
+ (singleton). If the factory is set to "SERVICE", the creation policy follows the OSGi
+ service factory policy (one object object per asking bundle). INSTANCE allows creating one
+ different POJO object per asking instance. Finally, a custom strategy can be used by
+ specifying the qualified name of the class extending CreationPolicy</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
</xs:complexType>
- <xs:complexType name="PropertyType">
+ <xs:complexType name="ServiceControllerType">
<xs:annotation>
- <xs:documentation>
- Defines a component property.
- </xs:documentation>
+ <xs:documentation> Defines a service controller. </xs:documentation>
</xs:annotation>
- <xs:attribute name="field" type="xs:string" use="optional">
+ <xs:attribute name="field" type="xs:string" use="required">
<xs:annotation>
- <xs:documentation>
- Field of the property
- </xs:documentation>
- </xs:annotation>
- </xs:attribute>
- <xs:attribute name="method" type="xs:string" use="optional">
- <xs:annotation>
- <xs:documentation>
- Setter method of the property. This method is called
- to inject property value.
- </xs:documentation>
- </xs:annotation>
- </xs:attribute>
- <xs:attribute name="name" type="xs:string" use="optional">
- <xs:annotation>
- <xs:documentation>
- Name of the property.
- </xs:documentation>
+ <xs:documentation> Field of the controller </xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="value" type="xs:string" use="optional">
<xs:annotation>
- <xs:documentation>
- Default value of the property.
- </xs:documentation>
+ <xs:documentation> Intiail value of the controller </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ </xs:complexType>
+ <xs:complexType name="PropertyType">
+ <xs:annotation>
+ <xs:documentation> Defines a component property. </xs:documentation>
+ </xs:annotation>
+ <xs:attribute name="field" type="xs:string" use="optional">
+ <xs:annotation>
+ <xs:documentation> Field of the property </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="method" type="xs:string" use="optional">
+ <xs:annotation>
+ <xs:documentation> Setter method of the property. This method is called to inject property
+ value. </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="name" type="xs:string" use="optional">
+ <xs:annotation>
+ <xs:documentation> Name of the property. </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="value" type="xs:string" use="optional">
+ <xs:annotation>
+ <xs:documentation> Default value of the property. </xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="type" type="xs:string" use="optional">
<xs:annotation>
- <xs:documentation>
- Type of the property.
- </xs:documentation>
+ <xs:documentation> Type of the property. </xs:documentation>
</xs:annotation>
</xs:attribute>
- <xs:attribute name="mandatory" type="xs:boolean" use="optional" default="false">
- <xs:annotation>
- <xs:documentation>Set the property as mandatory. A mandatory property MUST receive a value either in the component type description or in the instance configuration. Properties are optional by default.</xs:documentation>
- </xs:annotation></xs:attribute>
- </xs:complexType>
- <xs:element name="callback" type="CallbackType" id="callback"></xs:element>
+ <xs:attribute name="mandatory" type="xs:boolean" use="optional" default="false">
+ <xs:annotation>
+ <xs:documentation>Set the property as mandatory. A mandatory property MUST receive a value
+ either in the component type description or in the instance configuration. Properties are
+ optional by default.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ </xs:complexType>
+ <xs:element name="callback" type="CallbackType" id="callback"/>
<xs:element name="controller" type="ControllerType" id="controller">
<xs:annotation>
- <xs:documentation></xs:documentation>
- </xs:annotation></xs:element>
- <xs:element name="requires" type="RequiresType" id="requires"></xs:element>
- <xs:element name="component" type="ComponentType" id="component"></xs:element>
- <xs:element name="handler" type="HandlerType" id="handler"></xs:element>
- <xs:element name="instance" type="InstanceType" id="instance"></xs:element>
+ <xs:documentation/>
+ </xs:annotation>
+ </xs:element>
+ <xs:element name="requires" type="RequiresType" id="requires"/>
+ <xs:element name="component" type="ComponentType" id="component"/>
+ <xs:element name="handler" type="HandlerType" id="handler"/>
+ <xs:element name="instance" type="InstanceType" id="instance"/>
- <xs:element name="properties" type="PropertiesType" id="properties"></xs:element>
+ <xs:element name="properties" type="PropertiesType" id="properties"/>
<xs:complexType name="PropertiesType">
- <xs:annotation>
- <xs:documentation>List of component, instance or service properties. This field will receive the property value.</xs:documentation>
- </xs:annotation>
- <xs:sequence minOccurs="0" maxOccurs="unbounded">
+ <xs:annotation>
+ <xs:documentation>List of component, instance or service properties. This field will receive
+ the property value.</xs:documentation>
+ </xs:annotation>
+ <xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="property" type="PropertyType">
<xs:annotation>
<xs:documentation>The list of properties.</xs:documentation>
- </xs:annotation></xs:element>
+ </xs:annotation>
+ </xs:element>
</xs:sequence>
<xs:attribute name="propagation" type="xs:boolean" use="optional">
<xs:annotation>
- <xs:documentation>Propagation of the component properties to the provided services. If this parameter is set to "true", each time properties are reconfigured, they are propagated to each service published by the component.</xs:documentation>
- </xs:annotation></xs:attribute>
+ <xs:documentation>Propagation of the component properties to the provided services. If this
+ parameter is set to "true", each time properties are reconfigured, they are propagated to
+ each service published by the component.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
<xs:attribute name="pid" type="xs:string" use="optional">
<xs:annotation>
- <xs:documentation>Unique identifier used to reconfigure components properties (via Managed Services) with the Configuration Admin.</xs:documentation>
- </xs:annotation></xs:attribute>
+ <xs:documentation>Unique identifier used to reconfigure components properties (via Managed
+ Services) with the Configuration Admin.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
<xs:attribute name="updated" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation>Method called when a reconfiguration is done</xs:documentation>
- </xs:annotation></xs:attribute>
+ </xs:annotation>
+ </xs:attribute>
</xs:complexType>
<xs:complexType name="ServiceDependencyType">
- <xs:attribute name="specification" type="xs:string" use="optional">
- <xs:annotation>
- <xs:documentation>The specification describing the required service type. This attribute is needed only when using aggregate dependencies with field injection and when the type of this field is a list, vector, collection and set.</xs:documentation>
- </xs:annotation></xs:attribute>
+ <xs:attribute name="specification" type="xs:string" use="optional">
+ <xs:annotation>
+ <xs:documentation>The specification describing the required service type. This attribute is
+ needed only when using aggregate dependencies with field injection and when the type of
+ this field is a list, vector, collection and set.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
<xs:attribute name="optional" type="xs:boolean" use="optional">
- <xs:annotation>
- <xs:documentation>Sets the service dependency optionality</xs:documentation>
- </xs:annotation>
+ <xs:annotation>
+ <xs:documentation>Sets the service dependency optionality</xs:documentation>
+ </xs:annotation>
</xs:attribute>
<xs:attribute name="aggregate" type="xs:boolean" use="optional">
- <xs:annotation>
- <xs:documentation>Sets the service dependency cardinality.</xs:documentation>
- </xs:annotation>
+ <xs:annotation>
+ <xs:documentation>Sets the service dependency cardinality.</xs:documentation>
+ </xs:annotation>
</xs:attribute>
<xs:attribute name="policy" use="optional">
- <xs:annotation>
- <xs:documentation>Sets the binding policy of the dependency. Three policies are supported. The dynamic policy supports service providers dynamism. The static policy freezes the provider set as soon as the dependency is used. The dynamic-priority policy is an extension of the dynamic policy, but providers are ranked.</xs:documentation>
- </xs:annotation>
- <xs:simpleType>
+ <xs:annotation>
+ <xs:documentation>Sets the binding policy of the dependency. Three policies are supported.
+ The dynamic policy supports service providers dynamism. The static policy freezes the
+ provider set as soon as the dependency is used. The dynamic-priority policy is an
+ extension of the dynamic policy, but providers are ranked.</xs:documentation>
+ </xs:annotation>
+ <xs:simpleType>
<xs:restriction base="xs:string">
- <xs:enumeration value="dynamic"></xs:enumeration>
- <xs:enumeration value="static"></xs:enumeration>
- <xs:enumeration value="dynamic-priority"></xs:enumeration>
+ <xs:enumeration value="dynamic"/>
+ <xs:enumeration value="static"/>
+ <xs:enumeration value="dynamic-priority"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="comparator" type="xs:string" use="optional">
- <xs:annotation>
- <xs:documentation>The comparator attribute allows specifying the class used to compare providers. This class must implemented the java.util.Comparator class and must support the comparison of service references.</xs:documentation>
- </xs:annotation>
+ <xs:annotation>
+ <xs:documentation>The comparator attribute allows specifying the class used to compare
+ providers. This class must implemented the java.util.Comparator class and must support the
+ comparison of service references.</xs:documentation>
+ </xs:annotation>
</xs:attribute>
<xs:attribute name="filter" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation>LDAP filter used to filter providers</xs:documentation>
- </xs:annotation></xs:attribute>
+ </xs:annotation>
+ </xs:attribute>
<xs:attribute name="id" type="xs:string" use="optional">
<xs:annotation>
- <xs:documentation>id of the service dependency. The id allows to indentify and to refert to this dependency.</xs:documentation>
- </xs:annotation></xs:attribute>
+ <xs:documentation>id of the service dependency. The id allows to indentify and to refert to
+ this dependency.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
</xs:complexType>
- <xs:complexType name="ControllerType">
- <xs:annotation>
- <xs:documentation>Specifies the lifecycle controller of a component, which allows to validate or invalidate component instances.</xs:documentation>
- </xs:annotation>
- <xs:attribute name="field" type="xs:string" use="required">
- <xs:annotation>
- <xs:documentation>The name of the component lifecycle controller field. The type of the specified field must be boolean. Setting the value of the specified field to "true" means the validation of the component instance while setting it to "false" means the invalidation of the component instance.</xs:documentation>
- </xs:annotation>
- </xs:attribute>
- </xs:complexType>
+ <xs:complexType name="ControllerType">
+ <xs:annotation>
+ <xs:documentation>Specifies the lifecycle controller of a component, which allows to validate
+ or invalidate component instances.</xs:documentation>
+ </xs:annotation>
+ <xs:attribute name="field" type="xs:string" use="required">
+ <xs:annotation>
+ <xs:documentation>The name of the component lifecycle controller field. The type of the
+ specified field must be boolean. Setting the value of the specified field to "true" means
+ the validation of the component instance while setting it to "false" means the
+ invalidation of the component instance.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ </xs:complexType>
</xs:schema>
diff --git a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/FieldCollector.java b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/FieldCollector.java
index 3bd0fb5..a2918e8 100644
--- a/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/FieldCollector.java
+++ b/ipojo/manipulator/src/main/java/org/apache/felix/ipojo/manipulation/annotations/FieldCollector.java
@@ -76,8 +76,17 @@
// Get the provides element
Element parent = (Element) m_collector.getIds().get("provides");
return new PropertyAnnotationParser(m_field, parent);
- }
-
+ }
+ }
+ if (arg0.equals("Lorg/apache/felix/ipojo/annotations/ServiceController;")) {
+ if (! m_collector.getIds().containsKey("provides")) { // The provides annotation is already computed.
+ System.err.println("The component does not provide services, skip ServiceController for " + m_field);
+ return null;
+ } else {
+ // Get the provides element
+ Element parent = (Element) m_collector.getIds().get("provides");
+ return new ServiceControllerAnnotationParser(m_field, parent);
+ }
}
if (arg0.equals("Lorg/apache/felix/ipojo/annotations/Property;")) {
Element parent = null;
@@ -380,4 +389,63 @@
}
}
+
+ /**
+ * Parses a ServiceController annotation.
+ */
+ private static final class ServiceControllerAnnotationParser extends EmptyVisitor implements AnnotationVisitor {
+
+ /**
+ * Parent element element.
+ */
+ private Element m_parent;
+
+ /**
+ * Field name.
+ */
+ private String m_field;
+
+ /**
+ * Property value.
+ */
+ private String m_value;
+
+ /**
+ * Constructor.
+ * @param parent : parent element.
+ * @param field : field name.
+ */
+ private ServiceControllerAnnotationParser(String field, Element parent) {
+ m_parent = parent;
+ m_field = field;
+ }
+
+ /**
+ * Visit one "simple" annotation.
+ * @param arg0 : annotation name
+ * @param arg1 : annotation value
+ * @see org.objectweb.asm.AnnotationVisitor#visit(java.lang.String, java.lang.Object)
+ */
+ public void visit(String arg0, Object arg1) {
+ if (arg0.equals("value")) {
+ m_value = arg1.toString();
+ return;
+ }
+ }
+
+ /**
+ * End of the annotation.
+ * Create a "controller" element
+ * @see org.objectweb.asm.AnnotationVisitor#visitEnd()
+ */
+ public void visitEnd() {
+ Element controller = new Element("controller", "");
+ m_parent.addElement(controller);
+
+ controller.addAttribute(new Attribute("field", m_field));
+ if (m_value != null) {
+ controller.addAttribute(new Attribute("value", m_value));
+ }
+ }
+ }
}
diff --git a/ipojo/manipulator/src/main/resources/core.xsd b/ipojo/manipulator/src/main/resources/core.xsd
index 5d51779..c330d80 100644
--- a/ipojo/manipulator/src/main/resources/core.xsd
+++ b/ipojo/manipulator/src/main/resources/core.xsd
@@ -18,262 +18,289 @@
-->
<xs:schema elementFormDefault="qualified" targetNamespace="org.apache.felix.ipojo"
xmlns="org.apache.felix.ipojo" xmlns:xs="http://www.w3.org/2001/XMLSchema">
- <xs:annotation>
- <xs:documentation>iPOJO Core XML-Schema. This grammars models iPOJO descriptor using core features. It provides several extensibility mechanism in order to compose this schema with external handlers and other component implementation type such as compositions.</xs:documentation></xs:annotation>
- <xs:element name="ipojo">
+ <xs:annotation>
+ <xs:documentation>iPOJO Core XML-Schema. This grammars models iPOJO descriptor using core
+ features. It provides several extensibility mechanism in order to compose this schema with
+ external handlers and other component implementation type such as
+ compositions.</xs:documentation>
+ </xs:annotation>
+ <xs:element name="ipojo">
<xs:complexType>
- <xs:annotation>
- <xs:documentation>iPOJO top level element.</xs:documentation>
- </xs:annotation>
- <xs:choice minOccurs="0" maxOccurs="unbounded">
+ <xs:annotation>
+ <xs:documentation>iPOJO top level element.</xs:documentation>
+ </xs:annotation>
+ <xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="handler" minOccurs="0" maxOccurs="unbounded">
- <xs:annotation>
- <xs:documentation>The handler declarations.</xs:documentation>
- </xs:annotation>
+ <xs:annotation>
+ <xs:documentation>The handler declarations.</xs:documentation>
+ </xs:annotation>
</xs:element>
<xs:element ref="instance" minOccurs="0" maxOccurs="unbounded">
- <xs:annotation>
- <xs:documentation>The instance declarations.</xs:documentation>
- </xs:annotation>
+ <xs:annotation>
+ <xs:documentation>The instance declarations.</xs:documentation>
+ </xs:annotation>
</xs:element>
<xs:element ref="component" minOccurs="0" maxOccurs="unbounded">
- <xs:annotation>
- <xs:documentation>The component type declarations.</xs:documentation>
- </xs:annotation>
+ <xs:annotation>
+ <xs:documentation>The component type declarations.</xs:documentation>
+ </xs:annotation>
</xs:element>
- <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded">
- </xs:any>
+ <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"
+ > </xs:any>
</xs:choice>
</xs:complexType>
</xs:element>
<xs:complexType name="HandlerType">
- <xs:annotation>
- <xs:documentation>Description of the handler.</xs:documentation>
- </xs:annotation>
- <xs:complexContent>
+ <xs:annotation>
+ <xs:documentation>Description of the handler.</xs:documentation>
+ </xs:annotation>
+ <xs:complexContent>
<xs:extension base="RootElementType">
<xs:sequence maxOccurs="unbounded" minOccurs="0">
- <xs:any minOccurs="0" maxOccurs="unbounded" namespace="##any"
- processContents="skip">
- </xs:any>
+ <xs:any minOccurs="0" maxOccurs="unbounded" namespace="##any" processContents="skip"
+ > </xs:any>
</xs:sequence>
<xs:attribute name="classname" type="xs:string" use="required">
- <xs:annotation>
- <xs:documentation>The implementation class of the handler. The specified class must implement (direcly or not) the "org.apache.felix.ipojo.Handler" interface.</xs:documentation>
- </xs:annotation>
+ <xs:annotation>
+ <xs:documentation>The implementation class of the handler. The specified class must
+ implement (direcly or not) the "org.apache.felix.ipojo.Handler"
+ interface.</xs:documentation>
+ </xs:annotation>
</xs:attribute>
<xs:attribute name="name" type="xs:string" use="required">
- <xs:annotation>
- <xs:documentation>The name of the handler.</xs:documentation>
- </xs:annotation>
+ <xs:annotation>
+ <xs:documentation>The name of the handler.</xs:documentation>
+ </xs:annotation>
</xs:attribute>
<xs:attribute name="namespace" type="xs:string" use="optional">
- <xs:annotation>
- <xs:documentation>The XML namespace of the handler.</xs:documentation>
- </xs:annotation>
+ <xs:annotation>
+ <xs:documentation>The XML namespace of the handler.</xs:documentation>
+ </xs:annotation>
</xs:attribute>
- <xs:attribute name="architecture" type="xs:boolean"
- use="optional" fixed="false">
- <xs:annotation>
- <xs:documentation>Enables or disables the architecture exposition. By default, the architecture is not exposed. This allows handler introspection.</xs:documentation>
- </xs:annotation>
+ <xs:attribute name="architecture" type="xs:boolean" use="optional" fixed="false">
+ <xs:annotation>
+ <xs:documentation>Enables or disables the architecture exposition. By default, the
+ architecture is not exposed. This allows handler introspection.</xs:documentation>
+ </xs:annotation>
</xs:attribute>
<xs:attribute name="level" type="xs:int" use="optional">
- <xs:annotation>
- <xs:documentation>The start level of the handler.</xs:documentation>
- </xs:annotation>
+ <xs:annotation>
+ <xs:documentation>The start level of the handler.</xs:documentation>
+ </xs:annotation>
</xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="InstanceType">
- <xs:annotation>
- <xs:documentation>Describes an instance of a component.</xs:documentation>
- </xs:annotation>
- <xs:complexContent>
+ <xs:annotation>
+ <xs:documentation>Describes an instance of a component.</xs:documentation>
+ </xs:annotation>
+ <xs:complexContent>
<xs:extension base="RootElementType">
<xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="property" type="InstancePropertyType">
<xs:annotation>
<xs:documentation>The instance properties.</xs:documentation>
- </xs:annotation></xs:element>
+ </xs:annotation>
+ </xs:element>
</xs:sequence>
<xs:attribute name="component" type="xs:string">
<xs:annotation>
<xs:documentation>The name of the instance component type.</xs:documentation>
- </xs:annotation></xs:attribute>
+ </xs:annotation>
+ </xs:attribute>
<xs:attribute name="name" type="xs:string" use="optional">
- <xs:annotation>
- <xs:documentation>The (unique) name of the instance.</xs:documentation>
- </xs:annotation>
+ <xs:annotation>
+ <xs:documentation>The (unique) name of the instance.</xs:documentation>
+ </xs:annotation>
</xs:attribute>
<xs:attribute name="version" type="xs:string" use="optional">
- <xs:annotation>
- <xs:documentation>The version of the factory to use.</xs:documentation>
- </xs:annotation>
+ <xs:annotation>
+ <xs:documentation>The version of the factory to use.</xs:documentation>
+ </xs:annotation>
</xs:attribute>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="InstancePropertyType">
- <xs:annotation>
- <xs:documentation>Defines a property of an instance configuration.</xs:documentation>
- </xs:annotation>
- <xs:sequence>
- <xs:element name="property" type="InstancePropertyType" minOccurs="0" maxOccurs="unbounded"></xs:element>
+ <xs:annotation>
+ <xs:documentation>Defines a property of an instance configuration.</xs:documentation>
+ </xs:annotation>
+ <xs:sequence>
+ <xs:element name="property" type="InstancePropertyType" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="name" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation>Name of the property. Can be optional if a property is inside a structure.
-The 'instance.name' property has a special semantic as it will be used as the instance name.</xs:documentation>
- </xs:annotation></xs:attribute>
+ The 'instance.name' property has a special semantic as it will be used as the instance
+ name.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
<xs:attribute name="value" type="xs:string" use="optional">
<xs:annotation>
- <xs:documentation>Value of the property. Can be null for property containing other properties.</xs:documentation>
- </xs:annotation></xs:attribute>
+ <xs:documentation>Value of the property. Can be null for property containing other
+ properties.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
<xs:attribute name="type" type="xs:string" use="optional">
<xs:annotation>
- <xs:documentation>Type of the property, used to create the adequate object. Supported values are list, array, dictionary and map.</xs:documentation>
- </xs:annotation></xs:attribute>
+ <xs:documentation>Type of the property, used to create the adequate object. Supported values
+ are list, array, dictionary and map.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
</xs:complexType>
- <xs:complexType name="RootElementType"></xs:complexType>
+ <xs:complexType name="RootElementType"/>
<xs:complexType name="ComponentType">
<xs:annotation>
<xs:documentation>Declares an atomic (i.e. primitive) component type.</xs:documentation>
</xs:annotation>
<xs:choice minOccurs="0" maxOccurs="unbounded">
- <xs:element ref="callback" minOccurs="0"
- maxOccurs="unbounded">
- <xs:annotation>
- <xs:documentation>Describes the method(s) to invoke when the component's state changes.</xs:documentation>
- </xs:annotation>
+ <xs:element ref="callback" minOccurs="0" maxOccurs="unbounded">
+ <xs:annotation>
+ <xs:documentation>Describes the method(s) to invoke when the component's state
+ changes.</xs:documentation>
+ </xs:annotation>
</xs:element>
- <xs:element ref="provides" minOccurs="0"
- maxOccurs="unbounded">
- <xs:annotation>
- <xs:documentation>Indicates the component provided service(s). By default, all implemented interfaces are published.</xs:documentation>
- </xs:annotation>
+ <xs:element ref="provides" minOccurs="0" maxOccurs="unbounded">
+ <xs:annotation>
+ <xs:documentation>Indicates the component provided service(s). By default, all implemented
+ interfaces are published.</xs:documentation>
+ </xs:annotation>
</xs:element>
- <xs:element ref="requires" minOccurs="0"
- maxOccurs="unbounded">
- <xs:annotation>
- <xs:documentation>Indicates the service requirements of the component.</xs:documentation>
- </xs:annotation>
+ <xs:element ref="requires" minOccurs="0" maxOccurs="unbounded">
+ <xs:annotation>
+ <xs:documentation>Indicates the service requirements of the component.</xs:documentation>
+ </xs:annotation>
</xs:element>
- <xs:element ref="properties" minOccurs="0"
- maxOccurs="unbounded">
- <xs:annotation>
- <xs:documentation>Describes the properties of the component.</xs:documentation>
- </xs:annotation>
+ <xs:element ref="properties" minOccurs="0" maxOccurs="unbounded">
+ <xs:annotation>
+ <xs:documentation>Describes the properties of the component.</xs:documentation>
+ </xs:annotation>
</xs:element>
<xs:element ref="controller" minOccurs="0" maxOccurs="1">
<xs:annotation>
<xs:documentation>Lifecycle controller for this component.</xs:documentation>
- </xs:annotation></xs:element>
- <xs:any namespace="##other" processContents="lax"
- minOccurs="0" maxOccurs="unbounded">
- </xs:any>
+ </xs:annotation>
+ </xs:element>
+ <xs:any namespace="##other" processContents="lax" minOccurs="0" maxOccurs="unbounded"
+ > </xs:any>
</xs:choice>
<xs:attribute name="name" type="xs:string" use="optional">
<xs:annotation>
- <xs:documentation>Specifies the name of the component type. This name is used to identify the factory attached to this type. If not specified, the factory name is the implementation class name.</xs:documentation>
+ <xs:documentation>Specifies the name of the component type. This name is used to identify
+ the factory attached to this type. If not specified, the factory name is the
+ implementation class name.</xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="public" type="xs:boolean" use="optional">
<xs:annotation>
- <xs:documentation>Determines if the component type is public or private. A public factory (default) can be used from any bundles.</xs:documentation>
+ <xs:documentation>Determines if the component type is public or private. A public factory
+ (default) can be used from any bundles.</xs:documentation>
</xs:annotation>
</xs:attribute>
- <xs:attribute name="classname" type="xs:string"
- use="required">
+ <xs:attribute name="classname" type="xs:string" use="required">
<xs:annotation>
- <xs:documentation>Specifies the implementation class of the component type.</xs:documentation>
+ <xs:documentation>Specifies the implementation class of the component
+ type.</xs:documentation>
</xs:annotation>
</xs:attribute>
- <xs:attribute name="architecture" type="xs:boolean"
- use="optional">
+ <xs:attribute name="architecture" type="xs:boolean" use="optional">
<xs:annotation>
- <xs:documentation>Enables or disables the architecture exposition. By default, the architecture is exposed. This allows instance introspection.</xs:documentation>
+ <xs:documentation>Enables or disables the architecture exposition. By default, the
+ architecture is exposed. This allows instance introspection.</xs:documentation>
</xs:annotation>
</xs:attribute>
- <xs:attribute name="immediate" type="xs:boolean"
- use="optional">
- <xs:annotation>
- <xs:documentation>Creates the object of the component implementation type as soon as the component instance becomes valid. The default value is "true" if the component doesn't provide any service, "false" otherwise.</xs:documentation>
- </xs:annotation>
+ <xs:attribute name="immediate" type="xs:boolean" use="optional">
+ <xs:annotation>
+ <xs:documentation>Creates the object of the component implementation type as soon as the
+ component instance becomes valid. The default value is "true" if the component doesn't
+ provide any service, "false" otherwise.</xs:documentation>
+ </xs:annotation>
</xs:attribute>
<xs:attribute name="factory-method" type="xs:string" use="optional">
<xs:annotation>
- <xs:documentation>Factory method called to create POJO objects instead of the constructor. The specified method must be a static method of the implementation class returning an instance of this implementation class. The factory method can receive the bundle context in argument.</xs:documentation>
- </xs:annotation></xs:attribute>
+ <xs:documentation>Factory method called to create POJO objects instead of the constructor.
+ The specified method must be a static method of the implementation class returning an
+ instance of this implementation class. The factory method can receive the bundle context
+ in argument.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
<xs:attribute name="version" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation>Set the version of this component type</xs:documentation>
- </xs:annotation></xs:attribute>
+ </xs:annotation>
+ </xs:attribute>
</xs:complexType>
<xs:complexType name="RequiresType">
- <xs:annotation>
- <xs:documentation>Description of component services requirements.</xs:documentation>
- </xs:annotation>
- <xs:complexContent>
+ <xs:annotation>
+ <xs:documentation>Description of component services requirements.</xs:documentation>
+ </xs:annotation>
+ <xs:complexContent>
<xs:extension base="ServiceDependencyType">
<xs:sequence minOccurs="0" maxOccurs="unbounded">
- <xs:element name="callback"
- type="DependencyCallbackType">
- <xs:annotation>
- <xs:documentation>Service requirement method invocation description. Here can be specified a bind method called when a service appears and an unbind method called when a service disappears.</xs:documentation>
- </xs:annotation>
+ <xs:element name="callback" type="DependencyCallbackType">
+ <xs:annotation>
+ <xs:documentation>Service requirement method invocation description. Here can be
+ specified a bind method called when a service appears and an unbind method called
+ when a service disappears.</xs:documentation>
+ </xs:annotation>
</xs:element>
</xs:sequence>
- <xs:attribute name="interface" type="xs:string"
- use="prohibited">
- <xs:annotation>
- <xs:documentation>The interface describing the required service type. This attribute is needed only when using aggregate dependencies with field injection and when the type of this field is a list, vector, collection and set. This attribute is deprecated, use 'specification'.</xs:documentation>
- </xs:annotation>
+ <xs:attribute name="interface" type="xs:string" use="prohibited">
+ <xs:annotation>
+ <xs:documentation>The interface describing the required service type. This attribute is
+ needed only when using aggregate dependencies with field injection and when the type
+ of this field is a list, vector, collection and set. This attribute is deprecated, use
+ 'specification'.</xs:documentation>
+ </xs:annotation>
</xs:attribute>
- <xs:attribute name="field" type="xs:string"
- use="optional">
- <xs:annotation>
- <xs:documentation>The name of the field representing the service dependency in the implementation class.</xs:documentation>
- </xs:annotation>
+ <xs:attribute name="field" type="xs:string" use="optional">
+ <xs:annotation>
+ <xs:documentation>The name of the field representing the service dependency in the
+ implementation class.</xs:documentation>
+ </xs:annotation>
</xs:attribute>
- <xs:attribute name="nullable" type="xs:boolean"
- use="optional">
- <xs:annotation>
- <xs:documentation>Enable or disable the Nullable pattern on optional service dependencies. By default, Nullable pattern is enabled. If disabled, iPOJO will inject null instead of a Nullable object.</xs:documentation>
- </xs:annotation>
+ <xs:attribute name="nullable" type="xs:boolean" use="optional">
+ <xs:annotation>
+ <xs:documentation>Enable or disable the Nullable pattern on optional service
+ dependencies. By default, Nullable pattern is enabled. If disabled, iPOJO will inject
+ null instead of a Nullable object.</xs:documentation>
+ </xs:annotation>
</xs:attribute>
- <xs:attribute name="default-implementation"
- type="xs:string" use="optional">
- <xs:annotation>
- <xs:documentation>Specifies the default implementation class for an optional service dependency. If no providers are found, iPOJO creates an instance of the default-implementation (nullary constructor) and injects it. The given class must implement the required service interface.</xs:documentation>
- </xs:annotation>
+ <xs:attribute name="default-implementation" type="xs:string" use="optional">
+ <xs:annotation>
+ <xs:documentation>Specifies the default implementation class for an optional service
+ dependency. If no providers are found, iPOJO creates an instance of the
+ default-implementation (nullary constructor) and injects it. The given class must
+ implement the required service interface.</xs:documentation>
+ </xs:annotation>
</xs:attribute>
- <xs:attribute name="from" type="xs:string"
- use="optional">
- <xs:annotation>
- <xs:documentation>Specific service provider. The dependency can only be fulfilled by the component with the matching name, or by the service with a matching PID.</xs:documentation>
- </xs:annotation>
+ <xs:attribute name="from" type="xs:string" use="optional">
+ <xs:annotation>
+ <xs:documentation>Specific service provider. The dependency can only be fulfilled by the
+ component with the matching name, or by the service with a matching
+ PID.</xs:documentation>
+ </xs:annotation>
</xs:attribute>
-
- <xs:attribute name="proxy" type="xs:boolean"
- use="optional">
- <xs:annotation>
- <xs:documentation>Enables or Disable the proxy injection (on field injection)</xs:documentation>
- </xs:annotation>
+
+ <xs:attribute name="proxy" type="xs:boolean" use="optional">
+ <xs:annotation>
+ <xs:documentation>Enables or Disable the proxy injection (on field
+ injection)</xs:documentation>
+ </xs:annotation>
</xs:attribute>
<xs:attribute name="scope" use="optional">
<xs:simpleType>
<xs:restriction base="xs:string">
- <xs:enumeration value="global"></xs:enumeration>
- <xs:enumeration value="composite"></xs:enumeration>
- <xs:enumeration value="composite+global"></xs:enumeration>
+ <xs:enumeration value="global"/>
+ <xs:enumeration value="composite"/>
+ <xs:enumeration value="composite+global"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
@@ -282,213 +309,269 @@
</xs:complexContent>
</xs:complexType>
<xs:complexType name="DependencyCallbackType">
- <xs:annotation>
- <xs:documentation>Dependency callbacks are used to receive notification when service providers arrive and leave.</xs:documentation>
- </xs:annotation>
- <xs:attribute name="method" type="xs:string" use="required">
- <xs:annotation>
- <xs:documentation>Method to call</xs:documentation>
- </xs:annotation></xs:attribute>
+ <xs:annotation>
+ <xs:documentation>Dependency callbacks are used to receive notification when service providers
+ arrive and leave.</xs:documentation>
+ </xs:annotation>
+ <xs:attribute name="method" type="xs:string" use="required">
+ <xs:annotation>
+ <xs:documentation>Method to call</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
<xs:attribute name="type" use="required">
- <xs:annotation>
- <xs:documentation>
- Type of callback (bind, unbind, or updated). Bind means that the method will be called when a provider arrives. Unbind means that the method will be called when a provider leaves.
- Updated means that a service was modified but is still valid for the service dependency.
- </xs:documentation>
- </xs:annotation>
- <xs:simpleType>
+ <xs:annotation>
+ <xs:documentation> Type of callback (bind, unbind, or updated). Bind means that the method
+ will be called when a provider arrives. Unbind means that the method will be called when a
+ provider leaves. Updated means that a service was modified but is still valid for the
+ service dependency. </xs:documentation>
+ </xs:annotation>
+ <xs:simpleType>
<xs:restriction base="xs:string">
- <xs:enumeration value="bind"></xs:enumeration>
- <xs:enumeration value="unbind"></xs:enumeration>
- <xs:enumeration value="modified"></xs:enumeration>
+ <xs:enumeration value="bind"/>
+ <xs:enumeration value="unbind"/>
+ <xs:enumeration value="modified"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
<xs:complexType name="CallbackType">
- <xs:annotation>
- <xs:documentation>Lifecycle Callback. Allows a POJO to be notified when the instance becomes valid or invalid.</xs:documentation>
- </xs:annotation>
- <xs:attribute name="method" type="xs:string" use="required">
- <xs:annotation>
- <xs:documentation>Specifies the method to call on the transition.</xs:documentation>
- </xs:annotation></xs:attribute>
+ <xs:annotation>
+ <xs:documentation>Lifecycle Callback. Allows a POJO to be notified when the instance becomes
+ valid or invalid.</xs:documentation>
+ </xs:annotation>
+ <xs:attribute name="method" type="xs:string" use="required">
+ <xs:annotation>
+ <xs:documentation>Specifies the method to call on the transition.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
<xs:attribute name="transition" use="required">
- <xs:annotation>
- <xs:documentation>Specifies the transition when the callback needs to be invoked.</xs:documentation>
- </xs:annotation>
- <xs:simpleType>
- <xs:annotation>
- <xs:documentation>Lifecycle transition state. "validate" means that the component's instance was invalid and becomes valid, "invalidate" means that the component's intance was valid and becomes invalid.</xs:documentation>
- </xs:annotation>
- <xs:restriction base="xs:string">
- <xs:enumeration value="validate"></xs:enumeration>
- <xs:enumeration value="invalidate"></xs:enumeration>
+ <xs:annotation>
+ <xs:documentation>Specifies the transition when the callback needs to be
+ invoked.</xs:documentation>
+ </xs:annotation>
+ <xs:simpleType>
+ <xs:annotation>
+ <xs:documentation>Lifecycle transition state. "validate" means that the component's
+ instance was invalid and becomes valid, "invalidate" means that the component's intance
+ was valid and becomes invalid.</xs:documentation>
+ </xs:annotation>
+ <xs:restriction base="xs:string">
+ <xs:enumeration value="validate"/>
+ <xs:enumeration value="invalidate"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
</xs:complexType>
- <xs:element name="provides" type="ProvidesType" id="provides"></xs:element>
- <xs:complexType name="ProvidesType">
- <xs:annotation>
- <xs:documentation>Provided service(s) description.</xs:documentation>
- </xs:annotation>
- <xs:sequence minOccurs="0" maxOccurs="unbounded">
+ <xs:element name="provides" type="ProvidesType" id="provides"/>
+ <xs:complexType name="ProvidesType">
+ <xs:annotation>
+ <xs:documentation>Provided service(s) description.</xs:documentation>
+ </xs:annotation>
+ <xs:sequence minOccurs="0" maxOccurs="unbounded">
+ <xs:choice>
<xs:element name="property" type="PropertyType">
<xs:annotation>
<xs:documentation>List of service specific properties.</xs:documentation>
- </xs:annotation></xs:element>
+ </xs:annotation>
+ </xs:element>
+ <xs:element name="controller" minOccurs="0" maxOccurs="1" type="ServiceControllerType">
+ <xs:annotation>
+ <xs:documentation>Service Controller impacting the current provided
+ service</xs:documentation>
+ </xs:annotation>
+ </xs:element>
+ </xs:choice>
</xs:sequence>
<xs:attribute name="interface" type="xs:string" use="prohibited">
<xs:annotation>
- <xs:documentation>Deprecated attribute, use 'specifications' instead of 'interface'</xs:documentation>
- </xs:annotation></xs:attribute>
+ <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: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>
<xs:documentation>Use 'strategy' instead of 'factory'</xs:documentation>
- </xs:annotation></xs:attribute>
+ </xs:annotation>
+ </xs:attribute>
<xs:attribute name="strategy" type="xs:string" use="optional">
<xs:annotation>
- <xs:documentation>POJO creation strategy. By default, the POJO object is created once (singleton). If the factory is set to "SERVICE", the creation policy follows the OSGi service factory policy (one object object per asking bundle).
- INSTANCE allows creating one different POJO object per asking instance. Finally, a custom strategy can be used by specifying the qualified name of the class extending CreationPolicy</xs:documentation>
- </xs:annotation></xs:attribute>
+ <xs:documentation>POJO creation strategy. By default, the POJO object is created once
+ (singleton). If the factory is set to "SERVICE", the creation policy follows the OSGi
+ service factory policy (one object object per asking bundle). INSTANCE allows creating one
+ different POJO object per asking instance. Finally, a custom strategy can be used by
+ specifying the qualified name of the class extending CreationPolicy</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
</xs:complexType>
- <xs:complexType name="PropertyType">
+ <xs:complexType name="ServiceControllerType">
<xs:annotation>
- <xs:documentation>
- Defines a component property.
- </xs:documentation>
+ <xs:documentation> Defines a service controller. </xs:documentation>
</xs:annotation>
- <xs:attribute name="field" type="xs:string" use="optional">
+ <xs:attribute name="field" type="xs:string" use="required">
<xs:annotation>
- <xs:documentation>
- Field of the property
- </xs:documentation>
- </xs:annotation>
- </xs:attribute>
- <xs:attribute name="method" type="xs:string" use="optional">
- <xs:annotation>
- <xs:documentation>
- Setter method of the property. This method is called
- to inject property value.
- </xs:documentation>
- </xs:annotation>
- </xs:attribute>
- <xs:attribute name="name" type="xs:string" use="optional">
- <xs:annotation>
- <xs:documentation>
- Name of the property.
- </xs:documentation>
+ <xs:documentation> Field of the controller </xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="value" type="xs:string" use="optional">
<xs:annotation>
- <xs:documentation>
- Default value of the property.
- </xs:documentation>
+ <xs:documentation> Intiail value of the controller </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ </xs:complexType>
+ <xs:complexType name="PropertyType">
+ <xs:annotation>
+ <xs:documentation> Defines a component property. </xs:documentation>
+ </xs:annotation>
+ <xs:attribute name="field" type="xs:string" use="optional">
+ <xs:annotation>
+ <xs:documentation> Field of the property </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="method" type="xs:string" use="optional">
+ <xs:annotation>
+ <xs:documentation> Setter method of the property. This method is called to inject property
+ value. </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="name" type="xs:string" use="optional">
+ <xs:annotation>
+ <xs:documentation> Name of the property. </xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ <xs:attribute name="value" type="xs:string" use="optional">
+ <xs:annotation>
+ <xs:documentation> Default value of the property. </xs:documentation>
</xs:annotation>
</xs:attribute>
<xs:attribute name="type" type="xs:string" use="optional">
<xs:annotation>
- <xs:documentation>
- Type of the property.
- </xs:documentation>
+ <xs:documentation> Type of the property. </xs:documentation>
</xs:annotation>
</xs:attribute>
- <xs:attribute name="mandatory" type="xs:boolean" use="optional" default="false">
- <xs:annotation>
- <xs:documentation>Set the property as mandatory. A mandatory property MUST receive a value either in the component type description or in the instance configuration. Properties are optional by default.</xs:documentation>
- </xs:annotation></xs:attribute>
- </xs:complexType>
- <xs:element name="callback" type="CallbackType" id="callback"></xs:element>
+ <xs:attribute name="mandatory" type="xs:boolean" use="optional" default="false">
+ <xs:annotation>
+ <xs:documentation>Set the property as mandatory. A mandatory property MUST receive a value
+ either in the component type description or in the instance configuration. Properties are
+ optional by default.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ </xs:complexType>
+ <xs:element name="callback" type="CallbackType" id="callback"/>
<xs:element name="controller" type="ControllerType" id="controller">
<xs:annotation>
- <xs:documentation></xs:documentation>
- </xs:annotation></xs:element>
- <xs:element name="requires" type="RequiresType" id="requires"></xs:element>
- <xs:element name="component" type="ComponentType" id="component"></xs:element>
- <xs:element name="handler" type="HandlerType" id="handler"></xs:element>
- <xs:element name="instance" type="InstanceType" id="instance"></xs:element>
+ <xs:documentation/>
+ </xs:annotation>
+ </xs:element>
+ <xs:element name="requires" type="RequiresType" id="requires"/>
+ <xs:element name="component" type="ComponentType" id="component"/>
+ <xs:element name="handler" type="HandlerType" id="handler"/>
+ <xs:element name="instance" type="InstanceType" id="instance"/>
- <xs:element name="properties" type="PropertiesType" id="properties"></xs:element>
+ <xs:element name="properties" type="PropertiesType" id="properties"/>
<xs:complexType name="PropertiesType">
- <xs:annotation>
- <xs:documentation>List of component, instance or service properties. This field will receive the property value.</xs:documentation>
- </xs:annotation>
- <xs:sequence minOccurs="0" maxOccurs="unbounded">
+ <xs:annotation>
+ <xs:documentation>List of component, instance or service properties. This field will receive
+ the property value.</xs:documentation>
+ </xs:annotation>
+ <xs:sequence minOccurs="0" maxOccurs="unbounded">
<xs:element name="property" type="PropertyType">
<xs:annotation>
<xs:documentation>The list of properties.</xs:documentation>
- </xs:annotation></xs:element>
+ </xs:annotation>
+ </xs:element>
</xs:sequence>
<xs:attribute name="propagation" type="xs:boolean" use="optional">
<xs:annotation>
- <xs:documentation>Propagation of the component properties to the provided services. If this parameter is set to "true", each time properties are reconfigured, they are propagated to each service published by the component.</xs:documentation>
- </xs:annotation></xs:attribute>
+ <xs:documentation>Propagation of the component properties to the provided services. If this
+ parameter is set to "true", each time properties are reconfigured, they are propagated to
+ each service published by the component.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
<xs:attribute name="pid" type="xs:string" use="optional">
<xs:annotation>
- <xs:documentation>Unique identifier used to reconfigure components properties (via Managed Services) with the Configuration Admin.</xs:documentation>
- </xs:annotation></xs:attribute>
+ <xs:documentation>Unique identifier used to reconfigure components properties (via Managed
+ Services) with the Configuration Admin.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
<xs:attribute name="updated" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation>Method called when a reconfiguration is done</xs:documentation>
- </xs:annotation></xs:attribute>
+ </xs:annotation>
+ </xs:attribute>
</xs:complexType>
<xs:complexType name="ServiceDependencyType">
- <xs:attribute name="specification" type="xs:string" use="optional">
- <xs:annotation>
- <xs:documentation>The specification describing the required service type. This attribute is needed only when using aggregate dependencies with field injection and when the type of this field is a list, vector, collection and set.</xs:documentation>
- </xs:annotation></xs:attribute>
+ <xs:attribute name="specification" type="xs:string" use="optional">
+ <xs:annotation>
+ <xs:documentation>The specification describing the required service type. This attribute is
+ needed only when using aggregate dependencies with field injection and when the type of
+ this field is a list, vector, collection and set.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
<xs:attribute name="optional" type="xs:boolean" use="optional">
- <xs:annotation>
- <xs:documentation>Sets the service dependency optionality</xs:documentation>
- </xs:annotation>
+ <xs:annotation>
+ <xs:documentation>Sets the service dependency optionality</xs:documentation>
+ </xs:annotation>
</xs:attribute>
<xs:attribute name="aggregate" type="xs:boolean" use="optional">
- <xs:annotation>
- <xs:documentation>Sets the service dependency cardinality.</xs:documentation>
- </xs:annotation>
+ <xs:annotation>
+ <xs:documentation>Sets the service dependency cardinality.</xs:documentation>
+ </xs:annotation>
</xs:attribute>
<xs:attribute name="policy" use="optional">
- <xs:annotation>
- <xs:documentation>Sets the binding policy of the dependency. Three policies are supported. The dynamic policy supports service providers dynamism. The static policy freezes the provider set as soon as the dependency is used. The dynamic-priority policy is an extension of the dynamic policy, but providers are ranked.</xs:documentation>
- </xs:annotation>
- <xs:simpleType>
+ <xs:annotation>
+ <xs:documentation>Sets the binding policy of the dependency. Three policies are supported.
+ The dynamic policy supports service providers dynamism. The static policy freezes the
+ provider set as soon as the dependency is used. The dynamic-priority policy is an
+ extension of the dynamic policy, but providers are ranked.</xs:documentation>
+ </xs:annotation>
+ <xs:simpleType>
<xs:restriction base="xs:string">
- <xs:enumeration value="dynamic"></xs:enumeration>
- <xs:enumeration value="static"></xs:enumeration>
- <xs:enumeration value="dynamic-priority"></xs:enumeration>
+ <xs:enumeration value="dynamic"/>
+ <xs:enumeration value="static"/>
+ <xs:enumeration value="dynamic-priority"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="comparator" type="xs:string" use="optional">
- <xs:annotation>
- <xs:documentation>The comparator attribute allows specifying the class used to compare providers. This class must implemented the java.util.Comparator class and must support the comparison of service references.</xs:documentation>
- </xs:annotation>
+ <xs:annotation>
+ <xs:documentation>The comparator attribute allows specifying the class used to compare
+ providers. This class must implemented the java.util.Comparator class and must support the
+ comparison of service references.</xs:documentation>
+ </xs:annotation>
</xs:attribute>
<xs:attribute name="filter" type="xs:string" use="optional">
<xs:annotation>
<xs:documentation>LDAP filter used to filter providers</xs:documentation>
- </xs:annotation></xs:attribute>
+ </xs:annotation>
+ </xs:attribute>
<xs:attribute name="id" type="xs:string" use="optional">
<xs:annotation>
- <xs:documentation>id of the service dependency. The id allows to indentify and to refert to this dependency.</xs:documentation>
- </xs:annotation></xs:attribute>
+ <xs:documentation>id of the service dependency. The id allows to indentify and to refert to
+ this dependency.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
</xs:complexType>
- <xs:complexType name="ControllerType">
- <xs:annotation>
- <xs:documentation>Specifies the lifecycle controller of a component, which allows to validate or invalidate component instances.</xs:documentation>
- </xs:annotation>
- <xs:attribute name="field" type="xs:string" use="required">
- <xs:annotation>
- <xs:documentation>The name of the component lifecycle controller field. The type of the specified field must be boolean. Setting the value of the specified field to "true" means the validation of the component instance while setting it to "false" means the invalidation of the component instance.</xs:documentation>
- </xs:annotation>
- </xs:attribute>
- </xs:complexType>
+ <xs:complexType name="ControllerType">
+ <xs:annotation>
+ <xs:documentation>Specifies the lifecycle controller of a component, which allows to validate
+ or invalidate component instances.</xs:documentation>
+ </xs:annotation>
+ <xs:attribute name="field" type="xs:string" use="required">
+ <xs:annotation>
+ <xs:documentation>The name of the component lifecycle controller field. The type of the
+ specified field must be boolean. Setting the value of the specified field to "true" means
+ the validation of the component instance while setting it to "false" means the
+ invalidation of the component instance.</xs:documentation>
+ </xs:annotation>
+ </xs:attribute>
+ </xs:complexType>
</xs:schema>
diff --git a/ipojo/tests/core/annotations/pom.xml b/ipojo/tests/core/annotations/pom.xml
index d54fe9b..1942108 100644
--- a/ipojo/tests/core/annotations/pom.xml
+++ b/ipojo/tests/core/annotations/pom.xml
@@ -116,7 +116,7 @@
</plugin>
- <!-- <plugin>
+ <plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-junit4osgi-plugin</artifactId>
<version>1.1.0-SNAPSHOT</version>
@@ -132,7 +132,7 @@
</configuration>
</execution>
</executions>
- </plugin>-->
+ </plugin>
</plugins>
</build>
</project>
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/ServiceProdiving.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/ServiceProdiving.java
index 2702235..15c5813 100644
--- a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/ServiceProdiving.java
+++ b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/annotations/ServiceProdiving.java
@@ -82,6 +82,16 @@
}
+ public void testServiceController() {
+ Element meta = helper.getMetadata("org.apache.felix.ipojo.test.scenarios.component.PSServiceController");
+ Element[] provs = meta.getElements("provides");
+ assertNotNull("Provides exists ", provs);
+ System.out.println(provs[0].toString());
+ assertNotNull(provs[0].getElements("controller"));
+ assertEquals(1, provs[0].getElements("controller").length);
+ assertEquals("false", provs[0].getElements("controller")[0].getAttribute("value"));
+ }
+
private Element getPropertyByName(Element[] props, String name) {
for (int i = 0; i < props.length; i++) {
String na = props[i].getAttribute("name");
diff --git a/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/PSServiceController.java b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/PSServiceController.java
new file mode 100644
index 0000000..13b905c
--- /dev/null
+++ b/ipojo/tests/core/annotations/src/main/java/org/apache/felix/ipojo/test/scenarios/component/PSServiceController.java
@@ -0,0 +1,54 @@
+package org.apache.felix.ipojo.test.scenarios.component;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.annotations.Component;
+import org.apache.felix.ipojo.annotations.Provides;
+import org.apache.felix.ipojo.annotations.ServiceController;
+import org.apache.felix.ipojo.test.scenarios.annotations.service.BarService;
+import org.apache.felix.ipojo.test.scenarios.annotations.service.FooService;
+
+@Component
+@Provides(specifications= {FooService.class, BarService.class})
+public class PSServiceController implements FooService, BarService {
+
+ @ServiceController(value=false)
+ public boolean controller;
+
+ public boolean foo() {
+ return false;
+ }
+
+ public Properties fooProps() {
+ return null;
+ }
+
+ public boolean getBoolean() {
+ return false;
+ }
+
+ public double getDouble() {
+ return 0;
+ }
+
+ public int getInt() {
+ return 0;
+ }
+
+ public long getLong() {
+ return 0;
+ }
+
+ public Boolean getObject() {
+ return null;
+ }
+
+ public boolean bar() {
+ return false;
+ }
+
+ public Properties getProps() {
+ return null;
+ }
+
+}
diff --git a/ipojo/tests/core/service-providing/pom.xml b/ipojo/tests/core/service-providing/pom.xml
index 2e6ed9c..bdbf7e0 100644
--- a/ipojo/tests/core/service-providing/pom.xml
+++ b/ipojo/tests/core/service-providing/pom.xml
@@ -1,102 +1,120 @@
<!--
- 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
+ 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
+ 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.
+ 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.
-->
<project>
- <modelVersion>4.0.0</modelVersion>
- <packaging>bundle</packaging>
- <name>iPOJO Service Providing Test Suite</name>
- <artifactId>tests.core.ps</artifactId>
- <groupId>ipojo.tests</groupId>
- <version>1.5.0-SNAPSHOT</version>
- <dependencies>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo</artifactId>
- <version>${pom.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.metadata</artifactId>
- <version>${pom.version}</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.osgi.core</artifactId>
- <version>1.0.1</version>
- </dependency>
- <dependency>
- <groupId>junit</groupId>
- <artifactId>junit</artifactId>
- <version>3.8.1</version>
- </dependency>
- <dependency>
- <groupId>org.apache.felix</groupId>
- <artifactId>org.apache.felix.ipojo.junit4osgi</artifactId>
- <version>1.1.0-SNAPSHOT</version>
- </dependency>
- </dependencies>
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-bundle-plugin</artifactId>
- <version>1.4.3</version>
- <extensions>true</extensions>
- <configuration>
- <instructions>
- <Export-Package>
- org.apache.felix.ipojo.test.scenarios.ps.service
- </Export-Package>
- <Bundle-SymbolicName>
- ${pom.artifactId}
- </Bundle-SymbolicName>
- <Private-Package>
- org.apache.felix.ipojo.test*
- </Private-Package>
- <Test-Suite>
- org.apache.felix.ipojo.test.scenarios.ps.ProvidedServiceTestSuite
- </Test-Suite>
- </instructions>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.felix</groupId>
- <artifactId>maven-ipojo-plugin</artifactId>
- <version>${pom.version}</version>
- <executions>
- <execution>
- <goals>
- <goal>ipojo-bundle</goal>
- </goals>
- <configuration>
- <ignoreAnnotations>true</ignoreAnnotations>
- </configuration>
- </execution>
- </executions>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <configuration>
- <source>1.4</source>
- <target>1.4</target>
- </configuration>
- </plugin>
- </plugins>
- </build>
+ <modelVersion>4.0.0</modelVersion>
+ <packaging>bundle</packaging>
+ <name>iPOJO Service Providing Test Suite</name>
+ <artifactId>tests.core.ps</artifactId>
+ <groupId>ipojo.tests</groupId>
+ <version>1.5.0-SNAPSHOT</version>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.ipojo</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.ipojo.metadata</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.osgi.core</artifactId>
+ <version>1.0.1</version>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>3.8.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.ipojo.junit4osgi</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-bundle-plugin</artifactId>
+ <version>1.4.3</version>
+ <extensions>true</extensions>
+ <configuration>
+ <instructions>
+ <Export-Package>
+ org.apache.felix.ipojo.test.scenarios.ps.service
+ </Export-Package>
+ <Bundle-SymbolicName>
+ ${pom.artifactId}
+ </Bundle-SymbolicName>
+ <Private-Package>
+ org.apache.felix.ipojo.test*
+ </Private-Package>
+ <Test-Suite>
+ org.apache.felix.ipojo.test.scenarios.ps.ProvidedServiceTestSuite
+ </Test-Suite>
+ </instructions>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-ipojo-plugin</artifactId>
+ <version>${pom.version}</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>ipojo-bundle</goal>
+ </goals>
+ <configuration>
+ <ignoreAnnotations>true</ignoreAnnotations>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.4</source>
+ <target>1.4</target>
+ </configuration>
+ </plugin>
+
+ <plugin>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>maven-junit4osgi-plugin</artifactId>
+ <version>1.1.0-SNAPSHOT</version>
+ <executions>
+ <execution>
+ <goals>
+ <goal>test</goal>
+ </goals>
+ <configuration>
+ <configuration>
+ <org.osgi.http.port>8083</org.osgi.http.port>
+ </configuration>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
</project>
diff --git a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/controller/ControllerCheckService.java b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/controller/ControllerCheckService.java
new file mode 100644
index 0000000..988294f
--- /dev/null
+++ b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/controller/ControllerCheckService.java
@@ -0,0 +1,56 @@
+package org.apache.felix.ipojo.test.scenarios.component.controller;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.test.scenarios.ps.service.CheckService;
+import org.apache.felix.ipojo.test.scenarios.ps.service.FooService;
+
+public class ControllerCheckService implements FooService, CheckService {
+
+
+ private boolean controller;
+
+ public boolean foo() {
+ return controller;
+ }
+
+ public Properties fooProps() {
+ Properties props = new Properties();
+ props.put("controller", new Boolean(controller));
+ return props;
+ }
+
+ public boolean getBoolean() {
+ return false;
+ }
+
+ public double getDouble() {
+ return 0;
+ }
+
+ public int getInt() {
+ return 0;
+ }
+
+ public long getLong() {
+ return 0;
+ }
+
+ public Boolean getObject() {
+ return null;
+ }
+
+ public boolean check() {
+ System.out.println("Before : " + controller);
+ controller = ! controller; // Change
+ System.out.println("After : " + controller);
+ return controller;
+ }
+
+ public Properties getProps() {
+ Properties props = new Properties();
+ props.put("controller", new Boolean(controller));
+ return props;
+ }
+
+}
diff --git a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/controller/DoubleControllerCheckService.java b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/controller/DoubleControllerCheckService.java
new file mode 100644
index 0000000..bdfa92c
--- /dev/null
+++ b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/component/controller/DoubleControllerCheckService.java
@@ -0,0 +1,66 @@
+package org.apache.felix.ipojo.test.scenarios.component.controller;
+
+import java.util.Properties;
+
+import org.apache.felix.ipojo.test.scenarios.ps.service.CheckService;
+import org.apache.felix.ipojo.test.scenarios.ps.service.FooService;
+
+public class DoubleControllerCheckService implements FooService, CheckService {
+
+
+ private boolean controllerFoo;
+ private boolean controllerCS;
+
+ public boolean foo() {
+ controllerFoo = ! controllerFoo;
+ return controllerFoo;
+ }
+
+ public Properties fooProps() {
+ Properties props = new Properties();
+ props.put("controller", new Boolean(controllerFoo));
+
+ controllerCS = true;
+ controllerFoo = true;
+
+ return props;
+ }
+
+ public boolean getBoolean() {
+ return false;
+ }
+
+ public double getDouble() {
+ return 0;
+ }
+
+ public int getInt() {
+ return 0;
+ }
+
+ public long getLong() {
+ return 0;
+ }
+
+ public Boolean getObject() {
+ return null;
+ }
+
+ public boolean check() {
+ controllerCS = ! controllerCS;
+ return controllerCS;
+ }
+
+ public Properties getProps() {
+ Properties props = new Properties();
+ props.put("controller", new Boolean(controllerCS));
+
+ // Invert both
+ controllerCS = ! controllerCS;
+ controllerFoo = ! controllerFoo;
+
+ return props;
+
+ }
+
+}
diff --git a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/ProvidedServiceTestSuite.java b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/ProvidedServiceTestSuite.java
index 720c46a..5e9adc6 100644
--- a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/ProvidedServiceTestSuite.java
+++ b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/ProvidedServiceTestSuite.java
@@ -39,6 +39,7 @@
ots.addTestSuite(ClassTest.class);
ots.addTestSuite(OSGiPropertiesTest.class);
ots.addTestSuite(NullCheck.class);
+ ots.addTestSuite(ServiceControllerTest.class);
return ots;
}
diff --git a/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/ServiceControllerTest.java b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/ServiceControllerTest.java
new file mode 100644
index 0000000..c325ece
--- /dev/null
+++ b/ipojo/tests/core/service-providing/src/main/java/org/apache/felix/ipojo/test/scenarios/ps/ServiceControllerTest.java
@@ -0,0 +1,168 @@
+/*
+ * 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.test.scenarios.ps;
+
+import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.handlers.providedservice.ProvidedServiceDescription;
+import org.apache.felix.ipojo.handlers.providedservice.ProvidedServiceHandlerDescription;
+import org.apache.felix.ipojo.junit4osgi.OSGiTestCase;
+import org.apache.felix.ipojo.junit4osgi.helpers.IPOJOHelper;
+import org.apache.felix.ipojo.test.scenarios.ps.service.CheckService;
+import org.apache.felix.ipojo.test.scenarios.ps.service.FooService;
+
+public class ServiceControllerTest extends OSGiTestCase {
+
+ IPOJOHelper helper;
+
+ public void setUp() {
+ helper = new IPOJOHelper(this);
+ }
+
+
+ public void tearDown() {
+ helper.dispose();
+ }
+
+
+ public void testComponentWithAController() {
+ ComponentInstance ci = helper.createComponentInstance("PS-Controller-1-default");
+ // Controller set to true.
+ waitForService(FooService.class.getName(), null, 5000);
+ waitForService(CheckService.class.getName(), null, 5000);
+
+ CheckService check = (CheckService) getServiceObject(CheckService.class.getName(), null);
+ assertNotNull(check);
+
+ assertFalse(check.check());
+
+ // FooService should not be there anymore
+ assertNull(getServiceReference(FooService.class.getName()));
+
+ assertTrue(check.check());
+
+ assertNotNull(getServiceReference(FooService.class.getName()));
+
+ ci.dispose();
+ }
+
+ public void testComponentWithAControllerSetToFalse() {
+ ComponentInstance ci = helper.createComponentInstance("PS-Controller-1-false");
+ // Controller set to false.
+ waitForService(CheckService.class.getName(), null, 5000);
+ assertNull(getServiceReference(FooService.class.getName()));
+
+ CheckService check = (CheckService) getServiceObject(CheckService.class.getName(), null);
+ assertNotNull(check);
+
+ assertTrue(check.check());
+ assertNotNull(getServiceReference(FooService.class.getName()));
+
+ assertFalse(check.check());
+ // FooService should not be there anymore
+ assertNull(getServiceReference(FooService.class.getName()));
+
+ ci.dispose();
+ }
+
+ public void testComponentWithTwoControllersSetToTrue() {
+ ComponentInstance ci = helper.createComponentInstance("PS-Controller-2-truetrue");
+
+ waitForService(CheckService.class.getName(), null, 5000);
+ waitForService(FooService.class.getName(), null, 5000);
+
+ CheckService check = (CheckService) getServiceObject(CheckService.class.getName(), null);
+ assertNotNull(check);
+
+ check.check();
+
+ assertNull(getServiceReference(CheckService.class.getName()));
+ assertNotNull(getServiceReference(FooService.class.getName()));
+
+ FooService fs = (FooService) getServiceObject(FooService.class.getName(), null);
+ fs.foo();
+
+ assertNull(getServiceReference(CheckService.class.getName()));
+ assertNull(getServiceReference(FooService.class.getName()));
+
+ ci.dispose();
+ }
+
+ public void testComponentWithTwoControllersSetToTrueAndFalse() {
+ ComponentInstance ci = helper.createComponentInstance("PS-Controller-2-truefalse");
+
+ waitForService(CheckService.class.getName(), null, 5000);
+
+ assertFalse(isServiceAvailable(FooService.class.getName()));
+
+ CheckService check = (CheckService) getServiceObject(CheckService.class.getName(), null);
+ assertNotNull(check);
+
+ check.getProps();
+
+ assertFalse(isServiceAvailable(CheckService.class.getName()));
+ assertTrue(isServiceAvailable(FooService.class.getName()));
+
+ FooService fs = (FooService) getServiceObject(FooService.class.getName(), null);
+ fs.fooProps();
+
+ assertTrue(isServiceAvailable(CheckService.class.getName()));
+ assertTrue(isServiceAvailable(FooService.class.getName()));
+
+ ci.dispose();
+ }
+
+ public void testArchitecture() {
+ ComponentInstance ci = helper.createComponentInstance("PS-Controller-1-default");
+ // Controller set to true.
+ waitForService(FooService.class.getName(), null, 5000);
+ waitForService(CheckService.class.getName(), null, 5000);
+
+ ProvidedServiceHandlerDescription pshd = null;
+ pshd = (ProvidedServiceHandlerDescription) ci.getInstanceDescription()
+ .getHandlerDescription("org.apache.felix.ipojo:provides");
+
+ ProvidedServiceDescription ps = getPS(FooService.class.getName(), pshd.getProvidedServices());
+ assertEquals("true", ps.getController());
+
+ CheckService check = (CheckService) getServiceObject(CheckService.class.getName(), null);
+ assertNotNull(check);
+
+ assertFalse(check.check());
+
+ ps = getPS(FooService.class.getName(), pshd.getProvidedServices());
+ assertEquals("false", ps.getController());
+
+ assertTrue(check.check());
+
+ ps = getPS(FooService.class.getName(), pshd.getProvidedServices());
+ assertEquals("true", ps.getController());
+
+ }
+
+ private ProvidedServiceDescription getPS(String itf, ProvidedServiceDescription[] svc) {
+ for (int i = 0; i < svc.length; i++) {
+ if (svc[i].getServiceSpecifications()[0].equals(itf)) {
+ return svc[i];
+ }
+ }
+
+ fail("Service : " + itf + " not found");
+ return null;
+ }
+}
diff --git a/ipojo/tests/core/service-providing/src/main/resources/metadata.xml b/ipojo/tests/core/service-providing/src/main/resources/metadata.xml
index 50c458d..6abd991 100644
--- a/ipojo/tests/core/service-providing/src/main/resources/metadata.xml
+++ b/ipojo/tests/core/service-providing/src/main/resources/metadata.xml
@@ -168,4 +168,46 @@
<property field="prop2"/>
</provides>
</component>
+
+ <!-- Service Controller -->
+ <component classname="org.apache.felix.ipojo.test.scenarios.component.controller.ControllerCheckService"
+ name="PS-Controller-1-default">
+ <provides specifications="org.apache.felix.ipojo.test.scenarios.ps.service.FooService">
+ <controller field="controller"/>
+ </provides>
+ <provides specifications="org.apache.felix.ipojo.test.scenarios.ps.service.CheckService">
+ </provides>
+ </component>
+ <component classname="org.apache.felix.ipojo.test.scenarios.component.controller.ControllerCheckService"
+ name="PS-Controller-1-false">
+ <provides specifications="org.apache.felix.ipojo.test.scenarios.ps.service.FooService">
+ <property name="test2" type="string" value="test2"/>
+ <controller field="controller" value="false"/>
+ <property name="test" type="string" value="test"/>
+ </provides>
+ <provides specifications="org.apache.felix.ipojo.test.scenarios.ps.service.CheckService">
+ </provides>
+ </component>
+ <component classname="org.apache.felix.ipojo.test.scenarios.component.controller.DoubleControllerCheckService"
+ name="PS-Controller-2-truetrue">
+ <provides specifications="org.apache.felix.ipojo.test.scenarios.ps.service.FooService">
+ <property name="test2" type="string" value="test2"/>
+ <controller field="controllerFoo" value="true"/>
+ <property name="test" type="string" value="test"/>
+ </provides>
+ <provides specifications="org.apache.felix.ipojo.test.scenarios.ps.service.CheckService">
+ <controller field="controllerCS" value="true"/>
+ </provides>
+ </component>
+ <component classname="org.apache.felix.ipojo.test.scenarios.component.controller.DoubleControllerCheckService"
+ name="PS-Controller-2-truefalse">
+ <provides specifications="org.apache.felix.ipojo.test.scenarios.ps.service.FooService">
+ <property name="test2" type="string" value="test2"/>
+ <controller field="controllerFoo" value="false"/>
+ <property name="test" type="string" value="test"/>
+ </provides>
+ <provides specifications="org.apache.felix.ipojo.test.scenarios.ps.service.CheckService">
+ <controller field="controllerCS" value="true"/>
+ </provides>
+ </component>
</ipojo>
diff --git a/ipojo/tests/handler/transaction/pom.xml b/ipojo/tests/handler/transaction/pom.xml
index 79a47cd..e3320cc 100644
--- a/ipojo/tests/handler/transaction/pom.xml
+++ b/ipojo/tests/handler/transaction/pom.xml
@@ -32,13 +32,19 @@
<artifactId>org.apache.felix.ipojo.handler.transaction</artifactId>
<version>${pom.version}</version>
</dependency>
+
+ <dependency>
+ <groupId>org.apache.felix</groupId>
+ <artifactId>org.apache.felix.ipojo.test.helpers</artifactId>
+ <version>${pom.version}</version>
+ </dependency>
<!--
Pax Exam API:
-->
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam</artifactId>
- <version>1.1.0</version>
+ <version>1.2.0</version>
</dependency>
<!--
During runtime Pax Exam will discover the OSGi container to use by
@@ -50,7 +56,7 @@
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-container-default
</artifactId>
- <version>1.1.0</version>
+ <version>1.2.0</version>
</dependency>
<!--
If your test code is based on JUnit you will have to have the Junit
@@ -59,7 +65,7 @@
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-junit</artifactId>
- <version>1.1.0</version>
+ <version>1.2.0</version>
</dependency>
<dependency>
<groupId>junit</groupId>
@@ -68,11 +74,11 @@
<type>jar</type>
<scope>test</scope>
</dependency>
-
+ <!-- Tinybundles -->
<dependency>
<groupId>org.ops4j.pax.swissbox</groupId>
<artifactId>pax-swissbox-tinybundles</artifactId>
- <version>1.0.0</version>
+ <version>1.2.0</version>
</dependency>
<dependency>
<groupId>org.apache.felix</groupId>
@@ -87,12 +93,12 @@
<dependency>
<groupId>org.ops4j.pax.logging</groupId>
<artifactId>pax-logging-api</artifactId>
- <version>1.3.0</version>
+ <version>1.4</version>
</dependency>
<dependency>
<groupId>org.ops4j.pax.logging</groupId>
<artifactId>pax-logging-service</artifactId>
- <version>1.3.0</version>
+ <version>1.4</version>
</dependency>
</dependencies>
diff --git a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/IPOJOHelper.java b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/IPOJOHelper.java
deleted file mode 100644
index 0fbe4d9..0000000
--- a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/IPOJOHelper.java
+++ /dev/null
@@ -1,730 +0,0 @@
-/*
- * 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.transaction.test;
-
-import java.util.ArrayList;
-import java.util.Dictionary;
-import java.util.List;
-import java.util.Properties;
-
-import org.apache.felix.ipojo.ComponentInstance;
-import org.apache.felix.ipojo.Factory;
-import org.apache.felix.ipojo.Handler;
-import org.apache.felix.ipojo.HandlerFactory;
-import org.apache.felix.ipojo.ServiceContext;
-import org.apache.felix.ipojo.architecture.Architecture;
-import org.apache.felix.ipojo.metadata.Element;
-import org.apache.felix.ipojo.parser.ManifestMetadataParser;
-import org.apache.felix.ipojo.parser.ParseException;
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.cm.ManagedServiceFactory;
-
-/**
- * iPOJO Helper.
- * This helper helps getting {@link Factory}, and managing
- * {@link ComponentInstance}.
- * @author <a href="mailto:dev@felix.apache.org">Felix Project Team</a>
- */
-public class IPOJOHelper {
-
- /**
- * The bundle context.
- */
- private BundleContext m_context;
-
-
- /**
- * List of instances.
- */
- private List<ComponentInstance> m_instances;
-
- /**
- * Creates a IPOJOHelper.
- * @param tc the OSGi Test Case
- */
- public IPOJOHelper(BundleContext context) {
- m_context = context;
- m_instances = new ArrayList<ComponentInstance>();
- }
-
- /**
- * Disposes created instances.
- * @see org.apache.felix.ipojo.junit4osgi.Helper#dispose()
- */
- public void dispose() {
- for (int i = 0; i < m_instances.size(); i++) {
- ((ComponentInstance) m_instances.get(i)).dispose();
- }
- m_instances.clear();
- }
-
- /**
- * Gets a created instance from the instance name.
- * @param name the instance name.
- * @return the created {@link ComponentInstance} or <code>null</code>
- * if the instance was not created during the session.
- */
- public ComponentInstance getInstanceByName(String name) {
- for (int i = 0; i < m_instances.size(); i++) {
- if (((ComponentInstance) m_instances.get(i)).getInstanceName()
- .equals(name)) {
- return (ComponentInstance) m_instances.get(i);
- }
- }
- return null;
- }
-
- /**
- * Creates a new component instance with the given name (and empty
- * configuration), from the factory specified in the given bundle.
- *
- * @param bundle the bundle from which the component factory is defined.
- * @param factoryName the name of the component factory, defined in the
- * specified bundle.
- * @param instanceName the name of the component instance to create.
- * @return the newly created component instance.
- */
- public static ComponentInstance createComponentInstance(Bundle bundle,
- String factoryName, String instanceName) {
-
- // Create the instance configuration
- Properties configuration = new Properties();
- configuration.put("instance.name", instanceName);
-
- return createComponentInstance(bundle, factoryName, configuration);
- }
-
- /**
- * Creates a new component instance with the given configuration, from the
- * factory specified in the given bundle.
- *
- * @param bundle the bundle from which the component factory is defined.
- * @param factoryName the name of the component factory, defined in the
- * specified bundle.
- * @param configuration the configuration of the component instance to
- * create.
- * @return the newly created component instance.
- */
- public static ComponentInstance createComponentInstance(Bundle bundle,
- String factoryName, Dictionary configuration) {
-
- // Retrieve the component factory.
- Factory fact = getFactory(bundle, factoryName);
-
- if (fact == null) {
- // Factory not found...
- throw new IllegalArgumentException(
- "Cannot find the component factory (" + factoryName
- + ") in the specified bundle ("
- + bundle.getSymbolicName() + ").");
- }
-
- try {
- return fact.createComponentInstance(configuration);
- } catch (Exception e) {
- throw new IllegalArgumentException(
- "Cannot create the component instance with the given configuration:"
- + e.getMessage());
- }
- }
-
- /**
- * Creates a new component instance with the given name and configuration,
- * from the factory specified in the given bundle.
- *
- * @param bundle the bundle from which the component factory is defined.
- * @param factoryName the name of the component factory, defined in the
- * specified bundle.
- * @param instanceName the name of the component instance to create.
- * @param configuration the configuration of the instance to create.
- * @return the newly created component instance.
- */
- public static ComponentInstance createComponentInstance(Bundle bundle,
- String factoryName, String instanceName, Dictionary configuration) {
-
- // Add the instance name to the configuration
- configuration.put("instance.name", instanceName);
-
- return createComponentInstance(bundle, factoryName, configuration);
- }
-
- /**
- * Creates a new component instance with the given name (and an empty
- * configuration), from the factory specified in the given service context.
- *
- * @param serviceContext the service context in which the component factory
- * service is registered.
- * @param factoryName the name of the component factory, defined in the
- * specified service context.
- * @param instanceName the name of the component instance to create.
- * @return the newly created component instance.
- */
- public static ComponentInstance createComponentInstance(
- ServiceContext serviceContext, String factoryName,
- String instanceName) {
-
- // Create the instance configuration
- Properties configuration = new Properties();
- configuration.put("instance.name", instanceName);
-
- return createComponentInstance(serviceContext, factoryName,
- configuration);
- }
-
- /**
- * Creates a new component instance with the given name and configuration,
- * from the factory specified in the given service context.
- *
- * @param serviceContext the service context in which the component factory
- * service is registered.
- * @param factoryName the name of the component factory, defined in the
- * specified service context.
- * @param configuration the configuration of the instance to create.
- * @return the newly created component instance.
- */
- public static ComponentInstance createComponentInstance(
- ServiceContext serviceContext, String factoryName,
- Dictionary configuration) {
-
- // Retrieve the component factory.
- Factory fact = getFactory(serviceContext, factoryName);
-
- if (fact == null) {
- // Factory not found...
- throw new IllegalArgumentException(
- "Cannot find the component factory (" + factoryName
- + ") in the specified service context.");
- }
-
- try {
- return fact.createComponentInstance(configuration);
- } catch (Exception e) {
- throw new IllegalArgumentException(
- "Cannot create the component instance with the given configuration: "
- + e.getMessage());
- }
- }
-
- /**
- * Creates a new component instance with the given name and configuration,
- * from the factory specified in the given service context.
- *
- * @param serviceContext the service context in which the component factory
- * service is registered.
- * @param factoryName the name of the component factory, defined in the
- * specified service context.
- * @param instanceName the name of the component instance to create.
- * @param configuration the configuration of the instance to create.
- * @return the newly created component instance.
- */
- public static ComponentInstance createComponentInstance(
- ServiceContext serviceContext, String factoryName,
- String instanceName, Dictionary configuration) {
-
- // Add the instance name to the configuration
- configuration.put("instance.name", instanceName);
-
- return createComponentInstance(serviceContext, factoryName,
- configuration);
- }
-
- /**
- * Creates a new component instance with the given name (and empty
- * configuration), from the factory specified in the local bundle.
- *
- * @param factoryName the name of the component factory, defined in the
- * local bundle.
- * @param instanceName the name of the component instance to create.
- * @return the newly created component instance.
- */
- public ComponentInstance createComponentInstance(String factoryName,
- String instanceName) {
- ComponentInstance ci = createComponentInstance(m_context.getBundle(),
- factoryName, instanceName);
- m_instances.add(ci);
- return ci;
- }
-
- /**
- * Creates a new component instance with the given configuration, from the
- * factory specified in the local bundle.
- *
- * @param factoryName the name of the component factory, in the local
- * bundle.
- * @param configuration the configuration of the component instance to
- * create.
- * @return the newly created component instance.
- */
- public ComponentInstance createComponentInstance(String factoryName,
- Dictionary configuration) {
- ComponentInstance ci = createComponentInstance(m_context.getBundle(),
- factoryName, configuration);
- m_instances.add(ci);
- return ci;
- }
-
- /**
- * Creates a new component instance with no configuration, from the factory
- * specified in the local bundle.
- *
- * @param factoryName the name of the component factory, in the local
- * bundle.
- * @return the newly created component instance.
- */
- public ComponentInstance createComponentInstance(String factoryName) {
- ComponentInstance ci = createComponentInstance(m_context.getBundle(),
- factoryName, (Dictionary) null);
- m_instances.add(ci);
- return ci;
- }
-
- /**
- * Creates a new component instance with the given name and configuration,
- * from the factory specified in the given bundle.
- *
- * @param factoryName the name of the component factory, defined in the
- * specified bundle.
- * @param instanceName the name of the component instance to create.
- * @param configuration the configuration of the instance to create.
- * @return the newly created component instance.
- */
- public ComponentInstance createComponentInstance(String factoryName,
- String instanceName, Dictionary configuration) {
- ComponentInstance ci = createComponentInstance(m_context.getBundle(),
- factoryName, instanceName, configuration);
- m_instances.add(ci);
- return ci;
- }
-
- /**
- * Returns the component factory with the given name in the local bundle.
- *
- * @param factoryName the name of the factory to retrieve.
- * @return the component factory with the given name in the local bundle, or
- * {@code null} if not found.
- */
- public Factory getFactory(String factoryName) {
- return getFactory(m_context.getBundle(), factoryName);
- }
-
- /**
- * Returns the handler factory with the given name in the local bundle.
- *
- * @param factoryName the name of the handler factory to retrieve.
- * @return the handler factory with the given name in the local bundle, or
- * {@code null} if not found.
- */
- public HandlerFactory getHandlerFactory(String factoryName) {
- return getHandlerFactory(m_context.getBundle(), factoryName);
- }
-
- /**
- * Returns the metadata description of the component defined in this bundle.
- *
- * @param component the name of the locally defined component.
- * @return the metadata description of the component with the given name,
- * defined in this given bundle, or {@code null} if not found.
- */
- public Element getMetadata(String component) {
- return getMetadata(m_context.getBundle(), component);
- }
-
- /**
- * Returns the component factory with the given name in the given bundle.
- *
- * @param bundle the bundle from which the component factory is defined.
- * @param factoryName the name of the defined factory.
- * @return the component factory with the given name in the given bundle, or
- * {@code null} if not found.
- */
- public static Factory getFactory(Bundle bundle, String factoryName) {
- ServiceReference[] refs;
- try {
- // Retrieves the component factories services in the bundle.
- refs = bundle.getBundleContext().getServiceReferences(
- Factory.class.getName(),
- "(factory.name=" + factoryName + ")");
- if (refs != null) {
- return (Factory) bundle.getBundleContext().getService(refs[0]);
- }
-
- // Factory not found...
- return null;
-
- } catch (InvalidSyntaxException e) {
- throw new IllegalArgumentException(
- "Cannot get the component factory services: "
- + e.getMessage());
- }
- }
-
- /**
- * Returns the component factory with the given name, registered in the
- * given service context.
- *
- * @param serviceContext the service context in which the factory service is
- * defined.
- * @param factoryName the name of the factory.
- * @return the component factory with the given name, registered in the
- * given service context.
- */
- public static Factory getFactory(ServiceContext serviceContext,
- String factoryName) {
- ServiceReference[] refs;
- try {
- // Retrieves the component factories services in the service
- // context.
- refs = serviceContext.getServiceReferences(Factory.class.getName(),
- "(factory.name=" + factoryName + ")");
- if (refs != null) {
- return (Factory) serviceContext.getService(refs[0]);
- }
- return null;
-
- } catch (InvalidSyntaxException e) {
- System.err.println("Cannot get the factory " + factoryName + " : "
- + e.getMessage());
- return null;
- }
- }
-
- /**
- * Returns the handler factory with the given name in the given bundle.
- *
- * @param bundle the bundle from which the handler factory is defined.
- * @param factoryName the name of the handler factory to retrieve.
- * @return the handler factory with the given name in the given bundle, or
- * {@code null} if not found.
- */
- public static HandlerFactory getHandlerFactory(Bundle bundle,
- String factoryName) {
- ServiceReference[] refs;
- try {
- // Retrieves the handler factories services in the bundle.
- refs = bundle.getBundleContext().getServiceReferences(
- HandlerFactory.class.getName(),
- "(" + Handler.HANDLER_NAME_PROPERTY + "=" + factoryName
- + ")");
- if (refs != null) {
- return (HandlerFactory) bundle.getBundleContext().getService(
- refs[0]);
- }
-
- // Factory not found...
- return null;
- } catch (InvalidSyntaxException e) {
- throw new IllegalArgumentException(
- "Cannot get the handler factory services: "
- + e.getMessage());
- }
- }
-
- /**
- * Returns the metadata description of the component with the given name,
- * defined in the given bundle.
- *
- * @param bundle the bundle from which the component is defined.
- * @param component the name of the defined component.
- * @return the metadata description of the component with the given name,
- * defined in the given bundle, or {@code null} if not found.
- */
- public static Element getMetadata(Bundle bundle, String component) {
-
- // Retrieves the component description from the bundle's manifest.
- String elem = (String) bundle.getHeaders().get("iPOJO-Components");
- if (elem == null) {
- throw new IllegalArgumentException(
- "Cannot find iPOJO-Components descriptor in the specified bundle ("
- + bundle.getSymbolicName()
- + "). Not an iPOJO bundle.");
- }
-
- // Parses the retrieved description and find the component with the
- // given name.
- try {
- Element element = ManifestMetadataParser.parseHeaderMetadata(elem);
- Element[] childs = element.getElements("component");
- for (int i = 0; i < childs.length; i++) {
- String name = childs[i].getAttribute("name");
- String clazz = childs[i].getAttribute("classname");
- if (name != null && name.equalsIgnoreCase(component)) {
- return childs[i];
- }
- if (clazz.equalsIgnoreCase(component)) {
- return childs[i];
- }
- }
-
- // Component not found...
- return null;
-
- } catch (ParseException e) {
- throw new IllegalStateException(
- "Cannot parse the components from specified bundle ("
- + bundle.getSymbolicName() + "): " + e.getMessage());
- }
- }
-
- /**
- * Returns the service object of a service registered in the specified
- * service context, offering the specified interface and matching the given
- * filter.
- *
- * @param serviceContext the service context in which the service is
- * searched.
- * @param itf the interface provided by the searched service.
- * @param filter an additional filter (can be {@code null}).
- * @return the service object provided by the specified bundle, offering the
- * specified interface and matching the given filter.
- */
- public static Object getServiceObject(ServiceContext serviceContext,
- String itf, String filter) {
- ServiceReference ref = getServiceReference(serviceContext, itf, filter);
- if (ref != null) {
- return serviceContext.getService(ref);
- } else {
- return null;
- }
- }
-
- /**
- * Returns the service objects of the services registered in the specified
- * service context, offering the specified interface and matching the given
- * filter.
- *
- * @param serviceContext the service context in which services are searched.
- * @param itf the interface provided by the searched services.
- * @param filter an additional filter (can be {@code null}).
- * @return the service objects provided by the specified bundle, offering
- * the specified interface and matching the given filter.
- */
- public static Object[] getServiceObjects(ServiceContext serviceContext,
- String itf, String filter) {
- ServiceReference[] refs = getServiceReferences(serviceContext, itf,
- filter);
- if (refs != null) {
- Object[] list = new Object[refs.length];
- for (int i = 0; i < refs.length; i++) {
- list[i] = serviceContext.getService(refs[i]);
- }
- return list;
- } else {
- return new Object[0];
- }
- }
-
- /**
- * Returns the service reference of a service registered in the specified
- * service context, offering the specified interface and matching the given
- * filter.
- *
- * @param serviceContext the service context in which services are searched.
- * @param itf the interface provided by the searched service.
- * @param filter an additional filter (can be {@code null}).
- * @return a service reference registered in the specified service context,
- * offering the specified interface and matching the given filter.
- * If no service is found, {@code null} is returned.
- */
- public static ServiceReference getServiceReference(
- ServiceContext serviceContext, String itf, String filter) {
- ServiceReference[] refs = getServiceReferences(serviceContext, itf,
- filter);
- if (refs.length != 0) {
- return refs[0];
- } else {
- // No service found
- return null;
- }
- }
-
- /**
- * Returns the service reference of the service registered in the specified
- * service context, offering the specified interface and having the given
- * persistent ID.
- *
- * @param serviceContext the service context in which services are searched.
- * @param itf the interface provided by the searched service.
- * @param pid the persistent ID of the searched service.
- * @return a service registered in the specified service context, offering
- * the specified interface and having the given persistent ID.
- */
- public static ServiceReference getServiceReferenceByPID(
- ServiceContext serviceContext, String itf, String pid) {
- String filter = "(" + "service.pid" + "=" + pid + ")";
- ServiceReference[] refs = getServiceReferences(serviceContext, itf,
- filter);
- if (refs == null) {
- return null;
- } else if (refs.length == 1) {
- return refs[0];
- } else {
- throw new IllegalStateException(
- "A service lookup by PID returned several providers ("
- + refs.length + ")" + " for " + itf + " with pid="
- + pid);
- }
- }
-
- /**
- * Returns the service reference of all the services registered in the
- * specified service context, offering the specified interface and matching
- * the given filter.
- *
- * @param serviceContext the service context in which services are searched.
- * @param itf the interface provided by the searched services.
- * @param filter an additional filter (can be {@code null}).
- * @return all the service references registered in the specified service
- * context, offering the specified interface and matching the given
- * filter. If no service matches, an empty array is returned.
- */
- public static ServiceReference[] getServiceReferences(
- ServiceContext serviceContext, String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- // Get all the service references
- refs = serviceContext.getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- throw new IllegalArgumentException(
- "Cannot get service references: " + e.getMessage());
- }
- if (refs == null) {
- return new ServiceReference[0];
- } else {
- return refs;
- }
- }
-
- /**
- * Returns the service reference of a service registered in the specified
- * service context, offering the specified interface and having the given
- * name.
- *
- * @param serviceContext the service context in which services are searched.
- * @param itf the interface provided by the searched service.
- * @param name the name of the searched service.
- * @return a service registered in the specified service context, offering
- * the specified interface and having the given name.
- */
- public static ServiceReference getServiceReferenceByName(
- ServiceContext serviceContext, String itf, String name) {
- String filter = null;
- if (itf.equals(Factory.class.getName())
- || itf.equals(ManagedServiceFactory.class.getName())) {
- filter = "(" + "factory.name" + "=" + name + ")";
- } else if (itf.equals(Architecture.class.getName())) {
- filter = "(" + "architecture.instance" + "=" + name + ")";
- } else {
- filter = "(" + "instance.name" + "=" + name + ")";
- }
- return getServiceReference(serviceContext, itf, filter);
- }
-
- /**
- * Checks the availability of a service inside the given service context.
- * @param sc the service context
- * @param itf the service interface to found
- * @return <code>true</code> if the service is available in the service
- * context, <code>false</code> otherwise.
- */
- public static boolean isServiceAvailable(ServiceContext sc, String itf) {
- ServiceReference ref = getServiceReference(sc, itf, null);
- return ref != null;
- }
-
- /**
- * Checks the availability of a service inside the given service context.
- * @param sc the service context
- * @param itf the service interface to found
- * @param name the service provider name
- * @return <code>true</code> if the service is available in the service
- * context, <code>false</code> otherwise.
- */
- public static boolean isServiceAvailableByName(ServiceContext sc,
- String itf, String name) {
- ServiceReference ref = getServiceReferenceByName(sc, itf, name);
- return ref != null;
- }
-
- /**
- * Checks the availability of a service inside the given service context.
- * @param sc the service context
- * @param itf the service interface to found
- * @param pid the pid of the service
- * @return <code>true</code> if the service is available in the service
- * context, <code>false</code> otherwise.
- */
- public static boolean isServiceAvailableByPID(ServiceContext sc,
- String itf, String pid) {
- ServiceReference ref = getServiceReferenceByPID(sc, itf, pid);
- return ref != null;
- }
-
- /**
- * Returns the service reference of a service provided by the specified
- * bundle, offering the specified interface and having the given name.
- *
- * @param bundle the bundle from which the service is searched.
- * @param itf the interface provided by the searched service.
- * @param name the name of the searched service.
- * @return a service provided by the specified bundle, offering the
- * specified interface and having the given name.
- */
- public static ServiceReference getServiceReferenceByName(Bundle bundle,
- String itf, String name) {
- String filter = null;
- if (itf.equals(Factory.class.getName())
- || itf.equals(ManagedServiceFactory.class.getName())) {
- filter = "(" + "factory.name" + "=" + name + ")";
- } else if (itf.equals(Architecture.class.getName())) {
- filter = "(" + "architecture.instance" + "=" + name + ")";
- } else {
- filter = "(" + "instance.name" + "=" + name + ")";
- }
- return OSGiHelper.getServiceReference(bundle, itf, filter);
- }
-
- /**
- * Returns the service reference of a service provided by the local bundle,
- * offering the specified interface and having the given name.
- *
- * @param itf the interface provided by the searched service.
- * @param name the name of the searched service.
- * @return a service provided by the specified bundle, offering the
- * specified interface and having the given name.
- */
- public ServiceReference getServiceReferenceByName(String itf, String name) {
- return getServiceReferenceByName(m_context.getBundle(), itf, name);
- }
-
- /**
- * Checks if the service is available.
- * @param itf the service interface
- * @param name the service provider name
- * @return <code>true</code> if the service is available, <code>false</code>
- * otherwise.
- */
- public boolean isServiceAvailableByName(String itf, String name) {
- ServiceReference ref = getServiceReferenceByName(itf, name);
- return ref != null;
- }
-
-}
diff --git a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/OSGiHelper.java b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/OSGiHelper.java
deleted file mode 100644
index 604ee18..0000000
--- a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/OSGiHelper.java
+++ /dev/null
@@ -1,456 +0,0 @@
-package org.apache.felix.ipojo.transaction.test;
-
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.osgi.framework.Bundle;
-import org.osgi.framework.BundleContext;
-import org.osgi.framework.BundleException;
-import org.osgi.framework.InvalidSyntaxException;
-import org.osgi.framework.ServiceReference;
-import org.osgi.service.packageadmin.PackageAdmin;
-
-import static org.junit.Assert.fail;
-
-
-public class OSGiHelper {
-
- /**
- * The bundle context.
- */
- private BundleContext context;
-
- /**
- * List of get references.
- */
- private List<ServiceReference> m_references = new ArrayList<ServiceReference>();
-
- public OSGiHelper(BundleContext context) {
- this.context = context;
- }
-
- public void dispose() {
- // Unget services
- for (int i = 0; i < m_references.size(); i++) {
- context.ungetService((ServiceReference) m_references.get(i));
- }
- m_references.clear();
- }
-
- /**
- * Gets the Bundle Context.
- * @return the bundle context.
- */
- public BundleContext getContext() {
- return context;
- }
-
- /**
- * Returns the service object of a service provided by the specified bundle,
- * offering the specified interface and matching the given filter.
- *
- * @param bundle the bundle from which the service is searched.
- * @param itf the interface provided by the searched service.
- * @param filter an additional filter (can be {@code null}).
- * @return the service object provided by the specified bundle, offering the
- * specified interface and matching the given filter.
- */
- public static Object getServiceObject(Bundle bundle, String itf,
- String filter) {
- ServiceReference ref = getServiceReference(bundle, itf, filter);
- if (ref != null) {
- return bundle.getBundleContext().getService(ref);
- } else {
- return null;
- }
- }
-
- /**
- * Returns the service objects of the services provided by the specified
- * bundle, offering the specified interface and matching the given filter.
- *
- * @param bundle the bundle from which services are searched.
- * @param itf the interface provided by the searched services.
- * @param filter an additional filter (can be {@code null}).
- * @return the service objects provided by the specified bundle, offering
- * the specified interface and matching the given filter.
- */
- public static Object[] getServiceObjects(Bundle bundle, String itf,
- String filter) {
- ServiceReference[] refs = getServiceReferences(bundle, itf, filter);
- if (refs != null) {
- Object[] list = new Object[refs.length];
- for (int i = 0; i < refs.length; i++) {
- list[i] = bundle.getBundleContext().getService(refs[i]);
- }
- return list;
- } else {
- return new Object[0];
- }
- }
-
- /**
- * Returns the service reference of a service provided by the specified
- * bundle, offering the specified interface and matching the given filter.
- *
- * @param bundle the bundle from which the service is searched.
- * @param itf the interface provided by the searched service.
- * @param filter an additional filter (can be {@code null}).
- * @return a service reference provided by the specified bundle, offering
- * the specified interface and matching the given filter. If no
- * service is found, {@code null} is returned.
- */
- public static ServiceReference getServiceReference(Bundle bundle,
- String itf, String filter) {
- ServiceReference[] refs = getServiceReferences(bundle, itf, filter);
- if (refs.length != 0) {
- return refs[0];
- } else {
- // No service found
- return null;
- }
- }
-
- /**
- * Checks if the service is available.
- * @param itf the service interface
- * @return <code>true</code> if the service is available, <code>false</code>
- * otherwise.
- */
- public boolean isServiceAvailable(String itf) {
- ServiceReference ref = getServiceReference(itf, null);
- return ref != null;
- }
-
- /**
- * Checks if the service is available.
- * @param itf the service interface
- * @param pid the service pid
- * @return <code>true</code> if the service is available, <code>false</code>
- * otherwise.
- */
- public boolean isServiceAvailableByPID(String itf, String pid) {
- ServiceReference ref = getServiceReferenceByPID(itf, pid);
- return ref != null;
- }
-
- /**
- * Returns the service reference of the service provided by the specified
- * bundle, offering the specified interface and having the given persistent
- * ID.
- *
- * @param bundle the bundle from which the service is searched.
- * @param itf the interface provided by the searched service.
- * @param pid the persistent ID of the searched service.
- * @return a service provided by the specified bundle, offering the
- * specified interface and having the given persistent ID.
- */
- public static ServiceReference getServiceReferenceByPID(Bundle bundle,
- String itf, String pid) {
- String filter = "(" + "service.pid" + "=" + pid + ")";
- ServiceReference[] refs = getServiceReferences(bundle, itf, filter);
- if (refs == null) {
- return null;
- } else if (refs.length == 1) {
- return refs[0];
- } else {
- throw new IllegalStateException(
- "A service lookup by PID returned several providers ("
- + refs.length + ")" + " for " + itf + " with pid="
- + pid);
- }
- }
-
- /**
- * Returns the service reference of all the services provided in the
- * specified bundle, offering the specified interface and matching the given
- * filter.
- *
- * @param bundle the bundle from which services are searched.
- * @param itf the interface provided by the searched services.
- * @param filter an additional filter (can be {@code null}).
- * @return all the service references provided in the specified bundle,
- * offering the specified interface and matching the given filter.
- * If no service matches, an empty array is returned.
- */
- public static ServiceReference[] getServiceReferences(Bundle bundle,
- String itf, String filter) {
- ServiceReference[] refs = null;
- try {
- // Get all the service references
- refs = bundle.getBundleContext().getServiceReferences(itf, filter);
- } catch (InvalidSyntaxException e) {
- throw new IllegalArgumentException(
- "Cannot get service references: " + e.getMessage());
- }
- if (refs == null) {
- return new ServiceReference[0];
- } else {
- return refs;
- }
- }
-
- /**
- * Returns the service object of a service provided by the local bundle,
- * offering the specified interface and matching the given filter.
- *
- * @param itf the interface provided by the searched service.
- * @param filter an additional filter (can be {@code null}).
- * @return the service object provided by the local bundle, offering the
- * specified interface and matching the given filter.
- */
- public Object getServiceObject(String itf, String filter) {
- ServiceReference ref = getServiceReference(itf, filter);
- if (ref != null) {
- m_references.add(ref);
- return context.getService(ref);
- } else {
- return null;
- }
- }
-
- /**
- * Returns the service object associated with this service reference.
- *
- * @param ref service reference
- * @return the service object.
- */
- public Object getServiceObject(ServiceReference ref) {
- if (ref != null) {
- m_references.add(ref);
- return context.getService(ref);
- } else {
- return null;
- }
- }
-
- /**
- * Returns the service objects of the services provided by the local bundle,
- * offering the specified interface and matching the given filter.
- *
- * @param itf the interface provided by the searched services.
- * @param filter an additional filter (can be {@code null}).
- * @return the service objects provided by the local bundle, offering the
- * specified interface and matching the given filter.
- */
- public Object[] getServiceObjects(String itf, String filter) {
- ServiceReference[] refs = getServiceReferences(itf, filter);
- if (refs != null) {
- Object[] list = new Object[refs.length];
- for (int i = 0; i < refs.length; i++) {
- m_references.add(refs[i]);
- list[i] = context.getService(refs[i]);
- }
- return list;
- } else {
- return new Object[0];
- }
- }
-
- /**
- * Returns the service reference of a service provided by the local bundle,
- * offering the specified interface and matching the given filter.
- *
- * @param itf the interface provided by the searched service.
- * @param filter an additional filter (can be {@code null}).
- * @return a service reference provided by the local bundle, offering the
- * specified interface and matching the given filter. If no service
- * is found, {@code null} is returned.
- */
- public ServiceReference getServiceReference(String itf, String filter) {
- return getServiceReference(context.getBundle(), itf, filter);
- }
-
- /**
- * Returns the service reference of a service provided offering the
- * specified interface.
- *
- * @param itf the interface provided by the searched service.
- * @return a service reference provided by the local bundle, offering the
- * specified interface and matching the given filter. If no service
- * is found, {@code null} is returned.
- */
- public ServiceReference getServiceReference(String itf) {
- return getServiceReference(context.getBundle(), itf, null);
- }
-
- /**
- * Returns the service reference of the service provided by the local
- * bundle, offering the specified interface and having the given persistent
- * ID.
- *
- * @param itf the interface provided by the searched service.
- * @param pid the persistent ID of the searched service.
- * @return a service provided by the local bundle, offering the specified
- * interface and having the given persistent ID.
- */
- public ServiceReference getServiceReferenceByPID(String itf, String pid) {
- return getServiceReferenceByPID(context.getBundle(), itf, pid);
- }
-
- /**
- * Returns the service reference of all the services provided in the local
- * bundle, offering the specified interface and matching the given filter.
- *
- * @param itf the interface provided by the searched services.
- * @param filter an additional filter (can be {@code null}).
- * @return all the service references provided in the local bundle, offering
- * the specified interface and matching the given filter. If no
- * service matches, an empty array is returned.
- */
- public ServiceReference[] getServiceReferences(String itf, String filter) {
- return getServiceReferences(context.getBundle(), itf, filter);
- }
-
- /**
- * Gets the package admin exposed by the framework.
- * Fails if the package admin is not available.
- * @return the package admin service.
- */
- public PackageAdmin getPackageAdmin() {
- PackageAdmin pa = (PackageAdmin) getServiceObject(PackageAdmin.class.getName(), null);
- if (pa == null) {
- fail("No package admin available");
- }
- return pa;
- }
-
- /**
- * Refresh the packages.
- * Fails if the package admin service is not available.
- */
- public void refresh() {
- getPackageAdmin().refreshPackages(null);
- }
-
- /**
- * Waits for a service. Fails on timeout.
- * If timeout is set to 0, it sets the timeout to 10s.
- * @param itf the service interface
- * @param filter the filter
- * @param timeout the timeout
- */
- public void waitForService(String itf, String filter, long timeout) {
- if (timeout == 0) {
- timeout = 10000; // Default 10 secondes.
- }
- ServiceReference[] refs = getServiceReferences(itf, filter);
- long begin = System.currentTimeMillis();
- if (refs.length != 0) {
- return;
- } else {
- while(refs.length == 0) {
- try {
- Thread.sleep(5);
- } catch (InterruptedException e) {
- // Interrupted
- }
- long now = System.currentTimeMillis();
-
- if ((now - begin) > timeout) {
- fail("Timeout ... no services matching with the request after " + timeout + "ms");
- }
- refs = getServiceReferences(itf, filter);
- }
- }
- }
-
-
- /**
- * Installs a bundle.
- * Fails if the bundle cannot be installed.
- * Be aware that you have to uninstall the bundle yourself.
- * @param url bundle url
- * @return the installed bundle
- */
- public Bundle installBundle(String url) {
- try {
- return context.installBundle(url);
- } catch (BundleException e) {
- fail("Cannot install the bundle " + url + " : " + e.getMessage());
- }
- return null; // Can not happen
- }
-
- /**
- * Installs a bundle.
- * Fails if the bundle cannot be installed.
- * Be aware that you have to uninstall the bundle yourself.
- * @param url bundle url
- * @param stream input stream containing the bundle
- * @return the installed bundle
- */
- public Bundle installBundle(String url, InputStream stream) {
- try {
- return context.installBundle(url, stream);
- } catch (BundleException e) {
- fail("Cannot install the bundle " + url + " : " + e.getMessage());
- }
- return null; // Can not happen
- }
-
- /**
- * Installs and starts a bundle.
- * Fails if the bundle cannot be installed or an error occurs
- * during startup. Be aware that you have to uninstall the bundle
- * yourself.
- * @param url the bundle url
- * @return the Bundle object.
- */
- public Bundle installAndStart(String url) {
- Bundle bundle = installBundle(url);
- try {
- bundle.start();
- } catch (BundleException e) {
- fail("Cannot start the bundle " + url + " : " + e.getMessage());
- }
- return bundle;
- }
-
- /**
- * Installs and starts a bundle.
- * Fails if the bundle cannot be installed or an error occurs
- * during startup. Be aware that you have to uninstall the bundle
- * yourself.
- * @param url the bundle url
- * @param stream input stream containing the bundle
- * @return the Bundle object.
- */
- public Bundle installAndStart(String url, InputStream stream) {
- Bundle bundle = installBundle(url, stream);
- try {
- bundle.start();
- } catch (BundleException e) {
- fail("Cannot start the bundle " + url + " : " + e.getMessage());
- }
- return bundle;
- }
-
- /**
- * Get the bundle by its id.
- * @param bundleId the bundle id.
- * @return the bundle with the given id.
- */
- public Bundle getBundle(long bundleId) {
- return context.getBundle(bundleId);
- }
-
- /**
- * Gets a bundle by its symbolic name.
- * Fails if no bundle matches.
- * @param name the symbolic name of the bundle
- * @return the bundle object.
- */
- public Bundle getBundle(String name) {
- Bundle[] bundles = context.getBundles();
- for (int i = 0; i < bundles.length; i++) {
- if (name.equals(bundles[i].getSymbolicName())) {
- return bundles[i];
- }
- }
- fail("No bundles with the given symbolic name " + name);
- return null; // should not happen
- }
-
-}
diff --git a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestAnnotations.java b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestAnnotations.java
index a7a9658..f46f7f4 100644
--- a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestAnnotations.java
+++ b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestAnnotations.java
@@ -1,16 +1,16 @@
package org.apache.felix.ipojo.transaction.test;
-import static org.ops4j.pax.exam.CoreOptions.bundle;
import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
import static org.ops4j.pax.exam.CoreOptions.options;
import static org.ops4j.pax.exam.CoreOptions.provision;
import static org.ops4j.pax.exam.MavenUtils.asInProject;
-import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.with;
import java.io.File;
-import java.net.URL;
+import java.io.InputStream;
import org.apache.felix.ipojo.metadata.Element;
+import org.apache.felix.ipojo.test.helpers.IPOJOHelper;
+import org.apache.felix.ipojo.test.helpers.OSGiHelper;
import org.apache.felix.ipojo.tinybundles.BundleAsiPOJO;
import org.apache.felix.ipojo.transaction.test.component.ComponentUsingAnnotations;
import org.apache.felix.ipojo.transaction.test.component.FooImpl;
@@ -60,33 +60,24 @@
public static Option[] configure() {
ROOT.mkdirs();
- URL service = TinyBundles.newBundle()
- .addClass(CheckService.class)
- .addClass(Foo.class)
- .prepare(
- with()
- .set(Constants.BUNDLE_SYMBOLICNAME,"Service")
- .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
- )
- .build( TinyBundles.asURL());
+ InputStream service = TinyBundles.newBundle()
+ .add(CheckService.class)
+ .add(Foo.class)
+ .set(Constants.BUNDLE_SYMBOLICNAME,"Service")
+ .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
+ .build( TinyBundles.withBnd());
- String fooimpl = TinyBundles.newBundle()
- .addClass(FooImpl.class)
- .prepare(
- with()
- .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
- )
- .build( new BundleAsiPOJO(new File(ROOT, "FooImpl.jar"), new File(TEST, "foo.xml")) ).toExternalForm();
+ InputStream fooimpl = TinyBundles.newBundle()
+ .add(FooImpl.class)
+ .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
+ .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
+ .build( BundleAsiPOJO.asiPOJOBundle(new File(ROOT, "FooImpl.jar"), new File(TEST, "foo.xml")) );
- String test = TinyBundles.newBundle()
- .addClass(ComponentUsingAnnotations.class)
- .prepare(
- with()
- .set(Constants.BUNDLE_SYMBOLICNAME,"Transaction Annotation Test")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction")
- )
- .build( new BundleAsiPOJO(new File(ROOT, "annotations.jar"), new File(TEST, "annotation.xml")) ).toExternalForm();
+ InputStream test = TinyBundles.newBundle()
+ .add(ComponentUsingAnnotations.class)
+ .set(Constants.BUNDLE_SYMBOLICNAME,"TransactionAnnotationTest")
+ .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction")
+ .build( BundleAsiPOJO.asiPOJOBundle(new File(ROOT, "annotations.jar"), new File(TEST, "annotation.xml")) );
Option[] opt = options(
@@ -96,17 +87,14 @@
mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.handler.transaction").version(asInProject()),
mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.transaction").version(asInProject()),
- mavenBundle()
- .groupId( "org.ops4j.pax.swissbox" )
- .artifactId( "pax-swissbox-tinybundles" )
- .version(asInProject()),
- bundle(service.toExternalForm()),
- bundle(fooimpl),
- bundle(test)
- )
+ mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.test.helpers").version(asInProject())
+ ),
+ provision(
+ service,
+ fooimpl,
+ test
)
-
- ;
+ );
return opt;
}
@@ -154,7 +142,8 @@
private Bundle getBundle() {
for(Bundle b : context.getBundles()) {
- if ("Transaction Annotation Test".equals(b.getSymbolicName())) {
+ System.out.println(b.getSymbolicName());
+ if ("TransactionAnnotationTest".equals(b.getSymbolicName())) {
return b;
}
}
diff --git a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestInstallation.java b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestInstallation.java
index b957c7c..4f0b92a 100644
--- a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestInstallation.java
+++ b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestInstallation.java
@@ -1,14 +1,12 @@
package org.apache.felix.ipojo.transaction.test;
-import static org.ops4j.pax.exam.CoreOptions.bundle;
import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
import static org.ops4j.pax.exam.CoreOptions.options;
import static org.ops4j.pax.exam.CoreOptions.provision;
import static org.ops4j.pax.exam.MavenUtils.asInProject;
-import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.with;
import java.io.File;
-import java.net.URL;
+import java.io.InputStream;
import javax.transaction.HeuristicMixedException;
import javax.transaction.HeuristicRollbackException;
@@ -19,6 +17,8 @@
import org.apache.felix.ipojo.ComponentInstance;
import org.apache.felix.ipojo.HandlerFactory;
+import org.apache.felix.ipojo.test.helpers.IPOJOHelper;
+import org.apache.felix.ipojo.test.helpers.OSGiHelper;
import org.apache.felix.ipojo.tinybundles.BundleAsiPOJO;
import org.apache.felix.ipojo.transaction.test.component.FooDelegator;
import org.apache.felix.ipojo.transaction.test.component.FooImpl;
@@ -29,6 +29,7 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Customizer;
import org.ops4j.pax.exam.Inject;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.Configuration;
@@ -37,6 +38,7 @@
import org.osgi.framework.Bundle;
import org.osgi.framework.BundleContext;
import org.osgi.framework.Constants;
+import org.osgi.framework.InvalidSyntaxException;
import org.osgi.framework.ServiceReference;
@RunWith( JUnit4TestRunner.class )
@@ -69,58 +71,61 @@
public static Option[] configure() {
ROOT.mkdirs();
- URL service = TinyBundles.newBundle()
- .addClass(CheckService.class)
- .addClass(Foo.class)
- .prepare(
- with()
- .set(Constants.BUNDLE_SYMBOLICNAME,"Service")
- .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
- )
- .build( TinyBundles.asURL());
+ InputStream service = TinyBundles.newBundle()
+ .add(CheckService.class)
+ .add(Foo.class)
+ .set(Constants.BUNDLE_SYMBOLICNAME,"Service")
+ .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
+ .build();
+
+// try {
+// StreamUtils.copy(service, new FileOutputStream(new File(ROOT, "service.jar")));
+// } catch (Exception e) {
+// e.printStackTrace();
+// }
- String fooimpl = TinyBundles.newBundle()
- .addClass(FooImpl.class)
- .prepare(
- with()
- .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
- )
- .build( new BundleAsiPOJO(new File(ROOT, "FooImpl.jar"), new File(TEST, "foo.xml")) ).toExternalForm();
+ InputStream fooimpl = TinyBundles.newBundle()
+ .add(FooImpl.class)
+ .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
+ .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
+ .build( BundleAsiPOJO.asiPOJOBundle(new File(ROOT, "FooImpl.jar"), new File(TEST, "foo.xml")) );
- String test = TinyBundles.newBundle()
- .addClass(FooDelegator.class)
- .prepare(
- with()
- .set(Constants.BUNDLE_SYMBOLICNAME,"Required Transaction Propgatation")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction")
- )
- .build( new BundleAsiPOJO(new File(ROOT, "requires.jar"), new File(TEST, "requires.xml")) ).toExternalForm();
+ InputStream test = TinyBundles.newBundle()
+ .add(FooDelegator.class)
+ .set(Constants.BUNDLE_SYMBOLICNAME,"RequiredTransactionPropagation")
+ .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction")
+ .build( BundleAsiPOJO.asiPOJOBundle(new File(ROOT, "requires.jar"), new File(TEST, "requires.xml")) );
Option[] opt = options(
-
provision(
mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-api").version(asInProject()),
mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.handler.transaction").version(asInProject()),
mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.transaction").version(asInProject()),
- mavenBundle()
- .groupId( "org.ops4j.pax.swissbox" )
- .artifactId( "pax-swissbox-tinybundles" )
- .version(asInProject()),
- bundle(service.toExternalForm()),
- bundle(fooimpl),
- bundle(test)
+ mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.test.helpers").version(asInProject())
+ ),
+ provision(
+ service,
+ fooimpl,
+ test
)
- )
-
- ;
+ ,
+ new Customizer() {
+ @Override
+ public InputStream customizeTestProbe( InputStream testProbe )
+ {
+ return TinyBundles.modifyBundle(testProbe)
+ .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
+ .build();
+ }
+ });
+
return opt;
}
@Test
- public void install() throws NotSupportedException, SystemException, IllegalStateException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException {
+ public void install() throws NotSupportedException, SystemException, IllegalStateException, SecurityException, HeuristicMixedException, HeuristicRollbackException, RollbackException, InvalidSyntaxException {
Bundle[] bundles = context.getBundles();
for (Bundle b : bundles) {
Assert.assertTrue(b.getSymbolicName(), b.getState() == Bundle.ACTIVE);
@@ -148,10 +153,12 @@
Assert.assertEquals(ComponentInstance.VALID, prov.getState());
Assert.assertEquals(ComponentInstance.VALID, under.getState());
- ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
- Assert.assertNotNull(ref);
+ ServiceReference[] refs = context.getAllServiceReferences(CheckService.class.getName(), "(instance.name=" + under.getInstanceName() +")");
+
+// ref = ipojo.getServiceReferenceByName(CheckService.class.getName(), under.getInstanceName());
+ Assert.assertNotNull(refs);
- ((CheckService) osgi.getServiceObject(ref)).doSomethingGood();
+ ((CheckService) osgi.getServiceObject(refs[0])).doSomethingGood();
}
}
diff --git a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestInvalidation.java b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestInvalidation.java
index 548df24..e6c4a69 100644
--- a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestInvalidation.java
+++ b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestInvalidation.java
@@ -1,14 +1,12 @@
package org.apache.felix.ipojo.transaction.test;
-import static org.ops4j.pax.exam.CoreOptions.bundle;
import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
import static org.ops4j.pax.exam.CoreOptions.options;
import static org.ops4j.pax.exam.CoreOptions.provision;
import static org.ops4j.pax.exam.MavenUtils.asInProject;
-import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.with;
import java.io.File;
-import java.net.URL;
+import java.io.InputStream;
import javax.transaction.HeuristicMixedException;
import javax.transaction.HeuristicRollbackException;
@@ -20,6 +18,8 @@
import javax.transaction.TransactionManager;
import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.test.helpers.IPOJOHelper;
+import org.apache.felix.ipojo.test.helpers.OSGiHelper;
import org.apache.felix.ipojo.tinybundles.BundleAsiPOJO;
import org.apache.felix.ipojo.transaction.test.component.FooDelegator;
import org.apache.felix.ipojo.transaction.test.component.FooImpl;
@@ -30,6 +30,7 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Customizer;
import org.ops4j.pax.exam.Inject;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.Configuration;
@@ -70,54 +71,49 @@
ROOT.mkdirs();
- URL service = TinyBundles.newBundle()
- .addClass(CheckService.class)
- .addClass(Foo.class)
- .prepare(
- with()
- .set(Constants.BUNDLE_SYMBOLICNAME,"Service")
- .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
- .set(Constants.IMPORT_PACKAGE, "javax.transaction")
- )
- .build( TinyBundles.asURL());
+ InputStream service = TinyBundles.newBundle()
+ .add(CheckService.class)
+ .add(Foo.class)
+ .set(Constants.BUNDLE_SYMBOLICNAME,"Service")
+ .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
+ .build();
- String fooimpl = TinyBundles.newBundle()
- .addClass(FooImpl.class)
- .prepare(
- with()
- .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
- )
- .build( new BundleAsiPOJO(new File(ROOT, "FooImpl.jar"), new File(TEST, "foo.xml")) ).toExternalForm();
+ InputStream fooimpl = TinyBundles.newBundle()
+ .add(FooImpl.class)
+ .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
+ .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
+ .build( BundleAsiPOJO.asiPOJOBundle(new File(ROOT, "FooImpl.jar"), new File(TEST, "foo.xml")) );
- String test = TinyBundles.newBundle()
- .addClass(FooDelegator.class)
- .prepare(
- with()
- .set(Constants.BUNDLE_SYMBOLICNAME,"Required Transaction Propgatation")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction")
- )
- .build( new BundleAsiPOJO(new File(ROOT, "requires.jar"), new File(TEST, "requires.xml")) ).toExternalForm();
+ InputStream test = TinyBundles.newBundle()
+ .add(FooDelegator.class)
+ .set(Constants.BUNDLE_SYMBOLICNAME,"RequiredTransactionPropagation")
+ .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction")
+ .build( BundleAsiPOJO.asiPOJOBundle(new File(ROOT, "requires.jar"), new File(TEST, "requires.xml")) );
Option[] opt = options(
-
provision(
mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-api").version(asInProject()),
mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.handler.transaction").version(asInProject()),
mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.transaction").version(asInProject()),
- mavenBundle()
- .groupId( "org.ops4j.pax.swissbox" )
- .artifactId( "pax-swissbox-tinybundles" )
- .version(asInProject()),
- bundle(service.toExternalForm()),
- bundle(fooimpl),
- bundle(test)
+ mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.test.helpers").version(asInProject())
+ ),
+ provision(
+ service,
+ fooimpl,
+ test
)
- )
-
- ;
+ ,
+ new Customizer() {
+ @Override
+ public InputStream customizeTestProbe( InputStream testProbe )
+ {
+ return TinyBundles.modifyBundle(testProbe)
+ .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
+ .build();
+ }
+ });
return opt;
}
diff --git a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestMandatory.java b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestMandatory.java
index 03d2e43..69c43e3 100644
--- a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestMandatory.java
+++ b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestMandatory.java
@@ -1,14 +1,12 @@
package org.apache.felix.ipojo.transaction.test;
-import static org.ops4j.pax.exam.CoreOptions.bundle;
import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
import static org.ops4j.pax.exam.CoreOptions.options;
import static org.ops4j.pax.exam.CoreOptions.provision;
import static org.ops4j.pax.exam.MavenUtils.asInProject;
-import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.with;
import java.io.File;
-import java.net.URL;
+import java.io.InputStream;
import javax.transaction.HeuristicMixedException;
import javax.transaction.HeuristicRollbackException;
@@ -20,6 +18,8 @@
import javax.transaction.TransactionManager;
import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.test.helpers.IPOJOHelper;
+import org.apache.felix.ipojo.test.helpers.OSGiHelper;
import org.apache.felix.ipojo.tinybundles.BundleAsiPOJO;
import org.apache.felix.ipojo.transaction.test.component.FooDelegator;
import org.apache.felix.ipojo.transaction.test.component.FooImpl;
@@ -30,6 +30,7 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Customizer;
import org.ops4j.pax.exam.Inject;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.Configuration;
@@ -69,54 +70,50 @@
public static Option[] configure() {
ROOT.mkdirs();
- URL service = TinyBundles.newBundle()
- .addClass(CheckService.class)
- .addClass(Foo.class)
- .prepare(
- with()
- .set(Constants.BUNDLE_SYMBOLICNAME,"Service")
- .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
- .set(Constants.IMPORT_PACKAGE, "javax.transaction")
- )
- .build( TinyBundles.asURL());
+ InputStream service = TinyBundles.newBundle()
+ .add(CheckService.class)
+ .add(Foo.class)
+ .set(Constants.BUNDLE_SYMBOLICNAME,"Service")
+ .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
+ .build();
- String fooimpl = TinyBundles.newBundle()
- .addClass(FooImpl.class)
- .prepare(
- with()
- .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
- )
- .build( new BundleAsiPOJO(new File(ROOT, "FooImpl.jar"), new File(TEST, "foo.xml")) ).toExternalForm();
-
- String test = TinyBundles.newBundle()
- .addClass(FooDelegator.class)
- .prepare(
- with()
- .set(Constants.BUNDLE_SYMBOLICNAME,"Mandatory Transaction Propgatation")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction")
- )
- .build( new BundleAsiPOJO(new File(ROOT, "mandatory.jar"), new File(TEST, "mandatory.xml")) ).toExternalForm();
-
-
+ InputStream fooimpl = TinyBundles.newBundle()
+ .add(FooImpl.class)
+ .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
+ .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
+ .build( BundleAsiPOJO.asiPOJOBundle(new File(ROOT, "FooImpl.jar"), new File(TEST, "foo.xml")) );
+
+ InputStream test = TinyBundles.newBundle()
+ .add(FooDelegator.class)
+ .set(Constants.BUNDLE_SYMBOLICNAME,"MandatoryTransactionPropagation")
+ .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction")
+ .build( BundleAsiPOJO.asiPOJOBundle(new File(ROOT, "mandatory.jar"), new File(TEST, "mandatory.xml")) );
+
+
Option[] opt = options(
-
provision(
mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-api").version(asInProject()),
mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.handler.transaction").version(asInProject()),
mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.transaction").version(asInProject()),
- mavenBundle()
- .groupId( "org.ops4j.pax.swissbox" )
- .artifactId( "pax-swissbox-tinybundles" )
- .version(asInProject()),
- bundle(service.toExternalForm()),
- bundle(fooimpl),
- bundle(test)
+ mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.test.helpers").version(asInProject())
+ ),
+ provision(
+ service,
+ fooimpl,
+ test
)
- )
-
- ;
+ ,
+ new Customizer() {
+ @Override
+ public InputStream customizeTestProbe( InputStream testProbe )
+ {
+ return TinyBundles.modifyBundle(testProbe)
+ .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
+ .build();
+ }
+ });
+
return opt;
}
diff --git a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestNever.java b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestNever.java
index 609f9f5..ac63000 100644
--- a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestNever.java
+++ b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestNever.java
@@ -1,14 +1,12 @@
package org.apache.felix.ipojo.transaction.test;
-import static org.ops4j.pax.exam.CoreOptions.bundle;
import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
import static org.ops4j.pax.exam.CoreOptions.options;
import static org.ops4j.pax.exam.CoreOptions.provision;
import static org.ops4j.pax.exam.MavenUtils.asInProject;
-import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.with;
import java.io.File;
-import java.net.URL;
+import java.io.InputStream;
import javax.transaction.HeuristicMixedException;
import javax.transaction.HeuristicRollbackException;
@@ -20,6 +18,8 @@
import javax.transaction.TransactionManager;
import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.test.helpers.IPOJOHelper;
+import org.apache.felix.ipojo.test.helpers.OSGiHelper;
import org.apache.felix.ipojo.tinybundles.BundleAsiPOJO;
import org.apache.felix.ipojo.transaction.test.component.FooDelegator;
import org.apache.felix.ipojo.transaction.test.component.FooImpl;
@@ -30,6 +30,7 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Customizer;
import org.ops4j.pax.exam.Inject;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.Configuration;
@@ -68,54 +69,49 @@
public static Option[] configure() {
ROOT.mkdirs();
- URL service = TinyBundles.newBundle()
- .addClass(CheckService.class)
- .addClass(Foo.class)
- .prepare(
- with()
- .set(Constants.BUNDLE_SYMBOLICNAME,"Service")
- .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
- .set(Constants.IMPORT_PACKAGE, "javax.transaction")
- )
- .build( TinyBundles.asURL());
+ InputStream service = TinyBundles.newBundle()
+ .add(CheckService.class)
+ .add(Foo.class)
+ .set(Constants.BUNDLE_SYMBOLICNAME,"Service")
+ .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
+ .build();
- String fooimpl = TinyBundles.newBundle()
- .addClass(FooImpl.class)
- .prepare(
- with()
- .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
- )
- .build( new BundleAsiPOJO(new File(ROOT,"FooImpl.jar"), new File(TEST, "foo.xml")) ).toExternalForm();
-
- String test = TinyBundles.newBundle()
- .addClass(FooDelegator.class)
- .prepare(
- with()
- .set(Constants.BUNDLE_SYMBOLICNAME,"Mandatory Transaction Propgatation")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction")
- )
- .build( new BundleAsiPOJO(new File(ROOT, "never.jar"), new File(TEST, "never.xml")) ).toExternalForm();
-
-
+ InputStream fooimpl = TinyBundles.newBundle()
+ .add(FooImpl.class)
+ .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
+ .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
+ .build( BundleAsiPOJO.asiPOJOBundle(new File(ROOT, "FooImpl.jar"), new File(TEST, "foo.xml")) );
+
+ InputStream test = TinyBundles.newBundle()
+ .add(FooDelegator.class)
+ .set(Constants.BUNDLE_SYMBOLICNAME,"NeverTransactionPropagation")
+ .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction")
+ .build( BundleAsiPOJO.asiPOJOBundle(new File(ROOT, "never.jar"), new File(TEST, "never.xml")) );
+
Option[] opt = options(
-
provision(
mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-api").version(asInProject()),
mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.handler.transaction").version(asInProject()),
mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.transaction").version(asInProject()),
- mavenBundle()
- .groupId( "org.ops4j.pax.swissbox" )
- .artifactId( "pax-swissbox-tinybundles" )
- .version(asInProject()),
- bundle(service.toExternalForm()),
- bundle(fooimpl),
- bundle(test)
+ mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.test.helpers").version(asInProject())
+ ),
+ provision(
+ service,
+ fooimpl,
+ test
)
- )
-
- ;
+ ,
+ new Customizer() {
+ @Override
+ public InputStream customizeTestProbe( InputStream testProbe )
+ {
+ return TinyBundles.modifyBundle(testProbe)
+ .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
+ .build();
+ }
+ });
+
return opt;
}
diff --git a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestNotSupported.java b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestNotSupported.java
index bd07984..ad5d311 100644
--- a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestNotSupported.java
+++ b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestNotSupported.java
@@ -1,14 +1,12 @@
package org.apache.felix.ipojo.transaction.test;
-import static org.ops4j.pax.exam.CoreOptions.bundle;
import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
import static org.ops4j.pax.exam.CoreOptions.options;
import static org.ops4j.pax.exam.CoreOptions.provision;
import static org.ops4j.pax.exam.MavenUtils.asInProject;
-import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.with;
import java.io.File;
-import java.net.URL;
+import java.io.InputStream;
import javax.transaction.HeuristicMixedException;
import javax.transaction.HeuristicRollbackException;
@@ -20,6 +18,8 @@
import javax.transaction.TransactionManager;
import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.test.helpers.IPOJOHelper;
+import org.apache.felix.ipojo.test.helpers.OSGiHelper;
import org.apache.felix.ipojo.tinybundles.BundleAsiPOJO;
import org.apache.felix.ipojo.transaction.test.component.FooDelegator;
import org.apache.felix.ipojo.transaction.test.component.FooImpl;
@@ -30,6 +30,7 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Customizer;
import org.ops4j.pax.exam.Inject;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.Configuration;
@@ -68,54 +69,49 @@
public static Option[] configure() {
ROOT.mkdirs();
- URL service = TinyBundles.newBundle()
- .addClass(CheckService.class)
- .addClass(Foo.class)
- .prepare(
- with()
- .set(Constants.BUNDLE_SYMBOLICNAME,"Service")
- .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
- .set(Constants.IMPORT_PACKAGE, "javax.transaction")
- )
- .build( TinyBundles.asURL());
+ InputStream service = TinyBundles.newBundle()
+ .add(CheckService.class)
+ .add(Foo.class)
+ .set(Constants.BUNDLE_SYMBOLICNAME,"Service")
+ .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
+ .build();
- String fooimpl = TinyBundles.newBundle()
- .addClass(FooImpl.class)
- .prepare(
- with()
- .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
- )
- .build( new BundleAsiPOJO(new File(ROOT, "FooImpl.jar"), new File(TEST, "foo.xml")) ).toExternalForm();
-
- String test = TinyBundles.newBundle()
- .addClass(FooDelegator.class)
- .prepare(
- with()
- .set(Constants.BUNDLE_SYMBOLICNAME,"Required Transaction Propgatation")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction")
- )
- .build( new BundleAsiPOJO(new File(ROOT, "notsupported.jar"), new File(TEST, "notsupported.xml")) ).toExternalForm();
-
-
+ InputStream fooimpl = TinyBundles.newBundle()
+ .add(FooImpl.class)
+ .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
+ .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
+ .build( BundleAsiPOJO.asiPOJOBundle(new File(ROOT, "FooImpl.jar"), new File(TEST, "foo.xml")) );
+
+ InputStream test = TinyBundles.newBundle()
+ .add(FooDelegator.class)
+ .set(Constants.BUNDLE_SYMBOLICNAME,"NotSupportedTransactionPropagation")
+ .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction")
+ .build( BundleAsiPOJO.asiPOJOBundle(new File(ROOT, "notsupported.jar"), new File(TEST, "notsupported.xml")) );
+
Option[] opt = options(
-
provision(
mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-api").version(asInProject()),
mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.handler.transaction").version(asInProject()),
mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.transaction").version(asInProject()),
- mavenBundle()
- .groupId( "org.ops4j.pax.swissbox" )
- .artifactId( "pax-swissbox-tinybundles" )
- .version(asInProject()),
- bundle(service.toExternalForm()),
- bundle(fooimpl),
- bundle(test)
+ mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.test.helpers").version(asInProject())
+ ),
+ provision(
+ service,
+ fooimpl,
+ test
)
- )
-
- ;
+ ,
+ new Customizer() {
+ @Override
+ public InputStream customizeTestProbe( InputStream testProbe )
+ {
+ return TinyBundles.modifyBundle(testProbe)
+ .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
+ .build();
+ }
+ });
+
return opt;
}
diff --git a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestRequires.java b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestRequires.java
index 5dfd591..4299d2d 100644
--- a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestRequires.java
+++ b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestRequires.java
@@ -1,14 +1,12 @@
package org.apache.felix.ipojo.transaction.test;
-import static org.ops4j.pax.exam.CoreOptions.bundle;
import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
import static org.ops4j.pax.exam.CoreOptions.options;
import static org.ops4j.pax.exam.CoreOptions.provision;
import static org.ops4j.pax.exam.MavenUtils.asInProject;
-import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.with;
import java.io.File;
-import java.net.URL;
+import java.io.InputStream;
import javax.transaction.HeuristicMixedException;
import javax.transaction.HeuristicRollbackException;
@@ -20,6 +18,8 @@
import javax.transaction.TransactionManager;
import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.test.helpers.IPOJOHelper;
+import org.apache.felix.ipojo.test.helpers.OSGiHelper;
import org.apache.felix.ipojo.tinybundles.BundleAsiPOJO;
import org.apache.felix.ipojo.transaction.test.component.FooDelegator;
import org.apache.felix.ipojo.transaction.test.component.FooImpl;
@@ -30,6 +30,7 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Customizer;
import org.ops4j.pax.exam.Inject;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.Configuration;
@@ -69,54 +70,49 @@
public static Option[] configure() {
ROOT.mkdirs();
- URL service = TinyBundles.newBundle()
- .addClass(CheckService.class)
- .addClass(Foo.class)
- .prepare(
- with()
- .set(Constants.BUNDLE_SYMBOLICNAME,"Service")
- .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
- .set(Constants.IMPORT_PACKAGE, "javax.transaction")
- )
- .build( TinyBundles.asURL());
+ InputStream service = TinyBundles.newBundle()
+ .add(CheckService.class)
+ .add(Foo.class)
+ .set(Constants.BUNDLE_SYMBOLICNAME,"Service")
+ .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
+ .build();
- String fooimpl = TinyBundles.newBundle()
- .addClass(FooImpl.class)
- .prepare(
- with()
- .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
- )
- .build( new BundleAsiPOJO(new File(ROOT, "FooImpl.jar"), new File(TEST, "foo.xml")) ).toExternalForm();
-
- String test = TinyBundles.newBundle()
- .addClass(FooDelegator.class)
- .prepare(
- with()
- .set(Constants.BUNDLE_SYMBOLICNAME,"Required Transaction Propgatation")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction")
- )
- .build( new BundleAsiPOJO(new File(ROOT, "requires.jar"), new File(TEST, "requires.xml")) ).toExternalForm();
-
-
+ InputStream fooimpl = TinyBundles.newBundle()
+ .add(FooImpl.class)
+ .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
+ .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
+ .build( BundleAsiPOJO.asiPOJOBundle(new File(ROOT, "FooImpl.jar"), new File(TEST, "foo.xml")) );
+
+ InputStream test = TinyBundles.newBundle()
+ .add(FooDelegator.class)
+ .set(Constants.BUNDLE_SYMBOLICNAME,"RequiresTransactionPropagation")
+ .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction")
+ .build( BundleAsiPOJO.asiPOJOBundle(new File(ROOT, "requires.jar"), new File(TEST, "requires.xml")) );
+
Option[] opt = options(
-
provision(
mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-api").version(asInProject()),
mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.handler.transaction").version(asInProject()),
mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.transaction").version(asInProject()),
- mavenBundle()
- .groupId( "org.ops4j.pax.swissbox" )
- .artifactId( "pax-swissbox-tinybundles" )
- .version(asInProject()),
- bundle(service.toExternalForm()),
- bundle(fooimpl),
- bundle(test)
+ mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.test.helpers").version(asInProject())
+ ),
+ provision(
+ service,
+ fooimpl,
+ test
)
- )
-
- ;
+ ,
+ new Customizer() {
+ @Override
+ public InputStream customizeTestProbe( InputStream testProbe )
+ {
+ return TinyBundles.modifyBundle(testProbe)
+ .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
+ .build();
+ }
+ });
+
return opt;
}
diff --git a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestRequiresNew.java b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestRequiresNew.java
index b7a231b..c033233 100644
--- a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestRequiresNew.java
+++ b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestRequiresNew.java
@@ -1,14 +1,12 @@
package org.apache.felix.ipojo.transaction.test;
-import static org.ops4j.pax.exam.CoreOptions.bundle;
import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
import static org.ops4j.pax.exam.CoreOptions.options;
import static org.ops4j.pax.exam.CoreOptions.provision;
import static org.ops4j.pax.exam.MavenUtils.asInProject;
-import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.with;
import java.io.File;
-import java.net.URL;
+import java.io.InputStream;
import javax.transaction.HeuristicMixedException;
import javax.transaction.HeuristicRollbackException;
@@ -20,6 +18,8 @@
import javax.transaction.TransactionManager;
import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.test.helpers.IPOJOHelper;
+import org.apache.felix.ipojo.test.helpers.OSGiHelper;
import org.apache.felix.ipojo.tinybundles.BundleAsiPOJO;
import org.apache.felix.ipojo.transaction.test.component.FooDelegator;
import org.apache.felix.ipojo.transaction.test.component.FooImpl;
@@ -30,6 +30,7 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Customizer;
import org.ops4j.pax.exam.Inject;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.Configuration;
@@ -69,54 +70,51 @@
public static Option[] configure() {
ROOT.mkdirs();
- URL service = TinyBundles.newBundle()
- .addClass(CheckService.class)
- .addClass(Foo.class)
- .prepare(
- with()
- .set(Constants.BUNDLE_SYMBOLICNAME,"Service")
- .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
- .set(Constants.IMPORT_PACKAGE, "javax.transaction")
- )
- .build( TinyBundles.asURL());
+
+ InputStream service = TinyBundles.newBundle()
+ .add(CheckService.class)
+ .add(Foo.class)
+ .set(Constants.BUNDLE_SYMBOLICNAME,"Service")
+ .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
+ .build();
- String fooimpl = TinyBundles.newBundle()
- .addClass(FooImpl.class)
- .prepare(
- with()
- .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
- )
- .build( new BundleAsiPOJO(new File(ROOT, "FooImpl.jar"), new File(TEST, "foo.xml")) ).toExternalForm();
-
- String test = TinyBundles.newBundle()
- .addClass(FooDelegator.class)
- .prepare(
- with()
- .set(Constants.BUNDLE_SYMBOLICNAME,"Required Transaction Propgatation")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction")
- )
- .build( new BundleAsiPOJO(new File(ROOT, "requiresnew.jar"), new File(TEST, "requiresnew.xml")) ).toExternalForm();
-
-
+ InputStream fooimpl = TinyBundles.newBundle()
+ .add(FooImpl.class)
+ .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
+ .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
+ .build( BundleAsiPOJO.asiPOJOBundle(new File(ROOT, "FooImpl.jar"), new File(TEST, "foo.xml")) );
+
+ InputStream test = TinyBundles.newBundle()
+ .add(FooDelegator.class)
+ .set(Constants.BUNDLE_SYMBOLICNAME,"RequiresNewTransactionPropagation")
+ .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction")
+ .build( BundleAsiPOJO.asiPOJOBundle(new File(ROOT, "requiresnew.jar"), new File(TEST, "requiresnew.xml")) );
+
Option[] opt = options(
-
provision(
mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-api").version(asInProject()),
mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.handler.transaction").version(asInProject()),
mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.transaction").version(asInProject()),
- mavenBundle()
- .groupId( "org.ops4j.pax.swissbox" )
- .artifactId( "pax-swissbox-tinybundles" )
- .version(asInProject()),
- bundle(service.toExternalForm()),
- bundle(fooimpl),
- bundle(test)
+ mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.test.helpers").version(asInProject())
+ ),
+ provision(
+ service,
+ fooimpl,
+ test
)
- )
-
- ;
+ ,
+ new Customizer() {
+ @Override
+ public InputStream customizeTestProbe( InputStream testProbe )
+ {
+ return TinyBundles.modifyBundle(testProbe)
+ .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
+ .build();
+ }
+ });
+
+
return opt;
}
diff --git a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestSupported.java b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestSupported.java
index b2eea67..5fb7016 100644
--- a/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestSupported.java
+++ b/ipojo/tests/handler/transaction/src/test/java/org/apache/felix/ipojo/transaction/test/TestSupported.java
@@ -1,14 +1,12 @@
package org.apache.felix.ipojo.transaction.test;
-import static org.ops4j.pax.exam.CoreOptions.bundle;
import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
import static org.ops4j.pax.exam.CoreOptions.options;
import static org.ops4j.pax.exam.CoreOptions.provision;
import static org.ops4j.pax.exam.MavenUtils.asInProject;
-import static org.ops4j.pax.swissbox.tinybundles.core.TinyBundles.with;
import java.io.File;
-import java.net.URL;
+import java.io.InputStream;
import javax.transaction.HeuristicMixedException;
import javax.transaction.HeuristicRollbackException;
@@ -20,6 +18,8 @@
import javax.transaction.TransactionManager;
import org.apache.felix.ipojo.ComponentInstance;
+import org.apache.felix.ipojo.test.helpers.IPOJOHelper;
+import org.apache.felix.ipojo.test.helpers.OSGiHelper;
import org.apache.felix.ipojo.tinybundles.BundleAsiPOJO;
import org.apache.felix.ipojo.transaction.test.component.FooDelegator;
import org.apache.felix.ipojo.transaction.test.component.FooImpl;
@@ -30,6 +30,7 @@
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.ops4j.pax.exam.Customizer;
import org.ops4j.pax.exam.Inject;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.Configuration;
@@ -68,54 +69,50 @@
public static Option[] configure() {
ROOT.mkdirs();
- URL service = TinyBundles.newBundle()
- .addClass(CheckService.class)
- .addClass(Foo.class)
- .prepare(
- with()
- .set(Constants.BUNDLE_SYMBOLICNAME,"Service")
- .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
- .set(Constants.IMPORT_PACKAGE, "javax.transaction")
- )
- .build( TinyBundles.asURL());
+ InputStream service = TinyBundles.newBundle()
+ .add(CheckService.class)
+ .add(Foo.class)
+ .set(Constants.BUNDLE_SYMBOLICNAME,"Service")
+ .set(Constants.EXPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
+ .build();
- String fooimpl = TinyBundles.newBundle()
- .addClass(FooImpl.class)
- .prepare(
- with()
- .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
- )
- .build( new BundleAsiPOJO(new File(ROOT, "FooImpl.jar"), new File(TEST, "foo.xml")) ).toExternalForm();
-
- String test = TinyBundles.newBundle()
- .addClass(FooDelegator.class)
- .prepare(
- with()
- .set(Constants.BUNDLE_SYMBOLICNAME,"Required Transaction Propgatation")
- .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction")
- )
- .build( new BundleAsiPOJO(new File(ROOT, "supported.jar"), new File(TEST, "supported.xml")) ).toExternalForm();
-
-
+ InputStream fooimpl = TinyBundles.newBundle()
+ .add(FooImpl.class)
+ .set(Constants.BUNDLE_SYMBOLICNAME,"Foo Provider")
+ .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
+ .build( BundleAsiPOJO.asiPOJOBundle(new File(ROOT, "FooImpl.jar"), new File(TEST, "foo.xml")) );
+
+ InputStream test = TinyBundles.newBundle()
+ .add(FooDelegator.class)
+ .set(Constants.BUNDLE_SYMBOLICNAME,"SupportedTransactionPropagation")
+ .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service, javax.transaction")
+ .build( BundleAsiPOJO.asiPOJOBundle(new File(ROOT, "supported.jar"), new File(TEST, "supported.xml")) );
+
Option[] opt = options(
-
provision(
mavenBundle().groupId("org.ops4j.pax.logging").artifactId("pax-logging-api").version(asInProject()),
mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo").version(asInProject()),
mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.handler.transaction").version(asInProject()),
mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.transaction").version(asInProject()),
- mavenBundle()
- .groupId( "org.ops4j.pax.swissbox" )
- .artifactId( "pax-swissbox-tinybundles" )
- .version(asInProject()),
- bundle(service.toExternalForm()),
- bundle(fooimpl),
- bundle(test)
+ mavenBundle().groupId("org.apache.felix").artifactId("org.apache.felix.ipojo.test.helpers").version(asInProject())
+ ),
+ provision(
+ service,
+ fooimpl,
+ test
)
- )
-
- ;
+ ,
+ new Customizer() {
+ @Override
+ public InputStream customizeTestProbe( InputStream testProbe )
+ {
+ return TinyBundles.modifyBundle(testProbe)
+ .set(Constants.IMPORT_PACKAGE, "org.apache.felix.ipojo.transaction.test.service")
+ .build();
+ }
+ });
+
+
return opt;
}
diff --git a/ipojo/tests/integration-tests/pom.xml b/ipojo/tests/integration-tests/pom.xml
index 38a79f1..1530e62 100644
--- a/ipojo/tests/integration-tests/pom.xml
+++ b/ipojo/tests/integration-tests/pom.xml
@@ -262,7 +262,7 @@
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.eventadmin</artifactId>
- <version>1.0.0</version>
+ <version>1.2.2</version>
<scope>test</scope>
</dependency>
<dependency>