Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable the CDI Lite LiteExtensionTranslator #23897

Merged
merged 1 commit into from
Apr 11, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
import static com.sun.enterprise.util.Utility.isAnyEmpty;
import static com.sun.enterprise.util.Utility.isAnyNull;
import static com.sun.enterprise.util.Utility.isEmpty;
import static java.lang.System.getSecurityManager;
import static java.security.AccessController.doPrivileged;
import static java.util.Collections.emptyList;
import static java.util.logging.Level.FINE;
import static org.glassfish.cdi.CDILoggerInfo.CREATING_DEPLOYMENT_ARCHIVE;
Expand All @@ -42,6 +44,7 @@
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.security.PrivilegedAction;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Enumeration;
Expand Down Expand Up @@ -73,6 +76,9 @@
import com.sun.enterprise.deployment.EjbDescriptor;

import jakarta.enterprise.inject.spi.Extension;
import org.jboss.weld.bootstrap.spi.helpers.MetadataImpl;
import org.jboss.weld.lite.extension.translator.BuildCompatibleExtensionLoader;
import org.jboss.weld.lite.extension.translator.LiteExtensionTranslator;

/*
* Represents a deployment of a CDI (Weld) application.
Expand Down Expand Up @@ -243,6 +249,22 @@ public Iterable<Metadata<Extension>> getExtensions() {
}

List<Metadata<Extension>> extensionsList = new ArrayList<>();
// Register org.jboss.weld.lite.extension.translator.LiteExtensionTranslator in order to be able to execute build compatible extensions
// Note that we only register this if we discovered at least one implementation of BuildCompatibleExtension
if (!BuildCompatibleExtensionLoader.getBuildCompatibleExtensions().isEmpty()) {
try {
LiteExtensionTranslator extension = getSecurityManager() != null ? doPrivileged(new PrivilegedAction<LiteExtensionTranslator>() {
@Override
public LiteExtensionTranslator run() {
return new LiteExtensionTranslator();
}
}) : new LiteExtensionTranslator();
extensionsList.add(new MetadataImpl<>(extension));
} catch (Exception e) {
throw new RuntimeException(e);
}
}

for (BeanDeploymentArchive beanDeploymentArchive : getBeanDeploymentArchives()) {
if (!(beanDeploymentArchive instanceof RootBeanDeploymentArchive)) {
extensions =
Expand Down