Author: clement
Date: Wed Feb 13 09:20:49 2013
New Revision: 1445514
URL: http://svn.apache.org/r1445514
Log:
migrate pages and menu
Modified:
felix/site/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/apache-felix-ipojo-api.mdtext
felix/site/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/ipojo-faq.mdtext
felix/site/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/using-xml-schemas.mdtext
felix/site/trunk/content/ipojo/site/button.html
Modified:
felix/site/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/apache-felix-ipojo-api.mdtext
URL:
http://svn.apache.org/viewvc/felix/site/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/apache-felix-ipojo-api.mdtext?rev=1445514&r1=1445513&r2=1445514&view=diff
==============================================================================
---
felix/site/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/apache-felix-ipojo-api.mdtext
(original)
+++
felix/site/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/apache-felix-ipojo-api.mdtext
Wed Feb 13 09:20:49 2013
@@ -7,29 +7,29 @@ Title: apache-felix-ipojo-api
*The iPOJO API provides a third way to describe iPOJO components and
instances. With the API, you can dynamically create new components types and
create instances from them. Your component types are described with a Java API.
To use the API, deploy and start the iPOJO-API bundle and the iPOJO core
bundle.*
-{div:class=toc}
[TOC]
-{div}
## A simple example
Let's imagine a simple component providing a service Foo. The following code
is the implementation class of our component:
-{code:java}
-package org.example.service.impl;
-import org.example.service.Foo;
+ :::java
+ package org.example.service.impl;
-public class FooImpl implements Foo {
+ import org.example.service.Foo;
- public void doSomething() {
- // Do something...
- }
+ public class FooImpl implements Foo {
-}
+ public void doSomething() {
+ // Do something...
+ }
+
+ }
- To create the component type and an instance of the component type just
create a class, get the bundle context (either from a Bundle-Activator, or from
an iPOJO component), and write the following code:
- {code:java}
+To create the component type and an instance of the component type just create
a class, get the bundle context (either from a Bundle-Activator, or from an
iPOJO component), and write the following code:
+
+ :::java
new PrimitiveComponentType()
.setBundleContext(context)
.setClassName(FooImpl.class.getName())
@@ -38,23 +38,24 @@ public class FooImpl implements Foo {
So, now let's imagine another component using this service. The following code
is the implementation class of this component type:
-{code:java}
-package org.example.service.impl;
-import org.example.service.Foo;
+ :::java
+ package org.example.service.impl;
-public class MyComponentImpl {
- private Foo myFoo;
+ import org.example.service.Foo;
+
+ public class MyComponentImpl {
+ private Foo myFoo;
+
+ public void start() {
+ myFoo.doSomething();
+ }
- public void start() {
- myFoo.doSomething();
}
-}
+It is a regular iPOJO component expecting to get a Foo service in the `myFoo`
field. It also has a method executed when the instance is valid using the Foo
service. To describe this component, just write the following lines:
-
- It is a regular iPOJO component expecting to get a Foo service in the
{{myFoo}} field. It also has a method executed when the instance is valid using
the Foo service. To describe this component, just write the following lines:
- {code:java}
+ :::java
new PrimitiveComponentType()
.setBundleContext(context)
.setClassName(MyComponentImpl.class.getName())
@@ -62,18 +63,13 @@ public class MyComponentImpl {
.setValidateMethod("start")
.createInstance();
-
## Deploying the API
Before being able to create component types at runtime, you need to deploy 3
bundles:
+
* iPOJO (core)
* iPOJO Composite
* iPOJO API
-You can deploy all these bundles in one step thanks to OBR:
-
- obr start "Apache Felix iPOJO API"
-
-
## Primitive Component Type basics
When you create a new Primitive component type (so, using a Java class as
implementation), you must set the bundle context and the class name. Everything
else is optional.
@@ -87,25 +83,27 @@ To set validate and invalidate methods,
## Declaring services
To declare that a component provides a service, add a new service to your
primitive component type.
The Service object can be configured. By default, it exposed every implemented
interface (regular iPOJO behavior). So, you can:
+
* Add service property
* Set the creation strategy
* Set the exposed service specifications
-{code:java}
-new PrimitiveComponentType()
- .setBundleContext(context)
- .setClassName(org.example.service.impl.MyComponentImpl.class.getName())
- .addService(new Service()
- .addProperty(new ServiceProperty()
- .setField("myServiceProperty")
- .setName("sample.myProperty"))
- .setCreationStrategy(Service.INSTANCE_STRATEGY))
- .createInstance();
+ :::java
+ new PrimitiveComponentType()
+ .setBundleContext(context)
+ .setClassName(org.example.service.impl.MyComponentImpl.class.getName())
+ .addService(new Service()
+ .addProperty(new ServiceProperty()
+ .setField("myServiceProperty")
+ .setName("sample.myProperty"))
+ .setCreationStrategy(Service.INSTANCE_STRATEGY))
+ .createInstance();
- h2. Service Dependencies
- To declare a service dependency, create and add a Dependency object. The
dependency object offers all the iPOJO service dependency features. You can set
the injected field and/or bind/unbind methods. Here is an example:
- {code:java}
+## Service Dependencies
+To declare a service dependency, create and add a Dependency object. The
dependency object offers all the iPOJO service dependency features. You can set
the injected field and/or bind/unbind methods. Here is an example:
+
+ :::java
new PrimitiveComponentType()
.setBundleContext(context)
.setClassName(org.example.service.impl.MyComponentImpl.class.getName())
@@ -116,27 +114,28 @@ new PrimitiveComponentType()
)
.createInstance();
-
## Properties
Thanks to the `addProperty` method, you can create component properties. Here
is some example of properties:
-{code:java}
-new PrimitiveComponentType()
- .setBundleContext(context)
- .setClassName(MyComponentImpl.class.getName())
- .addProperty(new Property()
- .setField("myProperty")
- .setValue("default-value")
+
+ :::java
+ new PrimitiveComponentType()
+ .setBundleContext(context)
+ .setClassName(MyComponentImpl.class.getName())
+ .addProperty(new Property()
+ .setField("myProperty")
+ .setValue("default-value")
+ )
+ .addProperty(new Property()
+ .setMethod("setMethod")
+ .setName("prop")
)
- .addProperty(new Property()
- .setMethod("setMethod")
- .setName("prop")
- )
- .createInstance();
+ .createInstance();
- h2. Temporal Dependencies
- Temporal dependencies are also supported:
- {code:java}
+## Temporal Dependencies
+Temporal dependencies are also supported:
+
+ :::java
new PrimitiveComponentType()
.setBundleContext(context)
.setClassName(MyComponentImpl.class.getName())
@@ -167,25 +166,26 @@ The API provides bridge to get access to
## Singleton Component Type
If you are sure to create only one instance of your component type, you can
use the singleton component type class. This is a kind of primitive component
type, but when you start it (with the `create` method), it will automatically
create an instance.
-{code:java}
- PrimitiveComponentType type = new SingletonComponentType()
- .setBundleContext(context)
-
.setClassName(org.example.service.impl.MyComponentImpl.class.getName())
- .addDependency(new Dependency().setField("myFoo"))
- .setValidateMethod("start");
-
- ((SingletonComponentType) type)
- .setObject(new MyComponentImpl(5)) // Inject a pojo object
- .create();// Create an instance
+ :::java
+ PrimitiveComponentType type = new SingletonComponentType()
+ .setBundleContext(context)
+
.setClassName(org.example.service.impl.MyComponentImpl.class.getName())
+ .addDependency(new Dependency().setField("myFoo"))
+ .setValidateMethod("start");
+
+ ((SingletonComponentType) type)
+ .setObject(new MyComponentImpl(5)) // Inject a pojo object
+ .create();// Create an instance
+
+The type created with the singleton component type are set to `private` by
default. Instead of calling the `start` method, you have to call one of the
`create` methods to start the type and create the instance.
- The type created with the singleton component type are set to {{private}}
by default. Instead of calling the {{start}} method, you have to call one of
the {{create}} methods to start the type and create the instance.
-
- You can also set the contained POJO object by using the {{setObject}}
method. The given object MUST be compatible with the component implementation
class.
+You can also set the contained POJO object by using the `setObject` method.
The given object MUST be compatible with the component implementation class.
- h2. Using external handlers
- iPOJO is extensible... So, it makes sense that the API is also extensible.
So component type provides a method allowing to add external handler
configuration:
- {code:java}
+## Using external handlers
+iPOJO is extensible... So, it makes sense that the API is also extensible. So
component type provides a method allowing to add external handler configuration:
+
+ :::java
return new PrimitiveComponentType()
.setBundleContext(context)
.setClassName(HostImpl.class.getName())
@@ -197,117 +197,126 @@ If you are sure to create only one insta
The `addHandler` method allows you to add any handler description. A handler
description is an object of a class implementing
`org.apache.felix.ipojo.api.HandlerConfiguration`. Handler provider willing to
support the API have to provide this class. For example, the example above uses
`Whiteboard` that is the Whiteboard pattern handler description. This class is
very simple, and is shown below:
-{code:java}
-public class Whiteboard implements HandlerConfiguration {
-
- public static final String NAME = "wbp";
-
- public static final String NAMESPACE = "org.apache.felix.ipojo.whiteboard";
-
- private String arrival;
-
- private String departure;
-
- private String modification;
-
- private String filter;
-
- public Whiteboard onArrival(String method) {
- arrival = method;
- return this;
- }
-
- public Whiteboard onDeparture(String method) {
- departure = method;
- return this;
- }
-
- public Whiteboard onModification(String method) {
- modification = method;
- return this;
- }
-
- public Whiteboard setFilter(String fil) {
- filter = fil;
- return this;
- }
- public Element getElement() {
- ensureValidity();
- // Create the root element.
- Element element = new Element(NAME, NAMESPACE);
- // Mandatory attributes
- element.addAttribute(new Attribute("onArrival", arrival));
- element.addAttribute(new Attribute("onDeparture", departure));
- element.addAttribute(new Attribute("filter", filter));
+ :::java
+ public class Whiteboard implements HandlerConfiguration {
- // Optional attribute
- if (modification != null) {
- element.addAttribute(new Attribute("onModification",
modification));
- }
+ public static final String NAME = "wbp";
- return element;
- }
-
- private void ensureValidity() {
- if (arrival == null) {
- throw new IllegalStateException("The whiteboard pattern
configuration must have a onArrival method");
+ public static final String NAMESPACE =
"org.apache.felix.ipojo.whiteboard";
+
+ private String arrival;
+
+ private String departure;
+
+ private String modification;
+
+ private String filter;
+
+ public Whiteboard onArrival(String method) {
+ arrival = method;
+ return this;
}
- if (departure == null) {
- throw new IllegalStateException("The whiteboard pattern
configuration must have a onDeparture method");
+
+ public Whiteboard onDeparture(String method) {
+ departure = method;
+ return this;
}
- if (filter == null) {
- throw new IllegalStateException("The whiteboard pattern
configuration must have a filter");
+
+ public Whiteboard onModification(String method) {
+ modification = method;
+ return this;
}
- }
+ public Whiteboard setFilter(String fil) {
+ filter = fil;
+ return this;
+ }
+
+ public Element getElement() {
+ ensureValidity();
+ // Create the root element.
+ Element element = new Element(NAME, NAMESPACE);
+ // Mandatory attributes
+ element.addAttribute(new Attribute("onArrival", arrival));
+ element.addAttribute(new Attribute("onDeparture", departure));
+ element.addAttribute(new Attribute("filter", filter));
+
+ // Optional attribute
+ if (modification != null) {
+ element.addAttribute(new Attribute("onModification",
modification));
+ }
+
+ return element;
+ }
+
+ private void ensureValidity() {
+ if (arrival == null) {
+ throw new IllegalStateException("The whiteboard pattern
configuration must have a onArrival method");
+ }
+ if (departure == null) {
+ throw new IllegalStateException("The whiteboard pattern
configuration must have a onDeparture method");
+ }
+ if (filter == null) {
+ throw new IllegalStateException("The whiteboard pattern
configuration must have a filter");
+ }
+
+ }
- The only required method is {{getElement}} returning the Element-Attribute
structure representing the handler configuration (this uses the internal iPOJO
data format). If the metadata cannot be generated, the class throws
IllegalStateExceptions.
+The only required method is `getElement` returning the `Element-Attribute`
structure representing the handler configuration (this uses the internal iPOJO
data format). If the metadata cannot be generated, the class throws
IllegalStateExceptions.
- h2. Creating composition with the API
- The API also allows you to create iPOJO compositions in a pretty simple
way. So you can create compositions:
- * containing internal instances
- * importing services
- * instantiating sub-services
- * exporting services
- * providing services (by delegation)
+## Creating compositions with the API
+The API also allows you to create iPOJO compositions in a pretty simple way.
So you can create compositions:
+
+* containing internal instances
+* importing services
+* instantiating sub-services
+* exporting services
+* providing services (by delegation)
- Here are some examples:
- {code:java|title=Contained instances}
- PrimitiveComponentType prov = createAProvider(); // Create a primitive
type
- PrimitiveComponentType cons = createAConsumer(); // Create another
primitive type
-
- CompositeComponentType type = new CompositeComponentType()
- .setBundleContext(context)
- .setComponentTypeName("comp1")
- .addInstance(new Instance(prov.getFactory().getName())) //
Create an instance in the composite
- .addInstance(new Instance(cons.getFactory().getName()));
+Here are some examples:
+
+#### Creating instances inside a composite:
+
+ :::java
+ PrimitiveComponentType prov = createAProvider(); // Create a primitive type
+ PrimitiveComponentType cons = createAConsumer(); // Create another
primitive type
- ComponentInstance ci = type.createInstance();
+ CompositeComponentType type = new CompositeComponentType()
+ .setBundleContext(context)
+ .setComponentTypeName("comp1")
+ .addInstance(new Instance(prov.getFactory().getName())) // Create
an instance in the composite
+ .addInstance(new Instance(cons.getFactory().getName()));
+
+ ComponentInstance ci = type.createInstance();
-{code:java|title=Importing services}
- CompositeComponentType type = new CompositeComponentType()
+#### Importing a service
+
+ :::java
+ CompositeComponentType type = new CompositeComponentType()
.setBundleContext(context)
.setComponentTypeName("comp3")
- .addSubService(new InstantiatedService() // Importation
- .setSpecification(Foo.class.getName())
- .setOptional(true));
-
- {code:java|title=Instantiated sub-services}
- CompositeComponentType type = new CompositeComponentType()
- .setBundleContext(context)
- .setComponentTypeName("comp2")
- .addSubService(new InstantiatedService() // Instantiated
service
- .setSpecification(Foo.class.getName()))
- .addInstance(new Instance(cons.getFactory().getName()));
+ .addSubService(new ImportedService() // Importation
+ .setSpecification(Foo.class.getName())
+ .setOptional(true));
+
+#### Instantiating a service
-{code:java|title=Exported Services}
-CompositeComponentType type = new CompositeComponentType()
+ :::java
+ CompositeComponentType type = new CompositeComponentType()
+ .setBundleContext(context)
+ .setComponentTypeName("comp2")
+ .addSubService(new InstantiatedService() // Instantiated service
+ .setSpecification(Foo.class.getName()))
+ .addInstance(new Instance(cons.getFactory().getName()));
+
+#### Exporting a service
+
+ :::java
+ CompositeComponentType type = new CompositeComponentType()
.setBundleContext(context)
.setComponentTypeName("compExport")
.addSubService(new
InstantiatedService().setSpecification(Foo.class.getName()))
.addService(new ExportedService()
- .setSpecification(Foo.class.getName())); // Exports a service
-
- \\
+ .setSpecification(Foo.class.getName())); // Exports a service
Modified:
felix/site/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/ipojo-faq.mdtext
URL:
http://svn.apache.org/viewvc/felix/site/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/ipojo-faq.mdtext?rev=1445514&r1=1445513&r2=1445514&view=diff
==============================================================================
---
felix/site/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/ipojo-faq.mdtext
(original)
+++
felix/site/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/ipojo-faq.mdtext
Wed Feb 13 09:20:49 2013
@@ -6,42 +6,42 @@ Title: iPOJO FAQ
# Apache Felix iPOJO FAQ
-{div:class=toc}
[TOC]
-{div}
## Injecting the bundle context in a POJO
It is sometimes useful to inject the bundle context in your POJO. Then, your
POJO is able to deal with the OSGi environment as *regular* OSGi applications.
It is possible to a POJO to get its `BundleContext`. A POJO can receive its
bundle context as an argument of its constructor. The next code snippet shows
an example:
-{code:java}
-public class ASimplePOJO{
- private BundleContext context;
- public ASimplePOJO(BundleContext bc) {
- context = bc;
- // do something...
- }}
- As you see on the previous snippet, the bundle context is injected in the
POJO. Then the POJO can use it as a 'normal' bundle context. The POJO code can:
- * load classes
- * register / unregister services
- * discover, track and use services
-
- However, all these interactions are no more managed by the iPOJO
container. So, be careful to manage the dynamism, synchronization, listeners...
+ :::java
+ public class ASimplePOJO{
+ private BundleContext context;
+ public ASimplePOJO(BundleContext bc) {
+ context = bc;
+ // do something...
+ }
+ }
+
+As you see on the previous snippet, the bundle context is injected in the
POJO. Then the POJO can use it as a 'normal' bundle context. The POJO code can:
+
+* load classes
+* register / unregister services
+* discover, track and use services
- h2. Accessing services inside inner and anonymous classes
+However, all these interactions are no more managed by the iPOJO container.
So, be careful to manage the dynamism, synchronization, listeners...
- An inner class is a class defined inside another class. This mechanism is
useful in order to avoid creating a bunch of small files. So, it is common when
creating threads, Swing listeners ... Generally speaking, inner classes are
regular classes treated as separate classes. However this is an
oversimplification. Some of the information about an inner class is not in its
class file. See section 4.7.5 for further details:
-
[http://java.sun.com/docs/books/jvms/second_edition/html/ClassFile.doc.html]
+## Accessing services inside inner and anonymous classes
+An inner class is a class defined inside another class. This mechanism is
useful in order to avoid creating a bunch of small files. So, it is common when
creating threads, Swing listeners ... Generally speaking, inner classes are
regular classes treated as separate classes. However this is an
oversimplification. Some of the information about an inner class is not in its
class file. See section 4.7.5 for further details on
[http://java.sun.com/docs/books/jvms/second_edition/html/ClassFile.doc.html]
- An inner class can access fields of its outer class. Since the iPOJO 1.0.0
version, fields managed by iPOJO, such as a service dependencies and
properties, are also available from the inner class. Indeed, iPOJO manipulation
also manipulates inner and nested classes, and accesses to outer class fields
are correctly managed.
+An inner class can access fields of its outer class. Since the iPOJO 1.0.0
version, fields managed by iPOJO, such as a service dependencies and
properties, are also available from the inner class. Indeed, iPOJO manipulation
also manipulates inner and nested classes, and accesses to outer class fields
are correctly managed.
- h2. Using a different version of the manipulator during the manipulation
+## Using a different version of the manipulator during the manipulation
- You can configure the version of the manipulator that you want to use when
you're using the maven-ipojo-plugin or the iPOJO ant task. This allows to
benefit latest improvements.
+You can configure the version of the manipulator that you want to use when
you're using the maven-ipojo-plugin or the iPOJO ant task. This allows to
benefit latest improvements.
- For Maven, Just declare a dependency on the manipulator that you want to
use in the maven-ipojo-plugin plugin section:
- {code:xml|title=Maven}
+For Maven, Just declare a dependency on the manipulator that you want to use
in the maven-ipojo-plugin plugin section:
+
+ :::xml
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-ipojo-plugin</artifactId>
@@ -56,25 +56,26 @@ public class ASimplePOJO{
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.ipojo.manipulator</artifactId>
- <version>1.6.2</version>
+ <version>1.8.6</version>
</dependency>
</dependencies>
</plugin>
-
For Ant, just configure the classpath of the iPOJO ant task with the
Manipulator that you want to use:
-{code:xml|title=Ant}
-<taskdef name="ipojo"
- classname="org.apache.felix.ipojo.task.IPojoTask"
-
classpath="../ipojo/manipulator/org.apache.felix.ipojo.manipulator-1.7.0-SNAPSHOT.jar;
lib/org.apache.felix.ipojo.ant-1.7.0-SNAPSHOT.jar;" />
- />
+
+ :::xml
+ <taskdef name="ipojo"
+ classname="org.apache.felix.ipojo.task.IPojoTask"
+
classpath="../ipojo/manipulator/org.apache.felix.ipojo.manipulator-1.7.0-SNAPSHOT.jar;
lib/org.apache.felix.ipojo.ant-1.7.0-SNAPSHOT.jar;" />
+ />
- h2. Callbacks order.
+## Callbacks order.
- A lot of handlers define callbacks to notify the implementation class. The
'core' callbacks are called in the following order:
- {code:java}
+A lot of handlers define callbacks to notify the implementation class. The
'core' callbacks are called in the following order:
+
+ :::java
@Component
@Provides
public class CallbacksOrder implements MyService {
@@ -133,21 +134,22 @@ For Ant, just configure the classpath of
}
-## Disabling proxies in iPOJO 1.6\+
+## Disabling proxies in iPOJO 1.6+
iPOJO 1.6.0 has generalized the proxy usage. However this mechanism can be
disabled.
-To disable the proxies on the entire framework, just set the property
`ipojo.proxy` to `disabled` (this set the default 'proxy' value). This property
is either a system property (`\-Dipojo.proxy=disabled` in the command line) or
a framework property (given to the framework during its initialization).
+To disable the proxies on the entire framework, just set the property
`ipojo.proxy` to `disabled` (this set the default 'proxy' value). This property
is either a system property (`-Dipojo.proxy=disabled` in the command line) or a
framework property (given to the framework during its initialization).
You can also disable proxies for specific dependencies by using the `proxy`
attribute:
-{code:java}
-@Requires(proxy=false)
-private LogService log
- or
- {code:xml}
- <requires field="log" proxy="false"/>
+ :::java
+ @Requires(proxy=false)
+ private LogService log
+or
+
+ :::xml
+ <requires field="log" proxy="false"/>
The default value of the `proxy` attribute is the value of the `ipojo.proxy`
property.
@@ -158,6 +160,7 @@ Smart proxies are generated on the fly u
## Can I use iPOJO with other OSGi implementations?
iPOJO relies on the OSGi R4.1 specification, so works on any compliant
implementation. Moreover, iPOJO is weekly tested on Apache Felix, Eclipse
Equinox and Knopflerfish..
+
For further information, refer to the [supported OSGi implementations]({{
refs.apache-felix-ipojo-supportedosgi.path }}) page and on this
[blog|http://ipojo-dark-side.blogspot.com/2008/11/lessons-learned-from-ipojo-testing.html]
post.
## Detecting optional service unavailability
@@ -165,13 +168,15 @@ For further information, refer to the [s
Sometimes it is useful to check if an optional service dependency is fulfilled
or not. In order to propose a pretty simple development model, iPOJO injects
proxies by default which avoid such check (Because proxies hide such details).
By disabling proxies, you can easily check to unavailability.
* First, disable the proxy injection:
-{code:java}
-@Requires(proxy=false)
-private LogService log;
+
+ :::java
+ @Requires(proxy=false)
+ private LogService log;
- * The injected object will be a direct reference. By default, iPOJO
injects a {{Nullable}} object, on which you can call service method without
checking for {{null}}. To detect Nullable objects, just use {{instanceof}}
- {code:java}
+* The injected object will be a direct reference. By default, iPOJO injects a
`Nullable` object, on which you can call service method without checking for
`null`. To detect Nullable objects, just use `instanceof`
+
+ :::java
@Requires(proxy=false)
private LogService log;
@@ -185,31 +190,34 @@ private LogService log;
* If you prefer injecting `null` instead of a `Nullable`, just disable
Nullable injection too. However, be care to check for `null` before each
invocation.
-{code:java}
-@Requires(proxy=false, nullable=false)
-private LogService log;
-
-public void doSomething() {
- if (log == null) {
- // Service unavailable
- } else {
- // Service available
+
+ :::java
+ @Requires(proxy=false, nullable=false)
+ private LogService log;
+
+ public void doSomething() {
+ if (log == null) {
+ // Service unavailable
+ } else {
+ // Service available
+ }
}
-}
- h2. Setting the iPOJO log level
+## Setting the iPOJO log level
- By default, iPOJO logs only warning and error messages. There are two
different methods to configure the log level. First, you can set the global log
level by setting the _ipojo.log.level_ system property. This replaces the
default log level (warning). All iPOJO instances will be impacted. However,
each bundle containing component types can specify a different log level. To
set this level, add the _ipojo-log-level_ header in your manifest. The possible
values for these two properties are:
+By default, iPOJO logs only warning and error messages. There are two
different methods to configure the log level. First, you can set the global log
level by setting the _ipojo.log.level_ system property. This replaces the
default log level (warning). All iPOJO instances will be impacted. However,
each bundle containing component types can specify a different log level. To
set this level, add the _ipojo-log-level_ header in your manifest. The possible
values for these two properties are:
+
* info
* debug
* warning (default)
* error
- h2. Installing iPOJO in Service Mix Kernel
+## Installing iPOJO in Service Mix Kernel
- You can use iPOJO in Service Mix Kernel. To deploy and start it, just
execute the following command line in the ServiceMix Kernel Shell.
- {code:xml}
+You can use iPOJO in Service Mix Kernel. To deploy and start it, just execute
the following command line in the ServiceMix Kernel Shell.
+
+ :::xml
osgi install -s mvn:org.apache.felix/org.apache.felix.ipojo/1.2.0
@@ -224,6 +232,7 @@ Thanks to File install you can create, d
iPOJO Handlers have a *start* level. This is *not* the `OSGi Start Level`.
This level is used to determine in which order handler are configured, started
and stopped. Handlers with a low level are configured and started before
handlers with a high level. Moreover they are stopped after handlers with a
high level. By default, handlers have no level. It means that they have the
maximum level (`Integer.MAX`).
Here are the levels of core handlers:
+
* Service Dependency: 0 (minimum level)
* Lifecycle Callback: 1
* Configuration Properties: 1
@@ -232,24 +241,27 @@ Here are the levels of core handlers:
* Architecture Handler: no level (Integer.MAX)
From these levels, we can see that bind methods will be called before set
methods from configuration properties. So, when a POJO objects, callback are
called in this order:
+
1. bind methods
1. validate method
1. setter methods from instance configuration
-<div class="info" markdown="1">
-**Changes in the 1.3.0-SNAPSHOT**
+<div class="alert alert-info info" markdown="1">
+<h4>Changes in the 1.3.0-SNAPSHOT</h4>
iPOJO 1.3.0-SNAPSHOT sets the lifecycle callback handler level to 2. So,
setter methods from instance properties are called before the validate method.
</div>
## Why does my bundle import unused packages?
If you check iPOJO bundle imported packages, you will see that some packages
where added:
+
* org.apache.felix.ipojo;version= 1.2.0
* org.apache.felix.ipojo.architecture;version= 1.2.0
* org.osgi.service.cm;version=1.2
* org.osgi.service.log;version=1.3
The `org.apache.felix.ipojo` package is the main iPOJO package. Manipulated
class use it to get access to injected values. The
`org.apache.felix.ipojo.architecture` package is used to expose *Architecture*
service (allowing instance introspection). This service is exposed with the
bundle context from the bundle declaring the component type.
+
The `org.osgi.service.cm` package is imported to publish *ManagedService* and
*ManagedServiceFactory* with the bundle context from the bundle declaring the
component type. So, if you look for services exposed by a bundle declaring
component types, you will see *ManagedServiceFactory* services.
Finally, the `org.osgi.service.log` is imported because iPOJO delegates log to
a log service (if available). This service is get from the bundle context from
the bundle declaring the component type. So, to get this service, the package
of the service interface is imported. Then, according to implementations, log
services may get the bundle logging the message.
@@ -257,7 +269,7 @@ Finally, the `org.osgi.service.log` is i
The following table highlights some of the features of each system, it does
not attempt to highlight every feature of each.
-| Dependency injection | Declarative Services | Blueprint | iPOJO |
+| Dependency injection | Declarative Services | Blueprint | iPOJO |
|--|--|--|--|
| Callback injection | Yes | Yes (public method only) | Yes |
| Constructor injection | No | Yes | Yes |
@@ -266,6 +278,8 @@ The following table highlights some of t
| Proxy injection | No | Yes | Yes |
| List injection | No | Yes | Yes |
| Nullable injection | No | No | Yes |
+
+
| Lifecycle | Declarative Services | Blueprint | iPOJO |
|--|--|--|--|
| Callbacks (activate/deactivate) | Yes | Yes | Yes |
@@ -275,25 +289,30 @@ The following table highlights some of t
| Field synchronization | No | No | Yes |
| Component lifecycle control | Yes | Partial | Yes |
| Service lifecycle control | No | No | Yes |
+
+
| Configuration | Declarative Services | Blueprint | iPOJO |
|--|--|--|--|
| Property configuration | No | Yes | Yes |
| Field configuration | No | No | Yes |
| Configuration Admin | Yes | No | Yes |
+
+
| Services | Declarative Services | Blueprint | iPOJO |
|--|--|--|--|
| Custom attribute type | No | Yes | Yes |
| Lazy initialization | Yes | Yes | Yes |
| Composite services | No | No | Yes |
+
+
| Component description | Declarative Services | Blueprint | iPOJO |
|--|--|--|--|
| XML | Yes | Yes | Yes |
| Java annotations | No | No | Yes |
| API | No | No | Yes |
+
+
| Nonfunctional | Declarative Services | Blueprint | iPOJO |
|--|--|--|--|
| Multiple providers | Yes | Yes | No |
-
-
-
-
+
\ No newline at end of file
Modified:
felix/site/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/using-xml-schemas.mdtext
URL:
http://svn.apache.org/viewvc/felix/site/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/using-xml-schemas.mdtext?rev=1445514&r1=1445513&r2=1445514&view=diff
==============================================================================
---
felix/site/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/using-xml-schemas.mdtext
(original)
+++
felix/site/trunk/content/documentation/subprojects/apache-felix-ipojo/apache-felix-ipojo-userguide/using-xml-schemas.mdtext
Wed Feb 13 09:20:49 2013
@@ -8,7 +8,6 @@ Title: Using XML Schemas
*iPOJO provides XML schemas to check iPOJO descriptors (i.e. metadata.xml).
Several schemas are provided in order to describe the core syntax, compositions
and external handlers.*
-{center}
| Schema | URL |
|--|--|
| iPOJO Core |
[http://felix.apache.org/ipojo/schemas/CURRENT/core.xsd](http://felix.apache.org/ipojo/schemas/CURRENT/core.xsd)
|
@@ -18,12 +17,14 @@ Title: Using XML Schemas
| Extender pattern handler |
[http://felix.apache.org/ipojo/schemas/CURRENT/extender-pattern.xsd](http://felix.apache.org/ipojo/schemas/CURRENT/extender-pattern.xsd)
|
| Event Admin handlers |
[http://felix.apache.org/ipojo/schemas/CURRENT/event-admin.xsd](http://felix.apache.org/ipojo/schemas/CURRENT/event-admin.xsd)
|
| JMX handler |
[http://felix.apache.org/ipojo/schemas/CURRENT/jmx.xsd](http://felix.apache.org/ipojo/schemas/CURRENT/jmx.xsd)
|
-{center}
+
*Note:* the schemas are also provided inside implicated bundles.
+
*Note:* to use the 'dev' schemas, replace `CURRENT` by `SNAPSHOT` in the URL.
To use those schemas you have to declares those schemas in your metadata.xml
file such as in the next snippet using the iPOJO core XML-schema:
+ :::xml
<ipojo
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="org.apache.felix.ipojo
http://felix.apache.org/ipojo/schemas/CURRENT/core.xsd"
@@ -32,9 +33,10 @@ To use those schemas you have to declare
</component>
</ipojo>
-First, declares the 'XMLSChema-instance' namespace. Then, declares used
namespaces and schemas in the 'xsi:schemaLocation' attribute. This attribute
contains pairs 'namespace url' separated by spaces. Finally, declares the
default namespace to "org.apache.felix.ipojo".
+First, declare the 'XMLSChema-instance' namespace. Then, declares used
namespaces and schemas in the 'xsi:schemaLocation' attribute. This attribute
contains pairs 'namespace url' separated by spaces. Finally, declares the
default namespace to "org.apache.felix.ipojo".
You can also use several schemas in the same descriptor by using a header like:
+ :::xml
<ipojo xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="org.apache.felix.ipojo
http://felix.apache.org/ipojo/schemas/CURRENT/core.xsd
org.apache.felix.ipojo.extender
http://felix.apache.org/ipojo/schemas/CURRENT/extender-pattern.xsd"
@@ -53,10 +55,11 @@ You can also use several schemas in the
</ipojo>
The only difference is contained in the 'schemaLocation' attribute, which
contains several pairs. You also need to declare the namespace of the used
external handler.
+
If you declare schemas, the iPOJO manipulator automatically checks the
validity of the descriptor against the declared schemas. Moreover, if you use
'advanced' XML Editor supporting schemas, editing iPOJO descriptors should be
eased with auto-completion features.
## Avoid downloading XML Schemas during the build process
-The manipulator embeds the iPOJO XML Schemas to avoid using a network
connection to download them during the validation process. Keep the same url,
the manipulator will just resolve the URL differently to use embedded schemas.
You can also skipped this shortcut thanks the the `ignoreEmbeddedSchemas`
parameter (refer to the [ant task guide]({{ refs.ipojo-ant-task.path }}) and to
the [maven plugin guide|iPOJO Maven Plug-in] for further information about
configuration).
+The manipulator embeds the iPOJO XML Schemas to avoid using a network
connection to download them during the validation process. Keep the same url,
the manipulator will just resolve the URL differently to use embedded schemas.
You can also skipped this shortcut thanks the the `ignoreEmbeddedSchemas`
parameter (refer to the [ant task guide]({{ refs.ipojo-ant-task.path }}) and to
the [maven plugin guide]({{ refs.ipojo-maven-plug-in.path }}) for further
information about configuration).
Modified: felix/site/trunk/content/ipojo/site/button.html
URL:
http://svn.apache.org/viewvc/felix/site/trunk/content/ipojo/site/button.html?rev=1445514&r1=1445513&r2=1445514&view=diff
==============================================================================
--- felix/site/trunk/content/ipojo/site/button.html (original)
+++ felix/site/trunk/content/ipojo/site/button.html Wed Feb 13 09:20:49 2013
@@ -1,2 +1,2 @@
<html><head>
-<meta http-equiv="content-type" content="text/html;
charset=UTF-8"></head><body></body></html>
\ No newline at end of file
+<meta http-equiv="content-type" content="text/html;
charset=UTF-8"></head><body></body></html>