yes - with "ongoing discussion" i talked about your initial mail (today). we didn't agree on it.
regards, gerhard 2012/1/22 Mark Struberg <[email protected]> > sorry, didn't know you are still working on that stuff. It was marked as > done and while reviewing I spotted a few areas where I thought we can do > this even better. > > LieGrue, > strub > > > > ----- Original Message ----- > > From: Gerhard Petracek <[email protected]> > > To: [email protected] > > Cc: > > Sent: Sunday, January 22, 2012 3:23 PM > > Subject: Re: git commit: DELTASPIKE-24 rework Deactivation logic > > > > i know why you did it in this case - but in general: -1 for committing > such > > large changes in case of an ongoing discussion. > > some hours ago i added a suggestion to [1] exactly for such cases. > > > > regards, > > gerhard > > > > [1] http://s.apache.org/oo > > > > > > > > 2012/1/22 <[email protected]> > > > >> Updated Branches: > >> refs/heads/master f5d1995b3 -> e3f7e3e4e > >> > >> > >> DELTASPIKE-24 rework Deactivation logic > >> > >> This introduces 3 new features > >> a.) allow deactivation and also re-activation based on ordinals > >> b.) make it a 1-liner to use for external Extensions > >> c.) Deativatable is now a pure Marker Interface > >> > >> > >> Project: > http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/repo > >> Commit: > >> > http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/commit/e3f7e3e4 > >> Tree: > >> > http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/tree/e3f7e3e4 > >> Diff: > >> > http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/diff/e3f7e3e4 > >> > >> Branch: refs/heads/master > >> Commit: e3f7e3e4e254401265ac5cc87fcaff5f232392f8 > >> Parents: f5d1995 > >> Author: Mark Struberg <[email protected]> > >> Authored: Sun Jan 22 14:21:52 2012 +0100 > >> Committer: Mark Struberg <[email protected]> > >> Committed: Sun Jan 22 14:21:52 2012 +0100 > >> > >> ---------------------------------------------------------------------- > >> .../api/activation/AbstractClassDeactivator.java | 61 ------- > >> .../core/api/activation/ClassDeactivation.java | 122 > +++++++++++++++ > >> .../core/api/activation/ClassDeactivator.java | 16 +- > >> .../core/api/activation/Deactivatable.java | 20 +-- > >> .../deltaspike/core/api/config/ConfigResolver.java | 10 +- > >> .../core/impl/exclude/ExcludeExtension.java | 14 +- > >> .../core/impl/util/ClassDeactivation.java | 113 > ------------- > >> .../core/impl/util/ClassDeactivatorStorage.java | 66 -------- > >> .../core/impl/util/DefaultClassDeactivator.java | 51 ------ > >> .../test/core/impl/activation/ActivatedClass.java | 5 +- > >> .../core/impl/activation/DeactivatedClass.java | 4 +- > >> .../impl/activation/TestClassDeactivation.java | 6 +- > >> .../core/impl/activation/TestClassDeactivator.java | 19 ++- > >> .../core/api/exclude/ExcludeIntegrationTest.java | 3 +- > >> .../META-INF/apache-deltaspike.properties | 1 - > >> 15 files changed, 178 insertions(+), 333 deletions(-) > >> ---------------------------------------------------------------------- > >> > >> > >> > >> > > > http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/e3f7e3e4/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/activation/AbstractClassDeactivator.java > >> ---------------------------------------------------------------------- > >> diff --git > >> > > > a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/activation/AbstractClassDeactivator.java > >> > > > b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/activation/AbstractClassDeactivator.java > >> deleted file mode 100644 > >> index f3755ad..0000000 > >> --- > >> > > > a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/activation/AbstractClassDeactivator.java > >> +++ /dev/null > >> @@ -1,61 +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.activation; > >> - > >> -import java.util.HashSet; > >> -import java.util.Set; > >> - > >> -/** > >> - * Base implementation which allows an easier class-deactivator > >> implementation > >> - */ > >> -public abstract class AbstractClassDeactivator implements > ClassDeactivator > >> -{ > >> - // HashSet due to Serializable warning in checkstyle rules > >> - private HashSet<Class> deactivatedClasses = null; > >> - > >> - /** > >> - * {@inheritDoc} > >> - */ > >> - @Override > >> - public final synchronized Set<Class> getDeactivatedClasses() > >> - { > >> - if (this.deactivatedClasses == null) > >> - { > >> - this.deactivatedClasses = new HashSet<Class>(); > >> - deactivateClasses(); > >> - } > >> - return this.deactivatedClasses; > >> - } > >> - > >> - /** > >> - * Can be used by sub-classes to add deactivated classes easily. > >> - * > >> - * @param deactivatedClass class to deactivate > >> - */ > >> - protected final void addDeactivatedClass(Class deactivatedClass) > >> - { > >> - this.deactivatedClasses.add(deactivatedClass); > >> - } > >> - > >> - /** > >> - * An implementation has to add classes which shouldn't be used by > >> DeltaSpike. > >> - * (use {@link #addDeactivatedClass(Class)} for adding classes) > >> - */ > >> - protected abstract void deactivateClasses(); > >> -} > >> > >> > >> > > > http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/e3f7e3e4/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/activation/ClassDeactivation.java > >> ---------------------------------------------------------------------- > >> diff --git > >> > > > a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/activation/ClassDeactivation.java > >> > > > b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/activation/ClassDeactivation.java > >> new file mode 100644 > >> index 0000000..6a31ad9 > >> --- /dev/null > >> +++ > >> > > > b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/activation/ClassDeactivation.java > >> @@ -0,0 +1,122 @@ > >> +/* > >> + * 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.activation; > >> + > >> +import org.apache.deltaspike.core.api.config.ConfigResolver; > >> +import org.apache.deltaspike.core.api.util.ClassUtils; > >> + > >> +import javax.enterprise.inject.Typed; > >> +import java.util.ArrayList; > >> +import java.util.List; > >> +import java.util.Map; > >> +import java.util.concurrent.ConcurrentHashMap; > >> +import java.util.logging.Logger; > >> + > >> +/** > >> + * Helper methods for {@link ClassDeactivator} > >> + */ > >> +@Typed() > >> +public final class ClassDeactivation > >> +{ > >> + private static final Logger LOG = > >> Logger.getLogger(ClassDeactivation.class.getName()); > >> + > >> + /** > >> + * This Map holds the ClassLoader as first level to make it > possible > >> to have different configurations per > >> + * WebApplication in an EAR or other Multi-ClassLoader scenario. > >> + * > >> + * The Map then contains a List of {@link ClassDeactivator}s in > order > >> of their configured ordinal. > >> + */ > >> + private static Map<ClassLoader, List<ClassDeactivator>> > >> classDeactivatorMap > >> + = new ConcurrentHashMap<ClassLoader, > > List<ClassDeactivator>>(); > >> + > >> + private ClassDeactivation() > >> + { > >> + // private ct to prevent utility class from instantiation. > >> + } > >> + > >> + /** > >> + * Evaluates if the given {@link Deactivatable} is active. > >> + * > >> + * @param deactivatableClazz {@link Deactivatable} under test. > >> + * @return <code>true</code> if it is active, > > <code>false</code> > >> otherwise > >> + */ > >> + public static synchronized boolean isActivated(Class<? extends > >> Deactivatable> deactivatableClazz) > >> + { > >> + List<ClassDeactivator> classDeactivators = > > getClassDeactivators(); > >> + > >> + Boolean isActivated = Boolean.TRUE; // by default a class is > >> always activated. > >> + > >> + for (ClassDeactivator classDeactivator : classDeactivators) > >> + { > >> + Boolean isLocallyActivated = > >> classDeactivator.isActivated(deactivatableClazz); > >> + if (isLocallyActivated != null) > >> + { > >> + isActivated = isLocallyActivated; > >> + } > >> + } > >> + > >> + if (!isActivated) > >> + { > >> + LOG.info("Deactivating class " + > > deactivatableClazz); > >> + } > >> + > >> + return isActivated; > >> + } > >> + > >> + > >> + /** > >> + * @return the List of configured @{link ClassDeactivator}s for > the > >> current context ClassLoader. > >> + */ > >> + private static List<ClassDeactivator> getClassDeactivators() > >> + { > >> + List<ClassDeactivator> classDeactivators = > >> classDeactivatorMap.get(ClassUtils.getClassLoader(null)); > >> + if (classDeactivators == null) > >> + { > >> + classDeactivators = getConfiguredClassDeactivator(); > >> + } > >> + > >> + return classDeactivators; > >> + } > >> + > >> + private static List<ClassDeactivator> > > getConfiguredClassDeactivator() > >> + { > >> + List<String> classDeactivatorClassNames = > >> ConfigResolver.getAllPropertyValues(ClassDeactivator.class.getName()); > >> + > >> + List<ClassDeactivator> classDeactivators = new > >> ArrayList<ClassDeactivator>(); > >> + > >> + for (String classDeactivatorClassName : > >> classDeactivatorClassNames) > >> + { > >> + LOG.fine("processing ClassDeactivator: " + > >> classDeactivatorClassName); > >> + > >> + try > >> + { > >> + ClassDeactivator currentClassDeactivator = > >> + (ClassDeactivator) > >> ClassUtils.instantiateClassForName(classDeactivatorClassName); > >> + classDeactivators.add(currentClassDeactivator); > >> + } > >> + catch (Exception e) > >> + { > >> + LOG.warning(classDeactivatorClassName + " can't > > be > >> instantiated"); > >> + throw new RuntimeException(e); > >> + } > >> + } > >> + > >> + return classDeactivators; > >> + } > >> +} > >> > >> > >> > > > http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/e3f7e3e4/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/activation/ClassDeactivator.java > >> ---------------------------------------------------------------------- > >> diff --git > >> > > > a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/activation/ClassDeactivator.java > >> > > > b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/activation/ClassDeactivator.java > >> index 1506539..89e4a6f 100644 > >> --- > >> > > > a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/activation/ClassDeactivator.java > >> +++ > >> > > > b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/activation/ClassDeactivator.java > >> @@ -19,26 +19,28 @@ > >> package org.apache.deltaspike.core.api.activation; > >> > >> import java.io.Serializable; > >> -import java.util.Set; > >> > >> /** > >> - * <p>A class-deactivator allows to specify deactivated classes > > which > >> can't be deactivated via std. CDI mechanisms.</p> > >> + * <p>A class-deactivator allows to specify deactivated classes > > which > >> can't be deactivated via std. CDI mechanisms. > >> + * This might be the case for CDI Extensions because CDI mechanisms > are > >> not available at startup time.</p> > >> * > >> * <p>A class-deactivator will be resolved from the environment via > > the > >> default resolvers or via a custom resolver which > >> * allows to use any type of configuration-format. See {@link > >> org.apache.deltaspike.core.api.config.ConfigResolver} > >> * for more information about how to configure it. The configuration > key is > >> * > >> > > > <code>org.apache.deltaspike.core.api.activation.ClassDeactivator</code></p> > >> * > >> - * <p>Furthermore, {@link AbstractClassDeactivator} is a convenience > >> class which > >> - * allows an easier implementation. All classes which implement {@link > >> Deactivatable} in-/directly, can be deactivated > >> - * with this mechanism. For all other classes/beans, you can use the > veto > >> mechanism provided by CDI.</p> > >> + * <p>All DlassDeactivators will get picked up in order of their > > ordinal > >> and might explicitely activate or > >> + * deactivate {@link Deactivatable} classes. Returning a > >> <code>null</code> value means that the ClassDeactivator > >> + * doesn't care about the very Deactivatable class.</p> > >> + * > >> */ > >> public interface ClassDeactivator extends Serializable > >> { > >> /** > >> * Provides classes which should be deactivated. > >> * > >> - * @return classes which should be deactivated > >> + * @return {@link Boolean#FALSE} if class should get activated, > >> {@link Boolean#FALSE} if class must be available > >> + * and <code>null</code> to let it as is (defined > > by default > >> or other > >> */ > >> - Set<Class> getDeactivatedClasses(); > >> + Boolean isActivated(Class<? extends Deactivatable> > >> deactivatableClazz); > >> } > >> > >> > >> > > > http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/e3f7e3e4/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/activation/Deactivatable.java > >> ---------------------------------------------------------------------- > >> diff --git > >> > > > a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/activation/Deactivatable.java > >> > > > b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/activation/Deactivatable.java > >> index 42bb6c7..a0785e3 100644 > >> --- > >> > > > a/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/activation/Deactivatable.java > >> +++ > >> > > > b/deltaspike/core/api/src/main/java/org/apache/deltaspike/core/api/activation/Deactivatable.java > >> @@ -19,20 +19,18 @@ > >> package org.apache.deltaspike.core.api.activation; > >> > >> /** > >> - * Interface to allow easier detection of deactivatable classes. > >> - * These classes are activated by default (e.g. via CDI config). > >> + * <p>Interface to allow easier detection of deactivatable > > classes.</p> > >> + * > >> + * <p>These classes are activated by default and can be disabled on > >> demand (e.g. via CDI config). > >> * Since CDI, JSF,... currently don't allow to deactivate default > >> implementations, > >> - * DeltaSpike has to introduce a proprietary mechanism. > >> + * DeltaSpike has to introduce a proprietary mechanism.</p> > >> + * > >> + * <p>This is e.g. used to disable CDI Extensions in DeltaSpike and > > might > >> get > >> + * used for other Extension libraries as well.</p> > >> * > >> - * This is e.g. used to disable CDI Extensions in DeltaSpike and > might get > >> - * used for other Extension libraries as well. > >> + * <p><b>Note:</b> It is suggested that the > > implementations > >> + * use the {@link ClassDeactivation} for implementing the lookup</p> > >> */ > >> public interface Deactivatable > >> { > >> - /** > >> - * Returns if the current instance is active or not. > >> - * > >> - * @return true if the current instance is active, false otherwise > >> - */ > >> - boolean isActivated(); > >> } > >> > >> > >> > > > http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/e3f7e3e4/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 fa83da9..6c71add 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 > >> @@ -84,9 +84,13 @@ public final class ConfigResolver > >> } > >> > >> /** > >> - * Resolve all values for the given key, from all registered > >> ConfigSources. > >> - * @param key > >> - * @return List with all found property values, sorted in order of > >> their ordinal. > >> + * Resolve all values for the given key, from all registered > >> ConfigSources ordered by their > >> + * ordinal value in ascending ways. If more {@link ConfigSource}s > >> have the same ordinal, their > >> + * order is undefined. > >> + * > >> + * @param key under which configuration is stored > >> + * @return List with all found property values, sorted in > ascending > >> order of their ordinal. > >> + * @see > >> org.apache.deltaspike.core.spi.config.ConfigSource#getOrdinal() > >> */ > >> public static List<String> getAllPropertyValues(String key) > >> { > >> > >> > >> > > > http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/e3f7e3e4/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 > >> index ad73a81..c86ac94 100644 > >> --- > >> > > > 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 > >> @@ -18,6 +18,7 @@ > >> */ > >> package org.apache.deltaspike.core.impl.exclude; > >> > >> +import org.apache.deltaspike.core.api.activation.ClassDeactivation; > >> import org.apache.deltaspike.core.api.activation.Deactivatable; > >> import org.apache.deltaspike.core.api.exclude.Exclude; > >> import > org.apache.deltaspike.core.api.interpreter.ExpressionInterpreter; > >> @@ -25,7 +26,6 @@ import > >> org.apache.deltaspike.core.api.projectstage.ProjectStage; > >> import org.apache.deltaspike.core.api.util.ClassUtils; > >> import > >> > org.apache.deltaspike.core.impl.interpreter.PropertyExpressionInterpreter; > >> import > org.apache.deltaspike.core.impl.projectstage.ProjectStageProducer; > >> -import org.apache.deltaspike.core.impl.util.ClassDeactivation; > >> > >> import javax.enterprise.event.Observes; > >> import javax.enterprise.inject.spi.AfterDeploymentValidation; > >> @@ -44,6 +44,8 @@ public class ExcludeExtension implements Extension, > >> Deactivatable > >> { > >> private static final Logger LOG = > >> Logger.getLogger(ExcludeExtension.class.getName()); > >> > >> + private Boolean isActivated = null; > >> + > >> /** > >> * triggers initialization in any case > >> * @param afterDeploymentValidation observed event > >> @@ -197,12 +199,12 @@ public class ExcludeExtension implements > Extension, > >> Deactivatable > >> > processAnnotatedType.getAnnotatedType().getJavaClass()); > >> } > >> > >> - /** > >> - * {@inheritDoc} > >> - */ > >> - @Override > >> public boolean isActivated() > >> { > >> - return ClassDeactivation.isClassActivated(getClass()); > >> + if (isActivated == null) > >> + { > >> + isActivated = ClassDeactivation.isActivated(getClass()); > >> + } > >> + return isActivated; > >> } > >> } > >> > >> > >> > > > http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/e3f7e3e4/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/util/ClassDeactivation.java > >> ---------------------------------------------------------------------- > >> diff --git > >> > > > a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/util/ClassDeactivation.java > >> > > > b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/util/ClassDeactivation.java > >> deleted file mode 100644 > >> index ef06193..0000000 > >> --- > >> > > > a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/util/ClassDeactivation.java > >> +++ /dev/null > >> @@ -1,113 +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.util; > >> - > >> -import org.apache.deltaspike.core.api.activation.ClassDeactivator; > >> -import org.apache.deltaspike.core.api.config.ConfigResolver; > >> -import org.apache.deltaspike.core.api.util.ClassUtils; > >> - > >> -import javax.enterprise.inject.Typed; > >> -import java.util.HashSet; > >> -import java.util.List; > >> -import java.util.Set; > >> -import java.util.logging.Logger; > >> - > >> -/** > >> - * Helper methods for {@link ClassDeactivator} > >> - */ > >> -@Typed() > >> -public final class ClassDeactivation > >> -{ > >> - private static final Logger LOG = > >> Logger.getLogger(ClassDeactivation.class.getName()); > >> - > >> - private ClassDeactivation() > >> - { > >> - } > >> - > >> - /** > >> - * Evaluates if the given class is active > >> - * > >> - * @param targetClass current class > >> - * @return true if it is active, false otherwise > >> - */ > >> - public static boolean isClassActivated(Class targetClass) > >> - { > >> - ClassDeactivator classDeactivator = > >> ClassDeactivatorStorage.getClassDeactivator(); > >> - > >> - if (classDeactivator == null) > >> - { > >> - classDeactivator = resolveAndCacheClassDeactivator(); > >> - } > >> - > >> - boolean classDeactivated = > >> classDeactivator.getDeactivatedClasses().contains(targetClass); > >> - > >> - return !classDeactivated; > >> - } > >> - > >> - /** > >> - * Allows to provide a custom {@link ClassDeactivator} > >> - * > >> - * @param classDeactivator class-deactivator which should be used > >> - */ > >> - public static void setClassDeactivator(ClassDeactivator > >> classDeactivator) > >> - { > >> - ClassDeactivatorStorage.setClassDeactivator(classDeactivator); > >> - } > >> - > >> - private static ClassDeactivator resolveAndCacheClassDeactivator() > >> - { > >> - ClassDeactivator classDeactivator = > >> getConfiguredClassDeactivator(); > >> - > >> - // display deactivated classes here once > >> - // NOTE that isClassActivated() will be called many times for > the > >> same class > >> - for (Class<?> deactivatedClass : > >> classDeactivator.getDeactivatedClasses()) > >> - { > >> - LOG.info("deactivate: " + deactivatedClass); > >> - } > >> - > >> - ClassDeactivatorStorage.setClassDeactivator(classDeactivator); > >> - return classDeactivator; > >> - } > >> - > >> - private static ClassDeactivator getConfiguredClassDeactivator() > >> - { > >> - List<String> classDeactivatorClassNames = > >> ConfigResolver.getAllPropertyValues(ClassDeactivator.class.getName()); > >> - Set<Class> deactivatedClasses = new HashSet<Class>(); > >> - > >> - ClassDeactivator currentClassDeactivator; > >> - for (String classDeactivatorClassName : > >> classDeactivatorClassNames) > >> - { > >> - LOG.info(classDeactivatorClassName + " gets > > processed"); > >> - > >> - currentClassDeactivator = > >> - > >> ClassUtils.tryToInstantiateClassForName(classDeactivatorClassName, > >> ClassDeactivator.class); > >> - > >> - if (currentClassDeactivator != null) > >> - { > >> - > >> > > > deactivatedClasses.addAll(currentClassDeactivator.getDeactivatedClasses()); > >> - } > >> - else > >> - { > >> - LOG.warning(classDeactivatorClassName + " can't > > be > >> instantiated"); > >> - } > >> - } > >> - > >> - return new DefaultClassDeactivator(deactivatedClasses); > >> - } > >> -} > >> > >> > >> > > > http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/e3f7e3e4/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/util/ClassDeactivatorStorage.java > >> ---------------------------------------------------------------------- > >> diff --git > >> > > > a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/util/ClassDeactivatorStorage.java > >> > > > b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/util/ClassDeactivatorStorage.java > >> deleted file mode 100644 > >> index a7c2d02..0000000 > >> --- > >> > > > a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/util/ClassDeactivatorStorage.java > >> +++ /dev/null > >> @@ -1,66 +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.util; > >> - > >> -import org.apache.deltaspike.core.api.activation.ClassDeactivator; > >> -import org.apache.deltaspike.core.api.util.ClassUtils; > >> - > >> -import javax.enterprise.inject.Typed; > >> -import java.util.Map; > >> -import java.util.concurrent.ConcurrentHashMap; > >> - > >> -/** > >> - * Cache for {@link ClassDeactivator} implementations > >> - */ > >> -@Typed() > >> -class ClassDeactivatorStorage > >> -{ > >> - private static Map<ClassLoader, ClassDeactivator> > > classDeactivatorMap > >> - = new ConcurrentHashMap<ClassLoader, ClassDeactivator>(); > >> - > >> - private ClassDeactivatorStorage() > >> - { > >> - } > >> - > >> - static void setClassDeactivator(ClassDeactivator classDeactivator) > >> - { > >> - if (classDeactivator != null) > >> - { > >> - classDeactivatorMap.put(getClassLoader(), > classDeactivator); > >> - } > >> - else > >> - { > >> - classDeactivatorMap.remove(getClassLoader()); > >> - } > >> - } > >> - > >> - static ClassDeactivator getClassDeactivator() > >> - { > >> - if (!classDeactivatorMap.containsKey(getClassLoader())) > >> - { > >> - return null; > >> - } > >> - return classDeactivatorMap.get(getClassLoader()); > >> - } > >> - > >> - private static ClassLoader getClassLoader() > >> - { > >> - return ClassUtils.getClassLoader(null); > >> - } > >> -} > >> > >> > >> > > > http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/e3f7e3e4/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/util/DefaultClassDeactivator.java > >> ---------------------------------------------------------------------- > >> diff --git > >> > > > a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/util/DefaultClassDeactivator.java > >> > > > b/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/util/DefaultClassDeactivator.java > >> deleted file mode 100644 > >> index b8c2831..0000000 > >> --- > >> > > > a/deltaspike/core/impl/src/main/java/org/apache/deltaspike/core/impl/util/DefaultClassDeactivator.java > >> +++ /dev/null > >> @@ -1,51 +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.util; > >> - > >> -import org.apache.deltaspike.core.api.activation.ClassDeactivator; > >> - > >> -import java.util.Set; > >> - > >> -/** > >> - * Helper implementation which gets initialized with all configured > >> classes which have to be deactivated > >> - */ > >> -class DefaultClassDeactivator implements ClassDeactivator > >> -{ > >> - private static final long serialVersionUID = > -1653478265237950470L; > >> - > >> - private Set<Class> deactivatedClasses; > >> - > >> - /** > >> - * Required constructor which receives all configured classes > which > >> will be returned by #getDeactivatedClasses > >> - * @param deactivatedClasses classes which get returned by > >> #getDeactivatedClasses > >> - */ > >> - public DefaultClassDeactivator(Set<Class> deactivatedClasses) > >> - { > >> - this.deactivatedClasses = deactivatedClasses; > >> - } > >> - > >> - /** > >> - * {@inheritDoc} > >> - */ > >> - @Override > >> - public Set<Class> getDeactivatedClasses() > >> - { > >> - return this.deactivatedClasses; > >> - } > >> -} > >> > >> > >> > > > http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/e3f7e3e4/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/activation/ActivatedClass.java > >> ---------------------------------------------------------------------- > >> diff --git > >> > > > a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/activation/ActivatedClass.java > >> > > > b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/activation/ActivatedClass.java > >> index 4eb5fe7..86fcb34 100644 > >> --- > >> > > > a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/activation/ActivatedClass.java > >> +++ > >> > > > b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/activation/ActivatedClass.java > >> @@ -18,9 +18,12 @@ > >> */ > >> package org.apache.deltaspike.test.core.impl.activation; > >> > >> +import org.apache.deltaspike.core.api.activation.Deactivatable; > >> + > >> /** > >> * Class which isn't deactivated > >> */ > >> -public class ActivatedClass > >> +public class ActivatedClass implements Deactivatable > >> { > >> + > >> } > >> > >> > >> > > > http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/e3f7e3e4/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/activation/DeactivatedClass.java > >> ---------------------------------------------------------------------- > >> diff --git > >> > > > a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/activation/DeactivatedClass.java > >> > > > b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/activation/DeactivatedClass.java > >> index a8f1a62..8cba1c0 100644 > >> --- > >> > > > a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/activation/DeactivatedClass.java > >> +++ > >> > > > b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/activation/DeactivatedClass.java > >> @@ -18,9 +18,11 @@ > >> */ > >> package org.apache.deltaspike.test.core.impl.activation; > >> > >> +import org.apache.deltaspike.core.api.activation.Deactivatable; > >> + > >> /** > >> * Class which is deactivated > >> */ > >> -public class DeactivatedClass > >> +public class DeactivatedClass implements Deactivatable > >> { > >> } > >> > >> > >> > > > http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/e3f7e3e4/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/activation/TestClassDeactivation.java > >> ---------------------------------------------------------------------- > >> diff --git > >> > > > a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/activation/TestClassDeactivation.java > >> > > > b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/activation/TestClassDeactivation.java > >> index f5af85d..bb4e7a1 100644 > >> --- > >> > > > a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/activation/TestClassDeactivation.java > >> +++ > >> > > > b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/activation/TestClassDeactivation.java > >> @@ -18,7 +18,7 @@ > >> */ > >> package org.apache.deltaspike.test.core.impl.activation; > >> > >> -import org.apache.deltaspike.core.impl.util.ClassDeactivation; > >> +import org.apache.deltaspike.core.api.activation.ClassDeactivation; > >> import org.apache.deltaspike.test.core.api.provider.TestBean; > >> import > >> org.apache.deltaspike.test.core.api.temptestutil.ShrinkWrapArchiveUtil; > >> import org.apache.deltaspike.test.util.FileUtils; > >> @@ -64,7 +64,7 @@ public class TestClassDeactivation > >> @Test > >> public void testActivatedClass() > >> { > >> - > >> > > > Assert.assertTrue(ClassDeactivation.isClassActivated(ActivatedClass.class)); > >> + > >> > Assert.assertTrue(ClassDeactivation.isActivated(ActivatedClass.class)); > >> } > >> > >> /** > >> @@ -73,6 +73,6 @@ public class TestClassDeactivation > >> @Test > >> public void testDeactivatedClass() > >> { > >> - > >> > > > Assert.assertFalse(ClassDeactivation.isClassActivated(DeactivatedClass.class)); > >> + > >> > Assert.assertFalse(ClassDeactivation.isActivated(DeactivatedClass.class)); > >> } > >> } > >> > >> > >> > > > http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/e3f7e3e4/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/activation/TestClassDeactivator.java > >> ---------------------------------------------------------------------- > >> diff --git > >> > > > a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/activation/TestClassDeactivator.java > >> > > > b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/activation/TestClassDeactivator.java > >> index 2d7557f..e7ec158 100644 > >> --- > >> > > > a/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/activation/TestClassDeactivator.java > >> +++ > >> > > > b/deltaspike/core/impl/src/test/java/org/apache/deltaspike/test/core/impl/activation/TestClassDeactivator.java > >> @@ -18,20 +18,23 @@ > >> */ > >> package org.apache.deltaspike.test.core.impl.activation; > >> > >> -import > org.apache.deltaspike.core.api.activation.AbstractClassDeactivator; > >> + > >> +import org.apache.deltaspike.core.api.activation.ClassDeactivator; > >> +import org.apache.deltaspike.core.api.activation.Deactivatable; > >> > >> /** > >> * Test {@link > org.apache.deltaspike.core.api.activation.ClassDeactivator} > >> - * which is needed to test {@link > >> org.apache.deltaspike.core.impl.util.ClassDeactivation} > >> + * which is needed to test {@link > >> org.apache.deltaspike.core.api.activation.ClassDeactivation} > >> */ > >> -public class TestClassDeactivator extends AbstractClassDeactivator > >> +public class TestClassDeactivator implements ClassDeactivator > >> { > >> - /** > >> - * {@inheritDoc} > >> - */ > >> @Override > >> - protected void deactivateClasses() > >> + public Boolean isActivated(Class<? extends Deactivatable> > >> deactivatableClazz) > >> { > >> - addDeactivatedClass(DeactivatedClass.class); > >> + if (deactivatableClazz.equals(DeactivatedClass.class)) > >> + { > >> + return Boolean.FALSE; > >> + } > >> + return null; > >> } > >> } > >> > >> > >> > > > http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/e3f7e3e4/deltaspike/core/integration-test/src/test/java/org/apache/deltaspike/integration/core/api/exclude/ExcludeIntegrationTest.java > >> ---------------------------------------------------------------------- > >> diff --git > >> > > > a/deltaspike/core/integration-test/src/test/java/org/apache/deltaspike/integration/core/api/exclude/ExcludeIntegrationTest.java > >> > > > b/deltaspike/core/integration-test/src/test/java/org/apache/deltaspike/integration/core/api/exclude/ExcludeIntegrationTest.java > >> index c63a9ba..246c1a1 100644 > >> --- > >> > > > a/deltaspike/core/integration-test/src/test/java/org/apache/deltaspike/integration/core/api/exclude/ExcludeIntegrationTest.java > >> +++ > >> > > > b/deltaspike/core/integration-test/src/test/java/org/apache/deltaspike/integration/core/api/exclude/ExcludeIntegrationTest.java > >> @@ -68,7 +68,8 @@ public class ExcludeIntegrationTest > >> "META-INF/beans.xml", > >> new > > String[]{"org.apache.deltaspike.core", > >> > > "org.apache.deltaspike.integration", > >> - > >> "org.apache.deltaspike.test.core.api.exclude"}, > >> + > >> "org.apache.deltaspike.test.core.api.exclude", > >> + > >> "org.apache.deltaspike.test.core.impl.activation"}, > >> null)) > >> .addClass(IntegrationTestProjectStageProducer.class) > >> > >> .addAsResource(FileUtils.getFileForURL(deltaSpikeConfig.toString()), > >> > >> > >> > > > http://git-wip-us.apache.org/repos/asf/incubator-deltaspike/blob/e3f7e3e4/deltaspike/core/integration-test/src/test/resources/META-INF/apache-deltaspike.properties > >> ---------------------------------------------------------------------- > >> diff --git > >> > > > a/deltaspike/core/integration-test/src/test/resources/META-INF/apache-deltaspike.properties > >> > > > b/deltaspike/core/integration-test/src/test/resources/META-INF/apache-deltaspike.properties > >> index 8a7e771..043eaaa 100644 > >> --- > >> > > > a/deltaspike/core/integration-test/src/test/resources/META-INF/apache-deltaspike.properties > >> +++ > >> > > > b/deltaspike/core/integration-test/src/test/resources/META-INF/apache-deltaspike.properties > >> @@ -18,6 +18,5 @@ > >> deltaspike_ordinal=1001 > >> > >> > >> > > > org.apache.deltaspike.core.impl.projectstage.ProjectStageProducer=org.apache.deltaspike.integration.core.api.projectstage.IntegrationTestProjectStageProducer > >> > >> > > > -org.apache.deltaspike.core.api.activation.ClassDeactivator=org.apache.deltaspike.integration.core.impl.activation.TestClassDeactivator > >> db=itDb > >> > >> > >> > > >
