|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjavax.servlet.GenericServlet
javax.servlet.http.HttpServlet
com.yworks.yfiles.server.tiles.servlet.BaseServlet
This is an abstract base class for the servlets in the yFiles AJAX servlet package. It provides utilities for server side code. These are
cacheGraph(HttpSession,String,Graph2D)
,
getId(Graph2D, Node)
,
getNodeURL(Graph2D, Node)
,
addViewConfigurator(Graph2D, ViewConfigurator)
,
Serialized FormField Summary | |
static Object |
EDGE_DESCRIPTION_KEY
DataProvider key used for setEdgeDescription(y.view.Graph2D, y.base.Edge, String)
and getEdgeDescription(y.view.Graph2D, y.base.Edge) |
static Object |
EDGE_URL_KEY
DataProvider key used for setEdgeURL(y.view.Graph2D, y.base.Edge, String)
and getEdgeURL(y.view.Graph2D, y.base.Edge) |
static Object |
NODE_DESCRIPTION_KEY
DataProvider key used for setNodeDescription(y.view.Graph2D, y.base.Node, String)
and getNodeDescription(y.view.Graph2D, y.base.Node) |
static Object |
NODE_URL_KEY
DataProvider key used for setNodeURL(y.view.Graph2D, y.base.Node, String)
and getNodeURL(y.view.Graph2D, y.base.Node) |
Constructor Summary | |
BaseServlet()
|
Method Summary | |
static void |
addViewConfigurator(Graph2D graph,
ViewConfigurator viewConfigurator)
adds the view configurator for the given graph. |
static String[] |
cachedGraphs(javax.servlet.http.HttpSession session)
returns the names of the cached graphs for the given session. |
static void |
cacheGraph(javax.servlet.http.HttpSession session,
String graphName,
Graph2D graph)
caches the given graph for the given name in the given session. |
protected void |
doGet(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
calls handleGetRequest(HttpServletRequest,HttpServletResponse) . |
protected void |
doPost(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
calls handlePostRequest(HttpServletRequest,HttpServletResponse) . |
static String |
getEdgeDescription(Graph2D graph,
Edge edge)
returns a description for a given edge. |
static URL |
getEdgeURL(Graph2D graph,
Edge edge)
returns a URL for a given edge. |
static Object |
getForId(Graph2D graph,
String id)
returns a graph element (node, edge, node label or edge label) for a given graph and an id or null, if not found. |
static Graph2D |
getGraph(javax.servlet.http.HttpSession session,
String graphName)
returns the graph cached for the given session and name or null, if not found. |
static Rectangle |
getGraphBounds(javax.servlet.http.HttpSession session,
String graphName)
returns the bounds of the cached graph for the given name and session or null, if not found. |
static Rectangle |
getGraphContentBounds(javax.servlet.http.HttpSession session,
String graphName)
returns the content bounds of the cached graph for the given name and session or null, if not found. |
static String |
getId(Graph2D graph,
Edge e)
Returns a unique ID for the given edge of the given graph. |
static String |
getId(Graph2D graph,
EdgeLabel el)
Returns a unique ID for the given edge label of the given graph. |
static String |
getId(Graph2D graph,
Node n)
Returns a unique ID for the given node of the given graph. |
static String |
getId(Graph2D graph,
NodeLabel nl)
Returns a unique ID for the given node label of the given graph. |
static String |
getNodeDescription(Graph2D graph,
Node node)
returns a description for a given node. |
static URL |
getNodeURL(Graph2D graph,
Node node)
returns a URL for a given node. |
static ReadWriteLock |
getReadWriteLock(Graph2D graph)
Get the ReadWriteLock instance associated with the provided graph. |
static Object |
getSessionMonitor(javax.servlet.http.HttpSession session)
Returns a monitor object attached to the provided session that can be used to synchronize on the session. |
static Set |
getViewConfigurators(Graph2D graph)
|
static PrintWriter |
getWriter(javax.servlet.http.HttpServletResponse response)
returns a PrintWriter for the given response with content type "text/json". |
protected void |
handleGetRequest(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
handles GET requests. |
protected void |
handlePostRequest(javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
handles POST requests. |
static boolean |
hasDescriptions(Graph2D graph)
returns true, if there is a data provider for descriptions for the given graph. |
static boolean |
hasURLs(Graph2D graph)
returns true, if there is a data provider for URLs for the given graph. |
void |
init()
calls initialize() . |
void |
initialize()
Deprecated. use init() instead. |
static boolean |
isUseJSONPrefixing()
|
static String |
lookupId(Graph2D graph,
Edge edge)
Returns the id that is assigned to the provided edge, or null
if no id was assigned yet. |
static String |
lookupId(Graph2D graph,
EdgeLabel edgeLabel)
Returns the id that is assigned to the provided edge label, or null
if no id was assigned yet. |
static String |
lookupId(Graph2D graph,
Node node)
Returns the id that is assigned to the provided node, or null
if no id was assigned yet. |
static String |
lookupId(Graph2D graph,
NodeLabel nodeLabel)
Returns the id that is assigned to the provided label, or null
if no id was assigned yet. |
static Graph2D |
newGraph()
returns a new empty graph which already has a hierarchy manager. |
static void |
readLock(Graph2D graph)
Aquire a read lock for the provided graph. |
static void |
registerLicense(String licenseData)
Register the yFiles AJAX license data as an xml string. |
static void |
removeViewConfigurator(Graph2D graph,
ViewConfigurator viewConfigurator)
removes the view configurator for the given graph. |
static void |
setEdgeDescription(Graph2D graph,
Edge edge,
String desc)
sets the description for a given edge. |
static void |
setEdgeURL(Graph2D graph,
Edge edge,
String urlString)
sets the URL for a given edge. |
static void |
setNodeDescription(Graph2D graph,
Node node,
String desc)
sets the description for a given node. |
static void |
setNodeURL(Graph2D graph,
Node node,
String urlString)
sets the URL for a given node. |
static void |
uncacheGraph(javax.servlet.http.HttpSession session,
String graphName)
removes the graph cached for the given name from the cache for the given session. |
static void |
unlockRead(Graph2D graph)
Release a read lock that has been aquired for the provided graph. |
static void |
unlockWrite(Graph2D graph)
Release a write lock that has been aquired for the provided graph. |
static void |
updateEdgePaths(Graph2D graph)
Make sure that the edge realizers are not dirty. |
static void |
validateIds(Graph2D graph)
Make sure that a unique id is assigned to all nodes, edges, node labels and edge labels. |
static void |
writeContentBounds(String graphName,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
|
static void |
writeLock(Graph2D graph)
Acquire a write lock for the provided graph. |
static void |
writeWorldBounds(String graphName,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
writes the world bounds of the graph with the given name cached for the session of the given request to the given response in JSON format. |
Methods inherited from class javax.servlet.http.HttpServlet |
doDelete, doHead, doOptions, doPut, doTrace, getLastModified, service, service |
Methods inherited from class javax.servlet.GenericServlet |
destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, log, log |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final Object NODE_URL_KEY
setNodeURL(y.view.Graph2D, y.base.Node, String)
and getNodeURL(y.view.Graph2D, y.base.Node)
public static final Object EDGE_URL_KEY
setEdgeURL(y.view.Graph2D, y.base.Edge, String)
and getEdgeURL(y.view.Graph2D, y.base.Edge)
public static final Object NODE_DESCRIPTION_KEY
setNodeDescription(y.view.Graph2D, y.base.Node, String)
and getNodeDescription(y.view.Graph2D, y.base.Node)
public static final Object EDGE_DESCRIPTION_KEY
setEdgeDescription(y.view.Graph2D, y.base.Edge, String)
and getEdgeDescription(y.view.Graph2D, y.base.Edge)
Constructor Detail |
public BaseServlet()
Method Detail |
public void init() throws javax.servlet.ServletException
initialize()
.
javax.servlet.ServletException
public static boolean isUseJSONPrefixing()
public void initialize() throws javax.servlet.ServletException
init()
instead.
init()
for backwards compatibility. In previous releases, init()
was final.
javax.servlet.ServletException
- if servlet related problems occurprotected final void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException
handlePostRequest(HttpServletRequest,HttpServletResponse)
.
request
- the requestresponse
- the response
javax.servlet.ServletException
IOException
protected void handlePostRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException
BaseServlet
. Subclasses should redefine this method,
if necessary. Note that doPost(HttpServletRequest,HttpServletResponse)
is final.
request
- the request from a clientresponse
- the response to be sent to the client
IOException
- if I/O problems occur
javax.servlet.ServletException
- if servlet related problems occurprotected final void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException
handleGetRequest(HttpServletRequest,HttpServletResponse)
.
request
- the requestresponse
- the response
javax.servlet.ServletException
IOException
protected void handleGetRequest(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException
BaseServlet
. Subclasses should redefine this method,
if necessary. Note that doGet(HttpServletRequest,HttpServletResponse)
is final.
request
- the request from a clientresponse
- the response to be sent to the client
IOException
- if I/O problems occur
javax.servlet.ServletException
- if servlet related problems occurpublic static void registerLicense(String licenseData)
WEB-INF
directory. Note that this method has to be called before any servlet requests
are handled by the BaseServlet or any derived Servlets.
licenseData
- The license data as an xml string.public static PrintWriter getWriter(javax.servlet.http.HttpServletResponse response) throws IOException
PrintWriter
for the given response with content type "text/json".
response
- the given response
IOException
- if the writer cannot be obtainedpublic static void writeWorldBounds(String graphName, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException
graphName
- the name of the graphrequest
- a servlet requestresponse
- the response for the request
IOException
- for problems writing the responsepublic static void writeContentBounds(String graphName, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws IOException
IOException
public static Object getForId(Graph2D graph, String id)
graph
- the graphid
- the id of the graph element
public static String getId(Graph2D graph, Node n)
graph
- the graphn
- the node
lookupId(y.view.Graph2D, y.base.Node)
,
validateIds(y.view.Graph2D)
,
getId(Graph2D, NodeLabel)
,
getId(Graph2D, Edge)
public static void validateIds(Graph2D graph)
getId(y.view.Graph2D, y.base.Node)
,
getId(y.view.Graph2D, NodeLabel)
,
getId(y.view.Graph2D, y.base.Edge)
,
getId(y.view.Graph2D, y.view.EdgeLabel)
,
lookupId(y.view.Graph2D, y.base.Node)
,
lookupId(y.view.Graph2D, NodeLabel)
,
lookupId(y.view.Graph2D, y.base.Edge)
public static String lookupId(Graph2D graph, Node node)
null
if no id was assigned yet.
Use getId(y.view.Graph2D, y.base.Node)
if a valid id should be created if necessary.
getId(y.view.Graph2D, y.base.Node)
,
validateIds(y.view.Graph2D)
public static String lookupId(Graph2D graph, Edge edge)
null
if no id was assigned yet.
Use getId(y.view.Graph2D, y.base.Edge)
if a valid id should be created if necessary.
getId(y.view.Graph2D, y.base.Edge)
,
validateIds(y.view.Graph2D)
public static String lookupId(Graph2D graph, NodeLabel nodeLabel)
null
if no id was assigned yet.
Use getId(y.view.Graph2D, y.view.NodeLabel)
if a valid id should be created if necessary.
getId(y.view.Graph2D, y.view.NodeLabel)
,
validateIds(y.view.Graph2D)
public static String lookupId(Graph2D graph, EdgeLabel edgeLabel)
null
if no id was assigned yet.
Use getId(y.view.Graph2D, y.view.EdgeLabel)
if a valid id should be created if necessary.
getId(y.view.Graph2D, y.view.EdgeLabel)
,
validateIds(y.view.Graph2D)
public static String getId(Graph2D graph, NodeLabel nl)
graph
- the graphnl
- the node label
lookupId(y.view.Graph2D, y.view.NodeLabel)
,
getId(Graph2D, Node)
,
getId(Graph2D, Edge)
,
validateIds(y.view.Graph2D)
public static String getId(Graph2D graph, Edge e)
graph
- the graphe
- the edge
lookupId(y.view.Graph2D, y.base.Edge)
,
validateIds(y.view.Graph2D)
,
getId(Graph2D, EdgeLabel)
,
getId(Graph2D, Node)
public static String getId(Graph2D graph, EdgeLabel el)
graph
- the graphel
- the edge label
lookupId(y.view.Graph2D, y.view.EdgeLabel)
,
validateIds(y.view.Graph2D)
,
getId(Graph2D, Edge)
,
getId(Graph2D, Node)
public static boolean hasURLs(Graph2D graph)
graph
- the given graph
hasDescriptions(Graph2D)
,
getNodeURL(Graph2D, Node)
,
getEdgeURL(Graph2D, Edge)
public static URL getNodeURL(Graph2D graph, Node node)
graph
- the graph, the node belongs tonode
- the given node
hasURLs(Graph2D)
,
setNodeURL(Graph2D, Node, String)
public static void setNodeURL(Graph2D graph, Node node, String urlString)
graph
- the graph, the node belongs tonode
- the given nodeurlString
- the URL to sethasURLs(Graph2D)
,
getNodeURL(Graph2D, Node)
public static URL getEdgeURL(Graph2D graph, Edge edge)
graph
- the graph, the edge belongs toedge
- the given edge
hasURLs(Graph2D)
,
setEdgeURL(Graph2D, Edge, String)
public static void setEdgeURL(Graph2D graph, Edge edge, String urlString)
graph
- the graph, the node belongs toedge
- the given edgeurlString
- the URL to sethasURLs(Graph2D)
,
getEdgeURL(Graph2D, Edge)
public static boolean hasDescriptions(Graph2D graph)
graph
- the given graph
hasURLs(Graph2D)
,
getNodeDescription(Graph2D, Node)
,
getEdgeDescription(Graph2D, Edge)
public static String getNodeDescription(Graph2D graph, Node node)
graph
- the graph, the node belongs tonode
- the given node
hasDescriptions(Graph2D)
,
setNodeDescription(Graph2D, Node, String)
public static void setNodeDescription(Graph2D graph, Node node, String desc)
graph
- the graph, the node belongs tonode
- the given nodedesc
- the description to be sethasDescriptions(Graph2D)
,
getNodeDescription(Graph2D, Node)
public static String getEdgeDescription(Graph2D graph, Edge edge)
graph
- the graph, the edge belongs toedge
- the given edge
hasDescriptions(Graph2D)
,
setEdgeDescription(Graph2D, Edge, String)
public static void setEdgeDescription(Graph2D graph, Edge edge, String desc)
graph
- the graph, the node belongs toedge
- the given edgedesc
- the description to be sethasDescriptions(Graph2D)
,
getEdgeDescription(Graph2D, Edge)
public static void cacheGraph(javax.servlet.http.HttpSession session, String graphName, Graph2D graph)
null
this method does nothing.
session
- the session for cachinggraphName
- the name for the graphgraph
- the graph to cachecachedGraphs(HttpSession)
,
uncacheGraph(HttpSession, String)
,
getGraph(HttpSession,String)
,
getGraphBounds(HttpSession,String)
public static Object getSessionMonitor(javax.servlet.http.HttpSession session)
public static void uncacheGraph(javax.servlet.http.HttpSession session, String graphName)
null
this method does nothing.
session
- the sessiongraphName
- the name of an entry to be removed from the cachecacheGraph(HttpSession, String, Graph2D)
,
cachedGraphs(HttpSession)
public static String[] cachedGraphs(javax.servlet.http.HttpSession session)
session
- the session
cacheGraph(HttpSession,String,Graph2D)
,
getGraph(HttpSession,String)
,
getGraphBounds(HttpSession,String)
public static Graph2D newGraph()
public static void updateEdgePaths(Graph2D graph)
EdgeRealizer.isDirty()
public static Graph2D getGraph(javax.servlet.http.HttpSession session, String graphName)
session
- the sessiongraphName
- the name of the graph
cacheGraph(HttpSession,String,Graph2D)
,
getGraphBounds(HttpSession,String)
public static Rectangle getGraphBounds(javax.servlet.http.HttpSession session, String graphName)
session
- the sessiongraphName
- the name of the graph
cacheGraph(HttpSession,String,Graph2D)
,
getGraph(HttpSession,String)
public static Rectangle getGraphContentBounds(javax.servlet.http.HttpSession session, String graphName)
session
- the sessiongraphName
- the name of the graph
cacheGraph(HttpSession,String,Graph2D)
,
getGraph(HttpSession,String)
public static void addViewConfigurator(Graph2D graph, ViewConfigurator viewConfigurator)
null
the method does nothing. If the given view configurator already belongs
to the set of view configurators for this graph, it will not be added again.
graph
- the graphviewConfigurator
- the configuratorgetViewConfigurators(Graph2D)
,
removeViewConfigurator(Graph2D, ViewConfigurator)
public static void removeViewConfigurator(Graph2D graph, ViewConfigurator viewConfigurator)
null
the method does nothing.
graph
- the graphviewConfigurator
- the configuratorgetViewConfigurators(Graph2D)
,
removeViewConfigurator(Graph2D, ViewConfigurator)
public static Set getViewConfigurators(Graph2D graph)
graph
- a graph
addViewConfigurator(Graph2D, ViewConfigurator)
,
removeViewConfigurator(Graph2D, ViewConfigurator)
public static void readLock(Graph2D graph)
unlockRead(y.view.Graph2D)
:
BaseServlet.readLock(graph); try { // read graph, e.g. iterate over the graph's nodes } finally { BaseServlet.unlockRead(graph) }
graph
- The graph instance that will be accessed by the read operationReadWriteLock
,
unlockRead(y.view.Graph2D)
,
writeLock(y.view.Graph2D)
,
getReadWriteLock(y.view.Graph2D)
public static void unlockRead(Graph2D graph)
graph
- The graph instance that was accessed by the calling threadReadWriteLock
,
readLock(y.view.Graph2D)
,
getReadWriteLock(y.view.Graph2D)
public static void writeLock(Graph2D graph)
unlockWrite(y.view.Graph2D)
:
BaseServlet.writeLock(graph); try { // modify the graph, e.g. add nodes or edges } finally { BaseServlet.unlockWrite(graph) }
graph
- The graph instance that will be modified by the calling threadReadWriteLock
,
unlockWrite(y.view.Graph2D)
,
readLock(y.view.Graph2D)
,
getReadWriteLock(y.view.Graph2D)
public static void unlockWrite(Graph2D graph)
graph
- The graph instance that was modified by the calling threadReadWriteLock
,
readLock(y.view.Graph2D)
,
getReadWriteLock(y.view.Graph2D)
public static ReadWriteLock getReadWriteLock(Graph2D graph)
graph
- A graph instance to obtain read/write locks for.
readLock(y.view.Graph2D)
,
unlockRead(y.view.Graph2D)
,
writeLock(y.view.Graph2D)
,
unlockWrite(y.view.Graph2D)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |