Gld Extension Development: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(30 intermediate revisions by the same user not shown)
Line 66: Line 66:
The POM "extension.name" property is the authoritative source of information for extension name. The system property will be used everywhere the extension name is required.  
The POM "extension.name" property is the authoritative source of information for extension name. The system property will be used everywhere the extension name is required.  


For consistency, it is recommended that the extension top-level directory of the extension project has the same name as "extension.name".
=Extension Project Home Directory=
 
For consistency, it is recommended that the extension home directory - the top-level directory of the extension project - has the same name as "extension.name" system property value.


=Extension Version=
=Extension Version=


Use a variant of the procedure described here [[Nova Ordis Utilities Version Metadata Handling]], with the difference that the resource file has an extension-specific name (example: "jboss-datagrid-7-extension-version") and call VersionUtilities.getVersion(<extension-specific-resource-file-name>) instead.
Use a variant of the procedure described here:
 
{{Internal|Nova Ordis Utilities Version Metadata Handling|Nova Ordis Utilities Version Metadata Handling}}
 
The difference is that the resource file has an extension-specific name (example: "jboss-datagrid-7-extension-version").
 
To get the version information, call  
 
<syntaxhighlight lang='java'>
VersionUtilities.getVersion(<extension-specific-resource-file-name>)
</syntaxhighlight>
 
instead.
 
=New Extension Procedure=


=New Extension=
==New Extension Infrastructure==


<span id='New_Extension'></span>
* Create the project root directory under $GLD_PROJECT_HOME/extensions.
* Create the project root directory under $GLD_PROJECT_HOME/extensions.
* The directory name should follow the guidelines exposed [[#Extension_Name|here]].
* The directory name should follow the guidelines provided in the "[[#Extension_Project_Home_Directory|Extension Project Home Directory]]" section, above.
* Start from the following [[gld Extension pom.xml Sample|pom.xml]].
* Start from the following [[gld Extension pom.xml Sample|pom.xml]] or from the closest working extension POM and update the following:
* Update the following:
** <name>
** The <name>.
** <tt>groupId</tt>/<tt>artifactId</tt>/<tt>version</tt> according to the details presented in section "[[#Maven_Coordinates|Maven Coordinates]]".
** groupId/artifactId/version.
** The "extension.name" property, It should follow the guidelines exposed  in the "[[#Extension_Name|Extension Name]]" section. Ideally, it should be identical with the name of the project root directory.
** The "extension.name" property, It should follow the guidelines exposed  [[#Extension_Name|here]] and ideally should be identical with the name of the project root directory.
** Various dependency versions, including the "common" module, shared by the extensions corresponding to different versions of the target service. jboss-datagrid-* use a common module. For the extensions that do not need a "common" module and rely directly on the GLD API, declared a direct dependency on GLD API. jboss-eap-*-jms do not use a common module.
** Various dependency versions, including the "common" module, shared by the extensions corresponding to different versions of the target service. jboss-datagrid-* use a common module. For the extensions that do not need a "common" module and rely directly on the GLD API, declared a direct dependency on GLD API. jboss-eap-*-jms do not use a common module.
** Repositories, if specific repositories are necessary.
* Create the 'main' and 'release' directories.
* Create the 'main' and 'release' directories.
* Initialize the 'main' module.
* Initialize the 'main' module.
** Use this [[gld Extension Main Module pom.xml|pom.xml]] sample as template.
** Use this [[gld Extension Main Module pom.xml|pom.xml]] sample as template, or the closest working extension main module POM.
** Create the source root (src/main/java/io/novaordis/gld/extensions/jboss/datagrid). It is important that "io.novaordis.gld.extensions." prefixes the package name.
** Create the source and the test root. It is important that "io.novaordis.gld.extensions." prefixes the package name:
** Create the test root (src/test/java/io/novaordis/gld/extensions/jboss/datagrid)
 
cd main
mkdir -p src/main/java/io/novaordis/gld/extensions/jboss/eap/jms
mkdir -p src/test/java/io/novaordis/gld/extensions/jboss/eap/jms
 
* Initialize the 'release' module.
* Initialize the 'release' module.
** Use this [[gld Extension Release Module pom.xml|pom.xml]] sample as template.
** Use this [[gld Extension Release Module pom.xml|pom.xml]] sample as template, or the closest working extension release module POM.
** Initialize src/assembly/release.xml using the sample available here: [[gld Extension Release Module release.xml|release.xml]].
** Initialize src/assembly/release.xml using the sample available here: [[gld Extension Release Module release.xml|release.xml]].
* Convenience aliases (cdgldjdg7)
* Convenience aliases (cdgldjdg7)
* Create the IntelliJ IDEA project:
* Create the IntelliJ IDEA project:
** The root of the project should be the project directory name. There will be an independent IntelliJ IDEA project per extension.
** The root of the project should be the project directory name. There will be an independent IntelliJ IDEA project per extension.
** Project Name: "GLD Extension for JBoss Data Grid 7"
** Project Names:
*** "GLD Extension for JBoss Data Grid 7"
*** "GLD Extension for JBoss EAP 7 JMS"
*** "GLD Extension for JBoss EAP 6 JMS"
 
* Release infrastructure:
* Release infrastructure:
** <span id="version_metadata_file"></span>version metadata file: main/src/main/resources/jboss-datagrid-7-extension-version, with the following content: <tt>version=${project.version}</tt>.
** <span id="version_metadata_file"></span>version metadata file: main/src/main/resources/jboss-datagrid-7-extension-version, with the following content: <tt>version=${project.version}</tt>
** release/src/main/bash/.install. Template available here: [[gld Extension .install Script|.install]].
** release/src/main/bash/.install. Template available here: [[gld Extension .install Script|.install]]
** [[gld Extension project.yml|.nort/project.yml]].
** [[gld Extension project.yml|.nort/project.yml]]


Code:
==New Extension Code==


* io.novaordis.gld.extensions.jboss.datagrid.JBossDatagrid7Service extends JBossDatagridServiceBase.
Service code examples:


{{External|https://github.com/NovaOrdis/gld/blob/master/extensions/jboss-datagrid-7/main/src/main/java/io/novaordis/gld/extensions/jboss/datagrid/JBossDatagrid7Service.java}}
* [https://github.com/NovaOrdis/gld/blob/master/extensions/jboss-datagrid-7/main/src/main/java/io/novaordis/gld/extensions/jboss/datagrid/JBossDatagrid7Service.java io.novaordis.gld.extensions.jboss.datagrid.JBossDatagrid7Service] extends JBossDatagridServiceBase.
* [https://github.com/NovaOrdis/gld/blob/master/extensions/jboss-eap-7-jms/main/src/main/java/io/novaordis/gld/extensions/jboss/eap/jms/JBossEap7JmsService.java io.novaordis.gld.extensions.jboss.eap.jms. JBossEap7JmsService] extends JmsServiceBase.


* Extension version reporting: the Service implementation must override <tt>getVesion()</tt> as follows:
Extension version reporting: the Service implementation must override <tt>getVesion()</tt> as follows:


<pre>
<syntaxhighlight lang='java'>
@Override
@Override
public String getVersion() {
public String getVersion() {
       return VersionUtilities.getVersion(EXTENSION_VERSION_METADATA_FILE_NAME);
       return VersionUtilities.getVersion(EXTENSION_VERSION_METADATA_FILE_NAME);
}
}
</pre>
</syntaxhighlight>


where EXTENSION_VERSION_METADATA_FILE_NAME contains the name of the [[#version_metadata_file|version metadata file]] mentioned above.
where EXTENSION_VERSION_METADATA_FILE_NAME contains the name of the [[#version_metadata_file|version metadata file]] mentioned above.
Line 119: Line 143:
Also the service test class should contain the following:
Also the service test class should contain the following:


<pre>
<syntaxhighlight lang='java'>
@Test
@Test
public void version() throws Exception {
public void version() throws Exception {
Line 126: Line 150:


     String version = s.getVersion();
     String version = s.getVersion();
    log.info(version);


     assertNotNull(version);
     assertNotNull(version);
Line 135: Line 157:
     assertEquals(mavenInjectedProjectVersion, version);
     assertEquals(mavenInjectedProjectVersion, version);
}
}
</pre>
</syntaxhighlight>


"maven.injected.project.version" should be injected by Maven, if we used the correct pom.xml template.
"maven.injected.project.version" should be injected by Maven, if we used the correct pom.xml top-level project template. The system property is set by the maven-surefire-plugin task.


Configuration:
==Configuration==


* A reference configuration should be available as main/src/test/resources/data/reference-gld-jboss-datagrid-7.yml
A reference configuration should be available as main/src/test/resources/data/reference-jboss-datagrid-7.yml


=Service Implementation Class Naming Conventions=
=Service Implementation Class Naming Conventions=
Line 170: Line 192:
* [[Gld JDG 7 Run|JBoss Data Grid 7 Extension Smoke Test]]
* [[Gld JDG 7 Run|JBoss Data Grid 7 Extension Smoke Test]]
* [[gld EAP 7 JMS Run|EAP 7 JMS Extension Smoke Test]]
* [[gld EAP 7 JMS Run|EAP 7 JMS Extension Smoke Test]]
* [[gld EAP 6 JMS Run|EAP 6 JMS Extension Smoke Test]]

Latest revision as of 00:16, 6 September 2017

Internal

Overview

Extensions are developed independently of the core, which includes the GLD API, shipped as gld-api-*.jar and the load driver, shipped as gld-load-driver-*.jar. Once a new core version has been released, the extensions that wish to use it should update their

<gld.api.version>...</gld.api.version> 

in the topmost POM of the extension.

To get to the work area of an extension:

cd projects/gld/extensions/<extension-name>
release snapshot

The above will build the extension and install it in $RUNTIME_DIR/gld/extensions. For more details about the release process, see The Release Process below.

Maven Coordinates

Group ID:

io.novaordis.gld.extensions.simplified-extension-name

Example:

io.novaordis.gld.extensions.jboss-datagrid

There is no target product version information in the Group ID, the version information goes into the artifact ID, if necessary.

Artifact IDs examples:

JBoss Data Grid:

  • jboss-datagrid-common
  • jboss-datagrid-6
  • jboss-datagrid-7

JBoss JMS Providers (the common JMS library's place is taken by the JMS API):

  • jboss-eap-7-jms

Extension Name

The extension name should follow guidelines described in:

gld Concepts - Extension Name

Once established, the extension name must be specified as the "extension.name" property in the extension project topmost POM:

<project ...>
    ...
    <properties>

        <!--
            The official extension name
        -->
        <extension.name>jboss-datagrid-7</extension.name>

        ...
    </properties>
   ...
</project>

The POM "extension.name" property is the authoritative source of information for extension name. The system property will be used everywhere the extension name is required.

Extension Project Home Directory

For consistency, it is recommended that the extension home directory - the top-level directory of the extension project - has the same name as "extension.name" system property value.

Extension Version

Use a variant of the procedure described here:

Nova Ordis Utilities Version Metadata Handling

The difference is that the resource file has an extension-specific name (example: "jboss-datagrid-7-extension-version").

To get the version information, call

VersionUtilities.getVersion(<extension-specific-resource-file-name>)

instead.

New Extension Procedure

New Extension Infrastructure

  • Create the project root directory under $GLD_PROJECT_HOME/extensions.
  • The directory name should follow the guidelines provided in the "Extension Project Home Directory" section, above.
  • Start from the following pom.xml or from the closest working extension POM and update the following:
    • <name>
    • groupId/artifactId/version according to the details presented in section "Maven Coordinates".
    • The "extension.name" property, It should follow the guidelines exposed in the "Extension Name" section. Ideally, it should be identical with the name of the project root directory.
    • Various dependency versions, including the "common" module, shared by the extensions corresponding to different versions of the target service. jboss-datagrid-* use a common module. For the extensions that do not need a "common" module and rely directly on the GLD API, declared a direct dependency on GLD API. jboss-eap-*-jms do not use a common module.
  • Create the 'main' and 'release' directories.
  • Initialize the 'main' module.
    • Use this pom.xml sample as template, or the closest working extension main module POM.
    • Create the source and the test root. It is important that "io.novaordis.gld.extensions." prefixes the package name:
cd main
mkdir -p src/main/java/io/novaordis/gld/extensions/jboss/eap/jms
mkdir -p src/test/java/io/novaordis/gld/extensions/jboss/eap/jms
  • Initialize the 'release' module.
    • Use this pom.xml sample as template, or the closest working extension release module POM.
    • Initialize src/assembly/release.xml using the sample available here: release.xml.
  • Convenience aliases (cdgldjdg7)
  • Create the IntelliJ IDEA project:
    • The root of the project should be the project directory name. There will be an independent IntelliJ IDEA project per extension.
    • Project Names:
      • "GLD Extension for JBoss Data Grid 7"
      • "GLD Extension for JBoss EAP 7 JMS"
      • "GLD Extension for JBoss EAP 6 JMS"
  • Release infrastructure:
    • version metadata file: main/src/main/resources/jboss-datagrid-7-extension-version, with the following content: version=${project.version}
    • release/src/main/bash/.install. Template available here: .install
    • .nort/project.yml

New Extension Code

Service code examples:

Extension version reporting: the Service implementation must override getVesion() as follows:

@Override
public String getVersion() {
       return VersionUtilities.getVersion(EXTENSION_VERSION_METADATA_FILE_NAME);
}

where EXTENSION_VERSION_METADATA_FILE_NAME contains the name of the version metadata file mentioned above.

Also the service test class should contain the following:

@Test
public void version() throws Exception {

    JBossDatagrid7Service s = new JBossDatagrid7Service();

    String version = s.getVersion();

    assertNotNull(version);

    String mavenInjectedProjectVersion = System.getProperty("maven.injected.project.version");
    assertNotNull(mavenInjectedProjectVersion);
    assertEquals(mavenInjectedProjectVersion, version);
}

"maven.injected.project.version" should be injected by Maven, if we used the correct pom.xml top-level project template. The system property is set by the maven-surefire-plugin task.

Configuration

A reference configuration should be available as main/src/test/resources/data/reference-jboss-datagrid-7.yml

Service Implementation Class Naming Conventions

As per gld 1.0, the Service implementation class must adhere to naming convention described below. In the future, we plan to relax this requirement.

The extension name dictates the Service implementation class name.

If the extension name is "alpha-beta-gamma", where any of the components, except the first one, can be entirely numeric, then the service implementation class name must be: "io.novaordis.gld.extensions.alpha.beta.gamma.AlphaBetaGammaService". The components that are entirely numeric are dropped from the package name. The logic is implemented here (extensionNameToExtensionServiceFullyQualifiedClassName() method):

https://github.com/NovaOrdis/gld/blob/master/core/api/src/main/java/io/novaordis/gld/api/service/ServiceFactory.java

The Release Process

An extension source tree is completely independent of core. The only relationship is the API version specified in the extension's POM file.

The release process should be as simple as:

release snapshot|minor|...

nort will install the extension into the local gld deployment. The location of the installation directory can be configured in <extension-name>/.nort/project.yml, as "install/installation.directory".

Smoke Tests