Skip to content

Commit

Permalink
WELD-2804 Remove deprecated code parts.
Browse files Browse the repository at this point in the history
Deprecate and mark for removal WeldContainer#instance(); change all remaining SE tests using this method.
Remove deprecation from methods obtaining qualifiers on EnhancedAnnotated - those have been deprecated since early versions but had meanwhile become core part of this API.
  • Loading branch information
manovotn committed Nov 27, 2024
1 parent 8b57e0f commit de7a926
Show file tree
Hide file tree
Showing 22 changed files with 35 additions and 302 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,6 @@ public class Weld extends SeContainerInitializer implements ContainerInstanceFac
*/
public static final String ARCHIVE_ISOLATION_SYSTEM_PROPERTY = "org.jboss.weld.se.archive.isolation";

/**
* Since Weld 5.1.0.Final, this property is deprecated and serves no purpose.
* It will be removed in future versions.
*/
@Deprecated(since = "5.1.0.Final")
public static final String DEV_MODE_SYSTEM_PROPERTY = "org.jboss.weld.development";

/**
* Standard behavior is that empty {@code beans.xml} is treated as discovery mode {@code annotated}.
* This configuration property allows to change the behavior to discovery mode {@code all} which is how it used to work
Expand Down Expand Up @@ -949,18 +942,6 @@ public Weld scanClasspathEntries() {
return property(SCAN_CLASSPATH_ENTRIES_SYSTEM_PROPERTY, true);
}

/**
* Since Weld 5.1.0.Final, this method is deprecated and became no-op.
* It will be removed in future versions.
*
* @return self
* @see #DEV_MODE_SYSTEM_PROPERTY
*/
@Deprecated(since = "5.1.0.Final")
public Weld enableDevMode() {
return property(DEV_MODE_SYSTEM_PROPERTY, true);
}

/**
* Registers annotations which will be considered as bean defining annotations.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.jboss.weld.environment.se;

import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import java.util.Collection;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
Expand Down Expand Up @@ -249,12 +251,16 @@ private void fireContainerInitializedEvent() {
}

/**
* Provides access to all beans within the application. Retained for backward compatibility - WeldContainer implements
* {@linkjakarta.enterprise.inject.Instance}.
* Deprecated - {@code WeldContainer} implements {@linkjakarta.enterprise.inject.Instance} and applications can
* therefore directly perform programmatic lookup from this object.
* See {@link #select(Type, Annotation...)} and other methods.
* <p>
* Provides access to all beans within the application.
*
* @return the instance
* @deprecated Applications are encouraged to use methods for programmatic lookup directly.
*/
@Deprecated(forRemoval = true)
public Instance<Object> instance() {
checkState();
return getInstance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ public void init() {
public void testMainEmptyArgs() {
WeldContainer container = startMain.go();

MainTestBean mainTestBean = container.instance().select(MainTestBean.class).get();
MainTestBean mainTestBean = container.select(MainTestBean.class).get();
assertNotNull(mainTestBean);

ParametersTestBean paramsBean = mainTestBean.getParametersTestBean();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public void testMain() {

assertEquals(container.getId(), RegistrySingletonProvider.STATIC_INSTANCE);

MainTestBean mainTestBean = container.instance().select(MainTestBean.class).get();
MainTestBean mainTestBean = container.select(MainTestBean.class).get();
assertNotNull(mainTestBean);

ParametersTestBean paramsBean = mainTestBean.getParametersTestBean();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public void testInitialize() {
Weld weld = new Weld();
WeldContainer container = weld.initialize();

MainTestBean mainTestBean = container.instance().select(MainTestBean.class).get();
MainTestBean mainTestBean = container.select(MainTestBean.class).get();
assertNotNull(mainTestBean);

ParametersTestBean paramsBean = mainTestBean.getParametersTestBean();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public void testContainerIsolation() {

Weld weld2 = new Weld("2");
WeldContainer weldContainer2 = weld2.initialize();
Foo foo2 = weldContainer2.instance().select(Foo.class).get();
Foo foo2 = weldContainer2.select(Foo.class).get();

foo1.setValue(1);
foo2.setValue(2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public void testPostConstructInherited() {

Plant.postConstructCalled = false;
WeldContainer weldContainer = weld.initialize();
weldContainer.instance().select(Tree.class).get();
weldContainer.select(Tree.class).get();
assertTrue(Plant.postConstructCalled);

} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ public void testSelect() throws Exception {
Weld weld = new Weld();
try {
WeldContainer wc = weld.initialize();
Assert.assertNotNull(wc.instance().select(KPT.class).select(new KPQLiteral()).get());
Assert.assertNotNull(wc.instance().select(KPT.class, new KPQLiteral()).get());
Assert.assertNotNull(wc.select(KPT.class).select(new KPQLiteral()).get());
Assert.assertNotNull(wc.select().select(KPT.class, new KPQLiteral()).get());
} finally {
weld.shutdown();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public class SingletonContextTest {
public void testSingletonBeanLifecycle() {
Weld weld = new Weld();
WeldContainer container = weld.initialize();
assertEquals("bar", container.instance().select(Translator.class).get().translate("hello"));
assertEquals("bar", container.select().select(Translator.class).get().translate("hello"));
assertTrue(Translator.isInitCallbackInvoked);
assertTrue(Dictionary.isInitCallbackInvoked);
weld.shutdown();
Expand Down
8 changes: 0 additions & 8 deletions impl/src/main/java/org/jboss/weld/Container.java
Original file line number Diff line number Diff line change
Expand Up @@ -172,14 +172,6 @@ public BeanManagerImpl getBeanManager(String key) {
return managers.get(key);
}

/**
* @deprecated Use {@link #getBeanManager(String)} instead
*/
@Deprecated
public BeanManagerImpl activityManager(String key) {
return getBeanManager(key);
}

private String addBeanManager(BeanManagerImpl manager) {
String id = manager.getId();
if (manager.getId() == null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
*/
package org.jboss.weld.annotated.enhanced;

import static org.jboss.weld.util.reflection.Reflections.EMPTY_ANNOTATIONS;

import java.lang.annotation.Annotation;
import java.lang.reflect.Type;
import java.util.Set;
Expand All @@ -30,8 +32,7 @@
import org.jboss.weld.util.collections.Arrays2;

/**
* AnnotatedItem provides a uniform access to the annotations on an annotated
* item defined either in Java or XML
* AnnotatedItem provides uniform access to the annotations on an annotated item defined either in Java or XML
*
* @author Pete Muir
*/
Expand Down Expand Up @@ -61,25 +62,27 @@ public interface EnhancedAnnotated<T, S> extends Annotated {

/**
* Gets the binding types for this element
* <p>
* This reflection type should not know about CDI qualifiers.
* However, it is very convenient, so we keep it here.
*
* @returns A set of binding types present on the type. Returns an empty set
* if there are no matches.
* @deprecated This reflection type should not know about JSR-299 binding
* types
*/
@Deprecated
Set<Annotation> getQualifiers();

/**
* Gets the binding types for this element
* <p>
* This reflection type should not know about CDI qualifiers.
* However, it is very convenient, so we keep it here.
*
* @returns An array of binding types present on the type. Returns an empty
* array if there are no matches.
* @deprecated This reflection type should not know about JSR-299 binding
* types
*/
@Deprecated
Annotation[] getBindingsAsArray();
default Annotation[] getBindingsAsArray() {
return getQualifiers().toArray(EMPTY_ANNOTATIONS);
}

/**
* Get the type hierarchy of any interfaces implemented by this class.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
package org.jboss.weld.annotated.enhanced.jlr;

import static org.jboss.weld.util.collections.WeldCollections.immutableMapView;
import static org.jboss.weld.util.reflection.Reflections.EMPTY_ANNOTATIONS;

import java.lang.annotation.Annotation;
import java.lang.reflect.ParameterizedType;
Expand Down Expand Up @@ -225,7 +224,6 @@ public Set<Annotation> getMetaAnnotations(Class<? extends Annotation> metaAnnota
return ImmutableSet.copyOf(metaAnnotationMap.get(metaAnnotationType));
}

@Deprecated
public Set<Annotation> getQualifiers() {
Set<Annotation> qualifiers = getMetaAnnotations(Qualifier.class);
if (qualifiers.size() > 0) {
Expand All @@ -235,11 +233,6 @@ public Set<Annotation> getQualifiers() {
}
}

@Deprecated
public Annotation[] getBindingsAsArray() {
return getQualifiers().toArray(EMPTY_ANNOTATIONS);
}

public <A extends Annotation> A getAnnotation(Class<A> annotationType) {
return annotationType.cast(annotationMap.get(annotationType));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,7 @@ public static ProxyInstantiator create(WeldConfiguration configuration) {
result = DefaultProxyInstantiator.INSTANCE;
}
} else {
result = create(configuration.getBooleanProperty(ConfigurationKey.RELAXED_CONSTRUCTION)
|| configuration.getBooleanProperty(ConfigurationKey.PROXY_UNSAFE));
result = create(configuration.getBooleanProperty(ConfigurationKey.RELAXED_CONSTRUCTION));
}
BootstrapLogger.LOG.debugv("Using instantiator: {0}", result.getClass().getName());
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@
public class WeldStartup {

static {
VersionLogger.LOG.version(Formats.version(null));
VersionLogger.LOG.version(Formats.version());
}

private BeanManagerImpl deploymentManager;
Expand Down
78 changes: 1 addition & 77 deletions impl/src/main/java/org/jboss/weld/config/ConfigurationKey.java
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,7 @@ public enum ConfigurationKey {

/**
* Weld supports a non-standard workaround to be able to create client proxies for Java types that cannot be proxied by the
* container, using non-portable
* JVM APIs.
* container, using non-portable JVM APIs.
*/
@Description("Weld supports a non-standard workaround to be able to create client proxies for Java types that cannot be proxied by the container, using non-portable JVM APIs.")
RELAXED_CONSTRUCTION("org.jboss.weld.construction.relaxed", false),
Expand All @@ -130,16 +129,6 @@ public enum ConfigurationKey {
*/
PROXY_INSTANTIATOR("org.jboss.weld.proxy.instantiator", ""),

/**
* Weld supports a non-standard workaround to be able to create client proxies for Java types that cannot be proxied by the
* container, using non-portable
* JVM APIs.
*
* @deprecated this option is deprecated. RELAXED_CONSTRUCTION should be used instead
*/
@Description("This option is deprecated - <code>org.jboss.weld.construction.relaxed</code> should be used instead.")
PROXY_UNSAFE("org.jboss.weld.proxy.unsafe", false),

/**
* XML descriptor validation is enabled by default.
*/
Expand All @@ -154,30 +143,6 @@ public enum ConfigurationKey {
@Description("For certain combinations of scopes, the container is permitted to optimize an injectable reference lookup. The optimization is disabled by default.")
INJECTABLE_REFERENCE_OPTIMIZATION("org.jboss.weld.injection.injectableReferenceOptimization", false),

/**
* This option is deprecated and has no function since Weld 5.1.0.Final.
* It will be removed in upcoming versions.
*/
@Deprecated(since = "5.1.0.Final")
@Description("This option is deprecated and has no function since Weld 5.1.0.Final.")
PROBE_INVOCATION_MONITOR_EXCLUDE_TYPE("org.jboss.weld.probe.invocationMonitor.excludeType", ""),

/**
* This option is deprecated and has no function since Weld 5.1.0.Final.
* It will be removed in upcoming versions.
*/
@Deprecated(since = "5.1.0.Final")
@Description("This option is deprecated and has no function since Weld 5.1.0.Final.")
PROBE_INVOCATION_MONITOR_SKIP_JAVABEAN_PROPERTIES("org.jboss.weld.probe.invocationMonitor.skipJavaBeanProperties", true),

/**
* This option is deprecated and has no function since Weld 5.1.0.Final.
* It will be removed in upcoming versions.
*/
@Deprecated(since = "5.1.0.Final")
@Description("This option is deprecated and has no function since Weld 5.1.0.Final.")
PROBE_EVENT_MONITOR_EXCLUDE_TYPE("org.jboss.weld.probe.eventMonitor.excludeType", ""),

/**
* This optimization is used to reduce the HTTP session replication overhead. However, the inconsistency detection mechanism
* may cause problems in some
Expand All @@ -186,14 +151,6 @@ public enum ConfigurationKey {
@Description("This optimization is used to reduce the HTTP session replication overhead. However, the inconsistency detection mechanism may cause problems in some development environments.")
BEAN_IDENTIFIER_INDEX_OPTIMIZATION("org.jboss.weld.serialization.beanIdentifierIndexOptimization", true),

/**
* This option is deprecated and has no function since Weld 5.1.0.Final.
* It will be removed in upcoming versions.
*/
@Deprecated(since = "5.1.0.Final")
@Description("This option is deprecated and has no function since Weld 5.1.0.Final.")
PROBE_EMBED_INFO_SNIPPET("org.jboss.weld.probe.embedInfoSnippet", true),

/**
* If set to <code>true</code>, the attributes should be fetched lazily from the backing store for some contexts (e.g.
* attributes of an HTTP session for a
Expand All @@ -202,31 +159,6 @@ public enum ConfigurationKey {
@Description("If set to <code>true</code>, the attributes should be fetched lazily from the backing store for some contexts (e.g. attributes of an HTTP session for a session context).")
CONTEXT_ATTRIBUTES_LAZY_FETCH("org.jboss.weld.context.attributes.lazyFetch", true),

/**
* This option is deprecated and has no function since Weld 5.1.0.Final.
* It will be removed in upcoming versions.
*/
@Deprecated(since = "5.1.0.Final")
@Description("This option is deprecated and has no function since Weld 5.1.0.Final.")
PROBE_JMX_SUPPORT("org.jboss.weld.probe.jmxSupport", false),

/**
* This option is deprecated and has no function since Weld 5.1.0.Final.
* It will be removed in upcoming versions.
*/
@Deprecated(since = "5.1.0.Final")
@Description("This option is deprecated and has no function since Weld 5.1.0.Final.")
PROBE_EVENT_MONITOR_CONTAINER_LIFECYCLE_EVENTS("org.jboss.weld.probe.eventMonitor.containerLifecycleEvents", false),

/**
* This option is deprecated and has no function since Weld 5.1.0.Final.
* It will be removed in upcoming versions.
*/
@Deprecated(since = "5.1.0.Final")
@Description("This option is deprecated and has no function since Weld 5.1.0.Final.")
PROBE_ALLOW_REMOTE_ADDRESS("org.jboss.weld.probe.allowRemoteAddress",
"127.0.0.1|::1|::1%.+|0:0:0:0:0:0:0:1|0:0:0:0:0:0:0:1%.+"),

/**
* Weld supports a non-standard workaround to be able to create proxies for Java types which declare non-private non-static
* final methods. These methods are
Expand Down Expand Up @@ -284,14 +216,6 @@ public enum ConfigurationKey {
@Description("A regular expression. If a non-empty string, then all annotated types whose <code>jakarta.enterprise.inject.spi.AnnotatedType#getJavaClass().getName()</code> matches this pattern are vetoed if not annotated with a bean defining annotation.")
VETO_TYPES_WITHOUT_BEAN_DEFINING_ANNOTATION("org.jboss.weld.bootstrap.vetoTypesWithoutBeanDefiningAnnotation", ""),

/**
* This option is deprecated and has no function since Weld 5.1.0.Final.
* It will be removed in upcoming versions.
*/
@Deprecated(since = "5.1.0.Final")
@Description("This option is deprecated and has no function since Weld 5.1.0.Final.")
PROBE_EXPORT_DATA_AFTER_DEPLOYMENT("org.jboss.weld.probe.exportDataAfterDeployment", ""),

/**
* If set to <code>true</code>:
* <ul>
Expand Down
15 changes: 0 additions & 15 deletions impl/src/main/java/org/jboss/weld/manager/BeanManagerImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -749,21 +749,6 @@ public Object getReference(Bean<?> bean, Type requestedType, CreationalContext<?
}
}

/**
* The name of this method was misleading, use {@link #getInjectableReference(InjectionPoint, Bean, CreationalContext)}
* instead.
*
* @param injectionPoint
* @param resolvedBean
* @param creationalContext
* @return the injectable reference
* @deprecated Use {@link #getInjectableReference(InjectionPoint, Bean, CreationalContext)} instead
*/
@Deprecated
public Object getReference(InjectionPoint injectionPoint, Bean<?> resolvedBean, CreationalContext<?> creationalContext) {
return getInjectableReference(injectionPoint, resolvedBean, creationalContext);
}

/**
* Get a reference, registering the injection point used.
*
Expand Down
Loading

0 comments on commit de7a926

Please sign in to comment.