Difference between revisions of "How to Create a new OSGi Bundle"
(New page: While writing Customizing opentaps 2: an OSGi Tutorial, I realized that one of the Java classes was in the wrong place. <tt>Note.java</tt>, which is the object representation of a not...) |
m (Protected "How to Create a new OSGi Bundle": Sysop page [edit=sysop:move=sysop]) |
(No difference)
| |
Revision as of 22:02, 24 February 2012
While writing Customizing opentaps 2: an OSGi Tutorial, I realized that one of the Java classes was in the wrong place. Note.java, 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="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.opentaps</groupId>
<artifactId>notes.domain</artifactId>
<version>2.0.1-SNAPSHOT</version>
<name>Notes domain</name>
<packaging>bundle</packaging>
<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
</plugin>
</plugins>
</build>
<parent>
<groupId>org.opentaps</groupId>
<version>2.0.1-SNAPSHOT</version>
<artifactId>notes</artifactId>
</parent>
</project>