com.yworks.yfiles.server.tiles.demos
Class InfoServlet
java.lang.Object
javax.servlet.GenericServlet
javax.servlet.http.HttpServlet
com.yworks.yfiles.server.tiles.servlet.BaseServlet
com.yworks.yfiles.server.tiles.demos.InfoServlet
- All Implemented Interfaces:
- Serializable, Servlet, ServletConfig
public class InfoServlet
- extends BaseServlet
This servlet provides information on a graph.
The information is available on diferent levels. There is information on the graph as a whole, e.g., the number of
nodes. There is information on parts of the graph, e.g., on a single node or a single edge. Information for a certain
aspect of the graph can also point to further information. The information for an edge for example points to two node
informations, one for the source node and one for the target node of the edge.
The information is accessed using a path in a logical tree. The information for graph foo is accessible via
a URL like the following.
http://www.mycompany.com/yfiles-ajax/graphs/foo
Information on node 42 of that graph is accessed like this.
http://www.mycompany.com/yfiles-ajax/graphs/foo/nodes/42
The returned information is in JSON format.
- See Also:
- Serialized Form
| Methods inherited from class com.yworks.yfiles.server.tiles.servlet.BaseServlet |
cachedGraphs, cacheGraph, doGet, doPost, getEdgeDescription, getEdgeURL, getForId, getGraph, getGraphBounds, getId, getId, getId, getId, getNodeDescription, getNodeURL, getWriter, hasDescriptions, hasURLs, init, initialize, newGraph, setEdgeDescription, setEdgeURL, setNodeDescription, setNodeURL, uncacheGraph, writeWorldBounds |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
InfoServlet
public InfoServlet()
handleGetRequest
protected void handleGetRequest(HttpServletRequest request,
HttpServletResponse response)
throws ServletException,
IOException
- answers "GET" requests for graph information.
A request has the format of a logical path starting with "/graphs", e.g., information on node 42 of
graph foo is accessed like this.
http://www.mycompany.com/yfiles-ajax/graphs/foo/nodes/42
The following logical paths are supported.
- .../graphs returns a list of known graph names (we assume that foo is among
them in the following)
- .../graphs/foo returns global information on the graph named foo
- .../graphs/foo/world_bounds returns the world bounds for the graph named foo
- .../graphs/foo/nodes returns the list of nodes for the graph named foo
- .../graphs/foo/edges returns the list of edges for the graph named foo
- .../graphs/foo/nodes/42 returns information on node 42 of the graph named foo
- .../graphs/foo/edges/7 returns information on edge 7 of the graph named foo
A graph is known to this servlet for the current session, if it is cached in the session (see
BaseServlet.cachedGraphs(HttpSession)).
NOTE: Information on a graph can only be obtained, if it is already in the cache for the session.
- Overrides:
handleGetRequest in class BaseServlet
- Parameters:
request - the requestresponse - the response to write to
- Throws:
ServletException
IOException
handlePostRequest
protected void handlePostRequest(HttpServletRequest request,
HttpServletResponse response)
throws ServletException,
IOException
- calls
handleGetRequest(HttpServletRequest, HttpServletResponse).
This is a convenience method, since it might be better to use a "POST" request, if the graph changes over time
and the browser caches "GET" requests. "POST" requests are never cached.
- Overrides:
handlePostRequest in class BaseServlet
- Parameters:
request - the requestresponse - the response to write to
- Throws:
ServletException
IOException
getRequestPath
protected String[] getRequestPath(HttpServletRequest request)
- returns the request path as an array of Strings, one for each element of the path. This
method also normalizes the path by removing a trailing slash and everything before "/graphs".
- Parameters:
request - the request
- Returns:
- the elements of the request path as an array of strings
Copyright © 2006-2008 yWorks GmbH. All rights reserved