LibraryToggle FramesPrintFeedback

In order to generate a project using the Maven Quickstart archetype, you must have the following prerequisites:

You must customize the POM file in order to generate an OSGi bundle, as follows:

  1. Follow the POM customization steps described in Modifying an Existing Maven Project.

  2. In the configuration of the Maven bundle plug-in, modify the bundle instructions to export the org.fusesource.example.service package, as follows:

    <project ... >
      ...
      <build>
        ...
        <plugins>
          ...
          <plugin>
            <groupId>org.apache.felix</groupId>
            <artifactId>maven-bundle-plugin</artifactId>
            <extensions>true</extensions>
            <configuration>
              <instructions>
                <Bundle-SymbolicName>${pom.groupId}.${pom.artifactId}</Bundle-SymbolicName>
            	    <Export-Package>org.fusesource.example.service</Export-Package>
              </instructions>
            </configuration>
          </plugin>
        </plugins>
      </build>
      ...
    </project>

To install and run the osgi-service project, perform the following steps:

  1. Build the project—open a command prompt and change directory to ProjectDir/osgi-service. Use Maven to build the demonstration by entering the following command:

    mvn install

    If this command runs successfully, the ProjectDir/osgi-service/target directory should contain the bundle file, osgi-service-1.0-SNAPSHOT.jar.

  2. Install and start the osgi-service bundle—at the Fuse ESB console, enter the following command:

    karaf@root> osgi:install -s file:ProjectDir/osgi-service/target/osgi-service-1.0-SNAPSHOT.jar

    Where ProjectDir is the directory containing your Maven projects and the -s flag directs the container to start the bundle right away. For example, if your project directory is C:\Projects on a Windows machine, you would enter the following command:

    karaf@root> osgi:install -s file:C:/Projects/osgi-service/target/osgi-service-1.0-SNAPSHOT.jar
    [Note]Note

    On Windows machines, be careful how you format the file URL—for details of the syntax understood by the file URL handler, see File URL Handler.

  3. Check that the service has been created—to check that the bundle has started successfully, enter the following Fuse ESB console command:

    karaf@root> osgi:list

    Somewhere in this listing, you should see a line for the osgi-service bundle, for example:

    [ 236] [Active     ] [Created     ] [       ] [   60] osgi-service (1.0.0.SNAPSHOT)

    To check that the service is registered in the OSGi service registry, enter a console command like the following:

    karaf@root> osgi:ls 236

    Where the argument to the preceding command is the osgi-service bundle ID. You should see some output like the following at the console:

    osgi-service (236) provides:
    ----------------------------
    osgi.service.blueprint.compname = hello
    objectClass = org.fusesource.example.service.HelloWorldSvc
    service.id = 272
    ----
    osgi.blueprint.container.version = 1.0.0.SNAPSHOT
    osgi.blueprint.container.symbolicname = org.fusesource.example.osgi-service
    objectClass = org.osgi.service.blueprint.container.BlueprintContainer
    service.id = 273
Comments powered by Disqus
loading table of contents...