You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@uima.apache.org by al...@apache.org on 2006/11/28 23:21:53 UTC

svn commit: r480242 [3/5] - in /incubator/uima/uimaj/trunk/jVinci/src/main/java/org/apache/vinci: debug/ transport/ transport/context/ transport/document/ transport/util/ transport/vns/ transport/vns/client/ transport/vns/service/

Modified: incubator/uima/uimaj/trunk/jVinci/src/main/java/org/apache/vinci/transport/VinciClient.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/jVinci/src/main/java/org/apache/vinci/transport/VinciClient.java?view=diff&rev=480242&r1=480241&r2=480242
==============================================================================
--- incubator/uima/uimaj/trunk/jVinci/src/main/java/org/apache/vinci/transport/VinciClient.java (original)
+++ incubator/uima/uimaj/trunk/jVinci/src/main/java/org/apache/vinci/transport/VinciClient.java Tue Nov 28 14:21:50 2006
@@ -32,19 +32,24 @@
  */
 public class VinciClient extends BaseClient {
 
-  private int          level       = -2;
-  private int          instance    = -1;
-  private String       serviceName = null;
-  private VinciContext context     = null;
+  private int level = -2;
+
+  private int instance = -1;
+
+  private String serviceName = null;
+
+  private VinciContext context = null;
 
   /**
-   * Construct a new client connected to the requested service, and uses a VinciFrame
-   * factory to create the return document type.
-   *
-   * @param service_name The name of the service to connect to.
-   *
-   * @throws IllegalStateException if no VNS_HOST has been specified.
-   *
+   * Construct a new client connected to the requested service, and uses a VinciFrame factory to
+   * create the return document type.
+   * 
+   * @param service_name
+   *          The name of the service to connect to.
+   * 
+   * @throws IllegalStateException
+   *           if no VNS_HOST has been specified.
+   * 
    * @pre service_name != null
    */
   public VinciClient(String service_name) throws ServiceDownException, VNSException {
@@ -52,18 +57,22 @@
   }
 
   /**
-   * Constructs a new client connected to the requested service.  Consults VNS for the proper
-   * host and port to connect to.  Service names must be properly qualified. 
-   *
-   * @param service_name The name of the service to connect to.  
-   * @param factory The factory used for creating return documents of desired type.
-   *
-   * @throws IllegalStateException if no VNS_HOST has been specified.
-   *
+   * Constructs a new client connected to the requested service. Consults VNS for the proper host
+   * and port to connect to. Service names must be properly qualified.
+   * 
+   * @param service_name
+   *          The name of the service to connect to.
+   * @param factory
+   *          The factory used for creating return documents of desired type.
+   * 
+   * @throws IllegalStateException
+   *           if no VNS_HOST has been specified.
+   * 
    * @pre service_name != null
    * @pre factory != null
    */
-  public VinciClient(String service_name, TransportableFactory factory) throws ServiceDownException, VNSException {
+  public VinciClient(String service_name, TransportableFactory factory)
+          throws ServiceDownException, VNSException {
     super(factory);
     open(service_name);
   }
@@ -72,11 +81,12 @@
    * @pre service_name != null
    * @pre factory != null
    * @pre myContext != null
-   *
-   * @throws IllegalStateException if no VNS_HOST has been specified.
+   * 
+   * @throws IllegalStateException
+   *           if no VNS_HOST has been specified.
    */
   public VinciClient(String service_name, TransportableFactory factory, VinciContext myContext)
-      throws ServiceDownException, VNSException {
+          throws ServiceDownException, VNSException {
     super(factory);
     setContext(myContext);
     open(service_name);
@@ -85,58 +95,69 @@
   /**
    * @pre service_name != null
    * @pre myContext != null
-   *
-   * @throws IllegalStateException if no VNS_HOST has been specified.
+   * 
+   * @throws IllegalStateException
+   *           if no VNS_HOST has been specified.
    */
-  public VinciClient(String service_name, VinciContext myContext) throws ServiceDownException, VNSException {
+  public VinciClient(String service_name, VinciContext myContext) throws ServiceDownException,
+          VNSException {
     this(service_name, VinciFrame.getVinciFrameFactory(), myContext);
   }
 
   /**
-   * Construct a new client connected to the requested service, and uses a VinciFrame
-   * factory to create the return document type.
-   *
-   * @param service_name The name of the service to connect to.
-   * @param connectTimeout The number of milliseconds that will elapse before a connect attempt fails.
-   *
-   * @throws IllegalStateException if no VNS_HOST has been specified.
-   *
+   * Construct a new client connected to the requested service, and uses a VinciFrame factory to
+   * create the return document type.
+   * 
+   * @param service_name
+   *          The name of the service to connect to.
+   * @param connectTimeout
+   *          The number of milliseconds that will elapse before a connect attempt fails.
+   * 
+   * @throws IllegalStateException
+   *           if no VNS_HOST has been specified.
+   * 
    * @pre service_name != null
    */
-  public VinciClient(String service_name, int connectTimeout) throws ServiceDownException, VNSException {
+  public VinciClient(String service_name, int connectTimeout) throws ServiceDownException,
+          VNSException {
     this(service_name, VinciFrame.getVinciFrameFactory(), connectTimeout);
   }
 
   /**
-   * Constructs a new client connected to the requested service.  Consults VNS for the proper
-   * host and port to connect to.  Service names must be properly qualified. 
-   *
-   * @param service_name The name of the service to connect to.  
-   * @param factory The factory used for creating return documents of desired type.
-   * @param connectTimeout The number of milliseconds that will elapse before a connect attempt fails.
-   *
-   * @throws IllegalStateException if no VNS_HOST has been specified.
-   *
+   * Constructs a new client connected to the requested service. Consults VNS for the proper host
+   * and port to connect to. Service names must be properly qualified.
+   * 
+   * @param service_name
+   *          The name of the service to connect to.
+   * @param factory
+   *          The factory used for creating return documents of desired type.
+   * @param connectTimeout
+   *          The number of milliseconds that will elapse before a connect attempt fails.
+   * 
+   * @throws IllegalStateException
+   *           if no VNS_HOST has been specified.
+   * 
    * @pre service_name != null
    * @pre factory != null
    */
   public VinciClient(String service_name, TransportableFactory factory, int connectTimeout)
-      throws ServiceDownException, VNSException {
+          throws ServiceDownException, VNSException {
     super(factory, connectTimeout);
     open(service_name);
   }
 
   /**
    * Constructs a new client connected to the requested service.
-   *
+   * 
    * @pre service_name != null
    * @pre factory != null
    * @pre myContext != null
-   *
-   * @throws IllegalStateException if no VNS_HOST has been specified.
+   * 
+   * @throws IllegalStateException
+   *           if no VNS_HOST has been specified.
    */
-  public VinciClient(String service_name, TransportableFactory factory, VinciContext myContext, int connectTimeout)
-      throws ServiceDownException, VNSException {
+  public VinciClient(String service_name, TransportableFactory factory, VinciContext myContext,
+          int connectTimeout) throws ServiceDownException, VNSException {
     super(factory, connectTimeout);
     setContext(myContext);
     open(service_name);
@@ -144,103 +165,111 @@
 
   /**
    * Constructs a new client connected to the requested service.
-   *
+   * 
    * @pre service_name != null
    * @pre myContext != null
-   *
-   * @throws IllegalStateException if no VNS_HOST has been specified.
+   * 
+   * @throws IllegalStateException
+   *           if no VNS_HOST has been specified.
    */
-  public VinciClient(String service_name, VinciContext myContext, int connectTimeout) throws ServiceDownException,
-      VNSException {
+  public VinciClient(String service_name, VinciContext myContext, int connectTimeout)
+          throws ServiceDownException, VNSException {
     this(service_name, VinciFrame.getVinciFrameFactory(), myContext, connectTimeout);
   }
 
   /**
-   * Construct a new client WITHOUT opening a connection, using the VinciFrame factory
-   * to create return documents.
+   * Construct a new client WITHOUT opening a connection, using the VinciFrame factory to create
+   * return documents.
    */
   public VinciClient() {
     super();
   }
 
   /**
-   * Construct a new client WITHOUT opening a connection, using the specified factory
-   * to create return documents.
+   * Construct a new client WITHOUT opening a connection, using the specified factory to create
+   * return documents.
    */
   public VinciClient(TransportableFactory f) {
     super(f);
   }
 
   /**
-   * Get the priority level of the service to which this client is connected. This 
-   * method only works after the connection has been opened.
+   * Get the priority level of the service to which this client is connected. This method only works
+   * after the connection has been opened.
    */
   public int getLevel() {
     return level;
   }
 
   /**
-   * Get the instance number of this service. This method only works after the connection has
-   * been opened.
-   *
+   * Get the instance number of this service. This method only works after the connection has been
+   * opened.
+   * 
    * Services should have "non zero" instance numbers only when more than one instance of the
    * service is running on the same host. The unique instance value allows each instance to be
-   * distinguished and uniquely addressed via a fully qualified service name.  
+   * distinguished and uniquely addressed via a fully qualified service name.
    */
   public int getInstance() {
     return instance;
   }
 
   /**
-   * Convenience method for "one-shot"/single-query connections. Equivalent of manually creating
-   * a new VinciClient(), calling (non-static) sendAndReceive, and then closing the client.
-   *
-   * @throws IllegalStateException if the VNS host has not been specified.
+   * Convenience method for "one-shot"/single-query connections. Equivalent of manually creating a
+   * new VinciClient(), calling (non-static) sendAndReceive, and then closing the client.
+   * 
+   * @throws IllegalStateException
+   *           if the VNS host has not been specified.
    * 
    * @pre in != null
    * @pre service_name != null
    * @pre factory != null
    */
-  static public Transportable sendAndReceive(Transportable in, String service_name, TransportableFactory factory)
-      throws IOException, ServiceException, ServiceDownException, VNSException {
+  static public Transportable sendAndReceive(Transportable in, String service_name,
+          TransportableFactory factory) throws IOException, ServiceException, ServiceDownException,
+          VNSException {
     return VinciContext.getGlobalContext().sendAndReceive(in, service_name, factory);
   }
 
   /**
-   * Convenience method for "one-shot"/single-query connections. Equivalent of manually creating
-   * a new VinciClient(), calling (non-static) sendAndReceive, and then closing the client.
-   *
-   * @throws IllegalStateException if the VNS host has not been specified.
-   *
+   * Convenience method for "one-shot"/single-query connections. Equivalent of manually creating a
+   * new VinciClient(), calling (non-static) sendAndReceive, and then closing the client.
+   * 
+   * @throws IllegalStateException
+   *           if the VNS host has not been specified.
+   * 
    * @pre in != null
    * @pre service_name != null
    * @pre factory != null
    * @pre socket_timeout >= 0
    */
-  static public Transportable sendAndReceive(Transportable in, String service_name, TransportableFactory factory,
-      int socket_timeout) throws IOException, ServiceException {
-    return VinciContext.getGlobalContext().sendAndReceive(in, service_name, factory, socket_timeout);
+  static public Transportable sendAndReceive(Transportable in, String service_name,
+          TransportableFactory factory, int socket_timeout) throws IOException, ServiceException {
+    return VinciContext.getGlobalContext()
+            .sendAndReceive(in, service_name, factory, socket_timeout);
   }
 
   /**
-   * Convenience method for "one-shot"/single-query connections. Equivalent of manually creating
-   * a new VinciClient(), calling (non-static) sendAndReceive, and then closing the client.
-   *
-   * @throws IllegalStateException if the VNS host has not been specified.
-   *
+   * Convenience method for "one-shot"/single-query connections. Equivalent of manually creating a
+   * new VinciClient(), calling (non-static) sendAndReceive, and then closing the client.
+   * 
+   * @throws IllegalStateException
+   *           if the VNS host has not been specified.
+   * 
    * @pre in != null
    * @pre service_name != null
    * @pre factory != null
    * @pre socket_timeout >= 0
    */
-  static public Transportable sendAndReceive(Transportable in, String service_name, TransportableFactory factory,
-      int socket_timeout, int connect_timeout) throws IOException, ServiceException {
-    return VinciContext.getGlobalContext().sendAndReceive(in, service_name, factory, socket_timeout, connect_timeout);
+  static public Transportable sendAndReceive(Transportable in, String service_name,
+          TransportableFactory factory, int socket_timeout, int connect_timeout)
+          throws IOException, ServiceException {
+    return VinciContext.getGlobalContext().sendAndReceive(in, service_name, factory,
+            socket_timeout, connect_timeout);
   }
 
   /**
-   * Get the context associated with this client. By default clients use the global Vinci
-   * context, though this can be overridden.
+   * Get the context associated with this client. By default clients use the global Vinci context,
+   * though this can be overridden.
    */
   public VinciContext getContext() {
     if (context == null) {
@@ -251,24 +280,25 @@
   }
 
   /**
-   * Set the VinciContext to be used by this client. Set to null if you wish the global context
-   * to be used. You should set the context BEFORE a connection is open (e.g. ater using the
-   * no-arg constructor), otherwise the global context parameters will be used to establish the
-   * connection before you have a chance to change it.
+   * Set the VinciContext to be used by this client. Set to null if you wish the global context to
+   * be used. You should set the context BEFORE a connection is open (e.g. ater using the no-arg
+   * constructor), otherwise the global context parameters will be used to establish the connection
+   * before you have a chance to change it.
    */
   public void setContext(VinciContext c) {
     context = c;
   }
 
   /**
-   * Get the fully qualified name of this service. This method is useful when for whatever
-   * reason a connection needs to be re-established with this exact same service instance. This
-   * method only works after connection has been established.  
-   *
+   * Get the fully qualified name of this service. This method is useful when for whatever reason a
+   * connection needs to be re-established with this exact same service instance. This method only
+   * works after connection has been established.
+   * 
    * @pre getHost() != null
    */
   public String getQualifiedServiceName() {
-    return ResolveResult.unqualifiedName(serviceName) + '[' + getLevel() + ',' + getHost() + ',' + getInstance() + ']';
+    return ResolveResult.unqualifiedName(serviceName) + '[' + getLevel() + ',' + getHost() + ','
+            + getInstance() + ']';
   }
 
   public String getServiceName() {
@@ -276,18 +306,22 @@
   }
 
   /**
-   * Connects the client to the specified service as delegated by VNS. Use this open method
-   * in conjunction with the no-arg VinciClient constructor.
-   *
-   * @param serviceName The name of the service to connect to.
-   * @throws ServiceDownException Thrown when either (1) VNS is inaccessible
-   * or (2) none of the servers registered under serviceName are accessible.
-   * @throws VNSException Thrown when VNS is accessible but reports an error,
-   * which should almost always indicate that the requested service is not registered.
+   * Connects the client to the specified service as delegated by VNS. Use this open method in
+   * conjunction with the no-arg VinciClient constructor.
+   * 
+   * @param serviceName
+   *          The name of the service to connect to.
+   * @throws ServiceDownException
+   *           Thrown when either (1) VNS is inaccessible or (2) none of the servers registered
+   *           under serviceName are accessible.
+   * @throws VNSException
+   *           Thrown when VNS is accessible but reports an error, which should almost always
+   *           indicate that the requested service is not registered.
    * 
    * @pre service_name != null
-   *
-   * @throws IllegalStateException if no VNS_HOST has been specified.
+   * 
+   * @throws IllegalStateException
+   *           if no VNS_HOST has been specified.
    */
   public void open(String service_name) throws ServiceDownException, VNSException {
     this.serviceName = service_name;
@@ -301,7 +335,8 @@
     String vnsHost = myContext.getVNSHost();
     int vnsPort = myContext.getVNSPort();
 
-    // Check to see if default host/port are being overridden by vns "@" specification in service name
+    // Check to see if default host/port are being overridden by vns "@" specification in service
+    // name
     int atIndex = service_name.indexOf('@');
     if (atIndex != -1) {
       vnsHost = service_name.substring(atIndex + 1);
@@ -317,7 +352,7 @@
     }
 
     // ^^ A list of service locations that have already been determined to be
-    // unavailable. 
+    // unavailable.
     for (;;) {
       try {
         response = myContext.getCachedResolveResult(serviceName);
@@ -326,8 +361,8 @@
           if (query == null) {
             query = ResolveResult.composeQuery(serviceName);
           }
-          response = (ResolveResult) BaseClient.sendAndReceive(query, vnsHost, vnsPort, ResolveResult.factory,
-              myContext.getVNSResolveTimeout());
+          response = (ResolveResult) BaseClient.sendAndReceive(query, vnsHost, vnsPort,
+                  ResolveResult.factory, myContext.getVNSResolveTimeout());
           myContext.cacheResolveResult(serviceName, response);
         } else {
           usedCache = true;
@@ -363,8 +398,8 @@
             Debug.p("Resolved " + serviceName + " to: " + locator.host + ":" + locator.port);
             return;
           } catch (IOException e) {
-            Debug.p("WARNING: Failed to connect to service at (" + locator.host + ":" + locator.port + "):"
-                + e.getMessage());
+            Debug.p("WARNING: Failed to connect to service at (" + locator.host + ":"
+                    + locator.port + "):" + e.getMessage());
             connectFailed = true;
             if (alreadyTried == null) {
               alreadyTried = new ArrayList();
@@ -381,7 +416,8 @@
       } else if (response.priority != 0 && !ResolveResult.isQualified(serviceName)) {
         // If a service name was specified without qualifications, then
         // we allow fail-over to lower-priority services.
-        Debug.p("VinciClient.open(String)", "Resolving with lower priority than: " + response.priority);
+        Debug.p("VinciClient.open(String)", "Resolving with lower priority than: "
+                + response.priority);
         myContext.flushFromCache(serviceName);
         int next_level = response.priority;
         if (next_level == -1) {
@@ -411,52 +447,54 @@
    * Same as VinciClient.sendAndReceive(Transportable) except for return type. Syntactic sugar
    * method for the case where return result is known to be VinciFrame (eliminates the need for
    * casting in the typical usage case).
-   *
-   * @throws IllegalStateException if the VNS host has not been specified.
+   * 
+   * @throws IllegalStateException
+   *           if the VNS host has not been specified.
    * @return A VinciFrame representing the service result.
    * 
    * @pre in != null
    * @pre service_name != null
    */
-  static public VinciFrame rpc(Transportable in, String service_name) throws IOException, ServiceException,
-      ServiceDownException, VNSException {
+  static public VinciFrame rpc(Transportable in, String service_name) throws IOException,
+          ServiceException, ServiceDownException, VNSException {
     return VinciContext.getGlobalContext().rpc(in, service_name);
   }
 
   /**
-   * Same as VinciClient.sendAndReceive(Transportable, service_name) except it also takes a
-   * timeout value.  WARNING: This method "hides" the BaseClient rpc method with the same
-   * signature. The BaseClient method accepts (Transportable, host string, port) whereas this
-   * one accepts (Transportable, service_name, timeout).  Despite the equivalent signatures, the
-   * semantics of these two methods are quite different.
-   *
-   * @return A VinciFrame representing the service result.  
-   *
+   * Same as VinciClient.sendAndReceive(Transportable, service_name) except it also takes a timeout
+   * value. WARNING: This method "hides" the BaseClient rpc method with the same signature. The
+   * BaseClient method accepts (Transportable, host string, port) whereas this one accepts
+   * (Transportable, service_name, timeout). Despite the equivalent signatures, the semantics of
+   * these two methods are quite different.
+   * 
+   * @return A VinciFrame representing the service result.
+   * 
    * @pre in != null
    * @pre service_name != null
    * @pre timeout >= 0
    */
-  static public VinciFrame rpc(Transportable in, String service_name, int timeout) throws IOException,
-      ServiceException, ServiceDownException, VNSException {
+  static public VinciFrame rpc(Transportable in, String service_name, int timeout)
+          throws IOException, ServiceException, ServiceDownException, VNSException {
     return VinciContext.getGlobalContext().rpc(in, service_name, timeout);
   }
 
   /**
    * Same as VinciClient.sendAndReceive(Transportable, service_name) except it also takes socket
-   * read and socket connect timeout values.  WARNING: This method "hides" the BaseClient rpc
-   * method with the same signature. The BaseClient method accepts (Transportable, host string,
-   * port) whereas this one accepts (Transportable, service_name, timeout).  Despite the
-   * equivalent signatures, the semantics of these two methods are quite different.
-   *
-   * @return A VinciFrame representing the service result.  
-   *
+   * read and socket connect timeout values. WARNING: This method "hides" the BaseClient rpc method
+   * with the same signature. The BaseClient method accepts (Transportable, host string, port)
+   * whereas this one accepts (Transportable, service_name, timeout). Despite the equivalent
+   * signatures, the semantics of these two methods are quite different.
+   * 
+   * @return A VinciFrame representing the service result.
+   * 
    * @pre in != null
    * @pre service_name != null
    * @pre timeout >= 0
    * @pre connect_timeout > 0
    */
-  static public VinciFrame rpc(Transportable in, String service_name, int timeout, int connect_timeout)
-      throws IOException, ServiceException, ServiceDownException, VNSException {
+  static public VinciFrame rpc(Transportable in, String service_name, int timeout,
+          int connect_timeout) throws IOException, ServiceException, ServiceDownException,
+          VNSException {
     return VinciContext.getGlobalContext().rpc(in, service_name, timeout, connect_timeout);
   }
 

Modified: incubator/uima/uimaj/trunk/jVinci/src/main/java/org/apache/vinci/transport/VinciFrame.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/jVinci/src/main/java/org/apache/vinci/transport/VinciFrame.java?view=diff&rev=480242&r1=480241&r2=480242
==============================================================================
--- incubator/uima/uimaj/trunk/jVinci/src/main/java/org/apache/vinci/transport/VinciFrame.java (original)
+++ incubator/uima/uimaj/trunk/jVinci/src/main/java/org/apache/vinci/transport/VinciFrame.java Tue Nov 28 14:21:50 2006
@@ -25,24 +25,26 @@
 
 /**
  * This is the "default" document class for use with the Vinci client and servable classes.
- * VinciFrame implements a queryable frame from (nested) ArrayList data structures. Search time
- * for a named tag is O(n) in the number of keys at a given depth, which is fine for all but the
- * largest documents.
- *
+ * VinciFrame implements a queryable frame from (nested) ArrayList data structures. Search time for
+ * a named tag is O(n) in the number of keys at a given depth, which is fine for all but the largest
+ * documents.
+ * 
  * VinciFrame complements the QueryableFrame adders and getters with several setter methods
  * [fset(String, *)] for modifying the values of designated tags.
  */
 public class VinciFrame extends QueryableFrame {
 
-  private int                         capacity;
-  private int                         size;
-  private KeyValuePair[]              elements;
+  private int capacity;
+
+  private int size;
+
+  private KeyValuePair[] elements;
 
   private static TransportableFactory vinciFrameFactory = new TransportableFactory() {
-                                                          public Transportable makeTransportable() {
-                                                            return new VinciFrame();
-                                                          }
-                                                        };
+    public Transportable makeTransportable() {
+      return new VinciFrame();
+    }
+  };
 
   /**
    * Get a TransportableFactory that creates new VinciFrames.
@@ -69,10 +71,11 @@
 
   /**
    * Create a new empty VinciFrame with the specified initial capacity.
-   *
-   * @param initialCapacity the capacity value to be passed on to the internal ArrayList used
-   * for holding KeyValuePairs. 
-   *
+   * 
+   * @param initialCapacity
+   *          the capacity value to be passed on to the internal ArrayList used for holding
+   *          KeyValuePairs.
+   * 
    * @pre initialCapacity >= 0
    */
   public VinciFrame(int initialCapacity) {
@@ -82,10 +85,9 @@
   }
 
   /**
-   * Returns a ArrayList of all the keys at the top-level of this frame, removing any
-   * duplicates.
-   *
-   * @return A ArrayList of keys.  
+   * Returns a ArrayList of all the keys at the top-level of this frame, removing any duplicates.
+   * 
+   * @return A ArrayList of keys.
    */
   public ArrayList fkeys() {
     ArrayList rval = new ArrayList();
@@ -98,7 +100,7 @@
     return rval;
   }
 
-  /** 
+  /**
    * Implementation of the abstract fget method defined in QueryableFrame.
    */
   public ArrayList fget(String key) {
@@ -112,7 +114,7 @@
     return return_me;
   }
 
-  /** 
+  /**
    * Implementation of the abstract fgetFirst method defined in QueryableFrame.
    */
   public FrameComponent fgetFirst(String key) {
@@ -127,7 +129,7 @@
 
   /**
    * Override the createSubFrame to create a VinciFrame of precise capacity.
-   *
+   * 
    * @pre tag_name != null
    * @pre initialCapacity >= 0
    */
@@ -137,9 +139,11 @@
 
   /**
    * Convenience method for fetching sub-frames when their type is known to be VinciFrame
-   *
-   * @param key The key identifying the value to retrieve.
-   * @exception ClassCastException (unchecked) if the value was not of type VinciFrame.
+   * 
+   * @param key
+   *          The key identifying the value to retrieve.
+   * @exception ClassCastException
+   *              (unchecked) if the value was not of type VinciFrame.
    * @return The requested value, or null if the specified key does not exist.
    */
   public VinciFrame fgetVinciFrame(String key) {
@@ -147,11 +151,12 @@
   }
 
   /**
-   * Change the value associated with first occurence of the given key to val. If the key
-   * doesn't exist, then the value is added.
-   *
-   * @exception NullPointerException if val is null.  
-   *
+   * Change the value associated with first occurence of the given key to val. If the key doesn't
+   * exist, then the value is added.
+   * 
+   * @exception NullPointerException
+   *              if val is null.
+   * 
    * @pre key != null
    * @pre val != null
    */
@@ -162,7 +167,7 @@
 
   /**
    * Change the value associated with the first occurence of the given key to val. If the key
-   * doesn't exist, then the value is added.  
+   * doesn't exist, then the value is added.
    * 
    * @pre key != null
    */
@@ -173,8 +178,8 @@
 
   /**
    * Change the value associated with the first occurence of the given key to val. If the key
-   * doesn't exist, then the value is added. 
-   *
+   * doesn't exist, then the value is added.
+   * 
    * @pre key != null
    */
   public VinciFrame fset(String key, boolean val) {
@@ -184,8 +189,8 @@
 
   /**
    * Change the value associated with the first occurence of the given key to val. If the key
-   * doesn't exist, then the value is added. 
-   *
+   * doesn't exist, then the value is added.
+   * 
    * @pre key != null
    */
   public VinciFrame fset(String key, int val) {
@@ -196,7 +201,7 @@
   /**
    * Change the value associated with the first occurence of the given key to val. If the key
    * doesn't exist, then the value is added.
-   *
+   * 
    * @pre key != null
    * @pre val != null
    */
@@ -208,9 +213,10 @@
   /**
    * Change the value associated with the first occurence of the given key to val. If the key
    * doesn't exist, then the value is added.
-   *
-   * @exception NullPointerException if val is null.  
-   *
+   * 
+   * @exception NullPointerException
+   *              if val is null.
+   * 
    * @pre key != null
    */
   public VinciFrame fset(String key, Frame val) {
@@ -220,8 +226,8 @@
 
   /**
    * Change the value associated with the first occurence of the given key to val. If the key
-   * doesn't exist, then the value is added.  
-   *
+   * doesn't exist, then the value is added.
+   * 
    * @pre key != null
    */
   public VinciFrame fset(String key, double val) {
@@ -232,9 +238,10 @@
   /**
    * Change the value associated with the first occurence of the given key to val. If the key
    * doesn't exist, then the value is added.
-   *
-   * @exception NullPointerException if bin is null.  
-   *
+   * 
+   * @exception NullPointerException
+   *              if bin is null.
+   * 
    * @pre key != null
    * @pre bin != null
    */
@@ -245,11 +252,12 @@
 
   /**
    * Change the value associated with the first occurence of the given key to val. If the key
-   * doesn't exist, then the value is added. The warnings associated with faddTrueBinary also
-   * apply to this method.
-   *
-   * @exception NullPointerException if bin is null.  
-   *
+   * doesn't exist, then the value is added. The warnings associated with faddTrueBinary also apply
+   * to this method.
+   * 
+   * @exception NullPointerException
+   *              if bin is null.
+   * 
    * @pre key != null
    * @pre bin != null
    */
@@ -260,11 +268,12 @@
 
   /**
    * Change the value associated with the first occurence of the given key to val. If the key
-   * doesn't exist, then the value is added. Note that there is no suite of methods to change
-   * *all* values associated with a given key to some value.
-   *
-   * @exception NullPointerException if val is null.  
-   *
+   * doesn't exist, then the value is added. Note that there is no suite of methods to change *all*
+   * values associated with a given key to some value.
+   * 
+   * @exception NullPointerException
+   *              if val is null.
+   * 
    * @pre key != null
    */
   protected void set(String key, FrameComponent val) {
@@ -283,11 +292,12 @@
   }
 
   /**
-   * Remove only the first element whose tag name matches the specified key (if any) from the
-   * top level of this frame.
+   * Remove only the first element whose tag name matches the specified key (if any) from the top
+   * level of this frame.
    * 
-   * @param key The tag name of the element to remove.
-   * @return this object (NOT the component dropped).  
+   * @param key
+   *          The tag name of the element to remove.
+   * @return this object (NOT the component dropped).
    */
   public VinciFrame fdropFirst(String key) {
     for (int i = 0; i < size; i++) {
@@ -303,11 +313,12 @@
   }
 
   /**
-   * Remove all elements whose tag name matches the provided key (if any) from the top level of
-   * this frame.
+   * Remove all elements whose tag name matches the provided key (if any) from the top level of this
+   * frame.
    * 
-   * @param key The tag name of the elements to remove.
-   * @return this object (NOT the component dropped).  
+   * @param key
+   *          The tag name of the elements to remove.
+   * @return this object (NOT the component dropped).
    */
   public VinciFrame fdrop(String key) {
     int shift = 0;
@@ -341,7 +352,7 @@
 
   /**
    * Implementation of the abstract Frame method.
-   *
+   * 
    * @pre key != null
    * @pre val != null
    */
@@ -364,7 +375,7 @@
 
   /**
    * Implementation of the abstract Frame method.
-   *
+   * 
    * @pre which < getKeyValuePairCount()
    * @pre which >= 0
    */

Modified: incubator/uima/uimaj/trunk/jVinci/src/main/java/org/apache/vinci/transport/VinciServable.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/jVinci/src/main/java/org/apache/vinci/transport/VinciServable.java?view=diff&rev=480242&r1=480241&r2=480242
==============================================================================
--- incubator/uima/uimaj/trunk/jVinci/src/main/java/org/apache/vinci/transport/VinciServable.java (original)
+++ incubator/uima/uimaj/trunk/jVinci/src/main/java/org/apache/vinci/transport/VinciServable.java Tue Nov 28 14:21:50 2006
@@ -26,13 +26,15 @@
 public interface VinciServable extends TransportableFactory {
 
   /**
-   * The eval method accepts an input document and returns an output document
-   * that is the result of performing the service. 
+   * The eval method accepts an input document and returns an output document that is the result of
+   * performing the service.
    * 
    * @return The output document
-   * @param in The input document
-   * @exception ServiceException thrown when there is an application level error that should
-   * result in the client receiving the same ServiceException on the other end.
+   * @param in
+   *          The input document
+   * @exception ServiceException
+   *              thrown when there is an application level error that should result in the client
+   *              receiving the same ServiceException on the other end.
    */
   Transportable eval(Transportable in) throws ServiceException;
 

Modified: incubator/uima/uimaj/trunk/jVinci/src/main/java/org/apache/vinci/transport/VinciServableAdapter.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/jVinci/src/main/java/org/apache/vinci/transport/VinciServableAdapter.java?view=diff&rev=480242&r1=480241&r2=480242
==============================================================================
--- incubator/uima/uimaj/trunk/jVinci/src/main/java/org/apache/vinci/transport/VinciServableAdapter.java (original)
+++ incubator/uima/uimaj/trunk/jVinci/src/main/java/org/apache/vinci/transport/VinciServableAdapter.java Tue Nov 28 14:21:50 2006
@@ -20,8 +20,8 @@
 package org.apache.vinci.transport;
 
 /**
- * Adapter class for VinciServable, which provides a do-nothing cleanExit() method and
- * a TransportableFactory that returns a VinciFrame.
+ * Adapter class for VinciServable, which provides a do-nothing cleanExit() method and a
+ * TransportableFactory that returns a VinciFrame.
  */
 public abstract class VinciServableAdapter implements VinciServable {
   public abstract Transportable eval(Transportable in) throws ServiceException;

Modified: incubator/uima/uimaj/trunk/jVinci/src/main/java/org/apache/vinci/transport/VinciServer.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/jVinci/src/main/java/org/apache/vinci/transport/VinciServer.java?view=diff&rev=480242&r1=480241&r2=480242
==============================================================================
--- incubator/uima/uimaj/trunk/jVinci/src/main/java/org/apache/vinci/transport/VinciServer.java (original)
+++ incubator/uima/uimaj/trunk/jVinci/src/main/java/org/apache/vinci/transport/VinciServer.java Tue Nov 28 14:21:50 2006
@@ -29,35 +29,38 @@
 import org.apache.vinci.transport.vns.client.ServeonResult;
 
 /**
- * "Standard" service container for a VinciServable. This extends BaseServer with functions
- * allowing port negotiation via interaction with VNS. It also provides rudimentary support for
- * service control and monitoring by responding to vinci:SHUTDOWN and vinci:PING.
- *
- * Note that this server class directs requests to a single VinciServable. For many applications
- * it may be desirable to have one server accept requests that get delegated to multiple services,
- * not just a single service. For such applications consider using the MultiplexedServer. You can
- * also implement a VinciServable that implements its own sub-service delegation scheme.
- *
+ * "Standard" service container for a VinciServable. This extends BaseServer with functions allowing
+ * port negotiation via interaction with VNS. It also provides rudimentary support for service
+ * control and monitoring by responding to vinci:SHUTDOWN and vinci:PING.
+ * 
+ * Note that this server class directs requests to a single VinciServable. For many applications it
+ * may be desirable to have one server accept requests that get delegated to multiple services, not
+ * just a single service. For such applications consider using the MultiplexedServer. You can also
+ * implement a VinciServable that implements its own sub-service delegation scheme.
+ * 
  */
 public class VinciServer extends BaseServer {
 
-  private int          priority    = 0;
-  private int          instance    = 0;
-  private String       hostName    = null;
-  private String       serviceName = null;
+  private int priority = 0;
+
+  private int instance = 0;
+
+  private String hostName = null;
+
+  private String serviceName = null;
 
   // Port gets set via VNS port negotiation once serving
   // is initiated.
-  private volatile int port        = -1;
+  private volatile int port = -1;
 
-  private VinciContext context     = null;
+  private VinciContext context = null;
 
   /**
-   * Create a new server. If an incorrect hostname is provided, this server will not be
-   * reachable.
-   *
-   * @param host_name The DNS hostname of the machine running this server.
-   *
+   * Create a new server. If an incorrect hostname is provided, this server will not be reachable.
+   * 
+   * @param host_name
+   *          The DNS hostname of the machine running this server.
+   * 
    * @pre service_name != null
    * @pre host_name != null
    * @pre servable != null
@@ -67,11 +70,12 @@
   }
 
   /**
-   * Create a new server that reports the current machine's IP address as the host.
-   * This should not be used for DHCP-based hosts since IP address can change.
-   *
-   * @throws UnknownHostException If there is an error determining machine IP address.
-   *
+   * Create a new server that reports the current machine's IP address as the host. This should not
+   * be used for DHCP-based hosts since IP address can change.
+   * 
+   * @throws UnknownHostException
+   *           If there is an error determining machine IP address.
+   * 
    * @pre service_name != null
    * @pre servable != null
    */
@@ -81,14 +85,15 @@
 
   /**
    * Create a new server.
-   *
+   * 
    * @pre service_name != null
    * @pre host_name != null
    * @pre servable != null
    * @pre myPriority >= -1
    * @pre myInstance >= 0
    */
-  public VinciServer(String service_name, String host_name, VinciServable servable, int myPriority, int myInstance) {
+  public VinciServer(String service_name, String host_name, VinciServable servable, int myPriority,
+          int myInstance) {
     super(servable);
     this.priority = myPriority;
     this.serviceName = service_name;
@@ -111,7 +116,8 @@
    * @pre servable != null
    * @pre myPriority >= -1
    */
-  public VinciServer(String service_name, VinciServable servable, int myPriority) throws UnknownHostException {
+  public VinciServer(String service_name, VinciServable servable, int myPriority)
+          throws UnknownHostException {
     this(service_name, InetAddress.getLocalHost().getHostAddress(), servable, myPriority);
   }
 
@@ -122,7 +128,7 @@
    * @pre myInstance >= 0
    */
   public VinciServer(String service_name, VinciServable servable, int myPriority, int myInstance)
-      throws UnknownHostException {
+          throws UnknownHostException {
     this(service_name, InetAddress.getLocalHost().getHostName(), servable, myPriority, myInstance);
   }
 
@@ -134,8 +140,8 @@
   }
 
   /**
-   * Get the context associated with this server. By default clients use the global Vinci
-   * context, though this can be overridden.
+   * Get the context associated with this server. By default clients use the global Vinci context,
+   * though this can be overridden.
    */
   public VinciContext getContext() {
     if (context == null) {
@@ -162,9 +168,9 @@
   }
 
   /**
-   * After invoking serve() or startServing(), this method can be used to determine
-   * the port which was negotiated with VNS on which to serve requests.
-   *
+   * After invoking serve() or startServing(), this method can be used to determine the port which
+   * was negotiated with VNS on which to serve requests.
+   * 
    * @since 2.0.15
    */
   public int getServingPort() {
@@ -172,24 +178,26 @@
   }
 
   /**
-   * Set the VinciContext to be used by this server. Set to null if you wish the global
-   * context to be used.
+   * Set the VinciContext to be used by this server. Set to null if you wish the global context to
+   * be used.
    */
   public void setContext(VinciContext c) {
     context = c;
   }
 
   /**
-   * Serve requests until a clean shutdown is triggered. Note that all three exceptions thrown
-   * by this method are IOExceptions so a single IOException catch phrase is sufficient
-   * unless it is important to determine the particular failure.
-   *
-   * @throws ServiceDownException Thrown if there was a failure to contact VNS for port
-   * negotiation.
-   * @throws VNSException Typically thrown if VNS does not recognize the service provided by
-   * this server.
-   * @throws IOException Thrown if there was some problem with the server socket. 
-   * @throws IllegalStateException if VNS host is not specified.
+   * Serve requests until a clean shutdown is triggered. Note that all three exceptions thrown by
+   * this method are IOExceptions so a single IOException catch phrase is sufficient unless it is
+   * important to determine the particular failure.
+   * 
+   * @throws ServiceDownException
+   *           Thrown if there was a failure to contact VNS for port negotiation.
+   * @throws VNSException
+   *           Typically thrown if VNS does not recognize the service provided by this server.
+   * @throws IOException
+   *           Thrown if there was some problem with the server socket.
+   * @throws IllegalStateException
+   *           if VNS host is not specified.
    */
   public void serve() throws ServiceDownException, VNSException, IOException {
     this.port = getPort();
@@ -198,18 +206,20 @@
   }
 
   /**
-   * Start a new thread that will serve requests until a clean shutdown is triggered. Note that
-   * all three exceptions thrown by this method are IOExceptions so a single IOException catch
-   * phrase is sufficient unless it is important to determine the particular failure. If this
-   * method returns without throwing an exception then the port has been determined and a new
-   * thread has been launched.
-   *
-   * @throws ServiceDownException Thrown if there was a failure to
-   * contact VNS for port negotiation.
-   * @throws VNSException Typically thrown if VNS does not recognize the service provided by
-   * this server.
-   * @throws IOException Thrown if there was some problem with the server socket. 
-   * @throws IllegalStateException if VNS host is not specified.
+   * Start a new thread that will serve requests until a clean shutdown is triggered. Note that all
+   * three exceptions thrown by this method are IOExceptions so a single IOException catch phrase is
+   * sufficient unless it is important to determine the particular failure. If this method returns
+   * without throwing an exception then the port has been determined and a new thread has been
+   * launched.
+   * 
+   * @throws ServiceDownException
+   *           Thrown if there was a failure to contact VNS for port negotiation.
+   * @throws VNSException
+   *           Typically thrown if VNS does not recognize the service provided by this server.
+   * @throws IOException
+   *           Thrown if there was some problem with the server socket.
+   * @throws IllegalStateException
+   *           if VNS host is not specified.
    * @since 2.0.15
    */
   public void startServing() throws ServiceDownException, VNSException, IOException {
@@ -226,28 +236,29 @@
   }
 
   /**
-   * Factory method for creating a shutdown message. Send the returned object to 
-   * any server, and if it is programmed to respond to shutdown, it will do so.
-   *
-   * @param shutdown_message Should be used to pass a message explaining the shutdown,
-   * or in the future it may also include authentication information for password-protected
-   * shutdown.
+   * Factory method for creating a shutdown message. Send the returned object to any server, and if
+   * it is programmed to respond to shutdown, it will do so.
+   * 
+   * @param shutdown_message
+   *          Should be used to pass a message explaining the shutdown, or in the future it may also
+   *          include authentication information for password-protected shutdown.
    */
   public static Transportable createShutdownCommand(String shutdown_message) {
     return new VinciFrame().fadd(TransportConstants.SHUTDOWN_KEY, shutdown_message);
   }
 
   /**
-   * This method is called by the server when a remote shutdown request is received. In general
-   * if you want to stop the server call shutdownServing() -- this method should have probably
-   * been declared "protected".  You can override this method if you want the shutdown message
-   * to be ignored in certain cases.
+   * This method is called by the server when a remote shutdown request is received. In general if
+   * you want to stop the server call shutdownServing() -- this method should have probably been
+   * declared "protected". You can override this method if you want the shutdown message to be
+   * ignored in certain cases.
    */
   public boolean shutdown(String shutdown_message) {
     // Override this method if shutdown is to be ignored in certain cases (by returning
-    // false). Default implementation unconditionally halts serving, 
+    // false). Default implementation unconditionally halts serving,
     // and hence always returns true.
-    Debug.printDebuggingMessage("VinciServer.shutdown()", "Accepted shutdown request: " + shutdown_message);
+    Debug.printDebuggingMessage("VinciServer.shutdown()", "Accepted shutdown request: "
+            + shutdown_message);
     new Thread(new Runnable() {
       public void run() {
         try {
@@ -263,14 +274,15 @@
   }
 
   /**
-   * @throws IllegalStateException if VNS host isn't specified.
+   * @throws IllegalStateException
+   *           if VNS host isn't specified.
    */
   protected int getPort() throws ServiceDownException, VNSException {
     try {
       VinciContext myContext = getContext();
-      ServeonResult response = (ServeonResult) VinciClient.sendAndReceive(ServeonResult.composeQuery(serviceName,
-          hostName, priority, instance), myContext.getVNSHost(), myContext.getVNSPort(), ServeonResult.factory,
-          myContext.getVNSServeonTimeout());
+      ServeonResult response = (ServeonResult) VinciClient.sendAndReceive(ServeonResult
+              .composeQuery(serviceName, hostName, priority, instance), myContext.getVNSHost(),
+              myContext.getVNSPort(), ServeonResult.factory, myContext.getVNSServeonTimeout());
       return response.port;
     } catch (IOException e) {
       Debug.reportException(e);

Modified: incubator/uima/uimaj/trunk/jVinci/src/main/java/org/apache/vinci/transport/VinciServerRunnable.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/jVinci/src/main/java/org/apache/vinci/transport/VinciServerRunnable.java?view=diff&rev=480242&r1=480241&r2=480242
==============================================================================
--- incubator/uima/uimaj/trunk/jVinci/src/main/java/org/apache/vinci/transport/VinciServerRunnable.java (original)
+++ incubator/uima/uimaj/trunk/jVinci/src/main/java/org/apache/vinci/transport/VinciServerRunnable.java Tue Nov 28 14:21:50 2006
@@ -38,12 +38,14 @@
     if (header != null) {
       if (header.key.equals(TransportConstants.SHUTDOWN_KEY)) {
         if (((VinciServer) getParent()).shutdown(header.getValueAsString())) {
-          out = (VinciFrame) new VinciFrame().fadd(TransportConstants.STATUS_KEY, TransportConstants.OK_VALUE);
+          out = (VinciFrame) new VinciFrame().fadd(TransportConstants.STATUS_KEY,
+                  TransportConstants.OK_VALUE);
         } else {
           out = new ErrorFrame("Shutdown request ignored.");
         }
       } else if (header.key.equals(TransportConstants.PING_KEY)) {
-        out = (VinciFrame) new VinciFrame().fadd(TransportConstants.STATUS_KEY, TransportConstants.OK_VALUE);
+        out = (VinciFrame) new VinciFrame().fadd(TransportConstants.STATUS_KEY,
+                TransportConstants.OK_VALUE);
       }
     }
     return out;

Modified: incubator/uima/uimaj/trunk/jVinci/src/main/java/org/apache/vinci/transport/XTalkTransporter.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/jVinci/src/main/java/org/apache/vinci/transport/XTalkTransporter.java?view=diff&rev=480242&r1=480241&r2=480242
==============================================================================
--- incubator/uima/uimaj/trunk/jVinci/src/main/java/org/apache/vinci/transport/XTalkTransporter.java (original)
+++ incubator/uima/uimaj/trunk/jVinci/src/main/java/org/apache/vinci/transport/XTalkTransporter.java Tue Nov 28 14:21:50 2006
@@ -32,22 +32,26 @@
  */
 public class XTalkTransporter implements FrameTransporter {
 
-  static private final int    OVERSIZE_KEY_LENGTH = 1024 * 1024 * 1024;
-  static public final byte    DOCUMENT_MARKER     = (byte) 'X';
-  static public final byte    ELEMENT_MARKER      = (byte) 'E';
-  static public final byte    PI_MARKER           = (byte) 'p';
-  static public final byte    STRING_MARKER       = (byte) 's';
-  static public final byte    VERSION_CODE        = (byte) 0;
+  static private final int OVERSIZE_KEY_LENGTH = 1024 * 1024 * 1024;
 
-  static final private String OVERSIZE_FIELD      = "Oversize field: ";
+  static public final byte DOCUMENT_MARKER = (byte) 'X';
+
+  static public final byte ELEMENT_MARKER = (byte) 'E';
+
+  static public final byte PI_MARKER = (byte) 'p';
+
+  static public final byte STRING_MARKER = (byte) 's';
+
+  static public final byte VERSION_CODE = (byte) 0;
+
+  static final private String OVERSIZE_FIELD = "Oversize field: ";
 
   /**
    * Parse the data-stream according to the XTalk protocol.
    * 
-   * @return If the first tag belongs to the Vinci namespace, then this
-   *         tag/value combination is returned. Otherwise returns null. Should
-   *         there be a non-null return, then the value object of the
-   *         KeyValuePair can be either FrameLeaf or Frame.
+   * @return If the first tag belongs to the Vinci namespace, then this tag/value combination is
+   *         returned. Otherwise returns null. Should there be a non-null return, then the value
+   *         object of the KeyValuePair can be either FrameLeaf or Frame.
    * @pre is != null
    * @pre f != null
    */
@@ -74,10 +78,12 @@
     return fromStreamWork(is, f, new byte[128], new char[128]);
   }
 
-  public KeyValuePair fromStreamWork(InputStream is, Frame f, byte[] buffer, char[] cbuffer) throws IOException {
+  public KeyValuePair fromStreamWork(InputStream is, Frame f, byte[] buffer, char[] cbuffer)
+          throws IOException {
     int version = is.read();
     if ((byte) version != VERSION_CODE) {
-      throw new IOException("Xtalk version code doesn't match " + (int) VERSION_CODE + ": " + version);
+      throw new IOException("Xtalk version code doesn't match " + (int) VERSION_CODE + ": "
+              + version);
     }
     int top_field_count = readInt(is);
     // Skip over intro PI's.
@@ -111,7 +117,8 @@
    * 
    * @pre is != null
    */
-  private Attributes consumeAttributes(InputStream is, byte[] buffer, char[] cbuffer) throws IOException {
+  private Attributes consumeAttributes(InputStream is, byte[] buffer, char[] cbuffer)
+          throws IOException {
     int attribute_count = readInt(is);
     if (attribute_count < 1) {
       return null;
@@ -146,7 +153,8 @@
    * @pre is != null
    * @pre f != null
    */
-  public KeyValuePair consumeRootChildren(InputStream is, Frame f, byte[] buffer, char[] cbuffer) throws IOException {
+  public KeyValuePair consumeRootChildren(InputStream is, Frame f, byte[] buffer, char[] cbuffer)
+          throws IOException {
     consumeString(is, buffer, cbuffer); // ignore root tag name -- assume it's
     // always vinci:FRAME
     Attributes attributes = consumeAttributes(is, buffer, cbuffer);
@@ -181,7 +189,8 @@
    * @pre is != null
    * @pre f != null
    */
-  public KeyValuePair consumeRootElement(InputStream is, Frame f, byte[] buffer, char[] cbuffer) throws IOException {
+  public KeyValuePair consumeRootElement(InputStream is, Frame f, byte[] buffer, char[] cbuffer)
+          throws IOException {
     // This code returns the first ELEMENT as the KeyValuePair header, if its
     // tag
     // is from the Vinci namespace.
@@ -235,8 +244,8 @@
    * @pre is != null
    * @pre f != null
    */
-  public void consumeChildren(InputStream is, Frame f, int field_count, int marker, byte[] buffer, char[] cbuffer)
-      throws IOException {
+  public void consumeChildren(InputStream is, Frame f, int field_count, int marker, byte[] buffer,
+          char[] cbuffer) throws IOException {
     while (field_count > 0) {
       switch ((byte) marker) {
         case PI_MARKER:
@@ -297,8 +306,8 @@
   }
 
   /**
-   * Consume a string from the input stream. TODO: Make a faster version that
-   * exploits work buffers to reduce allocations to a single string object.
+   * Consume a string from the input stream. TODO: Make a faster version that exploits work buffers
+   * to reduce allocations to a single string object.
    * 
    * @param is
    * @return
@@ -316,7 +325,8 @@
     return UTFConverter.convertUTFToString(bytearr);
   }
 
-  static public String consumeString(InputStream is, byte[] buffer, char[] cbuffer) throws IOException {
+  static public String consumeString(InputStream is, byte[] buffer, char[] cbuffer)
+          throws IOException {
     int utflen = readInt(is);
     if (utflen > OVERSIZE_KEY_LENGTH) {
       throw new IOException(OVERSIZE_FIELD + utflen);
@@ -333,11 +343,11 @@
   }
 
   /**
-   * Consume the string of bytesToRead utf-8 bytes. assumes buffers are big
-   * enough to hold bytesToRead bytes/chars
+   * Consume the string of bytesToRead utf-8 bytes. assumes buffers are big enough to hold
+   * bytesToRead bytes/chars
    */
-  static public int consumeCharacters(InputStream is, byte[] byteBuf, char[] charBuf, int bytesToRead)
-      throws IOException {
+  static public int consumeCharacters(InputStream is, byte[] byteBuf, char[] charBuf,
+          int bytesToRead) throws IOException {
     readFully(byteBuf, bytesToRead, is);
     return UTFConverter.convertUTFToString(byteBuf, 0, bytesToRead, charBuf);
   }
@@ -438,8 +448,8 @@
   }
 
   /**
-   * Sends a string as utf8, using the temporary buffer if it is big enough to
-   * avoid allocating new memory.
+   * Sends a string as utf8, using the temporary buffer if it is big enough to avoid allocating new
+   * memory.
    */
   static public void stringToBin(String str, OutputStream os, byte[] buffer) throws IOException {
     byte[] newbuf;
@@ -459,13 +469,15 @@
     os.write(newbuf, 0, newlen);
   }
 
-  static public void stringToBin(char[] str, int begin, int len, OutputStream os) throws IOException {
+  static public void stringToBin(char[] str, int begin, int len, OutputStream os)
+          throws IOException {
     byte[] write_me = UTFConverter.convertStringToUTF(str, begin, len);
     writeInt(write_me.length, os);
     os.write(write_me);
   }
 
-  static public void stringToBin(char[] str, int begin, int len, OutputStream os, byte[] buffer) throws IOException {
+  static public void stringToBin(char[] str, int begin, int len, OutputStream os, byte[] buffer)
+          throws IOException {
     byte[] newbuf;
     if (buffer.length < (len - begin) * 3) {
       int byteslen = UTFConverter.calculateUTFLength(str, begin, len);
@@ -550,7 +562,8 @@
    * @pre os != null
    * @pre attributes != null
    */
-  public void attributesToBin(OutputStream os, Attributes attributes, byte[] workbuf) throws IOException {
+  public void attributesToBin(OutputStream os, Attributes attributes, byte[] workbuf)
+          throws IOException {
     int size = attributes.getKeyValuePairCount();
     writeInt(size, os);
     for (int i = 0; i < size; i++) {

Modified: incubator/uima/uimaj/trunk/jVinci/src/main/java/org/apache/vinci/transport/context/VinciContext.java
URL: http://svn.apache.org/viewvc/incubator/uima/uimaj/trunk/jVinci/src/main/java/org/apache/vinci/transport/context/VinciContext.java?view=diff&rev=480242&r1=480241&r2=480242
==============================================================================
--- incubator/uima/uimaj/trunk/jVinci/src/main/java/org/apache/vinci/transport/context/VinciContext.java (original)
+++ incubator/uima/uimaj/trunk/jVinci/src/main/java/org/apache/vinci/transport/context/VinciContext.java Tue Nov 28 14:21:50 2006
@@ -34,28 +34,38 @@
 import org.apache.vinci.transport.vns.client.ResolveResult;
 
 /**
- * <p>This class can be used to globally affect various behaviors of Vinci clients and servers
- * under its control (for example, which VNS to contact). There is one "global" VinciContext that
- * is used by default, though anyone can create an alternate context should multiple sets of
- * defaults be required in a single program. Each VinciContext also serves to cache resolve
- * results for all clients under its control (for a default of 1 minute). </p> 
- *
- * <p>For the most part, Vinci library users won't have to directly deal with this class, since
- * there is a global context used by default which is almost always adequate.</p>
- *
- * <p>The most common use of this class is to programmatically specify a VNS hostname other than
- * the default (which is the one specified by the Java property VNS_HOST).</p> 
+ * <p>
+ * This class can be used to globally affect various behaviors of Vinci clients and servers under
+ * its control (for example, which VNS to contact). There is one "global" VinciContext that is used
+ * by default, though anyone can create an alternate context should multiple sets of defaults be
+ * required in a single program. Each VinciContext also serves to cache resolve results for all
+ * clients under its control (for a default of 1 minute).
+ * </p>
+ * 
+ * <p>
+ * For the most part, Vinci library users won't have to directly deal with this class, since there
+ * is a global context used by default which is almost always adequate.
+ * </p>
+ * 
+ * <p>
+ * The most common use of this class is to programmatically specify a VNS hostname other than the
+ * default (which is the one specified by the Java property VNS_HOST).
+ * </p>
  */
 
 public class VinciContext {
 
-  public static final int     DEFAULT_VNS_CACHE_SIZE  = 1000;
+  public static final int DEFAULT_VNS_CACHE_SIZE = 1000;
 
-  private static final String VNS_HOST_PROPERTY       = "VNS_HOST";
-  private static final String VNS_HOST_PROPERTY_2     = "VNSHOST";
-  private static final String VNS_PORT_PROPERTY       = "VNS_PORT";
-  private static final String VNS_PORT_PROPERTY_2     = "VNSPORT";
-  private static final int    DEFAULT_VNS_PORT        = 9000;
+  private static final String VNS_HOST_PROPERTY = "VNS_HOST";
+
+  private static final String VNS_HOST_PROPERTY_2 = "VNSHOST";
+
+  private static final String VNS_PORT_PROPERTY = "VNS_PORT";
+
+  private static final String VNS_PORT_PROPERTY_2 = "VNSPORT";
+
+  private static final int DEFAULT_VNS_PORT = 9000;
 
   static private VinciContext globalContext;
   static {
@@ -81,23 +91,28 @@
     globalContext = new VinciContext(host, port);
   }
 
-  private static final int    DEFAULT_RESOLVE_TIMEOUT = 20000;
-  private static final int    DEFAULT_SERVEON_TIMEOUT = 60000;
+  private static final int DEFAULT_RESOLVE_TIMEOUT = 20000;
+
+  private static final int DEFAULT_SERVEON_TIMEOUT = 60000;
+
   // Default time to live for cached VNS entries.
-  private static final int    DEFAULT_TTL             = 60000;
+  private static final int DEFAULT_TTL = 60000;
+
+  private int vnsResolveTimeout = DEFAULT_RESOLVE_TIMEOUT;
 
-  private int                 vnsResolveTimeout       = DEFAULT_RESOLVE_TIMEOUT;
-  private int                 vnsServeonTimeout       = DEFAULT_SERVEON_TIMEOUT;
-  private int                 ttlMillis               = DEFAULT_TTL;
+  private int vnsServeonTimeout = DEFAULT_SERVEON_TIMEOUT;
+
+  private int ttlMillis = DEFAULT_TTL;
 
   // Whether or not to use stale cached entries
   // in the event VNS is inaccessible.
-  private boolean             allowStaleLookups       = true;
+  private boolean allowStaleLookups = true;
+
+  private int vnsCacheSize = DEFAULT_VNS_CACHE_SIZE;
 
-  private int                 vnsCacheSize            = DEFAULT_VNS_CACHE_SIZE;
+  private String host;
 
-  private String              host;
-  private int                 port;
+  private int port;
 
   static class CachedVNSResult {
     CachedVNSResult(ResolveResult r) {
@@ -106,26 +121,28 @@
     }
 
     ResolveResult r;
-    long          entryTime;
+
+    long entryTime;
   }
 
   /**
-   * Set the size of the VNS cache. This method can be invoked at any time, however if the cache size
-   * is ever reduced, it might not take effect.
+   * Set the size of the VNS cache. This method can be invoked at any time, however if the cache
+   * size is ever reduced, it might not take effect.
    * 
-   * @param to The limit on the number of entries that will be maintained in the VNS cache.
+   * @param to
+   *          The limit on the number of entries that will be maintained in the VNS cache.
    */
   synchronized public void setVNSCacheSize(int to) {
     vnsCacheSize = to;
   }
 
   private LinkedHashMap vnsCache = new LinkedHashMap(16, .75f, true) {
-                                   private static final long serialVersionUID = 7138871637782205744L;
+    private static final long serialVersionUID = 7138871637782205744L;
 
-                                   protected boolean removeEldestEntry(Map.Entry e) {
-                                     return size() > vnsCacheSize;
-                                   }
-                                 };
+    protected boolean removeEldestEntry(Map.Entry e) {
+      return size() > vnsCacheSize;
+    }
+  };
 
   /**
    * @pre myport >= 0
@@ -137,33 +154,33 @@
   }
 
   /**
-   * Return the VNS hostname. When the global instance of this class is first loaded, it will
-   * set the hostname from the java property VNS_HOST.  To set the VNS_HOST using this java
-   * property, you must therefore specify the property before the class is ever referenced,
-   * e.g. through the command-line property option -DVNS_HOST=[hostname], or by calling
-   * System.setProperty("VNS_HOST", [hostname]) before ever invoking any Vinci client
-   * code. Otherwise, you can set the hostname using the setVNSHost() method provided by this
-   * class.  
-   *
-   * @throws IllegalStateException if the VNS host has not been specified.
+   * Return the VNS hostname. When the global instance of this class is first loaded, it will set
+   * the hostname from the java property VNS_HOST. To set the VNS_HOST using this java property, you
+   * must therefore specify the property before the class is ever referenced, e.g. through the
+   * command-line property option -DVNS_HOST=[hostname], or by calling
+   * System.setProperty("VNS_HOST", [hostname]) before ever invoking any Vinci client code.
+   * Otherwise, you can set the hostname using the setVNSHost() method provided by this class.
+   * 
+   * @throws IllegalStateException
+   *           if the VNS host has not been specified.
    */
   public String getVNSHost() {
     if (host == null) {
       throw new IllegalStateException(
-          "No VNS host or IP address has been specified! You can specify the VNS host or IP address through the Java command-line option -DVNS_HOST=[hostname], or programmatically using either System.setProperty(\"VNS_HOST\",[hostname]) or VinciContext.getGlobalContext().setVNSHost([hostname]).");
+              "No VNS host or IP address has been specified! You can specify the VNS host or IP address through the Java command-line option -DVNS_HOST=[hostname], or programmatically using either System.setProperty(\"VNS_HOST\",[hostname]) or VinciContext.getGlobalContext().setVNSHost([hostname]).");
     } else {
       return host;
     }
   }
 
   /**
-   * Return the VNS listener port. When the global instance of this class is first loaded, it
-   * will attempt to set the port number from the java property VNS_PORT.  To set the port using
-   * this java property, you must therefore specify the VNS_PORT property before the class is
-   * ever referenced, e.g. through the command-line property option -DVNS_PORT=[hostname], or by
-   * calling System.setProperty("VNS_PORT", [hostname]) before ever invoking any Vinci client
-   * code. Otherwise, the port will default to 9000. You can override this default (or any
-   * property-specified value) by calling the setPort() method provided by this class.  
+   * Return the VNS listener port. When the global instance of this class is first loaded, it will
+   * attempt to set the port number from the java property VNS_PORT. To set the port using this java
+   * property, you must therefore specify the VNS_PORT property before the class is ever referenced,
+   * e.g. through the command-line property option -DVNS_PORT=[hostname], or by calling
+   * System.setProperty("VNS_PORT", [hostname]) before ever invoking any Vinci client code.
+   * Otherwise, the port will default to 9000. You can override this default (or any
+   * property-specified value) by calling the setPort() method provided by this class.
    */
   public int getVNSPort() {
     return port;
@@ -189,16 +206,16 @@
   }
 
   /**
-   * Returns whether clients can use stale resolve cache entries for service location in the
-   * event VNS is unreachable.
+   * Returns whether clients can use stale resolve cache entries for service location in the event
+   * VNS is unreachable.
    */
   public boolean areStaleLookupsAllowed() {
     return allowStaleLookups;
   }
 
   /**
-   * Set whether clients can use stale resolve cache entries for service location in the event
-   * VNS is unreachable. Default is true. 
+   * Set whether clients can use stale resolve cache entries for service location in the event VNS
+   * is unreachable. Default is true.
    */
   public void setAllowStaleLookups(boolean b) {
     allowStaleLookups = b;
@@ -212,15 +229,15 @@
   }
 
   /**
-   * Set the time-to-live of cached service locators (resolve results). Default is 1 minute. Set
-   * to 0 to disable caching completely.
+   * Set the time-to-live of cached service locators (resolve results). Default is 1 minute. Set to
+   * 0 to disable caching completely.
    */
   public void setResolveCacheTTL(int millis) {
     ttlMillis = millis;
   }
 
   /**
-   * Get the timeout setting of VNS resolve queries. 
+   * Get the timeout setting of VNS resolve queries.
    */
   public int getVNSResolveTimeout() {
     return vnsResolveTimeout;
@@ -248,8 +265,7 @@
   }
 
   /**
-   * Get the global VinciContext used by Vinci classes when no context is explicitly
-   * specified.
+   * Get the global VinciContext used by Vinci classes when no context is explicitly specified.
    */
   static public VinciContext getGlobalContext() {
     return globalContext;
@@ -257,7 +273,7 @@
 
   /**
    * Get a cached resolve result (if any).
-   *
+   * 
    * @return the cached resolve result, or null if none is cached.
    * 
    * @pre serviceName != null
@@ -275,8 +291,8 @@
 
   /**
    * Get a cached resolve result (if any), but allow returning stale cache entries.
-   *
-   * @return the cached resolve result, or null if none is cached. 
+   * 
+   * @return the cached resolve result, or null if none is cached.
    * 
    * @pre serviceName != null
    */
@@ -302,7 +318,7 @@
       c.r = r;
       c.entryTime = System.currentTimeMillis();
     }
-    //long now = System.currentTimeMillis();
+    // long now = System.currentTimeMillis();
   }
 
   /**
@@ -320,17 +336,19 @@
 
   /**
    * See documentation for VinciClient.sendAndReceive().
-   *
+   * 
    * @see org.apache.vinci.transport.VinciClient
-   *
-   * @throws IllegalStateException if the VNS host has not been specified.
-   *
+   * 
+   * @throws IllegalStateException
+   *           if the VNS host has not been specified.
+   * 
    * @pre in != null
    * @pre service_name != null
    * @pre factory != null
    */
-  public Transportable sendAndReceive(Transportable in, String service_name, TransportableFactory factory)
-      throws IOException, ServiceException, ServiceDownException, VNSException {
+  public Transportable sendAndReceive(Transportable in, String service_name,
+          TransportableFactory factory) throws IOException, ServiceException, ServiceDownException,
+          VNSException {
     VinciClient tempClient = new VinciClient(service_name, factory, this);
     try {
       return tempClient.sendAndReceive(in);
@@ -341,18 +359,19 @@
 
   /**
    * See documentation for VinciClient.sendAndReceive().
-   *
+   * 
    * @see org.apache.vinci.transport.VinciClient
-   *
-   * @throws IllegalStateException if the VNS host has not been specified.
-   *
+   * 
+   * @throws IllegalStateException
+   *           if the VNS host has not been specified.
+   * 
    * @pre in != null
    * @pre service_name != null
    * @pre factory != null
    * @pre socket_timeout >= 0
    */
-  public Transportable sendAndReceive(Transportable in, String service_name, TransportableFactory factory,
-      int socket_timeout) throws IOException, ServiceException {
+  public Transportable sendAndReceive(Transportable in, String service_name,
+          TransportableFactory factory, int socket_timeout) throws IOException, ServiceException {
     VinciClient tempClient = new VinciClient(service_name, factory, this);
     tempClient.setSocketTimeout(socket_timeout);
     try {
@@ -364,21 +383,23 @@
 
   /**
    * See documentation for VinciClient.sendAndReceive().
-   *
-   * WARNING: This method relies on JDK-1.4 specific functions.  USE IT ONLY if you don't need
-   * to maintain JDK1.3 compatability.
-   *
+   * 
+   * WARNING: This method relies on JDK-1.4 specific functions. USE IT ONLY if you don't need to
+   * maintain JDK1.3 compatability.
+   * 
    * @see org.apache.vinci.transport.VinciClient
-   *
-   * @throws IllegalStateException if the VNS host has not been specified.
-   *
+   * 
+   * @throws IllegalStateException
+   *           if the VNS host has not been specified.
+   * 
    * @pre in != null
    * @pre service_name != null
    * @pre factory != null
    * @pre socket_timeout >= 0
    */
-  public Transportable sendAndReceive(Transportable in, String service_name, TransportableFactory factory,
-      int socket_timeout, int connect_timeout) throws IOException, ServiceException {
+  public Transportable sendAndReceive(Transportable in, String service_name,
+          TransportableFactory factory, int socket_timeout, int connect_timeout)
+          throws IOException, ServiceException {
     VinciClient tempClient = new VinciClient(service_name, factory, this, connect_timeout);
     tempClient.setSocketTimeout(socket_timeout);
     try {
@@ -390,16 +411,17 @@
 
   /**
    * See documentation for VinciClient.rpc().
-   *
+   * 
    * @see org.apache.vinci.transport.VinciClient
-   *
-   * @throws IllegalStateException if the VNS host has not been specified.
-   *
+   * 
+   * @throws IllegalStateException
+   *           if the VNS host has not been specified.
+   * 
    * @pre in != null
    * @pre service_name != null
    */
-  public VinciFrame rpc(Transportable in, String service_name) throws IOException, ServiceException,
-      ServiceDownException, VNSException {
+  public VinciFrame rpc(Transportable in, String service_name) throws IOException,
+          ServiceException, ServiceDownException, VNSException {
     VinciClient tempClient = new VinciClient(service_name, this);
     try {
       return tempClient.rpc(in);
@@ -410,17 +432,18 @@
 
   /**
    * See documentation for VinciClient.rpc().
-   *
+   * 
    * @see org.apache.vinci.transport.VinciClient
-   *
-   * @throws IllegalStateException if the VNS host has not been specified.
-   *
+   * 
+   * @throws IllegalStateException
+   *           if the VNS host has not been specified.
+   * 
    * @pre in != null
    * @pre service_name != null
    * @pre timeout >= 0
    */
-  public VinciFrame rpc(Transportable in, String service_name, int timeout) throws IOException, ServiceException,
-      ServiceDownException, VNSException {
+  public VinciFrame rpc(Transportable in, String service_name, int timeout) throws IOException,
+          ServiceException, ServiceDownException, VNSException {
     VinciClient tempClient = new VinciClient(service_name, this);
     tempClient.setSocketTimeout(timeout);
     try {
@@ -432,20 +455,22 @@
 
   /**
    * See documentation for VinciClient.rpc().
-   *
-   * WARNING: This method relies on JDK-1.4 specific functions.  USE IT ONLY if you don't need
-   * to maintain JDK1.3 compatability.
-   *
+   * 
+   * WARNING: This method relies on JDK-1.4 specific functions. USE IT ONLY if you don't need to
+   * maintain JDK1.3 compatability.
+   * 
    * @see org.apache.vinci.transport.VinciClient
-   *
-   * @throws IllegalStateException if the VNS host has not been specified.
-   *
+   * 
+   * @throws IllegalStateException
+   *           if the VNS host has not been specified.
+   * 
    * @pre in != null
    * @pre service_name != null
    * @pre timeout >= 0
    */
-  public VinciFrame rpc(Transportable in, String service_name, int socket_timeout, int connect_timeout)
-      throws IOException, ServiceException, ServiceDownException, VNSException {
+  public VinciFrame rpc(Transportable in, String service_name, int socket_timeout,
+          int connect_timeout) throws IOException, ServiceException, ServiceDownException,
+          VNSException {
     VinciClient tempClient = new VinciClient(service_name, this, connect_timeout);
     tempClient.setSocketTimeout(socket_timeout);
     try {