Author: fmeschbe
Date: Wed Jul 3 21:31:39 2013
New Revision: 1499565
URL: http://svn.apache.org/r1499565
Log:
Implement support for service based ResourceResolver and Session access
- Method object comparison does not work due to different method objects.
Falling back to just checking the method name and number of arguments.
- Catching InvocationTargetException of reflected method call to rethrow
unwrapped exception
Modified:
sling/whiteboard/fmeschbe/deprecate_login_administrative/jcr/base/src/main/java/org/apache/sling/jcr/base/SlingRepositoryProxyHandler.java
Modified:
sling/whiteboard/fmeschbe/deprecate_login_administrative/jcr/base/src/main/java/org/apache/sling/jcr/base/SlingRepositoryProxyHandler.java
URL:
http://svn.apache.org/viewvc/sling/whiteboard/fmeschbe/deprecate_login_administrative/jcr/base/src/main/java/org/apache/sling/jcr/base/SlingRepositoryProxyHandler.java?rev=1499565&r1=1499564&r2=1499565&view=diff
==============================================================================
---
sling/whiteboard/fmeschbe/deprecate_login_administrative/jcr/base/src/main/java/org/apache/sling/jcr/base/SlingRepositoryProxyHandler.java
(original)
+++
sling/whiteboard/fmeschbe/deprecate_login_administrative/jcr/base/src/main/java/org/apache/sling/jcr/base/SlingRepositoryProxyHandler.java
Wed Jul 3 21:31:39 2013
@@ -19,10 +19,9 @@
package org.apache.sling.jcr.base;
import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
-
-import org.apache.sling.jcr.api.SlingRepository;
import org.osgi.framework.Bundle;
import org.slf4j.LoggerFactory;
@@ -41,31 +40,12 @@ class SlingRepositoryProxyHandler implem
// The name of the method to re-route
private static final String LOGIN_SERVICE_NAME = "loginService";
- // The signature of the loginService method to re-route
- private static final Class<?>[] LOGIN_SERVICE_SIG = {
- String.class, String.class
- };
-
- // The actual longService method object used for re-routing
- private static final Method LOGIN_SERVICE;
-
// The delegatee object to which all calls are routed
private final AbstractSlingRepository delegatee;
// The bundle using this proxy service instance
private final Bundle usingBundle;
- static {
- Method tmplsm = null;
- try {
- tmplsm = SlingRepository.class.getMethod(LOGIN_SERVICE_NAME,
LOGIN_SERVICE_SIG);
- } catch (Exception e) { // SecurityException e, NoSuchMethodException
- LoggerFactory.getLogger(SlingRepositoryProxyHandler.class).error(
- "[init]: Cannot get " + LOGIN_SERVICE_NAME + " method from
SlingRepository interface", e);
- }
- LOGIN_SERVICE = tmplsm;
- }
-
/**
* Creates a new proxy instance for the given {@code delegatee} object. The
* proxy is handled by a new instance of this
@@ -106,11 +86,15 @@ class SlingRepositoryProxyHandler implem
}
public Object invoke(Object proxy, Method method, Object[] args) throws
Throwable {
- if (method == SlingRepositoryProxyHandler.LOGIN_SERVICE) {
+ if
(SlingRepositoryProxyHandler.LOGIN_SERVICE_NAME.equals(method.getName()) &&
args != null && args.length == 2) {
return this.delegatee.loginService(this.usingBundle, (String)
args[0], (String) args[1]);
}
// otherwise forward to the AbstractSlingRepository implementation
- return method.invoke(this.delegatee, args);
+ try {
+ return method.invoke(this.delegatee, args);
+ } catch (InvocationTargetException ite) {
+ throw ite.getTargetException();
+ }
}
}