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 2012/04/14 00:24:53 UTC
[1/2] git commit: DELTASPIKE-163 cleanup
Updated Branches:
refs/heads/master 29684acfe -> 1ced97b6d
DELTASPIKE-163 cleanup
including unified packages, improved javadoc
Project: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/commit/1ced97b6
Tree: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/tree/1ced97b6
Diff: http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/diff/1ced97b6
Branch: refs/heads/master
Commit: 1ced97b6dbdc27597019cd4570ea3309d0860081
Parents: 29684ac
Author: gpetracek <gp...@apache.org>
Authored: Sat Apr 14 00:07:53 2012 +0200
Committer: gpetracek <gp...@apache.org>
Committed: Sat Apr 14 00:21:13 2012 +0200
----------------------------------------------------------------------
.../deltaspike/core/api/config/ConfigResolver.java | 38 +-
.../core/api/config/DeltaSpikeConfig.java | 1 +
.../core/api/config/annotation/ConfigProperty.java | 17 +
.../deltaspike/core/api/converter/Converter.java | 6 +
.../core/api/converter/ConverterException.java | 6 +
.../core/api/converter/MetaDataAwareConverter.java | 6 +
.../core/api/exception/control/BeforeHandles.java | 44 --
.../api/exception/control/ExceptionHandler.java | 36 -
.../core/api/exception/control/Handles.java | 42 --
.../control/annotation/BeforeHandles.java | 44 ++
.../control/annotation/ExceptionHandler.java | 36 +
.../api/exception/control/annotation/Handles.java | 42 ++
.../core/api/message/annotation/MessageBundle.java | 6 +
.../message/annotation/MessageContextConfig.java | 16 +
.../api/message/annotation/MessageTemplate.java | 3 +
.../core/spi/converter/ConverterFactory.java | 3 +
.../core/util/SetAccessiblePrivilegedAction.java | 1 +
.../config/injectable/ConfigPropertyExtension.java | 115 ----
.../config/injectable/InjectionTargetEntry.java | 93 ---
.../extension/ConfigPropertyExtension.java | 116 ++++
.../injectable/extension/InjectionTargetEntry.java | 93 +++
.../control/ExceptionHandlerComparator.java | 2 +-
.../impl/exception/control/HandlerMethodImpl.java | 4 +-
.../extension/ExceptionControlExtension.java | 2 +-
.../core/impl/exclude/ExcludeExtension.java | 520 --------------
.../impl/exclude/extension/ExcludeExtension.java | 521 +++++++++++++++
.../core/impl/message/MessageBundleExtension.java | 1 +
.../services/javax.enterprise.inject.spi.Extension | 4 +-
.../test/core/api/exclude/ExcludeTest.java | 2 +-
.../impl/exception/control/event/EventTest.java | 6 +-
.../control/flow/AbortingBreadthFirstHandler.java | 6 +-
.../control/flow/AbortingDepthHandler.java | 4 +-
.../control/flow/ExceptionHandledHandler.java | 6 +-
.../control/flow/ProceedCauseHandler.java | 6 +-
.../exception/control/flow/RethrowHandler.java | 6 +-
.../exception/control/flow/ThrowingNewHandler.java | 6 +-
.../control/handler/BadInjectionPointHandler.java | 4 +-
.../control/handler/CalledExceptionHandler.java | 6 +-
.../control/handler/ExtensionExceptionHandler.java | 6 +-
.../handler/HandlerWhichThrowsExceptions.java | 4 +-
.../exception/control/handler/UnMuteHandler.java | 6 +-
.../control/traversal/ExceptionHandlerMethods.java | 6 +-
.../test.javax.enterprise.inject.spi.Extension | 4 +-
.../UnexpectedCredentialException.java | 1 +
.../authentication/event/AlreadyLoggedInEvent.java | 1 -
.../event/PostAuthenticateEvent.java | 1 -
.../authentication/event/PreAuthenticateEvent.java | 1 -
.../authorization/SecurityDefinitionException.java | 3 +-
.../annotation/SecurityParameterBinding.java | 4 +-
.../impl/authorization/SecurityExtension.java | 1 +
.../impl/authentication/LoginLogoutTest.java | 2 +-
.../secured/SecuredAnnotationTest.java | 2 +-
.../securitybinding/SecurityBindingTest.java | 2 +-
.../SecurityParameterBindingTest.java | 2 +-
54 files changed, 994 insertions(+), 922 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/1ced97b6/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/ConfigResolver.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/ConfigResolver.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/ConfigResolver.java
index 1b70d4a..b808294 100644
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/ConfigResolver.java
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/ConfigResolver.java
@@ -68,18 +68,20 @@ public final class ConfigResolver
{
ConfigSource[] appConfigSources = getConfigSources();
- for (ConfigSource cs : appConfigSources)
+ String value;
+ for (ConfigSource configSource : appConfigSources)
{
- String val = cs.getPropertyValue(key);
- if (val != null)
+ value = configSource.getPropertyValue(key);
+
+ if (value != null)
{
LOG.log(Level.FINE, "found value {0} for key {1} in ConfigSource {2}.",
- new Object[]{val, key, cs.getConfigName()});
- return val;
+ new Object[]{value, key, configSource.getConfigName()});
+ return value;
}
LOG.log(Level.FINER, "NO value found for key {0} in ConfigSource {1}.",
- new Object[]{key, cs.getConfigName()});
+ new Object[]{key, configSource.getConfigName()});
}
return null;
@@ -97,25 +99,27 @@ public final class ConfigResolver
public static List<String> getAllPropertyValues(String key)
{
List<ConfigSource> appConfigSources = sortAscending(Arrays.asList(getConfigSources()));
- List<String> allPropValues = new ArrayList<String>();
+ List<String> result = new ArrayList<String>();
- for (ConfigSource cs : appConfigSources)
+ String value;
+ for (ConfigSource configSource : appConfigSources)
{
- String val = cs.getPropertyValue(key);
- if (val != null && !allPropValues.contains(val))
+ value = configSource.getPropertyValue(key);
+
+ if (value != null && !result.contains(value))
{
- allPropValues.add(val);
+ result.add(value);
}
}
- return allPropValues;
+ return result;
}
private static synchronized ConfigSource[] getConfigSources()
{
- ClassLoader currentCl = ClassUtils.getClassLoader(null);
+ ClassLoader currentClassLoader = ClassUtils.getClassLoader(null);
- ConfigSource[] appConfigSources = configSources.get(currentCl);
+ ConfigSource[] appConfigSources = configSources.get(currentClassLoader);
if (appConfigSources == null)
{
@@ -130,7 +134,7 @@ public final class ConfigResolver
}
}
- configSources.put(currentCl, appConfigSources);
+ configSources.put(currentClassLoader, appConfigSources);
}
return appConfigSources;
@@ -143,9 +147,9 @@ public final class ConfigResolver
List<ConfigSourceProvider> configSourceProviderServiceLoader =
ServiceUtils.loadServiceImplementations(ConfigSourceProvider.class);
- for (ConfigSourceProvider csp : configSourceProviderServiceLoader)
+ for (ConfigSourceProvider configSourceProvider : configSourceProviderServiceLoader)
{
- appConfigSources.addAll(csp.getConfigSources());
+ appConfigSources.addAll(configSourceProvider.getConfigSources());
}
return appConfigSources;
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/1ced97b6/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/DeltaSpikeConfig.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/DeltaSpikeConfig.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/DeltaSpikeConfig.java
index 26686bd..76bdff1 100644
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/DeltaSpikeConfig.java
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/DeltaSpikeConfig.java
@@ -23,6 +23,7 @@ import java.io.Serializable;
/**
* Marker interface for all type-safe framework configs.
*/
+@SuppressWarnings("UnusedDeclaration")
public interface DeltaSpikeConfig extends Serializable
{
}
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/1ced97b6/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/annotation/ConfigProperty.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/annotation/ConfigProperty.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/annotation/ConfigProperty.java
index ffe2642..967841c 100644
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/annotation/ConfigProperty.java
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/config/annotation/ConfigProperty.java
@@ -40,11 +40,28 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Qualifier
public @interface ConfigProperty
{
+ /**
+ * Name/key of the property
+ * @return name of the property
+ */
String name();
+ /**
+ * Custom converter
+ * @return custom converter or default marker
+ */
@Nonbinding
Class<? extends Converter> converter() default Converter.class;
+ /**
+ * Per default all properties are validated during the bootstrapping process of the CDI container.
+ * If it can't be resolved, the bootstrapping will fail.
+ *
+ * Set it to true if the property will be set dynamically e.g. during the bootstrapping process and
+ * it will be stored in a dynamic data-store like data-base.
+ *
+ * @return true if the property has to be available from the very beginning, false otherwise
+ */
@Nonbinding
boolean eager() default true;
}
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/1ced97b6/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/converter/Converter.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/converter/Converter.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/converter/Converter.java
index 26696f9..fe15588 100644
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/converter/Converter.java
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/converter/Converter.java
@@ -18,6 +18,12 @@
*/
package org.apache.deltaspike.core.api.converter;
+/**
+ * Basic converter interface
+ *
+ * @param <S> source type which should be converted
+ * @param <T> target type
+ */
public interface Converter<S, T>
{
T convert(S source);
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/1ced97b6/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/converter/ConverterException.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/converter/ConverterException.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/converter/ConverterException.java
index 1727d64..ba7a418 100644
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/converter/ConverterException.java
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/converter/ConverterException.java
@@ -19,8 +19,14 @@
package org.apache.deltaspike.core.api.converter;
//TODO TBD
+
+/**
+ * Exception which provides the source- and target-type as payload
+ */
public class ConverterException extends RuntimeException
{
+ private static final long serialVersionUID = -1399119195483111935L;
+
private Class<?> sourceType;
private Class<?> targetType;
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/1ced97b6/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/converter/MetaDataAwareConverter.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/converter/MetaDataAwareConverter.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/converter/MetaDataAwareConverter.java
index 4032058..e7b88ab 100644
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/converter/MetaDataAwareConverter.java
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/converter/MetaDataAwareConverter.java
@@ -18,6 +18,12 @@
*/
package org.apache.deltaspike.core.api.converter;
+/**
+ * Special converter-interface which allows to provide payload for the conversion process via a custom annotation
+ * @param <S> source type which should be converted
+ * @param <T> target type
+ * @param <M> meta-data type (custom annotation)
+ */
public interface MetaDataAwareConverter<S, T, M> extends Converter<S, T>
{
T convert(S source, M metaData);
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/1ced97b6/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/exception/control/BeforeHandles.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/exception/control/BeforeHandles.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/exception/control/BeforeHandles.java
deleted file mode 100644
index 8e7078a..0000000
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/exception/control/BeforeHandles.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.deltaspike.core.api.exception.control;
-
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Marker annotation for a method to be considered an Exception Handler, handles the exception in the BEFORE
- * traversal of the exception chain. Handlers are typically in the form of
- * <code>public void ... (@BeforeHandles ... CaughtException<...> ...)</code> methods.
- * If a method has a return type, it is ignored.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.PARAMETER)
-@Documented
-public @interface BeforeHandles
-{
- /**
- * Precedence relative to callbacks for the same type
- */
- int ordinal() default 0;
-}
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/1ced97b6/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/exception/control/ExceptionHandler.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/exception/control/ExceptionHandler.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/exception/control/ExceptionHandler.java
deleted file mode 100644
index d706909..0000000
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/exception/control/ExceptionHandler.java
+++ /dev/null
@@ -1,36 +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.deltaspike.core.api.exception.control;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Marker for types containing Exception Handler methods.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.TYPE)
-@Documented
-public @interface ExceptionHandler
-{
-}
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/1ced97b6/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/exception/control/Handles.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/exception/control/Handles.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/exception/control/Handles.java
deleted file mode 100644
index 8d86160..0000000
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/exception/control/Handles.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.deltaspike.core.api.exception.control;
-
-import java.lang.annotation.Documented;
-import java.lang.annotation.ElementType;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
-import java.lang.annotation.Target;
-
-/**
- * Marker annotation for a method to be considered an Exception Handler. Handlers are typically in the form of
- * <code>public void ... (@Handles ... CaughtException<...> ...)</code> methods. If a method has a return type, it is
- * ignored.
- */
-@Retention(RetentionPolicy.RUNTIME)
-@Target(ElementType.PARAMETER)
-@Documented
-public @interface Handles
-{
- /**
- * Precedence relative to handlers for the same type
- */
- int ordinal() default 0; //TODO discuss Precedence
-}
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/1ced97b6/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/exception/control/annotation/BeforeHandles.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/exception/control/annotation/BeforeHandles.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/exception/control/annotation/BeforeHandles.java
new file mode 100644
index 0000000..33536c9
--- /dev/null
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/exception/control/annotation/BeforeHandles.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.exception.control.annotation;
+
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Marker annotation for a method to be considered an Exception Handler, handles the exception in the BEFORE
+ * traversal of the exception chain. Handlers are typically in the form of
+ * <code>public void ... (@BeforeHandles ... CaughtException<...> ...)</code> methods.
+ * If a method has a return type, it is ignored.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.PARAMETER)
+@Documented
+public @interface BeforeHandles
+{
+ /**
+ * Precedence relative to callbacks for the same type
+ */
+ int ordinal() default 0;
+}
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/1ced97b6/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/exception/control/annotation/ExceptionHandler.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/exception/control/annotation/ExceptionHandler.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/exception/control/annotation/ExceptionHandler.java
new file mode 100644
index 0000000..6b50086
--- /dev/null
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/exception/control/annotation/ExceptionHandler.java
@@ -0,0 +1,36 @@
+/*
+ * 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.exception.control.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Marker for types containing Exception Handler methods.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.TYPE)
+@Documented
+public @interface ExceptionHandler
+{
+}
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/1ced97b6/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/exception/control/annotation/Handles.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/exception/control/annotation/Handles.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/exception/control/annotation/Handles.java
new file mode 100644
index 0000000..6435ddd
--- /dev/null
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/exception/control/annotation/Handles.java
@@ -0,0 +1,42 @@
+/*
+ * 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.exception.control.annotation;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * Marker annotation for a method to be considered an Exception Handler. Handlers are typically in the form of
+ * <code>public void ... (@Handles ... CaughtException<...> ...)</code> methods. If a method has a return type, it is
+ * ignored.
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.PARAMETER)
+@Documented
+public @interface Handles
+{
+ /**
+ * Precedence relative to handlers for the same type
+ */
+ int ordinal() default 0; //TODO discuss Precedence
+}
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/1ced97b6/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/message/annotation/MessageBundle.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/message/annotation/MessageBundle.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/message/annotation/MessageBundle.java
index 90da537..bf4c463 100644
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/message/annotation/MessageBundle.java
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/message/annotation/MessageBundle.java
@@ -28,6 +28,12 @@ import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
+/**
+ * Marker annotation for a message-bundle interface which provides type-safe messages
+ * (methods annotated with {@link MessageTemplate}).
+ *
+ * Can be combined with {@link MessageContextConfig} to customize the message-resolution and processing
+ */
@Target({ TYPE, METHOD, PARAMETER, FIELD })
@Retention(RUNTIME)
@Documented
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/1ced97b6/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/message/annotation/MessageContextConfig.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/message/annotation/MessageContextConfig.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/message/annotation/MessageContextConfig.java
index d9456dc..2db4f76 100644
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/message/annotation/MessageContextConfig.java
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/message/annotation/MessageContextConfig.java
@@ -29,14 +29,30 @@ import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
+/**
+ * Allows to customize the message-resolution and processing in combination with {@link MessageBundle}
+ */
@Target({ TYPE })
@Retention(RUNTIME)
@Documented
public @interface MessageContextConfig
{
+ /**
+ * {@link MessageResolver} which should be used for resolving the message-template (= basic text)
+ * @return class of the {@link MessageResolver}-bean or the default marker
+ */
Class<? extends MessageResolver> messageResolver() default MessageResolver.class;
+ /**
+ * {@link MessageInterpolator} which should be used for replacing the placeholders in the resolved text
+ * @return class of the {@link MessageInterpolator}-bean or the default marker
+ */
Class<? extends MessageInterpolator> messageInterpolator() default MessageInterpolator.class;
+ /**
+ * {@link LocaleResolver} which should be used for providing the locale for resolving
+ * the message-template (= basic text)
+ * @return class of the {@link LocaleResolver}-bean or the default marker
+ */
Class<? extends LocaleResolver> localeResolver() default LocaleResolver.class;
}
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/1ced97b6/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/message/annotation/MessageTemplate.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/message/annotation/MessageTemplate.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/message/annotation/MessageTemplate.java
index 979d52b..a329bc3 100644
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/message/annotation/MessageTemplate.java
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/message/annotation/MessageTemplate.java
@@ -25,6 +25,9 @@ import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
+/**
+ * Provides the message(-template) for type-safe messages
+ */
@Target(METHOD)
@Retention(RUNTIME)
@Documented
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/1ced97b6/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/spi/converter/ConverterFactory.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/spi/converter/ConverterFactory.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/spi/converter/ConverterFactory.java
index 4079e9b..96ac265 100644
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/spi/converter/ConverterFactory.java
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/spi/converter/ConverterFactory.java
@@ -22,6 +22,9 @@ import org.apache.deltaspike.core.api.converter.Converter;
import java.lang.annotation.Annotation;
+/**
+ * Factory which allows to customize the creation of {@link Converter} instances
+ */
public interface ConverterFactory
{
//TODO discuss metaDataType
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/1ced97b6/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/SetAccessiblePrivilegedAction.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/SetAccessiblePrivilegedAction.java b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/SetAccessiblePrivilegedAction.java
index a344f2c..ff5c315 100644
--- a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/SetAccessiblePrivilegedAction.java
+++ b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/util/SetAccessiblePrivilegedAction.java
@@ -27,6 +27,7 @@ import java.security.PrivilegedAction;
* PrivilegedAction instance to enabling access to the specified {@link AccessibleObject}.
*/
@Typed()
+//TODO replace it with the SecurityService of OWB
public class SetAccessiblePrivilegedAction implements PrivilegedAction<Void>
{
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/1ced97b6/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/injectable/ConfigPropertyExtension.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/injectable/ConfigPropertyExtension.java b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/injectable/ConfigPropertyExtension.java
deleted file mode 100644
index edfb044..0000000
--- a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/injectable/ConfigPropertyExtension.java
+++ /dev/null
@@ -1,115 +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.deltaspike.core.impl.config.injectable;
-
-import org.apache.deltaspike.core.api.config.annotation.ConfigProperty;
-import org.apache.deltaspike.core.api.config.ConfigResolver;
-import org.apache.deltaspike.core.spi.activation.Deactivatable;
-import org.apache.deltaspike.core.util.ClassDeactivationUtils;
-
-import javax.enterprise.event.Observes;
-import javax.enterprise.inject.spi.AfterBeanDiscovery;
-import javax.enterprise.inject.spi.Extension;
-import javax.enterprise.inject.spi.InjectionPoint;
-import javax.enterprise.inject.spi.InjectionTarget;
-import javax.enterprise.inject.spi.ProcessInjectionTarget;
-import java.lang.annotation.Annotation;
-import java.util.HashSet;
-import java.util.Set;
-
-/**
- * Adds support for {@link org.apache.deltaspike.core.api.config.annotation.ConfigProperty}
- */
-public class ConfigPropertyExtension implements Extension, Deactivatable
-{
- private Boolean isActivated = null;
-
- private Set<InjectionTargetEntry> injectionTargets = new HashSet<InjectionTargetEntry>();
-
- protected void recordConfigPropertyAwareInjectionPoint(@Observes ProcessInjectionTarget event)
- {
- initActivation();
-
- if (!this.isActivated)
- {
- return;
- }
-
- InjectionTarget<?> injectionTarget = event.getInjectionTarget();
-
- ConfigProperty configProperty;
- Annotation qualifier;
- for (InjectionPoint injectionPoint : injectionTarget.getInjectionPoints())
- {
- qualifier = null;
- configProperty = injectionPoint.getAnnotated().getAnnotation(ConfigProperty.class);
-
- if (configProperty == null)
- {
- for (Annotation annotation : injectionPoint.getAnnotated().getAnnotations())
- {
- configProperty = annotation.annotationType().getAnnotation(ConfigProperty.class);
-
- if (configProperty != null)
- {
- qualifier = annotation;
- break;
- }
- }
- }
-
- if (configProperty != null)
- {
- //TODO add support for collections,...
- if (configProperty.eager() && ConfigResolver.getPropertyValue(configProperty.name()) == null)
- {
- throw new IllegalStateException("no configured value found for property: " + configProperty.name());
- }
-
- this.injectionTargets.add(
- new InjectionTargetEntry(injectionPoint.getType(), configProperty, qualifier));
- }
- }
- }
-
- @SuppressWarnings("UnusedDeclaration")
- protected void addDependentBeans(@Observes AfterBeanDiscovery event)
- {
- initActivation();
-
- if (!this.isActivated)
- {
- return;
- }
-
- for (InjectionTargetEntry injectionTargetEntry : this.injectionTargets)
- {
- event.addBean(new ConfigPropertyBean<Object>(injectionTargetEntry.getType(), injectionTargetEntry
- .getConfigProperty(), injectionTargetEntry.getCustomQualifier()));
- }
- }
-
- protected void initActivation()
- {
- if (this.isActivated == null)
- {
- this.isActivated = ClassDeactivationUtils.isActivated(getClass());
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/1ced97b6/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/injectable/InjectionTargetEntry.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/injectable/InjectionTargetEntry.java b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/injectable/InjectionTargetEntry.java
deleted file mode 100644
index 0dd9278..0000000
--- a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/injectable/InjectionTargetEntry.java
+++ /dev/null
@@ -1,93 +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.deltaspike.core.impl.config.injectable;
-
-import org.apache.deltaspike.core.api.config.annotation.ConfigProperty;
-
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Type;
-
-class InjectionTargetEntry
-{
- private final Type type;
- private final ConfigProperty configProperty;
- private final Annotation optionalCustomQualifier;
-
- InjectionTargetEntry(Type type, ConfigProperty configProperty, Annotation optionalCustomQualifier)
- {
- this.type = type;
- this.configProperty = configProperty;
- this.optionalCustomQualifier = optionalCustomQualifier;
- }
-
- Type getType()
- {
- return type;
- }
-
- ConfigProperty getConfigProperty()
- {
- return configProperty;
- }
-
- Annotation getCustomQualifier()
- {
- return optionalCustomQualifier;
- }
-
- @Override
- public boolean equals(Object o)
- {
- if (this == o)
- {
- return true;
- }
- if (o == null || getClass() != o.getClass())
- {
- return false;
- }
-
- InjectionTargetEntry that = (InjectionTargetEntry) o;
-
- if (!configProperty.equals(that.configProperty))
- {
- return false;
- }
- if (optionalCustomQualifier != null ? !optionalCustomQualifier
- .equals(that.optionalCustomQualifier) : that.optionalCustomQualifier != null)
- {
- return false;
- }
- if (!type.equals(that.type))
- {
- return false;
- }
-
- return true;
- }
-
- @Override
- public int hashCode()
- {
- int result = type.hashCode();
- result = 31 * result + configProperty.hashCode();
- result = 31 * result + (optionalCustomQualifier != null ? optionalCustomQualifier.hashCode() : 0);
- return result;
- }
-}
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/1ced97b6/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/injectable/extension/ConfigPropertyExtension.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/injectable/extension/ConfigPropertyExtension.java b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/injectable/extension/ConfigPropertyExtension.java
new file mode 100644
index 0000000..5a88804
--- /dev/null
+++ b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/injectable/extension/ConfigPropertyExtension.java
@@ -0,0 +1,116 @@
+/*
+ * 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.impl.config.injectable.extension;
+
+import org.apache.deltaspike.core.api.config.annotation.ConfigProperty;
+import org.apache.deltaspike.core.api.config.ConfigResolver;
+import org.apache.deltaspike.core.impl.config.injectable.ConfigPropertyBean;
+import org.apache.deltaspike.core.spi.activation.Deactivatable;
+import org.apache.deltaspike.core.util.ClassDeactivationUtils;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.AfterBeanDiscovery;
+import javax.enterprise.inject.spi.Extension;
+import javax.enterprise.inject.spi.InjectionPoint;
+import javax.enterprise.inject.spi.InjectionTarget;
+import javax.enterprise.inject.spi.ProcessInjectionTarget;
+import java.lang.annotation.Annotation;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * Adds support for {@link org.apache.deltaspike.core.api.config.annotation.ConfigProperty}
+ */
+public class ConfigPropertyExtension implements Extension, Deactivatable
+{
+ private Boolean isActivated = null;
+
+ private Set<InjectionTargetEntry> injectionTargets = new HashSet<InjectionTargetEntry>();
+
+ protected void recordConfigPropertyAwareInjectionPoint(@Observes ProcessInjectionTarget event)
+ {
+ initActivation();
+
+ if (!this.isActivated)
+ {
+ return;
+ }
+
+ InjectionTarget<?> injectionTarget = event.getInjectionTarget();
+
+ ConfigProperty configProperty;
+ Annotation qualifier;
+ for (InjectionPoint injectionPoint : injectionTarget.getInjectionPoints())
+ {
+ qualifier = null;
+ configProperty = injectionPoint.getAnnotated().getAnnotation(ConfigProperty.class);
+
+ if (configProperty == null)
+ {
+ for (Annotation annotation : injectionPoint.getAnnotated().getAnnotations())
+ {
+ configProperty = annotation.annotationType().getAnnotation(ConfigProperty.class);
+
+ if (configProperty != null)
+ {
+ qualifier = annotation;
+ break;
+ }
+ }
+ }
+
+ if (configProperty != null)
+ {
+ //TODO add support for collections,...
+ if (configProperty.eager() && ConfigResolver.getPropertyValue(configProperty.name()) == null)
+ {
+ throw new IllegalStateException("no configured value found for property: " + configProperty.name());
+ }
+
+ this.injectionTargets.add(
+ new InjectionTargetEntry(injectionPoint.getType(), configProperty, qualifier));
+ }
+ }
+ }
+
+ @SuppressWarnings("UnusedDeclaration")
+ protected void addDependentBeans(@Observes AfterBeanDiscovery event)
+ {
+ initActivation();
+
+ if (!this.isActivated)
+ {
+ return;
+ }
+
+ for (InjectionTargetEntry injectionTargetEntry : this.injectionTargets)
+ {
+ event.addBean(new ConfigPropertyBean<Object>(injectionTargetEntry.getType(), injectionTargetEntry
+ .getConfigProperty(), injectionTargetEntry.getCustomQualifier()));
+ }
+ }
+
+ protected void initActivation()
+ {
+ if (this.isActivated == null)
+ {
+ this.isActivated = ClassDeactivationUtils.isActivated(getClass());
+ }
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/1ced97b6/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/injectable/extension/InjectionTargetEntry.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/injectable/extension/InjectionTargetEntry.java b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/injectable/extension/InjectionTargetEntry.java
new file mode 100644
index 0000000..e168bb9
--- /dev/null
+++ b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/config/injectable/extension/InjectionTargetEntry.java
@@ -0,0 +1,93 @@
+/*
+ * 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.impl.config.injectable.extension;
+
+import org.apache.deltaspike.core.api.config.annotation.ConfigProperty;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+
+class InjectionTargetEntry
+{
+ private final Type type;
+ private final ConfigProperty configProperty;
+ private final Annotation optionalCustomQualifier;
+
+ InjectionTargetEntry(Type type, ConfigProperty configProperty, Annotation optionalCustomQualifier)
+ {
+ this.type = type;
+ this.configProperty = configProperty;
+ this.optionalCustomQualifier = optionalCustomQualifier;
+ }
+
+ Type getType()
+ {
+ return type;
+ }
+
+ ConfigProperty getConfigProperty()
+ {
+ return configProperty;
+ }
+
+ Annotation getCustomQualifier()
+ {
+ return optionalCustomQualifier;
+ }
+
+ @Override
+ public boolean equals(Object o)
+ {
+ if (this == o)
+ {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass())
+ {
+ return false;
+ }
+
+ InjectionTargetEntry that = (InjectionTargetEntry) o;
+
+ if (!configProperty.equals(that.configProperty))
+ {
+ return false;
+ }
+ if (optionalCustomQualifier != null ? !optionalCustomQualifier
+ .equals(that.optionalCustomQualifier) : that.optionalCustomQualifier != null)
+ {
+ return false;
+ }
+ if (!type.equals(that.type))
+ {
+ return false;
+ }
+
+ return true;
+ }
+
+ @Override
+ public int hashCode()
+ {
+ int result = type.hashCode();
+ result = 31 * result + configProperty.hashCode();
+ result = 31 * result + (optionalCustomQualifier != null ? optionalCustomQualifier.hashCode() : 0);
+ return result;
+ }
+}
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/1ced97b6/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/exception/control/ExceptionHandlerComparator.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/exception/control/ExceptionHandlerComparator.java b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/exception/control/ExceptionHandlerComparator.java
index 3095878..c8fca12 100644
--- a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/exception/control/ExceptionHandlerComparator.java
+++ b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/exception/control/ExceptionHandlerComparator.java
@@ -29,7 +29,7 @@ import java.util.Set;
/**
* Comparator to sort exception handlers according qualifier
- * ({@link org.apache.deltaspike.core.api.exception.control.BeforeHandles} first), ordinal
+ * ({@link org.apache.deltaspike.core.api.exception.control.annotation.BeforeHandles} first), ordinal
* (highest to lowest) and finally hierarchy (least to most specific).
*/
@SuppressWarnings({ "MethodWithMoreThanThreeNegations" })
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/1ced97b6/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/exception/control/HandlerMethodImpl.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/exception/control/HandlerMethodImpl.java b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/exception/control/HandlerMethodImpl.java
index 42ca2ff..55ac2c8 100644
--- a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/exception/control/HandlerMethodImpl.java
+++ b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/exception/control/HandlerMethodImpl.java
@@ -19,10 +19,10 @@
package org.apache.deltaspike.core.impl.exception.control;
-import org.apache.deltaspike.core.api.exception.control.BeforeHandles;
+import org.apache.deltaspike.core.api.exception.control.annotation.BeforeHandles;
+import org.apache.deltaspike.core.api.exception.control.annotation.Handles;
import org.apache.deltaspike.core.api.exception.control.event.ExceptionEvent;
import org.apache.deltaspike.core.api.exception.control.HandlerMethod;
-import org.apache.deltaspike.core.api.exception.control.Handles;
import org.apache.deltaspike.core.api.literal.AnyLiteral;
import org.apache.deltaspike.core.api.metadata.builder.ImmutableInjectionPoint;
import org.apache.deltaspike.core.api.metadata.builder.InjectableMethod;
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/1ced97b6/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/exception/control/extension/ExceptionControlExtension.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/exception/control/extension/ExceptionControlExtension.java b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/exception/control/extension/ExceptionControlExtension.java
index 75d6d38..3f48d00 100644
--- a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/exception/control/extension/ExceptionControlExtension.java
+++ b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/exception/control/extension/ExceptionControlExtension.java
@@ -19,7 +19,7 @@
package org.apache.deltaspike.core.impl.exception.control.extension;
-import org.apache.deltaspike.core.api.exception.control.ExceptionHandler;
+import org.apache.deltaspike.core.api.exception.control.annotation.ExceptionHandler;
import org.apache.deltaspike.core.api.exception.control.HandlerMethod;
import org.apache.deltaspike.core.impl.exception.control.HandlerMethodImpl;
import org.apache.deltaspike.core.spi.activation.Deactivatable;
http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/1ced97b6/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/exclude/ExcludeExtension.java
----------------------------------------------------------------------
diff --git a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/exclude/ExcludeExtension.java b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/exclude/ExcludeExtension.java
deleted file mode 100644
index b4e2c83..0000000
--- a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/exclude/ExcludeExtension.java
+++ /dev/null
@@ -1,520 +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.deltaspike.core.impl.exclude;
-
-import org.apache.deltaspike.core.api.config.ConfigResolver;
-import org.apache.deltaspike.core.api.exclude.annotation.Exclude;
-import org.apache.deltaspike.core.api.metadata.builder.AnnotatedTypeBuilder;
-import org.apache.deltaspike.core.spi.activation.Deactivatable;
-import org.apache.deltaspike.core.api.interpreter.ExpressionInterpreter;
-import org.apache.deltaspike.core.api.projectstage.ProjectStage;
-import org.apache.deltaspike.core.impl.interpreter.PropertyExpressionInterpreter;
-import org.apache.deltaspike.core.util.ClassDeactivationUtils;
-import org.apache.deltaspike.core.util.ClassUtils;
-import org.apache.deltaspike.core.util.ProjectStageProducer;
-
-import javax.enterprise.event.Observes;
-import javax.enterprise.inject.Alternative;
-import javax.enterprise.inject.spi.AfterDeploymentValidation;
-import javax.enterprise.inject.spi.BeanManager;
-import javax.enterprise.inject.spi.Extension;
-import javax.enterprise.inject.spi.ProcessAnnotatedType;
-import javax.enterprise.util.Nonbinding;
-import java.lang.annotation.Annotation;
-import java.lang.reflect.Method;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.logging.Level;
-import java.util.logging.Logger;
-
-/**
- * <p>This class implements the logic for handling
- * {@link org.apache.deltaspike.core.api.exclude.annotation.Exclude} annotations.</p>
- * <p/>
- * <p>Further details see {@link org.apache.deltaspike.core.api.exclude.annotation.Exclude}</p>
- */
-public class ExcludeExtension implements Extension, Deactivatable
-{
- private static final Logger LOG = Logger.getLogger(ExcludeExtension.class.getName());
-
- private static Boolean isOwbDetected = null;
-
- private Boolean isActivated = null;
- private Boolean isGlobalAlternativeActivated = null;
-
- /**
- * triggers initialization in any case
- * @param afterDeploymentValidation observed event
- */
- @SuppressWarnings("UnusedDeclaration")
- protected void initProjectStage(@Observes AfterDeploymentValidation afterDeploymentValidation)
- {
- ProjectStageProducer.getInstance();
- }
-
- /**
- * Observer which is vetoing beans based on {@link Exclude}
- * @param processAnnotatedType observed event
- */
- @SuppressWarnings("UnusedDeclaration")
- protected void vetoBeans(@Observes ProcessAnnotatedType<Object> processAnnotatedType, BeanManager beanManager)
- {
- initActivation();
-
- //we need to do it before the exclude logic to keep the @Exclude support for global alternatives
- if (this.isGlobalAlternativeActivated)
- {
- detectCdiImplementation();
-
- if (isOwbDetected)
- {
- activateGlobalAlternativesOwb(processAnnotatedType, beanManager);
- }
- else
- {
- activateGlobalAlternativesWeld(processAnnotatedType, beanManager);
- }
- }
-
- if (!this.isActivated)
- {
- return;
- }
-
- //TODO needs further discussions for a different feature CodiStartupBroadcaster.broadcastStartup();
-
- //also forces deterministic project-stage initialization
- ProjectStage projectStage = ProjectStageProducer.getInstance().getProjectStage();
-
- if (!processAnnotatedType.getAnnotatedType().getJavaClass().isAnnotationPresent(Exclude.class))
- {
- return;
- }
-
- Exclude exclude = processAnnotatedType.getAnnotatedType().getJavaClass().getAnnotation(Exclude.class);
-
- if (!evalExcludeWithoutCondition(processAnnotatedType, exclude))
- {
- return; //veto called already
- }
-
- if (!evalExcludeInProjectStage(processAnnotatedType, exclude, projectStage))
- {
- return; //veto called already
- }
-
- if (!evalExcludeNotInProjectStage(processAnnotatedType, exclude, projectStage))
- {
- return; //veto called already
- }
-
- evalExcludeWithExpression(processAnnotatedType, exclude);
- }
-
- private void activateGlobalAlternativesWeld(ProcessAnnotatedType<Object> processAnnotatedType,
- BeanManager beanManager)
- {
- Class<Object> currentBean = processAnnotatedType.getAnnotatedType().getJavaClass();
-
- if (currentBean.isInterface())
- {
- return;
- }
-
- Set<Class> beanBaseTypes = resolveBeanTypes(currentBean);
-
- boolean isAlternativeBeanImplementation = currentBean.isAnnotationPresent(Alternative.class);
-
- List<Annotation> qualifiersOfCurrentBean =
- resolveQualifiers(processAnnotatedType.getAnnotatedType().getAnnotations(), beanManager);
-
- String configuredBeanName;
- List<Annotation> qualifiersOfConfiguredBean;
- Class<Object> alternativeBeanClass;
- Set<Annotation> alternativeBeanAnnotations;
-
- for (Class currentType : beanBaseTypes)
- {
- alternativeBeanAnnotations = new HashSet<Annotation>();
-
- configuredBeanName = ConfigResolver.getPropertyValue(currentType.getName());
- if (configuredBeanName != null && configuredBeanName.length() > 0)
- {
- alternativeBeanClass = ClassUtils.tryToLoadClassForName(configuredBeanName);
-
- if (alternativeBeanClass == null)
- {
- throw new IllegalStateException("Can't find class " + configuredBeanName + " which is configured" +
- " for " + currentType.getName());
- }
-
- //check that the configured class is an alternative
- if (!alternativeBeanClass.isAnnotationPresent(Alternative.class))
- {
- //we have to continue because other classes can be configured as well
- continue;
- }
-
- alternativeBeanAnnotations.addAll(Arrays.asList(alternativeBeanClass.getAnnotations()));
- qualifiersOfConfiguredBean = resolveQualifiers(alternativeBeanAnnotations, beanManager);
- }
- else
- {
- continue;
- }
-
- if (isAlternativeBeanImplementation) //current bean is annotated with @Alternative
- {
- if (doQualifiersMatch(qualifiersOfCurrentBean, qualifiersOfConfiguredBean))
- {
- AnnotatedTypeBuilder<Object> annotatedTypeBuilder
- = new AnnotatedTypeBuilder<Object>().readFromType(processAnnotatedType.getAnnotatedType());
-
- annotatedTypeBuilder.removeFromClass(Alternative.class);
- processAnnotatedType.setAnnotatedType(annotatedTypeBuilder.create());
- return;
- }
- }
- else //current bean is the original implementation
- {
- if (doQualifiersMatch(qualifiersOfCurrentBean, qualifiersOfConfiguredBean))
- {
- //veto this original implementation because the alternative will be added
- processAnnotatedType.veto();
- return;
- }
- }
- }
- }
-
- //see OWB-643
- //just #veto the original implementation and remove @Alternative from the ProcessAnnotatedType of
- // the configured alternative doesn't work with OWB (due to OWB-643)
- private void activateGlobalAlternativesOwb(ProcessAnnotatedType<Object> processAnnotatedType,
- BeanManager beanManager)
- {
- //the current bean is the bean with a potential global alternative
- Class<Object> currentBean = processAnnotatedType.getAnnotatedType().getJavaClass();
-
- if (currentBean.isInterface())
- {
- return;
- }
-
- Set<Class> beanBaseTypes = resolveBeanTypes(currentBean);
-
- boolean isAlternativeBeanImplementation = currentBean.isAnnotationPresent(Alternative.class);
-
- List<Annotation> qualifiersOfCurrentBean =
- resolveQualifiers(processAnnotatedType.getAnnotatedType().getAnnotations(), beanManager);
-
- String configuredBeanName;
- List<Annotation> qualifiersOfConfiguredBean;
- Class<Object> alternativeBeanClass;
- Set<Annotation> alternativeBeanAnnotations;
-
- for (Class currentType : beanBaseTypes)
- {
- alternativeBeanAnnotations = new HashSet<Annotation>();
-
- configuredBeanName = ConfigResolver.getPropertyValue(currentType.getName());
- if (configuredBeanName != null && configuredBeanName.length() > 0)
- {
- alternativeBeanClass = ClassUtils.tryToLoadClassForName(configuredBeanName);
-
- if (alternativeBeanClass == null)
- {
- throw new IllegalStateException("Can't find class " + configuredBeanName + " which is configured" +
- " for " + currentType.getName());
- }
- alternativeBeanAnnotations.addAll(Arrays.asList(alternativeBeanClass.getAnnotations()));
- qualifiersOfConfiguredBean = resolveQualifiers(alternativeBeanAnnotations, beanManager);
- }
- else
- {
- continue;
- }
-
- if (isAlternativeBeanImplementation)
- {
- if (doQualifiersMatch(qualifiersOfCurrentBean, qualifiersOfConfiguredBean))
- {
- //veto if the current annotated-type is a global alternative - it replaced the original type already
- processAnnotatedType.veto();
- break;
- }
- }
- else
- {
- if (!alternativeBeanClass.isAnnotationPresent(Alternative.class))
- {
- continue;
- }
-
- if (doQualifiersMatch(qualifiersOfCurrentBean, qualifiersOfConfiguredBean))
- {
- AnnotatedTypeBuilder<Object> annotatedTypeBuilder
- = new AnnotatedTypeBuilder<Object>().readFromType(alternativeBeanClass);
-
- //just to avoid issues with switching between app-servers,...
- annotatedTypeBuilder.removeFromClass(Alternative.class);
- processAnnotatedType.setAnnotatedType(annotatedTypeBuilder.create());
- }
- }
- }
- }
-
- private boolean doQualifiersMatch(List<Annotation> qualifiersOfCurrentBean,
- List<Annotation> qualifiersOfConfiguredBean)
- {
- if (qualifiersOfCurrentBean.size() != qualifiersOfConfiguredBean.size())
- {
- return false;
- }
-
- int matchingQualifiers = 0;
- for (Annotation currentQualifier : qualifiersOfCurrentBean)
- {
- for (Annotation qualifierConfiguredBean : qualifiersOfConfiguredBean)
- {
- if (doesQualifierMatch(currentQualifier, qualifierConfiguredBean))
- {
- matchingQualifiers++;
- break;
- }
- }
- }
- return qualifiersOfConfiguredBean.size() == matchingQualifiers;
- }
-
- private boolean doesQualifierMatch(Annotation currentQualifier, Annotation qualifierConfiguredBean)
- {
- if (!currentQualifier.annotationType().equals(qualifierConfiguredBean.annotationType()))
- {
- return false;
- }
-
- Object currentValue;
- Object valueOfQualifierConfiguredBean;
- for (Method currentMethod : currentQualifier.annotationType().getDeclaredMethods())
- {
- if (currentMethod.isAnnotationPresent(Nonbinding.class))
- {
- continue;
- }
-
- try
- {
- currentMethod.setAccessible(true);
- currentValue = currentMethod.invoke(currentQualifier);
- valueOfQualifierConfiguredBean = currentMethod.invoke(qualifierConfiguredBean);
-
- if (!currentValue.equals(valueOfQualifierConfiguredBean))
- {
- return false;
- }
- }
- catch (Exception e)
- {
- throw new IllegalStateException("Can't compare " + currentQualifier.annotationType().getName() +
- " with " + qualifierConfiguredBean.annotationType().getName());
- }
- }
- return true;
- }
-
- private List<Annotation> resolveQualifiers(Set<Annotation> annotations, BeanManager beanManager)
- {
- List<Annotation> result = new ArrayList<Annotation>();
-
- for (Annotation annotation : annotations)
- {
- if (beanManager.isQualifier(annotation.annotationType()))
- {
- result.add(annotation);
- }
- }
- return result;
- }
-
- private Set<Class> resolveBeanTypes(Class beanClass)
- {
- Set<Class> result = new HashSet<Class>();
-
- Class<?> currentClass = beanClass;
- while (currentClass != null && !Object.class.getName().equals(currentClass.getName()))
- {
- result.add(currentClass);
-
- for (Class interfaceClass : currentClass.getInterfaces())
- {
- if (interfaceClass.getName().startsWith("java.") || interfaceClass.getName().startsWith("javax."))
- {
- continue;
- }
- result.addAll(resolveBeanTypes(interfaceClass));
- }
-
- currentClass = currentClass.getSuperclass();
- }
-
- return result;
- }
-
- private boolean evalExcludeWithoutCondition(ProcessAnnotatedType<Object> processAnnotatedType, Exclude exclude)
- {
- if (exclude.ifProjectStage().length == 0 && exclude.exceptIfProjectStage().length == 0 &&
- "".equals(exclude.onExpression()))
- {
- veto(processAnnotatedType, "Stateless");
- return false;
- }
- return true;
- }
-
- private boolean evalExcludeInProjectStage(ProcessAnnotatedType<Object> processAnnotatedType, Exclude exclude,
- ProjectStage currentlyConfiguredProjectStage)
- {
- Class<? extends ProjectStage>[] activatedIn = exclude.ifProjectStage();
-
- if (activatedIn.length == 0)
- {
- return true;
- }
-
- if (isInProjectStage(activatedIn, currentlyConfiguredProjectStage))
- {
- veto(processAnnotatedType, "IfProjectState");
- return false;
- }
- return true;
- }
-
- private boolean evalExcludeNotInProjectStage(ProcessAnnotatedType<Object> processAnnotatedType, Exclude exclude,
- ProjectStage currentlyConfiguredProjectStage)
- {
- Class<? extends ProjectStage>[] notIn = exclude.exceptIfProjectStage();
-
- if (notIn.length == 0)
- {
- return true;
- }
-
- if (!isInProjectStage(notIn, currentlyConfiguredProjectStage))
- {
- veto(processAnnotatedType, "ExceptIfProjectState");
- return false;
- }
- return true;
- }
-
- private void evalExcludeWithExpression(ProcessAnnotatedType<Object> processAnnotatedType, Exclude exclude)
- {
- if ("".equals(exclude.onExpression()))
- {
- return;
- }
-
- if (isDeactivated(exclude, PropertyExpressionInterpreter.class))
- {
- veto(processAnnotatedType, "Expression");
- }
- }
-
- private boolean isInProjectStage(Class<? extends ProjectStage>[] activatedIn,
- ProjectStage currentlyConfiguredProjectStage)
- {
- if (activatedIn != null && activatedIn.length > 0)
- {
- for (Class<? extends ProjectStage> activated : activatedIn)
- {
- if (currentlyConfiguredProjectStage.getClass().equals(activated))
- {
- return true;
- }
- }
- }
-
- return false;
- }
-
- private boolean isDeactivated(Exclude exclude, Class defaultExpressionInterpreterClass)
- {
- String expressions = exclude.onExpression();
-
- Class<? extends ExpressionInterpreter> interpreterClass = exclude.interpretedBy();
-
- if (interpreterClass.equals(ExpressionInterpreter.class))
- {
- interpreterClass = defaultExpressionInterpreterClass;
- }
-
- ExpressionInterpreter<String, Boolean> expressionInterpreter =
- ClassUtils.tryToInstantiateClass(interpreterClass);
-
- if (expressionInterpreter == null)
- {
- if (LOG.isLoggable(Level.WARNING))
- {
- LOG.warning("can't instantiate " + interpreterClass.getClass().getName());
- }
- return true;
- }
-
- return expressionInterpreter.evaluate(expressions);
- }
-
- private void veto(ProcessAnnotatedType<?> processAnnotatedType, String vetoType)
- {
- processAnnotatedType.veto();
- LOG.finer(vetoType + " based veto for bean with type: " +
- processAnnotatedType.getAnnotatedType().getJavaClass());
- }
-
- public void initActivation()
- {
- if (isActivated == null)
- {
- isActivated = ClassDeactivationUtils.isActivated(getClass());
- isGlobalAlternativeActivated = ClassDeactivationUtils.isActivated(GlobalAlternative.class);
- }
- }
-
- private void detectCdiImplementation()
- {
- if (isOwbDetected == null)
- {
- isOwbDetected = false;
-
- IllegalStateException runtimeException = new IllegalStateException();
-
- for (StackTraceElement element : runtimeException.getStackTrace())
- {
- if (element.toString().contains("org.apache.webbeans."))
- {
- isOwbDetected = true;
- break;
- }
- }
- }
- }
-}