Using Jade4spring in your application

Jade4Spring is created in order to make use of JADE with Spring Framework faster and easier. This section explains how you set up your application to support JADE agents.

The Application Context

In order to access Jade4Spring in your application you need to add the following bean to your Application Context .
										
<!--  JADE Container bean -->
<bean id="jadeBean"
	class="net.sf.jade4spring.JadeBean"
	init-method="startContainer" lazy-init="false"
	destroy-method="stopContainer">
</bean>
								

There are a few properties which are worth mentioning. The utilityAgents property can be set to true or false indicating whether the container should start utility agents for monitoring the platform that it is connected to. One of these agents is the J4SInfiltratorAgent which keeps track of events in the platform and which agents that are currently running. This is the agent used by JadeBean to obtain platform information.

The utility agents are started by JadeBean by default, so if you want to disable this, then add the following element to your JadeBean configuration:

												
<property name="utilityAgents">
	<value>false</value>
</property>
										
N.B. When setting the utilityAgents property to false, all calls to the JadeBean methods that performs Agent related action like kill, suspend and resume will not be execute correctly.

Jade4Spring allows you to specify agents in the application context and have the JadeBean automatically start them when the container is running. To autostart your agents you have to specify them as beans in the application context and add them as a map to the JadeBean. This is done with the following configuration:

												
<property name="autostartAgents">
    <map>
       <entry>
            <key>
                <value>TestAgent</value>
            </key>
            <ref bean="testAgent" />
        </entry>
    </map>
</property>
										
You may add as many agents as you want, just make sure to give them unique names or all agents except the first one will fail to start...

JADE configuration

Configuring the JADE container that is launched through jade4spring is done via a properties file. This properties file must, by default, be located on your classpath as /jade.properties. if you want this file to be located in a different location you may specify this via the following parameter on the JadeBean instance:

										
<property name="propertiesFile" value="/path/to/configuration/jade.properties" />
								
								
or
										
<property name="propertiesFile" value="classpath:/path/on/classpath/jade.properties" />
								
								

The properties available to set in the properties files are those specified in the JADE configuration. Here is an example configuration for a container:

								
container=true
port=4242
host=localhost
container-name=MyContainer
								
								

From version (>= 1.0.3) additional parameters must be added to the jade.properties file:

								
local-port=42424
local-host=127.0.0.1