WebObjects 5.2

com.webobjects.appserver
Class WOAdaptor

java.lang.Object
  |
  +--com.webobjects.appserver.WOAdaptor

public abstract class WOAdaptor
extends Object

The WOAdaptor class serves as the abstract superclass for all WebObjects application adaptors (e.g. the adaptor running on the application side). Note that the WOServletAdaptor is not included in this list.

The Default adaptor's primary task is to receive incoming HTTP requests and package these events into a WORequest object. Second, the WOApplication object's dispatchRequest method is invoked with the WORequest object as a parameter. dispatchRequest returns a WOResponse object, which is then returned to the client as an HTTP response. The name of the default adaptor is WODefaultAdaptor.

During the WOApplication constructor, WOApplication.adaptorForName() is invoked, which in turn invokes the WOAdaptor constructor. Once the WOApplication object begins its runloop (started by WOApplication's run() method), registerForEvents is called. Once the runloop is ready to exit (typically by calling WOApplication's terminate() method), unregisterForEvents is called. If there are multiple adaptors, these invocations are called on each of them.

Note that the runloop does not repeatedly invoke any methods on the WOAdaptor objects. Because of this, developers should spawn at least one thread in registerForEvents to do useful work.

Custom adaptors can be be used by subclassing WOAdaptor. They can be substituted for the WODefaultAdaptor by using the WOAdaptor property, or they can be run in addition to the WODefaultAdaptor by using the WOAdditionalAdaptors property. To substitute a custom adaptor for the default adaptor:

-WOAdaptor com.mycompany.MyCustomAdaptor

To run additional adaptors:

-WOAdditionalAdaptors "({WOAdaptor=com.mycompany.MyCustomAdaptor1;}, {WOAdaptor=com.mycompany.MyCustomAdaptor2;})"

See Also:
WOApplication.adaptorWithName(String aClassName, NSDictionary anArgsDictionary), WOApplication.dispatchRequest(WORequest aRequest), registerForEvents(), unregisterForEvents()

Field Summary
protected static int DefaultListenQueueSize
          This class constant is an integer that specifies the default value for the WOListenQueueSize property, if not set elsewhere.
 
Constructor Summary
WOAdaptor(String aName, NSDictionary arguments)
           Initializes a WOAdaptor with the name aName and arguments arguments.
 
Method Summary
 boolean dispatchesRequestsConcurrently()
          This should return true if the adaptor is capable of dispatching requests to the application concurrently, false otherwise.
 boolean doesBusyRunOnce()
          Deprecated. This method will never be called and should not be used or overridden.
 int port()
          Returns the port number on which the adaptor listens.
abstract  void registerForEvents()
          WOApplication will invoke this method to prepare the WOAdaptor to start receiving events.
 void runOnce()
          Deprecated. This method will never be called and should not be used or overridden.
 String toString()
          Returns a string representation of the receiver.
abstract  void unregisterForEvents()
          WOApplication will invoke this method to cause the WOAdaptor to stop receiving events.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

DefaultListenQueueSize

protected static final int DefaultListenQueueSize
This class constant is an integer that specifies the default value for the WOListenQueueSize property, if not set elsewhere.
Constructor Detail

WOAdaptor

public WOAdaptor(String aName,
                 NSDictionary arguments)

Initializes a WOAdaptor with the name aName and arguments arguments. aName is the name of the WOAdaptor subclass. arguments are the default options specified for this adaptor (such as port number and listen queue depth).

The WOApplication method adaptorWithName invokes this method to create new WOAdaptors. If no custom WOAdaptors are added, either through the WOAdaptor or WOAdditionalAdaptors properties, a default adaptor (WODefaultAdaptor) will be created.

Custom subclasses should override this method to initialize their objects.

Parameters:
aName - name of the WOAdaptor subclass
arguments - the default options specified for this adaptor
See Also:
WOApplication.adaptorWithName(String aClassName, NSDictionary anArgsDictionary)
Method Detail

dispatchesRequestsConcurrently

public boolean dispatchesRequestsConcurrently()
This should return true if the adaptor is capable of dispatching requests to the application concurrently, false otherwise. Returning true does not necessarily mean that requests will be dispatched concurrently -- the WOAllowsConcurrentRequestHandling property must be set as well. WOApplication's isConcurrentRequestHandlingEnabled returns the current status of concurrent request handling in the application.
Returns:
true if the adaptor is capable of being multi-threaded, false otherwise
See Also:
WOApplication.isConcurrentRequestHandlingEnabled()

doesBusyRunOnce

public boolean doesBusyRunOnce()
Deprecated. This method will never be called and should not be used or overridden.

This method will never be called and should not be used or overridden.
Returns:
true

port

public int port()
Returns the port number on which the adaptor listens. If possible, the value returned by this method should be set in the constructor for the WOAdaptor subclass. Typically, this should be set to the value of the WOPort property.
Returns:
the port number
See Also:
WOApplication.port()

registerForEvents

public abstract void registerForEvents()
WOApplication will invoke this method to prepare the WOAdaptor to start receiving events. You can assume that this method will only be called once in the lifetime of the adaptor, and will be called before unregisterForEvents. This method should never be invoked directly.
See Also:
unregisterForEvents()

runOnce

public void runOnce()
Deprecated. This method will never be called and should not be used or overridden.

This method will never be called and should not be used or overridden.

toString

public String toString()
Returns a string representation of the receiver.
Overrides:
toString in class Object
Returns:
a string representation of the receiver

unregisterForEvents

public abstract void unregisterForEvents()
WOApplication will invoke this method to cause the WOAdaptor to stop receiving events. You can assume that this method will only be called once in the lifetime of the adaptor, and will be called after registerForEvents. This method should never be invoked directly.
See Also:
registerForEvents()

Last updated Fri Feb 21 13:15:00 PST 2003.

Copyright © 2003 Apple Computer, Inc.