Converting existing projects to OSGi projects

About this task

You can convert your Java™ EE modules, Java projects, and PDE plug-ins to OSGi projects to take advantage of the many benefits of the OSGi framework.

Procedure

  1. Launch the conversion dialog.
    In Enterprise Explorer, right-click your PDE, Java EE module, or EJB project and select Configure > Convert to OSGi Bundle Project. This conversion assumes that the project name and location are the same.
    Note: If you are converting a PDE fragment project or a Java EE fragment project to an OSGi fragment project, right-click the fragment and select Configure > Convert to OSGi Bundle Fragment Project.
  2. Review the information in the conversion dialog.
    Messages and Details
    The conversion dialog displays messages about the projects you are converting. If you select a message, if there is additional information it is displayed in the Details section.
    Search binaries that have no source attachment for packages to import
    When you convert a project with Java source files, packages that are not satisfied within the project are automatically added to the new bundle manifest file. However, if the source is not available, the option Search binaries that have no source attachment for packages to import facilitates the conversion. Note that when you search binary files, there are some instances when packages are not found. For example, the package information for objects used only within method blocks is not found. If necessary, in these cases you can add the import information manually to the manifest. Search binaries that have no source attachment for packages to import is selected by default.
    The following image shows the conversion dialog with example messages for an EJB conversion.
    Convert to an OSGi bundle project
  3. Click OK to convert the project.

Results

When your Java EE, EJB, or PDE project is converted to an OSGi bundle, OSGi specific natures, builders, class path entries, and project resources are added to the OSGi application. PDE-specific natures, builders, class path entries, and project resources are removed from the newly converted OSGi application. The project settings are updated to include default preferences for your OSGi application.

The bundle manifest file, MANIFEST.MF, is created or updated to include all of the required bundle properties. An OSGi bundle manifest describes the bundle and bundle dependencies. For more information about the bundle manifest file, see OSGi bundle manifest file. For information on the fragment manifest file, refer to OSGi fragment manifest files.

What to do next

After you convert your PDE or Java EE project into an OSGi bundle project, you can create your business logic, export the OSGi bundle as a JAR file, add the bundle to an OSGi application, or add the bundle to a composite bundle.