Skip to content

Open Source Non Modeled REST and JAX RS

an481n edited this page Dec 12, 2016 · 1 revision

Open Source Non Modeled REST and JAX-RS

Overview

This webpage will explain how to create an "UnModelled" Service (JAX-RS) running within the AJSC OpenSource. A developer will be able to create the initial service project from the Apache Maven based ajsc-archetype. You will then be able to run and test the service locally within your IDE. After running local testing. This simple example can be used and built upon for any other service you would like to deploy to the SOA cloud running on the AJSC.
Current Version of ajsc-archetype

The current version(s) of the archetype can be found through public maven central.

Please refer below link for the latest release.

Releases and Announcements Current Version of ajsc-archetype

com.att.ajsc ajsc-archetype 2.0.0

JAX-RS Service Creation Add the ajsc-archetype

This can be done simply through Eclipse. Open your Eclipse IDE, and select File, New, Other, Maven Project, New Maven Project. Use the default properties (have only "Use default workspace location" checked). Select Next. Here you will be prompted for a Maven Archetype selection. If this is your first time using the ajsc-archetype (or, if you are using a different version of the archetype), you will need to "Add Archetype". If you have already added the archetype you will be using, you can simply select it from this menu. If you are adding it, select "Add Archetype", and fill in the proper values for Archetype Group Id: "com.att.ajsc", Archetype Artifact Id: "ajsc-archetype", Archetype Version: (Look to the top of this wiki for the current version(s) of the ajsc)uncheck the "show the latest version of archetype only" option to see all versions of the ajsc-archetype.

Select "OK". This may take a little time to download. IMPORTANT STEP: You will be filling in the information for creating your project. Here, you need to define the parameters for your project. You can use whatever values you want for your Group Id, Artifact Id, Version, and Package. OwnerManagementGroupt,If you have no idea what an "OwnerManagementGroup" default value, "com.att.csid.lab". Note here that we are passing "0" values for the port and ssl port. This will allow for ephemeral port selection when running the service.

Default Project Setup

You can setup your Eclipse environment to accept *.route file associations with Content-Type (XML) , and use the XML editor with all of your .route files. Go to Eclipse, Preferences, General, Content Types, and click on XML for Content Type, and Add... *.route, Click "OK". Next, click on "File Associations' and Add... *.route to File Types, and make sure the XML Editor is selected as the Default.

Here is the basic layout of the project, and the basic layout of an ajsc deployment package structure. Here, you can see 4 important files:

  1. JaxrsEchoService.java - Here, you are defining your jaxrs service. In this templated example, we have created an Echo Service utilizing jaxrs to simply echo a value returning "Hello, " + input + "." where the input will be the echo parameter of the jaxrs servlet.

  2. jaxrsBeans.groovy - This is where you define your beans to be accessed by your routes in Nimbus. Here, the xmlns namespaces are added for jaxrs implementation. And, you see your JaxrsEchoService bean defined as well.

  3. jaxrsExample.route - Here is the route created to access your JaxrsEchoService bean.

  4. pom.xml - Since, this project is being built by Maven, your pom.xml controls your project's build structure and dependencies, and in this case allows for proper packaging and local deployment testing as well as swm registration/deployment.

Below, you can see how defining your namespace and namespaceVersion within your pom.xml will be replaced AUTOMAGICALLY in your route through the property Placeholders. In the next step, where you will run a Maven build on the project, module_ajsc_namespace_name and module_ajsc_namespace_version will be replaced by the values in your pom.xml for module.ajsc.namespace.name and module.ajsc.namespace.version. This will allow you to copy and paste more frequently allowing your actual namespace and version to be pulled into the route definitions through your pom.xml. Of course, you can simply input values for namespace and version where appropriate and not use the property placeholders.

Note: If you are not able to find jaxrsBeans.groovy and jaxrsExample.route files at the location specified below in the screenshot, do a file search on the project workspace (on eclipse, Ctl + Shift + R) and type in those file names to open and locate the files in the GUI.

##Run Locally - mvn -P runAjsc (preferred)

With more current versions of AJSC, we have created 2 different maven profiles used to run locally. The initial profile, "runLocal" was using the antrun maven plugin to fork a java process. This can cause termination issues within a Windows/Eclipse environment. We have since created the "runAjsc" profile which utilizes the maven exec plugin. This profile is now the preferred method for running the AJSC locally. This java process will terminate appropriately within all known environments. You can view this profile within the pom.xml of your project, and verify/modify any system properties or other items allowed for by this plugin to use when running the AJSC.

Clone this wiki locally