public class JMXServerJob extends java.lang.Object implements ArooaSessionAware, JmxServer
JMXClientJob
.
Security can be added using the environment property. Simple JMX security comes
prepackaged as SimpleServerSecurity
. Note that the access file is
an Oddjob specific access file. Oddjob requires full read/write access because
it uses JMX operations and all JMX operation require full read/write access.
Oddjob uses a JMX access format file but provides it's own primitive access
control on top the JMX layer. Oddjob's access control removes an entire java
interface from the client side proxy if any of it's methods are write.
One affect of this is that a read only account can't access properties of
the remote job with the ${server/remote-job} syntax because this functionality
is provided by the same interface (BeanUtils DynaBean
) that allows
a remote job's properties to be written.
For more information on JMX Security see The JMX Tutorial.
This service will use the Platform MBeanServer if no url
property is provided. Creating an unsecured Oddjob server on a private
network can be achieved simply by launching Oddjob with a command line
such as:
java -Dcom.sun.management.jmxremote.port=nnnn \ -Dcom.sun.management.jmxremote.ssl=false \ -Dcom.sun.management.jmxremote.authenticate=false \ -jar run-oddjob.jar -f my-config.xmlAnd then including this service somewhere in the configuration. Note that the properties must be to the left of the -jar, not to the right because the must be available to the JVM before Oddjob starts.
The server.xml
Oddjob configration file in Oddjob's top
level directory provides a simple Oddjob server that uses an RMI
Registry.
More information on Oddjob servers can be found in the User Guide under 'Sharing Jobs on the Network'.
<oddjob xmlns:jmx="http://rgordon.co.uk/oddjob/jmx"> <job> <sequential> <jobs> <jmx:server root="${echo}"/> <echo id="echo">Hello from an Oddjob Server!</echo> </jobs> </sequential> </job> </oddjob>
This is probably the simplest way to launch Oddjob as a server.
Here's an example of the command used to launch it:
java -Dcom.sun.management.jmxremote.port=13013 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false -jar C:\Users\rob\projects\oddjob\run-oddjob.jar -f C:\Users\rob\projects\oddjob\test\java\org\oddjob\jmx\PlatformMBeanServerExample.xmlFor an example of a client to connect to this server see the first example for
JMXClientJob
.
<oddjob id="this"> <job> <sequential> <jobs> <rmireg/> <jmx:server id="server1" root="${server-jobs}" url="service:jmx:rmi://ignored/jndi/rmi://localhost/freds-oddjob-server" xmlns:jmx="http://rgordon.co.uk/oddjob/jmx"/> <oddjob file="${this.dir}/ServerJobs.xml" id="server-jobs"/> </jobs> </sequential> </job> </oddjob>
The nested Oddjob can be any normal Oddjob configuration. Here is the nested Oddjob used in some client examples. The greeting is in a folder because it will only be run from the client.
<oddjob> <job> <folder> <jobs> <echo id="greeting">Hello World</echo> </jobs> </folder> </job> </oddjob>
<jmx:server root="${some-job}" url="service:jmx:rmi://ignored/jndi/rmi://localhost/my-oddjob" xmlns:jmx="http://rgordon.co.uk/oddjob/jmx"> <environment> <jmx:server-security> <passwordFile> <file file="C:\rob\java\jmx_examples\Security\simple\config\password.properties"/> </passwordFile> </jmx:server-security> </environment> </jmx:server>
Modifier and Type | Field and Description |
---|---|
static java.lang.String |
ACCESS_FILE_PROPERTY |
Constructor and Description |
---|
JMXServerJob() |
Modifier and Type | Method and Description |
---|---|
java.lang.String |
getAddress() |
java.util.Map<java.lang.String,?> |
getEnvironment() |
HandlerFactoryProvider |
getHandlerFactories() |
java.lang.String |
getLogFormat() |
java.lang.String |
getName()
Get the name.
|
RemoteIdMappings |
getRemoteIdMappings()
For other services such as the web server that needs to reuse to remote ids.
|
java.lang.Object |
getRoot()
Get the root node of the monitor tree.
|
javax.management.MBeanServerConnection |
getServerConnection()
Used to create an
RemoteConnection . |
java.lang.String |
getUrl()
Get the name the root node is bound as in the naming service.
|
void |
setArooaSession(ArooaSession session)
Accept the current Arooa Session.
|
void |
setEnvironment(java.util.Map<java.lang.String,?> environment) |
void |
setHandlerFactories(HandlerFactoryProvider handlerFactories) |
void |
setLogFormat(java.lang.String logFormat) |
void |
setName(java.lang.String name)
Set the name
|
void |
setRoot(java.lang.Object rootNode)
Set the root node directly.
|
void |
setUrl(java.lang.String url)
Set the name to bind the root node as in the naming service.
|
void |
start() |
void |
stop() |
java.lang.String |
toString() |
public static final java.lang.String ACCESS_FILE_PROPERTY
public void setArooaSession(ArooaSession session)
ArooaSessionAware
setArooaSession
in interface ArooaSessionAware
session
- The Arooa Session. Never null.public java.lang.String getName()
public void setName(java.lang.String name)
name
- The name.public void setRoot(java.lang.Object rootNode)
rootNode
- The root node for the monitor tree.public java.lang.Object getRoot()
public java.lang.String getAddress()
public void setUrl(java.lang.String url)
url
- The name for the naming service.public java.lang.String getUrl()
public RemoteIdMappings getRemoteIdMappings()
getRemoteIdMappings
in interface JmxServer
public javax.management.MBeanServerConnection getServerConnection()
RemoteConnection
.getServerConnection
in interface JmxServer
public void start() throws javax.management.JMException, java.io.IOException, ServerLoopBackException
javax.management.JMException
java.io.IOException
ServerLoopBackException
public void stop() throws java.lang.Exception
java.lang.Exception
public java.lang.String toString()
toString
in class java.lang.Object
public java.lang.String getLogFormat()
public void setLogFormat(java.lang.String logFormat)
public HandlerFactoryProvider getHandlerFactories()
public void setHandlerFactories(HandlerFactoryProvider handlerFactories)
public java.util.Map<java.lang.String,?> getEnvironment()
public void setEnvironment(java.util.Map<java.lang.String,?> environment)