Return-Path: X-Original-To: apmail-deltaspike-commits-archive@www.apache.org Delivered-To: apmail-deltaspike-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C3B7E18664 for ; Sat, 17 Oct 2015 23:06:04 +0000 (UTC) Received: (qmail 48168 invoked by uid 500); 17 Oct 2015 23:06:04 -0000 Delivered-To: apmail-deltaspike-commits-archive@deltaspike.apache.org Received: (qmail 48130 invoked by uid 500); 17 Oct 2015 23:06:04 -0000 Mailing-List: contact commits-help@deltaspike.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@deltaspike.apache.org Delivered-To: mailing list commits@deltaspike.apache.org Received: (qmail 48121 invoked by uid 99); 17 Oct 2015 23:06:04 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 17 Oct 2015 23:06:04 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 5C8A6DFF13; Sat, 17 Oct 2015 23:06:04 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: gpetracek@apache.org To: commits@deltaspike.apache.org Date: Sat, 17 Oct 2015 23:06:04 -0000 Message-Id: X-Mailer: ASF-Git Admin Mailer Subject: [1/2] deltaspike git commit: DELTASPIKE-1004 unified base-implementation for InvocationContext Repository: deltaspike Updated Branches: refs/heads/master 7988bfc96 -> 05876253e DELTASPIKE-1004 unified base-implementation for InvocationContext Project: http://git-wip-us.apache.org/repos/asf/deltaspike/repo Commit: http://git-wip-us.apache.org/repos/asf/deltaspike/commit/51d5ac89 Tree: http://git-wip-us.apache.org/repos/asf/deltaspike/tree/51d5ac89 Diff: http://git-wip-us.apache.org/repos/asf/deltaspike/diff/51d5ac89 Branch: refs/heads/master Commit: 51d5ac8989810a848fa21eecbf688dae4491ef80 Parents: 7988bfc Author: gpetracek Authored: Sun Oct 18 00:50:19 2015 +0200 Committer: gpetracek Committed: Sun Oct 18 00:50:19 2015 +0200 ---------------------------------------------------------------------- .../core/util/AbstractInvocationContext.java | 92 ++++++++++++++++++++ .../data/impl/tx/InvocationContextWrapper.java | 57 +----------- .../invocation/ManualInvocationContext.java | 69 ++------------- 3 files changed, 102 insertions(+), 116 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/deltaspike/blob/51d5ac89/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/AbstractInvocationContext.java ---------------------------------------------------------------------- diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/AbstractInvocationContext.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/AbstractInvocationContext.java new file mode 100644 index 0000000..8c8f691 --- /dev/null +++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/AbstractInvocationContext.java @@ -0,0 +1,92 @@ +/* + * 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.deltaspike.core.util; + +import javax.enterprise.inject.Typed; +import javax.interceptor.InvocationContext; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.util.HashMap; +import java.util.Map; + +@Typed() +public abstract class AbstractInvocationContext implements InvocationContext +{ + protected final T target; + protected final Method method; + protected final Object timer; + + protected Object[] parameters; + protected Map contextData; + + protected AbstractInvocationContext(T target, Method method, Object[] parameters, Object timer) + { + this.target = target; + this.method = method; + this.parameters = parameters; + this.timer = timer; + } + + + @Override + public Object getTarget() + { + return target; + } + + @Override + public Method getMethod() + { + return method; + } + + @Override + public Object getTimer() + { + return timer; + } + + @Override + public Object[] getParameters() + { + return parameters; + } + + @Override + public void setParameters(Object[] parameters) + { + this.parameters = parameters; + } + + @Override + public Map getContextData() + { + if (contextData == null) + { + contextData = new HashMap(); + } + return contextData; + } + + // @Override - forward compatibility to interceptors API 1.2 + public Constructor getConstructor() + { + return null; + } +} http://git-wip-us.apache.org/repos/asf/deltaspike/blob/51d5ac89/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/tx/InvocationContextWrapper.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/tx/InvocationContextWrapper.java b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/tx/InvocationContextWrapper.java index 4cee509..790c57c 100644 --- a/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/tx/InvocationContextWrapper.java +++ b/deltaspike/modules/data/impl/src/main/java/org/apache/deltaspike/data/impl/tx/InvocationContextWrapper.java @@ -18,64 +18,13 @@ */ package org.apache.deltaspike.data.impl.tx; -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; -import java.util.HashMap; -import java.util.Map; - -import javax.interceptor.InvocationContext; - +import org.apache.deltaspike.core.util.AbstractInvocationContext; import org.apache.deltaspike.data.impl.handler.CdiQueryInvocationContext; -public abstract class InvocationContextWrapper implements InvocationContext +public abstract class InvocationContextWrapper extends AbstractInvocationContext { - - private final CdiQueryInvocationContext context; - public InvocationContextWrapper(CdiQueryInvocationContext context) { - this.context = context; - } - - // @Override - forward compatibility to interceptors API 1.2 - public Constructor getConstructor() - { - return null; - } - - @Override - public Map getContextData() - { - return new HashMap(0); - } - - @Override - public Method getMethod() - { - return context.getMethod(); + super(context.getProxy(), context.getMethod(), context.getMethodParameters(), null); } - - @Override - public Object[] getParameters() - { - return context.getMethodParameters(); - } - - @Override - public Object getTarget() - { - return context.getProxy(); - } - - @Override - public Object getTimer() - { - return null; - } - - @Override - public void setParameters(Object[] args) - { - } - } http://git-wip-us.apache.org/repos/asf/deltaspike/blob/51d5ac89/deltaspike/modules/proxy/impl-asm5/src/main/java/org/apache/deltaspike/proxy/impl/invocation/ManualInvocationContext.java ---------------------------------------------------------------------- diff --git a/deltaspike/modules/proxy/impl-asm5/src/main/java/org/apache/deltaspike/proxy/impl/invocation/ManualInvocationContext.java b/deltaspike/modules/proxy/impl-asm5/src/main/java/org/apache/deltaspike/proxy/impl/invocation/ManualInvocationContext.java index 30c9339..dd3c2b3 100644 --- a/deltaspike/modules/proxy/impl-asm5/src/main/java/org/apache/deltaspike/proxy/impl/invocation/ManualInvocationContext.java +++ b/deltaspike/modules/proxy/impl-asm5/src/main/java/org/apache/deltaspike/proxy/impl/invocation/ManualInvocationContext.java @@ -18,33 +18,27 @@ */ package org.apache.deltaspike.proxy.impl.invocation; -import java.lang.reflect.Constructor; import java.lang.reflect.Method; -import java.util.HashMap; import java.util.List; -import java.util.Map; import javax.enterprise.context.spi.CreationalContext; import javax.enterprise.inject.Typed; import javax.enterprise.inject.spi.BeanManager; import javax.enterprise.inject.spi.InterceptionType; import javax.enterprise.inject.spi.Interceptor; -import javax.interceptor.InvocationContext; + import org.apache.deltaspike.core.api.provider.BeanManagerProvider; +import org.apache.deltaspike.core.util.AbstractInvocationContext; /** - * {@link InvocationContext} implementation to support manual interceptor invocation before invoking the + * {@link javax.interceptor.InvocationContext} + * implementation to support manual interceptor invocation before invoking the * original logic via the given {@link AbstractManualInvocationHandler}. */ @Typed -public class ManualInvocationContext implements InvocationContext +public class ManualInvocationContext extends AbstractInvocationContext { protected List> interceptors; protected int interceptorIndex; - protected T target; - protected Method method; - protected Object[] parameters; - protected Map contextData; - protected Object timer; protected AbstractManualInvocationHandler manualInvocationHandler; protected BeanManager beanManager; @@ -55,51 +49,15 @@ public class ManualInvocationContext implements InvocationContext public ManualInvocationContext(AbstractManualInvocationHandler manualInvocationHandler, List> interceptors, T target, Method method, Object[] parameters, Object timer) { + super(target, method, parameters, timer); + this.manualInvocationHandler = manualInvocationHandler; this.interceptors = interceptors; - this.target = target; - this.method = method; - this.parameters = parameters; - this.timer = timer; this.interceptorIndex = 0; } @Override - public Object getTarget() - { - return target; - } - - @Override - public Method getMethod() - { - return method; - } - - @Override - public Object[] getParameters() - { - return parameters; - } - - @Override - public void setParameters(Object[] os) - { - parameters = os; - } - - @Override - public Map getContextData() - { - if (contextData == null) - { - contextData = new HashMap(); - } - return contextData; - } - - @Override public Object proceed() throws Exception { if (proceedOriginal) @@ -161,19 +119,6 @@ public class ManualInvocationContext implements InvocationContext return null; } - @Override - public Object getTimer() - { - return timer; - } - - // @Override - // CDI 1.1 compatibility - public Constructor getConstructor() - { - return null; - } - public boolean isProceedOriginal() { return proceedOriginal;