blob: e177083fd81241ab2852c8c12cc3aa4f9768d511 [file] [log] [blame]
h1. Developing OSGi components with EIK
This chapter describes how to develop a osgi component with EIK.
Now we have a functional karaf environment in Eclipse, and we will illustrate howto develop a debug simple Camel route
For this example we use apache servicemix 4.4.2.
Using command line, we can create our project:
{noformat}
mvn archetype:generate \
-DarchetypeGroupId=org.apache.karaf.eik.archetypes \
-DarchetypeArtifactId=eik-camel-archetype \
-DarchetypeVersion=0.9.0-SNAPSHOT \
-DgroupId=org.apache \
-DartifactId=eik-camel-osgi-project \
-Dversion=1.0.0-SNAPSHOT
{noformat}
as soon as possible this archetype will be available for m2e
*Additional parameters*
During the maven creation process, additional questions will be asked on the console :
* Define value for property 'camel-version':
The version of camel we want to use
* Define value for property 'slf4j-version':
The version of slf4j we want to use
*Result of Maven command execution*
{noformat}
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] >>> maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom >>>
[INFO]
[INFO] <<< maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom <<<
[INFO]
[INFO] --- maven-archetype-plugin:2.2:generate (default-cli) @ standalone-pom ---
[INFO] Generating project in Interactive mode
[INFO] Archetype repository missing. Using the one from [org.apache.karaf.eik.archetypes:camel-osgi-pde-plugin:3.0.0-SNAPSHOT] found in catalog local
[INFO] Using property: groupId = org.apache
[INFO] Using property: artifactId = eik-camel-osgi-project
[INFO] Using property: version = 1.0.0-SNAPSHOT
[INFO] Using property: package = org.apache
Define value for property 'camel-version': ${camel-version}: : 2.8.5
Define value for property 'slf4j-version': ${slf4j-version}: : 1.6.1
Confirm properties configuration:
groupId: org.apache
artifactId: eik-camel-osgi-project
version: 1.0.0-SNAPSHOT
package: org.apache
camel-version: 2.8.5
slf4j-version: 1.6.1
Y: :
[INFO] ----------------------------------------------------------------------------
[INFO] Using following parameters for creating project from Archetype: camel-osgi-pde-plugin:3.0.0-SNAPSHOT
[INFO] ----------------------------------------------------------------------------
[INFO] Parameter: groupId, Value: org.apache
[INFO] Parameter: artifactId, Value: eik-camel-osgi-project
[INFO] Parameter: version, Value: 1.0.0-SNAPSHOT
[INFO] Parameter: package, Value: org.apache
[INFO] Parameter: packageInPathFormat, Value: org/apache
[INFO] Parameter: camel-version, Value: 2.8.5
[INFO] Parameter: package, Value: org.apache
[INFO] Parameter: version, Value: 1.0.0-SNAPSHOT
[INFO] Parameter: groupId, Value: org.apache
[INFO] Parameter: slf4j-version, Value: 1.6.1
[INFO] Parameter: artifactId, Value: eik-camel-osgi-project
[INFO] project created from Archetype in dir: /projects/formazione/manual/test/eik-camel-osgi-project
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 13.551s
[INFO] Finished at: Wed Oct 10 13:54:28 CEST 2012
[INFO] Final Memory: 7M/118M
[INFO] ------------------------------------------------------------------------
{noformat}
*Import project in eclipse*
To compile and import project in Eclipse, type:
mvn clean install -DskipTests=true eclipse:eclipse
then import the project in Eclipse and add to MANIFEST
then inport project in eclipse and add in MANIFEST
* Bundle ID
* Name
!/images/devcomponent_1.png!
Using Eclipse IDE we can import package for our needs in the project, the package available are those present in target platform.
To do that we need do double click on the MANIFEST.MF > Dependencies you can use UI to import package
EIK feature allows Automatic deployment of workspace plugin projects.
If you check Run configurations or in Debug configurations. You will see your project
!/images/devcomponent_2.png!
To run your application, select Debug button, wait few seconds for container startup and you will see
!/images/devcomponent_9.png!