public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if ("close".equals(method.getName())) { throw new IllegalStateException("Illegal to call this method from injected, managed EntityManager"); } else { //catch all try { return method.invoke(getWrappedObject(), args); } catch (InvocationTargetException e) { if (e.getTargetException() instanceof RuntimeException) { throw (RuntimeException) e.getTargetException(); } else { throw e; } } } }
new EntityManagerUnwrappedTargetInvocationHandler(entityManager, extensionClass); Object proxyForUnwrappedObject = Proxy.newProxyInstance(
new EntityManagerUnwrappedTargetInvocationHandler(entityManager, extensionClass); Object proxyForUnwrappedObject = Proxy.newProxyInstance(
public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { if ("close".equals(method.getName())) { throw new IllegalStateException("Illegal to call this method from injected, managed EntityManager"); } else { //catch all try { return method.invoke(getWrappedObject(), args); } catch (InvocationTargetException e) { if (e.getTargetException() instanceof RuntimeException) { throw (RuntimeException) e.getTargetException(); } else { throw e; } } } }