You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Next »

GShell Commands Structure
Build-in commands like set, clean, help, quit and so on are defined in gshell-builtin project
Geronimo commands like start-server,stop-server adn deploy commands like start-module are defined in geronimo-commands project.
Jaxws commands  are defined in  geronimo-jaxws-builder project.
Remote commands are defined in gshell-remote-client project.
GShell Startup progress
1 org.codehaus.plexus.ClassLoader load every jar defined in etc/gsh-classworlds.conf
2 org.apache.geronimo.gshell.plugin.CommandDiscoverer load the commands.xml in gshell-builtin.jar/META-INF/gshell
3 All the commands register in org.apache.geronimo.gshell.registry..CommandRegistry.
4 The same process for geronimo-commands and jaws-commands
5 org.apache.geronimo.gshell.layout.loader.XMLLayoutLoader load the layout.xml in etc/layout.xml
6 GShell start up DefaultLayoutManager.
7 GShell start up org.apache.geronimo.gshell.DefaultCommandLineBuilder and DefaultCommandExecutor
8 Gshell read argument from console and read history from Document and Setting/[username]/.gshell/gshell.history
9 Finish initialization and waiting
<ac:structured-macro ac:name="panel" ac:schema-version="1" ac:macro-id="d1b3166e-1c5c-4c0f-a1b8-7db3ddb8bb0b"><ac:rich-text-body>
<p><span style="color: #ff0000">Note:</span></p>

<p>Command.xml shows reflection between command id and command implementation</p>

<p>Layout.xml shows reflection between command line string and command id</p></ac:rich-text-body></ac:structured-macro>GShell process command line progress
1 org.apache.geronimo.gshell.console.JLineConsole get a command line from console
2 org.apache.geronimo.gshell.DefaultCommandLineBuilder parse the command line and check if it has a syntax error
3 org.apache.geronimo.gshell.layout.DefaultLayoutManager find corresponding command id and give to org.apache.geronimo.gshell.DefaultCommandExecutor .
4org.apache.geronimo.gshell.DefaultCommandExecutor  call  A certain command execute the doExecute() method.
5 org.apache.geronimo.gshell.clp.CommandLineProcessor process the arguements.
Define your own command
1 Define command class
In geronimo/framework/modules/geronimo-commands projects, you can define your own command class in src folder.
Note all the command classes  are defined in groovy.
E.g.

package org.apache.geronimo.commands
import org.apache.geronimo.gshell.command.annotation.CommandComponent

/**
  * Test
  */
@CommandComponent(id='geronimo-commands:test', description="Test")
class TestCommand extends ConnectCommand {
    @Option(name='-a', aliases=['--argument'], description='Arguement test')
    int argu = 1;   
    protected Object doExecute() throws Exception {
        print "Hello World!"   
    }
}

Compile source codes and put the target jar file in the same directory in binary server file.
2 Modify configuration file
Modify file layout.xml in [server dir]/etc
E.g

.......&nbsp;

<\!--&nbsp;Geronimo&nbsp;-->

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<group>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<name>geronimo</name>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<nodes>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<command>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<name>stop-server</name>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<id>geronimo-commands:stop-server</id>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</command>

{color:#ff0000}&nbsp;<command>{color}

{color:#ff0000}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<name>test</name>{color}

{color:#ff0000}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<id>geronimo-commands:test</id>{color}

{color:#ff0000}&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</command>{color}

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</nodes>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</group>

.....

3 restart gshell
You can find test command in help list and use test to see print line.
Details in Geronimo-commands(Client)
Geronimo command part:
Jmx->kenel->invoke(shutdown/getAttribute)
Basically, Geronimo stop and wait for server commands connect to remote/local server via jmx connections and get a MBeanServerConnection.Through MBeanServerConnection command get Kernel as Mbean and call invoke() method to shutdown or getAttribute.
Deploy command part
Geronimo-deploy-tool->ServerConnection->GeronimoDeploymentManager
Details in geronimo-jmx-remoting(Server)
Build JMX Server progress
Key codes
in JMXConnector in geronimo-jmx-remoting project

  • No labels