Enabling Spring With Plugins

21 / May / 2016 by Ankit Arora 1 comments

Writing a code to integrate MQTT functionality in my Spring application development made me think, am I not doing this over and over again. Having been involved in different IoT applications and numerous other domains, MQTT became an essential part of almost all the applications that I prepared.

This is just one example of such a case, where we tend to write or maybe sometimes copy the same code again and again from one application to another. Thinking about how many seconds would have I played TT more, if I would have had something for the rescue.

On the same lines, is the Java Enabler Toolkit, that I thought could be a potential solution in the open source community.

What is the Java Enabler Toolkit??

Coding for hours the same code again, we plugged out the essentials and made them mere configurable stuff for others to use. Java Enabler Toolkit comprises of different components that can be used separately over choice. The entire toolkit is made out of a main Maven Parent, which further contains the different child components. The structure of the toolkit is as follows:

Screen Shot 2016-05-21 at 1.31.23 PM

 

Sample Component – MQTT

Let’s take the example of the pain that I have been going through, MQTT.
The source code for the toolkit is available for use at the following location:
https://github.com/ankitarora12/TTNDJavaToolkit
Download the source code for the project.
The structure of the MQTT component looks as follows:
Screen Shot 2016-05-21 at 1.32.53 PM

To build the entire toolkit run “mvn clean install” on the folder: TTNDJavaToolkit/toolkit-parent/
The jars would be built and be available for use.

To use MQTT jar in your project follow the steps:

  1. Create a directory “repo” under your custom project, where your pom file is located.
  2. Hook onto the folder <customProject>/repo/ (cd <customProject>/repo)
  3. Run the following commands:
    1. mvn install:install-file -Dfile=<baseDir>/TTNDJavaToolKit/toolkit-parent/pom.xml -DgroupId=com.ttnd.toolkit -DartifactId=toolkit-parent -Dversion=0.0.1-SNAPSHOT -Dpackaging=pom -DlocalRepositoryPath=.
    2. mvn install:install-file -Dfile=<baseDir>/TTNDJavaToolkit/toolkit-parent/toolkit-mqtt/target/toolkit-mqtt-0.1-jar-with-dependencies.jar -DgroupId=com.ttnd.toolkit -DartifactId=toolkit-mqtt -Dversion=0.1 -Dpackaging=jar -DlocalRepositoryPath=.
  4. Running the above commands prepares your local repository with the mqtt jar.
  5. Add the following lines to your pom file:
    1. Add the following lines under the <repositories> tag:

      <repository>
      <id>repo</id>
      <url>file://${project.basedir}/repo</url>
      </repository>

    2. Then add the following lines under <dependencies> tag:

      <dependency>
      <groupId>com.ttnd.toolkit</groupId>
      <artifactId>toolkit-mqtt </artifactId>
      <version>0.1</version>
      </dependency>

  6. Doing this adds the jar to your project.

Njoy!!!

FOUND THIS USEFUL? SHARE IT

comments (1 “Enabling Spring With Plugins”)

Leave a Reply

Your email address will not be published. Required fields are marked *