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

Add jakarta.batch API module-info #192

Merged
merged 4 commits into from
Jan 20, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 8 additions & 8 deletions api/src/main/java/jakarta/batch/runtime/BatchRuntime.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
import java.security.AccessController;
import java.security.PrivilegedAction;
import java.util.ServiceLoader;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.lang.System.Logger;
import java.lang.System.Logger.Level;

import jakarta.batch.operations.JobOperator;

Expand All @@ -34,7 +34,7 @@
public class BatchRuntime {

private final static String sourceClass = BatchRuntime.class.getName();
private final static Logger logger = Logger.getLogger(sourceClass);
private final static Logger logger = System.getLogger(sourceClass);

/**
* The getJobOperator factory method returns
Expand All @@ -46,8 +46,8 @@ public static JobOperator getJobOperator() {
JobOperator operator = null;
if (System.getSecurityManager() == null) {
for (JobOperator provider : ServiceLoader.load(JobOperator.class)) {
if (logger.isLoggable(Level.FINE)) {
logger.fine("Loaded JobOperator with class: " + provider.getClass().getCanonicalName());
if (logger.isLoggable(Level.DEBUG)) {
logger.log(Level.DEBUG, "Loaded JobOperator with class: " + provider.getClass().getCanonicalName());
}
operator = provider;
break;
Expand All @@ -59,8 +59,8 @@ public JobOperator run() {
ServiceLoader<JobOperator> loader = ServiceLoader.load(JobOperator.class);
JobOperator returnVal = null;
for (JobOperator provider : loader) {
if (logger.isLoggable(Level.FINE)) {
logger.fine("Loaded JobOperator with class: " + provider.getClass().getCanonicalName());
if (logger.isLoggable(Level.DEBUG)) {
logger.log(Level.DEBUG, "Loaded JobOperator with class: " + provider.getClass().getCanonicalName());
}
// Use first one
returnVal = provider;
Expand All @@ -74,7 +74,7 @@ public JobOperator run() {

if (operator == null) {
if (logger.isLoggable(Level.WARNING)) {
logger.warning("The ServiceLoader was unable to find an implementation for JobOperator. Check classpath for META-INF/services/jakarta.batch.operations.JobOperator file.");
logger.log(Level.WARNING, "The ServiceLoader was unable to find an implementation for JobOperator. Check classpath for META-INF/services/jakarta.batch.operations.JobOperator file.");
}
}
return operator;
Expand Down
34 changes: 34 additions & 0 deletions api/src/main/java/module-info.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Copyright 2022 International Business Machines Corp. and others
*
* 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.
*
* SPDX-License-Identifier: Apache-2.0
*/
module jakarta.batch {

requires static jakarta.cdi;
requires transitive static jakarta.inject;

Copy link

@OndroMih OndroMih Jan 17, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's OK that jakarta.cdi is optional. But shouldn't we also add an explicit dependency on jakarta.inject, since that one is really required all the time to support batch properties injection?

Suggested change
requires jakarta.inject;

Copy link
Contributor Author

@scottkurz scottkurz Jan 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I apologize since though I brought up this issue, I don't think my comments have kept up with the code I pushed here.

I see your point and we could make this change (I'd be OK with that).

One point I started to make: it is possible to have an application that just starts and monitors, etc. jobs via JobOperator that does NOT itself require 'inject'.

So from a purely minimalist point of view I think the case could be made that it's "optional", strictly speaking.

However... jakarta.inject is a small API that doesn't drag in other dependencies while jakarta.cdi is a good bit bigger.

If you think a more reasonable compromise is to include a runtime dependency for jakarta.inject, and keep the jakarta.cdi dependency as static/optional... I'd believe you. I don't have a lot of real-world experience with JPMS to be honest.

@rmannibucau had commented too on this point.

for inject: it is less critical to me since batchproperty hardly depends on it so if we want to make it optional we should split the api in 2 at least so likely not for this time IMHO.
Reading that now, I think he more agreed with you... am I reading that correctly?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's see it one level higher: Scott is right inject is optional for end user but if the end user needs it, it will add it cause its code depends on it so let's ensure it is statically required only maybe? it would also align with the API itself which has both jars as provided (https://github.com/eclipse-ee4j/batch-api/blob/master/api/pom.xml#L33)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My thinking was along what the spec requires from the implementation. And DI support is mandatory, while CDI support is optional, am I wrong? Therefore, since DI needs to be in the impl, it should be mandatory. And also transitive so that it's available to the user even if they only require batch and not jakarta.inject. Now I realize that required modules aren't automatically transitive, so I'd suggest that we add the following:

Suggested change
requires transitive jakarta.inject;

I only suggest it because it seems as the purest solution for me (works like maven - you only need to require batch and you can also use @Inject without any other required module). I don't insist on it, we can leave it to the user to add the dependency on DI or revisit this in a later version of the spec.

Copy link
Contributor Author

@scottkurz scottkurz Jan 18, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we do:

requires static transitive jakarta.inject;

This way we get a single dependency for the typical application with a batch job implementation (artifacts, etc.), and a user still has the option to build a batch operator/client without using inject or cdi.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That sounds good, I agree with that.

exports jakarta.batch.api;
exports jakarta.batch.api.chunk;
exports jakarta.batch.api.chunk.listener;
exports jakarta.batch.api.listener;
exports jakarta.batch.api.partition;
exports jakarta.batch.operations;
exports jakarta.batch.runtime;
exports jakarta.batch.runtime.context;

uses jakarta.batch.operations.JobOperator;
}
2 changes: 1 addition & 1 deletion api/src/main/resources/jakarta/xml/batch/jobXML_2_0.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
<xs:documentation>

Defines a decimal type used for versioning documents
defined via this scheam. Intended to be identical
defined via this schema. Intended to be identical
to the "dewey-versionType" dewey decimal restriction
type defined in
https://jakarta.ee/xml/ns/jakartaee/jakartaee_9.xsd
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
<version.java>11</version.java>

<!-- Dependencies -->
<version.jakarta.enterprise.jakarta.enterprise.cdi-api>3.0.0</version.jakarta.enterprise.jakarta.enterprise.cdi-api>
<version.jakarta.enterprise.jakarta.enterprise.cdi-api>4.0.0.Beta3</version.jakarta.enterprise.jakarta.enterprise.cdi-api>
<version.jakarta.inject.jakarta.inject-api>2.0.1</version.jakarta.inject.jakarta.inject-api>

<version.org.sonatype.plugins.nexus-staging-maven-plugin>1.6.6</version.org.sonatype.plugins.nexus-staging-maven-plugin>
Expand Down
4 changes: 2 additions & 2 deletions spec/src/main/asciidoc/batch_programming_model.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -1547,9 +1547,9 @@ enable finer control over parallel processing:
number of partitions and unique properties for each.
.. PartitionReducer provides a unit of work demarcation around
partition processing.
.. PartitionCollector provides a means for merging interrim results
.. PartitionCollector provides a means for merging interim results
from individual partitions.
.. PartitionAnalyzer provides a means to gather interrim and final
.. PartitionAnalyzer provides a means to gather interim and final
results from individual partitions for single point of control
processing and decision making.

Expand Down