You can call Macromedia JRun application functionality through JMX using Flash Remoting MX. You connect to a JMX MBean object using the MBean object name in the ActionScript getService function. Service functions are methods defined in the MBean's manageable interface. The following sections describe how to get a reference to a JMX MBean object and call its methods.
To grant clients access to JMX MBeans, you must provide permissions that specify the exposed MBean object names in the jrun_root/lib/jrun.policy file. For example, the following line of text, which is currently uncommented in the jrun.policy file, exposes the DeployerService for the JRun Flash samples:
permission jrun.security.JMXPermission "accessMBean.DefaultDomain:service=DeployerService";
You can also use wildcards to grant access to JMX MBeans. For example, to grant access to all MBeans under the DefaultDomain using a wildcard, you would uncomment the following line in the jrun.policy file:
// permission jrun.security.JMXPermission "accessMBean.DefaultDomain:*";
Before calling the methods of an MBean from ActionScript, you must get a reference to to an MBean.
#include "NetServices.as"
NetServices.setDefaultGatewayUrl("http://localhost/flashservices/gateway");
Note: There are several other ways to specify the gateway URL. For more information, see, "Using Flash Remoting Components in ActionScript," on page 13.
gatewayConnection = NetServices.createGatewayConnection();
getService function, as shown in the following example:jrunDeployerMBean = gatewayConnection.getService ("DefaultDomain:service = DeployerService", this);
Once you have a reference to an MBean, you can use ActionScript functions to invoke its public methods. For example, you could use the following ActionScript code to invoke the getEARs method of the jrunDeployerMBean MBean to get a list of JMX object names for deployed enterprise applications:
function getEARs()
{
jrunDeployerMBean.getEARs();
}
To handle the function results, you use a result handler function like the following:
function getEARs_Result(result)
{
numDeployed.text = result.length;
}
For more information about handling results in ActionScript, see "Handling function results in ActionScript".
Send me an e-mail when comments are added to this page | Comment Report
Current page: http://livedocs.adobe.com/flashremoting/mx/Using_Flash_Remoting_MX/usingFRJ2EE6.htm