Top Description Fields Constructors Methods
org.glassfish.grizzly.http.ajp

public Class AjpHandlerFilter

extends BaseFilter
Class Inheritance
Imports
java.io.IOException, java.security.SecureRandom, java.util.Properties, .Queue, java.util.concurrent.LinkedTransferQueue, java.util.logging.Level, .Logger, org.glassfish.grizzly.Buffer, .Connection, .Grizzly, org.glassfish.grizzly.attributes.Attribute, org.glassfish.grizzly.filterchain.BaseFilter, .FilterChainContext, .FilterChainEvent, .NextAction, org.glassfish.grizzly.http.HttpContent, .HttpContext, .HttpHeader, .HttpPacket, .HttpResponsePacket, .HttpServerFilter, org.glassfish.grizzly.http.util.DataChunk, org.glassfish.grizzly.memory.Buffers, .MemoryManager

Filter is working as Codec between Ajp and Http packets. In other words it's responsible for decoding Ajp message to HttpRequestPacket, and encoding HttpResponsePacket to Ajp message back.
Author
Alexey Stashok

Field Summary

Modifier and TypeField and Description
private final Attribute<AjpHttpRequest>
private boolean
private static final Logger
private final Buffer
private String
private final Queue<ShutdownHandler>

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public void
addShutdownHandler(final ShutdownHandler handler)

Add the ShutdownHandler, which will be called, when shutdown request received.

public void
configure(final Properties properties)

Configure Ajp Filter using properties.

private Buffer
encodeHttpPacket(final Connection<L> connection, final HttpPacket httpPacket)

private int
extractType(final FilterChainContext ctx, final Buffer buffer)

public String

Returns:

not null, if only requests from workers with this secret keyword will be accepted, or null otherwise.
getSecret
()

If not null, only requests from workers with this secret keyword will be accepted.

public NextAction

Returns:

the NextAction.
handleEvent
(final FilterChainContext ctx, final FilterChainEvent
the event triggering the invocation of this method.
event
)

Overrides org.glassfish.grizzly.filterchain.BaseFilter.handleEvent.

Implements org.glassfish.grizzly.filterchain.Filter.handleEvent.

Handling Http request completion event sent by Http server filter and send the Ajp end response message.

public NextAction
public NextAction

Returns:

the NextAction
handleWrite
(final FilterChainContext ctx)

Overrides org.glassfish.grizzly.filterchain.BaseFilter.handleWrite.

Implements org.glassfish.grizzly.filterchain.Filter.handleWrite.

Encoding HttpResponsePacket or HttpContent to Ajp message.

public boolean

Returns:

true, if the authentication will be done in Grizzly. Otherwise, the authenticated principal will be propagated from the native webserver and used for authorization in Grizzly.
isTomcatAuthentication
()

If set to true, the authentication will be done in Grizzly.

private NextAction
processCPing(final FilterChainContext ctx, final Buffer message)

Process CPing request message.

private NextAction
processData(final FilterChainContext ctx, final Buffer messageContent)

private NextAction

Returns:

NextAction
processForwardRequest
(final FilterChainContext ctx, final Buffer
the content of the forwarded request
content
)

Process ForwardRequest request message.

private NextAction
processShutdown(final FilterChainContext ctx, final Buffer message)

Process Shutdown request message.

public void
private void
private void
public void
setSecret(String
if not null, only requests from workers with this secret keyword will be accepted.
requiredSecret
)

If not null, only requests from workers with this secret keyword will be accepted.

public void
setTomcatAuthentication(boolean
if true, the authentication will be done in Grizzly. Otherwise, the authenticated principal will be propagated from the native webserver and used for authorization in Grizzly.
isTomcatAuthentication
)

/** If set to true, the authentication will be done in Grizzly.

Inherited from org.glassfish.grizzly.filterchain.BaseFilter:
createContextexceptionOccurredhandleAccepthandleClosehandleConnectonAddedonFilterChainChangedonRemovedtoString

Field Detail

httpRequestInProcessAttrback to summary
private final Attribute<AjpHttpRequest> httpRequestInProcessAttr
isTomcatAuthenticationback to summary
private boolean isTomcatAuthentication
LOGGERback to summary
private static final Logger LOGGER
NEED_MORE_DATA_MESSAGEback to summary
private final Buffer NEED_MORE_DATA_MESSAGE
secretback to summary
private String secret
shutdownHandlersback to summary
private final Queue<ShutdownHandler> shutdownHandlers

Constructor Detail

AjpHandlerFilterback to summary
public AjpHandlerFilter()

Method Detail

addShutdownHandlerback to summary
public void addShutdownHandler(final ShutdownHandler handler)

Add the ShutdownHandler, which will be called, when shutdown request received.

Parameters
handler:ShutdownHandler

ShutdownHandler

configureback to summary
public void configure(final Properties properties)

Configure Ajp Filter using properties. We support following properties: request.useSecret, request.secret, tomcatAuthentication.

Annotations
@SuppressWarnings:UnusedDeclaration
encodeHttpPacketback to summary
private Buffer encodeHttpPacket(final Connection<L> connection, final HttpPacket httpPacket)
extractTypeback to summary
private int extractType(final FilterChainContext ctx, final Buffer buffer)
getSecretback to summary
public String getSecret()

If not null, only requests from workers with this secret keyword will be accepted.

Returns:String

not null, if only requests from workers with this secret keyword will be accepted, or null otherwise.

Annotations
@SuppressWarnings:UnusedDeclaration
handleEventback to summary
public NextAction handleEvent(final FilterChainContext ctx, final FilterChainEvent event) throws IOException

Overrides org.glassfish.grizzly.filterchain.BaseFilter.handleEvent.

Implements org.glassfish.grizzly.filterchain.Filter.handleEvent.

Handling Http request completion event sent by Http server filter and send the Ajp end response message.

Parameters
ctx:FilterChainContext

the FilterChainContext for the current org.glassfish.grizzly.filterchain.FilterChain invocation.

event:FilterChainEvent

the event triggering the invocation of this method.

Returns:NextAction

the NextAction.

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs.
handleReadback to summary
public NextAction handleRead(final FilterChainContext ctx) throws IOException

Overrides org.glassfish.grizzly.filterchain.BaseFilter.handleRead.

Implements org.glassfish.grizzly.filterchain.Filter.handleRead.

Handle the Ajp message.

Parameters
ctx:FilterChainContext

the FilterChainContext for the current org.glassfish.grizzly.filterchain.FilterChain invocation.

Returns:NextAction

the NextAction

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
handleWriteback to summary
public NextAction handleWrite(final FilterChainContext ctx) throws IOException

Overrides org.glassfish.grizzly.filterchain.BaseFilter.handleWrite.

Implements org.glassfish.grizzly.filterchain.Filter.handleWrite.

Encoding HttpResponsePacket or HttpContent to Ajp message.

Parameters
ctx:FilterChainContext

the FilterChainContext for the current org.glassfish.grizzly.filterchain.FilterChain invocation.

Returns:NextAction

the NextAction

Annotations
@Override
Exceptions
IOException:
if an I/O error occurs
isTomcatAuthenticationback to summary
public boolean isTomcatAuthentication()

If set to true, the authentication will be done in Grizzly. Otherwise, the authenticated principal will be propagated from the native webserver and used for authorization in Grizzly. The default value is true.

Returns:boolean

true, if the authentication will be done in Grizzly. Otherwise, the authenticated principal will be propagated from the native webserver and used for authorization in Grizzly.

Annotations
@SuppressWarnings:UnusedDeclaration
processCPingback to summary
private NextAction processCPing(final FilterChainContext ctx, final Buffer message) throws IOException

Process CPing request message. We send CPong response back as plain Grizzly Buffer.

processDataback to summary
private NextAction processData(final FilterChainContext ctx, final Buffer messageContent)
processForwardRequestback to summary
private NextAction processForwardRequest(final FilterChainContext ctx, final Buffer content) throws IOException

Process ForwardRequest request message.

Parameters
ctx:FilterChainContext

the FilterChainContext for the current org.glassfish.grizzly.filterchain.FilterChain invocation.

content:Buffer

the content of the forwarded request

Returns:NextAction

NextAction

Exceptions
IOException:
if an I/O error occurs
processShutdownback to summary
private NextAction processShutdown(final FilterChainContext ctx, final Buffer message)

Process Shutdown request message. For now just ignore it.

removeShutdownHandlerback to summary
public void removeShutdownHandler(final ShutdownHandler handler)

Remove the ShutdownHandler.

Parameters
handler:ShutdownHandler

ShutdownHandler

Annotations
@SuppressWarnings:UnusedDeclaration
sendEndResponseback to summary
private void sendEndResponse(final FilterChainContext ctx) throws IOException
sendMoreDataRequestIfNeededback to summary
private void sendMoreDataRequestIfNeeded(final FilterChainContext ctx) throws IOException
setSecretback to summary
public void setSecret(String requiredSecret)

If not null, only requests from workers with this secret keyword will be accepted.

Parameters
requiredSecret:String

if not null, only requests from workers with this secret keyword will be accepted.

setTomcatAuthenticationback to summary
public void setTomcatAuthentication(boolean isTomcatAuthentication)

/** If set to true, the authentication will be done in Grizzly. Otherwise, the authenticated principal will be propagated from the native webserver and used for authorization in Grizzly. The default value is true.

Parameters
isTomcatAuthentication:boolean

if true, the authentication will be done in Grizzly. Otherwise, the authenticated principal will be propagated from the native webserver and used for authorization in Grizzly.