<html>
<head>
<base href="http://cwiki.apache.org/confluence">
<link rel="stylesheet" href="/confluence/s/1519/1/1/_/styles/combined.css?spaceKey=GMOxDEV&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%21CommandsStructure.jpgalign%3Dleft%2Cwidth%3D571%2Cheight%3D277%21"></a>GShell
Commands Structure <img src="/confluence/download/attachments/13271124/Commands Structure.jpg"
align="left" border="0" height="277" width="571" /></h3>
<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 are defined in geronimo-jaxws-builder project.<br/>
Remote commands are defined in gshell-remote-client project.</p>
<h3><a name="HowGShellworkswithGeronimokernel-GShellStartupprogress%21Startupprogress.jpgalign%3Dleft%2Cwidth%3D727%2Cheight%3D599%21"></a>GShell
Startup progress <img src="/confluence/download/attachments/13271124/Startup progress.jpg"
align="left" border="0" height="599" width="727" /></h3>
<h3><a name="HowGShellworkswithGeronimokernel-"></a></h3>
<h3><a name="HowGShellworkswithGeronimokernel-"></a></h3>
<h3><a name="HowGShellworkswithGeronimokernel-"></a></h3>
<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 shows reflection between command id and command implementation</p>
<p>Layout.xml shows reflection between command line string and command 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 call 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>
<h3><a name="HowGShellworkswithGeronimokernel-"></a></h3>
<h4><a name="HowGShellworkswithGeronimokernel-1Definecommandclass"></a>1
Define command class</h4>
<h4><a name="HowGShellworkswithGeronimokernel-"></a></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 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">.......
<!-- Geronimo -->
<group>
<name>geronimo</name>
<nodes>
<command>
<name>stop-server</name>
<id>geronimo-commands:stop-server</id>
</command>
<command>
<name>test</name>
<id>geronimo-commands:test</id>
</command>
</nodes>
</group>
.....
</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>
<h3><a name="HowGShellworkswithGeronimokernel-DetailsinGeronimocommands%28Client%29"></a>Details
in Geronimo-commands(Client)</h3>
<h4><a name="HowGShellworkswithGeronimokernel-Geronimocommandpart%3A"></a>Geronimo
command part:</h4>
<h4><a name="HowGShellworkswithGeronimokernel-"></a></h4>
<p>Jmx-<del>>kenel</del>->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>
<h3><a name="HowGShellworkswithGeronimokernel-"></a></h3>
<h4><a name="HowGShellworkswithGeronimokernel-Deploycommandpart"></a>Deploy
command part</h4>
<p>Geronimo-deploy-tool-<del>>ServerConnection</del>->GeronimoDeploymentManager</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>
<h4><a name="HowGShellworkswithGeronimokernel-Keycodes"></a>Key codes</h4>
<h4><a name="HowGShellworkswithGeronimokernel-"></a></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=4&originalVersion=3">View
Change</a>
|
<a href="http://cwiki.apache.org/confluence/display/GMOxDEV/How+GShell+works+with+Geronimo+kernel?showComments=true&showCommentArea=true#addcomment">Add
Comment</a>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
|