You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by ol...@apache.org on 2013/07/25 14:28:47 UTC

svn commit: r1506926 - in /commons/sandbox/monitoring/trunk: ./ cdi/ cdi/src/ cdi/src/main/ cdi/src/main/java/ cdi/src/main/java/org/ cdi/src/main/java/org/apache/ cdi/src/main/java/org/apache/commons/ cdi/src/main/java/org/apache/commons/monitoring/ c...

Author: olamy
Date: Thu Jul 25 12:28:46 2013
New Revision: 1506926

URL: http://svn.apache.org/r1506926
Log:
apply path provided by Romain Manni-Bucau

Added:
    commons/sandbox/monitoring/trunk/cdi/
    commons/sandbox/monitoring/trunk/cdi/commons-monitoring-cdi.iml
    commons/sandbox/monitoring/trunk/cdi/pom.xml   (with props)
    commons/sandbox/monitoring/trunk/cdi/src/
    commons/sandbox/monitoring/trunk/cdi/src/main/
    commons/sandbox/monitoring/trunk/cdi/src/main/java/
    commons/sandbox/monitoring/trunk/cdi/src/main/java/org/
    commons/sandbox/monitoring/trunk/cdi/src/main/java/org/apache/
    commons/sandbox/monitoring/trunk/cdi/src/main/java/org/apache/commons/
    commons/sandbox/monitoring/trunk/cdi/src/main/java/org/apache/commons/monitoring/
    commons/sandbox/monitoring/trunk/cdi/src/main/java/org/apache/commons/monitoring/cdi/
    commons/sandbox/monitoring/trunk/cdi/src/main/java/org/apache/commons/monitoring/cdi/CommonsMonitoringInterceptor.java   (with props)
    commons/sandbox/monitoring/trunk/cdi/src/main/java/org/apache/commons/monitoring/cdi/Monitored.java   (with props)
    commons/sandbox/monitoring/trunk/cdi/src/main/resources/
    commons/sandbox/monitoring/trunk/cdi/src/main/resources/META-INF/
    commons/sandbox/monitoring/trunk/cdi/src/main/resources/META-INF/beans.xml   (with props)
    commons/sandbox/monitoring/trunk/cdi/src/test/
    commons/sandbox/monitoring/trunk/cdi/src/test/java/
    commons/sandbox/monitoring/trunk/cdi/src/test/java/org/
    commons/sandbox/monitoring/trunk/cdi/src/test/java/org/apache/
    commons/sandbox/monitoring/trunk/cdi/src/test/java/org/apache/commons/
    commons/sandbox/monitoring/trunk/cdi/src/test/java/org/apache/commons/monitoring/
    commons/sandbox/monitoring/trunk/cdi/src/test/java/org/apache/commons/monitoring/cdi/
    commons/sandbox/monitoring/trunk/cdi/src/test/java/org/apache/commons/monitoring/cdi/CommonsMonitoringInterceptorTest.java   (with props)
    commons/sandbox/monitoring/trunk/cdi/src/test/resources/
    commons/sandbox/monitoring/trunk/cdi/src/test/resources/META-INF/
    commons/sandbox/monitoring/trunk/cdi/src/test/resources/META-INF/beans.xml   (with props)
    commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/repositories/RepositoryFinder.java   (with props)
    commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/util/
    commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/util/ClassLoaders.java   (with props)
Modified:
    commons/sandbox/monitoring/trunk/jdbc/src/main/java/org/apache/commons/monitoring/jdbc/MonitoredCallableStatement.java
    commons/sandbox/monitoring/trunk/jdbc/src/main/java/org/apache/commons/monitoring/jdbc/MonitoredConnectionHandler.java
    commons/sandbox/monitoring/trunk/jdbc/src/main/java/org/apache/commons/monitoring/jdbc/MonitoredStatementHandler.java
    commons/sandbox/monitoring/trunk/pom.xml

Added: commons/sandbox/monitoring/trunk/cdi/commons-monitoring-cdi.iml
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/cdi/commons-monitoring-cdi.iml?rev=1506926&view=auto
==============================================================================
--- commons/sandbox/monitoring/trunk/cdi/commons-monitoring-cdi.iml (added)
+++ commons/sandbox/monitoring/trunk/cdi/commons-monitoring-cdi.iml Thu Jul 25 12:28:46 2013
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
+  <component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5" inherit-compiler-output="true">
+    <exclude-output />
+    <content url="file://$MODULE_DIR$">
+      <sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/main/resources" isTestSource="false" />
+      <sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
+      <sourceFolder url="file://$MODULE_DIR$/src/test/resources" isTestSource="true" />
+      <excludeFolder url="file://$MODULE_DIR$/target" />
+    </content>
+    <orderEntry type="inheritedJdk" />
+    <orderEntry type="sourceFolder" forTests="false" />
+    <orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.geronimo.specs:geronimo-jcdi_1.0_spec:1.0" level="project" />
+    <orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.geronimo.specs:geronimo-interceptor_1.1_spec:1.0" level="project" />
+    <orderEntry type="module" module-name="commons-monitoring-instrumentation" />
+    <orderEntry type="module" module-name="commons-monitoring-core" />
+    <orderEntry type="library" name="Maven: org.apache.commons:commons-math:2.0" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: junit:junit:4.11" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.hamcrest:hamcrest-core:1.3" level="project" />
+    <orderEntry type="library" name="Maven: org.apache.geronimo.specs:geronimo-servlet_2.5_spec:1.2" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.openwebbeans.test:cditest-owb:1.2.0" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.openwebbeans.test:cditest:1.2.0" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.geronimo.specs:geronimo-atinject_1.0_spec:1.0" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.openwebbeans:openwebbeans-spi:1.2.0" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.openwebbeans:openwebbeans-impl:1.2.0" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.xbean:xbean-finder-shaded:3.13" level="project" />
+    <orderEntry type="library" scope="TEST" name="Maven: org.apache.xbean:xbean-asm-shaded:3.13" level="project" />
+  </component>
+</module>
+

Added: commons/sandbox/monitoring/trunk/cdi/pom.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/cdi/pom.xml?rev=1506926&view=auto
==============================================================================
--- commons/sandbox/monitoring/trunk/cdi/pom.xml (added)
+++ commons/sandbox/monitoring/trunk/cdi/pom.xml Thu Jul 25 12:28:46 2013
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one or more
+  contributor license agreements.  See the NOTICE file distributed with
+  this work for additional information regarding copyright ownership.
+  The ASF licenses this file to You under the Apache License, Version 2.0
+  (the "License"); you may not use this file except in compliance with
+  the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+  <parent>
+    <artifactId>commons-monitoring-parent</artifactId>
+    <groupId>org.apache.commons.monitoring</groupId>
+    <version>1.0-SNAPSHOT</version>
+  </parent>
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <artifactId>commons-monitoring-cdi</artifactId>
+  <name>Commons Monitoring (Sandbox) :: CDI Integration</name>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.geronimo.specs</groupId>
+      <artifactId>geronimo-jcdi_1.0_spec</artifactId>
+      <version>1.0</version>
+      <scope>provided</scope>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.geronimo.specs</groupId>
+      <artifactId>geronimo-interceptor_1.1_spec</artifactId>
+      <version>1.0</version>
+      <scope>provided</scope>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.commons.monitoring</groupId>
+      <artifactId>commons-monitoring-instrumentation</artifactId>
+      <version>${project.version}</version>
+    </dependency>
+
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit</artifactId>
+    </dependency>
+    <dependency>
+      <groupId>org.apache.geronimo.specs</groupId>
+      <artifactId>geronimo-servlet_2.5_spec</artifactId>
+      <version>1.2</version>
+    </dependency>
+
+    <dependency>
+      <groupId>org.apache.openwebbeans.test</groupId>
+      <artifactId>cditest-owb</artifactId>
+      <version>1.2.0</version>
+      <scope>test</scope>
+    </dependency>
+  </dependencies>
+
+</project>

Propchange: commons/sandbox/monitoring/trunk/cdi/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/monitoring/trunk/cdi/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: commons/sandbox/monitoring/trunk/cdi/src/main/java/org/apache/commons/monitoring/cdi/CommonsMonitoringInterceptor.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/cdi/src/main/java/org/apache/commons/monitoring/cdi/CommonsMonitoringInterceptor.java?rev=1506926&view=auto
==============================================================================
--- commons/sandbox/monitoring/trunk/cdi/src/main/java/org/apache/commons/monitoring/cdi/CommonsMonitoringInterceptor.java (added)
+++ commons/sandbox/monitoring/trunk/cdi/src/main/java/org/apache/commons/monitoring/cdi/CommonsMonitoringInterceptor.java Thu Jul 25 12:28:46 2013
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.monitoring.cdi;
+
+import org.apache.commons.monitoring.instrumentation.aop.AbstractPerformanceInterceptor;
+import org.apache.commons.monitoring.repositories.RepositoryFinder;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InvocationContext;
+
+@Interceptor @Monitored
+public class CommonsMonitoringInterceptor extends AbstractPerformanceInterceptor<InvocationContext> {
+    public CommonsMonitoringInterceptor() {
+        setRepository(RepositoryFinder.REPOSITORY);
+    }
+
+    @AroundInvoke
+    public Object monitor(final InvocationContext invocationContext) throws Throwable
+    {
+        return doInvoke(invocationContext);
+    }
+
+    @Override
+    protected Object proceed(final InvocationContext invocation) throws Throwable
+    {
+        return invocation.proceed();
+    }
+
+    @Override
+    protected String getMonitorName(InvocationContext invocation)
+    {
+        return getMonitorName(invocation.getMethod());
+    }
+}

Propchange: commons/sandbox/monitoring/trunk/cdi/src/main/java/org/apache/commons/monitoring/cdi/CommonsMonitoringInterceptor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/monitoring/trunk/cdi/src/main/java/org/apache/commons/monitoring/cdi/CommonsMonitoringInterceptor.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: commons/sandbox/monitoring/trunk/cdi/src/main/java/org/apache/commons/monitoring/cdi/Monitored.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/cdi/src/main/java/org/apache/commons/monitoring/cdi/Monitored.java?rev=1506926&view=auto
==============================================================================
--- commons/sandbox/monitoring/trunk/cdi/src/main/java/org/apache/commons/monitoring/cdi/Monitored.java (added)
+++ commons/sandbox/monitoring/trunk/cdi/src/main/java/org/apache/commons/monitoring/cdi/Monitored.java Thu Jul 25 12:28:46 2013
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.monitoring.cdi;
+
+import javax.interceptor.InterceptorBinding;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@InterceptorBinding
+@Target({ElementType.TYPE, ElementType.METHOD })
+@Retention(RetentionPolicy.RUNTIME)
+public @interface Monitored {
+}

Propchange: commons/sandbox/monitoring/trunk/cdi/src/main/java/org/apache/commons/monitoring/cdi/Monitored.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/monitoring/trunk/cdi/src/main/java/org/apache/commons/monitoring/cdi/Monitored.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: commons/sandbox/monitoring/trunk/cdi/src/main/resources/META-INF/beans.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/cdi/src/main/resources/META-INF/beans.xml?rev=1506926&view=auto
==============================================================================
--- commons/sandbox/monitoring/trunk/cdi/src/main/resources/META-INF/beans.xml (added)
+++ commons/sandbox/monitoring/trunk/cdi/src/main/resources/META-INF/beans.xml Thu Jul 25 12:28:46 2013
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+                            http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
+  <interceptors>
+    <class>org.apache.commons.monitoring.cdi.CommonsMonitoringInterceptor</class>
+  </interceptors>
+</beans>

Propchange: commons/sandbox/monitoring/trunk/cdi/src/main/resources/META-INF/beans.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/monitoring/trunk/cdi/src/main/resources/META-INF/beans.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: commons/sandbox/monitoring/trunk/cdi/src/test/java/org/apache/commons/monitoring/cdi/CommonsMonitoringInterceptorTest.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/cdi/src/test/java/org/apache/commons/monitoring/cdi/CommonsMonitoringInterceptorTest.java?rev=1506926&view=auto
==============================================================================
--- commons/sandbox/monitoring/trunk/cdi/src/test/java/org/apache/commons/monitoring/cdi/CommonsMonitoringInterceptorTest.java (added)
+++ commons/sandbox/monitoring/trunk/cdi/src/test/java/org/apache/commons/monitoring/cdi/CommonsMonitoringInterceptorTest.java Thu Jul 25 12:28:46 2013
@@ -0,0 +1,64 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.monitoring.cdi;
+
+import org.apache.commons.monitoring.Counter;
+import org.apache.commons.monitoring.repositories.RepositoryFinder;
+import org.apache.webbeans.cditest.CdiTestContainer;
+import org.apache.webbeans.cditest.CdiTestContainerLoader;
+import org.junit.Test;
+
+import javax.enterprise.context.ApplicationScoped;
+import javax.enterprise.inject.spi.BeanManager;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+
+public class CommonsMonitoringInterceptorTest
+{
+    @Test
+    public void checkMeasures() throws Exception
+    {
+        final CdiTestContainer container = CdiTestContainerLoader.getCdiContainer();
+        container.bootContainer();
+        container.startApplicationScope();
+
+        final BeanManager beanManager = container.getBeanManager();
+        final MonitoredBean bean = MonitoredBean.class.cast(beanManager.getReference(beanManager.resolve(beanManager.getBeans(MonitoredBean.class)), MonitoredBean.class, null));
+
+        bean.twoSeconds();
+
+        container.stopApplicationScope();
+        container.shutdownContainer();
+
+        final Counter perf = RepositoryFinder.REPOSITORY.getMonitor(MonitoredBean.class.getName() + ".twoSeconds").getCounter("performances");
+        assertNotNull(perf);
+
+        assertEquals(2000, perf.getMax(), 200);
+    }
+
+    @Monitored @ApplicationScoped
+    public static class MonitoredBean {
+        public void twoSeconds() {
+            try {
+                Thread.sleep(2000);
+            } catch (final InterruptedException e) {
+                // no-op
+            }
+        }
+    }
+}

Propchange: commons/sandbox/monitoring/trunk/cdi/src/test/java/org/apache/commons/monitoring/cdi/CommonsMonitoringInterceptorTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/monitoring/trunk/cdi/src/test/java/org/apache/commons/monitoring/cdi/CommonsMonitoringInterceptorTest.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: commons/sandbox/monitoring/trunk/cdi/src/test/resources/META-INF/beans.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/cdi/src/test/resources/META-INF/beans.xml?rev=1506926&view=auto
==============================================================================
--- commons/sandbox/monitoring/trunk/cdi/src/test/resources/META-INF/beans.xml (added)
+++ commons/sandbox/monitoring/trunk/cdi/src/test/resources/META-INF/beans.xml Thu Jul 25 12:28:46 2013
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  Licensed to the Apache Software Foundation (ASF) under one
+  or more contributor license agreements.  See the NOTICE file
+  distributed with this work for additional information
+  regarding copyright ownership.  The ASF licenses this file
+  to you under the Apache License, Version 2.0 (the
+  "License"); you may not use this file except in compliance
+  with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing,
+  software distributed under the License is distributed on an
+  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+  KIND, either express or implied.  See the License for the
+  specific language governing permissions and limitations
+  under the License.
+-->
+<beans xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
+                            http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
+
+</beans>

Propchange: commons/sandbox/monitoring/trunk/cdi/src/test/resources/META-INF/beans.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/monitoring/trunk/cdi/src/test/resources/META-INF/beans.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/repositories/RepositoryFinder.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/repositories/RepositoryFinder.java?rev=1506926&view=auto
==============================================================================
--- commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/repositories/RepositoryFinder.java (added)
+++ commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/repositories/RepositoryFinder.java Thu Jul 25 12:28:46 2013
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.monitoring.repositories;
+
+import org.apache.commons.monitoring.Repository;
+
+import java.util.Iterator;
+import java.util.ServiceLoader;
+
+public final class RepositoryFinder
+{
+    public static final Repository REPOSITORY = findRepository();
+
+    private static Repository findRepository() {
+        final ServiceLoader<Repository> loader = ServiceLoader.load(Repository.class, RepositoryFinder.class.getClassLoader());
+        final Iterator<Repository> iterator = loader.iterator();
+        if (iterator.hasNext())
+        {
+            return iterator.next();
+        }
+        return new DefaultRepository();
+    }
+
+    private RepositoryFinder() {
+        // no-op
+    }
+}

Propchange: commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/repositories/RepositoryFinder.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/repositories/RepositoryFinder.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Added: commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/util/ClassLoaders.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/util/ClassLoaders.java?rev=1506926&view=auto
==============================================================================
--- commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/util/ClassLoaders.java (added)
+++ commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/util/ClassLoaders.java Thu Jul 25 12:28:46 2013
@@ -0,0 +1,34 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.commons.monitoring.util;
+
+public final class ClassLoaders
+{
+    public static ClassLoader current()
+    {
+        final ClassLoader tccl = Thread.currentThread().getContextClassLoader();
+        if (tccl != null) {
+            return tccl;
+        }
+        return ClassLoaders.class.getClassLoader();
+    }
+
+    private ClassLoaders()
+    {
+        // no-op
+    }
+}

Propchange: commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/util/ClassLoaders.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: commons/sandbox/monitoring/trunk/core/src/main/java/org/apache/commons/monitoring/util/ClassLoaders.java
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision

Modified: commons/sandbox/monitoring/trunk/jdbc/src/main/java/org/apache/commons/monitoring/jdbc/MonitoredCallableStatement.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/jdbc/src/main/java/org/apache/commons/monitoring/jdbc/MonitoredCallableStatement.java?rev=1506926&r1=1506925&r2=1506926&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/jdbc/src/main/java/org/apache/commons/monitoring/jdbc/MonitoredCallableStatement.java (original)
+++ commons/sandbox/monitoring/trunk/jdbc/src/main/java/org/apache/commons/monitoring/jdbc/MonitoredCallableStatement.java Thu Jul 25 12:28:46 2013
@@ -1,717 +1,717 @@
-package org.apache.commons.monitoring.jdbc;
-
-import java.io.InputStream;
-import java.io.Reader;
-import java.math.BigDecimal;
-import java.net.URL;
-import java.sql.Array;
-import java.sql.Blob;
-import java.sql.CallableStatement;
-import java.sql.Clob;
-import java.sql.Date;
-import java.sql.NClob;
-import java.sql.Ref;
-import java.sql.RowId;
-import java.sql.SQLException;
-import java.sql.SQLXML;
-import java.sql.Time;
-import java.sql.Timestamp;
-import java.util.Calendar;
-import java.util.Map;
-
-import org.apache.commons.monitoring.Repository;
-import org.apache.commons.monitoring.jdbc.MonitoredPreparedStatement;
-
-/**
- * @author ndeloof
- *
- */
-public class MonitoredCallableStatement
-    extends MonitoredPreparedStatement
-    implements CallableStatement
-{
-    private CallableStatement statement;
-
-    /**
-     * @param statement
-     * @param sql
-     * @param repository
-     */
-    public MonitoredCallableStatement( CallableStatement statement, String sql, Repository repository )
-    {
-        super( statement, sql, repository );
-        this.statement = statement;
-    }
-
-    // --- delegate methods ---
-
-    public Array getArray( int i )
-        throws SQLException
-    {
-        return statement.getArray( i );
-    }
-
-    public Array getArray( String parameterName )
-        throws SQLException
-    {
-        return statement.getArray( parameterName );
-    }
-
-    @Deprecated
-    public BigDecimal getBigDecimal( int parameterIndex, int scale )
-        throws SQLException
-    {
-        return statement.getBigDecimal( parameterIndex, scale );
-    }
-
-    public BigDecimal getBigDecimal( int parameterIndex )
-        throws SQLException
-    {
-        return statement.getBigDecimal( parameterIndex );
-    }
-
-    public BigDecimal getBigDecimal( String parameterName )
-        throws SQLException
-    {
-        return statement.getBigDecimal( parameterName );
-    }
-
-    public Blob getBlob( int i )
-        throws SQLException
-    {
-        return statement.getBlob( i );
-    }
-
-    public Blob getBlob( String parameterName )
-        throws SQLException
-    {
-        return statement.getBlob( parameterName );
-    }
-
-    public boolean getBoolean( int parameterIndex )
-        throws SQLException
-    {
-        return statement.getBoolean( parameterIndex );
-    }
-
-    public boolean getBoolean( String parameterName )
-        throws SQLException
-    {
-        return statement.getBoolean( parameterName );
-    }
-
-    public byte getByte( int parameterIndex )
-        throws SQLException
-    {
-        return statement.getByte( parameterIndex );
-    }
-
-    public byte getByte( String parameterName )
-        throws SQLException
-    {
-        return statement.getByte( parameterName );
-    }
-
-    public byte[] getBytes( int parameterIndex )
-        throws SQLException
-    {
-        return statement.getBytes( parameterIndex );
-    }
-
-    public byte[] getBytes( String parameterName )
-        throws SQLException
-    {
-        return statement.getBytes( parameterName );
-    }
-
-    public Clob getClob( int i )
-        throws SQLException
-    {
-        return statement.getClob( i );
-    }
-
-    public Clob getClob( String parameterName )
-        throws SQLException
-    {
-        return statement.getClob( parameterName );
-    }
-
-    public Date getDate( int parameterIndex, Calendar cal )
-        throws SQLException
-    {
-        return statement.getDate( parameterIndex, cal );
-    }
-
-    public Date getDate( int parameterIndex )
-        throws SQLException
-    {
-        return statement.getDate( parameterIndex );
-    }
-
-    public Date getDate( String parameterName, Calendar cal )
-        throws SQLException
-    {
-        return statement.getDate( parameterName, cal );
-    }
-
-    public Date getDate( String parameterName )
-        throws SQLException
-    {
-        return statement.getDate( parameterName );
-    }
-
-    public double getDouble( int parameterIndex )
-        throws SQLException
-    {
-        return statement.getDouble( parameterIndex );
-    }
-
-    public double getDouble( String parameterName )
-        throws SQLException
-    {
-        return statement.getDouble( parameterName );
-    }
-
-    public float getFloat( int parameterIndex )
-        throws SQLException
-    {
-        return statement.getFloat( parameterIndex );
-    }
-
-    public float getFloat( String parameterName )
-        throws SQLException
-    {
-        return statement.getFloat( parameterName );
-    }
-
-    public int getInt( int parameterIndex )
-        throws SQLException
-    {
-        return statement.getInt( parameterIndex );
-    }
-
-    public int getInt( String parameterName )
-        throws SQLException
-    {
-        return statement.getInt( parameterName );
-    }
-
-    public long getLong( int parameterIndex )
-        throws SQLException
-    {
-        return statement.getLong( parameterIndex );
-    }
-
-    public long getLong( String parameterName )
-        throws SQLException
-    {
-        return statement.getLong( parameterName );
-    }
-
-    public Object getObject( int i, Map<String, Class<?>> map )
-        throws SQLException
-    {
-        return statement.getObject( i, map );
-    }
-
-    public Object getObject( int parameterIndex )
-        throws SQLException
-    {
-        return statement.getObject( parameterIndex );
-    }
-
-    public Object getObject( String parameterName, Map<String, Class<?>> map )
-        throws SQLException
-    {
-        return statement.getObject( parameterName, map );
-    }
-
-    public Object getObject( String parameterName )
-        throws SQLException
-    {
-        return statement.getObject( parameterName );
-    }
-
-    public Ref getRef( int i )
-        throws SQLException
-    {
-        return statement.getRef( i );
-    }
-
-    public Ref getRef( String parameterName )
-        throws SQLException
-    {
-        return statement.getRef( parameterName );
-    }
-
-    public short getShort( int parameterIndex )
-        throws SQLException
-    {
-        return statement.getShort( parameterIndex );
-    }
-
-    public short getShort( String parameterName )
-        throws SQLException
-    {
-        return statement.getShort( parameterName );
-    }
-
-    public String getString( int parameterIndex )
-        throws SQLException
-    {
-        return statement.getString( parameterIndex );
-    }
-
-    public String getString( String parameterName )
-        throws SQLException
-    {
-        return statement.getString( parameterName );
-    }
-
-    public Time getTime( int parameterIndex, Calendar cal )
-        throws SQLException
-    {
-        return statement.getTime( parameterIndex, cal );
-    }
-
-    public Time getTime( int parameterIndex )
-        throws SQLException
-    {
-        return statement.getTime( parameterIndex );
-    }
-
-    public Time getTime( String parameterName, Calendar cal )
-        throws SQLException
-    {
-        return statement.getTime( parameterName, cal );
-    }
-
-    public Time getTime( String parameterName )
-        throws SQLException
-    {
-        return statement.getTime( parameterName );
-    }
-
-    public Timestamp getTimestamp( int parameterIndex, Calendar cal )
-        throws SQLException
-    {
-        return statement.getTimestamp( parameterIndex, cal );
-    }
-
-    public Timestamp getTimestamp( int parameterIndex )
-        throws SQLException
-    {
-        return statement.getTimestamp( parameterIndex );
-    }
-
-    public Timestamp getTimestamp( String parameterName, Calendar cal )
-        throws SQLException
-    {
-        return statement.getTimestamp( parameterName, cal );
-    }
-
-    public Timestamp getTimestamp( String parameterName )
-        throws SQLException
-    {
-        return statement.getTimestamp( parameterName );
-    }
-
-    public URL getURL( int parameterIndex )
-        throws SQLException
-    {
-        return statement.getURL( parameterIndex );
-    }
-
-    public URL getURL( String parameterName )
-        throws SQLException
-    {
-        return statement.getURL( parameterName );
-    }
-
-    public void registerOutParameter( int parameterIndex, int sqlType, int scale )
-        throws SQLException
-    {
-        statement.registerOutParameter( parameterIndex, sqlType, scale );
-    }
-
-    public void registerOutParameter( int paramIndex, int sqlType, String typeName )
-        throws SQLException
-    {
-        statement.registerOutParameter( paramIndex, sqlType, typeName );
-    }
-
-    public void registerOutParameter( int parameterIndex, int sqlType )
-        throws SQLException
-    {
-        statement.registerOutParameter( parameterIndex, sqlType );
-    }
-
-    public void registerOutParameter( String parameterName, int sqlType, int scale )
-        throws SQLException
-    {
-        statement.registerOutParameter( parameterName, sqlType, scale );
-    }
-
-    public void registerOutParameter( String parameterName, int sqlType, String typeName )
-        throws SQLException
-    {
-        statement.registerOutParameter( parameterName, sqlType, typeName );
-    }
-
-    public void registerOutParameter( String parameterName, int sqlType )
-        throws SQLException
-    {
-        statement.registerOutParameter( parameterName, sqlType );
-    }
-
-    public void setAsciiStream( String parameterName, InputStream x, int length )
-        throws SQLException
-    {
-        statement.setAsciiStream( parameterName, x, length );
-    }
-
-    public void setBigDecimal( String parameterName, BigDecimal x )
-        throws SQLException
-    {
-        statement.setBigDecimal( parameterName, x );
-    }
-
-    public void setBinaryStream( String parameterName, InputStream x, int length )
-        throws SQLException
-    {
-        statement.setBinaryStream( parameterName, x, length );
-    }
-
-    public void setBoolean( String parameterName, boolean x )
-        throws SQLException
-    {
-        statement.setBoolean( parameterName, x );
-    }
-
-    public void setByte( String parameterName, byte x )
-        throws SQLException
-    {
-        statement.setByte( parameterName, x );
-    }
-
-    public void setBytes( String parameterName, byte[] x )
-        throws SQLException
-    {
-        statement.setBytes( parameterName, x );
-    }
-
-    public void setCharacterStream( String parameterName, Reader reader, int length )
-        throws SQLException
-    {
-        statement.setCharacterStream( parameterName, reader, length );
-    }
-
-    public void setDate( String parameterName, Date x, Calendar cal )
-        throws SQLException
-    {
-        statement.setDate( parameterName, x, cal );
-    }
-
-    public void setDate( String parameterName, Date x )
-        throws SQLException
-    {
-        statement.setDate( parameterName, x );
-    }
-
-    public void setDouble( String parameterName, double x )
-        throws SQLException
-    {
-        statement.setDouble( parameterName, x );
-    }
-
-    public void setFloat( String parameterName, float x )
-        throws SQLException
-    {
-        statement.setFloat( parameterName, x );
-    }
-
-    public void setInt( String parameterName, int x )
-        throws SQLException
-    {
-        statement.setInt( parameterName, x );
-    }
-
-    public void setLong( String parameterName, long x )
-        throws SQLException
-    {
-        statement.setLong( parameterName, x );
-    }
-
-    public void setNull( String parameterName, int sqlType, String typeName )
-        throws SQLException
-    {
-        statement.setNull( parameterName, sqlType, typeName );
-    }
-
-    public void setNull( String parameterName, int sqlType )
-        throws SQLException
-    {
-        statement.setNull( parameterName, sqlType );
-    }
-
-    public void setObject( String parameterName, Object x, int targetSqlType, int scale )
-        throws SQLException
-    {
-        statement.setObject( parameterName, x, targetSqlType, scale );
-    }
-
-    public void setObject( String parameterName, Object x, int targetSqlType )
-        throws SQLException
-    {
-        statement.setObject( parameterName, x, targetSqlType );
-    }
-
-    public void setObject( String parameterName, Object x )
-        throws SQLException
-    {
-        statement.setObject( parameterName, x );
-    }
-
-    public void setShort( String parameterName, short x )
-        throws SQLException
-    {
-        statement.setShort( parameterName, x );
-    }
-
-    public void setString( String parameterName, String x )
-        throws SQLException
-    {
-        statement.setString( parameterName, x );
-    }
-
-    public void setTime( String parameterName, Time x, Calendar cal )
-        throws SQLException
-    {
-        statement.setTime( parameterName, x, cal );
-    }
-
-    public void setTime( String parameterName, Time x )
-        throws SQLException
-    {
-        statement.setTime( parameterName, x );
-    }
-
-    public void setTimestamp( String parameterName, Timestamp x, Calendar cal )
-        throws SQLException
-    {
-        statement.setTimestamp( parameterName, x, cal );
-    }
-
-    public void setTimestamp( String parameterName, Timestamp x )
-        throws SQLException
-    {
-        statement.setTimestamp( parameterName, x );
-    }
-
-    public void setURL( String parameterName, URL val )
-        throws SQLException
-    {
-        statement.setURL( parameterName, val );
-    }
-
-    public boolean wasNull()
-        throws SQLException
-    {
-        return statement.wasNull();
-    }
-
-    // --- jdbc 4 ---
-
-    public final Reader getCharacterStream( int parameterIndex )
-        throws SQLException
-    {
-        return statement.getCharacterStream( parameterIndex );
-    }
-
-    public final Reader getCharacterStream( String parameterName )
-        throws SQLException
-    {
-        return statement.getCharacterStream( parameterName );
-    }
-
-    public final Reader getNCharacterStream( int parameterIndex )
-        throws SQLException
-    {
-        return statement.getNCharacterStream( parameterIndex );
-    }
-
-    public final Reader getNCharacterStream( String parameterName )
-        throws SQLException
-    {
-        return statement.getNCharacterStream( parameterName );
-    }
-
-    public final NClob getNClob( int parameterIndex )
-        throws SQLException
-    {
-        return statement.getNClob( parameterIndex );
-    }
-
-    public final NClob getNClob( String parameterName )
-        throws SQLException
-    {
-        return statement.getNClob( parameterName );
-    }
-
-    public final String getNString( int parameterIndex )
-        throws SQLException
-    {
-        return statement.getNString( parameterIndex );
-    }
-
-    public final String getNString( String parameterName )
-        throws SQLException
-    {
-        return statement.getNString( parameterName );
-    }
-
-    public final RowId getRowId( int parameterIndex )
-        throws SQLException
-    {
-        return statement.getRowId( parameterIndex );
-    }
-
-    public final RowId getRowId( String parameterName )
-        throws SQLException
-    {
-        return statement.getRowId( parameterName );
-    }
-
-    public final SQLXML getSQLXML( int parameterIndex )
-        throws SQLException
-    {
-        return statement.getSQLXML( parameterIndex );
-    }
-
-    public final SQLXML getSQLXML( String parameterName )
-        throws SQLException
-    {
-        return statement.getSQLXML( parameterName );
-    }
-
-    public final void setAsciiStream( String parameterName, InputStream x, long length )
-        throws SQLException
-    {
-        statement.setAsciiStream( parameterName, x, length );
-    }
-
-    public final void setAsciiStream( String parameterName, InputStream x )
-        throws SQLException
-    {
-        statement.setAsciiStream( parameterName, x );
-    }
-
-    public final void setBinaryStream( String parameterName, InputStream x, long length )
-        throws SQLException
-    {
-        statement.setBinaryStream( parameterName, x, length );
-    }
-
-    public final void setBinaryStream( String parameterName, InputStream x )
-        throws SQLException
-    {
-        statement.setBinaryStream( parameterName, x );
-    }
-
-    public final void setBlob( String parameterName, Blob x )
-        throws SQLException
-    {
-        statement.setBlob( parameterName, x );
-    }
-
-    public final void setBlob( String parameterName, InputStream inputStream, long length )
-        throws SQLException
-    {
-        statement.setBlob( parameterName, inputStream, length );
-    }
-
-    public final void setBlob( String parameterName, InputStream inputStream )
-        throws SQLException
-    {
-        statement.setBlob( parameterName, inputStream );
-    }
-
-    public final void setCharacterStream( String parameterName, Reader reader, long length )
-        throws SQLException
-    {
-        statement.setCharacterStream( parameterName, reader, length );
-    }
-
-    public final void setCharacterStream( String parameterName, Reader reader )
-        throws SQLException
-    {
-        statement.setCharacterStream( parameterName, reader );
-    }
-
-    public final void setClob( String parameterName, Clob x )
-        throws SQLException
-    {
-        statement.setClob( parameterName, x );
-    }
-
-    public final void setClob( String parameterName, Reader reader, long length )
-        throws SQLException
-    {
-        statement.setClob( parameterName, reader, length );
-    }
-
-    public final void setClob( String parameterName, Reader reader )
-        throws SQLException
-    {
-        statement.setClob( parameterName, reader );
-    }
-
-    public final void setNCharacterStream( String parameterName, Reader value, long length )
-        throws SQLException
-    {
-        statement.setNCharacterStream( parameterName, value, length );
-    }
-
-    public final void setNCharacterStream( String parameterName, Reader value )
-        throws SQLException
-    {
-        statement.setNCharacterStream( parameterName, value );
-    }
-
-    public final void setNClob( String parameterName, NClob value )
-        throws SQLException
-    {
-        statement.setNClob( parameterName, value );
-    }
-
-    public final void setNClob( String parameterName, Reader reader, long length )
-        throws SQLException
-    {
-        statement.setNClob( parameterName, reader, length );
-    }
-
-    public final void setNClob( String parameterName, Reader reader )
-        throws SQLException
-    {
-        statement.setNClob( parameterName, reader );
-    }
-
-    public final void setNString( String parameterName, String value )
-        throws SQLException
-    {
-        statement.setNString( parameterName, value );
-    }
-
-    public final void setRowId( String parameterName, RowId x )
-        throws SQLException
-    {
-        statement.setRowId( parameterName, x );
-    }
-
-    public final void setSQLXML( String parameterName, SQLXML xmlObject )
-        throws SQLException
-    {
-        statement.setSQLXML( parameterName, xmlObject );
-    }
-
-}
+package org.apache.commons.monitoring.jdbc;
+
+import java.io.InputStream;
+import java.io.Reader;
+import java.math.BigDecimal;
+import java.net.URL;
+import java.sql.Array;
+import java.sql.Blob;
+import java.sql.CallableStatement;
+import java.sql.Clob;
+import java.sql.Date;
+import java.sql.NClob;
+import java.sql.Ref;
+import java.sql.RowId;
+import java.sql.SQLException;
+import java.sql.SQLXML;
+import java.sql.Time;
+import java.sql.Timestamp;
+import java.util.Calendar;
+import java.util.Map;
+
+import org.apache.commons.monitoring.Repository;
+import org.apache.commons.monitoring.jdbc.MonitoredPreparedStatement;
+
+/**
+ * @author ndeloof
+ *
+ */
+public class MonitoredCallableStatement
+    extends MonitoredPreparedStatement
+    implements CallableStatement
+{
+    private CallableStatement statement;
+
+    /**
+     * @param statement
+     * @param sql
+     * @param repository
+     */
+    public MonitoredCallableStatement( CallableStatement statement, String sql, Repository repository )
+    {
+        super( statement, sql, repository );
+        this.statement = statement;
+    }
+
+    // --- delegate methods ---
+
+    public Array getArray( int i )
+        throws SQLException
+    {
+        return statement.getArray( i );
+    }
+
+    public Array getArray( String parameterName )
+        throws SQLException
+    {
+        return statement.getArray( parameterName );
+    }
+
+    @Deprecated
+    public BigDecimal getBigDecimal( int parameterIndex, int scale )
+        throws SQLException
+    {
+        return statement.getBigDecimal( parameterIndex, scale );
+    }
+
+    public BigDecimal getBigDecimal( int parameterIndex )
+        throws SQLException
+    {
+        return statement.getBigDecimal( parameterIndex );
+    }
+
+    public BigDecimal getBigDecimal( String parameterName )
+        throws SQLException
+    {
+        return statement.getBigDecimal( parameterName );
+    }
+
+    public Blob getBlob( int i )
+        throws SQLException
+    {
+        return statement.getBlob( i );
+    }
+
+    public Blob getBlob( String parameterName )
+        throws SQLException
+    {
+        return statement.getBlob( parameterName );
+    }
+
+    public boolean getBoolean( int parameterIndex )
+        throws SQLException
+    {
+        return statement.getBoolean( parameterIndex );
+    }
+
+    public boolean getBoolean( String parameterName )
+        throws SQLException
+    {
+        return statement.getBoolean( parameterName );
+    }
+
+    public byte getByte( int parameterIndex )
+        throws SQLException
+    {
+        return statement.getByte( parameterIndex );
+    }
+
+    public byte getByte( String parameterName )
+        throws SQLException
+    {
+        return statement.getByte( parameterName );
+    }
+
+    public byte[] getBytes( int parameterIndex )
+        throws SQLException
+    {
+        return statement.getBytes( parameterIndex );
+    }
+
+    public byte[] getBytes( String parameterName )
+        throws SQLException
+    {
+        return statement.getBytes( parameterName );
+    }
+
+    public Clob getClob( int i )
+        throws SQLException
+    {
+        return statement.getClob( i );
+    }
+
+    public Clob getClob( String parameterName )
+        throws SQLException
+    {
+        return statement.getClob( parameterName );
+    }
+
+    public Date getDate( int parameterIndex, Calendar cal )
+        throws SQLException
+    {
+        return statement.getDate( parameterIndex, cal );
+    }
+
+    public Date getDate( int parameterIndex )
+        throws SQLException
+    {
+        return statement.getDate( parameterIndex );
+    }
+
+    public Date getDate( String parameterName, Calendar cal )
+        throws SQLException
+    {
+        return statement.getDate( parameterName, cal );
+    }
+
+    public Date getDate( String parameterName )
+        throws SQLException
+    {
+        return statement.getDate( parameterName );
+    }
+
+    public double getDouble( int parameterIndex )
+        throws SQLException
+    {
+        return statement.getDouble( parameterIndex );
+    }
+
+    public double getDouble( String parameterName )
+        throws SQLException
+    {
+        return statement.getDouble( parameterName );
+    }
+
+    public float getFloat( int parameterIndex )
+        throws SQLException
+    {
+        return statement.getFloat( parameterIndex );
+    }
+
+    public float getFloat( String parameterName )
+        throws SQLException
+    {
+        return statement.getFloat( parameterName );
+    }
+
+    public int getInt( int parameterIndex )
+        throws SQLException
+    {
+        return statement.getInt( parameterIndex );
+    }
+
+    public int getInt( String parameterName )
+        throws SQLException
+    {
+        return statement.getInt( parameterName );
+    }
+
+    public long getLong( int parameterIndex )
+        throws SQLException
+    {
+        return statement.getLong( parameterIndex );
+    }
+
+    public long getLong( String parameterName )
+        throws SQLException
+    {
+        return statement.getLong( parameterName );
+    }
+
+    public Object getObject( int i, Map<String, Class<?>> map )
+        throws SQLException
+    {
+        return statement.getObject( i, map );
+    }
+
+    public Object getObject( int parameterIndex )
+        throws SQLException
+    {
+        return statement.getObject( parameterIndex );
+    }
+
+    public Object getObject( String parameterName, Map<String, Class<?>> map )
+        throws SQLException
+    {
+        return statement.getObject( parameterName, map );
+    }
+
+    public Object getObject( String parameterName )
+        throws SQLException
+    {
+        return statement.getObject( parameterName );
+    }
+
+    public Ref getRef( int i )
+        throws SQLException
+    {
+        return statement.getRef( i );
+    }
+
+    public Ref getRef( String parameterName )
+        throws SQLException
+    {
+        return statement.getRef( parameterName );
+    }
+
+    public short getShort( int parameterIndex )
+        throws SQLException
+    {
+        return statement.getShort( parameterIndex );
+    }
+
+    public short getShort( String parameterName )
+        throws SQLException
+    {
+        return statement.getShort( parameterName );
+    }
+
+    public String getString( int parameterIndex )
+        throws SQLException
+    {
+        return statement.getString( parameterIndex );
+    }
+
+    public String getString( String parameterName )
+        throws SQLException
+    {
+        return statement.getString( parameterName );
+    }
+
+    public Time getTime( int parameterIndex, Calendar cal )
+        throws SQLException
+    {
+        return statement.getTime( parameterIndex, cal );
+    }
+
+    public Time getTime( int parameterIndex )
+        throws SQLException
+    {
+        return statement.getTime( parameterIndex );
+    }
+
+    public Time getTime( String parameterName, Calendar cal )
+        throws SQLException
+    {
+        return statement.getTime( parameterName, cal );
+    }
+
+    public Time getTime( String parameterName )
+        throws SQLException
+    {
+        return statement.getTime( parameterName );
+    }
+
+    public Timestamp getTimestamp( int parameterIndex, Calendar cal )
+        throws SQLException
+    {
+        return statement.getTimestamp( parameterIndex, cal );
+    }
+
+    public Timestamp getTimestamp( int parameterIndex )
+        throws SQLException
+    {
+        return statement.getTimestamp( parameterIndex );
+    }
+
+    public Timestamp getTimestamp( String parameterName, Calendar cal )
+        throws SQLException
+    {
+        return statement.getTimestamp( parameterName, cal );
+    }
+
+    public Timestamp getTimestamp( String parameterName )
+        throws SQLException
+    {
+        return statement.getTimestamp( parameterName );
+    }
+
+    public URL getURL( int parameterIndex )
+        throws SQLException
+    {
+        return statement.getURL( parameterIndex );
+    }
+
+    public URL getURL( String parameterName )
+        throws SQLException
+    {
+        return statement.getURL( parameterName );
+    }
+
+    public void registerOutParameter( int parameterIndex, int sqlType, int scale )
+        throws SQLException
+    {
+        statement.registerOutParameter( parameterIndex, sqlType, scale );
+    }
+
+    public void registerOutParameter( int paramIndex, int sqlType, String typeName )
+        throws SQLException
+    {
+        statement.registerOutParameter( paramIndex, sqlType, typeName );
+    }
+
+    public void registerOutParameter( int parameterIndex, int sqlType )
+        throws SQLException
+    {
+        statement.registerOutParameter( parameterIndex, sqlType );
+    }
+
+    public void registerOutParameter( String parameterName, int sqlType, int scale )
+        throws SQLException
+    {
+        statement.registerOutParameter( parameterName, sqlType, scale );
+    }
+
+    public void registerOutParameter( String parameterName, int sqlType, String typeName )
+        throws SQLException
+    {
+        statement.registerOutParameter( parameterName, sqlType, typeName );
+    }
+
+    public void registerOutParameter( String parameterName, int sqlType )
+        throws SQLException
+    {
+        statement.registerOutParameter( parameterName, sqlType );
+    }
+
+    public void setAsciiStream( String parameterName, InputStream x, int length )
+        throws SQLException
+    {
+        statement.setAsciiStream( parameterName, x, length );
+    }
+
+    public void setBigDecimal( String parameterName, BigDecimal x )
+        throws SQLException
+    {
+        statement.setBigDecimal( parameterName, x );
+    }
+
+    public void setBinaryStream( String parameterName, InputStream x, int length )
+        throws SQLException
+    {
+        statement.setBinaryStream( parameterName, x, length );
+    }
+
+    public void setBoolean( String parameterName, boolean x )
+        throws SQLException
+    {
+        statement.setBoolean( parameterName, x );
+    }
+
+    public void setByte( String parameterName, byte x )
+        throws SQLException
+    {
+        statement.setByte( parameterName, x );
+    }
+
+    public void setBytes( String parameterName, byte[] x )
+        throws SQLException
+    {
+        statement.setBytes( parameterName, x );
+    }
+
+    public void setCharacterStream( String parameterName, Reader reader, int length )
+        throws SQLException
+    {
+        statement.setCharacterStream( parameterName, reader, length );
+    }
+
+    public void setDate( String parameterName, Date x, Calendar cal )
+        throws SQLException
+    {
+        statement.setDate( parameterName, x, cal );
+    }
+
+    public void setDate( String parameterName, Date x )
+        throws SQLException
+    {
+        statement.setDate( parameterName, x );
+    }
+
+    public void setDouble( String parameterName, double x )
+        throws SQLException
+    {
+        statement.setDouble( parameterName, x );
+    }
+
+    public void setFloat( String parameterName, float x )
+        throws SQLException
+    {
+        statement.setFloat( parameterName, x );
+    }
+
+    public void setInt( String parameterName, int x )
+        throws SQLException
+    {
+        statement.setInt( parameterName, x );
+    }
+
+    public void setLong( String parameterName, long x )
+        throws SQLException
+    {
+        statement.setLong( parameterName, x );
+    }
+
+    public void setNull( String parameterName, int sqlType, String typeName )
+        throws SQLException
+    {
+        statement.setNull( parameterName, sqlType, typeName );
+    }
+
+    public void setNull( String parameterName, int sqlType )
+        throws SQLException
+    {
+        statement.setNull( parameterName, sqlType );
+    }
+
+    public void setObject( String parameterName, Object x, int targetSqlType, int scale )
+        throws SQLException
+    {
+        statement.setObject( parameterName, x, targetSqlType, scale );
+    }
+
+    public void setObject( String parameterName, Object x, int targetSqlType )
+        throws SQLException
+    {
+        statement.setObject( parameterName, x, targetSqlType );
+    }
+
+    public void setObject( String parameterName, Object x )
+        throws SQLException
+    {
+        statement.setObject( parameterName, x );
+    }
+
+    public void setShort( String parameterName, short x )
+        throws SQLException
+    {
+        statement.setShort( parameterName, x );
+    }
+
+    public void setString( String parameterName, String x )
+        throws SQLException
+    {
+        statement.setString( parameterName, x );
+    }
+
+    public void setTime( String parameterName, Time x, Calendar cal )
+        throws SQLException
+    {
+        statement.setTime( parameterName, x, cal );
+    }
+
+    public void setTime( String parameterName, Time x )
+        throws SQLException
+    {
+        statement.setTime( parameterName, x );
+    }
+
+    public void setTimestamp( String parameterName, Timestamp x, Calendar cal )
+        throws SQLException
+    {
+        statement.setTimestamp( parameterName, x, cal );
+    }
+
+    public void setTimestamp( String parameterName, Timestamp x )
+        throws SQLException
+    {
+        statement.setTimestamp( parameterName, x );
+    }
+
+    public void setURL( String parameterName, URL val )
+        throws SQLException
+    {
+        statement.setURL( parameterName, val );
+    }
+
+    public boolean wasNull()
+        throws SQLException
+    {
+        return statement.wasNull();
+    }
+
+    // --- jdbc 4 ---
+
+    public final Reader getCharacterStream( int parameterIndex )
+        throws SQLException
+    {
+        return statement.getCharacterStream( parameterIndex );
+    }
+
+    public final Reader getCharacterStream( String parameterName )
+        throws SQLException
+    {
+        return statement.getCharacterStream( parameterName );
+    }
+
+    public final Reader getNCharacterStream( int parameterIndex )
+        throws SQLException
+    {
+        return statement.getNCharacterStream( parameterIndex );
+    }
+
+    public final Reader getNCharacterStream( String parameterName )
+        throws SQLException
+    {
+        return statement.getNCharacterStream( parameterName );
+    }
+
+    public final NClob getNClob( int parameterIndex )
+        throws SQLException
+    {
+        return statement.getNClob( parameterIndex );
+    }
+
+    public final NClob getNClob( String parameterName )
+        throws SQLException
+    {
+        return statement.getNClob( parameterName );
+    }
+
+    public final String getNString( int parameterIndex )
+        throws SQLException
+    {
+        return statement.getNString( parameterIndex );
+    }
+
+    public final String getNString( String parameterName )
+        throws SQLException
+    {
+        return statement.getNString( parameterName );
+    }
+
+    public final RowId getRowId( int parameterIndex )
+        throws SQLException
+    {
+        return statement.getRowId( parameterIndex );
+    }
+
+    public final RowId getRowId( String parameterName )
+        throws SQLException
+    {
+        return statement.getRowId( parameterName );
+    }
+
+    public final SQLXML getSQLXML( int parameterIndex )
+        throws SQLException
+    {
+        return statement.getSQLXML( parameterIndex );
+    }
+
+    public final SQLXML getSQLXML( String parameterName )
+        throws SQLException
+    {
+        return statement.getSQLXML( parameterName );
+    }
+
+    public final void setAsciiStream( String parameterName, InputStream x, long length )
+        throws SQLException
+    {
+        statement.setAsciiStream( parameterName, x, length );
+    }
+
+    public final void setAsciiStream( String parameterName, InputStream x )
+        throws SQLException
+    {
+        statement.setAsciiStream( parameterName, x );
+    }
+
+    public final void setBinaryStream( String parameterName, InputStream x, long length )
+        throws SQLException
+    {
+        statement.setBinaryStream( parameterName, x, length );
+    }
+
+    public final void setBinaryStream( String parameterName, InputStream x )
+        throws SQLException
+    {
+        statement.setBinaryStream( parameterName, x );
+    }
+
+    public final void setBlob( String parameterName, Blob x )
+        throws SQLException
+    {
+        statement.setBlob( parameterName, x );
+    }
+
+    public final void setBlob( String parameterName, InputStream inputStream, long length )
+        throws SQLException
+    {
+        statement.setBlob( parameterName, inputStream, length );
+    }
+
+    public final void setBlob( String parameterName, InputStream inputStream )
+        throws SQLException
+    {
+        statement.setBlob( parameterName, inputStream );
+    }
+
+    public final void setCharacterStream( String parameterName, Reader reader, long length )
+        throws SQLException
+    {
+        statement.setCharacterStream( parameterName, reader, length );
+    }
+
+    public final void setCharacterStream( String parameterName, Reader reader )
+        throws SQLException
+    {
+        statement.setCharacterStream( parameterName, reader );
+    }
+
+    public final void setClob( String parameterName, Clob x )
+        throws SQLException
+    {
+        statement.setClob( parameterName, x );
+    }
+
+    public final void setClob( String parameterName, Reader reader, long length )
+        throws SQLException
+    {
+        statement.setClob( parameterName, reader, length );
+    }
+
+    public final void setClob( String parameterName, Reader reader )
+        throws SQLException
+    {
+        statement.setClob( parameterName, reader );
+    }
+
+    public final void setNCharacterStream( String parameterName, Reader value, long length )
+        throws SQLException
+    {
+        statement.setNCharacterStream( parameterName, value, length );
+    }
+
+    public final void setNCharacterStream( String parameterName, Reader value )
+        throws SQLException
+    {
+        statement.setNCharacterStream( parameterName, value );
+    }
+
+    public final void setNClob( String parameterName, NClob value )
+        throws SQLException
+    {
+        statement.setNClob( parameterName, value );
+    }
+
+    public final void setNClob( String parameterName, Reader reader, long length )
+        throws SQLException
+    {
+        statement.setNClob( parameterName, reader, length );
+    }
+
+    public final void setNClob( String parameterName, Reader reader )
+        throws SQLException
+    {
+        statement.setNClob( parameterName, reader );
+    }
+
+    public final void setNString( String parameterName, String value )
+        throws SQLException
+    {
+        statement.setNString( parameterName, value );
+    }
+
+    public final void setRowId( String parameterName, RowId x )
+        throws SQLException
+    {
+        statement.setRowId( parameterName, x );
+    }
+
+    public final void setSQLXML( String parameterName, SQLXML xmlObject )
+        throws SQLException
+    {
+        statement.setSQLXML( parameterName, xmlObject );
+    }
+
+}

Modified: commons/sandbox/monitoring/trunk/jdbc/src/main/java/org/apache/commons/monitoring/jdbc/MonitoredConnectionHandler.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/jdbc/src/main/java/org/apache/commons/monitoring/jdbc/MonitoredConnectionHandler.java?rev=1506926&r1=1506925&r2=1506926&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/jdbc/src/main/java/org/apache/commons/monitoring/jdbc/MonitoredConnectionHandler.java (original)
+++ commons/sandbox/monitoring/trunk/jdbc/src/main/java/org/apache/commons/monitoring/jdbc/MonitoredConnectionHandler.java Thu Jul 25 12:28:46 2013
@@ -1,98 +1,98 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one or more
- * contributor license agreements.  See the NOTICE file distributed with
- * this work for additional information regarding copyright ownership.
- * The ASF licenses this file to You under the Apache License, Version 2.0
- * (the "License"); you may not use this file except in compliance with
- * the License.  You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package org.apache.commons.monitoring.jdbc;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.Method;
-import java.lang.reflect.Proxy;
-import java.sql.CallableStatement;
-import java.sql.Connection;
-import java.sql.PreparedStatement;
-import java.sql.Statement;
-
-import org.apache.commons.monitoring.Repository;
-
-/**
- * @author ndeloof
- *
- */
-public class MonitoredConnectionHandler
-    implements InvocationHandler
-{
-    /** target connection */
-    private Connection connection;
-
-    private Repository repository;
-
-    private ConnectionClosedCallBack callBack;
-
-    public MonitoredConnectionHandler( Connection connection, Repository repository, ConnectionClosedCallBack callBack )
-    {
-        super();
-        this.connection = connection;
-        this.repository = repository;
-        this.callBack = callBack;
-    }
-
-    /**
-     * {@inheritDoc}
-     * 
-     * @see java.lang.reflect.InvocationHandler#invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
-     */
-    public Object invoke( Object proxy, Method method, Object[] args )
-        throws Throwable
-    {
-        String name = method.getName();
-        if ( name.equals( "createStatement" ) )
-        {
-            Statement statement = (Statement) method.invoke( connection, args );
-            return Proxy.newProxyInstance( getClassLoader(), new Class[] { Statement.class },
-                new MonitoredStatementHandler( repository, statement ) );
-        }
-        else if ( name.equals( "prepareStatement" ) )
-        {
-            PreparedStatement statement = (PreparedStatement) method.invoke( connection, args );
-            return Proxy.newProxyInstance( getClassLoader(), new Class[] { PreparedStatement.class },
-                new MonitoredStatementHandler( repository, statement ) );
-        }
-        else if ( name.equals( "prepareCall" ) )
-        {
-            CallableStatement statement = (CallableStatement) method.invoke( connection, args );
-            return Proxy.newProxyInstance( getClassLoader(), new Class[] { CallableStatement.class },
-                new MonitoredStatementHandler( repository, statement ) );
-        }
-        else if ( name.equals( "close" ) )
-        {
-            callBack.onConnectionClosed();
-        }
-        return method.invoke( connection, args );
-    }
-
-    /**
-     * @return
-     */
-    private ClassLoader getClassLoader()
-    {
-        ClassLoader cl = Thread.currentThread().getContextClassLoader();
-        if ( cl == null )
-        {
-            cl = getClass().getClassLoader();
-        }
-        return cl;
-    }
-}
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.commons.monitoring.jdbc;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.sql.CallableStatement;
+import java.sql.Connection;
+import java.sql.PreparedStatement;
+import java.sql.Statement;
+
+import org.apache.commons.monitoring.Repository;
+
+/**
+ * @author ndeloof
+ *
+ */
+public class MonitoredConnectionHandler
+    implements InvocationHandler
+{
+    /** target connection */
+    private Connection connection;
+
+    private Repository repository;
+
+    private ConnectionClosedCallBack callBack;
+
+    public MonitoredConnectionHandler( Connection connection, Repository repository, ConnectionClosedCallBack callBack )
+    {
+        super();
+        this.connection = connection;
+        this.repository = repository;
+        this.callBack = callBack;
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see java.lang.reflect.InvocationHandler#invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
+     */
+    public Object invoke( Object proxy, Method method, Object[] args )
+        throws Throwable
+    {
+        String name = method.getName();
+        if ( name.equals( "createStatement" ) )
+        {
+            Statement statement = (Statement) method.invoke( connection, args );
+            return Proxy.newProxyInstance( getClassLoader(), new Class[] { Statement.class },
+                new MonitoredStatementHandler( repository, statement ) );
+        }
+        else if ( name.equals( "prepareStatement" ) )
+        {
+            PreparedStatement statement = (PreparedStatement) method.invoke( connection, args );
+            return Proxy.newProxyInstance( getClassLoader(), new Class[] { PreparedStatement.class },
+                new MonitoredStatementHandler( repository, statement ) );
+        }
+        else if ( name.equals( "prepareCall" ) )
+        {
+            CallableStatement statement = (CallableStatement) method.invoke( connection, args );
+            return Proxy.newProxyInstance( getClassLoader(), new Class[] { CallableStatement.class },
+                new MonitoredStatementHandler( repository, statement ) );
+        }
+        else if ( name.equals( "close" ) )
+        {
+            callBack.onConnectionClosed();
+        }
+        return method.invoke( connection, args );
+    }
+
+    /**
+     * @return
+     */
+    private ClassLoader getClassLoader()
+    {
+        ClassLoader cl = Thread.currentThread().getContextClassLoader();
+        if ( cl == null )
+        {
+            cl = getClass().getClassLoader();
+        }
+        return cl;
+    }
+}

Modified: commons/sandbox/monitoring/trunk/jdbc/src/main/java/org/apache/commons/monitoring/jdbc/MonitoredStatementHandler.java
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/jdbc/src/main/java/org/apache/commons/monitoring/jdbc/MonitoredStatementHandler.java?rev=1506926&r1=1506925&r2=1506926&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/jdbc/src/main/java/org/apache/commons/monitoring/jdbc/MonitoredStatementHandler.java (original)
+++ commons/sandbox/monitoring/trunk/jdbc/src/main/java/org/apache/commons/monitoring/jdbc/MonitoredStatementHandler.java Thu Jul 25 12:28:46 2013
@@ -1,73 +1,72 @@
-package org.apache.commons.monitoring.jdbc;
-
-import java.lang.reflect.InvocationHandler;
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.sql.SQLException;
-import java.sql.Statement;
-
-import org.apache.commons.monitoring.Monitor;
-import org.apache.commons.monitoring.Repository;
-import org.apache.commons.monitoring.StopWatch;
-
-/**
- * @author ndeloof
- *
- */
-public class MonitoredStatementHandler
-    implements InvocationHandler
-{
-
-    private Repository repository;
-
-    private Statement statement;
-
-    /**
-     * @param repository
-     * @param statement
-     */
-    public MonitoredStatementHandler( Repository repository, Statement statement )
-    {
-        super();
-        this.repository = repository;
-        this.statement = statement;
-    }
-
-    /**
-     * {@inheritDoc}
-     * 
-     * @see java.lang.reflect.InvocationHandler#invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
-     */
-    public Object invoke( Object proxy, Method method, Object[] args )
-        throws Throwable
-    {
-        if ( method.getName().startsWith( "execute" ) )
-        {
-            // skip executeUpdate
-            String sql = ( args.length > 0 ? (String) args[0] : "batch" );
-            StopWatch stopWatch = repository.start( repository.getMonitor( sql, "jdbc" ) );
-            try
-            {
-                return method.invoke( statement, args );
-            }
-            catch ( InvocationTargetException ite )
-            {
-                if ( ite.getCause() instanceof SQLException )
-                {
-                    SQLException sqle = (SQLException) ite.getCause();
-                    String name = "SQLException:" + sqle.getSQLState() + ":" + sqle.getErrorCode();
-                    Monitor monitor = repository.getMonitor( name, "jdbc" );
-                    monitor.getCounter( Monitor.FAILURES ).add( 1 );
-                    throw sqle;
-                }
-                throw ite;
-            }
-            finally
-            {
-                stopWatch.stop();
-            }
-        }
-        return method.invoke( proxy, args );
-    }
-
-}
+package org.apache.commons.monitoring.jdbc;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+import java.sql.SQLException;
+import java.sql.Statement;
+
+import org.apache.commons.monitoring.Monitor;
+import org.apache.commons.monitoring.Repository;
+import org.apache.commons.monitoring.StopWatch;
+
+/**
+ * @author ndeloof
+ *
+ */
+public class MonitoredStatementHandler
+    implements InvocationHandler
+{
+
+    private Repository repository;
+
+    private Statement statement;
+
+    /**
+     * @param repository
+     * @param statement
+     */
+    public MonitoredStatementHandler( Repository repository, Statement statement )
+    {
+        super();
+        this.repository = repository;
+        this.statement = statement;
+    }
+
+    /**
+     * {@inheritDoc}
+     * 
+     * @see java.lang.reflect.InvocationHandler#invoke(java.lang.Object, java.lang.reflect.Method, java.lang.Object[])
+     */
+    public Object invoke( Object proxy, Method method, Object[] args )
+        throws Throwable
+    {
+        if ( method.getName().startsWith( "execute" ) )
+        {
+            // skip executeUpdate
+            String sql = ( args.length > 0 ? (String) args[0] : "batch" );
+            StopWatch stopWatch = repository.start( repository.getMonitor( sql, "jdbc" ) );
+            try
+            {
+                return method.invoke( statement, args );
+            }
+            catch ( InvocationTargetException ite )
+            {
+                if ( ite.getCause() instanceof SQLException )
+                {
+                    SQLException sqle = (SQLException) ite.getCause();
+                    String name = "SQLException:" + sqle.getSQLState() + ":" + sqle.getErrorCode();
+                    Monitor monitor = repository.getMonitor( name, "jdbc" );
+                    monitor.getCounter( Monitor.FAILURES ).add( 1 );
+                    throw sqle;
+                }
+                throw ite;
+            }
+            finally
+            {
+                stopWatch.stop();
+            }
+        }
+        return method.invoke( proxy, args );
+    }
+}

Modified: commons/sandbox/monitoring/trunk/pom.xml
URL: http://svn.apache.org/viewvc/commons/sandbox/monitoring/trunk/pom.xml?rev=1506926&r1=1506925&r2=1506926&view=diff
==============================================================================
--- commons/sandbox/monitoring/trunk/pom.xml (original)
+++ commons/sandbox/monitoring/trunk/pom.xml Thu Jul 25 12:28:46 2013
@@ -41,6 +41,7 @@
     <module>spring</module>
     <module>reporting</module>
     <module>jdbc</module>
+    <module>cdi</module>
   </modules>
 
   <developers>
@@ -99,6 +100,18 @@
     <commons.componentid>monitoring</commons.componentid>
     <commons.jira.componentid>12312100</commons.jira.componentid>
   </properties>
+
+  <dependencyManagement>
+    <dependencies>
+      <dependency>
+        <groupId>junit</groupId>
+        <artifactId>junit</artifactId>
+        <version>4.11</version>
+        <scope>test</scope>
+      </dependency>
+    </dependencies>
+  </dependencyManagement>
+
   <reporting>
     <plugins>
       <plugin>