Version 7

    Maven archetype is project templating toolkit. One can use archetype to quick start writing specific module. Mobicents provides archetypes for SLEE 1.1 components.

     

    Note: please refer to catalog definition and archetype plugin documentation.

    Note2: there are two arechetypes( "basic" ) which build modules specific to 1.x SLEE container, since 1.x is not in development anymore, those archetypes are not included in article.

     

    Source code

    Current source code can be downloaded from trunk. Released version source code is available at this location.

     

     

    Setting up catalog

    Archetype Catalog contains definition of available archetypes. There are two ways to set up the catalog. First one requires manual build of archetype sources. After successful build, maven will generate catalog which will look similar to one presented below:

     

    {code:xml}

    <?xml version="1.0" encoding="UTF-8"?><archetype-catalog>

      <archetypes>

        <archetype>

          <groupId>org.mobicents.tools.maven.archetype.slee</groupId>

          <artifactId>jain-slee-11-library</artifactId>

          <version>1.0.0.BETA2-SNAPSHOT</version>

          <description>Mobicents :: Tools :: SLEE :: Maven2 Archetypes :: jain-slee-11-library</description>

        </archetype>

        <archetype>

          <groupId>org.mobicents.tools.maven.archetype.slee</groupId>

          <artifactId>jain-slee-11-profile</artifactId>

          <version>1.0.0.BETA2-SNAPSHOT</version>

          <description>Mobicents :: Tools :: SLEE :: Maven2 Archetypes :: jain-slee-11-profile</description>

        </archetype>

        <archetype>

          <groupId>org.mobicents.tools.maven.archetype.slee</groupId>

          <artifactId>jain-slee-11-ra</artifactId>

          <version>1.0.0.BETA2-SNAPSHOT</version>

          <description>Mobicents :: Tools :: SLEE :: Maven2 Archetypes :: jain-slee-11-ra</description>

        </archetype>

        <archetype>

          <groupId>org.mobicents.tools.maven.archetype.slee</groupId>

          <artifactId>jain-slee-11-service</artifactId>

          <version>1.0.0.BETA2-SNAPSHOT</version>

          <description>Mobicents :: Tools :: SLEE :: Maven2 Archetypes :: jain-slee-11-service</description>

        </archetype>

      </archetypes>

    </archetype-catalog>

     

    {code}

     

     

    Second way to setup catalog is to simply create archetype-catalog.xml file. This file is located in ~.m2 catalog and is regular xml file. Since its created by hand, there are no archetype jars present in local repository. Thus catalog definition must point to download location. To do that, <archetype> entry must contain repository definition. Example archetype definition looks as follows:

     

     

    {code:xml}

    <archetype>

       <groupId>org.mobicents.tools.maven.archetype.slee</groupId>

       <artifactId>jain-slee-11-ra</artifactId>

       <version>1.0.0.BETA2-SNAPSHOT</version>

       <repository>http://repository.jboss.org/nexus/content/groups/public-jboss/</repository>

    </archetype>

    {code}

     

     

     

    Using archetype

    There are two ways to use archetype. First way is by direct pass of archetype metadata(group, version, id) in call to archetype plugin. This requires us to know metadata.

    Second way is to relly on catalog definition. Maven plugin checks catalog definition and proposes set of choices. It looks as follows:

     

     

    {code}

    $ mvn archetype:generate -DarchetypeCatalog=local

    [INFO] Scanning for projects...

    [INFO] Reactor build order:

    [INFO]   Unnamed - org.mobicents.tools.maven.archetype.slee:maven-archetypes:pom:1.0.0.BETA2-SNAPSHOT

    [INFO]   Mobicents :: Tools :: SLEE :: Maven2 Archetypes :: jain-slee-basic-service

    [INFO]   Mobicents :: Tools :: SLEE :: Maven2 Archetypes :: jain-slee-basic-ra

    [INFO]   Mobicents :: Tools :: SLEE :: Maven2 Archetypes :: jain-slee-11-library

    [INFO]   Mobicents :: Tools :: SLEE :: Maven2 Archetypes :: jain-slee-11-profile

    [INFO]   Mobicents :: Tools :: SLEE :: Maven2 Archetypes :: jain-slee-11-ra

    [INFO]   Mobicents :: Tools :: SLEE :: Maven2 Archetypes :: jain-slee-11-service

    [INFO] ------------------------------------------------------------------------

    [INFO] Building Unnamed - org.mobicents.tools.maven.archetype.slee:maven-archetypes:pom:1.0.0.BETA2-SNAPSHOT

    [INFO]    task-segment: [archetype:generate] (aggregator-style)

    [INFO] ------------------------------------------------------------------------

    [INFO] Preparing archetype:generate

    [INFO] No goals needed for project - skipping

    [INFO] Setting property: classpath.resource.loader.class => 'org.codehaus.plexus.velocity.ContextClassLoaderResourceLoader'.

    [INFO] Setting property: velocimacro.messages.on => 'false'.

    [INFO] Setting property: resource.loader => 'classpath'.

    [INFO] Setting property: resource.manager.logwhenfound => 'false'.

    [INFO] [archetype:generate {execution: default-cli}]

    [INFO] Generating project in Interactive mode

    [INFO] No archetype defined. Using maven-archetype-quickstart (org.apache.maven.archetypes:maven-archetype-quickstart:1.0)

    Choose archetype:

    1: local -> jain-slee-basic-service (Mobicents :: Tools :: SLEE :: Maven2 Archetypes :: jain-slee-basic-service)

    2: local -> jain-slee-basic-ra (Mobicents :: Tools :: SLEE :: Maven2 Archetypes :: jain-slee-basic-ra)

    3: local -> jain-slee-11-library (Mobicents :: Tools :: SLEE :: Maven2 Archetypes :: jain-slee-11-library)

    4: local -> jain-slee-11-profile (Mobicents :: Tools :: SLEE :: Maven2 Archetypes :: jain-slee-11-profile)

    5: local -> jain-slee-11-ra (Mobicents :: Tools :: SLEE :: Maven2 Archetypes :: jain-slee-11-ra)

    6: local -> jain-slee-11-service (Mobicents :: Tools :: SLEE :: Maven2 Archetypes :: jain-slee-11-service)

    Choose a number:  (1/2/3/4/5/6):

    {code}

     

    Regardles of way of using archetype you need to specify some metadata for generated module this includes:

    • group Id
    • version
    • artifact Id

     

    Above data will be used as metadata of newly generated module. Generated module will be stored in ./${artifactId}.

    Dialog in which you can specify above data looks as follows:

     

    {code}

    Choose archetype:

    1: local -> jain-slee-basic-service (Mobicents :: Tools :: SLEE :: Maven2 Archetypes :: jain-slee-basic-service)

    2: local -> jain-slee-basic-ra (Mobicents :: Tools :: SLEE :: Maven2 Archetypes :: jain-slee-basic-ra)

    3: local -> jain-slee-11-library (Mobicents :: Tools :: SLEE :: Maven2 Archetypes :: jain-slee-11-library)

    4: local -> jain-slee-11-profile (Mobicents :: Tools :: SLEE :: Maven2 Archetypes :: jain-slee-11-profile)

    5: local -> jain-slee-11-ra (Mobicents :: Tools :: SLEE :: Maven2 Archetypes :: jain-slee-11-ra)

    6: local -> jain-slee-11-service (Mobicents :: Tools :: SLEE :: Maven2 Archetypes :: jain-slee-11-service)

    Choose a number: : 4

    Define value for property 'groupId': : com.example.group

    Define value for property 'artifactId': : slee-11-profile

    Define value for property 'version': 1.0-SNAPSHOT:

    Define value for property 'package': com.example.group:

    [INFO] Using property: mobicentsDUPluginVersion = 2.0.0.BETA4

    [INFO] Using property: mobicentsEclipsePluginVersion = 1.0.0.BETA2

    [INFO] Using property: mobicentsLibraryPluginVersion = 1.0.0.BETA2

    [INFO] Using property: mobicentsParentVersion = 2.16

    Confirm properties configuration:

    groupId: com.example.group

    artifactId: slee-11-profile

    version: 1.0-SNAPSHOT

    package: com.example.group

    mobicentsDUPluginVersion: 2.0.0.BETA4

    mobicentsEclipsePluginVersion: 1.0.0.BETA2

    mobicentsLibraryPluginVersion: 1.0.0.BETA2

    mobicentsParentVersion: 2.16

    Y:

    {code}

     

    As you can see there are some predefined values for some dependencies, ie. eclipse plugin version. To alter those you can do following:

    • answer no (press n+Enter) to above question
    • specify value with -D parameter upon call to mvn, ie.

      {code}$ mvn archetype:generate -DarchetypeCatalog=local -o -DmobicentsDUPluginVersion=1.0.0 {code}

     

    Upon accepting above dialog, maven will generate desired module.

     

    Module as project in Eclipse

    Generated modules contain eclipse plugin definition. Thus it is possible to make maven create valid eclipse project and import it into IDE.

    To generate project files simply invoke mvn mobicents:eclipse in top directory of generated module. After successful execution simply perform import from eclipse. It should import project with all required dependencies.

     

    To work in eclipse and project generated by above command, you need one change in eclipse configuration. You have to add classpath variable pointing to .m2 repository - M2_REPO. To do that navigate to Preferences -> Java -> Build Path -> Classpath Variables. Below is example of such  variables defined, current M2_REPO points to windows like path to repository.

     

    note: F_M2_REPO contians path to linux like .m2, on linux like OS its value should be present in M2_REPO

    M2_REPO.png

    Archetype module vs EclipseSLEE

     

    Modules generated from archetypes have nothing in common with EclipseSLEE. Generated modules contain only poms, slee descriptors and some example source files. It provides template which needs to be edited by user. How it is done, is up to user.

     

    EclipseSLEE allows user to modify descriptors and source files with GUI dialogs. User can either create whole project from scratch or use maven arechetype template. For more information on EclipseSLEE please refer to articles about it.