org.mortbay.jetty.asyncblazeds
Class BaseAsyncHTTPEndpoint

java.lang.Object
  extended by flex.management.ManageableComponent
      extended by flex.messaging.endpoints.AbstractEndpoint
          extended by flex.messaging.endpoints.BaseHTTPEndpoint
              extended by org.mortbay.jetty.asyncblazeds.BaseAsyncHTTPEndpoint
All Implemented Interfaces:
flex.management.Manageable, flex.messaging.client.PollWaitListener, flex.messaging.config.ConfigurationConstants, flex.messaging.endpoints.Endpoint, flex.messaging.endpoints.Endpoint2, flex.messaging.FlexComponent, flex.messaging.FlexConfigurable
Direct Known Subclasses:
AsyncAMFEndpoint, AsyncHTTPEndpoint

public abstract class BaseAsyncHTTPEndpoint
extends flex.messaging.endpoints.BaseHTTPEndpoint
implements flex.messaging.client.PollWaitListener

Base for HTTP-based endpoints that support regular polling and long polling. If there are messages waiting when the client polls, the request returns immediately with the messages. Otherwise, the client will hold the poll. If the endpoint is configured to wait indefinitely until notified of messages, the client will do a blocking long poll, placing the request thread into a wait state; if configured to wait for a positive value of milliseconds, request processing is suspended and the request goes into a threadless wait. The request returns when messages are available to deliver, or when the configurable wait interval is reached. The threadless wait is achieved using jetty-7 portable continuations, which work asynchronous on jetty-6 and any servlet-3.0 container.


Field Summary
protected  int clientWaitInterval
           
protected  java.lang.Object lock
          Used to synchronize sets and gets to the number of waiting clients.
protected  int maxWaitingPollRequests
           
protected  boolean piggybackingEnabled
           
protected  boolean pollingEnabled
           
protected  long pollingIntervalMillis
           
protected  int waitingPollRequestsCount
          A count of the number of request threads that are currently in the wait state (including those on their way into or out of it).
protected  long waitInterval
           
 
Fields inherited from class flex.messaging.endpoints.BaseHTTPEndpoint
addNoCacheHeaders, controller, filterChain, HTTP_PROTOCOL_SCHEME, HTTPS_PROTOCOL_SCHEME, invalidateSessionOnDisconnect, loginAfterDisconnect, redirectURL
 
Fields inherited from class flex.messaging.endpoints.AbstractEndpoint
clientContextParsed, clientLoadBalancingUrls, clientType, connectTimeoutSeconds, deserializerClass, flexClientOutboundQueueProcessClass, flexClientOutboundQueueProcessor, flexClientOutboundQueueProcessorConfig, HEADER_NAME_CACHE_CONTROL, HEADER_NAME_EXPIRES, HEADER_NAME_PRAGMA, log, LOG_CATEGORY, messagingVersion, parsedClientUrl, parsedForContext, parsedUrl, port, recordMessageSizes, recordMessageTimes, remote, requestTimeoutSeconds, serializationContext, serializerClass, server, serverOnly, typeMarshaller, url
 
Fields inherited from class flex.management.ManageableComponent
control, id, managed, NULL_COMPONENT_PROPERTY, parent, PROPERTY_CHANGE_AFTER_STARTUP, started, valid
 
Fields inherited from interface flex.messaging.config.ConfigurationConstants
ADAPTER_ATTR, ADAPTER_DEFINITION_CHILDREN, ADAPTER_DEFINITION_ELEMENT, ADAPTER_DEFINITION_REQ_CHILDREN, ADAPTER_ELEMENT, ADAPTERS_CHILDREN, ADAPTERS_ELEMENT, ADAPTIVE_FREQUENCY, ASYNC_MESSAGE_FILTERS_ELEMENT, ASYNC_MESSAGE_FILTERS_ELEMENT_CHILDREN, AUTH_METHOD_ELEMENT, CHANNEL_DEFINITION_CHILDREN, CHANNEL_DEFINITION_ELEMENT, CHANNEL_DEFINITION_REQ_CHILDREN, CHANNEL_DEFINITION_SERVER_REQ_CHILDREN, CHANNEL_ELEMENT, CHANNELS_ATTR, CHANNELS_CHILDREN, CHANNELS_ELEMENT, CLASS_AND_SERVER_ONLY_ERROR, CLASS_ATTR, CLASS_NOT_SPECIFIED, CLASS_OR_SERVER_ONLY_ERROR, CLIENT_LOAD_BALANCING_ELEMENT, CLUSTER_DEFINITION_CHILDREN, CLUSTER_DEFINITION_ELEMENT, CLUSTER_PROPERTIES_ATTR, CLUSTERING_CHILDREN, CLUSTERS_ELEMENT, CONNECT_TIMEOUT_SECONDS_ELEMENT, CONTEXT_PATH_ALT_TOKEN, CONTEXT_PATH_TOKEN, DEFAULT_ATTR, DEFAULT_CHANNELS_CHILDREN, DEFAULT_CHANNELS_ELEMENT, DEFAULT_LOCALE_ELEMENT, DEFAULT_SECURITY_CONSTRAINT_ELEMENT, DEST_NEEDS_ADAPTER, DEST_NEEDS_CHANNEL, DESTINATION_ADAPTER_CHILDREN, DESTINATION_ATTR, DESTINATION_CHANNEL_REQ_CHILDREN, DESTINATION_CHANNELS_CHILDREN, DESTINATION_CHILDREN, DESTINATION_ELEMENT, DESTINATION_INCLUDE_CHILDREN, DESTINATION_INCLUDE_ELEMENT, DESTINATION_REQ_CHILDREN, DESTINATIONS_CHILDREN, DESTINATIONS_ELEMENT, DUPLICATE_CHANNEL_ERROR, DUPLICATE_COMPONENT_ID, DUPLICATE_DEFAULT_ADAPTER, DUPLICATE_DEST_ID, DUPLICATE_DESTINATION_ERROR, DUPLICATE_SERVICE_ERROR, EMBEDDED_SECURITY_CHILDREN, EMPTY_STRING, ENABLE_SMALL_MESSAGES_ELEMENT, ENABLED_ELEMENT, ENDPOINT_CHILDREN, ENDPOINT_ELEMENT, ENFORCE_ENDOINT_VALIDATION, ERR_MSG_CLIENT_LOAD_BALANCING_URL_WITH_TOKEN, ERR_MSG_EMPTY_CLIENT_LOAD_BALANCING_ELEMENT, ERR_MSG_EMTPY_CLIENT_LOAD_BALACNING_URL, FACTORIES_CHILDREN, FACTORIES_ELEMENT, FACTORY_ELEMENT, FACTORY_REQ_CHILDREN, FALSE_STRING, FILTER_CHILDREN, FILTER_ELEMENT, FILTER_REQ_CHILDREN, FILTERS_CHILDREN, FILTERS_ELEMENT, FLEX_CLIENT_CHILDREN, FLEX_CLIENT_ELEMENT, FLEX_CLIENT_HEARTBEAT_INTERVAL_MILLIS, FLEX_CLIENT_OUTBOUND_QUEUE_PROCESSOR_ELEMENT, FLEX_CLIENT_OUTBOUND_QUEUE_PROCESSOR_REQ_CHILDREN, FLEX_CLIENT_RELIABLE_RECONNECT_DURATION_MILLIS, FLEX_CLIENT_TIMEOUT_MINUTES_ELEMENT, ID_ATTR, INVALID_DEFAULT_CHANNEL, INVALID_DESTINATION_INCLUDE_ROOT, INVALID_ENDPOINT_PORT, INVALID_FLEX_CLIENT_HEARTBEAT_INTERVAL_MILLIS, INVALID_FLEX_CLIENT_RELIABLE_RECONNECT_DURATION_MILLIS, INVALID_FLEX_CLIENT_TIMEOUT, INVALID_ID, INVALID_ID_IN_SERVICE, INVALID_REF_IN_DEST, INVALID_SECURITY_CONSTRAINT_REF, INVALID_SERVICE_INCLUDE_ROOT, INVALID_SERVICES_ROOT, INVALID_VALUE_FOR_PROPERTY_OF_COMPONENT_WITH_ID, IP_ADDRESS_PATTERN, IRREPLACABLE_TOKEN, LEVEL_ATTR, LIST_DELIMITERS, LOCALE_CHILDREN, LOCALE_ELEMENT, LOGGING_CHILDREN, LOGGING_ELEMENT, LOGIN_AFTER_DISCONNECT_ELEMENT, LOGIN_COMMAND_CHILDREN, LOGIN_COMMAND_ELEMENT, LOGIN_COMMAND_REQ_CHILDREN, MANAGEABLE_ELEMENT, MESSAGE_TYPES_ATTR, METADATA_ELEMENT, MISSING_ATTRIBUTE, MISSING_ELEMENT, NULL_COMPONENT, NULL_COMPONENT_ID, PARSER_INIT_ERROR, PARSER_INTERNAL_ERROR, PATTERN_ELEMENT, PER_CLIENT_AUTH, PIGGYBACKING_ENABLED_ELEMENT, POLLING_ENABLED_ELEMENT, POLLING_INTERVAL_MILLIS_ELEMENT, POLLING_INTERVAL_SECONDS_ELEMENT, PROPERTIES_ELEMENT, RECORD_MESSAGE_SIZES_ELEMENT, RECORD_MESSAGE_TIMES_ELEMENT, REDEPLOY_CHILDREN, REDEPLOY_ELEMENT, REF_ATTR, REF_NOT_FOUND, REF_NOT_FOUND_IN_CHANNEL, REF_NOT_FOUND_IN_DEST, REMOTE_ATTR, REQUEST_TIMEOUT_SECONDS_ELEMENT, REQUIRE_ADVANCED_MESSAGING_SUPPORT, ROLE_ELEMENT, ROLES_CHILDREN, ROLES_ELEMENT, SECURITY_CHILDREN, SECURITY_CONSTRAINT_ATTR, SECURITY_CONSTRAINT_DEFINITION_CHILDREN, SECURITY_CONSTRAINT_DEFINITION_ELEMENT, SECURITY_CONSTRAINT_ELEMENT, SECURITY_ELEMENT, SERIALIZATION_ELEMENT, SERVER_ATTR, SERVER_CHILDREN, SERVER_ELEMENT, SERVER_NAME_TOKEN, SERVER_ONLY_ATTR, SERVER_PORT_TOKEN, SERVER_REQ_CHILDREN, SERVERS_CHILDREN, SERVERS_ELEMENT, SERVICE_CHILDREN, SERVICE_ELEMENT, SERVICE_INCLUDE_CHILDREN, SERVICE_INCLUDE_ELEMENT, SERVICE_REQ_CHILDREN, SERVICES_CHILDREN, SERVICES_CONFIG_CHILDREN, SERVICES_CONFIG_ELEMENT, SERVICES_ELEMENT, SLASH_CONTEXT_PATH_TOKEN, SRC_ATTR, SYNC_MESSAGE_FILTERS_ELEMENT, SYNC_MESSAGE_FILTERS_ELEMENT_CHILDREN, SYSTEM_CHILDREN, SYSTEM_ELEMENT, TARGET_CHILDREN, TARGET_ELEMENT, TARGET_REQ_CHILDREN, TOO_MANY_OCCURRENCES, TOUCH_FILE_ELEMENT, TRUE_STRING, TYPE_ATTR, UNDEFINED_CONTEXT_ROOT, UNEXPECTED_ATTRIBUTE, UNEXPECTED_ELEMENT, UNEXPECTED_TEXT, UNKNOWN_SOURCE_FILE, UNREGISTERED_ADAPTER, URI_ATTR, URL_ATTR, VALIDATOR_CHILDREN, VALIDATOR_ELEMENT, VALIDATOR_REQ_CHILDREN, VALIDATORS_CHILDREN, VALIDATORS_ELEMENT, WATCH_FILE_ELEMENT, WATCH_INTERVAL_ELEMENT, XML_PARSER_ERROR
 
Constructor Summary
BaseAsyncHTTPEndpoint()
          Constructs an unmanaged BaseAsyncHTTPEndpoint.
BaseAsyncHTTPEndpoint(boolean enableManagement)
          Constructs a BaseAsyncHTTPEndpoint with the indicated management.
 
Method Summary
 flex.messaging.config.ConfigMap describeEndpoint()
           
 int getClientWaitInterval()
          Returns the number of milliseconds the client will wait after receiving a response for a poll with server wait before it issues its next poll request.
 int getMaxWaitingPollRequests()
          Returns the maximum number of server poll response threads that will be waiting for messages to arrive for clients.
 long getWaitInterval()
          Returns the number of milliseconds the server poll response thread will be waiting for messages to arrive for the client.
protected  flex.messaging.client.FlushResult handleFlexClientPoll(flex.messaging.client.FlexClient flexClient, flex.messaging.messages.CommandMessage pollCommand)
          Overrides the base poll handling to support optionally putting Http request handling threads into a wait state until messages are available to be delivered in the poll response or a timeout is reached.
 void initialize(java.lang.String id, flex.messaging.config.ConfigMap properties)
          Initializes the Endpoint with the properties.
 void service(javax.servlet.http.HttpServletRequest req, javax.servlet.http.HttpServletResponse res)
          Handle AMF/AMFX encoded messages sent over HTTP, with suspend/resume of the request, using jetty-7 portable continuations.
 void setClientWaitInterval(int value)
          Sets the number of milliseconds a client will wait after receiving a response for a poll with server wait before it issues its next poll request.
 void setMaxWaitingPollRequests(int maxWaitingPollRequests)
          Sets the maximum number of server poll response threads that will be waiting for messages to arrive for clients.
 void setWaitInterval(long waitInterval)
          Sets the number of milliseconds the server poll response thread will be waiting for messages to arrive for the client.
 void start()
          Sets up monitoring of waited poll requests so they can be notified and exit when the endpoint stops.
 void stop()
          Ensures that no poll requests in a wait state are left un-notified when the endpoint stops.
 void waitEnd(java.lang.Object notifier)
           
 void waitStart(java.lang.Object notifier)
           
 
Methods inherited from class flex.messaging.endpoints.BaseHTTPEndpoint
createFilterChain, getInsecureProtocolScheme, getRedirectURL, getResponseContentType, getSecureProtocolScheme, handleChannelDisconnect, isAddNoCacheHeaders, isInvalidateSessionOnDisconnect, setAddNoCacheHeaders, setInvalidateSessionOnDisconnect, setRedirectURL, setupFlexClient
 
Methods inherited from class flex.messaging.endpoints.AbstractEndpoint
addClientLoadBalancingUrl, addNoCacheHeaders, checkSecurityConstraint, clearThreadLocals, convertToSmallMessage, createClass, getClientLoadBalancingUrls, getClientType, getDeserializerClassName, getFlexClientOutboundQueueProcessorClass, getFlexClientOutboundQueueProcessorConfig, getLogCategory, getMessageBroker, getMessagingVersion, getParsedUrl, getPort, getSecurityConstraint, getSerializationContext, getSerializerClassName, getServer, getServerOnly, getThroughput, getTypeMarshaller, getUrl, getUrlForClient, handleClientMessagingVersion, handleFlexClientPollCommand, initializeClientLoadBalancing, isRecordMessageSizes, isRecordMessageTimes, isRemote, isSecure, removeClientLoadBalancingUrl, serviceMessage, setClientType, setFlexClientOutboundQueueProcessorClass, setFlexClientOutboundQueueProcessorConfig, setId, setMessageBroker, setRemote, setSecurityConstraint, setSerializationContext, setServer, setServerOnly, setThreadLocals, setTypeMarshaller, setupEndpointControl, setupFlexClient, setUrl, validateEndpointProtocol, validateRequestProtocol, verifyFlexClientSupport
 
Methods inherited from class flex.management.ManageableComponent
blockAssignmentWhileStarted, blockNullAssignment, getControl, getId, getParent, invalidate, isManaged, isStarted, isValid, setControl, setManaged, setParent, setStarted, setValid, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface flex.messaging.endpoints.Endpoint
getId, isStarted
 
Methods inherited from interface flex.management.Manageable
getControl, isManaged, setControl, setManaged
 

Field Detail

lock

protected final java.lang.Object lock
Used to synchronize sets and gets to the number of waiting clients.


waitingPollRequestsCount

protected int waitingPollRequestsCount
A count of the number of request threads that are currently in the wait state (including those on their way into or out of it).


clientWaitInterval

protected int clientWaitInterval

maxWaitingPollRequests

protected int maxWaitingPollRequests

piggybackingEnabled

protected boolean piggybackingEnabled

pollingEnabled

protected boolean pollingEnabled

pollingIntervalMillis

protected long pollingIntervalMillis

waitInterval

protected long waitInterval
Constructor Detail

BaseAsyncHTTPEndpoint

public BaseAsyncHTTPEndpoint()
Constructs an unmanaged BaseAsyncHTTPEndpoint.


BaseAsyncHTTPEndpoint

public BaseAsyncHTTPEndpoint(boolean enableManagement)
Constructs a BaseAsyncHTTPEndpoint with the indicated management.

Parameters:
enableManagement - true if the BaseAsyncHTTPEndpoint is manageable; otherwise false.
Method Detail

service

public void service(javax.servlet.http.HttpServletRequest req,
                    javax.servlet.http.HttpServletResponse res)
Handle AMF/AMFX encoded messages sent over HTTP, with suspend/resume of the request, using jetty-7 portable continuations.

Specified by:
service in interface flex.messaging.endpoints.Endpoint
Overrides:
service in class flex.messaging.endpoints.BaseHTTPEndpoint
Parameters:
req - The original servlet request.
res - The active servlet response.

initialize

public void initialize(java.lang.String id,
                       flex.messaging.config.ConfigMap properties)
Initializes the Endpoint with the properties. If subclasses override, they must call super.initialize().

Specified by:
initialize in interface flex.messaging.endpoints.Endpoint
Specified by:
initialize in interface flex.messaging.FlexConfigurable
Overrides:
initialize in class flex.messaging.endpoints.BaseHTTPEndpoint
Parameters:
id - Id of the Endpoint.
properties - Properties for the Endpoint.

getClientWaitInterval

public int getClientWaitInterval()
Returns the number of milliseconds the client will wait after receiving a response for a poll with server wait before it issues its next poll request. A value of zero or less causes the client to use its default polling interval (based on the channel's polling-interval-millis configuration) and this value is ignored. A value greater than zero will cause the client to wait for the specified interval before issuing its next poll request with a value of 1 triggering an immediate poll from the client as soon as a waited poll response is received.


setClientWaitInterval

public void setClientWaitInterval(int value)
Sets the number of milliseconds a client will wait after receiving a response for a poll with server wait before it issues its next poll request. A value of zero or less causes the client to use its default polling interval (based on the channel's polling-interval-millis configuration) and this value is ignored. A value greater than zero will cause the client to wait for the specified interval before issuing its next poll request with a value of 1 triggering an immediate poll from the client as soon as a waited poll response is received. This property does not effect polling clients that poll the server without a server wait.


getMaxWaitingPollRequests

public int getMaxWaitingPollRequests()
Returns the maximum number of server poll response threads that will be waiting for messages to arrive for clients.


setMaxWaitingPollRequests

public void setMaxWaitingPollRequests(int maxWaitingPollRequests)
Sets the maximum number of server poll response threads that will be waiting for messages to arrive for clients. If you set wait-interval to -1, note that the request threads will block and you will need to use a lower limit; if you set wait-interval to use a positive integer, the requests will be suspended using threadless waits, and it is safe to set a higher limit.

Parameters:
maxWaitingPollRequests - The maximum number of server poll response threads that will be waiting for messages to arrive for the client.

getWaitInterval

public long getWaitInterval()
Returns the number of milliseconds the server poll response thread will be waiting for messages to arrive for the client.


setWaitInterval

public void setWaitInterval(long waitInterval)
Sets the number of milliseconds the server poll response thread will be waiting for messages to arrive for the client.

Parameters:
waitInterval - The number of milliseconds the server poll response thread will be waiting for messages to arrive for the client. A value of -1 means wait until notified, and will hold the request thread. A value > 0 puts the request into a threadless wait.

describeEndpoint

public flex.messaging.config.ConfigMap describeEndpoint()
Specified by:
describeEndpoint in interface flex.messaging.endpoints.Endpoint
Overrides:
describeEndpoint in class flex.messaging.endpoints.BaseHTTPEndpoint

start

public void start()
Sets up monitoring of waited poll requests so they can be notified and exit when the endpoint stops.

Specified by:
start in interface flex.messaging.endpoints.Endpoint
Specified by:
start in interface flex.messaging.FlexComponent
Overrides:
start in class flex.messaging.endpoints.BaseHTTPEndpoint
See Also:
AbstractEndpoint.start()

stop

public void stop()
Ensures that no poll requests in a wait state are left un-notified when the endpoint stops.

Specified by:
stop in interface flex.messaging.endpoints.Endpoint
Specified by:
stop in interface flex.messaging.FlexComponent
Overrides:
stop in class flex.messaging.endpoints.AbstractEndpoint
See Also:
AbstractEndpoint.stop()

waitStart

public void waitStart(java.lang.Object notifier)
Specified by:
waitStart in interface flex.messaging.client.PollWaitListener
See Also:
PollWaitListener.waitStart(Object)

waitEnd

public void waitEnd(java.lang.Object notifier)
Specified by:
waitEnd in interface flex.messaging.client.PollWaitListener
See Also:
PollWaitListener.waitEnd(Object)

handleFlexClientPoll

protected flex.messaging.client.FlushResult handleFlexClientPoll(flex.messaging.client.FlexClient flexClient,
                                                                 flex.messaging.messages.CommandMessage pollCommand)
Overrides the base poll handling to support optionally putting Http request handling threads into a wait state until messages are available to be delivered in the poll response or a timeout is reached. The number of threads that may be put in a wait state is bounded by max-waiting-poll-requests and waits will only be attempted if the canWait flag that is based on the max-waiting-poll-requests and the specified wait-interval is true.

Overrides:
handleFlexClientPoll in class flex.messaging.endpoints.AbstractEndpoint
Parameters:
flexClient - The FlexClient that issued the poll request.
pollCommand - The poll command from the client.
Returns:
The flush info used to build the poll response.


Copyright © 1995-2011 Mort Bay Consulting. All Rights Reserved.