org.faceless.graph2.tag
Class GraphContext

java.lang.Object
  extended by org.faceless.graph2.tag.GraphContext

public class GraphContext
extends Object

The GraphContext is the equivalent of the ServletContext, and manages the generated graphs, their resources and the Embedders/RequestHandlers that are used to create and serve them. Unless you're creating your own RequestHandler you will not need to access this class.

Since:
2.4

Method Summary
 void destroy()
          Destroy this GraphContext - must be called when the ServletContext is reloaded.
 EmbedderFactory getEmbedderFactory(String type)
          Get the EmbedderFactory that closest matches the specified type, which may be a default EmbedderFactory if no direct match is found.
 byte[] getFile(String pageid, String graphid)
          Return a generated file saved with putFile()
 String getFileType(String pageid, String graphid)
          Return the MIME-type of the generated file saved with putFile()
static GraphContext getGraphContext(ServletContext sc)
          Retrieve the GraphContext object for the specified ServletContext.
static GraphContext getGraphContext(ServletContext sc, HttpServletRequest req)
           Retrieve the GraphContext object for the specified context.
 RequestHandler getRequestHandler(String type)
          Get a RequestHandler that matches the specified type, or null if no matching handlers are found.
 Map getResources()
          Return a context-wide Map that can be used to save general resources
 String nextPageId()
          Return a new unique ID for the next page - guaranteed to be unique
 void putFile(String pageid, String graphid, byte[] data, String mimetype)
          Store a generated Image
 void setStoreSize(int storesize)
          Set the maximum number of pages to keep around before they're freed.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getGraphContext

public static GraphContext getGraphContext(ServletContext sc)
Retrieve the GraphContext object for the specified ServletContext. Calls getGraphContext(sc, null)

Parameters:
sc - the Servlet Context

getGraphContext

public static GraphContext getGraphContext(ServletContext sc,
                                           HttpServletRequest req)

Retrieve the GraphContext object for the specified context. One is created if it doesn't exist.

Which context is used (the session or the ServletContext) depends on the org.faceless.graph2.tag.UseSession init-parameter. If this is set to true, graphs will be stored in the session. This is required for clustered load-balancing.

Parameters:
sc - the Servlet Context
req - the HTTP request - only required if graphs are to be stored in the session context

destroy

public void destroy()
Destroy this GraphContext - must be called when the ServletContext is reloaded.


setStoreSize

public void setStoreSize(int storesize)
Set the maximum number of pages to keep around before they're freed. This isn't exactly the same as the number of graphs - a page may have more than one graph on it. The default is "50"

Parameters:
storesize - the size of the page store

getRequestHandler

public RequestHandler getRequestHandler(String type)
Get a RequestHandler that matches the specified type, or null if no matching handlers are found.

Parameters:
type - the type

getEmbedderFactory

public EmbedderFactory getEmbedderFactory(String type)
Get the EmbedderFactory that closest matches the specified type, which may be a default EmbedderFactory if no direct match is found.

Parameters:
type - the type

nextPageId

public String nextPageId()
Return a new unique ID for the next page - guaranteed to be unique


putFile

public void putFile(String pageid,
                    String graphid,
                    byte[] data,
                    String mimetype)
Store a generated Image

Parameters:
pageid - the page id
graphid - the graph id - must be unique on the specified page
data - the data
mimetype - the MIME-type of the image

getFile

public byte[] getFile(String pageid,
                      String graphid)
Return a generated file saved with putFile()

Parameters:
pageid - the page id
graphid - the graph id

getFileType

public String getFileType(String pageid,
                          String graphid)
Return the MIME-type of the generated file saved with putFile()

Parameters:
pageid - the page id
graphid - the graph id

getResources

public Map getResources()
Return a context-wide Map that can be used to save general resources



Copyright © 2001-2011 Big Faceless Organization