org.nakedobjects.plugins.headless.viewer.internal.Proxy Maven / Gradle / Ivy
package org.nakedobjects.plugins.headless.viewer.internal;
import java.util.Collection;
import java.util.Map;
import org.nakedobjects.metamodel.runtimecontext.RuntimeContext;
import org.nakedobjects.metamodel.spec.feature.OneToManyAssociation;
import org.nakedobjects.plugins.headless.applib.HeadlessViewer;
import org.nakedobjects.plugins.headless.applib.HeadlessViewer.ExecutionMode;
public class Proxy {
public static T proxy(
final T toProxy,
final HeadlessViewer embeddedViewer,
final ExecutionMode mode,
final RuntimeContext runtimeContext) {
final DomainObjectInvocationHandler invocationHandler =
new DomainObjectInvocationHandler(toProxy, embeddedViewer, mode, runtimeContext);
final CgLibProxy cglibProxy = new CgLibProxy(invocationHandler);
return cglibProxy.proxy();
}
/**
* Whether to execute or not will be picked up from the supplied parent handler.
*/
public static Collection proxy(
final Collection collectionToProxy,
final String collectionName,
final DomainObjectInvocationHandler handler,
final RuntimeContext runtimeContext,
final OneToManyAssociation otma) {
final CollectionInvocationHandler> collectionInvocationHandler =
new CollectionInvocationHandler>(
collectionToProxy, collectionName, handler, runtimeContext, otma);
collectionInvocationHandler.setResolveObjectChangedEnabled(handler.isResolveObjectChangedEnabled());
final CgLibProxy> cglibProxy = new CgLibProxy>(collectionInvocationHandler);
return cglibProxy.proxy();
}
/**
* Whether to execute or not will be picked up from the supplied parent handler.
*/
public static Map proxy(
final Map
collectionToProxy,
final String collectionName,
final DomainObjectInvocationHandler handler,
final RuntimeContext runtimeContext,
final OneToManyAssociation otma) {
final MapInvocationHandler> mapInvocationHandler = new MapInvocationHandler>(collectionToProxy,
collectionName, handler, runtimeContext, otma);
mapInvocationHandler.setResolveObjectChangedEnabled(handler.isResolveObjectChangedEnabled());
final CgLibProxy