Gld Extension Development: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
 
(66 intermediate revisions by the same user not shown)
Line 5: Line 5:
=Overview=
=Overview=


Extensions are developed independently of the core, which include API and the load driver. Once a new core version has been released, the extensions that wish to use it should update their <tt><gld.api.version>...</gld.api.version></tt> in the topmost POM.
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  


To get to the work area of an extension (jboss-datagrid-7 in this case):
<gld.api.version>...</gld.api.version>


<pre>
in the topmost POM of the extension.
cdgldjdg7
 
</pre>
To get to the work area of an extension:


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


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|The Release Process]] below.
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|The Release Process]] below.
=Maven Coordinates=
Group ID:
io.novaordis.gld.extensions.''[[Gld_Concepts#Extension_Name|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=
=Extension Name=


The extension name, as described in the [[Gld_Concepts#Extension_Name|gld Concepts - Extension Name]] section, must be specified as the "extension.name" property in the extension project POM:
The extension name should follow guidelines described in:
 
{{Internal|gld_Concepts#Extension_Name|gld Concepts - Extension Name}}
 
Once established, the extension name must be specified as the "extension.name" property in the extension project topmost POM:


<pre>
<syntaxhighlight lang='xml'>
<project ...>
<project ...>
     ...
     ...
     <properties>
     <properties>


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


Line 35: Line 62:
   ...
   ...
</project>
</project>
</pre>
</syntaxhighlight>
 
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=


The POM "extension.name" property is the authoritative source of information for extension name, and it will be inferred from it everywhere extension name is necessary. For consistency, it is recommended that the extension top-level directory of the extension project has the same name as "extension.name".
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").


=New Extension=
To get the version information, call


* Create the project root directory under git@github.com:NovaOrdis/gld/extensions.
<syntaxhighlight lang='java'>
* The directory name should follow the guidelines exposed [[#Extension_Name|here]].
VersionUtilities.getVersion(<extension-specific-resource-file-name>)
* Start from the following [[gld Extension pom.xml Sample|pom.xml]].
</syntaxhighlight>
* Update the following:
 
** The <name>.
instead.
** groupId/artifactId/version.
 
** 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.
=New Extension Procedure=
** Various dependency versions.
 
** Repositories, if specific repositories are necessary.
==New Extension Infrastructure==
 
<span id='New_Extension'></span>
* Create the project root directory under $GLD_PROJECT_HOME/extensions.
* 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]] or from the closest working extension POM and update the following:
** <name>
** <tt>groupId</tt>/<tt>artifactId</tt>/<tt>version</tt> according to the details presented in section "[[#Maven_Coordinates|Maven Coordinates]]".
** 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.
** 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.
* 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 [[gld Extension Release Module release.xml|here]].
** 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:
* Code:
*** "GLD Extension for JBoss Data Grid 7"
** io.novaordis.gld.extensions.jboss.datagrid.JBossDatagrid6Service extends CacheServiceBase.
*** "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]]
* Extension version reporting: the Service implementation must override <tt>getVesion()</tt> as follows:
 
==New Extension Code==
 
Service code examples:
 
* [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:


<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 85: 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 92: Line 150:


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


     assertNotNull(version);
     assertNotNull(version);
Line 101: 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 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 (<tt>extensionNameToExtensionServiceFullyQualifiedClassName()</tt> method):


"maven.injected.project.version" should be injected by Maven, if we used the correct pom.xml template.
{{External|https://github.com/NovaOrdis/gld/blob/master/core/api/src/main/java/io/novaordis/gld/api/service/ServiceFactory.java}}


=The Release Process=
=The Release Process=
Line 116: Line 186:


[[#Nort|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".
[[#Nort|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=
* [[Gld JDG 6 Run|JBoss Data Grid 6 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 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