You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@isis.apache.org by da...@apache.org on 2012/01/22 08:38:05 UTC
svn commit: r1234457 [2/2] - in /incubator/isis/trunk/framework/progmodels:
dflt/src/main/java/org/apache/isis/progmodels/dflt/
dflt/src/test/java/org/apache/isis/progmodels/dflt/
groovy/applib/src/main/java/org/apache/isis/progmodel/groovy/applib/ gro...
Modified: incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/internal/DomainObjectInvocationHandler.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/internal/DomainObjectInvocationHandler.java?rev=1234457&r1=1234456&r2=1234457&view=diff
==============================================================================
--- incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/internal/DomainObjectInvocationHandler.java (original)
+++ incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/internal/DomainObjectInvocationHandler.java Sun Jan 22 07:38:03 2012
@@ -49,7 +49,6 @@ import org.apache.isis.core.metamodel.fa
import org.apache.isis.core.metamodel.facets.actions.defaults.ActionDefaultsFacet;
import org.apache.isis.core.metamodel.facets.collections.modify.CollectionAddToFacet;
import org.apache.isis.core.metamodel.facets.collections.modify.CollectionRemoveFromFacet;
-import org.apache.isis.core.metamodel.facets.hide.HiddenFacet;
import org.apache.isis.core.metamodel.facets.param.choices.ActionParameterChoicesFacet;
import org.apache.isis.core.metamodel.facets.properties.choices.PropertyChoicesFacet;
import org.apache.isis.core.metamodel.facets.properties.defaults.PropertyDefaultFacet;
@@ -67,11 +66,8 @@ import org.apache.isis.core.progmodel.fa
import org.apache.isis.core.progmodel.facets.collections.validate.CollectionValidateAddToFacetViaMethod;
import org.apache.isis.core.progmodel.facets.collections.validate.CollectionValidateRemoveFromFacetViaMethod;
import org.apache.isis.core.progmodel.facets.members.disable.method.DisableForContextFacetViaMethod;
-import org.apache.isis.core.progmodel.facets.members.hide.method.HiddenFacetViaHideMethodFacetFactory;
import org.apache.isis.core.progmodel.facets.members.hide.method.HideForContextFacetViaMethod;
-import org.apache.isis.core.progmodel.facets.object.hidden.method.HiddenObjectFacetViaHiddenMethod;
import org.apache.isis.core.progmodel.facets.properties.modify.PropertyClearFacetViaClearMethod;
-import org.apache.isis.core.progmodel.facets.properties.modify.PropertyModifyFacetFactory;
import org.apache.isis.core.progmodel.facets.properties.modify.PropertySetterFacetViaModifyMethod;
import org.apache.isis.core.progmodel.facets.properties.validate.PropertyValidateFacetViaMethod;
import org.apache.isis.progmodel.wrapper.applib.DisabledException;
@@ -107,10 +103,8 @@ public class DomainObjectInvocationHandl
*/
protected Method wrappedMethod;
- public DomainObjectInvocationHandler(final T delegate, final WrapperFactory embeddedViewer,
- final ExecutionMode mode, final AuthenticationSessionProvider authenticationSessionProvider,
- final SpecificationLookup specificationLookup, final AdapterMap adapterManager,
- final ObjectPersistor objectPersistor) {
+ public DomainObjectInvocationHandler(final T delegate, final WrapperFactory embeddedViewer, final ExecutionMode mode, final AuthenticationSessionProvider authenticationSessionProvider, final SpecificationLookup specificationLookup, final AdapterMap adapterManager,
+ final ObjectPersistor objectPersistor) {
super(delegate, embeddedViewer, mode);
this.authenticationSessionProvider = authenticationSessionProvider;
@@ -152,22 +146,16 @@ public class DomainObjectInvocationHandl
final ObjectMember objectMember = locateAndCheckMember(method);
final List<Facet> imperativeFacets = getImperativeFacets(objectMember, method);
-
+
final String memberName = objectMember.getName();
-
- if(instanceOf(imperativeFacets,
- DisableForContextFacetViaMethod.class,
- HideForContextFacetViaMethod.class
- )) {
- throw new UnsupportedOperationException(String.format(
- "Cannot invoke supporting method '%s'", memberName));
- }
+ if (instanceOf(imperativeFacets, DisableForContextFacetViaMethod.class, HideForContextFacetViaMethod.class)) {
+ throw new UnsupportedOperationException(String.format("Cannot invoke supporting method '%s'", memberName));
+ }
-
final String methodName = method.getName();
- if(instanceOf(imperativeFacets, ActionDefaultsFacet.class, PropertyDefaultFacet.class, ActionChoicesFacet.class, ActionParameterChoicesFacet.class, PropertyChoicesFacet.class)) {
+ if (instanceOf(imperativeFacets, ActionDefaultsFacet.class, PropertyDefaultFacet.class, ActionChoicesFacet.class, ActionParameterChoicesFacet.class, PropertyChoicesFacet.class)) {
return method.invoke(getDelegate(), args);
}
@@ -176,75 +164,58 @@ public class DomainObjectInvocationHandl
if (objectMember.isOneToOneAssociation()) {
- if(instanceOf(imperativeFacets,
- PropertyValidateFacetViaMethod.class,
- PropertySetterFacetViaModifyMethod.class,
- PropertyClearFacetViaClearMethod.class
- )) {
- throw new UnsupportedOperationException(String.format(
- "Cannot invoke supporting method '%s'; use only property accessor/mutator", memberName));
- }
+ if (instanceOf(imperativeFacets, PropertyValidateFacetViaMethod.class, PropertySetterFacetViaModifyMethod.class, PropertyClearFacetViaClearMethod.class)) {
+ throw new UnsupportedOperationException(String.format("Cannot invoke supporting method '%s'; use only property accessor/mutator", memberName));
+ }
final OneToOneAssociation otoa = (OneToOneAssociation) objectMember;
- if(instanceOf(imperativeFacets, PropertyOrCollectionAccessorFacet.class)) {
+ if (instanceOf(imperativeFacets, PropertyOrCollectionAccessorFacet.class)) {
return handleGetterMethodOnProperty(args, targetAdapter, otoa, methodName);
}
- if(instanceOf(imperativeFacets, PropertySetterFacet.class, PropertyInitializationFacet.class)) {
+ if (instanceOf(imperativeFacets, PropertySetterFacet.class, PropertyInitializationFacet.class)) {
checkUsability(getAuthenticationSession(), targetAdapter, objectMember);
return handleSetterMethodOnProperty(args, getAuthenticationSession(), targetAdapter, otoa, methodName);
}
}
if (objectMember.isOneToManyAssociation()) {
- if(instanceOf(imperativeFacets,
- CollectionValidateAddToFacetViaMethod.class,
- CollectionValidateRemoveFromFacetViaMethod.class
- )) {
- throw new UnsupportedOperationException(String.format(
- "Cannot invoke supporting method '%s'; use only collection accessor/mutator", memberName));
- }
+ if (instanceOf(imperativeFacets, CollectionValidateAddToFacetViaMethod.class, CollectionValidateRemoveFromFacetViaMethod.class)) {
+ throw new UnsupportedOperationException(String.format("Cannot invoke supporting method '%s'; use only collection accessor/mutator", memberName));
+ }
final OneToManyAssociation otma = (OneToManyAssociation) objectMember;
- if(instanceOf(imperativeFacets, PropertyOrCollectionAccessorFacet.class)) {
+ if (instanceOf(imperativeFacets, PropertyOrCollectionAccessorFacet.class)) {
return handleGetterMethodOnCollection(method, args, targetAdapter, otma, memberName);
}
- if(instanceOf(imperativeFacets, CollectionAddToFacet.class)) {
+ if (instanceOf(imperativeFacets, CollectionAddToFacet.class)) {
checkUsability(getAuthenticationSession(), targetAdapter, objectMember);
return handleCollectionAddToMethod(args, targetAdapter, otma, methodName);
}
- if(instanceOf(imperativeFacets, CollectionRemoveFromFacet.class)) {
+ if (instanceOf(imperativeFacets, CollectionRemoveFromFacet.class)) {
checkUsability(getAuthenticationSession(), targetAdapter, objectMember);
return handleCollectionRemoveFromMethod(args, targetAdapter, otma, methodName);
}
}
// filter out
- if(instanceOf(imperativeFacets, PropertyOrCollectionAccessorFacet.class)) {
- throw new UnsupportedOperationException(String.format(
- "Can only invoke accessor on properties or collections; '%s' represents %s", methodName,
- decode(objectMember)));
- }
- if(instanceOf(imperativeFacets, PropertySetterFacet.class)) {
- throw new UnsupportedOperationException(String.format(
- "Can only invoke mutator on properties; '%s' represents %s", methodName, decode(objectMember)));
- }
- if(instanceOf(imperativeFacets, CollectionAddToFacet.class)) {
- throw new UnsupportedOperationException(String.format(
- "Can only invoke 'adder' on collections; '%s' represents %s", methodName, decode(objectMember)));
- }
- if(instanceOf(imperativeFacets, CollectionRemoveFromFacet.class)) {
- throw new UnsupportedOperationException(String.format(
- "Can only invoke 'remover' on collections; '%s' represents %s", methodName, decode(objectMember)));
+ if (instanceOf(imperativeFacets, PropertyOrCollectionAccessorFacet.class)) {
+ throw new UnsupportedOperationException(String.format("Can only invoke accessor on properties or collections; '%s' represents %s", methodName, decode(objectMember)));
+ }
+ if (instanceOf(imperativeFacets, PropertySetterFacet.class)) {
+ throw new UnsupportedOperationException(String.format("Can only invoke mutator on properties; '%s' represents %s", methodName, decode(objectMember)));
+ }
+ if (instanceOf(imperativeFacets, CollectionAddToFacet.class)) {
+ throw new UnsupportedOperationException(String.format("Can only invoke 'adder' on collections; '%s' represents %s", methodName, decode(objectMember)));
+ }
+ if (instanceOf(imperativeFacets, CollectionRemoveFromFacet.class)) {
+ throw new UnsupportedOperationException(String.format("Can only invoke 'remover' on collections; '%s' represents %s", methodName, decode(objectMember)));
}
if (objectMember instanceof ObjectAction) {
- if(instanceOf(imperativeFacets,
- ActionValidationFacetViaMethod.class
- )) {
- throw new UnsupportedOperationException(String.format(
- "Cannot invoke supporting method '%s'; use only the 'invoke' method", memberName));
- }
+ if (instanceOf(imperativeFacets, ActionValidationFacetViaMethod.class)) {
+ throw new UnsupportedOperationException(String.format("Cannot invoke supporting method '%s'; use only the 'invoke' method", memberName));
+ }
checkUsability(getAuthenticationSession(), targetAdapter, objectMember);
@@ -258,26 +229,27 @@ public class DomainObjectInvocationHandl
public List<Facet> getImperativeFacets(final ObjectMember objectMember, final Method method) {
final List<Facet> imperativeFacets = objectMember.getFacets(new Filter<Facet>() {
@Override
- public boolean accept(Facet facet) {
- ImperativeFacet imperativeFacet = asImperativeFacet(facet);
- if(imperativeFacet == null) {
+ public boolean accept(final Facet facet) {
+ final ImperativeFacet imperativeFacet = asImperativeFacet(facet);
+ if (imperativeFacet == null) {
return false;
}
return imperativeFacet.getMethods().contains(method);
}
- private ImperativeFacet asImperativeFacet(Facet facet) {
- if(facet == null) {
+
+ private ImperativeFacet asImperativeFacet(final Facet facet) {
+ if (facet == null) {
return null;
}
- if(facet instanceof ImperativeFacet) {
+ if (facet instanceof ImperativeFacet) {
return (ImperativeFacet) facet;
}
return asImperativeFacet(facet.getUnderlyingFacet());
}
});
-
+
// there will be at least one
- if(imperativeFacets.isEmpty()) {
+ if (imperativeFacets.isEmpty()) {
throw new IllegalStateException("should be at least one imperative facet");
}
return imperativeFacets;
@@ -285,8 +257,8 @@ public class DomainObjectInvocationHandl
private static boolean instanceOf(final List<?> objects, final Class<?>... superTypes) {
for (final Class<?> superType : superTypes) {
- for(final Object obj: objects) {
- if(superType.isAssignableFrom(obj.getClass())) {
+ for (final Object obj : objects) {
+ if (superType.isAssignableFrom(obj.getClass())) {
return true;
}
}
@@ -298,15 +270,12 @@ public class DomainObjectInvocationHandl
// title
// /////////////////////////////////////////////////////////////////
- private Object handleTitleMethod(final Method method, final Object[] args, final ObjectAdapter targetAdapter)
- throws IllegalAccessException, InvocationTargetException {
+ private Object handleTitleMethod(final Method method, final Object[] args, final ObjectAdapter targetAdapter) throws IllegalAccessException, InvocationTargetException {
resolveIfRequired(targetAdapter);
final ObjectSpecification targetNoSpec = targetAdapter.getSpecification();
- final ObjectTitleContext titleContext =
- targetNoSpec.createTitleInteractionContext(getAuthenticationSession(), InteractionInvocationMethod.BY_USER,
- targetAdapter);
+ final ObjectTitleContext titleContext = targetNoSpec.createTitleInteractionContext(getAuthenticationSession(), InteractionInvocationMethod.BY_USER, targetAdapter);
final ObjectTitleEvent titleEvent = titleContext.createInteractionEvent();
notifyListeners(titleEvent);
return titleEvent.getTitle();
@@ -316,8 +285,7 @@ public class DomainObjectInvocationHandl
// save
// /////////////////////////////////////////////////////////////////
- private Object handleSaveMethod(final AuthenticationSession session, final ObjectAdapter targetAdapter,
- final ObjectSpecification targetNoSpec) {
+ private Object handleSaveMethod(final AuthenticationSession session, final ObjectAdapter targetAdapter, final ObjectSpecification targetNoSpec) {
final InteractionResult interactionResult = targetNoSpec.isValidResult(targetAdapter);
notifyListenersAndVetoIfRequired(interactionResult);
@@ -334,8 +302,7 @@ public class DomainObjectInvocationHandl
// property - access
// /////////////////////////////////////////////////////////////////
- private Object handleGetterMethodOnProperty(final Object[] args, final ObjectAdapter targetAdapter,
- final OneToOneAssociation otoa, final String methodName) {
+ private Object handleGetterMethodOnProperty(final Object[] args, final ObjectAdapter targetAdapter, final OneToOneAssociation otoa, final String methodName) {
if (args.length != 0) {
throw new IllegalArgumentException("Invoking a 'get' should have no arguments");
}
@@ -345,8 +312,7 @@ public class DomainObjectInvocationHandl
final ObjectAdapter currentReferencedAdapter = otoa.get(targetAdapter);
final Object currentReferencedObj = AdapterUtils.unwrap(currentReferencedAdapter);
- final PropertyAccessEvent ev =
- new PropertyAccessEvent(getDelegate(), otoa.getIdentifier(), currentReferencedObj);
+ final PropertyAccessEvent ev = new PropertyAccessEvent(getDelegate(), otoa.getIdentifier(), currentReferencedObj);
notifyListeners(ev);
return currentReferencedObj;
}
@@ -355,8 +321,7 @@ public class DomainObjectInvocationHandl
// property - modify
// /////////////////////////////////////////////////////////////////
- private Object handleSetterMethodOnProperty(final Object[] args, final AuthenticationSession session,
- final ObjectAdapter targetAdapter, final OneToOneAssociation otoa, final String methodName) {
+ private Object handleSetterMethodOnProperty(final Object[] args, final AuthenticationSession session, final ObjectAdapter targetAdapter, final OneToOneAssociation otoa, final String methodName) {
if (args.length != 1) {
throw new IllegalArgumentException("Invoking a setter should only have a single argument");
}
@@ -366,13 +331,13 @@ public class DomainObjectInvocationHandl
final Object argumentObj = underlying(args[0]);
final ObjectAdapter argumentNO = argumentObj != null ? getAdapterManager().adapterFor(argumentObj) : null;
- final InteractionResult interactionResult =
- otoa.isAssociationValid(targetAdapter, argumentNO).getInteractionResult();
+ final InteractionResult interactionResult = otoa.isAssociationValid(targetAdapter, argumentNO).getInteractionResult();
notifyListenersAndVetoIfRequired(interactionResult);
if (getExecutionMode() == ExecutionMode.EXECUTE) {
if (argumentNO != null) {
- otoa.setAssociation(targetAdapter, argumentNO); // need to wrap arg
+ otoa.setAssociation(targetAdapter, argumentNO); // need to wrap
+ // arg
} else {
otoa.clearAssociation(targetAdapter);
}
@@ -387,8 +352,7 @@ public class DomainObjectInvocationHandl
// collection - access
// /////////////////////////////////////////////////////////////////
- private Object handleGetterMethodOnCollection(final Method method, final Object[] args,
- final ObjectAdapter targetAdapter, final OneToManyAssociation otma, final String memberName) {
+ private Object handleGetterMethodOnCollection(final Method method, final Object[] args, final ObjectAdapter targetAdapter, final OneToManyAssociation otma, final String memberName) {
if (args.length != 0) {
throw new IllegalArgumentException("Invoking a 'get' should have no arguments");
}
@@ -401,25 +365,21 @@ public class DomainObjectInvocationHandl
final CollectionAccessEvent ev = new CollectionAccessEvent(getDelegate(), otma.getIdentifier());
if (currentReferencedObj instanceof Collection) {
- final Collection<?> collectionViewObject =
- lookupViewObject(method, memberName, (Collection<?>) currentReferencedObj, otma);
+ final Collection<?> collectionViewObject = lookupViewObject(method, memberName, (Collection<?>) currentReferencedObj, otma);
notifyListeners(ev);
return collectionViewObject;
} else if (currentReferencedObj instanceof Map) {
- final Map<?, ?> mapViewObject =
- lookupViewObject(method, memberName, (Map<?, ?>) currentReferencedObj, otma);
+ final Map<?, ?> mapViewObject = lookupViewObject(method, memberName, (Map<?, ?>) currentReferencedObj, otma);
notifyListeners(ev);
return mapViewObject;
}
- throw new IllegalArgumentException(String.format("Collection type '%s' not supported by framework",
- currentReferencedObj.getClass().getName()));
+ throw new IllegalArgumentException(String.format("Collection type '%s' not supported by framework", currentReferencedObj.getClass().getName()));
}
/**
* Looks up (or creates) a proxy for this object.
*/
- private Collection<?> lookupViewObject(final Method method, final String memberName,
- final Collection<?> collectionToLookup, final OneToManyAssociation otma) {
+ private Collection<?> lookupViewObject(final Method method, final String memberName, final Collection<?> collectionToLookup, final OneToManyAssociation otma) {
Collection<?> collectionViewObject = collectionViewObjectsByMethod.get(method);
if (collectionViewObject == null) {
if (collectionToLookup instanceof WrapperObject) {
@@ -432,8 +392,7 @@ public class DomainObjectInvocationHandl
return collectionViewObject;
}
- private Map<?, ?> lookupViewObject(final Method method, final String memberName, final Map<?, ?> mapToLookup,
- final OneToManyAssociation otma) {
+ private Map<?, ?> lookupViewObject(final Method method, final String memberName, final Map<?, ?> mapToLookup, final OneToManyAssociation otma) {
Map<?, ?> mapViewObject = mapViewObjectsByMethod.get(method);
if (mapViewObject == null) {
if (mapToLookup instanceof WrapperObject) {
@@ -450,8 +409,7 @@ public class DomainObjectInvocationHandl
// collection - add to
// /////////////////////////////////////////////////////////////////
- private Object handleCollectionAddToMethod(final Object[] args, final ObjectAdapter targetAdapter,
- final OneToManyAssociation otma, final String methodName) {
+ private Object handleCollectionAddToMethod(final Object[] args, final ObjectAdapter targetAdapter, final OneToManyAssociation otma, final String methodName) {
if (args.length != 1) {
throw new IllegalArgumentException("Invoking a addTo should only have a single argument");
@@ -481,8 +439,7 @@ public class DomainObjectInvocationHandl
// collection - remove from
// /////////////////////////////////////////////////////////////////
- private Object handleCollectionRemoveFromMethod(final Object[] args, final ObjectAdapter targetAdapter,
- final OneToManyAssociation otma, final String methodName) {
+ private Object handleCollectionRemoveFromMethod(final Object[] args, final ObjectAdapter targetAdapter, final OneToManyAssociation otma, final String methodName) {
if (args.length != 1) {
throw new IllegalArgumentException("Invoking a removeFrom should only have a single argument");
}
@@ -495,8 +452,7 @@ public class DomainObjectInvocationHandl
}
final ObjectAdapter argumentAdapter = getAdapterManager().adapterFor(argumentObj);
- final InteractionResult interactionResult =
- otma.isValidToRemove(targetAdapter, argumentAdapter).getInteractionResult();
+ final InteractionResult interactionResult = otma.isValidToRemove(targetAdapter, argumentAdapter).getInteractionResult();
notifyListenersAndVetoIfRequired(interactionResult);
if (getExecutionMode() == ExecutionMode.EXECUTE) {
@@ -512,8 +468,7 @@ public class DomainObjectInvocationHandl
// action
// /////////////////////////////////////////////////////////////////
- private Object handleActionMethod(final Object[] args, final AuthenticationSession session,
- final ObjectAdapter targetAdapter, final ObjectAction noa, final String memberName) {
+ private Object handleActionMethod(final Object[] args, final AuthenticationSession session, final ObjectAdapter targetAdapter, final ObjectAction noa, final String memberName) {
final Object[] underlyingArgs = new Object[args.length];
int i = 0;
@@ -527,8 +482,7 @@ public class DomainObjectInvocationHandl
argAdapters[j++] = underlyingArg != null ? getAdapterManager().adapterFor(underlyingArg) : null;
}
- final InteractionResult interactionResult =
- noa.isProposedArgumentSetValid(targetAdapter, argAdapters).getInteractionResult();
+ final InteractionResult interactionResult = noa.isProposedArgumentSetValid(targetAdapter, argAdapters).getInteractionResult();
notifyListenersAndVetoIfRequired(interactionResult);
if (getExecutionMode() == ExecutionMode.EXECUTE) {
@@ -554,17 +508,13 @@ public class DomainObjectInvocationHandl
// visibility and usability checks (common to all members)
// /////////////////////////////////////////////////////////////////
- private void checkVisibility(final AuthenticationSession session, final ObjectAdapter targetObjectAdapter,
- final ObjectMember objectMember) {
- final InteractionResult interactionResult =
- objectMember.isVisible(getAuthenticationSession(), targetObjectAdapter).getInteractionResult();
+ private void checkVisibility(final AuthenticationSession session, final ObjectAdapter targetObjectAdapter, final ObjectMember objectMember) {
+ final InteractionResult interactionResult = objectMember.isVisible(getAuthenticationSession(), targetObjectAdapter).getInteractionResult();
notifyListenersAndVetoIfRequired(interactionResult);
}
- private void checkUsability(final AuthenticationSession session, final ObjectAdapter targetObjectAdapter,
- final ObjectMember objectMember) {
- final InteractionResult interactionResult =
- objectMember.isUsable(getAuthenticationSession(), targetObjectAdapter).getInteractionResult();
+ private void checkUsability(final AuthenticationSession session, final ObjectAdapter targetObjectAdapter, final ObjectMember objectMember) {
+ final InteractionResult interactionResult = objectMember.isUsable(getAuthenticationSession(), targetObjectAdapter).getInteractionResult();
notifyListenersAndVetoIfRequired(interactionResult);
}
@@ -594,8 +544,9 @@ public class DomainObjectInvocationHandl
}
/**
- * Wraps a {@link InteractionEvent#isVeto() vetoing} {@link InteractionEvent} in a corresponding
- * {@link InteractionException}, and returns it.
+ * Wraps a {@link InteractionEvent#isVeto() vetoing}
+ * {@link InteractionEvent} in a corresponding {@link InteractionException},
+ * and returns it.
*/
private InteractionException toException(final InteractionEvent interactionEvent) {
if (!interactionEvent.isVeto()) {
@@ -613,8 +564,7 @@ public class DomainObjectInvocationHandl
final UsabilityEvent usabilityEvent = (UsabilityEvent) interactionEvent;
return new DisabledException(usabilityEvent);
}
- throw new IllegalArgumentException(
- "Provided interactionEvent must be a VisibilityEvent, UsabilityEvent or a ValidityEvent");
+ throw new IllegalArgumentException("Provided interactionEvent must be a VisibilityEvent, UsabilityEvent or a ValidityEvent");
}
// /////////////////////////////////////////////////////////////////
@@ -626,8 +576,7 @@ public class DomainObjectInvocationHandl
final ObjectMember member = objectSpecificationDefault.getMember(method);
if (member == null) {
final String methodName = method.getName();
- throw new UnsupportedOperationException("Method '" + methodName
- + "' being invoked does not correspond to any of the object's fields or actions.");
+ throw new UnsupportedOperationException("Method '" + methodName + "' being invoked does not correspond to any of the object's fields or actions.");
}
return member;
}
@@ -644,7 +593,6 @@ public class DomainObjectInvocationHandl
return method.equals(wrappedMethod);
}
-
// /////////////////////////////////////////////////////////////////
// Specification lookup
// /////////////////////////////////////////////////////////////////
@@ -656,8 +604,7 @@ public class DomainObjectInvocationHandl
private ObjectSpecificationDefault getJavaSpecification(final Class<?> clazz) {
final ObjectSpecification nos = getSpecification(clazz);
if (!(nos instanceof ObjectSpecificationDefault)) {
- throw new UnsupportedOperationException("Only Java is supported (specification is '"
- + nos.getClass().getCanonicalName() + "')");
+ throw new UnsupportedOperationException("Only Java is supported (specification is '" + nos.getClass().getCanonicalName() + "')");
}
return (ObjectSpecificationDefault) nos;
}
Modified: incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/internal/IClassInstantiatorCE.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/internal/IClassInstantiatorCE.java?rev=1234457&r1=1234456&r2=1234457&view=diff
==============================================================================
--- incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/internal/IClassInstantiatorCE.java (original)
+++ incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/internal/IClassInstantiatorCE.java Sun Jan 22 07:38:03 2012
@@ -25,8 +25,9 @@ package org.apache.isis.progmodel.wrappe
interface IClassInstantiatorCE {
/**
- * Return a new instance of the specified class. The recommended way is without calling any constructor. This is
- * usually done by doing like <code>ObjectInputStream.readObject()</code> which is JVM specific.
+ * Return a new instance of the specified class. The recommended way is
+ * without calling any constructor. This is usually done by doing like
+ * <code>ObjectInputStream.readObject()</code> which is JVM specific.
*
* @param c
* Class to instantiate
Modified: incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/internal/InteractionEventDispatcherTypeSafe.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/internal/InteractionEventDispatcherTypeSafe.java?rev=1234457&r1=1234456&r2=1234457&view=diff
==============================================================================
--- incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/internal/InteractionEventDispatcherTypeSafe.java (original)
+++ incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/internal/InteractionEventDispatcherTypeSafe.java Sun Jan 22 07:38:03 2012
@@ -21,8 +21,7 @@ package org.apache.isis.progmodel.wrappe
import org.apache.isis.applib.events.InteractionEvent;
-public abstract class InteractionEventDispatcherTypeSafe<T extends InteractionEvent> implements
- InteractionEventDispatcher {
+public abstract class InteractionEventDispatcherTypeSafe<T extends InteractionEvent> implements InteractionEventDispatcher {
public abstract void dispatchTypeSafe(T interactionEvent);
Modified: incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/internal/InvocationHandlerMethodInterceptor.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/internal/InvocationHandlerMethodInterceptor.java?rev=1234457&r1=1234456&r2=1234457&view=diff
==============================================================================
--- incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/internal/InvocationHandlerMethodInterceptor.java (original)
+++ incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/internal/InvocationHandlerMethodInterceptor.java Sun Jan 22 07:38:03 2012
@@ -33,8 +33,7 @@ public class InvocationHandlerMethodInte
}
@Override
- public Object intercept(final Object obj, final Method method, final Object[] args, final MethodProxy proxy)
- throws Throwable {
+ public Object intercept(final Object obj, final Method method, final Object[] args, final MethodProxy proxy) throws Throwable {
return handler.invoke(obj, method, args);
}
}
\ No newline at end of file
Modified: incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/internal/JavaProxyFactory.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/internal/JavaProxyFactory.java?rev=1234457&r1=1234456&r2=1234457&view=diff
==============================================================================
--- incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/internal/JavaProxyFactory.java (original)
+++ incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/internal/JavaProxyFactory.java Sun Jan 22 07:38:03 2012
@@ -35,7 +35,6 @@ public class JavaProxyFactory<T> impleme
@Override
@SuppressWarnings("unchecked")
public T createProxy(final Class<T> toProxy, final InvocationHandler handler) {
- return (T) Proxy.newProxyInstance(toProxy.getClassLoader(), new Class[] { toProxy, WrapperObject.class },
- handler);
+ return (T) Proxy.newProxyInstance(toProxy.getClassLoader(), new Class[] { toProxy, WrapperObject.class }, handler);
}
}
Modified: incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/internal/MapInvocationHandler.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/internal/MapInvocationHandler.java?rev=1234457&r1=1234456&r2=1234457&view=diff
==============================================================================
--- incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/internal/MapInvocationHandler.java (original)
+++ incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/internal/MapInvocationHandler.java Sun Jan 22 07:38:03 2012
@@ -27,8 +27,7 @@ import org.apache.isis.core.metamodel.sp
class MapInvocationHandler<T, C> extends AbstractCollectionInvocationHandler<T, C> {
- public MapInvocationHandler(final C collectionToProxy, final String collectionName,
- final DomainObjectInvocationHandler<T> handler, final OneToManyAssociation otma) {
+ public MapInvocationHandler(final C collectionToProxy, final String collectionName, final DomainObjectInvocationHandler<T> handler, final OneToManyAssociation otma) {
super(collectionToProxy, collectionName, handler, otma);
try {
Modified: incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/internal/Proxy.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/internal/Proxy.java?rev=1234457&r1=1234456&r2=1234457&view=diff
==============================================================================
--- incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/internal/Proxy.java (original)
+++ incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/internal/Proxy.java Sun Jan 22 07:38:03 2012
@@ -37,33 +37,27 @@ import org.apache.isis.progmodel.wrapper
public class Proxy {
- public static <T> T proxy(final T domainObject, final WrapperFactory wrapperFactory, final ExecutionMode mode,
- final AuthenticationSessionProvider authenticationSessionProvider,
- final SpecificationLookup specificationLookup, final AdapterMap adapterManager,
- final ObjectPersistor objectPersistor) {
-
+ public static <T> T proxy(final T domainObject, final WrapperFactory wrapperFactory, final ExecutionMode mode, final AuthenticationSessionProvider authenticationSessionProvider, final SpecificationLookup specificationLookup, final AdapterMap adapterManager, final ObjectPersistor objectPersistor) {
+
Ensure.ensureThatArg(wrapperFactory, is(not(nullValue())));
Ensure.ensureThatArg(authenticationSessionProvider, is(not(nullValue())));
Ensure.ensureThatArg(specificationLookup, is(not(nullValue())));
Ensure.ensureThatArg(adapterManager, is(not(nullValue())));
Ensure.ensureThatArg(objectPersistor, is(not(nullValue())));
-
- final DomainObjectInvocationHandler<T> invocationHandler =
- new DomainObjectInvocationHandler<T>(domainObject, wrapperFactory, mode, authenticationSessionProvider,
- specificationLookup, adapterManager, objectPersistor);
+
+ final DomainObjectInvocationHandler<T> invocationHandler = new DomainObjectInvocationHandler<T>(domainObject, wrapperFactory, mode, authenticationSessionProvider, specificationLookup, adapterManager, objectPersistor);
final CgLibProxy<T> cglibProxy = new CgLibProxy<T>(invocationHandler);
return cglibProxy.proxy();
}
/**
- * Whether to execute or not will be picked up from the supplied parent handler.
+ * Whether to execute or not will be picked up from the supplied parent
+ * handler.
*/
- public static <T, E> Collection<E> proxy(final Collection<E> collectionToProxy, final String collectionName,
- final DomainObjectInvocationHandler<T> handler, final OneToManyAssociation otma) {
+ public static <T, E> Collection<E> proxy(final Collection<E> collectionToProxy, final String collectionName, final DomainObjectInvocationHandler<T> handler, final OneToManyAssociation otma) {
- final CollectionInvocationHandler<T, Collection<E>> collectionInvocationHandler =
- new CollectionInvocationHandler<T, Collection<E>>(collectionToProxy, collectionName, handler, otma);
+ final CollectionInvocationHandler<T, Collection<E>> collectionInvocationHandler = new CollectionInvocationHandler<T, Collection<E>>(collectionToProxy, collectionName, handler, otma);
collectionInvocationHandler.setResolveObjectChangedEnabled(handler.isResolveObjectChangedEnabled());
final CgLibProxy<Collection<E>> cglibProxy = new CgLibProxy<Collection<E>>(collectionInvocationHandler);
@@ -71,13 +65,12 @@ public class Proxy {
}
/**
- * Whether to execute or not will be picked up from the supplied parent handler.
+ * Whether to execute or not will be picked up from the supplied parent
+ * handler.
*/
- public static <T, P, Q> Map<P, Q> proxy(final Map<P, Q> collectionToProxy, final String collectionName,
- final DomainObjectInvocationHandler<T> handler, final OneToManyAssociation otma) {
+ public static <T, P, Q> Map<P, Q> proxy(final Map<P, Q> collectionToProxy, final String collectionName, final DomainObjectInvocationHandler<T> handler, final OneToManyAssociation otma) {
- final MapInvocationHandler<T, Map<P, Q>> mapInvocationHandler =
- new MapInvocationHandler<T, Map<P, Q>>(collectionToProxy, collectionName, handler, otma);
+ final MapInvocationHandler<T, Map<P, Q>> mapInvocationHandler = new MapInvocationHandler<T, Map<P, Q>>(collectionToProxy, collectionName, handler, otma);
mapInvocationHandler.setResolveObjectChangedEnabled(handler.isResolveObjectChangedEnabled());
final CgLibProxy<Map<P, Q>> cglibProxy = new CgLibProxy<Map<P, Q>>(mapInvocationHandler);
Modified: incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/internal/WrapperFactoryDefault.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/internal/WrapperFactoryDefault.java?rev=1234457&r1=1234456&r2=1234457&view=diff
==============================================================================
--- incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/internal/WrapperFactoryDefault.java (original)
+++ incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/internal/WrapperFactoryDefault.java Sun Jan 22 07:38:03 2012
@@ -53,12 +53,10 @@ import org.apache.isis.progmodel.wrapper
import org.apache.isis.progmodel.wrapper.applib.WrapperObject;
import org.apache.isis.progmodel.wrapper.applib.listeners.InteractionListener;
-public class WrapperFactoryDefault implements WrapperFactory, AuthenticationSessionProviderAware,
- SpecificationLookupAware, AdapterMapAware, ObjectPersistorAware {
+public class WrapperFactoryDefault implements WrapperFactory, AuthenticationSessionProviderAware, SpecificationLookupAware, AdapterMapAware, ObjectPersistorAware {
private final List<InteractionListener> listeners = new ArrayList<InteractionListener>();
- private final Map<Class<? extends InteractionEvent>, InteractionEventDispatcher> dispatchersByEventClass =
- new HashMap<Class<? extends InteractionEvent>, InteractionEventDispatcher>();
+ private final Map<Class<? extends InteractionEvent>, InteractionEventDispatcher> dispatchersByEventClass = new HashMap<Class<? extends InteractionEvent>, InteractionEventDispatcher>();
private AuthenticationSessionProvider authenticationSessionProvider;
private SpecificationLookup specificationLookup;
@@ -74,141 +72,126 @@ public class WrapperFactoryDefault imple
}
}
});
- dispatchersByEventClass.put(PropertyVisibilityEvent.class,
- new InteractionEventDispatcherTypeSafe<PropertyVisibilityEvent>() {
- @Override
- public void dispatchTypeSafe(final PropertyVisibilityEvent interactionEvent) {
- for (final InteractionListener l : getListeners()) {
- l.propertyVisible(interactionEvent);
- }
- }
- });
- dispatchersByEventClass.put(PropertyUsabilityEvent.class,
- new InteractionEventDispatcherTypeSafe<PropertyUsabilityEvent>() {
- @Override
- public void dispatchTypeSafe(final PropertyUsabilityEvent interactionEvent) {
- for (final InteractionListener l : getListeners()) {
- l.propertyUsable(interactionEvent);
- }
- }
- });
- dispatchersByEventClass.put(PropertyAccessEvent.class,
- new InteractionEventDispatcherTypeSafe<PropertyAccessEvent>() {
- @Override
- public void dispatchTypeSafe(final PropertyAccessEvent interactionEvent) {
- for (final InteractionListener l : getListeners()) {
- l.propertyAccessed(interactionEvent);
- }
- }
- });
- dispatchersByEventClass.put(PropertyModifyEvent.class,
- new InteractionEventDispatcherTypeSafe<PropertyModifyEvent>() {
- @Override
- public void dispatchTypeSafe(final PropertyModifyEvent interactionEvent) {
- for (final InteractionListener l : getListeners()) {
- l.propertyModified(interactionEvent);
- }
- }
- });
- dispatchersByEventClass.put(CollectionVisibilityEvent.class,
- new InteractionEventDispatcherTypeSafe<CollectionVisibilityEvent>() {
- @Override
- public void dispatchTypeSafe(final CollectionVisibilityEvent interactionEvent) {
- for (final InteractionListener l : getListeners()) {
- l.collectionVisible(interactionEvent);
- }
- }
- });
- dispatchersByEventClass.put(CollectionUsabilityEvent.class,
- new InteractionEventDispatcherTypeSafe<CollectionUsabilityEvent>() {
- @Override
- public void dispatchTypeSafe(final CollectionUsabilityEvent interactionEvent) {
- for (final InteractionListener l : getListeners()) {
- l.collectionUsable(interactionEvent);
- }
- }
- });
- dispatchersByEventClass.put(CollectionAccessEvent.class,
- new InteractionEventDispatcherTypeSafe<CollectionAccessEvent>() {
- @Override
- public void dispatchTypeSafe(final CollectionAccessEvent interactionEvent) {
- for (final InteractionListener l : getListeners()) {
- l.collectionAccessed(interactionEvent);
- }
- }
- });
- dispatchersByEventClass.put(CollectionAddToEvent.class,
- new InteractionEventDispatcherTypeSafe<CollectionAddToEvent>() {
- @Override
- public void dispatchTypeSafe(final CollectionAddToEvent interactionEvent) {
- for (final InteractionListener l : getListeners()) {
- l.collectionAddedTo(interactionEvent);
- }
- }
- });
- dispatchersByEventClass.put(CollectionRemoveFromEvent.class,
- new InteractionEventDispatcherTypeSafe<CollectionRemoveFromEvent>() {
- @Override
- public void dispatchTypeSafe(final CollectionRemoveFromEvent interactionEvent) {
- for (final InteractionListener l : getListeners()) {
- l.collectionRemovedFrom(interactionEvent);
- }
- }
- });
- dispatchersByEventClass.put(ActionVisibilityEvent.class,
- new InteractionEventDispatcherTypeSafe<ActionVisibilityEvent>() {
- @Override
- public void dispatchTypeSafe(final ActionVisibilityEvent interactionEvent) {
- for (final InteractionListener l : getListeners()) {
- l.actionVisible(interactionEvent);
- }
- }
- });
- dispatchersByEventClass.put(ActionUsabilityEvent.class,
- new InteractionEventDispatcherTypeSafe<ActionUsabilityEvent>() {
- @Override
- public void dispatchTypeSafe(final ActionUsabilityEvent interactionEvent) {
- for (final InteractionListener l : getListeners()) {
- l.actionUsable(interactionEvent);
- }
- }
- });
- dispatchersByEventClass.put(ActionArgumentEvent.class,
- new InteractionEventDispatcherTypeSafe<ActionArgumentEvent>() {
- @Override
- public void dispatchTypeSafe(final ActionArgumentEvent interactionEvent) {
- for (final InteractionListener l : getListeners()) {
- l.actionArgument(interactionEvent);
- }
- }
- });
- dispatchersByEventClass.put(ActionInvocationEvent.class,
- new InteractionEventDispatcherTypeSafe<ActionInvocationEvent>() {
- @Override
- public void dispatchTypeSafe(final ActionInvocationEvent interactionEvent) {
- for (final InteractionListener l : getListeners()) {
- l.actionInvoked(interactionEvent);
- }
- }
- });
- dispatchersByEventClass.put(ObjectValidityEvent.class,
- new InteractionEventDispatcherTypeSafe<ObjectValidityEvent>() {
- @Override
- public void dispatchTypeSafe(final ObjectValidityEvent interactionEvent) {
- for (final InteractionListener l : getListeners()) {
- l.objectPersisted(interactionEvent);
- }
- }
- });
- dispatchersByEventClass.put(CollectionMethodEvent.class,
- new InteractionEventDispatcherTypeSafe<CollectionMethodEvent>() {
- @Override
- public void dispatchTypeSafe(final CollectionMethodEvent interactionEvent) {
- for (final InteractionListener l : getListeners()) {
- l.collectionMethodInvoked(interactionEvent);
- }
+ dispatchersByEventClass.put(PropertyVisibilityEvent.class, new InteractionEventDispatcherTypeSafe<PropertyVisibilityEvent>() {
+ @Override
+ public void dispatchTypeSafe(final PropertyVisibilityEvent interactionEvent) {
+ for (final InteractionListener l : getListeners()) {
+ l.propertyVisible(interactionEvent);
+ }
+ }
+ });
+ dispatchersByEventClass.put(PropertyUsabilityEvent.class, new InteractionEventDispatcherTypeSafe<PropertyUsabilityEvent>() {
+ @Override
+ public void dispatchTypeSafe(final PropertyUsabilityEvent interactionEvent) {
+ for (final InteractionListener l : getListeners()) {
+ l.propertyUsable(interactionEvent);
+ }
+ }
+ });
+ dispatchersByEventClass.put(PropertyAccessEvent.class, new InteractionEventDispatcherTypeSafe<PropertyAccessEvent>() {
+ @Override
+ public void dispatchTypeSafe(final PropertyAccessEvent interactionEvent) {
+ for (final InteractionListener l : getListeners()) {
+ l.propertyAccessed(interactionEvent);
+ }
+ }
+ });
+ dispatchersByEventClass.put(PropertyModifyEvent.class, new InteractionEventDispatcherTypeSafe<PropertyModifyEvent>() {
+ @Override
+ public void dispatchTypeSafe(final PropertyModifyEvent interactionEvent) {
+ for (final InteractionListener l : getListeners()) {
+ l.propertyModified(interactionEvent);
+ }
+ }
+ });
+ dispatchersByEventClass.put(CollectionVisibilityEvent.class, new InteractionEventDispatcherTypeSafe<CollectionVisibilityEvent>() {
+ @Override
+ public void dispatchTypeSafe(final CollectionVisibilityEvent interactionEvent) {
+ for (final InteractionListener l : getListeners()) {
+ l.collectionVisible(interactionEvent);
+ }
+ }
+ });
+ dispatchersByEventClass.put(CollectionUsabilityEvent.class, new InteractionEventDispatcherTypeSafe<CollectionUsabilityEvent>() {
+ @Override
+ public void dispatchTypeSafe(final CollectionUsabilityEvent interactionEvent) {
+ for (final InteractionListener l : getListeners()) {
+ l.collectionUsable(interactionEvent);
+ }
+ }
+ });
+ dispatchersByEventClass.put(CollectionAccessEvent.class, new InteractionEventDispatcherTypeSafe<CollectionAccessEvent>() {
+ @Override
+ public void dispatchTypeSafe(final CollectionAccessEvent interactionEvent) {
+ for (final InteractionListener l : getListeners()) {
+ l.collectionAccessed(interactionEvent);
+ }
+ }
+ });
+ dispatchersByEventClass.put(CollectionAddToEvent.class, new InteractionEventDispatcherTypeSafe<CollectionAddToEvent>() {
+ @Override
+ public void dispatchTypeSafe(final CollectionAddToEvent interactionEvent) {
+ for (final InteractionListener l : getListeners()) {
+ l.collectionAddedTo(interactionEvent);
}
- });
+ }
+ });
+ dispatchersByEventClass.put(CollectionRemoveFromEvent.class, new InteractionEventDispatcherTypeSafe<CollectionRemoveFromEvent>() {
+ @Override
+ public void dispatchTypeSafe(final CollectionRemoveFromEvent interactionEvent) {
+ for (final InteractionListener l : getListeners()) {
+ l.collectionRemovedFrom(interactionEvent);
+ }
+ }
+ });
+ dispatchersByEventClass.put(ActionVisibilityEvent.class, new InteractionEventDispatcherTypeSafe<ActionVisibilityEvent>() {
+ @Override
+ public void dispatchTypeSafe(final ActionVisibilityEvent interactionEvent) {
+ for (final InteractionListener l : getListeners()) {
+ l.actionVisible(interactionEvent);
+ }
+ }
+ });
+ dispatchersByEventClass.put(ActionUsabilityEvent.class, new InteractionEventDispatcherTypeSafe<ActionUsabilityEvent>() {
+ @Override
+ public void dispatchTypeSafe(final ActionUsabilityEvent interactionEvent) {
+ for (final InteractionListener l : getListeners()) {
+ l.actionUsable(interactionEvent);
+ }
+ }
+ });
+ dispatchersByEventClass.put(ActionArgumentEvent.class, new InteractionEventDispatcherTypeSafe<ActionArgumentEvent>() {
+ @Override
+ public void dispatchTypeSafe(final ActionArgumentEvent interactionEvent) {
+ for (final InteractionListener l : getListeners()) {
+ l.actionArgument(interactionEvent);
+ }
+ }
+ });
+ dispatchersByEventClass.put(ActionInvocationEvent.class, new InteractionEventDispatcherTypeSafe<ActionInvocationEvent>() {
+ @Override
+ public void dispatchTypeSafe(final ActionInvocationEvent interactionEvent) {
+ for (final InteractionListener l : getListeners()) {
+ l.actionInvoked(interactionEvent);
+ }
+ }
+ });
+ dispatchersByEventClass.put(ObjectValidityEvent.class, new InteractionEventDispatcherTypeSafe<ObjectValidityEvent>() {
+ @Override
+ public void dispatchTypeSafe(final ObjectValidityEvent interactionEvent) {
+ for (final InteractionListener l : getListeners()) {
+ l.objectPersisted(interactionEvent);
+ }
+ }
+ });
+ dispatchersByEventClass.put(CollectionMethodEvent.class, new InteractionEventDispatcherTypeSafe<CollectionMethodEvent>() {
+ @Override
+ public void dispatchTypeSafe(final CollectionMethodEvent interactionEvent) {
+ for (final InteractionListener l : getListeners()) {
+ l.collectionMethodInvoked(interactionEvent);
+ }
+ }
+ });
}
// /////////////////////////////////////////////////////////////
@@ -225,8 +208,7 @@ public class WrapperFactoryDefault imple
if (isWrapper(domainObject)) {
return domainObject;
}
- return Proxy.proxy(domainObject, this, mode, authenticationSessionProvider, specificationLookup,
- adapterManager, objectPersistor);
+ return Proxy.proxy(domainObject, this, mode, authenticationSessionProvider, specificationLookup, adapterManager, objectPersistor);
}
@Override
Modified: incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/internal/util/Constants.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/internal/util/Constants.java?rev=1234457&r1=1234456&r2=1234457&view=diff
==============================================================================
--- incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/internal/util/Constants.java (original)
+++ incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/main/java/org/apache/isis/progmodel/wrapper/metamodel/internal/util/Constants.java Sun Jan 22 07:38:03 2012
@@ -43,15 +43,10 @@ public final class Constants {
/**
* Cannot invoke methods with these prefixes.
*/
- public final static String[] INVALID_PREFIXES = { PREFIX_MODIFY, PREFIX_CLEAR, PREFIX_DISABLE, PREFIX_VALIDATE,
- PREFIX_VALIDATE_ADD_TO, PREFIX_VALIDATE_REMOVE_FROM, PREFIX_HIDE, };
+ public final static String[] INVALID_PREFIXES = { PREFIX_MODIFY, PREFIX_CLEAR, PREFIX_DISABLE, PREFIX_VALIDATE, PREFIX_VALIDATE_ADD_TO, PREFIX_VALIDATE_REMOVE_FROM, PREFIX_HIDE, };
- public final static String[] PROPERTY_PREFIXES = { PREFIX_GET, PREFIX_SET, PREFIX_MODIFY, PREFIX_CLEAR,
- PREFIX_DISABLE, PREFIX_VALIDATE, PREFIX_HIDE, PREFIX_DEFAULT, PREFIX_CHOICES };
- public final static String[] COLLECTION_PREFIXES = { PREFIX_GET, PREFIX_SET, PREFIX_ADD_TO, PREFIX_REMOVE_FROM,
- PREFIX_DISABLE, PREFIX_VALIDATE_ADD_TO, PREFIX_VALIDATE_REMOVE_FROM, PREFIX_HIDE, PREFIX_DEFAULT,
- PREFIX_CHOICES };
- public final static String[] ACTION_PREFIXES = { PREFIX_VALIDATE, PREFIX_DISABLE, PREFIX_HIDE, PREFIX_DEFAULT,
- PREFIX_CHOICES, };
+ public final static String[] PROPERTY_PREFIXES = { PREFIX_GET, PREFIX_SET, PREFIX_MODIFY, PREFIX_CLEAR, PREFIX_DISABLE, PREFIX_VALIDATE, PREFIX_HIDE, PREFIX_DEFAULT, PREFIX_CHOICES };
+ public final static String[] COLLECTION_PREFIXES = { PREFIX_GET, PREFIX_SET, PREFIX_ADD_TO, PREFIX_REMOVE_FROM, PREFIX_DISABLE, PREFIX_VALIDATE_ADD_TO, PREFIX_VALIDATE_REMOVE_FROM, PREFIX_HIDE, PREFIX_DEFAULT, PREFIX_CHOICES };
+ public final static String[] ACTION_PREFIXES = { PREFIX_VALIDATE, PREFIX_DISABLE, PREFIX_HIDE, PREFIX_DEFAULT, PREFIX_CHOICES, };
}
Modified: incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/test/java/org/apache/isis/progmodel/wrapper/WrappedFactoryDefaultTest_wrappedObject.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/test/java/org/apache/isis/progmodel/wrapper/WrappedFactoryDefaultTest_wrappedObject.java?rev=1234457&r1=1234456&r2=1234457&view=diff
==============================================================================
--- incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/test/java/org/apache/isis/progmodel/wrapper/WrappedFactoryDefaultTest_wrappedObject.java (original)
+++ incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/test/java/org/apache/isis/progmodel/wrapper/WrappedFactoryDefaultTest_wrappedObject.java Sun Jan 22 07:38:03 2012
@@ -23,20 +23,16 @@ import static org.hamcrest.CoreMatchers.
import static org.hamcrest.CoreMatchers.notNullValue;
import static org.junit.Assert.assertThat;
-import org.apache.isis.core.commons.authentication.AuthenticationSession;
import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2;
import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2.Mode;
import org.apache.isis.progmodel.wrapper.applib.DisabledException;
import org.apache.isis.progmodel.wrapper.applib.HiddenException;
import org.apache.isis.progmodel.wrapper.applib.InvalidException;
import org.apache.isis.progmodel.wrapper.applib.WrapperFactory;
-import org.apache.isis.progmodel.wrapper.dom.claim.ClaimRepository;
-import org.apache.isis.progmodel.wrapper.dom.claim.ClaimRepositoryImpl;
import org.apache.isis.progmodel.wrapper.dom.employee.Employee;
import org.apache.isis.progmodel.wrapper.dom.employee.EmployeeRepository;
import org.apache.isis.progmodel.wrapper.dom.employee.EmployeeRepositoryImpl;
import org.apache.isis.progmodel.wrapper.metamodel.internal.WrapperFactoryDefault;
-import org.jmock.Expectations;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
@@ -46,26 +42,27 @@ public class WrappedFactoryDefaultTest_w
@Rule
public JUnitRuleMockery2 mockery = JUnitRuleMockery2.createFor(Mode.INTERFACES_ONLY);
-
+
private EmployeeRepository employeeRepository;
- //private ClaimRepository claimRepository;
-
+ // private ClaimRepository claimRepository;
+
private Employee employeeDO;
private Employee employeeWO;
private WrapperFactory wrapperFactory;
-
@Before
public void setUp() {
employeeRepository = new EmployeeRepositoryImpl();
- //claimRepository = new ClaimRepositoryImpl();
+ // claimRepository = new ClaimRepositoryImpl();
employeeDO = new Employee();
employeeDO.setName("Smith");
- employeeDO.setEmployeeRepository(employeeRepository); // would be done by the EmbeddedContext impl
-
+ employeeDO.setEmployeeRepository(employeeRepository); // would be done
+ // by the
+ // EmbeddedContext
+ // impl
wrapperFactory = new WrapperFactoryDefault();
employeeWO = wrapperFactory.wrap(employeeDO);
@@ -84,12 +81,11 @@ public class WrappedFactoryDefaultTest_w
// given
assertThat(employeeDO.getEmployeeRepository(), is(notNullValue()));
-
+
// then
assertThat(employeeWO.getEmployeeRepository(), is(notNullValue()));
}
-
@Ignore("TODO - moved from embedded runtime, need to re-enable")
@Test
public void shouldBeAbleToReadVisibleProperty() {
@@ -103,7 +99,7 @@ public class WrappedFactoryDefaultTest_w
// given
employeeDO.whetherHideName = true;
// when
- employeeWO.getName();
+ employeeWO.getName();
// then should throw exception
}
Modified: incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/test/java/org/apache/isis/progmodel/wrapper/WrappedFactoryDefaultTest_wrappedObject_transient.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/test/java/org/apache/isis/progmodel/wrapper/WrappedFactoryDefaultTest_wrappedObject_transient.java?rev=1234457&r1=1234456&r2=1234457&view=diff
==============================================================================
--- incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/test/java/org/apache/isis/progmodel/wrapper/WrappedFactoryDefaultTest_wrappedObject_transient.java (original)
+++ incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/test/java/org/apache/isis/progmodel/wrapper/WrappedFactoryDefaultTest_wrappedObject_transient.java Sun Jan 22 07:38:03 2012
@@ -22,16 +22,11 @@ package org.apache.isis.progmodel.wrappe
import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;
-import org.apache.isis.core.commons.authentication.AuthenticationSession;
import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2;
import org.apache.isis.core.testsupport.jmock.JUnitRuleMockery2.Mode;
import org.apache.isis.progmodel.wrapper.applib.DisabledException;
import org.apache.isis.progmodel.wrapper.applib.WrapperFactory;
-import org.apache.isis.progmodel.wrapper.dom.claim.ClaimRepository;
-import org.apache.isis.progmodel.wrapper.dom.claim.ClaimRepositoryImpl;
import org.apache.isis.progmodel.wrapper.dom.employee.Employee;
-import org.apache.isis.progmodel.wrapper.dom.employee.EmployeeRepository;
-import org.apache.isis.progmodel.wrapper.dom.employee.EmployeeRepositoryImpl;
import org.apache.isis.progmodel.wrapper.metamodel.internal.WrapperFactoryDefault;
import org.jmock.auto.Mock;
import org.junit.Before;
@@ -45,58 +40,52 @@ public class WrappedFactoryDefaultTest_w
public final JUnitRuleMockery2 mockery = JUnitRuleMockery2.createFor(Mode.INTERFACES_ONLY);
@Mock
- //private AuthenticationSession mockAuthenticationSession;
-
- //private EmployeeRepository employeeRepository;
- //private ClaimRepository claimRepository;
-
+ // private AuthenticationSession mockAuthenticationSession;
+ // private EmployeeRepository employeeRepository;
+ // private ClaimRepository claimRepository;
private Employee employeeDO;
private Employee employeeWO;
private WrapperFactory wrapperFactory;
-
@Before
public void setUp() {
- //employeeRepository = new EmployeeRepositoryImpl();
- //claimRepository = new ClaimRepositoryImpl();
+ // employeeRepository = new EmployeeRepositoryImpl();
+ // claimRepository = new ClaimRepositoryImpl();
employeeDO = new Employee();
employeeDO.setName("Smith");
- //employeeDO.setEmployeeRepository(employeeRepository); // would be done by the EmbeddedContext impl
+ // employeeDO.setEmployeeRepository(employeeRepository); // would be
+ // done by the EmbeddedContext impl
wrapperFactory = new WrapperFactoryDefault();
employeeWO = wrapperFactory.wrap(employeeDO);
}
-
@Ignore("TODO - moved from embedded runtime, need to re-enable")
@Test(expected = DisabledException.class)
public void shouldNotBeAbleToModifyPropertyIfPersistent() {
-
+
// given
- //initializedMetaModelWhereEmployeeIs(PersistenceState.PERSISTENT);
-
+ // initializedMetaModelWhereEmployeeIs(PersistenceState.PERSISTENT);
+
// when
employeeWO.setPassword("12345678");
// then should throw exception
}
-
@Ignore("TODO - moved from embedded runtime, need to re-enable")
@Test
public void canModifyPropertyIfTransient() {
// given
- //initializedMetaModelWhereEmployeeIs(PersistenceState.TRANSIENT);
-
+ // initializedMetaModelWhereEmployeeIs(PersistenceState.TRANSIENT);
+
// when
employeeWO.setPassword("12345678");
// then be allowed
assertThat(employeeWO.getPassword(), is("12345678"));
}
-
-
}
Modified: incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/test/java/org/apache/isis/progmodel/wrapper/dom/employee/Employee.java
URL: http://svn.apache.org/viewvc/incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/test/java/org/apache/isis/progmodel/wrapper/dom/employee/Employee.java?rev=1234457&r1=1234456&r2=1234457&view=diff
==============================================================================
--- incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/test/java/org/apache/isis/progmodel/wrapper/dom/employee/Employee.java (original)
+++ incubator/isis/trunk/framework/progmodels/wrapper/wrapper-metamodel/src/test/java/org/apache/isis/progmodel/wrapper/dom/employee/Employee.java Sun Jan 22 07:38:03 2012
@@ -102,18 +102,19 @@ public class Employee extends AbstractDo
public void setApprover(final Approver approver) {
this.approver = approver;
}
+
// }}
-
// {{ injected: EmployeeRepository
private EmployeeRepository employeeRepository;
+
public EmployeeRepository getEmployeeRepository() {
return employeeRepository;
}
+
public void setEmployeeRepository(final EmployeeRepository employeeRepository) {
this.employeeRepository = employeeRepository;
}
// }}
-
}