MCPcopy Create free account
hub / github.com/directwebremoting/dwr / BaseCallHandler

Class BaseCallHandler

etc/future/scanner/BaseCallHandler.java:65–616  ·  view source on GitHub ↗

A Marshaller that output plain Javascript. This marshaller can be tweaked to output Javascript in an HTML context. This class works in concert with CallScriptConduit, they should be considered closely related and it is important to understand what one does while editing the other. TODO: Double check

Source from the content-addressed store, hash-verified

63 * @author Joe Walker [joe at getahead dot ltd dot uk]
64 */
65public abstract class BaseCallHandler extends BaseDwrpHandler
66{
67 /* (non-Javadoc)
68 * @see org.directwebremoting.Handler#handle(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
69 */
70 public void handle(HttpServletRequest request, HttpServletResponse response) throws IOException
71 {
72 try
73 {
74 RealWebContext webContext = (RealWebContext) WebContextFactory.get();
75 CallBatch batch = new CallBatch(request);
76
77 // Security checks first, once we've parsed the input
78 checkGetAllowed(batch);
79 checkNotCsrfAttack(request, batch);
80
81 // Save the batch so marshallException can get at a batch id
82 request.setAttribute(ATTRIBUTE_BATCH, batch);
83
84 String normalizedPage = pageNormalizer.normalizePage(batch.getPage());
85 webContext.checkPageInformation(normalizedPage, batch.getScriptSessionId(), batch.getWindowName());
86
87 // Various bits of the CallBatch need to be stashed away places
88 storeParsedRequest(request, webContext, batch);
89
90 Calls calls = marshallInbound(batch);
91
92 Replies replies = remoter.execute(calls);
93 marshallOutbound(replies, response);
94 }
95 catch (Exception ex)
96 {
97 marshallException(request, response, ex);
98 }
99 }
100
101 /**
102 * Convert batch into calls.
103 * @param batch The data we've parsed from the request
104 * @return The function calls to make
105 */
106 @SuppressWarnings({"ThrowableInstanceNeverThrown"})
107 public Calls marshallInbound(CallBatch batch)
108 {
109 Calls calls = batch.getCalls();
110
111 // Debug the environment
112 if (log.isDebugEnabled() && calls.getCallCount() > 0)
113 {
114 // We can just use 0 because they are all shared
115 InboundContext inctx = batch.getInboundContexts().get(0);
116 StringBuffer buffer = new StringBuffer();
117
118 for (Iterator<String> it = inctx.getInboundVariableNames(); it.hasNext();)
119 {
120 String key = it.next();
121 InboundVariable value = inctx.getInboundVariable(key);
122 if (key.startsWith(ProtocolConstants.INBOUND_CALLNUM_PREFIX) &&

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…