geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From conflue...@apache.org
Subject [CONF] Apache Geronimo Development > How GShell works with Geronimo kernel
Date Thu, 04 Feb 2010 08:18:00 GMT
<html>
<head>
    <base href="http://cwiki.apache.org/confluence">
            <link rel="stylesheet" href="/confluence/s/1519/1/1/_/styles/combined.css?spaceKey=GMOxDEV&amp;forWysiwyg=true"
type="text/css">
    </head>
<body style="background-color: white" bgcolor="white">
<div id="pageContent">
<div id="notificationFormat">
<div class="wiki-content">
<div class="email">
     <h2><a href="http://cwiki.apache.org/confluence/display/GMOxDEV/How+GShell+works+with+Geronimo+kernel">How
GShell works with Geronimo kernel</a></h2>
     <h4>Page <b>edited</b> by             <a href="http://cwiki.apache.org/confluence/display/~wwtvanessa">Wang
Wen Ting</a>
    </h4>
     
          <br/>
     <div class="notificationGreySide">
         <h3><a name="HowGShellworkswithGeronimokernel-GShellCommandsStructure"></a>GShell
Commands Structure</h3>


<h3><a name="HowGShellworkswithGeronimokernel-"></a></h3>


<p><img src="/confluence/download/attachments/13271124/Commands Structure.jpg" align="absmiddle"
border="0" height="305" width="631" /></p>

<p>Build-in commands like set, clean, help, quit and so on are defined in gshell-builtin
project<br/>
Geronimo commands like start-server,stop-server adn deploy commands like start-module are
defined in geronimo-commands project.<br/>
Jaxws commands&nbsp; are defined in&nbsp; geronimo-jaxws-builder project.<br/>
Remote commands are defined in gshell-remote-client project.</p>

<h3><a name="HowGShellworkswithGeronimokernel-GShellStartupprogress%26nbsp%3B"></a>GShell
Startup progress&nbsp;</h3>


<p><img src="/confluence/download/attachments/13271124/Startup progress.jpg" align="absmiddle"
border="0" height="599" width="727" /></p>


<p>1 org.codehaus.plexus.ClassLoader load every jar defined in etc/gsh-classworlds.conf<br/>
2 org.apache.geronimo.gshell.plugin.CommandDiscoverer load the commands.xml in gshell-builtin.jar/META-INF/gshell<br/>
3 All the commands register in org.apache.geronimo.gshell.registry..CommandRegistry.<br/>
4 The same process for geronimo-commands and jaws-commands<br/>
5 org.apache.geronimo.gshell.layout.loader.XMLLayoutLoader load the layout.xml in etc/layout.xml<br/>
6 GShell start up DefaultLayoutManager.<br/>
7 GShell start up org.apache.geronimo.gshell.DefaultCommandLineBuilder and DefaultCommandExecutor<br/>
8 Gshell read argument from console and read history from Document and Setting/[username]/.gshell/gshell.history<br/>
9 Finish initialization and waiting</p>
<div class="panel" style="border-width: 1px;"><div class="panelContent">
<p><font color="#ff0000">Note:</font></p>

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

<p>Layout.xml&nbsp;shows&nbsp;reflection&nbsp;between&nbsp;command&nbsp;line&nbsp;string&nbsp;and&nbsp;command&nbsp;id</p>
</div></div>

<h3><a name="HowGShellworkswithGeronimokernel-GShellprocesscommandlineprogress"></a>GShell
process command line progress</h3>

<p>1 org.apache.geronimo.gshell.console.JLineConsole get a command line from console<br/>
2 org.apache.geronimo.gshell.DefaultCommandLineBuilder parse the command line and check if
it has a syntax error<br/>
3 org.apache.geronimo.gshell.layout.DefaultLayoutManager find corresponding command id and
give to org.apache.geronimo.gshell.DefaultCommandExecutor .<br/>
4org.apache.geronimo.gshell.DefaultCommandExecutor&nbsp; call&nbsp; A certain command
execute the doExecute() method.<br/>
5 org.apache.geronimo.gshell.clp.CommandLineProcessor process the arguements.</p>

<h3><a name="HowGShellworkswithGeronimokernel-Defineyourowncommand"></a>Define
your own command</h3>

<h4><a name="HowGShellworkswithGeronimokernel-1Definecommandclass"></a>1
Define command class</h4>

<p>In geronimo/framework/modules/geronimo-commands projects, you can define your own
command class in src folder.<br/>
Note all the command classes&nbsp; are defined in groovy.<br/>
E.g.</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java"><span class="code-keyword">package</span> org.apache.geronimo.commands
<span class="code-keyword">import</span> org.apache.geronimo.gshell.command.annotation.CommandComponent

/**
  * Test
  */
@CommandComponent(id='geronimo-commands:test', description=<span class="code-quote">"Test"</span>)
class TestCommand <span class="code-keyword">extends</span> ConnectCommand {
    @Option(name='-a', aliases=['--argument'], description='Arguement test')
    <span class="code-object">int</span> argu = 1;   
    <span class="code-keyword">protected</span> <span class="code-object">Object</span> doExecute() <span
class="code-keyword">throws</span> Exception {
        print <span class="code-quote">"Hello World!"</span>   
    }
}
</pre>
</div></div>
<p>Compile source codes and put the target jar file in the same directory in binary
server file.</p>

<h4><a name="HowGShellworkswithGeronimokernel-2Modifyconfigurationfile"></a>2
Modify configuration file</h4>


<h4><a name="HowGShellworkswithGeronimokernel-"></a></h4>

<p>Modify file layout.xml in [server dir]/etc<br/>
E.g</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java">.......
&lt;!-- Geronimo --&gt;
&lt;group&gt;
&lt;name&gt;geronimo&lt;/name&gt;
&lt;nodes&gt;
&lt;command&gt;
&lt;name&gt;stop-server&lt;/name&gt;
&lt;id&gt;geronimo-commands:stop-server&lt;/id&gt;
&lt;/command&gt;
&lt;command&gt;
&lt;name&gt;test&lt;/name&gt;
&lt;id&gt;geronimo-commands:test&lt;/id&gt;
&lt;/command&gt;
&lt;/nodes&gt;
&lt;/group&gt;
.....
</pre>
</div></div>

<h4><a name="HowGShellworkswithGeronimokernel-3restartgshell"></a>3 restart
gshell</h4>

<p>You can find test command in help list and use test to see print line.</p>

<p><img src="/confluence/download/attachments/13271124/restart-gshell.jpg" align="absmiddle"
border="0" height="462" width="576" /></p>

<h3><a name="HowGShellworkswithGeronimokernel-DetailsinGeronimocommands%28Client%29"></a>Details
in Geronimo-commands(Client)</h3>

<p><img src="/confluence/download/attachments/13271124/Geronimo-commands.jpg" align="absmiddle"
border="0" height="358" width="527" /></p>

<h4><a name="HowGShellworkswithGeronimokernel-Geronimocommandpart%3A"></a>Geronimo
command part:</h4>


<p>Jmx&#45;<del>&gt;kenel</del>&#45;&gt;invoke(shutdown/getAttribute)<br/>
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.</p>

<p><img src="/confluence/download/attachments/13271124/Geronimo command.jpg" align="absmiddle"
border="0" height="295" width="705" /></p>

<h4><a name="HowGShellworkswithGeronimokernel-Deploycommandpart"></a>Deploy
command part</h4>

<p>Geronimo-deploy-tool&#45;<del>&gt; ServerConnection</del>&#45;&gt;GeronimoDeploymentManager<br/>
<img src="/confluence/download/attachments/13271124/Deploy command.jpg" align="absmiddle"
border="0" height="369" width="745" /></p>

<h3><a name="HowGShellworkswithGeronimokernel-Detailsingeronimojmxremoting%28Server%29"></a>Details
in geronimo-jmx-remoting(Server)</h3>


<h4><a name="HowGShellworkswithGeronimokernel-BuildJMXServerprogress"></a>Build
JMX Server progress</h4>

<p><img src="/confluence/download/attachments/13271124/JMX Server progress.jpg" align="absmiddle"
border="0" height="386" width="782" /></p>

<h4><a name="HowGShellworkswithGeronimokernel-Keycodes"></a>Key codes</h4>

<p>in JMXConnector in geronimo-jmx-remoting project</p>
<div class="code panel" style="border-width: 1px;"><div class="codeContent panelContent">
<pre class="code-java"><span class="code-keyword">public</span> void doStart() <span
class="code-keyword">throws</span> Exception {
        jmxServiceURL = <span class="code-keyword">new</span> JMXServiceURL(protocol, host, port, urlPath);
        Authenticator authenticator = <span class="code-keyword">null</span>;
        Map env = <span class="code-keyword">new</span> HashMap();
        <span class="code-keyword">if</span> (applicationConfigName != <span
class="code-keyword">null</span>) {
            authenticator = <span class="code-keyword">new</span> Authenticator(applicationConfigName, classLoader);
            env.put(JMXConnectorServer.AUTHENTICATOR, authenticator);
        } <span class="code-keyword">else</span> {
            log.warn(<span class="code-quote">"Starting unauthenticating JMXConnector <span
class="code-keyword">for</span> "</span> + jmxServiceURL);
        }        RMIServerSocketFactory serverSocketFactory = <span class="code-keyword">new</span> GeronimoRMIServerSocketFactory(host);
        env.put(RMIConnectorServer.RMI_SERVER_SOCKET_FACTORY_ATTRIBUTE, serverSocketFactory);
        server = JMXConnectorServerFactory.newJMXConnectorServer(jmxServiceURL, env, mbeanServer);
        NotificationFilterSupport filter = <span class="code-keyword">new</span> NotificationFilterSupport();
        filter.enableType(JMXConnectionNotification.OPENED);
        filter.enableType(JMXConnectionNotification.CLOSED);
        filter.enableType(JMXConnectionNotification.FAILED);
        server.addNotificationListener(authenticator, filter, <span class="code-keyword">null</span>);
        server.start();
        log.debug(<span class="code-quote">"Started JMXConnector "</span> + server.getAddress());
</pre>
</div></div>
     </div>
     <div id="commentsSection" class="wiki-content pageSection">
       <div style="float: right;">
            <a href="http://cwiki.apache.org/confluence/users/viewnotifications.action"
class="grey">Change Notification Preferences</a>
       </div>

       <a href="http://cwiki.apache.org/confluence/display/GMOxDEV/How+GShell+works+with+Geronimo+kernel">View
Online</a>
       |
       <a href="http://cwiki.apache.org/confluence/pages/diffpagesbyversion.action?pageId=13271124&revisedVersion=5&originalVersion=4">View
Change</a>
              |
       <a href="http://cwiki.apache.org/confluence/display/GMOxDEV/How+GShell+works+with+Geronimo+kernel?showComments=true&amp;showCommentArea=true#addcomment">Add
Comment</a>
            </div>
</div>
</div>
</div>
</div>
</body>
</html>

Mime
View raw message