org.wings.externalizer
Class AbstractExternalizeManager

java.lang.Object
  extended by org.wings.externalizer.AbstractExternalizeManager
Direct Known Subclasses:
ExternalizeManager, SystemExternalizeManager

public abstract class AbstractExternalizeManager
extends Object

Author:
Armin Haaf

Field Summary
static int FINAL
          for an externalized object with the final flag on the expired date header is set to a big value.
 long FINAL_EXPIRES
          in seconds; Computed from UNIQUE_TIMESLICE; do not change.
static int GLOBAL
          for an externalized object with the gobal flag on, the externalized object is available to all requests.
protected static org.apache.commons.logging.Log LOG
           
static String NOT_FOUND_IDENTIFIER
          The identifier generated, if the ExternalizeManager did not find an apropriate Externalizer.
protected  long PREFIX_TIMESLICE
          Prefix for the externalized ID; long.
static int REQUEST
          for an externalized object with the request flag on, the externalized object is removed from the ExternalizeManager after one request of the object.
protected  Map<ExternalizedResource,String> reverseExternalized
          To search for an already externalized object.
static int SESSION
          for an externalized object with the session flag on, the externalized object only available to requests within the session which created the object.
protected  String sessionEncoding
          To support Session local externalizing, the ExternalizeManager needs to encode the session identifier of the servlet container in the URL of the externalized object.
 int UNIQUE_TIMESLICE
          in seconds
 
Constructor Summary
AbstractExternalizeManager()
           
 
Method Summary
 void clear()
           
protected  String createIdentifier()
           
 void deliver(ExternalizedResource extInfo, javax.servlet.http.HttpServletResponse response, Device out)
           
 void deliver(String identifier, javax.servlet.http.HttpServletResponse response, Device out)
          delivers a externalized object identfied with the given identifier to a client.
 String externalize(ExternalizedResource extInfo)
          externalizes (make a java object available for a browser) the object in extInfo.
 String externalize(Object obj, Externalizer externalizer)
          externalizes (make a java object available for a browser) an object with the given Externalizer.
 String externalize(Object obj, Externalizer externalizer, Collection headers)
          externalizes (make a java object available for a browser) an object with the given Externalizer.
 String externalize(Object obj, Externalizer externalizer, Collection headers, int flags)
          externalizes (make a java object available for a browser) an object with the given Externalizer.
 String externalize(Object obj, Externalizer externalizer, int flags)
          externalizes (make a java object available for a browser) an object with the given Externalizer.
 String externalize(Object obj, Externalizer externalizer, String mimeType)
          externalizes (make a java object available for a browser) an object with the given Externalizer.
 String externalize(Object obj, Externalizer externalizer, String mimeType, Collection headers)
          externalizes (make a java object available for a browser) an object with the given Externalizer.
 String externalize(Object obj, Externalizer externalizer, String mimeType, Collection headers, int flags)
          externalizes (make a java object available for a browser) an object with the given Externalizer.
abstract  ExternalizedResource getExternalizedResource(String identifier)
          get the ExternalizedResource by identifier.
 String getId(String url)
          externalizes (make a java object available for a browser) the object in extInfo.
protected  long getNextIdentifier()
           
 String getPrefix()
          String prefixed to every created externlizer identifier via createIdentifier()
abstract  void removeExternalizedResource(String identifier)
          removes the ExternalizedResource by identifier.
 void setPrefix(String prefix)
          String prefixed to every created externlizer identifier via createIdentifier()
 void setResponse(javax.servlet.http.HttpServletResponse response)
           
protected abstract  void storeExternalizedResource(String identifier, ExternalizedResource extInfo)
          store the ExternalizedResource in a map.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

LOG

protected static final org.apache.commons.logging.Log LOG

NOT_FOUND_IDENTIFIER

public static final String NOT_FOUND_IDENTIFIER
The identifier generated, if the ExternalizeManager did not find an apropriate Externalizer.

See Also:
Constant Field Values

UNIQUE_TIMESLICE

public final int UNIQUE_TIMESLICE
in seconds

See Also:
Constant Field Values

FINAL_EXPIRES

public final long FINAL_EXPIRES
in seconds; Computed from UNIQUE_TIMESLICE; do not change.


PREFIX_TIMESLICE

protected final long PREFIX_TIMESLICE
Prefix for the externalized ID; long. Computed, do not change.


FINAL

public static final int FINAL
for an externalized object with the final flag on the expired date header is set to a big value. If the final flag is off, the browser or proxy does not cache the object.

See Also:
Constant Field Values

REQUEST

public static final int REQUEST
for an externalized object with the request flag on, the externalized object is removed from the ExternalizeManager after one request of the object.

See Also:
Constant Field Values

SESSION

public static final int SESSION
for an externalized object with the session flag on, the externalized object only available to requests within the session which created the object. The object is not accessible anymore after the session is destroyed (it is garbage collected after the session is garbage collected)

See Also:
Constant Field Values

GLOBAL

public static final int GLOBAL
for an externalized object with the gobal flag on, the externalized object is available to all requests. Also it is never garbage collected and available for the lifecycle of the servlet container.

See Also:
Constant Field Values

reverseExternalized

protected final Map<ExternalizedResource,String> reverseExternalized
To search for an already externalized object. This performs way better than search in the value set of the identifier-ExternalizedResource map.


sessionEncoding

protected String sessionEncoding
To support Session local externalizing, the ExternalizeManager needs to encode the session identifier of the servlet container in the URL of the externalized object. This is set in the constructor and should work (I hope so) with all servlet containers.

Constructor Detail

AbstractExternalizeManager

public AbstractExternalizeManager()
Method Detail

setResponse

public void setResponse(javax.servlet.http.HttpServletResponse response)

getNextIdentifier

protected final long getNextIdentifier()

getPrefix

public String getPrefix()
String prefixed to every created externlizer identifier via createIdentifier()


setPrefix

public void setPrefix(String prefix)
String prefixed to every created externlizer identifier via createIdentifier()


createIdentifier

protected final String createIdentifier()

storeExternalizedResource

protected abstract void storeExternalizedResource(String identifier,
                                                  ExternalizedResource extInfo)
store the ExternalizedResource in a map. The ExternalizedResource should later on accessible by the identifier getExternalizedResource(java.lang.String), removeExternalizedResource(java.lang.String)


getExternalizedResource

public abstract ExternalizedResource getExternalizedResource(String identifier)
get the ExternalizedResource by identifier.

Returns:
null, if not found!!

removeExternalizedResource

public abstract void removeExternalizedResource(String identifier)
removes the ExternalizedResource by identifier.


externalize

public String externalize(Object obj,
                          Externalizer externalizer)
externalizes (make a java object available for a browser) an object with the given Externalizer. The object is externalized in the SESSION scope.

Returns:
a URL for accessing the object relative to the base URL.

externalize

public String externalize(Object obj,
                          Externalizer externalizer,
                          Collection headers)
externalizes (make a java object available for a browser) an object with the given Externalizer. If the given headers are !=null the headers overwrite the headers from the Externalizer. The object is externalized in the SESSION scope.

Returns:
a URL for accessing the object relative to the base URL.

externalize

public String externalize(Object obj,
                          Externalizer externalizer,
                          int flags)
externalizes (make a java object available for a browser) an object with the given Externalizer. Valid flags are (this may change, look also in the static variable section)

Returns:
a URL for accessing the object relative to the base URL.

externalize

public String externalize(Object obj,
                          Externalizer externalizer,
                          Collection headers,
                          int flags)
externalizes (make a java object available for a browser) an object with the given Externalizer. If the given headers are !=null the headers overwrite the headers from the Externalizer. Valid flags are (this may change, look also in the static variable section)

Returns:
a URL for accessing the object relative to the base URL.

externalize

public String externalize(Object obj,
                          Externalizer externalizer,
                          String mimeType)
externalizes (make a java object available for a browser) an object with the given Externalizer. If the mimeType!=null, mimeType overwrites the mimeType of the Externalizer. The object is externalized in the SESSION scope.

Returns:
a URL for accessing the object relative to the base URL.

externalize

public String externalize(Object obj,
                          Externalizer externalizer,
                          String mimeType,
                          Collection headers)
externalizes (make a java object available for a browser) an object with the given Externalizer. If the mimeType!=null, mimeType overwrites the mimeType of the Externalizer. If the given headers are !=null the headers overwrite the headers from the Externalizer.

Returns:
a URL for accessing the object relative to the base URL.

externalize

public String externalize(Object obj,
                          Externalizer externalizer,
                          String mimeType,
                          Collection headers,
                          int flags)
externalizes (make a java object available for a browser) an object with the given Externalizer. If the mimeType!=null, mimeType overwrites the mimeType of the Externalizer. If the given headers are !=null the headers overwrite the headers from the Externalizer. Valid flags are (this may change, look also in the static variable section)

Returns:
a URL for accessing the object relative to the base URL.

externalize

public String externalize(ExternalizedResource extInfo)
externalizes (make a java object available for a browser) the object in extInfo.

Returns:
a URL for accessing the externalized object relative to the base URL.

getId

public String getId(String url)
externalizes (make a java object available for a browser) the object in extInfo.

Returns:
a URL for accessing the externalized object relative to the base URL.

deliver

public void deliver(String identifier,
                    javax.servlet.http.HttpServletResponse response,
                    Device out)
             throws IOException
delivers a externalized object identfied with the given identifier to a client. It sends an error (404), if the identifier is not registered.

Throws:
IOException

deliver

public void deliver(ExternalizedResource extInfo,
                    javax.servlet.http.HttpServletResponse response,
                    Device out)
             throws IOException
Throws:
IOException

clear

public void clear()


wingS Swings ;-)