You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tomee.apache.org by rz...@apache.org on 2024/03/26 20:32:57 UTC

(tomee) branch main updated: TOMEE-4307 - Batchee Downgrade to 1.0.4 (#1115)

This is an automated email from the ASF dual-hosted git repository.

rzo1 pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomee.git


The following commit(s) were added to refs/heads/main by this push:
     new d8c99fd5b8 TOMEE-4307 - Batchee Downgrade to 1.0.4 (#1115)
d8c99fd5b8 is described below

commit d8c99fd5b84e8e81d74fd204ec88eaf8fb26f334
Author: Richard Zowalla <13...@users.noreply.github.com>
AuthorDate: Tue Mar 26 21:32:52 2024 +0100

    TOMEE-4307 - Batchee Downgrade to 1.0.4 (#1115)
    
    * Downgrade to BatchEE 1.0.3 (Jakarta) to avoid henn-egg issues
    
    * small test
    
    * Small test for batchee
    
    * BatchEE 1.0.4 (with CDI-4 fix)
---
 boms/tomee-plume/pom.xml                           |  3 +-
 boms/tomee-plus/pom.xml                            |  3 +-
 container/openejb-core/pom.xml                     |  9 +++-
 .../org/apache/openejb/batchee/InjectionsMock.java | 58 ++++++++++++++++++++++
 .../org/apache/openejb/batchee/InjectionsTest.java | 56 +++++++++++++++++++++
 .../resources/META-INF/batch-jobs/injections.xml   | 24 +++++++++
 pom.xml                                            |  3 +-
 tomee/tomee-plume-webapp/pom.xml                   |  9 +++-
 tomee/tomee-plus-webapp/pom.xml                    |  9 +++-
 9 files changed, 165 insertions(+), 9 deletions(-)

diff --git a/boms/tomee-plume/pom.xml b/boms/tomee-plume/pom.xml
index 58a97d758e..72ee26a1a5 100644
--- a/boms/tomee-plume/pom.xml
+++ b/boms/tomee-plume/pom.xml
@@ -554,7 +554,8 @@
     <dependency>
       <groupId>org.apache.batchee</groupId>
       <artifactId>batchee-jbatch</artifactId>
-      <version>2.0.0-SNAPSHOT</version>
+      <version>1.0.4</version>
+      <classifier>jakarta</classifier>
       <exclusions>
         <exclusion>
           <artifactId>*</artifactId>
diff --git a/boms/tomee-plus/pom.xml b/boms/tomee-plus/pom.xml
index 5ae295cda6..cf1c493345 100644
--- a/boms/tomee-plus/pom.xml
+++ b/boms/tomee-plus/pom.xml
@@ -554,7 +554,8 @@
     <dependency>
       <groupId>org.apache.batchee</groupId>
       <artifactId>batchee-jbatch</artifactId>
-      <version>2.0.0-SNAPSHOT</version>
+      <version>1.0.4</version>
+      <classifier>jakarta</classifier>
       <exclusions>
         <exclusion>
           <artifactId>*</artifactId>
diff --git a/container/openejb-core/pom.xml b/container/openejb-core/pom.xml
index a07a3d679d..614ac4cc04 100644
--- a/container/openejb-core/pom.xml
+++ b/container/openejb-core/pom.xml
@@ -706,10 +706,15 @@
       <artifactId>batchee-jbatch</artifactId>
       <version>${version.batchee}</version>
       <scope>provided</scope>
+      <classifier>jakarta</classifier>
       <exclusions>
         <exclusion>
-          <groupId>org.glassfish.jaxb</groupId>
-          <artifactId>jaxb-runtime</artifactId>
+          <groupId>org.apache.batchee</groupId>
+          <artifactId>*</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>com.sun.xml.bind</groupId>
+          <artifactId>jaxb-impl</artifactId>
         </exclusion>
       </exclusions>
     </dependency>
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/batchee/InjectionsMock.java b/container/openejb-core/src/test/java/org/apache/openejb/batchee/InjectionsMock.java
new file mode 100644
index 0000000000..56e5e4cc80
--- /dev/null
+++ b/container/openejb-core/src/test/java/org/apache/openejb/batchee/InjectionsMock.java
@@ -0,0 +1,58 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.openejb.batchee;
+
+import jakarta.batch.api.AbstractBatchlet;
+import jakarta.batch.api.BatchProperty;
+import jakarta.batch.runtime.context.JobContext;
+import jakarta.enterprise.inject.spi.Bean;
+import jakarta.enterprise.inject.spi.BeanManager;
+import jakarta.inject.Inject;
+import jakarta.inject.Named;
+import org.junit.Assert;
+
+import java.net.URL;
+
+@Named("injected")
+public class InjectionsMock extends AbstractBatchlet {
+    @Inject
+    @BatchProperty
+    private URL url;
+
+    @Inject
+    private JobContext jobContext;
+
+    @Inject
+    private BeanManager beanManager;
+
+    @Override
+    public String process() throws Exception {
+        Assert.assertTrue(url.toExternalForm().equals("http://batchee.incubator.org"));
+        Assert.assertNotNull(jobContext);
+        Assert.assertEquals(jobContext.getJobName(), "injections");
+
+        // now check whether injection also works during the runtime of the batch
+        // this is needed if you e.g have a NormalScoped bean which only now gets initialized.
+        Assert.assertNotNull(beanManager);
+        Bean<?> bean = beanManager.resolve(beanManager.getBeans(JobContext.class));
+        JobContext jc = (JobContext) beanManager.getReference(bean, JobContext.class, beanManager.createCreationalContext(bean));
+        Assert.assertNotNull(jc);
+        Assert.assertEquals(jc.getJobName(), "injections");
+
+        return "true";
+    }
+}
diff --git a/container/openejb-core/src/test/java/org/apache/openejb/batchee/InjectionsTest.java b/container/openejb-core/src/test/java/org/apache/openejb/batchee/InjectionsTest.java
new file mode 100644
index 0000000000..3da269d8e0
--- /dev/null
+++ b/container/openejb-core/src/test/java/org/apache/openejb/batchee/InjectionsTest.java
@@ -0,0 +1,56 @@
+/*
+ * Copyright 2012 International Business Machines Corp.
+ *
+ * See the NOTICE file distributed with this work for additional information
+ * regarding copyright ownership. Licensed under the Apache License,
+ * Version 2.0 (the "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+*/
+package org.apache.openejb.batchee;
+
+import jakarta.batch.operations.JobOperator;
+import jakarta.batch.runtime.BatchRuntime;
+import jakarta.inject.Inject;
+import org.apache.openejb.junit.ApplicationComposer;
+import org.apache.openejb.testing.Module;
+import org.junit.Assert;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.apache.batchee.util.Batches.waitForEnd;
+
+@RunWith(ApplicationComposer.class)
+public class InjectionsTest {
+
+    @Module
+    public Class<?>[] cdi() {
+        return new Class<?>[]{BatchBean.class, InjectionsMock.class};
+    }
+
+    @Inject
+    private BatchBean bean;
+
+    @Test
+    public void test() {
+        Assert.assertEquals("true", bean.run());
+    }
+
+    public static class BatchBean {
+
+        public String run() {
+            final JobOperator operator = BatchRuntime.getJobOperator();
+            final long id = operator.start("injections", null);
+            waitForEnd(operator, id);
+            return operator.getStepExecutions(id).iterator().next().getExitStatus();
+        }
+
+    }
+}
diff --git a/container/openejb-core/src/test/resources/META-INF/batch-jobs/injections.xml b/container/openejb-core/src/test/resources/META-INF/batch-jobs/injections.xml
new file mode 100644
index 0000000000..0076454353
--- /dev/null
+++ b/container/openejb-core/src/test/resources/META-INF/batch-jobs/injections.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  See the NOTICE file distributed with this work for additional information
+  regarding copyright ownership. Licensed under the Apache License,
+  Version 2.0 (the "License"); you may not use this file except in compliance
+  with the License. You may obtain a copy of the License at
+
+    http://www.apache.org/licenses/LICENSE-2.0
+
+  Unless required by applicable law or agreed to in writing, software
+  distributed under the License is distributed on an "AS IS" BASIS,
+  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+  See the License for the specific language governing permissions and
+  limitations under the License.
+-->
+<job id="injections" version="1.0" xmlns="http://xmlns.jcp.org/xml/ns/javaee">
+  <step id="inject-step">
+    <batchlet ref="injected">
+      <properties>
+        <property name="url" value="http://batchee.incubator.org"/>
+      </properties>
+    </batchlet>
+  </step>
+</job>
diff --git a/pom.xml b/pom.xml
index 71e4dcfa81..7163c56a2c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -209,7 +209,8 @@
     <version.impl.saaj>2.0.1</version.impl.saaj>
     <!-- org.apache -->
     <version.activemq>5.18.3</version.activemq>
-    <version.batchee>2.0.0-SNAPSHOT</version.batchee>
+    <!-- downgrade to avoid a henn egg issue with batchee -->
+    <version.batchee>1.0.4</version.batchee>
     <version.bval>3.0.0</version.bval>
     <version.cxf>4.0.4</version.cxf>
     <version.geronimo.components>4.0.0</version.geronimo.components>
diff --git a/tomee/tomee-plume-webapp/pom.xml b/tomee/tomee-plume-webapp/pom.xml
index 839d319cf1..a29d37b667 100644
--- a/tomee/tomee-plume-webapp/pom.xml
+++ b/tomee/tomee-plume-webapp/pom.xml
@@ -349,10 +349,15 @@
       <artifactId>batchee-jbatch</artifactId>
       <version>${version.batchee}</version>
       <scope>runtime</scope>
+      <classifier>jakarta</classifier>
       <exclusions>
         <exclusion>
-          <groupId>org.glassfish.jaxb</groupId>
-          <artifactId>jaxb-runtime</artifactId>
+          <groupId>org.apache.batchee</groupId>
+          <artifactId>*</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>com.sun.xml.bind</groupId>
+          <artifactId>jaxb-impl</artifactId>
         </exclusion>
       </exclusions>
     </dependency>
diff --git a/tomee/tomee-plus-webapp/pom.xml b/tomee/tomee-plus-webapp/pom.xml
index 8b2f09d344..40521678d9 100644
--- a/tomee/tomee-plus-webapp/pom.xml
+++ b/tomee/tomee-plus-webapp/pom.xml
@@ -349,10 +349,15 @@
       <artifactId>batchee-jbatch</artifactId>
       <version>${version.batchee}</version>
       <scope>runtime</scope>
+      <classifier>jakarta</classifier>
       <exclusions>
         <exclusion>
-          <groupId>org.glassfish.jaxb</groupId>
-          <artifactId>jaxb-runtime</artifactId>
+          <groupId>org.apache.batchee</groupId>
+          <artifactId>*</artifactId>
+        </exclusion>
+        <exclusion>
+          <groupId>com.sun.xml.bind</groupId>
+          <artifactId>jaxb-impl</artifactId>
         </exclusion>
       </exclusions>
     </dependency>