Concrete developments steps

compared with
Current by Victor NOËL
on May 25, 2016 13:59.

(show comment)
Key
This line was removed.
This word was removed. This word was added.
This line was added.

Changes (26)

View Page History
h1. Setting up your environment

The first thing to do when starting working on a new component is to download and install Apache Maven 2, and a good IDE (e.g. NetBeans, Eclipse or IntelliJ).
In the rest of this document, it is assumed you use Eclipse as your IDE. When this document references Eclipse actions, you should be able to find equivalents with other IDEs.

{warning}For the moment, Maven 3 does not work for Petals ESB and its components. It would require some changes in the POM files.{warning}
h2. Installing and configuring Apache Maven

h2. Installing and configuring Apache Maven 2
[Apache Maven|http://maven.apache.org/] is a popular "software project management and comprehension tool". In many ways, it can be seen as the successor of - the still popular - Ant tool. Nowadays, Maven is used by an increasing number of software projects, including Petals ESB. An important part of the development of Petals component is based on the use of this tool.

[Apache Maven 2|http://maven.apache.org/] is a popular "software project management and comprehension tool". In many ways, it can be seen as the successor of - the still popular - Ant tool. Nowadays, Maven 2 is used by an increasing number of software projects, including Petals ESB. An important part of the development of Petals component is based on the use of this tool.

Either install maven with your distribution or do it by hand:
# Download Apache Maven 2 from: [http://maven.apache.org/|http://maven.apache.org/].
# Install Maven 2 using this guide: [http://maven.apache.org/download.html|http://maven.apache.org/download.html].
# Check if the {{M2_HOME}} environment variable is pointing to your Maven 2 installation.
# Check if {{M2_HOME/bin}} has been added to your system path.

To use the OW2 Maven 2 repositories, you must perform some additional configuration :
# Go into the Maven 2 local repository (typically {{C:/Documents and settings/username/.m2}} on Windows or {{/home/username/.m2}} on most Unix(es)).
# Open (or create if not present) the {{settings.xml}} file and make sure to include the repositories listed in the sample below.
That's it for Apache Maven.

{code:lang=xml}
<settings>
<profiles>
<profile>
<id>default-profile</id>
<activation>
<activeByDefault>TRUE</activeByDefault>
</activation>
<repositories>
<repository>
<id>ow2</id>
<url>http://maven.ow2.org/maven2</url>
</repository>
<repository>
<id>petalslink</id>
<url>http://maven.petalslink.org/public/</url>
</repository>
</repositories>
</profile>
</profiles>
</settings>
{code}

That's it for Apache Maven 2.

\\
{info:title=Info}
For more information on Apache Maven 2, you should read the following books:
* [Maven by Example|http://www.sonatype.com/books/mvnex-book/reference/public-book.html]
* [Maven: The Complete Reference|http://www.sonatype.com/books/mvnref-book/reference/public-book.html]
\\
{info:title=Releases vs. Snapshots}
Petals' released Maven artifacts are hosted by OW2. The Maven repository is the one given above.
However, snapshot versions are now hosted by Petals Link on its own Maven repositories. Those can be found at this address: [http://maven.petalslink.com]
Petals' released Maven artifacts are hosted on Maven Central and are available without configuration.
However, snapshot versions are hosted by OW2 on its own Maven repositories. Those can be found at this url: [http://repository.ow2.org/nexus/content/repositories/snapshots/]
{info}

h3. Configuring Eclipse

In order to make Eclipse use Maven artifacts, you have to set a class path variable.
To do so, launch your Eclipse, select *Window > Preferences* and go into *Java > Build Path > Classpath Variable*.
The variable to create is called *M2_REPO*.
In order to make Eclipse use Maven artifacts, you must install the Eclipse plugin m2e. It is usually installed by default.

{center} !eclipse-m2repo-cfg.png!{center}

If it does not exist, click *New...*, call it *M2_REPO* and associate it the Maven repository folder.
This folder is located at *\~/.m2/repository*. Click *OK* to register this variable and then *OK* to save and close the preferences.

h3. Configuring NetBeans

This section has to must be completed.

h3. Configuring IntelliJ

This section has to must be completed.

h1. Creating a component
* _petals-se-componentName_ for service engines.

Go into a directory where you can store your project.
Your IDE workspace may be a good place for that. Open a terminal on this location. The command below creates a service engine, based on the CDK 5, and called _petals-se-sample_.
...
This section must be completed.
...

{code:lang=actionscript}
# Maven command to create a Petals service engine
mvn archetype:generate
-DarchetypeGroupId=org.ow2.petals
-DarchetypeArtifactId=maven-archetype-petals-jbi-service-engine
-DarchetypeVersion=1.3
-DgroupId=org.ow2.petals.se.sample
-DartifactId=petals-se-sample
-Dversion=1.0-SNAPSHOT
{code}

{warning}Be careful, the previous command has been formatted for readability purpose. In fact, it should be on a single line.{warning}

\\
The meaning of these options is listed below.
* *archetypeArtifactId* is the type of artifact to create.
** *maven-archetype-petals-jbi-service-engine* for a service engine.
** *maven-archetype-petals-jbi-binding-component* for a binding component.
* *archetypeVersion* is the archetype version.
** *1.3* is the one to use for the (released) CDK 5.
** *1.4-SNAPSHOT* is the one (currently) used with the CDK in development.
* *groupId* is the group ID, which is also the name of the root package in the created project.
* *artifactId* is the artifact ID, usually the full component name.
* *version* is the component version, followed by the \-SNAPSHOT suffix.

\\
During the creation, you are asked to confirm the project properties. Type in '*Y*' to confirm.
The executed command results in the creation of a Java Maven project.

{warning}With the current version of the Petals Maven plug-in, you will have to make a minor change in the pom.xml. Otherwise, you will get an build error indicating that some libraries could not be found (related to ws-notifications). Use the version 4.1.1 of the petals-cdk-core and the version 4 for the parent. It should solve all your build problems.{warning}

\\
To transform it into a project we can use in our IDE. For Eclipse, we can use the following commands:

{code:lang=actionscript}
# Go into the created project
cd petals-se-sample

# Convert it into an Eclipse project
mvn eclipse:eclipse
{code}

\\
You should now wait for Maven to download all the required dependencies and create the Eclipse files. Once this is done, launch your Eclipse IDE and import the project in your workspace: select *File > Import...* and then *General > Existing projects into Workspace*. In the open dialog, click *Browse...*, select your workspace as the root folder and click *OK*. Now, in the listed projects, check your component project and click *OK*.

!petals-developing-components-import1.jpg!

\\
Your component project is now created and ready to be completed.
The main files to notice are:
* The *pom.xml*, which holds the Maven dependencies.
h3. Using Netbeans

This secction has to section must be completed.

h3. Using IntelliJ

This secction has to section must be completed.

h2. Testing a component