examples
Class PipeWrapperAgent

java.lang.Object
  extended byexamples.PipeWrapperAgent
All Implemented Interfaces:
Runnable, Serializable

public class PipeWrapperAgent
extends Object
implements Runnable, Serializable

This agent is an example for an agent wrapping a resource of the underlying operating system. Its purpose is to open a named pipe and simply print anything read from it to System.out.

The name of the pipe is inpipe and has to be located in in ${HOME}/tmp . What the users home directory is, depends on the opereating system the virtual machine is run on. If you're in doubt set the Java property user.home accordingly.

For testing just write to the pipe from a different process, for instance:

 cat foo.txt > inpipe 
 echo Hello World > inpipe
 cat > inpipe
 
How to create a named pipe depends on your operating system. On all UNIX/Linux derivats there is a command mkfifo which will do just that. Creating named pipes in Windows makes the things more difficult. There are API calls even for some scripting languages, which is in fact not that intuitive ;o) but, I do not know any other way. Perphaps just switch to UNIX? Please check out that the agent has the proper rights to open the named pipe from the filesystem. Please check out the file semoa/etc/semoa.policy To grant this right to the agent there should be an entry as follows:
 PERM java.io.FilePermission ${HOME}/tmp/- "read"
 
If you test it with the standard SeMoA distribution, the according entry already exists.

Version:
"$Id: PipeWrapperAgent.java 1913 2007-08-08 02:41:53Z jpeters $"
Author:
Ulrich Pinsdorf
See Also:
System.getProperties(), Serialized Form

Field Summary
private static String PIPE
          The pipe's name which is expected at the user's home directory.
 
Constructor Summary
PipeWrapperAgent()
          The agent's constructor.
 
Method Summary
 void run()
          Performs the agent's job.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PIPE

private static String PIPE
The pipe's name which is expected at the user's home directory.

Constructor Detail

PipeWrapperAgent

public PipeWrapperAgent()
The agent's constructor.

Method Detail

run

public void run()
Performs the agent's job. This method is called after each agent startup, e.g. after every migration. The agent's lifecycle is as follows:

Specified by:
run in interface Runnable


Copyright © Fraunhofer Gesellschaft. All Rights Reserved.