Difference between revisions of "Shell-call"

From GreenVulcano Wiki
Jump to: navigation, search
(Created page with "==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 t...")
 
({{VULCON}} / {{GVCONSOLE}} Configuration)
 
(21 intermediate revisions by 3 users not shown)
Line 1: Line 1:
 
==Definition==
 
==Definition==
Many IT applications, within their business process, need to invoke shell command. ''Gvvcl-shell'' plug-in can be used to invoke command shell.
+
Many IT applications, within their business process, need to invoke shell commands. ''shell-call'' plug-in can be used to invoke a command shell.
 
It is very simple to configure.  
 
It is very simple to configure.  
  
{{GVESB}} provides two different tools, {{L_GVCONSOLE}} and {{L_VULCON}}, to configure all supported plug-ins in GV services.
+
{{GVESB}} provides two different tools, {{L_GVCONSOLE}} and {{L_VULCON}}, to configure all supported plug-ins in {{GVESB}} services.
  
 
=={{VULCON}} / {{GVCONSOLE}} Configuration==
 
=={{VULCON}} / {{GVCONSOLE}} Configuration==
''shell-call'' is the operation that must be configured into {{L_VULCON}} or  {{L_GVCONSOLE}} [[System section]], to invoke command shell
+
''shell-call'' is the operation that must be configured into {{L_VULCON}} or  {{L_GVCONSOLE}} System section to invoke command shell.
 +
 
 
In order to add an operation ''shell-call'' you must define the following fields:
 
In order to add an operation ''shell-call'' you must define the following fields:
 +
{|class="gvtable"
 +
! Attribute !! Type !! Description
 +
|-
 +
| type || fixed || This attribute must assume the value '''call'''.
 +
|-
 +
| class || fixed || This attribute must assume the value '''it.greenvulcano.gvesb.virtual.shell.ShellCallOperation''' (java class that manages the ''shell-call'' invocation).
 +
|-
 +
| name || required || This field identify the operation name that you will use in service definition.
 +
|-
 +
| directory || optional ||Pathname of the directory in which the command is executed. This pathname can be static or may contain [[placeholders]] that are replaced at runtime. If this attribute is not present, the command is executed within the current working directory.
 +
|-
 +
| encoding || optional || The encoding with which encodes the command output in the [[GVBuffer]] body. If not specified, is used the ''file.encoding'' system property value.
 +
|}
  
* ''class'': it.greenvulcano.gvesb.virtual.shell.ShellCallOperation (java class that manage ''shell-call'' invocation).
+
Might contain the following sub-elements:
* ''name'': this field identify the operation name that you will use in service definition.
+
* [[ShellCommands#cmd|cmd]] or [[ShellCommands#cmd-array-elem|cmd-array-elem]]
* ''directory'':  Pathname of the directory in which the command is executed.
+
* [[ShellCommands#env-property|env-property]]
* ''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 {{L_VULCON}} or {{L_GVCONSOLE}} when you configure a ''shell-call'' operation:
 
The following example shows the configuration generated from {{L_VULCON}} or {{L_GVCONSOLE}} when you configure a ''shell-call'' operation:
  
 
<syntaxhighlight lang="XML"><?xml version="1.0" encoding="UTF-8"?>
 
<syntaxhighlight lang="XML"><?xml version="1.0" encoding="UTF-8"?>
                <Channel id-channel="CHANNEL-NAME">
+
<Channel id-channel="CHANNEL-NAME">
                    <shell-call class="it.greenvulcano.gvesb.virtual.shell.ShellCallOperation"
+
    <shell-call class="it.greenvulcano.gvesb.virtual.shell.ShellCallOperation"
                                directory="/home/greenvulcano/script" name="less_file"
+
      directory="/home/greenvulcano/script" name="cat_file"
                                type="call">
+
      type="call">
                        <cmd>less greenvulcano.log</cmd>
+
    <cmd>cat greenvulcano.log</cmd>
                    </shell-call>
+
    </shell-call>
                </Channel>
+
</Channel>
 
</syntaxhighlight>
 
</syntaxhighlight>
  
  
To use an ''excelreader-call'' in a {{GVESB}} 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.
+
To use an ''excelreader-call'' in a {{GVESB}} service, you need to define a node of type [[GVOperationNode]] into the [[Service]] and define in the field ''operation-name'' the name defined in ''excelreader-call'' operation.
  
The following example shows the configuration generated from {{L_VULCON}} or {{L_GVCONSOLE}} when you configure an ''excelreader-call'' operation in {{GVESB}} service:
+
The following example shows the configuration generated from {{L_VULCON}} or {{L_GVCONSOLE}} when you configure an ''shell-call'' operation in {{GVESB}} service:
  
 
<syntaxhighlight lang="XML"><?xml version="1.0" encoding="UTF-8"?>
 
<syntaxhighlight lang="XML"><?xml version="1.0" encoding="UTF-8"?>
Line 44: Line 56:
 
                           out-check-type="none" type="operation">
 
                           out-check-type="none" type="operation">
 
                     <Participant id-channel="CHANNEL-NAME" id-system="SYSTEM-NAME"/>
 
                     <Participant id-channel="CHANNEL-NAME" id-system="SYSTEM-NAME"/>
                     <Flow first-node="excel_reader" point-x="20" point-y="112">
+
                     <Flow first-node="cat_log_file" point-x="20" point-y="112">
 
                         <GVOperationNode class="it.greenvulcano.gvesb.core.flow.GVOperationNode"
 
                         <GVOperationNode class="it.greenvulcano.gvesb.core.flow.GVOperationNode"
                                         id="excel_reader" id-system="DAMA"
+
                                         id="shell-call" id-system="YOUR_SYSTEM"
 
                                         input="input" next-node-id="end"
 
                                         input="input" next-node-id="end"
 
                                         op-type="call"
 
                                         op-type="call"
                                         operation-name="ReadExcelInput"
+
                                         operation-name="cat_file"
                                         output="excel_xml" point-x="158"
+
                                         output="output" point-x="158"
 
                                         point-y="112" type="flow-node"/>
 
                                         point-y="112" type="flow-node"/>
 
                         <GVEndNode class="it.greenvulcano.gvesb.core.flow.GVEndNode"
 
                         <GVEndNode class="it.greenvulcano.gvesb.core.flow.GVEndNode"
 
                                   end-business-process="yes" id="end" op-type="end"
 
                                   end-business-process="yes" id="end" op-type="end"
                                   output="excel_xml" point-x="358" point-y="112"
+
                                   output="output" point-x="358" point-y="112"
 
                                   type="flow-node"/>
 
                                   type="flow-node"/>
 
                     </Flow>
 
                     </Flow>
Line 65: Line 77:
  
  
At this point you have configured a service with an ''excelreader-call'' operation.
+
At this point you have configured a service with a ''shell-call'' operation.
 
 
 
 
==Example==
 
This example shows an XML document generated by a simple Excel sheet (without cols and rows grouping).
 
Given an Excel sheet with the following structure:
 
{| class="gvtable"
 
|-
 
! ID1
 
! ID2
 
! ID3
 
! ID4
 
! ID5
 
! ID6
 
! ID7
 
|-
 
| 23
 
| 23232
 
| 23
 
| 23333
 
| 1
 
| 2
 
| 3
 
|-
 
| 24
 
| 24444
 
| 23
 
| 23332
 
| 1
 
| 2
 
| 3
 
|}
 
''excelreader-call'' generates the following XML:
 
 
 
<syntaxhighlight lang="XML"><?xml version="1.0" encoding="UTF-8"?>
 
<workbook>
 
    <sheet number="0">
 
        <name><![CDATA[Foglio1]]></name>
 
        <row number="0">
 
            <col number="0">
 
                <data><![CDATA[ID1]]></data>
 
            </col>
 
            <col number="1">
 
                <data><![CDATA[ID2]]></data>
 
            </col>
 
            <col number="2">
 
                <data><![CDATA[ID3]]></data>
 
            </col>
 
            <col number="3">
 
                <data><![CDATA[ID4]]></data>
 
            </col>
 
            <col number="4">
 
                <data><![CDATA[ID5]]></data>
 
            </col>
 
            <col number="5">
 
                <data><![CDATA[ID6]]></data>
 
            </col>
 
            <col number="6">
 
                <data><![CDATA[ID7]]></data>
 
            </col>
 
        </row>
 
        <row number="1">
 
            <col number="0">
 
                <data><![CDATA[23]]></data>
 
            </col>
 
            <col number="1">
 
                <data><![CDATA[23232]]></data>
 
            </col>
 
            <col number="2">
 
                <data><![CDATA[23]]></data>
 
            </col>
 
            <col number="3">
 
                <data><![CDATA[711]]></data>
 
            </col>
 
            <col number="4">
 
                <data><![CDATA[1]]></data>
 
            </col>
 
            <col number="5">
 
                <data><![CDATA[1]]></data>
 
            </col>
 
            <col number="6">
 
                <data><![CDATA[1]]></data>
 
            </col>
 
        </row>
 
        <row number="2">
 
            <col number="0">
 
                <data><![CDATA[23]]></data>
 
            </col>
 
            <col number="1">
 
                <data><![CDATA[711]]></data>
 
            </col>
 
            <col number="2">
 
                <data><![CDATA[23]]></data>
 
            </col>
 
            <col number="3">
 
                <data><![CDATA[23232]]></data>
 
            </col>
 
            <col number="4">
 
                <data><![CDATA[1]]></data>
 
            </col>
 
            <col number="5">
 
                <data><![CDATA[1]]></data>
 
            </col>
 
            <col number="6">
 
                <data><![CDATA[1]]></data>
 
            </col>
 
        </row>
 
    </sheet>
 
</workbook>
 
</syntaxhighlight>
 
 
 
With a [[ChangeGvBufferNode]] is possible parsing XML and retrieve any tag and value.
 
 
 
--[[User:A.sicignano|A.sicignano]] 16:30, 19 January 2012 (CET)
 

Latest revision as of 16:51, 24 February 2012

Definition

Many IT applications, within their business process, need to invoke shell commands. shell-call plug-in can be used to invoke a 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 GreenVulcano® ESB 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:

Attribute Type Description
type fixed This attribute must assume the value call.
class fixed This attribute must assume the value it.greenvulcano.gvesb.virtual.shell.ShellCallOperation (java class that manages the shell-call invocation).
name required This field identify the operation name that you will use in service definition.
directory optional Pathname of the directory in which the command is executed. This pathname can be static or may contain placeholders that are replaced at runtime. If this attribute is not present, the command is executed within the current working directory.
encoding optional The encoding with which encodes the command output in the GVBuffer body. If not specified, is used the file.encoding system property value.

Might contain the following sub-elements:

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="cat_file"
      type="call">
     <cmd>cat 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 into the Service 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="cat_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="cat_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.