dev@glassfish.java.net

Re: AMX sample code

From: Lloyd Chambers <Lloyd.Chambers_at_Sun.COM>
Date: Sat, 13 Sep 2008 09:27:49 -0700

Ludo,

I did the code from memory. Sorry, I should have waited and
compiled. :) I will work on getting some compiled and tested sample
code on Monday.

You might find the quicklook test code helpful in tests/quicklook/amx/
src/test/amx/BasicAMXTests.java . It's generic testing, but of course
it compiles and works.

Do use the javadoc, it will help. To generate current javadoc:
cd common/amx-api
mvn javadoc:javadoc
open target/site/apidocs/index.html

As far as "server-config", "listener-1", those are parameters, names
of configuration elements, just like you'd need to use for CLI
commands and/or dotted names; the issues are identical. If you were
presenting things to the user in a GUI, presumably you'd want to
allow the user to choose the server, config, listener, virtual server,
etc. That's what the admin GUI does. The CLI allows 'list' commands;
the equivalent form in AMX is to get a Map or Set eg for type 'Abc'.
For example, to get the list of servers:

Map<String,StandaloneServerConfig> m =
      
domainRoot
.getDomainConfig().getServersConfig().getStandaloneServerConfigMap();
StandaloneServerConfig server = m.get(serverName); // eg "server"

I don't expect the default server to be other than "server", or the
default config to be other than "server-config". But customers can
make their own choices. Probably we've hard-coded the DAS as "server"
and the world would break if it changed.

Lloyd


On Sep 13, 2008, at 8:53 AM, Ludovic Champenois wrote:

> Lloyd Chambers wrote:
>> First you need to get a DomainRoot.
>>
>> Out of process, this means connecting to the server. Currently RMI
>> is not working due to a JNDI bug. So JMXMP is being used.
>> AppserverConnectionSource is the way to connect once it works. For
>> now:
>>
>> ...
>>
>> DomainConfig dc = domainRoot.getDomainConfig();
>>
>> ...
>>
>> HTTPListenerConfig listener =
>> dc
>> .getHTTPServiceConfig().getHTTPListenerConfigMap().get("listener-1");
>>
>> final String rawValue = listener.getPort(); final int port =
>> listener.resolveInteger("Port");
>> listener.setPort( "7777" );
> ...
>
> Hi Lloyd,
> the code you sent does not compile...
> The correct code for example to fix compilation errors above is:
>
>
> HTTPListenerConfig listener =
> dc.getConfigsConfig().getConfigConfigMap().get("server-
> config
> ").getHTTPServiceConfig
> () .getHTTPListenerConfigMap().get("listener-1");
>
> final String rawValue = listener.getPort(); final int
> port = listener.resolveInteger("Port"); // will be a number
> listener.setPort("7777");
>
>
>
> Which raises the following questions:
> Is "listener-1" an exposed interface? What would be the server
> behavior if domain.xml contains another name there?
> Same for "server-config" or "Port". I did not look at the javadoc,
> maybe it is described there.
>
>
> The rest of the code does not still compile...I am trying to fix it
> but it is not very easy so far.
>
> When the code is functional, we'll put in on a AMX V3 wiki page.
>
> Ludo
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: dev-help_at_glassfish.dev.java.net
>