You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@shardingsphere.apache.org by zh...@apache.org on 2020/06/21 09:33:46 UTC
[shardingsphere-elasticjob-lite] branch master updated: Remove
JobInstanceProvided (#803)
This is an automated email from the ASF dual-hosted git repository.
zhangliang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere-elasticjob-lite.git
The following commit(s) were added to refs/heads/master by this push:
new 6797bd9 Remove JobInstanceProvided (#803)
6797bd9 is described below
commit 6797bd9ca1dca302d6f01bc19ed469b832463f61
Author: Liang Zhang <te...@163.com>
AuthorDate: Sun Jun 21 17:33:40 2020 +0800
Remove JobInstanceProvided (#803)
* Refactor JobBeanDefinitionParser
* remove JobInstanceProvided
---
.../elasticjob/lite/api/JobScheduler.java | 5 +--
.../InstanceProvidedDataflowJobConfiguration.java | 43 ----------------------
.../InstanceProvidedSimpleJobConfiguration.java | 41 ---------------------
.../config/provided/JobInstanceProvided.java | 33 -----------------
.../AbstractJobConfigurationGsonTypeAdapter.java | 13 +------
.../dataflow/DataflowJobBeanDefinitionParser.java | 12 +-----
.../simple/SimpleJobBeanDefinitionParser.java | 12 +-----
7 files changed, 6 insertions(+), 153 deletions(-)
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/api/JobScheduler.java b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/api/JobScheduler.java
index d9cc0b4..ad5b76e 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/api/JobScheduler.java
+++ b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/api/JobScheduler.java
@@ -27,7 +27,6 @@ import org.apache.shardingsphere.elasticjob.lite.event.JobEventBus;
import org.apache.shardingsphere.elasticjob.lite.event.JobEventConfiguration;
import org.apache.shardingsphere.elasticjob.lite.exception.JobSystemException;
import org.apache.shardingsphere.elasticjob.lite.executor.JobFacade;
-import org.apache.shardingsphere.elasticjob.lite.internal.config.provided.JobInstanceProvided;
import org.apache.shardingsphere.elasticjob.lite.internal.guarantee.GuaranteeService;
import org.apache.shardingsphere.elasticjob.lite.internal.schedule.JobRegistry;
import org.apache.shardingsphere.elasticjob.lite.internal.schedule.JobScheduleController;
@@ -137,9 +136,7 @@ public final class JobScheduler {
private JobDetail createJobDetail(final ElasticJob elasticJob) {
JobDetail result = JobBuilder.newJob(LiteJob.class).withIdentity(liteJobConfig.getJobName()).build();
result.getJobDataMap().put(JOB_FACADE_DATA_MAP_KEY, jobFacade);
- if (liteJobConfig.getTypeConfig() instanceof JobInstanceProvided && null != ((JobInstanceProvided) liteJobConfig.getTypeConfig()).getJobInstance()) {
- result.getJobDataMap().put(ELASTIC_JOB_DATA_MAP_KEY, ((JobInstanceProvided) liteJobConfig.getTypeConfig()).getJobInstance());
- } else if (null != elasticJob && !elasticJob.getClass().getName().equals(ScriptJob.class.getName())) {
+ if (null != elasticJob && !elasticJob.getClass().getName().equals(ScriptJob.class.getName())) {
result.getJobDataMap().put(ELASTIC_JOB_DATA_MAP_KEY, elasticJob);
}
return result;
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/config/provided/InstanceProvidedDataflowJobConfiguration.java b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/config/provided/InstanceProvidedDataflowJobConfiguration.java
deleted file mode 100644
index 40c1dd6..0000000
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/config/provided/InstanceProvidedDataflowJobConfiguration.java
+++ /dev/null
@@ -1,43 +0,0 @@
-/*
- * 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.shardingsphere.elasticjob.lite.internal.config.provided;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.elasticjob.lite.api.ElasticJob;
-import org.apache.shardingsphere.elasticjob.lite.api.JobType;
-import org.apache.shardingsphere.elasticjob.lite.config.JobCoreConfiguration;
-import org.apache.shardingsphere.elasticjob.lite.config.JobTypeConfiguration;
-
-/**
- * Dataflow job configuration.
- */
-@RequiredArgsConstructor
-@Getter
-public final class InstanceProvidedDataflowJobConfiguration implements JobTypeConfiguration, JobInstanceProvided {
-
- private final JobCoreConfiguration coreConfig;
-
- private final JobType jobType = JobType.DATAFLOW;
-
- private final String jobClass;
-
- private final boolean streamingProcess;
-
- private final ElasticJob jobInstance;
-}
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/config/provided/InstanceProvidedSimpleJobConfiguration.java b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/config/provided/InstanceProvidedSimpleJobConfiguration.java
deleted file mode 100644
index 03ff2d1..0000000
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/config/provided/InstanceProvidedSimpleJobConfiguration.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * 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.shardingsphere.elasticjob.lite.internal.config.provided;
-
-import lombok.Getter;
-import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.elasticjob.lite.api.ElasticJob;
-import org.apache.shardingsphere.elasticjob.lite.api.JobType;
-import org.apache.shardingsphere.elasticjob.lite.config.JobCoreConfiguration;
-import org.apache.shardingsphere.elasticjob.lite.config.JobTypeConfiguration;
-
-/**
- * Simple job configuration.
- */
-@RequiredArgsConstructor
-@Getter
-public final class InstanceProvidedSimpleJobConfiguration implements JobTypeConfiguration, JobInstanceProvided {
-
- private final JobCoreConfiguration coreConfig;
-
- private final JobType jobType = JobType.SIMPLE;
-
- private final String jobClass;
-
- private final ElasticJob jobInstance;
-}
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/config/provided/JobInstanceProvided.java b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/config/provided/JobInstanceProvided.java
deleted file mode 100644
index 3fe857a..0000000
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/internal/config/provided/JobInstanceProvided.java
+++ /dev/null
@@ -1,33 +0,0 @@
-/*
- * 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.shardingsphere.elasticjob.lite.internal.config.provided;
-
-import org.apache.shardingsphere.elasticjob.lite.api.ElasticJob;
-
-/**
- * Job instance provided.
- */
-public interface JobInstanceProvided {
-
- /**
- * Get job instance.
- *
- * @return job instance
- */
- ElasticJob getJobInstance();
-}
diff --git a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/util/json/AbstractJobConfigurationGsonTypeAdapter.java b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/util/json/AbstractJobConfigurationGsonTypeAdapter.java
index 8eaf318..f6d2532 100644
--- a/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/util/json/AbstractJobConfigurationGsonTypeAdapter.java
+++ b/elastic-job-lite-core/src/main/java/org/apache/shardingsphere/elasticjob/lite/util/json/AbstractJobConfigurationGsonTypeAdapter.java
@@ -30,7 +30,6 @@ import org.apache.shardingsphere.elasticjob.lite.config.script.ScriptJobConfigur
import org.apache.shardingsphere.elasticjob.lite.config.simple.SimpleJobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.executor.handler.JobProperties;
import org.apache.shardingsphere.elasticjob.lite.executor.handler.JobProperties.JobPropertiesEnum;
-import org.apache.shardingsphere.elasticjob.lite.internal.config.provided.InstanceProvidedDataflowJobConfiguration;
import java.io.IOException;
import java.util.HashMap;
@@ -55,7 +54,6 @@ public abstract class AbstractJobConfigurationGsonTypeAdapter<T extends JobRootC
String description = "";
JobProperties jobProperties = new JobProperties();
JobType jobType = null;
- String jobClass = "";
boolean streamingProcess = false;
String scriptCommandLine = "";
Map<String, Object> customizedValueMap = new HashMap<>(32, 1);
@@ -93,9 +91,6 @@ public abstract class AbstractJobConfigurationGsonTypeAdapter<T extends JobRootC
case "jobType":
jobType = JobType.valueOf(in.nextString());
break;
- case "jobClass":
- jobClass = in.nextString();
- break;
case "streamingProcess":
streamingProcess = in.nextBoolean();
break;
@@ -175,13 +170,7 @@ public abstract class AbstractJobConfigurationGsonTypeAdapter<T extends JobRootC
out.name("description").value(value.getTypeConfig().getCoreConfig().getDescription());
out.name("jobProperties").jsonValue(value.getTypeConfig().getCoreConfig().getJobProperties().json());
if (value.getTypeConfig().getJobType() == JobType.DATAFLOW) {
- boolean streamingProcess;
- if (value.getTypeConfig() instanceof InstanceProvidedDataflowJobConfiguration) {
- streamingProcess = ((InstanceProvidedDataflowJobConfiguration) value.getTypeConfig()).isStreamingProcess();
- } else {
- streamingProcess = ((DataflowJobConfiguration) value.getTypeConfig()).isStreamingProcess();
- }
- out.name("streamingProcess").value(streamingProcess);
+ out.name("streamingProcess").value(((DataflowJobConfiguration) value.getTypeConfig()).isStreamingProcess());
} else if (value.getTypeConfig().getJobType() == JobType.SCRIPT) {
ScriptJobConfiguration scriptJobConfig = (ScriptJobConfiguration) value.getTypeConfig();
out.name("scriptCommandLine").value(scriptJobConfig.getScriptCommandLine());
diff --git a/elastic-job-lite-spring/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/job/parser/dataflow/DataflowJobBeanDefinitionParser.java b/elastic-job-lite-spring/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/job/parser/dataflow/DataflowJobBeanDefinitionParser.java
index 7162471..42fc7d9 100644
--- a/elastic-job-lite-spring/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/job/parser/dataflow/DataflowJobBeanDefinitionParser.java
+++ b/elastic-job-lite-spring/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/job/parser/dataflow/DataflowJobBeanDefinitionParser.java
@@ -17,10 +17,8 @@
package org.apache.shardingsphere.elasticjob.lite.spring.job.parser.dataflow;
-import com.google.common.base.Strings;
-import org.apache.shardingsphere.elasticjob.lite.internal.config.provided.InstanceProvidedDataflowJobConfiguration;
+import org.apache.shardingsphere.elasticjob.lite.config.dataflow.DataflowJobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.spring.job.parser.common.AbstractJobBeanDefinitionParser;
-import org.apache.shardingsphere.elasticjob.lite.spring.job.parser.common.BaseJobBeanDefinitionParserTag;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.ParserContext;
@@ -33,15 +31,9 @@ public final class DataflowJobBeanDefinitionParser extends AbstractJobBeanDefini
@Override
protected BeanDefinition getJobTypeConfigurationBeanDefinition(final ParserContext parserContext, final BeanDefinition jobCoreConfigurationBeanDefinition, final Element element) {
- BeanDefinitionBuilder result = BeanDefinitionBuilder.rootBeanDefinition(InstanceProvidedDataflowJobConfiguration.class);
+ BeanDefinitionBuilder result = BeanDefinitionBuilder.rootBeanDefinition(DataflowJobConfiguration.class);
result.addConstructorArgValue(jobCoreConfigurationBeanDefinition);
- result.addConstructorArgValue(parserContext.getRegistry().getBeanDefinition(element.getAttribute(BaseJobBeanDefinitionParserTag.JOB_REF_ATTRIBUTE)).getBeanClassName());
result.addConstructorArgValue(element.getAttribute(DataflowJobBeanDefinitionParserTag.STREAMING_PROCESS_ATTRIBUTE));
- if (Strings.isNullOrEmpty(element.getAttribute(BaseJobBeanDefinitionParserTag.CLASS_ATTRIBUTE))) {
- result.addConstructorArgReference(element.getAttribute(BaseJobBeanDefinitionParserTag.JOB_REF_ATTRIBUTE));
- } else {
- result.addConstructorArgValue(null);
- }
return result.getBeanDefinition();
}
}
diff --git a/elastic-job-lite-spring/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/job/parser/simple/SimpleJobBeanDefinitionParser.java b/elastic-job-lite-spring/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/job/parser/simple/SimpleJobBeanDefinitionParser.java
index 64347b0..635336a 100644
--- a/elastic-job-lite-spring/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/job/parser/simple/SimpleJobBeanDefinitionParser.java
+++ b/elastic-job-lite-spring/src/main/java/org/apache/shardingsphere/elasticjob/lite/spring/job/parser/simple/SimpleJobBeanDefinitionParser.java
@@ -17,10 +17,8 @@
package org.apache.shardingsphere.elasticjob.lite.spring.job.parser.simple;
-import com.google.common.base.Strings;
-import org.apache.shardingsphere.elasticjob.lite.internal.config.provided.InstanceProvidedSimpleJobConfiguration;
+import org.apache.shardingsphere.elasticjob.lite.config.simple.SimpleJobConfiguration;
import org.apache.shardingsphere.elasticjob.lite.spring.job.parser.common.AbstractJobBeanDefinitionParser;
-import org.apache.shardingsphere.elasticjob.lite.spring.job.parser.common.BaseJobBeanDefinitionParserTag;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.xml.ParserContext;
@@ -33,14 +31,8 @@ public final class SimpleJobBeanDefinitionParser extends AbstractJobBeanDefiniti
@Override
protected BeanDefinition getJobTypeConfigurationBeanDefinition(final ParserContext parserContext, final BeanDefinition jobCoreConfigurationBeanDefinition, final Element element) {
- BeanDefinitionBuilder result = BeanDefinitionBuilder.rootBeanDefinition(InstanceProvidedSimpleJobConfiguration.class);
+ BeanDefinitionBuilder result = BeanDefinitionBuilder.rootBeanDefinition(SimpleJobConfiguration.class);
result.addConstructorArgValue(jobCoreConfigurationBeanDefinition);
- result.addConstructorArgValue(parserContext.getRegistry().getBeanDefinition(element.getAttribute(BaseJobBeanDefinitionParserTag.JOB_REF_ATTRIBUTE)).getBeanClassName());
- if (Strings.isNullOrEmpty(element.getAttribute(BaseJobBeanDefinitionParserTag.CLASS_ATTRIBUTE))) {
- result.addConstructorArgReference(element.getAttribute(BaseJobBeanDefinitionParserTag.JOB_REF_ATTRIBUTE));
- } else {
- result.addConstructorArgValue(null);
- }
return result.getBeanDefinition();
}
}