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

fix(CDI) Auto-detect beans on Rest services Refs: #30187 #30417

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
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
13 changes: 13 additions & 0 deletions bom/application/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1154,6 +1154,19 @@
<version>3.1.9.Final</version>
</dependency>

<dependency>
<groupId>org.glassfish.jersey.ext.cdi</groupId>
<artifactId>jersey-cdi1x</artifactId>
<version>${jersey.version}</version>
</dependency>

<dependency>
<groupId>org.glassfish.jersey.ext.cdi</groupId>
<artifactId>jersey-cdi1x-servlet</artifactId>
<version>${jersey.version}</version>
</dependency>


<dependency>
<groupId>org.glassfish.hk2.external</groupId>
<artifactId>bean-validator</artifactId>
Expand Down
11 changes: 11 additions & 0 deletions dotCMS/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -1405,6 +1405,17 @@
<version>3.1.9.Final</version>
</dependency>

<dependency>
<groupId>org.glassfish.jersey.ext.cdi</groupId>
<artifactId>jersey-cdi1x</artifactId>
</dependency>

<!-- This is required keep one single instance of the InjectionManager across all ServletContexts -->
<dependency>
<groupId>org.glassfish.jersey.ext.cdi</groupId>
<artifactId>jersey-cdi1x-servlet</artifactId>
</dependency>

<dependency>
<groupId>org.glassfish.hk2.external</groupId>
<artifactId>bean-validator</artifactId>
Expand Down

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
import org.glassfish.jersey.server.spi.Container;

/**
* A new Reloader will get created on each reload there can only be one container at a time
* A new Re-loader will get created on each reload there can only be one container at a time
*/
@Provider
@ApplicationScoped
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
import io.swagger.v3.jaxrs2.integration.resources.AcceptHeaderOpenApiResource;
import io.swagger.v3.jaxrs2.integration.resources.OpenApiResource;
import org.glassfish.jersey.ext.cdi1x.internal.CdiComponentProvider;
import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.info.Info;
import io.swagger.v3.oas.annotations.servers.Server;
Expand Down Expand Up @@ -57,7 +58,9 @@ public DotRestApplication() {
"com.dotcms.rendering.js",
"com.dotcms.ai.rest",
"io.swagger.v3.jaxrs2"
);
).register(CdiComponentProvider.class);

System.out.println("DotRestApplication: " + this);
}

/**
Expand Down
10 changes: 3 additions & 7 deletions dotCMS/src/main/webapp/WEB-INF/beans.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee"
version="2.0" bean-discovery-mode="annotated">
<scan>
<exclude name="org.apache.**"/>
</scan>
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
version="1.1" bean-discovery-mode="all">
</beans>
8 changes: 2 additions & 6 deletions dotCMS/src/test/resources/META-INF/beans.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee"
version="2.0" bean-discovery-mode="annotated">
<scan>
<exclude name="org.apache.**"/>
</scan>
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
version="1.1" bean-discovery-mode="all">
</beans>
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import com.dotcms.jobs.business.error.RetryStrategy;
import com.dotcms.jobs.business.error.RetryStrategyProducer;
import com.dotcms.jobs.business.queue.JobQueue;
import com.dotcms.jobs.business.queue.JobQueueProducer;
import com.dotcms.rest.api.v1.job.JobQueueHelper;
import org.jboss.weld.bootstrap.api.helpers.RegistrySingletonProvider;
import org.jboss.weld.junit5.WeldInitiator;
Expand All @@ -29,7 +28,7 @@ public class TestBaseJunit5WeldInitiator {
.containerId(RegistrySingletonProvider.STATIC_INSTANCE)
.beanClasses(JobQueueManagerAPIImpl.class, JobQueueConfig.class,
JobQueue.class, RetryStrategy.class, CircuitBreaker.class,
JobQueueProducer.class, JobQueueConfigProducer.class,
JobQueueConfigProducer.class,
RetryStrategyProducer.class, RealTimeJobMonitor.class,
EventProducer.class, JobProcessorFactory.class, JobQueueHelper.class,
JobProcessorScanner.class
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import com.dotcms.jobs.business.error.RetryStrategy;
import com.dotcms.jobs.business.error.RetryStrategyProducer;
import com.dotcms.jobs.business.queue.JobQueue;
import com.dotcms.jobs.business.queue.JobQueueProducer;
import com.dotcms.repackage.org.apache.struts.Globals;
import com.dotcms.repackage.org.apache.struts.config.ModuleConfig;
import com.dotcms.repackage.org.apache.struts.config.ModuleConfigFactory;
Expand Down Expand Up @@ -69,7 +68,6 @@ public void init() throws Exception {
JobQueue.class,
RetryStrategy.class,
CircuitBreaker.class,
JobQueueProducer.class,
JobQueueConfigProducer.class,
RetryStrategyProducer.class,
RealTimeJobMonitor.class,
Expand Down
8 changes: 2 additions & 6 deletions dotcms-integration/src/test/resources/META-INF/beans.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee"
version="2.0" bean-discovery-mode="annotated">
<scan>
<exclude name="org.apache.**"/>
</scan>
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/beans_1_1.xsd"
version="1.1" bean-discovery-mode="all">
</beans>
Loading