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 2015/01/22 17:57:04 UTC
[36/50] [abbrv] isis git commit: ISIS-970: consolidating processing
into DomainObjectAnnotationFacetFactory, ActionAnnotationFF,
PropertyAnnotationFF, CollectionAnnotationFF
http://git-wip-us.apache.org/repos/asf/isis/blob/6de787ad/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/interaction/ActionInteractionFacet.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/interaction/ActionInteractionFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/interaction/ActionInteractionFacet.java
deleted file mode 100644
index 4ec66fe..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/interaction/ActionInteractionFacet.java
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.metamodel.facets.actions.interaction;
-
-import org.apache.isis.core.metamodel.facets.SingleClassValueFacet;
-import org.apache.isis.core.metamodel.interactions.DisablingInteractionAdvisor;
-import org.apache.isis.core.metamodel.interactions.HidingInteractionAdvisor;
-import org.apache.isis.core.metamodel.interactions.ValidatingInteractionAdvisor;
-
-public interface ActionInteractionFacet
- extends SingleClassValueFacet, HidingInteractionAdvisor, DisablingInteractionAdvisor, ValidatingInteractionAdvisor {
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de787ad/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/interaction/ActionInteractionFacetAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/interaction/ActionInteractionFacetAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/interaction/ActionInteractionFacetAbstract.java
deleted file mode 100644
index 230eeef..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/interaction/ActionInteractionFacetAbstract.java
+++ /dev/null
@@ -1,127 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.metamodel.facets.actions.interaction;
-
-import org.apache.isis.applib.events.UsabilityEvent;
-import org.apache.isis.applib.events.ValidityEvent;
-import org.apache.isis.applib.events.VisibilityEvent;
-import org.apache.isis.applib.services.eventbus.AbstractDomainEvent;
-import org.apache.isis.applib.services.eventbus.ActionDomainEvent;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facets.InteractionHelper;
-import org.apache.isis.core.metamodel.facets.SingleClassValueFacetAbstract;
-import org.apache.isis.core.metamodel.facets.collections.interaction.CollectionInteractionFacet;
-import org.apache.isis.core.metamodel.interactions.ActionInvocationContext;
-import org.apache.isis.core.metamodel.interactions.UsabilityContext;
-import org.apache.isis.core.metamodel.interactions.ValidityContext;
-import org.apache.isis.core.metamodel.interactions.VisibilityContext;
-import org.apache.isis.core.metamodel.runtimecontext.ServicesInjector;
-import org.apache.isis.core.metamodel.spec.SpecificationLoader;
-
-public abstract class ActionInteractionFacetAbstract
- extends SingleClassValueFacetAbstract implements ActionInteractionFacet {
-
- private final InteractionHelper interactionHelper;
-
- /**
- * Pass event from validate to executing phases.
- *
- * <p>
- * A new event is created for the hide, disable and validate phases. But when the validate completes (and if does
- * not invalidate), then the event is passed through to the executing phase using this thread-local.
- * </p>
- */
- final static ThreadLocal<ActionDomainEvent<?>> currentInteraction = new ThreadLocal<>();
-
- public ActionInteractionFacetAbstract(
- final Class<? extends ActionDomainEvent<?>> eventType,
- final FacetHolder holder,
- final ServicesInjector servicesInjector,
- final SpecificationLoader specificationLoader) {
- super(CollectionInteractionFacet.class, holder, eventType, specificationLoader);
- interactionHelper = new InteractionHelper(servicesInjector);
- }
-
- @Override
- public String hides(final VisibilityContext<? extends VisibilityEvent> ic) {
- if(!interactionHelper.hasEventBusService()) {
- return null;
- }
-
- // reset (belt-n-braces)
- currentInteraction.set(null);
-
- final ActionDomainEvent<?> event =
- interactionHelper.postEventForAction(
- eventType(), null, null, AbstractDomainEvent.Phase.HIDE,
- getIdentified(), ic.getTarget(), null);
- if (event != null && event.isHidden()) {
- return "Hidden by subscriber";
- }
- return null;
- }
-
- @Override
- public String disables(UsabilityContext<? extends UsabilityEvent> ic) {
- if(!interactionHelper.hasEventBusService()) {
- return null;
- }
-
- // reset (belt-n-braces)
- currentInteraction.set(null);
-
- final ActionDomainEvent<?> event =
- interactionHelper.postEventForAction(
- eventType(), null, null, AbstractDomainEvent.Phase.DISABLE,
- getIdentified(), ic.getTarget(), null);
- if (event != null && event.isDisabled()) {
- return event.getDisabledReason();
- }
- return null;
- }
-
- @Override
- public String invalidates(ValidityContext<? extends ValidityEvent> ic) {
- if(!interactionHelper.hasEventBusService()) {
- return null;
- }
-
- // reset (belt-n-braces)
- currentInteraction.set(null);
-
- final ActionInvocationContext aic = (ActionInvocationContext) ic;
- final ActionDomainEvent<?> event =
- interactionHelper.postEventForAction(
- eventType(), null, null, AbstractDomainEvent.Phase.VALIDATE,
- getIdentified(), ic.getTarget(), aic.getArgs());
- if (event != null && event.isInvalid()) {
- return event.getInvalidityReason();
- }
-
- // make available for next phases (executing/executed)
- currentInteraction.set(event);
- return null;
- }
-
- private Class<?> eventType() {
- return value();
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de787ad/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/interaction/ActionInteractionFacetAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/interaction/ActionInteractionFacetAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/interaction/ActionInteractionFacetAnnotation.java
deleted file mode 100644
index 779ef28..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/interaction/ActionInteractionFacetAnnotation.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.metamodel.facets.actions.interaction;
-
-import org.apache.isis.applib.services.eventbus.ActionDomainEvent;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.runtimecontext.ServicesInjector;
-import org.apache.isis.core.metamodel.spec.SpecificationLoader;
-
-public class ActionInteractionFacetAnnotation extends ActionInteractionFacetAbstract {
-
- public ActionInteractionFacetAnnotation(
- final Class<? extends ActionDomainEvent<?>> eventType,
- final ServicesInjector servicesInjector, final SpecificationLoader specificationLoader, final FacetHolder holder) {
- super(eventType, holder, servicesInjector, specificationLoader);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de787ad/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/interaction/ActionInteractionFacetDefault.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/interaction/ActionInteractionFacetDefault.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/interaction/ActionInteractionFacetDefault.java
deleted file mode 100644
index 7c42fcd..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/interaction/ActionInteractionFacetDefault.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.metamodel.facets.actions.interaction;
-
-import org.apache.isis.applib.services.eventbus.ActionDomainEvent;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.runtimecontext.ServicesInjector;
-import org.apache.isis.core.metamodel.spec.SpecificationLoader;
-
-public class ActionInteractionFacetDefault extends ActionInteractionFacetAbstract {
-
- public ActionInteractionFacetDefault(
- final Class<? extends ActionDomainEvent<?>> eventType,
- final ServicesInjector servicesInjector, final SpecificationLoader specificationLoader, final FacetHolder holder) {
- super(eventType, holder, servicesInjector, specificationLoader);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de787ad/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/interaction/ActionInvocationFacet.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/interaction/ActionInvocationFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/interaction/ActionInvocationFacet.java
deleted file mode 100644
index 029e40f..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/interaction/ActionInvocationFacet.java
+++ /dev/null
@@ -1,123 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.metamodel.facets.actions.interaction;
-
-import java.util.Arrays;
-import java.util.List;
-
-import org.apache.isis.applib.services.command.Command;
-import org.apache.isis.applib.services.command.CommandContext;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.facetapi.Facet;
-import org.apache.isis.core.metamodel.facetapi.IdentifiedHolder;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
-
-/**
- * Represents the mechanism by which the action should be invoked.
- *
- * <p>
- * In the standard Apache Isis Programming Model, corresponds to invoking the
- * actual action method itself (a <tt>public</tt> method that does not represent
- * a property, a collection or any of the supporting methods).
- */
-public interface ActionInvocationFacet extends Facet {
-
- @Deprecated
- public ObjectAdapter invoke(ObjectAdapter targetAdapter, ObjectAdapter[] argumentAdapters);
-
- public ObjectAdapter invoke(ObjectAction owningAction, ObjectAdapter targetAdapter, ObjectAdapter[] argumentAdapters);
-
- public ObjectSpecification getReturnType();
-
- public ObjectSpecification getOnType();
-
- public static class CurrentInvocation {
-
- private final Command command;
-
- private final ObjectAdapter target;
- private final IdentifiedHolder action;
- private final List<ObjectAdapter> parameters;
- private final ObjectAdapter result;
-
- public CurrentInvocation(
- final ObjectAdapter target,
- final IdentifiedHolder action,
- final ObjectAdapter[] parameters,
- final ObjectAdapter result,
- final Command command) {
- this(target, action, Arrays.asList(parameters), result, command);
- }
-
- public CurrentInvocation(
- final ObjectAdapter target,
- final IdentifiedHolder action,
- final List<ObjectAdapter> parameters,
- final ObjectAdapter result,
- final Command command) {
- this.target = target;
- this.action = action;
- this.parameters = parameters;
- this.result = result;
- this.command = command;
- }
-
- /**
- * deprecated since part of {@link #getCommand()}
- */
- @Deprecated
- public ObjectAdapter getTarget() {
- return target;
- }
- /**
- * deprecated since part of {@link #getCommand()}
- */
- @Deprecated
- public IdentifiedHolder getAction() {
- return action;
- }
-
- public List<ObjectAdapter> getParameters() {
- return parameters;
- }
-
- /**
- * deprecated since part of {@link #getCommand()}
- */
- @Deprecated
- public ObjectAdapter getResult() {
- return result;
- }
-
- public Command getCommand() {
- return command;
- }
- }
-
- /**
- * TODO...
- * @deprecated - should instead use the {@link CommandContext} request.
- */
- @Deprecated
- public static ThreadLocal<CurrentInvocation> currentInvocation = new ThreadLocal<CurrentInvocation>();
-
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de787ad/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/interaction/ActionInvocationFacetAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/interaction/ActionInvocationFacetAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/interaction/ActionInvocationFacetAbstract.java
deleted file mode 100644
index abec77d..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/interaction/ActionInvocationFacetAbstract.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.metamodel.facets.actions.interaction;
-
-import org.apache.isis.core.metamodel.facetapi.Facet;
-import org.apache.isis.core.metamodel.facetapi.FacetAbstract;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-
-public abstract class ActionInvocationFacetAbstract
- extends FacetAbstract
- implements ActionInvocationFacet {
-
- public static Class<? extends Facet> type() {
- return ActionInvocationFacet.class;
- }
-
- public ActionInvocationFacetAbstract(final FacetHolder holder) {
- super(type(), holder, Derivation.NOT_DERIVED);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de787ad/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/interaction/ActionInvocationFacetForActionInteractionAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/interaction/ActionInvocationFacetForActionInteractionAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/interaction/ActionInvocationFacetForActionInteractionAnnotation.java
deleted file mode 100644
index 452b468..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/interaction/ActionInvocationFacetForActionInteractionAnnotation.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.metamodel.facets.actions.interaction;
-
-import java.lang.reflect.Method;
-import org.apache.isis.applib.services.eventbus.ActionDomainEvent;
-import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.runtimecontext.RuntimeContext;
-import org.apache.isis.core.metamodel.runtimecontext.ServicesInjector;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-
-public class ActionInvocationFacetForActionInteractionAnnotation
- extends ActionInvocationFacetForInteractionAbstract {
-
- public ActionInvocationFacetForActionInteractionAnnotation(
- final Class<? extends ActionDomainEvent<?>> eventType, final Method method,
- final ObjectSpecification onType,
- final ObjectSpecification returnType,
- final ActionInteractionFacetAbstract actionInteractionFacet,
- final FacetHolder holder,
- final RuntimeContext runtimeContext,
- final AdapterManager adapterManager,
- final ServicesInjector servicesInjector) {
- super(eventType, method, onType, returnType, actionInteractionFacet, holder, runtimeContext, adapterManager, servicesInjector);
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de787ad/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/interaction/ActionInvocationFacetForActionInteractionDefault.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/interaction/ActionInvocationFacetForActionInteractionDefault.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/interaction/ActionInvocationFacetForActionInteractionDefault.java
deleted file mode 100644
index fdd99f5..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/interaction/ActionInvocationFacetForActionInteractionDefault.java
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.metamodel.facets.actions.interaction;
-
-import java.lang.reflect.Method;
-import org.apache.isis.applib.services.eventbus.ActionDomainEvent;
-import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.runtimecontext.RuntimeContext;
-import org.apache.isis.core.metamodel.runtimecontext.ServicesInjector;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-
-public class ActionInvocationFacetForActionInteractionDefault
- extends ActionInvocationFacetForInteractionAbstract {
-
- public ActionInvocationFacetForActionInteractionDefault(
- final Class<? extends ActionDomainEvent<?>> eventType, final Method method,
- final ObjectSpecification onType,
- final ObjectSpecification returnType,
- final ActionInteractionFacetAbstract actionInteractionFacet,
- final FacetHolder holder,
- final RuntimeContext runtimeContext,
- final AdapterManager adapterManager,
- final ServicesInjector servicesInjector) {
- super(eventType, method, onType, returnType, actionInteractionFacet, holder, runtimeContext, adapterManager, servicesInjector);
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de787ad/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/interaction/ActionInvocationFacetForInteractionAbstract.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/interaction/ActionInvocationFacetForInteractionAbstract.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/interaction/ActionInvocationFacetForInteractionAbstract.java
deleted file mode 100644
index 1fdcf19..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/interaction/ActionInvocationFacetForInteractionAbstract.java
+++ /dev/null
@@ -1,435 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.metamodel.facets.actions.interaction;
-
-import java.lang.reflect.InvocationTargetException;
-import java.lang.reflect.Method;
-import java.util.Collections;
-import java.util.List;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.apache.isis.applib.NonRecoverableException;
-import org.apache.isis.applib.RecoverableException;
-import org.apache.isis.applib.ViewModel;
-import org.apache.isis.applib.annotation.Bulk;
-import org.apache.isis.applib.annotation.InvokedOn;
-import org.apache.isis.applib.clock.Clock;
-import org.apache.isis.applib.services.actinvoc.ActionInvocationContext;
-import org.apache.isis.applib.services.background.ActionInvocationMemento;
-import org.apache.isis.applib.services.background.BackgroundService;
-import org.apache.isis.applib.services.bookmark.Bookmark;
-import org.apache.isis.applib.services.command.Command;
-import org.apache.isis.applib.services.command.CommandContext;
-import org.apache.isis.applib.services.command.spi.CommandService;
-import org.apache.isis.applib.services.eventbus.AbstractDomainEvent;
-import org.apache.isis.applib.services.eventbus.ActionDomainEvent;
-import org.apache.isis.core.commons.exceptions.IsisException;
-import org.apache.isis.core.commons.lang.ThrowableExtensions;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facets.ImperativeFacet;
-import org.apache.isis.core.metamodel.facets.InteractionHelper;
-import org.apache.isis.core.metamodel.facets.actcoll.typeof.ElementSpecificationProviderFromTypeOfFacet;
-import org.apache.isis.core.metamodel.facets.actcoll.typeof.TypeOfFacet;
-import org.apache.isis.core.metamodel.facets.actions.bulk.BulkFacet;
-import org.apache.isis.core.metamodel.facets.actions.command.CommandFacet;
-import org.apache.isis.core.metamodel.facets.actions.publish.PublishedActionFacet;
-import org.apache.isis.core.metamodel.facets.object.viewmodel.ViewModelFacet;
-import org.apache.isis.core.metamodel.runtimecontext.RuntimeContext;
-import org.apache.isis.core.metamodel.runtimecontext.ServicesInjector;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
-import org.apache.isis.core.metamodel.specloader.ReflectiveActionException;
-
-public abstract class ActionInvocationFacetForInteractionAbstract
- extends ActionInvocationFacetAbstract
- implements ImperativeFacet {
-
- private final static Logger LOG = LoggerFactory.getLogger(ActionInvocationFacetForInteractionAbstract.class);
-
- private final Method method;
- private final ObjectSpecification onType;
- private final ObjectSpecification returnType;
-
- private final AdapterManager adapterManager;
- private final ActionInteractionFacetAbstract actionInteractionFacet;
- private final RuntimeContext runtimeContext;
-
- private final ServicesInjector servicesInjector;
- final Class<? extends ActionDomainEvent<?>> eventType;
- private final InteractionHelper interactionHelper;
-
- public ActionInvocationFacetForInteractionAbstract(
- final Class<? extends ActionDomainEvent<?>> eventType,
- final Method method,
- final ObjectSpecification onType,
- final ObjectSpecification returnType,
- final ActionInteractionFacetAbstract actionInteractionFacet,
- final FacetHolder holder,
- final RuntimeContext runtimeContext,
- final AdapterManager adapterManager,
- final ServicesInjector servicesInjector) {
- super(holder);
- this.eventType = eventType;
- this.method = method;
- this.onType = onType;
- this.returnType = returnType;
- this.actionInteractionFacet = actionInteractionFacet;
- this.runtimeContext = runtimeContext;
- this.adapterManager = adapterManager;
- this.servicesInjector = servicesInjector;
- this.interactionHelper = new InteractionHelper(servicesInjector);
- }
-
- /**
- * Returns a singleton list of the {@link java.lang.reflect.Method} provided in the
- * constructor.
- */
- @Override
- public List<Method> getMethods() {
- return Collections.singletonList(method);
- }
-
- @Override
- public Intent getIntent(final Method method) {
- return Intent.EXECUTE;
- }
-
- @Override
- public ObjectSpecification getReturnType() {
- return returnType;
- }
-
- @Override
- public ObjectSpecification getOnType() {
- return onType;
- }
-
- /**
- * Introduced to disambiguate the meaning of <tt>null</tt> as a return value of
- * {@link #invoke(org.apache.isis.core.metamodel.adapter.ObjectAdapter, org.apache.isis.core.metamodel.adapter.ObjectAdapter[])}
- */
- public static class InvocationResult {
-
- public static InvocationResult forActionThatReturned(final ObjectAdapter resultAdapter) {
- return new InvocationResult(true, resultAdapter);
- }
-
- public static InvocationResult forActionNotInvoked() {
- return new InvocationResult(false, null);
- }
-
- private final boolean whetherInvoked;
- private final ObjectAdapter adapter;
-
- private InvocationResult(final boolean whetherInvoked, final ObjectAdapter result) {
- this.whetherInvoked = whetherInvoked;
- this.adapter = result;
- }
-
- public boolean getWhetherInvoked() {
- return whetherInvoked;
- }
-
- /**
- * Returns the result, or null if either the action invocation returned null or
- * if the action was never invoked in the first place.
- *
- * <p>
- * Use {@link #getWhetherInvoked()} to distinguish between these two cases.
- */
- public ObjectAdapter getAdapter() {
- return adapter;
- }
- }
-
- @Override
- public ObjectAdapter invoke(final ObjectAdapter targetAdapter, final ObjectAdapter[] argumentAdapters) {
- return invoke(null, targetAdapter, argumentAdapters);
- }
-
- @Override
- public ObjectAdapter invoke(
- final ObjectAction owningAction,
- final ObjectAdapter targetAdapter,
- final ObjectAdapter[] arguments) {
-
- try {
-
- final CommandContext commandContext = getServicesInjector().lookupService(CommandContext.class);
- final Command command = commandContext != null ? commandContext.getCommand() : null;
-
- // pick up existing event (saved in thread local during the validation phase)
- final ActionDomainEvent<?> existingEvent = actionInteractionFacet.currentInteraction.get();
-
- // ... post the executing event
- final ActionDomainEvent<?> event =
- interactionHelper.postEventForAction(
- eventType, existingEvent, command, AbstractDomainEvent.Phase.EXECUTING,
- owningAction, targetAdapter, arguments);
-
- // ... invoke the action
- final InvocationResult invocationResult = internalInvoke(command, owningAction, targetAdapter, arguments);
-
- // ... post the executed event
- if (invocationResult.getWhetherInvoked()) {
- // perhaps the Action was not properly invoked (i.e. an exception was raised).
- // If invoked, then send the ActionInteractionEvent to the EventBus.
- interactionHelper.postEventForAction(
- eventType, verify(event), command, AbstractDomainEvent.Phase.EXECUTED,
- owningAction, targetAdapter, arguments);
- }
-
- return invocationResult.getAdapter();
-
- } finally {
-
- // clean up event on thread
-
- // note that if the action invoked some other action via a wrapper then this will already have been cleared
- // out. That isn't a problem; we only need to pass the event from validate to pre-execute, not to formally
- // "nest" the events.
- actionInteractionFacet.currentInteraction.set(null);
- }
- }
-
- /**
- * Optional hook to allow the facet implementation for the deprecated {@link org.apache.isis.applib.annotation.PostsActionInvokedEvent} annotation
- * to discard the event if of a different type.
- */
- protected ActionDomainEvent<?> verify(ActionDomainEvent<?> event) {
- return event;
- }
-
- protected InvocationResult internalInvoke(
- final Command command,
- final ObjectAction owningAction,
- final ObjectAdapter targetAdapter,
- final ObjectAdapter[] arguments) {
-
-
- try {
- final Object[] executionParameters = new Object[arguments.length];
- for (int i = 0; i < arguments.length; i++) {
- executionParameters[i] = unwrap(arguments[i]);
- }
-
- final Object targetPojo = unwrap(targetAdapter);
-
- final BulkFacet bulkFacet = getFacetHolder().getFacet(BulkFacet.class);
- if (bulkFacet != null) {
- final ActionInvocationContext actionInvocationContext = getServicesInjector().lookupService(ActionInvocationContext.class);
- if (actionInvocationContext != null &&
- actionInvocationContext.getInvokedOn() == null) {
-
- actionInvocationContext.setInvokedOn(InvokedOn.OBJECT);
- actionInvocationContext.setDomainObjects(Collections.singletonList(targetPojo));
- }
-
- final Bulk.InteractionContext bulkInteractionContext = getServicesInjector().lookupService(Bulk.InteractionContext.class);
-
- if (bulkInteractionContext != null &&
- bulkInteractionContext.getInvokedAs() == null) {
-
- bulkInteractionContext.setInvokedAs(Bulk.InteractionContext.InvokedAs.REGULAR);
- actionInvocationContext.setDomainObjects(Collections.singletonList(targetPojo));
- }
-
-
- }
-
- if(command != null && command.getExecutor() == Command.Executor.USER && owningAction != null) {
-
- if(command.getTarget() != null) {
- // already set up by a ObjectActionContributee;
- // don't overwrite
- } else {
- command.setTargetClass(CommandUtil.targetClassNameFor(targetAdapter));
- command.setTargetAction(CommandUtil.targetActionNameFor(owningAction));
- command.setArguments(CommandUtil.argDescriptionFor(owningAction, arguments));
-
- final Bookmark targetBookmark = CommandUtil.bookmarkFor(targetAdapter);
- command.setTarget(targetBookmark);
- }
-
- command.setMemberIdentifier(CommandUtil.actionIdentifierFor(owningAction));
-
- // the background service is used here merely as a means to capture an invocation memento
- final BackgroundService backgroundService = getServicesInjector().lookupService(BackgroundService.class);
- if(backgroundService != null) {
- final Object targetObject = unwrap(targetAdapter);
- final Object[] args = CommandUtil.objectsFor(arguments);
- ActionInvocationMemento aim = backgroundService.asActionInvocationMemento(method, targetObject, args);
-
- if(aim != null) {
- command.setMemento(aim.asMementoString());
- } else {
- throw new IsisException(
- "Unable to build memento for action " +
- owningAction.getIdentifier().toClassAndNameIdentityString());
- }
- }
-
- // copy over the command execution 'context' (if available)
- final CommandFacet commandFacet = getFacetHolder().getFacet(CommandFacet.class);
- if(commandFacet != null && !commandFacet.isDisabled()) {
- command.setExecuteIn(commandFacet.executeIn());
- command.setPersistence(commandFacet.persistence());
- } else {
- // if no facet, assume do want to execute right now, but only persist (eventually) if hinted.
- command.setExecuteIn(org.apache.isis.applib.annotation.Command.ExecuteIn.FOREGROUND);
- command.setPersistence(org.apache.isis.applib.annotation.Command.Persistence.IF_HINTED);
- }
- }
-
-
- if( command != null &&
- command.getExecutor() == Command.Executor.USER &&
- command.getExecuteIn() == org.apache.isis.applib.annotation.Command.ExecuteIn.BACKGROUND) {
-
- // persist command so can be this command can be in the 'background'
- final CommandService commandService = getServicesInjector().lookupService(CommandService.class);
- if(commandService.persistIfPossible(command)) {
- // force persistence, then return the command itself.
- final ObjectAdapter resultAdapter = getAdapterManager().adapterFor(command);
- return InvocationResult.forActionThatReturned(resultAdapter);
- } else {
- throw new IsisException(
- "Unable to schedule action '"
- + owningAction.getIdentifier().toClassAndNameIdentityString() + "' to run in background: "
- + "CommandService does not support persistent commands " );
- }
- } else {
-
- // otherwise, go ahead and execute action in the 'foreground'
-
- if(command != null) {
- command.setStartedAt(Clock.getTimeAsJavaSqlTimestamp());
- }
-
- Object result = method.invoke(targetPojo, executionParameters);
-
- if (LOG.isDebugEnabled()) {
- LOG.debug(" action result " + result);
- }
- if (result == null) {
- if(targetAdapter.getSpecification().isViewModelCloneable(targetAdapter)) {
- // if this was a void method on a ViewModel.Cloneable, then (to save boilerplate in the domain)
- // automatically do the clone and return the clone instead.
- final ViewModel.Cloneable cloneable = (ViewModel.Cloneable) targetAdapter.getObject();
- final Object clone = cloneable.clone();
- final ObjectAdapter clonedAdapter = getAdapterManager().adapterFor(clone);
- return InvocationResult.forActionThatReturned(clonedAdapter);
- }
- return InvocationResult.forActionThatReturned(null);
- }
-
- ObjectAdapter resultAdapter = getAdapterManager().adapterFor(result);
-
- if(resultAdapter.getSpecification().isViewModelCloneable(resultAdapter)) {
- // if the object returned is a ViewModel.Cloneable, then
- // (to save boilerplate in the domain) automatically do the clone.
- final ViewModel.Cloneable cloneable = (ViewModel.Cloneable) result;
- result = cloneable.clone();
- resultAdapter = getAdapterManager().adapterFor(result);
- }
-
-
- // copy over TypeOfFacet if required
- final TypeOfFacet typeOfFacet = getFacetHolder().getFacet(TypeOfFacet.class);
- resultAdapter.setElementSpecificationProvider(ElementSpecificationProviderFromTypeOfFacet.createFrom(typeOfFacet));
-
- if(command != null) {
- if(!resultAdapter.getSpecification().containsDoOpFacet(ViewModelFacet.class)) {
- final Bookmark bookmark = CommandUtil.bookmarkFor(resultAdapter);
- command.setResult(bookmark);
- }
- }
-
- final PublishedActionFacet publishedActionFacet = getIdentified().getFacet(PublishedActionFacet.class);
- ActionInvocationFacet.currentInvocation.set(
- publishedActionFacet != null
- ? new CurrentInvocation(targetAdapter, getIdentified(), arguments, resultAdapter, command)
- :null);
-
- return InvocationResult.forActionThatReturned(resultAdapter);
- }
-
- } catch (final IllegalArgumentException e) {
- throw e;
- } catch (final InvocationTargetException e) {
- final Throwable targetException = e.getTargetException();
- if (targetException instanceof IllegalStateException) {
- throw new ReflectiveActionException("IllegalStateException thrown while executing " + method + " " + targetException.getMessage(), targetException);
- }
- if(targetException instanceof RecoverableException) {
- if (!runtimeContext.getTransactionState().canCommit()) {
- // something severe has happened to the underlying transaction;
- // so escalate this exception to be non-recoverable
- final Throwable targetExceptionCause = targetException.getCause();
- Throwable nonRecoverableCause = targetExceptionCause != null? targetExceptionCause: targetException;
- throw new NonRecoverableException(nonRecoverableCause);
- }
- }
-
- ThrowableExtensions.throwWithinIsisException(e, "Exception executing " + method);
-
- // Action was not invoked (an Exception was thrown)
- return InvocationResult.forActionNotInvoked();
- } catch (final IllegalAccessException e) {
- throw new ReflectiveActionException("Illegal access of " + method, e);
- }
- }
-
-
-
- private static Object unwrap(final ObjectAdapter adapter) {
- return adapter == null ? null : adapter.getObject();
- }
-
- @Override
- public boolean impliesResolve() {
- return true;
- }
-
- @Override
- public boolean impliesObjectChanged() {
- return false;
- }
-
- @Override
- protected String toStringValues() {
- return "method=" + method;
- }
-
-
- // /////////////////////////////////////////////////////////
- // Dependencies (from constructor)
- // /////////////////////////////////////////////////////////
-
- private AdapterManager getAdapterManager() {
- return adapterManager;
- }
-
- private ServicesInjector getServicesInjector() {
- return servicesInjector;
- }
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de787ad/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/interaction/ActionInvocationFacetForPostsActionInvokedEventAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/interaction/ActionInvocationFacetForPostsActionInvokedEventAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/interaction/ActionInvocationFacetForPostsActionInvokedEventAnnotation.java
deleted file mode 100644
index 0ed6994..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/interaction/ActionInvocationFacetForPostsActionInvokedEventAnnotation.java
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.metamodel.facets.actions.interaction;
-
-import java.lang.reflect.Method;
-import org.apache.isis.applib.services.eventbus.ActionDomainEvent;
-import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.runtimecontext.RuntimeContext;
-import org.apache.isis.core.metamodel.runtimecontext.ServicesInjector;
-import org.apache.isis.core.metamodel.spec.ObjectSpecification;
-
-public class ActionInvocationFacetForPostsActionInvokedEventAnnotation
- extends ActionInvocationFacetForInteractionAbstract {
-
- public ActionInvocationFacetForPostsActionInvokedEventAnnotation(
- final Class<? extends ActionDomainEvent<?>> eventType,
- final Method method,
- final ObjectSpecification onType,
- final ObjectSpecification returnType,
- final ActionInteractionFacetAbstract actionInteractionFacet,
- final FacetHolder holder,
- final RuntimeContext runtimeContext,
- final AdapterManager adapterManager,
- final ServicesInjector servicesInjector) {
- super(eventType, method, onType, returnType, actionInteractionFacet, holder, runtimeContext, adapterManager, servicesInjector);
- }
-
- @Override
- protected ActionDomainEvent<?> verify(final ActionDomainEvent<?> event) {
- // will discard event if different type to that specified in the PostsActionInvokedEvent annotation.
- return event != null && eventType == event.getClass() ? event : null;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de787ad/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/interaction/ActionNamedDebugExplorationFacetFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/interaction/ActionNamedDebugExplorationFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/interaction/ActionNamedDebugExplorationFacetFactory.java
index ed092f3..6eda353 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/interaction/ActionNamedDebugExplorationFacetFactory.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/interaction/ActionNamedDebugExplorationFacetFactory.java
@@ -21,7 +21,6 @@ package org.apache.isis.core.metamodel.facets.actions.interaction;
import java.lang.reflect.Method;
import org.apache.isis.core.commons.lang.StringExtensions;
-import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
import org.apache.isis.core.metamodel.facetapi.FacetHolder;
import org.apache.isis.core.metamodel.facetapi.FacetUtil;
import org.apache.isis.core.metamodel.facetapi.FeatureType;
@@ -30,11 +29,9 @@ import org.apache.isis.core.metamodel.facets.actions.debug.DebugFacet;
import org.apache.isis.core.metamodel.facets.actions.exploration.ExplorationFacet;
import org.apache.isis.core.metamodel.facets.all.named.NamedFacet;
import org.apache.isis.core.metamodel.facets.all.named.NamedFacetInferred;
-import org.apache.isis.core.metamodel.runtimecontext.RuntimeContext;
-import org.apache.isis.core.metamodel.runtimecontext.ServicesInjector;
/**
- * Sets up {@link ActionInteractionFacet} and also an {@link ActionInvocationFacet}, along with a number of supporting
+ * Sets up {@link org.apache.isis.core.metamodel.facets.actions.action.invocation.ActionDomainEventFacet} and also an {@link org.apache.isis.core.metamodel.facets.actions.action.invocation.ActionInvocationFacet}, along with a number of supporting
* facets that are based on the action's name.
*
* <p>
http://git-wip-us.apache.org/repos/asf/isis/blob/6de787ad/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/interaction/CommandUtil.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/interaction/CommandUtil.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/interaction/CommandUtil.java
deleted file mode 100644
index 14d50b6..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/interaction/CommandUtil.java
+++ /dev/null
@@ -1,120 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.metamodel.facets.actions.interaction;
-
-import java.lang.reflect.Method;
-import java.util.Arrays;
-import java.util.List;
-
-import com.google.common.collect.Iterables;
-import com.google.common.collect.Lists;
-
-import org.apache.isis.applib.services.bookmark.Bookmark;
-import org.apache.isis.applib.services.bookmark.BookmarkService;
-import org.apache.isis.applib.services.memento.MementoService;
-import org.apache.isis.core.commons.lang.StringExtensions;
-import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
-import org.apache.isis.core.metamodel.adapter.mgr.AdapterManager;
-import org.apache.isis.core.metamodel.adapter.oid.Oid;
-import org.apache.isis.core.metamodel.adapter.oid.RootOid;
-import org.apache.isis.core.metamodel.spec.feature.ObjectAction;
-import org.apache.isis.core.metamodel.spec.feature.ObjectActionParameter;
-
-
-/**
- * Factoring out the commonality between <tt>ActionInvocationFacetViaMethod</tt> and <tt>BackgroundServiceDefault</tt>.
- */
-public class CommandUtil {
-
- private CommandUtil(){}
-
- public static String targetActionNameFor(ObjectAction owningAction) {
- return owningAction.getName();
- }
-
- public static String targetClassNameFor(ObjectAdapter targetAdapter) {
- return StringExtensions.asNaturalName2(targetAdapter.getSpecification().getSingularName());
- }
-
- public static String actionIdentifierFor(ObjectAction owningAction) {
- return owningAction.getIdentifier().toClassAndNameIdentityString();
- }
-
- public static String argDescriptionFor(ObjectAction owningAction, ObjectAdapter[] arguments) {
- final StringBuilder argsBuf = new StringBuilder();
- List<ObjectActionParameter> parameters = owningAction.getParameters();
- if(parameters.size() == arguments.length) {
- // should be the case
- int i=0;
- for (ObjectActionParameter param : parameters) {
- CommandUtil.appendParamArg(argsBuf, param, arguments[i++]);
- }
- }
- String argsStr = argsBuf.toString();
- return argsStr;
- }
-
- public static Bookmark bookmarkFor(final ObjectAdapter adapter) {
- final Oid oid = adapter.getOid();
- if(!(oid instanceof RootOid)) {
- return null;
- }
- final RootOid rootOid = (RootOid) oid;
- return rootOid.asBookmark();
- }
-
- static void appendParamArg(final StringBuilder buf, ObjectActionParameter param, ObjectAdapter objectAdapter) {
- String titleOf = objectAdapter != null? objectAdapter.titleString(null): "null";
- buf.append(param.getName()).append(": ").append(titleOf).append("\n");
- }
-
- public static void buildMementoArgLists(MementoService mementoService, BookmarkService bookmarkService, final Method method, final Object[] args, final List<Class<?>> argTypes, final List<Object> argObjs) {
- for (int i = 0; i < args.length; i++) {
- Object input = args[i];
- if (mementoService.canSet(input)) {
- argTypes.add(method.getParameterTypes()[i]);
- argObjs.add(input);
- } else {
- Bookmark argBookmark = bookmarkService.bookmarkFor(input);
- argTypes.add(Bookmark.class);
- argObjs.add(argBookmark);
- }
- }
- }
-
-
- public static ObjectAdapter[] adaptersFor(final Object[] args, final AdapterManager adapterManager) {
- List<Object> argList = Arrays.asList(args);
- Iterable<ObjectAdapter> adapterList =
- Iterables.transform(
- argList, ObjectAdapter.Functions.adapterForUsing(adapterManager));
- return Lists.newArrayList(adapterList).toArray(new ObjectAdapter[]{});
- }
-
- public static Object[] objectsFor(ObjectAdapter[] arguments) {
- List<ObjectAdapter> argList = Arrays.asList(arguments);
- Iterable<Object> adapterList =
- Iterables.transform(
- argList, ObjectAdapter.Functions.getObject());
- return Lists.newArrayList(adapterList).toArray(new Object[]{});
- }
-
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de787ad/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/publish/annotation/PublishedActionFacetAnnotationFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/publish/annotation/PublishedActionFacetAnnotationFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/publish/annotation/PublishedActionFacetAnnotationFactory.java
deleted file mode 100644
index a0df302..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/publish/annotation/PublishedActionFacetAnnotationFactory.java
+++ /dev/null
@@ -1,42 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.metamodel.facets.actions.publish.annotation;
-
-import org.apache.isis.core.metamodel.facetapi.FeatureType;
-import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract;
-
-public class PublishedActionFacetAnnotationFactory extends FacetFactoryAbstract {
-
- public PublishedActionFacetAnnotationFactory() {
- super(FeatureType.ACTIONS_ONLY);
- }
-
- @Override
- public void process(final ProcessMethodContext processMethodContext) {
-
- //
- // moved to ActionAnnotationFacetFactory
- //
-
- }
-
-
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de787ad/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/typeof/annotation/TypeOfFacetForActionAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/typeof/annotation/TypeOfFacetForActionAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/typeof/annotation/TypeOfFacetForActionAnnotation.java
deleted file mode 100644
index 0b8e561..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/typeof/annotation/TypeOfFacetForActionAnnotation.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.metamodel.facets.actions.typeof.annotation;
-
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facets.actcoll.typeof.TypeOfFacetAbstract;
-import org.apache.isis.core.metamodel.spec.SpecificationLoader;
-
-public class TypeOfFacetForActionAnnotation extends TypeOfFacetAbstract {
-
- public TypeOfFacetForActionAnnotation(
- final Class<?> type,
- final SpecificationLoader specificationLookup,
- final FacetHolder holder) {
- super(type, holder, specificationLookup);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de787ad/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/typeof/annotation/TypeOfFacetOnActionAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/typeof/annotation/TypeOfFacetOnActionAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/typeof/annotation/TypeOfFacetOnActionAnnotation.java
deleted file mode 100644
index bb6a460..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/typeof/annotation/TypeOfFacetOnActionAnnotation.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.metamodel.facets.actions.typeof.annotation;
-
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facets.actcoll.typeof.TypeOfFacetAbstract;
-import org.apache.isis.core.metamodel.spec.SpecificationLoader;
-
-public class TypeOfFacetOnActionAnnotation extends TypeOfFacetAbstract {
-
- public TypeOfFacetOnActionAnnotation(
- final Class<?> type,
- final SpecificationLoader specificationLookup,
- final FacetHolder holder) {
- super(type, holder, specificationLookup);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de787ad/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/typeof/annotation/TypeOfFacetOnActionAnnotationFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/typeof/annotation/TypeOfFacetOnActionAnnotationFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/typeof/annotation/TypeOfFacetOnActionAnnotationFactory.java
deleted file mode 100644
index edc75f1..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/typeof/annotation/TypeOfFacetOnActionAnnotationFactory.java
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.metamodel.facets.actions.typeof.annotation;
-
-import org.apache.isis.core.metamodel.facetapi.FeatureType;
-import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract;
-import org.apache.isis.core.metamodel.specloader.collectiontyperegistry.CollectionTypeRegistry;
-
-public class TypeOfFacetOnActionAnnotationFactory extends FacetFactoryAbstract {
-
-
- public TypeOfFacetOnActionAnnotationFactory() {
- super(FeatureType.ACTIONS_ONLY);
- }
-
- @Override
- public void process(final ProcessMethodContext processMethodContext) {
-
-
- }
-
-}
http://git-wip-us.apache.org/repos/asf/isis/blob/6de787ad/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/validate/ActionValidationFacet.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/validate/ActionValidationFacet.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/validate/ActionValidationFacet.java
index a715cc4..083ac54 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/validate/ActionValidationFacet.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/actions/validate/ActionValidationFacet.java
@@ -21,7 +21,7 @@ package org.apache.isis.core.metamodel.facets.actions.validate;
import org.apache.isis.core.metamodel.adapter.ObjectAdapter;
import org.apache.isis.core.metamodel.facetapi.Facet;
-import org.apache.isis.core.metamodel.facets.actions.interaction.ActionInvocationFacet;
+import org.apache.isis.core.metamodel.facets.actions.action.invocation.ActionInvocationFacet;
import org.apache.isis.core.metamodel.interactions.ValidatingInteractionAdvisor;
/**
http://git-wip-us.apache.org/repos/asf/isis/blob/6de787ad/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/CollectionAnnotationFacetFactory.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/CollectionAnnotationFacetFactory.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/CollectionAnnotationFacetFactory.java
index 6fc2577..fe038e0 100644
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/CollectionAnnotationFacetFactory.java
+++ b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/CollectionAnnotationFacetFactory.java
@@ -20,16 +20,54 @@
package org.apache.isis.core.metamodel.facets.collections.collection;
import java.lang.reflect.Method;
+import java.lang.reflect.ParameterizedType;
+import java.lang.reflect.Type;
+import java.lang.reflect.TypeVariable;
import org.apache.isis.applib.annotation.Collection;
+import org.apache.isis.applib.annotation.CollectionInteraction;
+import org.apache.isis.applib.annotation.PostsCollectionAddedToEvent;
+import org.apache.isis.applib.annotation.PostsCollectionRemovedFromEvent;
+import org.apache.isis.applib.annotation.TypeOf;
+import org.apache.isis.applib.services.eventbus.CollectionDomainEvent;
import org.apache.isis.core.metamodel.facetapi.FacetHolder;
import org.apache.isis.core.metamodel.facetapi.FacetUtil;
import org.apache.isis.core.metamodel.facetapi.FeatureType;
import org.apache.isis.core.metamodel.facets.Annotations;
+import org.apache.isis.core.metamodel.facets.ContributeeMemberFacetFactory;
import org.apache.isis.core.metamodel.facets.FacetFactoryAbstract;
+import org.apache.isis.core.metamodel.facets.FacetedMethod;
+import org.apache.isis.core.metamodel.facets.actcoll.typeof.TypeOfFacet;
+import org.apache.isis.core.metamodel.facets.actcoll.typeof.TypeOfFacetInferredFromArray;
+import org.apache.isis.core.metamodel.facets.actcoll.typeof.TypeOfFacetInferredFromGenerics;
+import org.apache.isis.core.metamodel.facets.collections.collection.disabled.DisabledFacetForCollectionAnnotation;
+import org.apache.isis.core.metamodel.facets.collections.collection.modify.CollectionAddToFacetForDomainEventFromAbstract;
+import org.apache.isis.core.metamodel.facets.collections.collection.modify.CollectionAddToFacetForDomainEventFromCollectionAnnotation;
+import org.apache.isis.core.metamodel.facets.collections.collection.modify.CollectionAddToFacetForDomainEventFromCollectionInteractionAnnotation;
+import org.apache.isis.core.metamodel.facets.collections.collection.modify.CollectionAddToFacetForDomainEventFromDefault;
+import org.apache.isis.core.metamodel.facets.collections.collection.modify.CollectionAddToFacetForPostsCollectionAddedToEventAnnotation;
+import org.apache.isis.core.metamodel.facets.collections.collection.modify.CollectionDomainEventFacetAbstract;
+import org.apache.isis.core.metamodel.facets.collections.collection.modify.CollectionDomainEventFacetDefault;
+import org.apache.isis.core.metamodel.facets.collections.collection.modify.CollectionDomainEventFacetForCollectionAnnotation;
+import org.apache.isis.core.metamodel.facets.collections.collection.modify.CollectionDomainEventFacetForCollectionInteractionAnnotation;
+import org.apache.isis.core.metamodel.facets.collections.collection.modify.CollectionRemoveFromFacetForDomainEventFromAbstract;
+import org.apache.isis.core.metamodel.facets.collections.collection.modify.CollectionRemoveFromFacetForDomainEventFromCollectionAnnotation;
+import org.apache.isis.core.metamodel.facets.collections.collection.modify.CollectionRemoveFromFacetForDomainEventFromCollectionInteractionAnnotation;
+import org.apache.isis.core.metamodel.facets.collections.collection.modify.CollectionRemoveFromFacetForDomainEventFromDefault;
+import org.apache.isis.core.metamodel.facets.collections.collection.modify.CollectionRemoveFromFacetForPostsCollectionRemovedFromEventAnnotation;
+import org.apache.isis.core.metamodel.facets.collections.collection.hidden.HiddenFacetForCollectionAnnotation;
+import org.apache.isis.core.metamodel.facets.collections.collection.typeof.TypeOfFacetOnCollectionFromCollectionAnnotation;
+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.collections.collection.typeof.TypeOfFacetOnCollectionFromTypeOfAnnotation;
+import org.apache.isis.core.metamodel.facets.propcoll.accessor.PropertyOrCollectionAccessorFacet;
import org.apache.isis.core.metamodel.runtimecontext.ServicesInjector;
import org.apache.isis.core.metamodel.runtimecontext.ServicesInjectorAware;
+import org.apache.isis.core.metamodel.spec.feature.ObjectMember;
+import org.apache.isis.core.metamodel.specloader.collectiontyperegistry.CollectionTypeRegistry;
-public class CollectionAnnotationFacetFactory extends FacetFactoryAbstract implements ServicesInjectorAware {
+public class CollectionAnnotationFacetFactory extends FacetFactoryAbstract implements ServicesInjectorAware, ContributeeMemberFacetFactory {
+
+ private final CollectionTypeRegistry collectionTypeRegistry = new CollectionTypeRegistry();
private ServicesInjector servicesInjector;
@@ -40,20 +78,119 @@ public class CollectionAnnotationFacetFactory extends FacetFactoryAbstract imple
@Override
public void process(final ProcessMethodContext processMethodContext) {
- processInteraction(processMethodContext);
+ processModify(processMethodContext);
processHidden(processMethodContext);
processEditing(processMethodContext);
processTypeOf(processMethodContext);
}
- private void processInteraction(final ProcessMethodContext processMethodContext) {
+ void processModify(final ProcessMethodContext processMethodContext) {
+
+ final Method method = processMethodContext.getMethod();
+ final FacetHolder holder = processMethodContext.getFacetHolder();
+
+ final PropertyOrCollectionAccessorFacet getterFacet = holder.getFacet(PropertyOrCollectionAccessorFacet.class);
+ if(getterFacet == null) {
+ return;
+ }
+
+ //
+ // Set up CollectionDomainEventFacet, which will act as the hiding/disabling/validating advisor
+ //
+ final Collection collection = Annotations.getAnnotation(method, Collection.class);
+ final CollectionInteraction collectionInteraction = Annotations.getAnnotation(method, CollectionInteraction.class);
+ final Class<? extends CollectionDomainEvent<?, ?>> collectionDomainEventType;
+
+ final CollectionDomainEventFacetAbstract collectionDomainEventFacet;
+
+ // search for @PropertyInteraction(value=...)
+ if(collectionInteraction != null) {
+ collectionDomainEventType = collectionInteraction.value();
+ collectionDomainEventFacet = new CollectionDomainEventFacetForCollectionInteractionAnnotation(
+ collectionDomainEventType, servicesInjector, getSpecificationLoader(), holder);
+ } else
+ // search for @Property(domainEvent=...)
+ if(collection != null && collection.domainEvent() != null) {
+ collectionDomainEventType = collection.domainEvent();
+ collectionDomainEventFacet = new CollectionDomainEventFacetForCollectionAnnotation(
+ collectionDomainEventType, servicesInjector, getSpecificationLoader(), holder);
+
+ } else
+ // else use default event type
+ {
+ collectionDomainEventType = CollectionDomainEvent.Default.class;
+ collectionDomainEventFacet = new CollectionDomainEventFacetDefault(
+ collectionDomainEventType, servicesInjector, getSpecificationLoader(), holder);
+ }
+ FacetUtil.addFacet(collectionDomainEventFacet);
+
- // interaction is handled by CollectionInteractionFacetFactory, because the
- // deprecated annotations must also be supported.
+ //
+ // if the collection is mutable, then replace the existing addTo and removeFrom facets with equivalents that
+ // also post to the event bus.
+ //
+ // here we support the deprecated annotations
+ //
+ final PostsCollectionAddedToEvent postsCollectionAddedToEvent = Annotations.getAnnotation(method, PostsCollectionAddedToEvent.class);
+ final PostsCollectionRemovedFromEvent postsCollectionRemovedFromEvent = Annotations.getAnnotation(method, PostsCollectionRemovedFromEvent.class);
+
+ final CollectionAddToFacet collectionAddToFacet = holder.getFacet(CollectionAddToFacet.class);
+ if (collectionAddToFacet != null) {
+ // the current collectionAddToFacet will end up as the underlying facet of
+ // one of these facets to be created.
+ final CollectionAddToFacetForDomainEventFromAbstract replacementFacet;
+
+ // deprecated
+ if (postsCollectionAddedToEvent != null) {
+ replacementFacet = new CollectionAddToFacetForPostsCollectionAddedToEventAnnotation(
+ postsCollectionAddedToEvent.value(), getterFacet, collectionAddToFacet, collectionDomainEventFacet, holder, servicesInjector);
+ } else
+ // deprecated (but more recently)
+ if(collectionInteraction != null) {
+ replacementFacet = new CollectionAddToFacetForDomainEventFromCollectionInteractionAnnotation(
+ collectionDomainEventType, getterFacet, collectionAddToFacet, collectionDomainEventFacet, holder, servicesInjector);
+ } else
+ // current
+ if(collection != null) {
+ replacementFacet = new CollectionAddToFacetForDomainEventFromCollectionAnnotation(
+ collectionDomainEventType, getterFacet, collectionAddToFacet, collectionDomainEventFacet, holder, servicesInjector);
+ } else
+ // default
+ {
+ replacementFacet = new CollectionAddToFacetForDomainEventFromDefault(
+ collectionDomainEventType, getterFacet, collectionAddToFacet, collectionDomainEventFacet, holder, servicesInjector);
+ }
+ FacetUtil.addFacet(replacementFacet);
+ }
+
+ final CollectionRemoveFromFacet collectionRemoveFromFacet = holder.getFacet(CollectionRemoveFromFacet.class);
+ if (collectionRemoveFromFacet != null) {
+ // the current collectionRemoveFromFacet will end up as the underlying facet of the PostsCollectionRemovedFromEventFacetAnnotation
+
+ final CollectionRemoveFromFacetForDomainEventFromAbstract replacementFacet;
+
+ // deprecated
+ if (postsCollectionRemovedFromEvent != null) {
+ replacementFacet = new CollectionRemoveFromFacetForPostsCollectionRemovedFromEventAnnotation(postsCollectionRemovedFromEvent.value(), getterFacet, collectionRemoveFromFacet, collectionDomainEventFacet, servicesInjector, holder);
+ } else
+ // deprecated (but more recently)
+ if(collectionInteraction != null) {
+ replacementFacet = new CollectionRemoveFromFacetForDomainEventFromCollectionInteractionAnnotation(collectionDomainEventType, getterFacet, collectionRemoveFromFacet, collectionDomainEventFacet, servicesInjector, holder);
+ } else
+ // current
+ if(collection != null) {
+ replacementFacet = new CollectionRemoveFromFacetForDomainEventFromCollectionAnnotation(collectionDomainEventType, getterFacet, collectionRemoveFromFacet, collectionDomainEventFacet, servicesInjector, holder);
+ } else
+ // default
+ {
+ replacementFacet = new CollectionRemoveFromFacetForDomainEventFromDefault(collectionDomainEventType, getterFacet, collectionRemoveFromFacet, collectionDomainEventFacet, servicesInjector, holder);
+ }
+ FacetUtil.addFacet(replacementFacet);
+ }
}
- private void processHidden(final ProcessMethodContext processMethodContext) {
+ void processHidden(final ProcessMethodContext processMethodContext) {
final Method method = processMethodContext.getMethod();
final Collection collection = Annotations.getAnnotation(method, Collection.class);
final FacetHolder holder = processMethodContext.getFacetHolder();
@@ -62,7 +199,7 @@ public class CollectionAnnotationFacetFactory extends FacetFactoryAbstract imple
HiddenFacetForCollectionAnnotation.create(collection, holder));
}
- private void processEditing(final ProcessMethodContext processMethodContext) {
+ void processEditing(final ProcessMethodContext processMethodContext) {
final Method method = processMethodContext.getMethod();
final Collection collection = Annotations.getAnnotation(method, Collection.class);
final FacetHolder holder = processMethodContext.getFacetHolder();
@@ -71,12 +208,91 @@ public class CollectionAnnotationFacetFactory extends FacetFactoryAbstract imple
DisabledFacetForCollectionAnnotation.create(collection, holder));
}
- private void processTypeOf(final ProcessMethodContext processMethodContext) {
+ void processTypeOf(final ProcessMethodContext processMethodContext) {
+
+ final FacetedMethod facetHolder = processMethodContext.getFacetHolder();
+ final Method method = processMethodContext.getMethod();
+
+ final Class<?> methodReturnType = method.getReturnType();
+ if (!collectionTypeRegistry.isCollectionType(methodReturnType) && !collectionTypeRegistry.isArrayType(methodReturnType)) {
+ return;
+ }
+
+ TypeOfFacet facet;
+
+ // check for deprecated @TypeOf
+ final TypeOf annotation = Annotations.getAnnotation(method, TypeOf.class);
+ facet = TypeOfFacetOnCollectionFromTypeOfAnnotation.create(annotation, facetHolder, getSpecificationLoader());
- // typeOf is handled by TypeOfFacetOnCollectionAnnotationFactory, because the
- // deprecated annotations etc that must also be supported.
+ // check for @Collection(typeOf=...)
+ if(facet == null) {
+ final Collection collection = Annotations.getAnnotation(method, Collection.class);
+ facet = TypeOfFacetOnCollectionFromCollectionAnnotation.create(collection, facetHolder, getSpecificationLoader());
+ }
+
+ // infer from return type
+ if(facet == null) {
+ final Class<?> returnType = method.getReturnType();
+ if (returnType.isArray()) {
+ final Class<?> componentType = returnType.getComponentType();
+ facet = new TypeOfFacetInferredFromArray(componentType, facetHolder, getSpecificationLoader());
+ }
+ }
+
+ // infer from generic return type
+ if(facet == null) {
+ facet = inferFromGenericReturnType(processMethodContext);
+ }
+
+
+ FacetUtil.addFacet(facet);
+ }
+
+ private TypeOfFacet inferFromGenericReturnType(final ProcessMethodContext processMethodContext) {
+
+ final FacetedMethod facetHolder = processMethodContext.getFacetHolder();
+ final Method method = processMethodContext.getMethod();
+
+ final Type type = method.getGenericReturnType();
+ if (!(type instanceof ParameterizedType)) {
+ return null;
+ }
+
+ final ParameterizedType parameterizedType = (ParameterizedType) type;
+ final Type[] actualTypeArguments = parameterizedType.getActualTypeArguments();
+ if (actualTypeArguments.length == 0) {
+ return null;
+ }
+
+ final Object actualTypeArgument = actualTypeArguments[0];
+ if (actualTypeArgument instanceof Class) {
+ final Class<?> actualType = (Class<?>) actualTypeArgument;
+ return new TypeOfFacetInferredFromGenerics(actualType, facetHolder, getSpecificationLoader());
+ }
+
+ if (actualTypeArgument instanceof TypeVariable) {
+
+ // TODO: what to do here?
+ return null;
+ }
+
+ return null;
}
+ @Override
+ public void process(ContributeeMemberFacetFactory.ProcessContributeeMemberContext processMemberContext) {
+
+ final ObjectMember objectMember = processMemberContext.getFacetHolder();
+
+ //
+ // an enhancement would be to pick up a custom event, however the contributed collection ultimately maps
+ // to an action on a service, and would therefore require a @Collection(...) annotated on an action;
+ // would look rather odd
+ //
+
+ FacetUtil.addFacet(new CollectionDomainEventFacetDefault(CollectionDomainEvent.Default.class, servicesInjector, getSpecificationLoader(), objectMember));
+
+ }
@Override
public void setServicesInjector(final ServicesInjector servicesInjector) {
http://git-wip-us.apache.org/repos/asf/isis/blob/6de787ad/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/CollectionInteractionFacetForCollectionAnnotation.java
----------------------------------------------------------------------
diff --git a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/CollectionInteractionFacetForCollectionAnnotation.java b/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/CollectionInteractionFacetForCollectionAnnotation.java
deleted file mode 100644
index b634c25..0000000
--- a/core/metamodel/src/main/java/org/apache/isis/core/metamodel/facets/collections/collection/CollectionInteractionFacetForCollectionAnnotation.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-
-package org.apache.isis.core.metamodel.facets.collections.collection;
-
-import org.apache.isis.applib.annotation.Collection;
-import org.apache.isis.applib.services.eventbus.CollectionDomainEvent;
-import org.apache.isis.core.metamodel.facetapi.FacetHolder;
-import org.apache.isis.core.metamodel.facets.collections.interaction.CollectionInteractionFacet;
-import org.apache.isis.core.metamodel.facets.collections.interaction.CollectionInteractionFacetAbstract;
-import org.apache.isis.core.metamodel.runtimecontext.ServicesInjector;
-import org.apache.isis.core.metamodel.spec.SpecificationLoader;
-
-public class CollectionInteractionFacetForCollectionAnnotation extends CollectionInteractionFacetAbstract {
-
- static CollectionInteractionFacet create(
- final Collection collection,
- final ServicesInjector servicesInjector,
- final SpecificationLoader specificationLoader,
- final FacetHolder holder) {
- Class<? extends CollectionDomainEvent<?, ?>> collectionInteractionEventType = collection.domainEvent();
- return new CollectionInteractionFacetForCollectionAnnotation(
- collectionInteractionEventType, servicesInjector, specificationLoader, holder);
- }
-
- public CollectionInteractionFacetForCollectionAnnotation(
- final Class<? extends CollectionDomainEvent<?, ?>> eventType,
- final ServicesInjector servicesInjector, final SpecificationLoader specificationLoader, final FacetHolder holder) {
- super(eventType, holder, servicesInjector, specificationLoader);
- }
-
-}