List of usage examples for com.google.gwt.rpc.server WebModeClientOracle load
public static WebModeClientOracle load(InputStream stream) throws IOException
From source file:net.zschech.gwt.comet.server.CometServlet.java
License:Apache License
protected ClientOracle getClientOracle(HttpServletRequest request) throws IOException { String permutationStrongName = request.getParameter(CometTransport.STRONG_NAME_PARAMETER); if (permutationStrongName == null) { return null; }/*from ww w . ja v a2s . com*/ ClientOracle toReturn; synchronized (clientOracleCache) { if (clientOracleCache.containsKey(permutationStrongName)) { toReturn = clientOracleCache.get(permutationStrongName).get(); if (toReturn != null) { return toReturn; } } if ("HostedMode".equals(permutationStrongName)) { // if (!allowHostedModeConnections()) { // throw new SecurityException("Blocked hosted mode request"); // } toReturn = new HostedModeClientOracle(); } else { String moduleBase = request.getParameter(CometTransport.MODULE_BASE_PARAMETER); if (moduleBase == null) { return null; } String basePath = new URL(moduleBase).getPath(); if (basePath == null) { throw new MalformedURLException( "Blocked request without GWT base path parameter (XSRF attack?)"); } String contextPath = getServletContext().getContextPath(); if (!basePath.startsWith(contextPath)) { throw new MalformedURLException( "Blocked request with invalid GWT base path parameter (XSRF attack?)"); } basePath = basePath.substring(contextPath.length()); InputStream in = findClientOracleData(basePath, permutationStrongName); toReturn = WebModeClientOracle.load(in); } clientOracleCache.put(permutationStrongName, new SoftReference<ClientOracle>(toReturn)); } return toReturn; }
From source file:org.atmosphere.gwt.server.impl.RPCUtil.java
License:Apache License
protected static ClientOracle getClientOracle(HttpServletRequest request, ServletContext context) throws IOException { String permutationStrongName = request.getParameter(Constants.STRONG_NAME_PARAMETER); if (permutationStrongName == null) { return null; }//from ww w. jav a 2s .co m ClientOracle toReturn; synchronized (clientOracleCache) { if (clientOracleCache.containsKey(permutationStrongName)) { toReturn = clientOracleCache.get(permutationStrongName).get(); if (toReturn != null) { return toReturn; } } if ("HostedMode".equals(permutationStrongName)) { // if (!allowHostedModeConnections()) { // throw new SecurityException("Blocked hosted mode request"); // } toReturn = new HostedModeClientOracle(); } else { String moduleBase = request.getParameter(Constants.MODULE_BASE_PARAMETER); if (moduleBase == null) { return null; } String basePath = new URL(moduleBase).getPath(); if (basePath == null) { throw new MalformedURLException( "Blocked request without GWT base path parameter (XSRF attack?)"); } String contextPath = context.getContextPath(); if (!basePath.startsWith(contextPath)) { throw new MalformedURLException( "Blocked request with invalid GWT base path parameter (XSRF attack?)"); } basePath = basePath.substring(contextPath.length()); InputStream in = findClientOracleData(basePath, permutationStrongName, context); toReturn = WebModeClientOracle.load(in); } clientOracleCache.put(permutationStrongName, new SoftReference<ClientOracle>(toReturn)); } return toReturn; }