You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@deltaspike.apache.org by gp...@apache.org on 2013/01/02 11:19:18 UTC
git commit: DELTASPIKE-288 improved ConfigDescriptor
Updated Branches:
refs/heads/master 880ff8336 -> 9d4e719ae
DELTASPIKE-288 improved ConfigDescriptor
Project: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/commit/9d4e719a
Tree: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/tree/9d4e719a
Diff: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/diff/9d4e719a
Branch: refs/heads/master
Commit: 9d4e719aef5048194aa2b90c6173a524e1cb73e6
Parents: 880ff83
Author: gpetracek <gp...@apache.org>
Authored: Wed Jan 2 11:16:49 2013 +0100
Committer: gpetracek <gp...@apache.org>
Committed: Wed Jan 2 11:16:49 2013 +0100
----------------------------------------------------------------------
.../config/view/metadata/CallbackDescriptor.java | 48 +++-------
.../api/config/view/metadata/ConfigDescriptor.java | 49 ++++------
.../metadata/ExecutableCallbackDescriptor.java | 71 +++++++++++++++
.../view/metadata/SimpleCallbackDescriptor.java | 44 +++++++++
.../jsf/api/config/view/controller/PageBean.java | 8 +-
.../config/view/AbstractPathConfigDescriptor.java | 30 ++++++-
.../config/view/controller/uc004/TestSecured.java | 8 ++-
.../view/controller/uc004/ViewConfigTest.java | 6 +-
.../api/authorization/annotation/Secured.java | 19 +++--
9 files changed, 200 insertions(+), 83 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/9d4e719a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/view/metadata/CallbackDescriptor.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/view/metadata/CallbackDescriptor.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/view/metadata/CallbackDescriptor.java
index 0b6f8af..dd500ff 100644
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/view/metadata/CallbackDescriptor.java
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/view/metadata/CallbackDescriptor.java
@@ -20,7 +20,6 @@ package org.apache.deltaspike.core.api.config.view.metadata;
import org.apache.deltaspike.core.api.config.view.metadata.annotation.DefaultCallback;
import org.apache.deltaspike.core.api.provider.BeanProvider;
-import org.apache.deltaspike.core.util.ExceptionUtils;
import java.lang.annotation.Annotation;
import java.lang.reflect.Method;
@@ -30,12 +29,10 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
-//TODO bean-names
-//TODO callback which allows to validate the method signature (during the descriptor creation)
-public abstract class CallbackDescriptor<R>
+public abstract class CallbackDescriptor
{
- private List<CallbackEntry> callbacks = new ArrayList<CallbackEntry>();
- private Class<? extends Annotation> callbackType;
+ protected List<CallbackEntry> callbacks = new ArrayList<CallbackEntry>();
+ protected Class<? extends Annotation> callbackType;
protected CallbackDescriptor(Class beanClass, Class<? extends Annotation> callbackMarker)
{
@@ -67,33 +64,6 @@ public abstract class CallbackDescriptor<R>
}
}
- //TODO discuss if we should keep it here
- public List<R> execute(Object... optionalParams)
- {
- List<R> results = new ArrayList<R>();
- for (CallbackEntry callbackEntry : this.callbacks)
- {
- for (Method callbackMethod : callbackEntry.callbackMethods)
- {
- try
- {
- Object bean = getTargetObject(callbackEntry.targetBeanClass);
- R result = (R) callbackMethod.invoke(bean, optionalParams);
-
- if (result != null)
- {
- results.add(result);
- }
- }
- catch (Exception e)
- {
- ExceptionUtils.throwAsRuntimeException(e);
- }
- }
- }
- return results;
- }
-
public Map<Class, List<Method>> getCallbackMethods()
{
Map<Class, List<Method>> result = new HashMap<Class, List<Method>>(this.callbacks.size());
@@ -115,7 +85,7 @@ public abstract class CallbackDescriptor<R>
return this.callbackType.equals(callbackType);
}
- private static class CallbackEntry
+ protected static class CallbackEntry
{
private List<Method> callbackMethods = new ArrayList<Method>();
private final Class targetBeanClass;
@@ -171,5 +141,15 @@ public abstract class CallbackDescriptor<R>
currentClass = currentClass.getSuperclass();
}
}
+
+ public List<Method> getCallbackMethods()
+ {
+ return callbackMethods;
+ }
+
+ public Class getTargetBeanClass()
+ {
+ return targetBeanClass;
+ }
}
}
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/9d4e719a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/view/metadata/ConfigDescriptor.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/view/metadata/ConfigDescriptor.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/view/metadata/ConfigDescriptor.java
index 1acef53..d91b726 100644
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/view/metadata/ConfigDescriptor.java
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/view/metadata/ConfigDescriptor.java
@@ -46,50 +46,39 @@ public interface ConfigDescriptor
*/
<T extends Annotation> List<T> getMetaData(Class<T> target);
- //TODO discuss parameter meta-data-type (needed to use @DefaultCallback)
- //for using only CallbackDescriptor getCallbackDescriptor(Class<? extends Annotation> callbackType)
- //we would have to drop the support to re-use callback annotations for
- //different meta-data-types (e.g. @DefaultCallback)
-
- /*TODO discuss the usage - e.g.:
- CallbackDescriptor preRenderView =
- viewConfigDescriptor.getCallbackDescriptor(PageBean.class, PreRenderView.class);
+ /**
+ * Callbacks which are configured for the entry and bound to the given meta-data type.
+ * @param metaDataType type of the meta-data (e.g. PageBean.class)
+ * @return descriptor for the callback or null if there is no callback-method
+ */
+ CallbackDescriptor getCallbackDescriptor(Class<? extends Annotation> metaDataType);
- if (preRenderView != null)
- {
- preRenderView.execute();
- }
- */
/**
* Callbacks which are configured for the entry and bound to the given meta-data type.
* @param metaDataType type of the meta-data (e.g. PageBean.class)
* @param callbackType type of the callback (e.g. PreRenderView.class)
- * @return descriptor for the callback which also allows to invoke it or null if there is no callback-method
+ * @return descriptor for the callback null if there is no callback-method
*/
CallbackDescriptor getCallbackDescriptor(Class<? extends Annotation> metaDataType,
Class<? extends Annotation> callbackType);
- /*TODO discuss the usage - e.g.:
- CallbackDescriptor secured =
- viewConfigDescriptor.getCallbackDescriptor(Secured.class, DefaultCallback.class, Secured.SecuredDescriptor.class);
-
- if (secured != null)
- {
- List<Set<SecurityViolation>> callbackResult = secured.execute(accessDecisionVoterContext);
- }
+ /**
+ * Callbacks which are configured for the entry and bound to the given meta-data type.
+ * @param metaDataType type of the meta-data (e.g. PageBean.class)
+ * @param executorType type of the executor which allows to get a typed result (e.g. Secured.SecuredDescriptor)
+ * @return descriptor for the callback which also allows to invoke it or null if there is no callback-method
+ */
+ <T extends ExecutableCallbackDescriptor> T getExecutableCallbackDescriptor(Class<? extends Annotation> metaDataType,
+ Class<? extends T> executorType);
- List ... because there can be 1-n callbacks (in case of @Secured 1-n AccessDecisionVoter/s
- Set<SecurityViolation> ... return type specified by the callback method
- */
/**
* Callbacks which are configured for the entry and bound to the given meta-data type.
* @param metaDataType type of the meta-data (e.g. PageBean.class)
* @param callbackType type of the callback (e.g. PreRenderView.class)
- * @param executorType type of the executor which allows to get a typed result (e.g. Secured.SecuredDescriptor
+ * @param executorType type of the executor which allows to get a typed result (e.g. Secured.SecuredDescriptor)
* @return descriptor for the callback which also allows to invoke it or null if there is no callback-method
*/
- //only needed if the result is needed e.g. in case of @Secured
- <T extends CallbackDescriptor> T getCallbackDescriptor(Class<? extends Annotation> metaDataType,
- Class<? extends Annotation> callbackType,
- Class<? extends T> executorType);
+ <T extends ExecutableCallbackDescriptor> T getExecutableCallbackDescriptor(Class<? extends Annotation> metaDataType,
+ Class<? extends Annotation> callbackType,
+ Class<? extends T> executorType);
}
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/9d4e719a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/view/metadata/ExecutableCallbackDescriptor.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/view/metadata/ExecutableCallbackDescriptor.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/view/metadata/ExecutableCallbackDescriptor.java
new file mode 100644
index 0000000..ff20b0b
--- /dev/null
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/view/metadata/ExecutableCallbackDescriptor.java
@@ -0,0 +1,71 @@
+/*
+ * 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.api.config.view.metadata;
+
+import org.apache.deltaspike.core.util.ExceptionUtils;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Method;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * Provides {@link #execute} only for concrete descriptors, but doesn't expose it (-> can't get used by accident).
+ * Concrete implementations can provide type-safe versions of it, but delegate the final execution to {@link #execute}.
+ *
+ * @param <R> return type
+ */
+public abstract class ExecutableCallbackDescriptor<R> extends CallbackDescriptor
+{
+ protected ExecutableCallbackDescriptor(Class beanClass, Class<? extends Annotation> callbackMarker)
+ {
+ super(beanClass, callbackMarker);
+ }
+
+ protected ExecutableCallbackDescriptor(Class[] beanClasses, Class<? extends Annotation> callbackMarker)
+ {
+ super(beanClasses, callbackMarker);
+ }
+
+ protected List<R> execute(Object... parameters)
+ {
+ List<R> results = new ArrayList<R>();
+ for (CallbackEntry callbackEntry : this.callbacks)
+ {
+ for (Method callbackMethod : callbackEntry.getCallbackMethods())
+ {
+ try
+ {
+ Object bean = getTargetObject(callbackEntry.getTargetBeanClass());
+ R result = (R) callbackMethod.invoke(bean, parameters);
+
+ if (result != null)
+ {
+ results.add(result);
+ }
+ }
+ catch (Exception e)
+ {
+ ExceptionUtils.throwAsRuntimeException(e);
+ }
+ }
+ }
+ return results;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/9d4e719a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/view/metadata/SimpleCallbackDescriptor.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/view/metadata/SimpleCallbackDescriptor.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/view/metadata/SimpleCallbackDescriptor.java
new file mode 100644
index 0000000..c4787b2
--- /dev/null
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/view/metadata/SimpleCallbackDescriptor.java
@@ -0,0 +1,44 @@
+/*
+ * 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.api.config.view.metadata;
+
+import java.lang.annotation.Annotation;
+import java.util.List;
+
+/**
+ * For callback-methods without (supported) parameters
+ * @param <R> return type
+ */
+public abstract class SimpleCallbackDescriptor<R> extends ExecutableCallbackDescriptor<R>
+{
+ protected SimpleCallbackDescriptor(Class beanClass, Class<? extends Annotation> callbackMarker)
+ {
+ super(beanClass, callbackMarker);
+ }
+
+ protected SimpleCallbackDescriptor(Class[] beanClasses, Class<? extends Annotation> callbackMarker)
+ {
+ super(beanClasses, callbackMarker);
+ }
+
+ public List<R> execute()
+ {
+ return super.execute();
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/9d4e719a/deltaspike/modules/jsf/api/src/main/java/org/apache/deltaspike/jsf/api/config/view/controller/PageBean.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/api/src/main/java/org/apache/deltaspike/jsf/api/config/view/controller/PageBean.java b/deltaspike/modules/jsf/api/src/main/java/org/apache/deltaspike/jsf/api/config/view/controller/PageBean.java
index b902a3b..3a0562e 100644
--- a/deltaspike/modules/jsf/api/src/main/java/org/apache/deltaspike/jsf/api/config/view/controller/PageBean.java
+++ b/deltaspike/modules/jsf/api/src/main/java/org/apache/deltaspike/jsf/api/config/view/controller/PageBean.java
@@ -23,8 +23,8 @@ package org.apache.deltaspike.jsf.api.config.view.controller;
* Such page beans support e.g. the view-controller annotations.
*/
+import org.apache.deltaspike.core.api.config.view.metadata.SimpleCallbackDescriptor;
import org.apache.deltaspike.core.api.config.view.metadata.annotation.ViewMetaData;
-import org.apache.deltaspike.core.api.config.view.metadata.CallbackDescriptor;
import org.apache.deltaspike.core.spi.config.view.ConfigPreProcessor;
import org.apache.deltaspike.core.spi.config.view.ViewConfigNode;
@@ -76,11 +76,11 @@ public @interface PageBean
}
//not needed outside
- private class ViewControllerDescriptor extends CallbackDescriptor<Void>
+ private class ViewControllerDescriptor extends SimpleCallbackDescriptor<Void>
{
- protected ViewControllerDescriptor(Class beanClass, Class<? extends Annotation> callbackMarker)
+ protected ViewControllerDescriptor(Class beanClass, Class<? extends Annotation> callbackType)
{
- super(beanClass, callbackMarker);
+ super(beanClass, callbackType);
}
}
}
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/9d4e719a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/config/view/AbstractPathConfigDescriptor.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/config/view/AbstractPathConfigDescriptor.java b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/config/view/AbstractPathConfigDescriptor.java
index 62a0eba..3993e45 100644
--- a/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/config/view/AbstractPathConfigDescriptor.java
+++ b/deltaspike/modules/jsf/impl/src/main/java/org/apache/deltaspike/jsf/impl/config/view/AbstractPathConfigDescriptor.java
@@ -18,6 +18,7 @@
*/
package org.apache.deltaspike.jsf.impl.config.view;
+import org.apache.deltaspike.core.api.config.view.metadata.ExecutableCallbackDescriptor;
import org.apache.deltaspike.core.api.config.view.metadata.annotation.DefaultCallback;
import org.apache.deltaspike.core.api.config.view.metadata.CallbackDescriptor;
import org.apache.deltaspike.core.api.config.view.metadata.ConfigDescriptor;
@@ -71,16 +72,37 @@ abstract class AbstractPathConfigDescriptor implements ConfigDescriptor
}
@Override
+ public CallbackDescriptor getCallbackDescriptor(Class<? extends Annotation> metaDataType)
+ {
+ return getCallbackDescriptor(metaDataType, DefaultCallback.class);
+ }
+
+ @Override
public CallbackDescriptor getCallbackDescriptor(Class<? extends Annotation> metaDataType,
Class<? extends Annotation> callbackType)
{
- return getCallbackDescriptor(metaDataType, callbackType, CallbackDescriptor.class);
+ return findCallbackDescriptor(metaDataType, callbackType);
}
@Override
- public <T extends CallbackDescriptor> T getCallbackDescriptor(Class<? extends Annotation> metaDataType,
- Class<? extends Annotation> callbackType,
- Class<? extends T> executorType)
+ public <T extends ExecutableCallbackDescriptor> T getExecutableCallbackDescriptor(
+ Class<? extends Annotation> metaDataType,
+ Class<? extends T> executorType)
+ {
+ return getExecutableCallbackDescriptor(metaDataType, DefaultCallback.class, executorType);
+ }
+
+ @Override
+ public <T extends ExecutableCallbackDescriptor> T getExecutableCallbackDescriptor(
+ Class<? extends Annotation> metaDataType,
+ Class<? extends Annotation> callbackType,
+ Class<? extends T> executorType)
+ {
+ return findCallbackDescriptor(metaDataType, callbackType);
+ }
+
+ private <T extends CallbackDescriptor> T findCallbackDescriptor(Class<? extends Annotation> metaDataType,
+ Class<? extends Annotation> callbackType)
{
List<CallbackDescriptor> foundDescriptors = callbackDescriptors.get(metaDataType);
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/9d4e719a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/controller/uc004/TestSecured.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/controller/uc004/TestSecured.java b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/controller/uc004/TestSecured.java
index 1ce3100..d3c9970 100644
--- a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/controller/uc004/TestSecured.java
+++ b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/controller/uc004/TestSecured.java
@@ -19,6 +19,7 @@
package org.apache.deltaspike.test.jsf.impl.config.view.controller.uc004;
import org.apache.deltaspike.core.api.config.view.metadata.CallbackDescriptor;
+import org.apache.deltaspike.core.api.config.view.metadata.ExecutableCallbackDescriptor;
import org.apache.deltaspike.core.api.config.view.metadata.annotation.DefaultCallback;
import org.apache.deltaspike.core.api.config.view.metadata.annotation.ViewMetaData;
import org.apache.deltaspike.core.spi.config.view.ConfigPreProcessor;
@@ -62,11 +63,16 @@ public @interface TestSecured
}
//can be used from outside to get a typed result
- static class TestSecuredDescriptor extends CallbackDescriptor<Set<String>>
+ static class TestSecuredDescriptor extends ExecutableCallbackDescriptor<Set<String>>
{
public TestSecuredDescriptor(Class[] beanClasses, Class<? extends Annotation> callbackMarker)
{
super(beanClasses, callbackMarker);
}
+
+ public List<Set<String>> execute(String param1, String param2)
+ {
+ return super.execute(param1, param2);
+ }
}
}
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/9d4e719a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/controller/uc004/ViewConfigTest.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/controller/uc004/ViewConfigTest.java b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/controller/uc004/ViewConfigTest.java
index 76b3d08..2abb4ea 100644
--- a/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/controller/uc004/ViewConfigTest.java
+++ b/deltaspike/modules/jsf/impl/src/test/java/org/apache/deltaspike/test/jsf/impl/config/view/controller/uc004/ViewConfigTest.java
@@ -108,7 +108,7 @@ public class ViewConfigTest
Assert.assertNotNull(viewConfigDescriptor);
Assert.assertNull(viewConfigDescriptor.getCallbackDescriptor(PageBean.class, InitView.class));
Assert.assertNotNull(viewConfigDescriptor.getCallbackDescriptor(PageBean.class, PreRenderView.class));
- Assert.assertNotNull(viewConfigDescriptor.getCallbackDescriptor(TestSecured.class, DefaultCallback.class));
+ Assert.assertNotNull(viewConfigDescriptor.getCallbackDescriptor(TestSecured.class));
}
@Test
@@ -134,9 +134,9 @@ public class ViewConfigTest
ViewConfigDescriptor viewConfigDescriptor = viewConfigResolver.getViewConfigDescriptor(SimplePageConfig.class);
Assert.assertNotNull(viewConfigDescriptor);
- Assert.assertNotNull(viewConfigDescriptor.getCallbackDescriptor(TestSecured.class, DefaultCallback.class));
+ Assert.assertNotNull(viewConfigDescriptor.getCallbackDescriptor(TestSecured.class));
List<Set<String> /*return type of one callback*/> callbackResult =
- viewConfigDescriptor.getCallbackDescriptor(TestSecured.class, DefaultCallback.class, TestSecured.TestSecuredDescriptor.class)
+ viewConfigDescriptor.getExecutableCallbackDescriptor(TestSecured.class, TestSecured.TestSecuredDescriptor.class)
.execute("param1", "param2");
Assert.assertNotNull(callbackResult);
Assert.assertEquals(1, callbackResult.size());
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/9d4e719a/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/authorization/annotation/Secured.java
----------------------------------------------------------------------
diff --git a/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/authorization/annotation/Secured.java b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/authorization/annotation/Secured.java
index 37a74db..4d2e6de 100644
--- a/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/authorization/annotation/Secured.java
+++ b/deltaspike/modules/security/api/src/main/java/org/apache/deltaspike/security/api/authorization/annotation/Secured.java
@@ -20,19 +20,20 @@ package org.apache.deltaspike.security.api.authorization.annotation;
import org.apache.deltaspike.core.api.config.view.DefaultErrorView;
import org.apache.deltaspike.core.api.config.view.ViewConfig;
+import org.apache.deltaspike.core.api.config.view.metadata.ExecutableCallbackDescriptor;
import org.apache.deltaspike.core.api.config.view.metadata.annotation.DefaultCallback;
import org.apache.deltaspike.core.api.config.view.metadata.annotation.ViewMetaData;
-import org.apache.deltaspike.core.api.config.view.metadata.CallbackDescriptor;
import org.apache.deltaspike.core.spi.config.view.ConfigPreProcessor;
import org.apache.deltaspike.core.spi.config.view.ViewConfigNode;
import org.apache.deltaspike.security.api.authorization.AccessDecisionVoter;
+import org.apache.deltaspike.security.api.authorization.AccessDecisionVoterContext;
import org.apache.deltaspike.security.api.authorization.SecurityViolation;
import javax.enterprise.util.Nonbinding;
-import java.lang.annotation.Annotation;
import java.lang.annotation.Documented;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
+import java.util.List;
import java.util.Set;
import static java.lang.annotation.ElementType.ANNOTATION_TYPE;
@@ -76,18 +77,22 @@ public @interface Secured
@Override
public Secured beforeAddToConfig(Secured metaData, ViewConfigNode viewConfigNode)
{
- viewConfigNode.registerCallbackDescriptors(Secured.class,
- new SecuredDescriptor(metaData.value(), DefaultCallback.class));
+ viewConfigNode.registerCallbackDescriptors(Secured.class, new SecuredDescriptor(metaData.value()));
return metaData; //no change needed
}
}
//can be used from outside to get a typed result
- static class SecuredDescriptor extends CallbackDescriptor<Set<SecurityViolation>>
+ static class SecuredDescriptor extends ExecutableCallbackDescriptor<Set<SecurityViolation>>
{
- public SecuredDescriptor(Class[] beanClasses, Class<? extends Annotation> callbackMarker)
+ public SecuredDescriptor(Class<? extends AccessDecisionVoter>[] accessDecisionVoterBeanClasses)
{
- super(beanClasses, callbackMarker);
+ super(accessDecisionVoterBeanClasses, DefaultCallback.class);
+ }
+
+ public List<Set<SecurityViolation>> execute(AccessDecisionVoterContext accessDecisionVoterContext)
+ {
+ return super.execute(accessDecisionVoterContext);
}
}
}