org.iids.aos.agentserver.java
Class JavaAgentCodeSegment

java.lang.Object
  extended by org.iids.aos.agentserver.java.JavaAgentCodeSegment

public class JavaAgentCodeSegment
extends java.lang.Object

Defines the layout of the code segment of an agent for this particular Agent Server and provides convenient access for the AgentRunner. Currently, the layout corresponds to a single Java jar file. The jar file may ship its own classes and/or may contain references to other jar files (through the manifest's 'class path' attribute). references to otue

Author:
Patrick Verkaik

Field Summary
static int BUFSIZE
          Buffer size for copying data around.
 
Constructor Summary
JavaAgentCodeSegment(byte[] codeSegment)
          Parses and processes an agent's code segment.
 
Method Summary
 void cleanUp()
           
 java.net.URL getCodeBase()
          Returns a URL for the codebase in the code segment.
static java.util.jar.Manifest retrieveJarManifest(java.net.URL url)
          Retrieves the manifest from a jar file pointed to by the given URL.
static byte[] writeAgentCodeSegment(boolean shipcode, java.net.URL codebaseURL)
          Composes an agent's code segment.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

BUFSIZE

public static final int BUFSIZE
Buffer size for copying data around.

See Also:
Constant Field Values
Constructor Detail

JavaAgentCodeSegment

public JavaAgentCodeSegment(byte[] codeSegment)
                     throws JavaCodeSegmentException,
                            java.io.IOException
Parses and processes an agent's code segment.

Throws:
JavaCodeSegmentException - if codeSegment could not be parsed
java.io.IOException - if an error occurred writing a temporary jar file
Method Detail

writeAgentCodeSegment

public static byte[] writeAgentCodeSegment(boolean shipcode,
                                           java.net.URL codebaseURL)
                                    throws java.io.IOException
Composes an agent's code segment. Depending on the value of 'shipcode', either the contents of the jar file at the given codebaseURL is read and placed in the code segment (shipcode == true), or else a new jar file is created and placed in the code segment which refers to the agent's codebase through codebaseURL itself (shipcode == false).

Parameters:
codebaseURL - a URL pointing to a jar file containing the agent's codebase
Throws:
java.io.IOException - if an error occurred reading the codebase or writing the code segment

cleanUp

public void cleanUp()

getCodeBase

public java.net.URL getCodeBase()
Returns a URL for the codebase in the code segment.


retrieveJarManifest

public static java.util.jar.Manifest retrieveJarManifest(java.net.URL url)
                                                  throws java.io.IOException
Retrieves the manifest from a jar file pointed to by the given URL.

Parameters:
url - a URL pointing to a jar file
Returns:
the manifest
Throws:
java.io.IOException


Copyright © 2003, 2004 IIDS Group. All Rights Reserved.