Coder Social home page Coder Social logo

spring-resteasy's Introduction

XProgram webservice quick setup

1. Install Wildfly (JBoss)

Use following instruction to install and configure Wildfly (JBoss) 17.0.1.Final on Ubuntu 18.04 LTS: https://vitux.com/install-and-configure-wildfly-jboss-on-ubuntu/

2. Deploy spring-resteasy.war to the server

Following instructions contains information how to deploy spring-resteasy.war application on WildFly using the Web Console or the CLI: http://www.mastertheboss.com/jboss-server/jboss-deploy/deploying-applications-on-wildfly-using-the-web-console-and-the-cli

3. Configure program to execute

Copy holidays.cbl and xholidays.cbl into /vagrant/cobol/webservices/xholidays folder on the server and compile them with using following script:

#/bin/bash
echo 'starting shellscript'
echo 'set -e'
set -e
echo 'run cit setup script'
export DEFAULT_CITDIR=/opt/cobol-it4-64
export COBOLITDIR=$DEFAULT_CITDIR
export PATH=$COBOLITDIR/bin:${PATH}
export LD_LIBRARY_PATH="$COBOLITDIR/lib:${LD_LIBRARY_PATH:=}"
export DYLD_LIBRARY_PATH="$COBOLITDIR/lib:${DYLD_LIBRARY_PATH:=}"
export SHLIB_PATH="$COBOLITDIR/lib:${SHLIB_PATH:=}"
export LIBPATH="$COBOLITDIR/lib:${LIBPATH:=}"
export COB="COBOL-IT"
echo COBOL-IT Environement set to $COBOLITDIR
echo 'building service ...'
cobc -err errfile -g -ftraceall -x xholidays.cbl holidays.cbl 
echo 'all done'

In the /vagrant/cobol/webservices/xholidays folder create run.sh script with following content:

#!/bin/bash
export COBOLIT_LICENSE=/opt/cobol-it4-64/citlicense.xml
COBOLITDIR=/opt/cobol-it4-64
PATH=$COBOLITDIR/bin:${PATH}
LD_LIBRARY_PATH="$COBOLITDIR/lib:${LD_LIBRARY_PATH:=}"
DYLD_LIBRARY_PATH="$COBOLITDIR/lib:${DYLD_LIBRARY_PATH:=}"
SHLIB_PATH="$COBOLITDIR/lib:${SHLIB_PATH:=}"
LIBPATH="$COBOLITDIR/lib:${LIBPATH:=}"
COB="COBOL-IT"
COB_ERROR_FILE=/tmp/coberrplus
export COB_FILE_PATH=/tmp
export COB COBOLITDIR LD_LIBRARY_PATH PATH DYLD_LIBRARY_PATH SHLIB_PATH LIBPATH COB_ERROR_FILE
./xholidays

4. Make POST requests

Use cURL to make a POST request to http://localhost:8080/spring-resteasy/xprogram:

curl -X POST -H "Content-Type: text/plain" -d @getstring http://localhost:8080/spring-resteasy/xprogram

Implementation details

All source code located in the src/ folder.

Following quickstart example is used as an initial project: https://github.com/wildfly/quickstart/tree/17.0.1.Final/spring-resteasy

There are 3 key files:

  • XProgramBean executes configured command line program in the specified working directory and returns program execution output.
  • XProgramSpringResource process POST requests to the XProgram bean:
@Autowired
XProgramBean xProgramBean;

@POST
@Path("xprogram")
@Consumes("text/plain")
@Produces("text/plain")
public Response postXProgram(String body) {
    String result = xProgramBean.process(body);
    return Response.ok(result).build();
}

@POST
@Path("/xprogram-form")
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public Response postXProgramForm(@FormParam("msg") String msg) {
    String result = xProgramBean.process(msg);
    return Response.ok(result).build();
}
<!-- XProgram bean -->
<bean id="xProgramBean" class="org.jboss.as.quickstarts.resteasyspring.XProgramBean">
    <!-- Program execution working directory -->
    <constructor-arg index="0" type="java.lang.String" value="/vagrant/cobol/webservices/xholidays" />
    <!-- Program to execute -->
    <constructor-arg index="1" type="java.lang.String" value="/vagrant/cobol/webservices/xholidays/run.sh" />
</bean>

<!-- JAX-RS XProgram resource -->
<bean id="xProgramSpringResource" class="org.jboss.as.quickstarts.resteasyspring.XProgramSpringResource" />

How to build?

Apache Maven is required to build the project with using following command:

mvn clean package

Result spring-resteasy.war web application will be available in target folder.

spring-resteasy's People

Contributors

asalnik avatar ystrot avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

Forkers

isabella232

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.