public class Surrogate extends Object implements Extension, IEventListener
See :
This extension allows control of esigate features from the provider application.
This extension cooperates with other extensions to get the currently supported capabilities. To participate to capabilities collection, and extension should register to EVENT_SURROGATE_CAPABILITIES and provide capabilities when the event is fired.
driver.getEventManager().register(Surrogate.EVENT_SURROGATE_CAPABILITIES, new IEventListener() { public boolean event(EventDefinition id, Event event) { CapabilitiesEvent capEvent = (CapabilitiesEvent) event; capEvent.capabilities.add("ESI/1.0"); capEvent.capabilities.add("ESI-Inline/1.0"); capEvent.capabilities.add("ESIGATE/4.0"); return true; } });
The provider may respond with control directive. In that case, the extension should ensure that its capability are requested and do not process response otherwise.
if (renderEvent.httpResponse.containsHeader(Surrogate.H_X_ENABLED_CAPABILITIES)) { String capabilities = renderEvent.httpResponse.getFirstHeader(Surrogate.H_X_ENABLED_CAPABILITIES).getValue(); if (!containsIgnoreCase(capabilities, "ESI/1.0") { // Cancel processing } }
Targeting is supported.
NOTE:
Modifier and Type | Field and Description |
---|---|
static EventDefinition |
EVENT_SURROGATE_CAPABILITIES
This event is fired on startup to collect all installed capabilities.
|
static String |
H_X_ENABLED_CAPABILITIES
This is an internal header, used to track the requested capabilities.
|
Constructor and Description |
---|
Surrogate() |
Modifier and Type | Method and Description |
---|---|
boolean |
event(EventDefinition id,
Event event)
Handle an event.
|
void |
init(Driver driver,
Properties properties)
Initialize the extension using the given properties.
|
public static final String H_X_ENABLED_CAPABILITIES
Value is the value of the content directive from the Surrogate-Control header.
public static final EventDefinition EVENT_SURROGATE_CAPABILITIES
public void init(Driver driver, Properties properties)
Extension
Extensions may register to events during the init phase.
public boolean event(EventDefinition id, Event event)
IEventListener
event
in interface IEventListener
Copyright © 2008–2018. All rights reserved.