/** * Retrieves the meta information object from the connection. * * @param connectionClass * the connection class. * @param connection * the connection instance. * @return the meta information object from the connection or <code>null</code> in case of * problems. */ private Object getMetaData(Class<?> connectionClass, Object connection) { return cache.invokeMethod(connectionClass, GET_META_DATA, null, connection, null, null, JAVA_SQL_CONNECTION_FQN); }
/** * Retrieves the version of the database. * * @param databaseMetaDataClass * the meta information class. * @param databaseMetaData * the meta information instance of the connection. * @return the version of the database. */ private String parseVersion(Class<?> databaseMetaDataClass, Object databaseMetaData) { return (String) cache.invokeMethod(databaseMetaDataClass, GET_DATABASE_PRODUCT_VERSION, null, databaseMetaData, null, null, JAVA_SQL_DATABASE_META_DATA_FQN); }
/** * {@inheritDoc} */ @Override public void setSpanStore(SpanStore spanStore) { cache.invokeMethod(httpContext.getClass(), "setAttribute", new Class<?>[] { String.class, Object.class }, httpContext, new Object[] { SpanStoreAdapter.Constants.ID, spanStore }, null); } }
/** * {@inheritDoc} */ @Override public String getHttpMethod() { return (String) cache.invokeMethod(jettyHttpExchange.getClass(), "getMethod", new Class<?>[] {}, jettyHttpExchange, new Object[] {}, null); }
/** * {@inheritDoc} */ @Override public int getStatus() { return (Integer) cache.invokeMethod(httpServletResponse.getClass(), "getStatus", new Class<?>[] {}, httpServletResponse, new Object[] {}, 0, JAVAX_SERVLET_HTTP_SERVLET_RESPONSE_FQN); }
/** * {@inheritDoc} */ @Override public String getHttpMethod() { return (String) cache.invokeMethod(httpServletRequest.getClass(), "getMethod", new Class<?>[] {}, httpServletRequest, new Object[] {}, null, JAVAX_SERVLET_HTTP_SERVLET_REQUEST_CLASS); }
/** * {@inheritDoc} */ @Override public SpanStore getSpanStore() { Object spanStore = cache.invokeMethod(httpContext.getClass(), "getAttribute", new Class<?>[] { String.class }, httpContext, new Object[] { SpanStoreAdapter.Constants.ID }, null); if (spanStore instanceof SpanStore) { return (SpanStore) spanStore; } return null; }
/** * {@inheritDoc} */ @Override public void put(String key, String value) { cache.invokeMethod(message.getClass(), "setStringProperty", new Class<?>[] { String.class, String.class }, message, new Object[] { key, value }, null, JAVAX_JMS_MESSAGE); }
/** * {@inheritDoc} */ @Override public void setSpanContext(SpanContext spanContext) { cache.invokeMethod(httpServletRequest.getClass(), "setAttribute", new Class<?>[] { String.class, Object.class }, httpServletRequest, new Object[] { SpanContextStore.Constants.ID, spanContext }, null, JAVAX_SERVLET_HTTP_SERVLET_REQUEST_CLASS); }
/** * {@inheritDoc} */ @Override public void put(String key, String value) { // can not go through interface as we are getting concrete implementation cache.invokeMethod(jettyHttpExchange.getClass(), "setRequestHeader", new Class<?>[] { String.class, String.class }, jettyHttpExchange, new Object[] { key, value }, null); }
/** * @return Returns the request line from the request. */ private Object getRequestLine() { return cache.invokeMethod(apacheHttpRequest.getClass(), "getRequestLine", new Class<?>[] {}, apacheHttpRequest, new Object[] {}, null, ORG_APACHE_HTTP_HTTP_REQUEST_FQN); }
/** * {@inheritDoc} */ @Override public String getUrl() { Object url = cache.invokeMethod(httpServletRequest.getClass(), "getRequestURL", new Class<?>[] {}, httpServletRequest, new Object[] {}, null, JAVAX_SERVLET_HTTP_SERVLET_REQUEST_CLASS); if (null != url) { return url.toString(); } else { // fail back to URI return (String) cache.invokeMethod(httpServletRequest.getClass(), "getRequestURI", new Class<?>[] {}, httpServletRequest, new Object[] {}, null, JAVAX_SERVLET_HTTP_SERVLET_REQUEST_CLASS); } }
/** * {@inheritDoc} */ @Override public int getStatus() { int result = 0; Object statusLine = cache.invokeMethod(apacheHttpResponse.getClass(), "getStatusLine", new Class<?>[] {}, apacheHttpResponse, new Object[] {}, null, ORG_APACHE_HTTP_HTTP_RESPONSE_FQN); if (null != statusLine) { result = (Integer) cache.invokeMethod(statusLine.getClass(), "getStatusCode", new Class<?>[] {}, statusLine, new Object[] {}, Integer.valueOf(0), ORG_APACHE_HTTP_STATUS_LINE_FQN); } return result; }
/** * {@inheritDoc} */ @Override public int getStatus() { return (Integer) cache.invokeMethod(springClientHttpResponse.getClass(), "getRawStatusCode", new Class[] {}, springClientHttpResponse, new Object[] {}, Integer.valueOf(0), ORG_SPRINGFRAMEWORK_HTTP_CLIENT_CLIENT_HTTP_RESPONSE); }
/** * {@inheritDoc} */ @Override public String getUrl() { // String template provides complete URL with the getURI() method Object uri = cache.invokeMethod(springHttpRequest.getClass(), "getURI", new Class[] {}, springHttpRequest, new Object[] {}, null, ORG_SPRINGFRAMEWORK_HTTP_HTTP_REQUEST); if (null != uri) { return uri.toString(); } return null; }
/** * {@inheritDoc} */ @Override public String getHttpMethod() { Object requestLine = getRequestLine(); if (null != requestLine) { return (String) cache.invokeMethod(requestLine.getClass(), "getMethod", new Class<?>[] {}, requestLine, new Object[] {}, null, ORG_APACHE_HTTP_REQUEST_LINE_FQN); } return null; }
/** * {@inheritDoc} */ @Override public void put(String key, String value) { Object headers = getHttpHeaders(); if (null != headers) { cache.invokeMethod(headers.getClass(), "set", new Class[] { String.class, String.class }, headers, new Object[] { key, value }, null); } }
@Test public void throughInterfaceNotExisting() { Object object = "string"; Integer result = (Integer) cache.invokeMethod(String.class, "compareTo", new Class<?>[] { Object.class }, object, new Object[] { object }, -1, "my.ComparableClass"); assertThat(result, is(0)); }
@Test public void methodDoesNotExist() { Object errorvalue = "errorvalue"; Object result = cache.invokeMethod(String.class, "methodDoesNotExist", null, "test", null, errorvalue); assertThat(result, is(errorvalue)); }
@Test public void throughInterfaceMethodNotExisting() { String object = "string"; String result = (String) cache.invokeMethod(String.class, "toString", null, object, null, "errorValue", Comparable.class.getName()); assertThat(result, is(object)); }