deltaspike-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject [1/2] deltaspike git commit: DELTASPIKE-1004 unified base-implementation for InvocationContext
Date Sat, 17 Oct 2015 23:06:04 GMT
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 <gpetracek@apache.org>
Authored: Sun Oct 18 00:50:19 2015 +0200
Committer: gpetracek <gpetracek@apache.org>
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<T> implements InvocationContext
+{
+    protected final T target;
+    protected final Method method;
+    protected final Object timer;
+
+    protected Object[] parameters;
+    protected Map<String, Object> 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<String, Object> getContextData()
+    {
+        if (contextData == null)
+        {
+            contextData = new HashMap<String, Object>();
+        }
+        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<Object>
 {
-
-    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<String, Object> getContextData()
-    {
-        return new HashMap<String, Object>(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<T, H> implements InvocationContext
+public class ManualInvocationContext<T, H> extends AbstractInvocationContext<T>
 {
     protected List<Interceptor<H>> interceptors;
     protected int interceptorIndex;
-    protected T target;
-    protected Method method;
-    protected Object[] parameters;
-    protected Map<String, Object> contextData;
-    protected Object timer;
     protected AbstractManualInvocationHandler manualInvocationHandler;
 
     protected BeanManager beanManager;
@@ -55,51 +49,15 @@ public class ManualInvocationContext<T, H> implements InvocationContext
     public ManualInvocationContext(AbstractManualInvocationHandler manualInvocationHandler,
             List<Interceptor<H>> 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<String, Object> getContextData()
-    {
-        if (contextData == null)
-        {
-            contextData = new HashMap<String, Object>();
-        }
-        return contextData;
-    }
-
-    @Override
     public Object proceed() throws Exception
     {
         if (proceedOriginal)
@@ -161,19 +119,6 @@ public class ManualInvocationContext<T, H> 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;


Mime
View raw message