How to Create a new OSGi Bundle

From Opentaps Wiki
Revision as of 22:02, 24 February 2012 by Sichen (talk | contribs) (Protected "How to Create a new OSGi Bundle": Sysop page [edit=sysop:move=sysop])
Jump to navigationJump to search

While writing Customizing opentaps 2: an OSGi Tutorial, I realized that one of the Java classes was in the wrong place., which is the object representation of a note, is a domain class under the Domain Driven Architecture. Since domain classes represent data, not actions, it shouldn't be part of the services API bundle, so I'm going to move it into a new bundle for a domain class. In the process, I thought this would be a good tutorial on how to create an OSGi bundle.

First, I create a directory for my bundle. Under the opentaps-2/modules/notes, I will add a new directory called domain, parallel to api and impl.

Next, I create a directory within this bundle for my Java files: src/main/java under the opentaps-2/modules/notes/domain directory. This is where the Java source files go. If there were other types of source files, like web.xml for webapp configuration or .properties files for localizations, then I would also need a src/main/resources, but I don't have those right now, so I'm not going to create this.

Next, I need a pom.xml for maven in the domain/ directory. I will borrow from the one for the api bundle and modify it:

<project xmlns="" xmlns:xsi=""



    <name>Notes domain</name>