Deploying Your Application

Your application can include a class a main method, or you can use the main provided in the Able base class for starting a saved agent. As an example, we provide the SimpleAbleApp.java which constructs a SimpleAbleAgent and provides a data buffer connection to a SimpleAbleBean.

The AbleFileWatcherCustomizer is another example, but, it doesn't illustrate saving an agent's properties or restoring a saved agent.

Saving an Agent

You can save your agent to a file to be restored later like this:

agent.setFileName(path + File.separator + fileName + ".ser");
agent.saveToFile() ;

You can save your agent to a file for later deployment within the Agent Editor also.When you develop an agent within the Agent Editor, the root of the tree is an outermost agent that contains all the agents and beans you have add to the canvas and configure. In deployment, you may not want to include that outermost agent.

For example, say you just started the Agent Editor and added an AbleNeuralClassifierAgent to the canvas, configured it, and trained it. Simply saving the agent will save the AbleNeuralClassifierAgent as a bean inside the default agent container AbleDefaultAgent. If you deploy this, each time you pass data in the input buffer of the AbleDefaultAgent, it passes the same data to the AbleNeuralClassifierAgent, which passes it on to the input filter bean. There is an extra buffer transfer here between the default and classifier agents. Instead, select the AbleNeuralClassifierAgent and export that bean. Now your outermost container is the AbleNeuralClassifier itself. In this instance you will want to consider whether the Import objects should be serialized or not. For the neural classifer to process data provided externally, the agent should be in run mode, and the import objects must either be removed or their dataflow set off so that neither test or train datasources are used.

Restoring a Saved Agent

Once an agent or bean has been serialized to a file, it can be restored using a static method like this:

AbleBean bean = AbleObject.restoreFromSerializedFile(path + File.separator + filename);

Here is an example from the Able Agent Editor where a new agent is loaded and replaces the current agent. The Agent Editor has a listener on the current agent for property changes such as bean additions and removals, so it removes itself from the current agent before it reassigns its current agent to the restored agent.

AbleAgent agent = (AbleAgent)agent.restoreFromFile(path + File.separator + fileName + ".ser") ;
if (currentAgent!= null) currentAgent.removePropertyChangeListener(this);
currentAgent = agent ;
agent.addPropertyChangeListener(this) ;

Starting a Saved Agent

You can restore an agent from the command line by passing the serialized file to the main method in Able. Any enabled processing will start.

C:\able_1.5.0\bin>java com.ibm.able.Able C:\able_1.5.0\examples\neural\animal.ser

Jarfile Use

Typically you package your java class files in a jar, and distribute that jar as well as any of the Able-dependant jars such as ablebean.jar needed for runtime. Refer to the list of jar files provided for a description of jar content. You may redistribute the provided jars subject to the terms of the license agreement.

Note that you can insert serialized agents in a jar file for distribution using the Agent Editor Tools->Add agent to jar option.