Shell-call

From GreenVulcano Wiki
Revision as of 11:08, 20 January 2012 by Anonymous (talk) ({{VULCON}} / {{GVCONSOLE}} Configuration)
Jump to: navigation, search

Definition

Many IT applications, within their business process, need to invoke shell command. Gvvcl-shell plug-in can be used to invoke command shell. It is very simple to configure.

GreenVulcano® ESB provides two different tools, GV Console® and VulCon®, to configure all supported plug-ins in GV services.

VulCon / GV Console Configuration

shell-call is the operation that must be configured into VulCon® or GV Console® System section, to invoke command shell In order to add an operation shell-call you must define the following fields:

  • class,it.greenvulcano.gvesb.virtual.shell.ShellCallOperation (java class that manage shell-call invocation).
  • name,this field identify the operation name that you will use in service definition.
  • directory,Pathname of the directory in which the command is executed.This pathname can be static or may contain placeholders that are replaced at runtime.Can contains the following placeholders:
    • fixed : a text string;
    • ${{propname}} =a System property name
    • timestamp{{{pattern}}} : return the current timestamp formatted as 'pattern'
    • dateformat{{date::source-pattern::dest-pattern}} : reformat 'date' from 'source-pattern' to 'dest-pattern'
    • decode{{field[::cond1::val1][::cond2::val2][cond...n::val...n]::default}} : evaluate as if-then-else; if 'field' is equal to cond1...n, return the value of val1...n, otherwise 'default'
    • decodeL{{sep::field[::cond1::val1][::cond2::val2][cond...n::val...n]::default}} : is equivalent to 'decode', with the difference that 'condX' can be a list of values separated by 'sep'
    • js{{scope::script}} : evaluate a JavaScript script, using the scope 'scope', the GVBuffer is added to the scope as 'object'
    • sql{{conn::statement}} : execute a select sql statement sql and return the value of the first field of the first selected record. The 'conn' parameter is the JNDI name of a DataSource
    • sqllist{{conn::statement}}: execute a select sql statement sql and return the value of the first field of all selected records as a comma separated list. The 'conn' parameter is the JNDI name of a DataSource
    • sqltable{{conn::statement}}: executes a select sql statement and returns all values of returned cursor as an XML.The 'conn' parameter is the JNDI name of a DataSource
    • ognl{{script}} : evaluate a OGNL script,the GVBuffer is added to the context as 'object' (and is also the object on which execute the script)If this attribute is not present, the command is executed within the current working directory.
  • encoding: The encoding with which encode the output of the command in the body of GVBuffer.If not specified, is used the the 'file.encoding' system property value.


The following example shows the configuration generated from VulCon® or GV Console® when you configure a shell-call operation:

<?xml version="1.0" encoding="UTF-8"?>
<Channel id-channel="CHANNEL-NAME">
    <shell-call class="it.greenvulcano.gvesb.virtual.shell.ShellCallOperation"
      directory="/home/greenvulcano/script" name="less_file"
      type="call">
     <cmd>less greenvulcano.log</cmd>
    </shell-call>
</Channel>


To use an excelreader-call in a GreenVulcano® ESB service, you need to define a node of type GVOperationNode in Service section and define in the field operation-name the name defined in excelreader-call operation.

The following example shows the configuration generated from VulCon® or GV Console® when you configure an shell-call operation in GreenVulcano® ESB service:

<?xml version="1.0" encoding="UTF-8"?>
<GVServices name="SERVICES" type="module">
    <Groups>
        <Group group-activation="on" id-group="DEFAULT_GRP"/>
    </Groups>
    <Services>
        <Service group-name="DEFAULT_GRP" id-service="SERVICE-NAME"
                 service-activation="on">
            <Client id-system="SYSTEM-NAME" statistics="off" system-activation="on">
                <Operation name="RequestReply" operation-activation="on"
                           out-check-type="none" type="operation">
                    <Participant id-channel="CHANNEL-NAME" id-system="SYSTEM-NAME"/>
                    <Flow first-node="less_log_file" point-x="20" point-y="112">
                        <GVOperationNode class="it.greenvulcano.gvesb.core.flow.GVOperationNode"
                                         id="shell-call" id-system="YOUR_SYSTEM"
                                         input="input" next-node-id="end"
                                         op-type="call"
                                         operation-name="less_file"
                                         output="output" point-x="158"
                                         point-y="112" type="flow-node"/>
                        <GVEndNode class="it.greenvulcano.gvesb.core.flow.GVEndNode"
                                   end-business-process="yes" id="end" op-type="end"
                                   output="output" point-x="358" point-y="112"
                                   type="flow-node"/>
                    </Flow>
                </Operation>
            </Client>    
        </Service>
    </Services>
</GVServices>


At this point you have configured a service with a shell-call operation.

--A.sicignano 16:30, 19 January 2012 (CET)