public Object invoke()

in src/main/java/org/apache/jackrabbit/ocm/manager/objectconverter/impl/AbstractLazyLoader.java [89:120]


	public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {

		if (!(proxy instanceof OcmProxy)) {
			throw new IllegalArgumentException("proxy should implement OcmProxy");
		}

		// proxified methods without concrete implementation
		if (args.length == 0) {
			if (method.getName().equals("isInitialized")) {
				return isInitialized();

			} else if (method.getName().equals("fetch")) {
				getTarget();
				return null;
			}
		}

		Object returnValue = null;

		if (Modifier.isPublic(method.getModifiers())) {
			if (!method.getDeclaringClass().isInstance(getTarget())) {
				throw new ClassCastException(getTarget().getClass().getName());
			}
			returnValue = method.invoke(getTarget(), args);
		} else {
			if (!method.isAccessible()) {
				method.setAccessible(true);
			}
			returnValue = method.invoke(getTarget(), args);
		}
		return returnValue == getTarget() ? proxy : returnValue;
	}