diff --git a/bom/pom.xml b/bom/pom.xml index ebf51e0c..c1ad7bda 100644 --- a/bom/pom.xml +++ b/bom/pom.xml @@ -30,7 +30,6 @@ 3.2.8 - 1.7.0 https://repository.jboss.org/nexus/service/local/staging/deploy/maven2/ https://repository.jboss.org/nexus/content/repositories/snapshots/ diff --git a/pom.xml b/pom.xml index dfeb7242..ebc2ce69 100644 --- a/pom.xml +++ b/pom.xml @@ -99,12 +99,10 @@ 2.0.1 5.0.0 4.0.1 - 4.0.0 4.0.0-M6 2.0.1 2.2.0 6.1.0 - 3.1.1 @@ -115,12 +113,6 @@ ${jpa.api.version} - - jakarta.validation - jakarta.validation-api - ${validation.api.version} - - jakarta.inject jakarta.inject-api @@ -157,12 +149,6 @@ ${interceptor.api.version} - - jakarta.ws.rs - jakarta.ws.rs-api - ${jaxrs.api.version} - - jakarta.annotation jakarta.annotation-api diff --git a/weld-spi/pom.xml b/weld-spi/pom.xml index 6a335212..8679cdcd 100644 --- a/weld-spi/pom.xml +++ b/weld-spi/pom.xml @@ -19,6 +19,11 @@ + + jakarta.cdi + jakarta.cdi-el-api + + org.jboss.weld weld-api @@ -55,12 +60,6 @@ true - - jakarta.validation - jakarta.validation-api - true - - jakarta.ejb jakarta.ejb-api diff --git a/weld-spi/src/main/java/org/jboss/weld/bootstrap/api/SingletonProvider.java b/weld-spi/src/main/java/org/jboss/weld/bootstrap/api/SingletonProvider.java index ae525d2e..aaf5fb6d 100644 --- a/weld-spi/src/main/java/org/jboss/weld/bootstrap/api/SingletonProvider.java +++ b/weld-spi/src/main/java/org/jboss/weld/bootstrap/api/SingletonProvider.java @@ -38,8 +38,6 @@ public abstract class SingletonProvider { */ private static volatile SingletonProvider INSTANCE; - private static final String DEFAULT_SCOPE_FACTORY = RegistrySingletonProvider.class.getName(); - /** * Returns a singleton instance of this class. * @@ -76,12 +74,7 @@ protected SingletonProvider() { * Initialize with the default instance */ private static void initializeWithDefaultScope() { - try { - Class aClass = Class.forName(DEFAULT_SCOPE_FACTORY); - INSTANCE = (SingletonProvider) aClass.newInstance(); - } catch (Exception e) { - throw new RuntimeException(e); - } + INSTANCE = new RegistrySingletonProvider(); } /** diff --git a/weld-spi/src/main/java/org/jboss/weld/bootstrap/api/helpers/ServiceRegistries.java b/weld-spi/src/main/java/org/jboss/weld/bootstrap/api/helpers/ServiceRegistries.java index 6525a7be..3636c277 100644 --- a/weld-spi/src/main/java/org/jboss/weld/bootstrap/api/helpers/ServiceRegistries.java +++ b/weld-spi/src/main/java/org/jboss/weld/bootstrap/api/helpers/ServiceRegistries.java @@ -16,6 +16,14 @@ */ package org.jboss.weld.bootstrap.api.helpers; +import java.util.AbstractMap; +import java.util.Collection; +import java.util.Collections; +import java.util.Iterator; +import java.util.Map; +import java.util.Map.Entry; +import java.util.Set; + import org.jboss.weld.bootstrap.api.Service; import org.jboss.weld.bootstrap.api.ServiceRegistry; @@ -28,19 +36,46 @@ private ServiceRegistries() { } /** - * Returns an unmodifiable version of provided {@link ServiceRegistry} where any attempt to add a service results in an - * exception + * Returns a view of the provided {@link ServiceRegistry} that prevents adding, removing or replacing registrations. + * Changes made through the original registry remain visible. Service cleanup operations are still delegated. * * @param serviceRegistry service registry to process * @return unmodifiable variant */ public static ServiceRegistry unmodifiableServiceRegistry(final ServiceRegistry serviceRegistry) { + Map, Service> services = Collections.unmodifiableMap(new AbstractMap<>() { + @Override + public Set, Service>> entrySet() { + return serviceRegistry.entrySet(); + } + }); return new ForwardingServiceRegistry() { - public void add(java.lang.Class type, S service) { + @Override + public void add(Class type, S service) { + throw new UnsupportedOperationException("This service registry is unmodifiable"); + } + + @Override + public S addIfAbsent(Class type, S service) { + throw new UnsupportedOperationException("This service registry is unmodifiable"); + } + + @Override + public void addAll(Collection, Service>> services) { throw new UnsupportedOperationException("This service registry is unmodifiable"); } + @Override + public Set, Service>> entrySet() { + return services.entrySet(); + } + + @Override + public Iterator iterator() { + return services.values().iterator(); + } + @Override protected ServiceRegistry delegate() { return serviceRegistry; diff --git a/weld-spi/src/main/java/org/jboss/weld/bootstrap/api/helpers/SimpleServiceRegistry.java b/weld-spi/src/main/java/org/jboss/weld/bootstrap/api/helpers/SimpleServiceRegistry.java index 15d57bd7..fa5c21e7 100644 --- a/weld-spi/src/main/java/org/jboss/weld/bootstrap/api/helpers/SimpleServiceRegistry.java +++ b/weld-spi/src/main/java/org/jboss/weld/bootstrap/api/helpers/SimpleServiceRegistry.java @@ -113,40 +113,12 @@ public int hashCode() { @Override public boolean equals(Object obj) { - if (obj instanceof Map) { - return services.equals(obj); - } else { - return false; - } + return this == obj || obj instanceof SimpleServiceRegistry + && services.equals(((SimpleServiceRegistry) obj).services); } public Iterator iterator() { - return new ValueIterator, Service>() { - - @Override - protected Iterator, Service>> delegate() { - return services.entrySet().iterator(); - } - - }; - } - - private abstract static class ValueIterator implements Iterator { - - protected abstract Iterator> delegate(); - - public boolean hasNext() { - return delegate().hasNext(); - } - - public V next() { - return delegate().next().getValue(); - } - - public void remove() { - delegate().remove(); - } - + return services.values().iterator(); } @Override diff --git a/weld-spi/src/main/java/org/jboss/weld/bootstrap/spi/BeanDiscoveryMode.java b/weld-spi/src/main/java/org/jboss/weld/bootstrap/spi/BeanDiscoveryMode.java index b4f5185b..dcb2e3b2 100644 --- a/weld-spi/src/main/java/org/jboss/weld/bootstrap/spi/BeanDiscoveryMode.java +++ b/weld-spi/src/main/java/org/jboss/weld/bootstrap/spi/BeanDiscoveryMode.java @@ -19,7 +19,7 @@ /** * Represents the value of the bean-discovery-mode attribute within beans.xml. If a * beans.xml file does not contain the bean-discovery-mode attribute, the value defaults to - * {@link BeanDiscoveryMode#ALL}. + * {@link BeanDiscoveryMode#ANNOTATED}. * * @author Jozef Hartinger * diff --git a/weld-spi/src/main/java/org/jboss/weld/bootstrap/spi/Deployment.java b/weld-spi/src/main/java/org/jboss/weld/bootstrap/spi/Deployment.java index ffeadfcb..2cb2b783 100644 --- a/weld-spi/src/main/java/org/jboss/weld/bootstrap/spi/Deployment.java +++ b/weld-spi/src/main/java/org/jboss/weld/bootstrap/spi/Deployment.java @@ -140,14 +140,9 @@ public interface Deployment { /** * Specifies the extensions this deployment should call observer methods on. * - * JSR-299 specifies that extensions should be loaded using Service Providers from the JAR - * File specification - * - * Weld delegates this task to the container, allowing the container to programatically alter the extensions registered. To - * load extensions, the container could use the {@link ServiceLoader} available in the JDK (since Java 6). In pre Java 6 - * environments, the container must provide the ServiceLoader itself. We provide an example Service Loader here. + * CDI extensions are registered as service providers for {@link Extension}. + * Weld delegates loading to the container, allowing it to programmatically alter the registered extensions. + * The container can use {@link ServiceLoader} to discover extension providers. * * @return the extensions to call observer methods on, or an empty list if there are no observers */ diff --git a/weld-spi/src/main/java/org/jboss/weld/manager/api/WeldManager.java b/weld-spi/src/main/java/org/jboss/weld/manager/api/WeldManager.java index 9945d99c..bd090044 100644 --- a/weld-spi/src/main/java/org/jboss/weld/manager/api/WeldManager.java +++ b/weld-spi/src/main/java/org/jboss/weld/manager/api/WeldManager.java @@ -226,13 +226,15 @@ public interface WeldManager extends BeanManager, ELAwareBeanManager, Serializab * * Note that for each scope, there might be more than one {@link Context}, but there can be at most one active at a time. * + * The default implementation returns a snapshot of the active contexts. + * * @return Collection of all currently active {@link Context}s */ default Collection getActiveContexts() { return getScopes().stream() .filter(this::isContextActive) .map(this::getContext) - .collect(Collectors.toSet()); + .collect(Collectors.toUnmodifiableSet()); } /** @@ -243,6 +245,8 @@ default Collection getActiveContexts() { * This method can therefore return an incomplete view of all active contexts as not every context implements * {@link WeldAlterableContext}. * + * The default implementation returns a snapshot of the active contexts implementing {@link WeldAlterableContext}. + * * @return Collection of all active contexts implementing {@link WeldAlterableContext} */ default Collection getActiveWeldAlterableContexts() { @@ -251,18 +255,7 @@ default Collection getActiveWeldAlterableContexts() { .map(this::getContext) .filter(t -> t instanceof WeldAlterableContext) .map(t -> (WeldAlterableContext) t) - .collect(Collectors.toSet()); + .collect(Collectors.toUnmodifiableSet()); } - /** - * Obtains all {@linkplain Context context objects}, active and inactive, for the given - * {@linkplain jakarta.enterprise.context scope}. - *

- * This feature is planned to be added into specification as part of - * this issue. - * - * @param scopeType the {@linkplain jakarta.enterprise.context scope}; must not be {@code null} - * @return immutable collection of {@linkplain Context context objects}; never {@code null}, but may be empty - */ - Collection getContexts(Class scopeType); } diff --git a/weld-spi/src/test/java/org/jboss/weld/bootstrap/api/test/ServiceRegistriesTest.java b/weld-spi/src/test/java/org/jboss/weld/bootstrap/api/test/ServiceRegistriesTest.java new file mode 100644 index 00000000..789f24ad --- /dev/null +++ b/weld-spi/src/test/java/org/jboss/weld/bootstrap/api/test/ServiceRegistriesTest.java @@ -0,0 +1,66 @@ +package org.jboss.weld.bootstrap.api.test; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertSame; +import static org.testng.Assert.assertTrue; +import static org.testng.Assert.expectThrows; + +import java.util.Iterator; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.concurrent.atomic.AtomicBoolean; + +import org.jboss.weld.bootstrap.api.Service; +import org.jboss.weld.bootstrap.api.ServiceRegistry; +import org.jboss.weld.bootstrap.api.helpers.ServiceRegistries; +import org.jboss.weld.bootstrap.api.helpers.SimpleServiceRegistry; +import org.testng.annotations.Test; + +public class ServiceRegistriesTest { + + @Test + public void unmodifiableRegistryRejectsAllRegistrationChanges() { + ServiceRegistry backing = new SimpleServiceRegistry(); + Service original = () -> { + }; + Service replacement = () -> { + }; + backing.add(Service.class, original); + ServiceRegistry view = ServiceRegistries.unmodifiableServiceRegistry(backing); + + expectThrows(UnsupportedOperationException.class, () -> view.add(Service.class, replacement)); + expectThrows(UnsupportedOperationException.class, () -> view.addIfAbsent(Service.class, replacement)); + expectThrows(UnsupportedOperationException.class, () -> view.addIfAbsent(MockService.class, new MockService() { + })); + expectThrows(UnsupportedOperationException.class, + () -> view.addAll(List.of(Map.entry(Service.class, replacement)))); + expectThrows(UnsupportedOperationException.class, () -> view.entrySet().clear()); + expectThrows(UnsupportedOperationException.class, + () -> view.entrySet().iterator().next().setValue(replacement)); + Iterator, Service>> entries = view.entrySet().iterator(); + entries.next(); + expectThrows(UnsupportedOperationException.class, entries::remove); + Iterator services = view.iterator(); + assertSame(services.next(), original); + expectThrows(UnsupportedOperationException.class, services::remove); + assertFalse(services.hasNext()); + assertSame(backing.get(Service.class), original); + assertEquals(backing.entrySet().size(), 1); + } + + @Test + public void unmodifiableRegistryRemainsLiveAndDelegatesCleanup() { + ServiceRegistry backing = new SimpleServiceRegistry(); + ServiceRegistry view = ServiceRegistries.unmodifiableServiceRegistry(backing); + Set, Service>> entries = view.entrySet(); + AtomicBoolean cleaned = new AtomicBoolean(); + Service service = () -> cleaned.set(true); + backing.add(Service.class, service); + assertSame(view.get(Service.class), service); + assertEquals(entries.size(), 1); + view.cleanup(); + assertTrue(cleaned.get()); + } +} diff --git a/weld-spi/src/test/java/org/jboss/weld/bootstrap/api/test/SimpleServiceRegistryTest.java b/weld-spi/src/test/java/org/jboss/weld/bootstrap/api/test/SimpleServiceRegistryTest.java new file mode 100644 index 00000000..b0a8a9ff --- /dev/null +++ b/weld-spi/src/test/java/org/jboss/weld/bootstrap/api/test/SimpleServiceRegistryTest.java @@ -0,0 +1,78 @@ +package org.jboss.weld.bootstrap.api.test; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertFalse; +import static org.testng.Assert.assertTrue; +import static org.testng.Assert.expectThrows; + +import java.util.HashSet; +import java.util.Iterator; +import java.util.NoSuchElementException; +import java.util.Set; + +import org.jboss.weld.bootstrap.api.Service; +import org.jboss.weld.bootstrap.api.helpers.SimpleServiceRegistry; +import org.testng.annotations.Test; + +public class SimpleServiceRegistryTest { + + @Test + public void iteratorVisitsEachServiceAndTerminates() { + SimpleServiceRegistry registry = new SimpleServiceRegistry(); + Service first = () -> { + }; + MockService second = new MockService() { + }; + registry.add(Service.class, first); + registry.add(MockService.class, second); + + Iterator iterator = registry.iterator(); + Set visited = new HashSet<>(); + assertTrue(iterator.hasNext()); + visited.add(iterator.next()); + assertTrue(iterator.hasNext()); + visited.add(iterator.next()); + assertFalse(iterator.hasNext()); + assertEquals(visited, Set.of(first, second)); + expectThrows(NoSuchElementException.class, iterator::next); + } + + @Test + public void iteratorSupportsRemoval() { + SimpleServiceRegistry registry = new SimpleServiceRegistry(); + registry.add(Service.class, () -> { + }); + Iterator iterator = registry.iterator(); + expectThrows(IllegalStateException.class, iterator::remove); + iterator.next(); + iterator.remove(); + assertFalse(registry.contains(Service.class)); + assertFalse(iterator.hasNext()); + expectThrows(IllegalStateException.class, iterator::remove); + } + + @Test + public void equalityComparesRegistriesAndPreservesTheObjectContract() { + SimpleServiceRegistry first = new SimpleServiceRegistry(); + SimpleServiceRegistry second = new SimpleServiceRegistry(); + SimpleServiceRegistry third = new SimpleServiceRegistry(); + Service service = () -> { + }; + first.add(Service.class, service); + second.add(Service.class, service); + third.add(Service.class, service); + + assertTrue(first.equals(first)); + assertTrue(first.equals(second)); + assertTrue(second.equals(first)); + assertTrue(second.equals(third)); + assertTrue(first.equals(third)); + assertEquals(first.hashCode(), second.hashCode()); + assertFalse(first.equals(null)); + assertFalse(first.equals(java.util.Map.of(Service.class, service))); + second.add(MockService.class, new MockService() { + }); + assertFalse(first.equals(second)); + assertFalse(second.equals(first)); + } +} diff --git a/weld/pom.xml b/weld/pom.xml index 18b33b6e..bc0ce802 100644 --- a/weld/pom.xml +++ b/weld/pom.xml @@ -25,11 +25,6 @@ jakarta.cdi-api - - jakarta.cdi - jakarta.cdi-el-api - - jakarta.servlet jakarta.servlet-api diff --git a/weld/src/main/java/org/jboss/weld/bootstrap/event/WeldAfterBeanDiscovery.java b/weld/src/main/java/org/jboss/weld/bootstrap/event/WeldAfterBeanDiscovery.java index 5033acf6..797999ce 100644 --- a/weld/src/main/java/org/jboss/weld/bootstrap/event/WeldAfterBeanDiscovery.java +++ b/weld/src/main/java/org/jboss/weld/bootstrap/event/WeldAfterBeanDiscovery.java @@ -42,7 +42,7 @@ public interface WeldAfterBeanDiscovery extends AfterBeanDiscovery { InterceptorConfigurator addInterceptor(); /** - * Obtain a {@link WeldBeanConfigurator}, an extended version of {@link BeanConfigurator}. + * Obtain a {@link WeldBeanConfigurator}, a compatibility interface for {@link BeanConfigurator}. *

* The configurator behaves in the same manner as {@link BeanConfigurator}. * Configured bean is added automatically at the end of the observer invocation. @@ -52,7 +52,11 @@ public interface WeldAfterBeanDiscovery extends AfterBeanDiscovery { *

* * @return a configurator to configure custom new bean + * @deprecated use {@link AfterBeanDiscovery#addBean()} through the standard {@link AfterBeanDiscovery} interface + * and use {@link BeanConfigurator} as the configurator type. This override only narrows the return type + * and provides no additional functionality. */ + @Deprecated(since = "7.0", forRemoval = true) @Override public WeldBeanConfigurator addBean(); diff --git a/weld/src/main/java/org/jboss/weld/bootstrap/event/WeldBeanConfigurator.java b/weld/src/main/java/org/jboss/weld/bootstrap/event/WeldBeanConfigurator.java index 9b461b06..5e6cc0b9 100644 --- a/weld/src/main/java/org/jboss/weld/bootstrap/event/WeldBeanConfigurator.java +++ b/weld/src/main/java/org/jboss/weld/bootstrap/event/WeldBeanConfigurator.java @@ -27,16 +27,18 @@ import jakarta.enterprise.inject.spi.AnnotatedType; import jakarta.enterprise.inject.spi.BeanAttributes; import jakarta.enterprise.inject.spi.InjectionPoint; -import jakarta.enterprise.inject.spi.Prioritized; import jakarta.enterprise.inject.spi.configurator.BeanConfigurator; import jakarta.enterprise.util.TypeLiteral; -import jakarta.interceptor.Interceptor.Priority; /** - * Represents an enhanced version of {@link BeanConfigurator} + * A compatibility interface providing covariant return types for {@link BeanConfigurator}. * * @author Matej Novotny + * @param the bean type + * @deprecated use {@link BeanConfigurator}, which provides all of this interface's functionality. + * New configurator methods are inherited with the standard return type. */ +@Deprecated(since = "7.0", forRemoval = true) public interface WeldBeanConfigurator extends BeanConfigurator { @Override @@ -132,17 +134,6 @@ public interface WeldBeanConfigurator extends BeanConfigurator { @Override WeldBeanConfigurator beanClass(Class beanClass); - /** - * NOTE: Since CDI 4.0, this is now part of standard API! - *

- * Allows to set a priority to an alternative bean hence selecting it globally. - * Has the same effect as putting {@link Priority} annotation on an actual bean class - * or implementing {@link Prioritized} interface with custom bean classes. - * This method has no effect on custom beans which are not alternatives. - * - * @param priority the priority of this bean - * @return self - */ @Override WeldBeanConfigurator priority(int priority); } diff --git a/weld/src/main/java/org/jboss/weld/context/activator/ActivateRequestContext.java b/weld/src/main/java/org/jboss/weld/context/activator/ActivateRequestContext.java index 5caf39c0..dd1562f5 100644 --- a/weld/src/main/java/org/jboss/weld/context/activator/ActivateRequestContext.java +++ b/weld/src/main/java/org/jboss/weld/context/activator/ActivateRequestContext.java @@ -39,7 +39,9 @@ * @author Tomas Remes * @author Martin Kouba * @see RequestScoped + * @deprecated use {@link jakarta.enterprise.context.control.ActivateRequestContext}. */ +@Deprecated(since = "7.0", forRemoval = true) @InterceptorBinding @Retention(RUNTIME) @Target({ METHOD, TYPE }) @@ -47,7 +49,10 @@ /** * Annotation literal for {@link ActivateRequestContext} + * + * @deprecated use {@link AnnotationLiteral} with {@link jakarta.enterprise.context.control.ActivateRequestContext}. */ + @Deprecated(since = "7.0", forRemoval = true) class Literal extends AnnotationLiteral implements ActivateRequestContext { /** diff --git a/weld/src/main/java/org/jboss/weld/inject/WeldInstance.java b/weld/src/main/java/org/jboss/weld/inject/WeldInstance.java index aafea3ba..67c1f49c 100644 --- a/weld/src/main/java/org/jboss/weld/inject/WeldInstance.java +++ b/weld/src/main/java/org/jboss/weld/inject/WeldInstance.java @@ -19,14 +19,9 @@ import java.lang.annotation.Annotation; import java.lang.reflect.Type; import java.util.Comparator; -import java.util.stream.Stream; -import java.util.stream.StreamSupport; import jakarta.enterprise.context.Dependent; -import jakarta.enterprise.inject.AmbiguousResolutionException; import jakarta.enterprise.inject.Instance; -import jakarta.enterprise.inject.UnsatisfiedResolutionException; -import jakarta.enterprise.inject.spi.Bean; import jakarta.enterprise.inject.spi.Prioritized; import jakarta.enterprise.util.TypeLiteral; @@ -34,11 +29,9 @@ * Represents an enhanced version of {@link Instance}. * *

- * In the following example we filter out beans which are not {@link Dependent} then sort the beans by priority and use the - * handler whose bean has the highest - * priority (according to {@link #getPriorityComparator()}) to obtain the hello string. Note that contextual references for - * beans with lower priority are not - * created at all. + * In the following example we filter out beans which are not {@link Dependent}, sort the beans by priority, and use the + * handle whose bean has the highest priority (according to {@link #getHandlePriorityComparator()}) to obtain the hello string. + * Contextual references for beans with lower priority are not created at all. *

* *
@@ -49,8 +42,8 @@
  *     WeldInstance<HelloProvider> instance;
  *
  *     String hello() {
- *         HelloProvider helloProvider = instance.handlersStream().filter(h -> h.getBean().getScope().equals(Dependent.class))
- *                 .sorted(instance.getPriorityComparator()).findFirst().map(Handler::get).orElse(null);
+ *         HelloProvider helloProvider = instance.handlesStream().filter(h -> h.getBean().getScope().equals(Dependent.class))
+ *                 .sorted(instance.getHandlePriorityComparator()).findFirst().map(Instance.Handle::get).orElse(null);
  *         if (helloProvider != null)
  *             return helloProvider.getHello();
  *         return "No hello provider found!";
@@ -64,70 +57,6 @@
  */
 public interface WeldInstance extends Instance {
 
-    /**
-     * This method is deprecated as a similar functioning method exists in CDI 4.0 and newer.
-     * Users should instead use {@link Instance#getHandle()}.
-     *
-     * Obtains an initialized contextual reference handler for the bean that has the required type and required qualifiers and
-     * is eligible for injection.
-     *
-     * 

- * The contextual reference is obtained lazily, i.e. when first needed. - *

- * - * @return a new handler - * @throws UnsatisfiedResolutionException if there is no bean with given type and qualifiers - * @throws AmbiguousResolutionException if there is more than one bean given type and qualifiers - */ - @Deprecated - Handler getHandler(); - - /** - * This method is deprecated as a similar functioning method exists in CDI 4.0 and newer. - * Users should instead use {@link Instance#handles()}. - * - * Allows to iterate over contextual reference handlers for all the beans that have the required type and required - * qualifiers and are eligible - * for injection. - * - *

- * Note that the returned {@link Iterable} is stateless and so each {@link Iterable#iterator()} produces a new set of - * handlers. - *

- * - * @return a new iterable - */ - @Deprecated - Iterable> handlers(); - - /** - * This method is deprecated as a similar functioning method exists in CDI 4.0 and newer. - * Users should instead use {@link Instance#handlesStream()}. - * - * @return a new stream of contextual reference handlers - */ - @Deprecated - default Stream> handlersStream() { - return StreamSupport.stream(handlers().spliterator(), false); - } - - /** - * This method is deprecated in favor of {@link WeldInstance#getHandlePriorityComparator()} which operates on - * a non-deprecated {@link Instance.Handle} interface. - * - * The returned comparator sorts handlers by priority in descending order. - *
    - *
  • A class-based bean whose annotated type has {@code jakarta.annotation.Priority} has the priority of value - * {@code jakarta.annotation.Priority#value()}
  • - *
  • A custom bean which implements {@link Prioritized} has the priority of value {@link Prioritized#getPriority()}
  • - *
  • Any other bean has the priority of value 0
  • - *
- * - * @return a comparator instance - */ - @Deprecated - Comparator> getPriorityComparator(); - /** * The returned comparator sorts handles by priority in descending order. *
    @@ -168,57 +97,4 @@ default Stream> handlersStream() { */ WeldInstance select(Type subtype, Annotation... qualifiers); - /** - * This interface is deprecated. - * CDI 4.0 introduced {@link Instance.Handle} interface that offers the same functionality and can be used in place - * of Weld specific {@link WeldInstance.Handler}. - * - * This interface represents a contextual reference handler. - *

    - * Allows to inspect the metadata of the relevant bean and also to destroy the underlying contextual instance. - *

    - * - * @author Martin Kouba - * @param the required bean type - */ - @Deprecated - interface Handler extends Handle { - - /** - * The contextual reference is obtained lazily, i.e. when first needed. - * - * @return the contextual reference - * @see Instance#get() - * @throws IllegalStateException If the producing {@link WeldInstance} does not exist - */ - T get(); - - /** - * - * @return the bean metadata - */ - Bean getBean(); - - /** - * Destroy the contextual instance. - * - * It's a no-op if: - *
      - *
    • called multiple times
    • - *
    • if the producing {@link WeldInstance} does not exist
    • - *
    • if the handler does not hold a contextual reference, i.e. {@link #get()} was never called
    • - *
    - * - * @see Instance#destroy(Object) - */ - void destroy(); - - /** - * Delegates to {@link #destroy()}. - */ - @Override - void close(); - - } - -} \ No newline at end of file +} diff --git a/weld/src/main/java/org/jboss/weld/interceptor/WeldInvocationContext.java b/weld/src/main/java/org/jboss/weld/interceptor/WeldInvocationContext.java deleted file mode 100644 index ee9d0617..00000000 --- a/weld/src/main/java/org/jboss/weld/interceptor/WeldInvocationContext.java +++ /dev/null @@ -1,50 +0,0 @@ -/* - * JBoss, Home of Professional Open Source - * Copyright 2014, Red Hat, Inc., and individual contributors - * by the @authors tag. See the copyright.txt in the distribution for a - * full listing of individual contributors. - * - * Licensed 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.jboss.weld.interceptor; - -import java.lang.annotation.Annotation; -import java.util.Set; - -import jakarta.interceptor.InvocationContext; - -/** - * Represents an enhanced version of {@link InvocationContext}. - * - * @author Martin Kouba - * @see CDI-468 - */ -public interface WeldInvocationContext extends InvocationContext { - - /** - * Deprecated, users are encouraged to use {@link InvocationContext#getInterceptorBindings()} instead. - *

    - * A key value under which we store interceptor bindings in {@link InvocationContext} - */ - @Deprecated - String INTERCEPTOR_BINDINGS_KEY = "org.jboss.weld.interceptor.bindings"; - - /** - * @deprecated use {@link #getInterceptorBindings(Class)} - * - * @param annotationType type of the interceptor binding annotations - * @return immutable set of interceptor binding annotations of given type, never null - * @param annotation type - */ - @Deprecated - Set getInterceptorBindingsByType(Class annotationType); - -} \ No newline at end of file diff --git a/weld/src/main/java/org/jboss/weld/invoke/WeldInvokerBuilder.java b/weld/src/main/java/org/jboss/weld/invoke/WeldInvokerBuilder.java index 03046f76..86a26529 100644 --- a/weld/src/main/java/org/jboss/weld/invoke/WeldInvokerBuilder.java +++ b/weld/src/main/java/org/jboss/weld/invoke/WeldInvokerBuilder.java @@ -52,9 +52,9 @@ * we can set up the lookup and transformations and build an invoker like so: * *

    - * builder.setInstanceLookup()
    - *         .setArgumentTransformer(0, String.class, "toUpperCase")
    - *         .setReturnValueTransformer(Transformations.class, "repeatTwice")
    + * builder.withInstanceLookup()
    + *         .withArgumentTransformer(0, String.class, "toUpperCase")
    + *         .withReturnValueTransformer(Transformations.class, "repeatTwice")
      *         .build();
      * 
    * @@ -263,7 +263,7 @@ * deployment, as described in previous sections. Other types are checked during invocation, * at the very least due to the type checks performed implicitly by the JVM. The lookups, * transformers and the wrapper must arrange the inputs and outputs so that when the method - * is eventually invoked, the rules described in + * is eventually invoked, the rules described in {@link Invoker#invoke(Object, Object[]) Invoker.invoke()} are satisfied. */ public interface WeldInvokerBuilder extends InvokerBuilder { @Override