Skip to content

Commit

Permalink
WFLY-6981 Upgrade Weld to 2.4.0.Final
Browse files Browse the repository at this point in the history
- also remove the dependency on com.google.guava:guava
- also remove unused WeldAnnotationDiscovery
  • Loading branch information
mkouba committed Sep 13, 2016
1 parent 6b61a60 commit 92f54eb
Show file tree
Hide file tree
Showing 17 changed files with 56 additions and 227 deletions.
Expand Up @@ -37,8 +37,6 @@
</resources>

<dependencies>
<module name="ch.qos.cal10n" />
<module name="com.google.guava"/>
<module name="javax.api"/>
<module name="javax.annotation.api"/>
<module name="javax.ejb.api" />
Expand Down Expand Up @@ -82,8 +80,6 @@
<module name="org.jboss.weld.core" />
<module name="org.jboss.weld.spi" />
<module name="org.omg.api"/>
<module name="org.slf4j" />
<module name="org.slf4j.ext" />

<!-- TODO WFLY-5966 validate the need for these and remove if not needed.
Prior to WFLY-5922 they were exported by javax.ejb.api. -->
Expand Down
Expand Up @@ -33,8 +33,6 @@
</resources>

<dependencies>
<module name="ch.qos.cal10n" />
<module name="com.google.guava"/>
<module name="javax.api"/>
<module name="javax.annotation.api"/>
<module name="javax.ejb.api" />
Expand Down
Expand Up @@ -33,8 +33,6 @@
</resources>

<dependencies>
<module name="ch.qos.cal10n" />
<module name="com.google.guava"/>
<module name="javax.api"/>
<module name="javax.annotation.api"/>
<module name="javax.enterprise.api"/>
Expand Down
4 changes: 2 additions & 2 deletions pom.xml
Expand Up @@ -199,8 +199,8 @@
<version.org.jboss.spec.javax.xml.soap.jboss-saaj-api_1.3_spec>1.0.3.Final</version.org.jboss.spec.javax.xml.soap.jboss-saaj-api_1.3_spec>
<version.org.jboss.spec.javax.xml.ws.jboss-jaxws-api_2.2_spec>2.0.3.Final</version.org.jboss.spec.javax.xml.ws.jboss-jaxws-api_2.2_spec>
<version.org.jboss.spec.javax.websockets>1.1.1.Final</version.org.jboss.spec.javax.websockets>
<version.org.jboss.weld.weld>2.3.5.Final</version.org.jboss.weld.weld>
<version.org.jboss.weld.weld-api>2.3.SP2</version.org.jboss.weld.weld-api>
<version.org.jboss.weld.weld>2.4.0.Final</version.org.jboss.weld.weld>
<version.org.jboss.weld.weld-api>2.4.Final</version.org.jboss.weld.weld-api>
<version.org.jboss.ws.api>1.0.3.Final</version.org.jboss.ws.api>
<version.org.jboss.ws.spi>3.1.2.Final</version.org.jboss.ws.spi>
<version.org.jboss.ws.common>3.1.3.Final</version.org.jboss.ws.common>
Expand Down
9 changes: 3 additions & 6 deletions weld/pom.xml
Expand Up @@ -204,11 +204,6 @@
<groupId>org.jboss.weld</groupId>
<artifactId>weld-spi</artifactId>
</dependency>

<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>

<dependency>
<groupId>junit</groupId>
Expand All @@ -219,8 +214,10 @@
<dependency>
<groupId>org.wildfly.core</groupId>
<artifactId>wildfly-subsystem-test</artifactId>
<type>pom</type>
<type>pom</type>
<scope>test</scope>
</dependency>

</dependencies>

</project>
11 changes: 5 additions & 6 deletions weld/src/main/java/org/jboss/as/weld/CdiAnnotations.java
Expand Up @@ -25,10 +25,9 @@

import org.jboss.as.weld.discovery.AnnotationType;
import org.jboss.jandex.DotName;

import com.google.common.base.Function;
import com.google.common.collect.Collections2;
import com.google.common.collect.ImmutableSet;
import org.jboss.weld.util.Function;
import org.jboss.weld.util.collections.ImmutableSet;
import org.jboss.weld.util.collections.Iterables;

/**
* Class that stores the {@link DotName}s of CDI annotations.
Expand Down Expand Up @@ -200,8 +199,8 @@ public String getSimpleName() {

public static final Set<DotName> BUILT_IN_SCOPE_NAMES = ImmutableSet.<DotName>of(DEPENDENT.getDotName(), REQ_SCOPED.getDotName(), CONV_SCOPED.getDotName(), SESS_SCOPED.getDotName(), APP_SCOPED.getDotName(), SINGLETON.getDotName());

public static final Set<AnnotationType> BUILT_IN_SCOPES = ImmutableSet.copyOf(Collections2.transform(BUILT_IN_SCOPE_NAMES,
new Function<DotName, AnnotationType>() {
public static final Set<AnnotationType> BUILT_IN_SCOPES = ImmutableSet
.copyOf(Iterables.transform(BUILT_IN_SCOPE_NAMES, new Function<DotName, AnnotationType>() {
public AnnotationType apply(DotName input) {
return new AnnotationType(input, true);
}
Expand Down
Expand Up @@ -27,8 +27,7 @@
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.weld.bootstrap.api.Service;
import org.jboss.weld.bootstrap.spi.EEModuleDescriptor;

import com.google.common.collect.ImmutableSet;
import org.jboss.weld.util.collections.ImmutableSet;

/**
* A collection of Bean Deployment archives that share similar bean visibility.
Expand Down
Expand Up @@ -25,8 +25,7 @@

import org.jboss.as.server.deployment.AttachmentKey;
import org.jboss.as.server.deployment.module.ResourceRoot;

import com.google.common.collect.ImmutableMap;
import org.jboss.weld.util.collections.ImmutableMap;

/**
* Information about explicit CDI bean archives
Expand Down
Expand Up @@ -31,12 +31,9 @@

import javax.enterprise.inject.spi.Extension;

import org.jboss.as.server.deployment.Attachments;
import org.jboss.as.server.deployment.DeploymentUnit;
import org.jboss.as.server.deployment.annotation.CompositeIndex;
import org.jboss.as.weld.WeldModuleResourceLoader;
import org.jboss.as.weld.deployment.BeanDeploymentArchiveImpl.BeanArchiveType;
import org.jboss.as.weld.discovery.WeldAnnotationDiscovery;
import org.jboss.as.weld.logging.WeldLogger;
import org.jboss.as.weld.services.bootstrap.ProxyServicesImpl;
import org.jboss.modules.Module;
Expand All @@ -49,7 +46,6 @@
import org.jboss.weld.bootstrap.spi.CDI11Deployment;
import org.jboss.weld.bootstrap.spi.EEModuleDescriptor;
import org.jboss.weld.bootstrap.spi.Metadata;
import org.jboss.weld.resources.spi.AnnotationDiscovery;
import org.jboss.weld.resources.spi.ResourceLoader;
import org.jboss.weld.serialization.spi.ProxyServices;
import org.wildfly.security.manager.WildFlySecurityManager;
Expand Down Expand Up @@ -105,11 +101,6 @@ public WeldDeployment(Set<BeanDeploymentArchiveImpl> beanDeploymentArchives, Col
this.serviceRegistry.add(ProxyServices.class, new ProxyServicesImpl(module));
this.serviceRegistry.add(ResourceLoader.class, new WeldModuleResourceLoader(module));

CompositeIndex index = deploymentUnit.getAttachment(Attachments.COMPOSITE_ANNOTATION_INDEX);
if (index != null) {
this.serviceRegistry.add(AnnotationDiscovery.class, new WeldAnnotationDiscovery(index));
}

calculateAccessibilityGraph(this.beanDeploymentArchives);
makeTopLevelBdasVisibleFromStaticModules();
}
Expand Down
Expand Up @@ -12,7 +12,7 @@
import org.jboss.as.server.deployment.DeploymentUnitProcessingException;
import org.jboss.as.weld.logging.WeldLogger;
import org.jboss.weld.bootstrap.spi.Metadata;
import org.jboss.weld.metadata.MetadataImpl;
import org.jboss.weld.bootstrap.spi.helpers.MetadataImpl;

/**
* Container class that is attached to the top level deployment that holds all portable extension metadata.
Expand Down
Expand Up @@ -66,6 +66,7 @@
import org.jboss.as.weld.services.bootstrap.WeldJpaInjectionServices;
import org.jboss.as.weld.util.Indices;
import org.jboss.jandex.AnnotationInstance;
import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.DotName;
import org.jboss.jandex.Index;
import org.jboss.modules.Module;
Expand All @@ -74,11 +75,8 @@
import org.jboss.weld.bootstrap.spi.BeansXml;
import org.jboss.weld.injection.spi.JaxwsInjectionServices;
import org.jboss.weld.injection.spi.JpaInjectionServices;

import com.google.common.collect.Collections2;
import com.google.common.collect.HashMultimap;
import com.google.common.collect.Lists;
import com.google.common.collect.Multimap;
import org.jboss.weld.util.collections.Multimap;
import org.jboss.weld.util.collections.SetMultimap;

/**
* Deployment processor that builds bean archives and attaches them to the deployment
Expand Down Expand Up @@ -132,15 +130,17 @@ public void deploy(DeploymentPhaseContext phaseContext) throws DeploymentUnitPro
/*
* Finish EE component processing
*/
for (Map.Entry<ResourceRoot, ComponentDescription> entry : components.componentDescriptions.entries()) {
for (Entry<ResourceRoot, Collection<ComponentDescription>> entry : components.componentDescriptions.entrySet()) {
BeanDeploymentArchiveImpl bda = bdaMap.get(entry.getKey());
String id = null;
if (bda != null) {
id = bda.getId();
} else {
id = deploymentUnit.getAttachment(WeldAttachments.DEPLOYMENT_ROOT_BEAN_DEPLOYMENT_ARCHIVE).getId();
}
entry.getValue().setBeanDeploymentArchiveId(id);
for (ComponentDescription componentDescription : entry.getValue()) {
componentDescription.setBeanDeploymentArchiveId(id);
}
}

final JpaInjectionServices jpaInjectionServices = new WeldJpaInjectionServices(deploymentUnit);
Expand All @@ -163,8 +163,8 @@ public void undeploy(DeploymentUnit context) {
*/
private static class Components {

private final Multimap<ResourceRoot, ComponentDescription> componentDescriptions = HashMultimap.create();
private final Multimap<ResourceRoot, EJBComponentDescription> ejbComponentDescriptions = HashMultimap.create();
private final Multimap<ResourceRoot, ComponentDescription> componentDescriptions = SetMultimap.newSetMultimap();
private final Multimap<ResourceRoot, EJBComponentDescription> ejbComponentDescriptions = SetMultimap.newSetMultimap();
private final List<ComponentDescription> implicitComponentDescriptions = new ArrayList<ComponentDescription>();

public Components(DeploymentUnit deploymentUnit, Map<ResourceRoot, Index> indexes) {
Expand Down Expand Up @@ -311,7 +311,9 @@ private Set<String> getImplicitBeanClasses(Index index, ResourceRoot resourceRoo
Set<String> implicitBeanClasses = new HashSet<String>();
for (AnnotationType beanDefiningAnnotation : beanDefiningAnnotations) {
List<AnnotationInstance> annotationInstances = index.getAnnotations(beanDefiningAnnotation.getName());
implicitBeanClasses.addAll(Lists.transform(Indices.getAnnotatedClasses(annotationInstances), Indices.CLASS_INFO_TO_FQCN));
for (ClassInfo classInfo : Indices.getAnnotatedClasses(annotationInstances)) {
implicitBeanClasses.add(Indices.CLASS_INFO_TO_FQCN.apply(classInfo));
}
}
// Make all explicit components into implicit beans so they will support injection
for(ComponentDescription description : components.componentDescriptions.get(resourceRoot)) {
Expand All @@ -327,7 +329,9 @@ private BeanDeploymentArchiveImpl createExplicitBeanDeploymentArchive(final Inde
Set<String> classNames = new HashSet<String>();
// index may be null if a war has a beans.xml but no WEB-INF/classes
if (index != null) {
classNames.addAll(Collections2.transform(index.getKnownClasses(), Indices.CLASS_INFO_TO_FQCN));
for (ClassInfo classInfo : index.getKnownClasses()) {
classNames.add(Indices.CLASS_INFO_TO_FQCN.apply(classInfo));
}
}

String beanArchiveId = getDeploymentUnitId(deploymentUnit);
Expand Down
@@ -1,12 +1,12 @@
package org.jboss.as.weld.deployment.processors;

import static com.google.common.collect.Collections2.filter;
import static com.google.common.collect.Collections2.transform;
import static org.jboss.as.weld.discovery.AnnotationType.FOR_CLASSINFO;
import static org.jboss.as.weld.util.Indices.ANNOTATION_PREDICATE;
import static org.jboss.as.weld.util.Indices.getAnnotatedClasses;

import java.util.Collection;
import java.util.HashSet;
import java.util.Set;

import javax.transaction.TransactionScoped;

Expand All @@ -19,6 +19,7 @@
import org.jboss.as.weld.CdiAnnotations;
import org.jboss.as.weld.deployment.WeldAttachments;
import org.jboss.as.weld.discovery.AnnotationType;
import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.DotName;


Expand Down Expand Up @@ -68,7 +69,13 @@ private static void addAnnotation(final DeploymentUnit deploymentUnit, Annotatio
}

private Collection<AnnotationType> getAnnotationsAnnotatedWith(CompositeIndex index, DotName annotationName) {
return transform(filter(getAnnotatedClasses(index.getAnnotations(annotationName)), ANNOTATION_PREDICATE), FOR_CLASSINFO);
Set<AnnotationType> annotations = new HashSet<>();
for (ClassInfo classInfo : getAnnotatedClasses(index.getAnnotations(annotationName))) {
if (ANNOTATION_PREDICATE.test(classInfo)) {
annotations.add(FOR_CLASSINFO.apply(classInfo));
}
}
return annotations;
}

@Override
Expand Down
Expand Up @@ -22,8 +22,7 @@
import org.jboss.as.weld.util.Indices;
import org.jboss.jandex.ClassInfo;
import org.jboss.jandex.DotName;

import com.google.common.base.Function;
import org.jboss.weld.util.Function;

public class AnnotationType {

Expand Down

0 comments on commit 92f54eb

Please sign in to comment.