/** * See {@link #setContentLength(int)} for the reasons for proxying. * * @param len * parameter of the proxied method */ @ProxyMethod public void setContentLengthLong(final long len) { contentLengthHeaderModifications.add(new Runnable() { @Override public void run() { wrappedResponse.setContentLengthLong(len); } }); }
if (StringUtils.isEmpty(anno.methodName())) { methodPlan.methodName = method.getName(); } else { methodPlan.methodName = anno.methodName(); if (StringUtils.isEmpty(anno.returnType())) { methodPlan.returnType = method.getReturnType(); } else { methodPlan.returnType = getType(anno.returnType(), context); if (ArrayUtils.isEmpty(anno.parameterTypes())) { for (Class<?> paramType : targetMethodParamTypes) { methodPlan.parameterTypes.add(paramType); if (anno.parameterTypes().length != targetMethodParamTypes.length) { InvalidProxyDescriptionException.throwException("The parameter count in the ProxyMethod annotation " + "does not match the actual parameter count for " + method.getName()); for (int i = 0; i < anno.parameterTypes().length; i++) { String typeName = anno.parameterTypes()[i]; if (StringUtils.isEmpty(typeName)) { InvalidProxyDescriptionException.throwException("Invalid parameter type: %s", typeName); if (anno.isOptional()) {
/** * Overrides setContentLength to consume the call and to postpone it. When we inject our script * tag, the content length is not known beforehand. Therefore, in case we perform an injection, * we have to force chunked encoding by not setting any content length. * * @param len * the parameter from the proxied method. */ @ProxyMethod public void setContentLength(final int len) { contentLengthHeaderModifications.add(new Runnable() { @Override public void run() { wrappedResponse.setContentLength(len); } }); }
@Override @ProxyMethod public void flush() throws IOException { originalStream.flush(); }
@Override @ProxyMethod public void close() throws IOException { originalStream.close(); }
/** * Proxy method for setting the write listener. * * @param listener * write listener which should get set. */ @ProxyMethod(parameterTypes = { "javax.servlet.WriteListener" }, isOptional = true) public void setWriteListener(Object listener) { originalStream.setWriteListener(listener); }
/** * Proxy method for isReady method of the OutputStream. * * @return the ready state */ @ProxyMethod(isOptional = true) public boolean isReady() { return originalStream.isReady(); }
@ProxyMethod(methodName = "doubleInt") public int doubleInt_renamed(int a) { return 2 * a; }
@ProxyMethod public String sayHello() { return "Hello!"; }
/** * See {@link #setContentLength(int)} for the reasons for proxying. * * @param name * the name of the header * @param value * the value of the header */ @ProxyMethod public void setIntHeader(final String name, final int value) { if (CONTENT_LENGTH_HEADER_NAME.equalsIgnoreCase(name)) { contentLengthHeaderModifications.add(new Runnable() { @Override public void run() { wrappedResponse.setIntHeader(name, value); } }); } else { wrappedResponse.setIntHeader(name, value); } }
/** * Response status event. We can capture status here. * * @param version * version * @param status * status * @param reason * reason * @throws IOException * IOException */ @ProxyMethod(parameterTypes = { "org.eclipse.jetty.io.Buffer", "int", "org.eclipse.jetty.io.Buffer" }) public void onResponseStatus(Object version, int status, Object reason) throws IOException { this.status = status; if (null != originalListener) { WHttpEventListenerWrapper.ON_RESPONSE_STATUS.call(originalListener, version, status, reason); } }
/** * See {@link #setContentLength(int)} for the reasons for proxying. * * @param name * the name of the header * @param value * the value of the header */ @ProxyMethod public void addIntHeader(final String name, final int value) { if (CONTENT_LENGTH_HEADER_NAME.equalsIgnoreCase(name)) { contentLengthHeaderModifications.add(new Runnable() { @Override public void run() { wrappedResponse.addIntHeader(name, value); } }); } else { wrappedResponse.addIntHeader(name, value); } }
/** * See {@link #setContentLength(int)} for the reasons for proxying. * * @param name * the name of the header * @param value * the value of the header */ @ProxyMethod public void setHeader(final String name, final String value) { if (CONTENT_LENGTH_HEADER_NAME.equalsIgnoreCase(name)) { contentLengthHeaderModifications.add(new Runnable() { @Override public void run() { wrappedResponse.setHeader(name, value); } }); } else { wrappedResponse.setHeader(name, value); } }
/** * See {@link #setContentLength(int)} for the reasons for proxying. * * @param name * the name of the header * @param value * the value of the header */ @ProxyMethod public void addHeader(final String name, final String value) { if (CONTENT_LENGTH_HEADER_NAME.equalsIgnoreCase(name)) { contentLengthHeaderModifications.add(new Runnable() { @Override public void run() { wrappedResponse.addHeader(name, value); } }); } else { wrappedResponse.addHeader(name, value); } }
@ProxyMethod(returnType = "java.lang.StringBuffer") public Object createStringBuffer() { return new StringBuffer(); }
@ProxyMethod(parameterTypes = { "java.lang.StringBuffer", "java.lang.String" }) public void appendToStringBuffer(Object sb, Object stringToAppend) { ((StringBuffer) sb).append((String) stringToAppend); }
@ProxyMethod public void throwException() throws FileNotFoundException { throw new FileNotFoundException("testtext"); }
/** * Request committed event. This is earliest place we can start a span. * * @throws IOException * IOException */ @ProxyMethod() public void onRequestCommitted() throws IOException { spanStore.startSpan(); if (null != originalListener) { WHttpEventListenerWrapper.ON_REQUEST_COMMITED.call(originalListener); } }
/** * Connection failed. * * @param ex * Throwable */ @ProxyMethod(parameterTypes = "java.lang.Throwable") public void onConnectionFailed(Throwable ex) { handleThrowable(ex); if (null != originalListener) { WHttpEventListenerWrapper.ON_CONNECTION_FAILED.call(originalListener, ex); } }
/** * Exception occurred. * * @param ex * Throwable */ @ProxyMethod(parameterTypes = "java.lang.Throwable") public void onException(Throwable ex) { handleThrowable(ex); if (null != originalListener) { WHttpEventListenerWrapper.ON_EXCEPTION.call(originalListener, ex); } }