Skip to content

Commit

Permalink
Enable the CDI Lite LiteExtensionTranslator
Browse files Browse the repository at this point in the history
Signed-off-by: Scott M Stark <starksm64@gmail.com>
  • Loading branch information
starksm64 committed Apr 9, 2022
1 parent ce539d0 commit d6ac4ab
Showing 1 changed file with 22 additions and 0 deletions.
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

0 comments on commit d6ac4ab

Please sign in to comment.