Skip to content

Commit

Permalink
TOMEE-4307 - Batchee Downgrade to 1.0.4 (#1115)
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
rzo1 authored Mar 26, 2024
1 parent c98e7d9 commit d8c99fd
Show file tree
Hide file tree
Showing 9 changed files with 165 additions and 9 deletions.
3 changes: 2 additions & 1 deletion boms/tomee-plume/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
3 changes: 2 additions & 1 deletion boms/tomee-plus/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
9 changes: 7 additions & 2 deletions container/openejb-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Original file line number Diff line number Diff line change
@@ -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";
}
}
Original file line number Diff line number Diff line change
@@ -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();
}

}
}
Original file line number Diff line number Diff line change
@@ -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>
3 changes: 2 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
9 changes: 7 additions & 2 deletions tomee/tomee-plume-webapp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
9 changes: 7 additions & 2 deletions tomee/tomee-plus-webapp/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down

0 comments on commit d8c99fd

Please sign in to comment.