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/10/09 16:41:52 UTC
[shardingsphere] branch master updated: Add
shardingsphere-infra-datetime module (#7723)
This is an automated email from the ASF dual-hosted git repository.
zhangyonglun pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shardingsphere.git
The following commit(s) were added to refs/heads/master by this push:
new b7d1391 Add shardingsphere-infra-datetime module (#7723)
b7d1391 is described below
commit b7d1391317ddb225f1e0a11a09431418975d5de5
Author: Liang Zhang <te...@163.com>
AuthorDate: Sat Oct 10 00:41:26 2020 +0800
Add shardingsphere-infra-datetime module (#7723)
* Add shardingsphere-infra-datetime structure
* Remove useless SingletonServiceLoader
* Add RequiredSPI
* Use RequiredSPI on DatetimeService
* Move DatetimeService to shardingsphere-infra-datetime-spi module
* Move SystemDatetimeService to shardingsphere-system-datetime module
* Add SystemDatetimeServiceTest
* Remove DatetimeServiceFixture
* Move shardingsphere-database-datetime
* Remove shardingsphere-sharding-time-service module
* Fix pom
---
.../shardingsphere-sharding/pom.xml | 1 -
.../shardingsphere-sharding-route/pom.xml | 5 ++
.../engine/ShardingConditionEngineFactory.java | 6 ++
.../impl/InsertClauseShardingConditionEngine.java | 6 +-
.../ConditionValueBetweenOperatorGenerator.java | 5 +-
.../ConditionValueCompareOperatorGenerator.java | 5 +-
.../impl/ConditionValueInOperatorGenerator.java | 6 +-
.../datatime/fixture/DatetimeServiceFixture.java | 36 ----------
...ConditionValueBetweenOperatorGeneratorTest.java | 6 ++
shardingsphere-infra/pom.xml | 1 +
.../infra/spi/required/RequiredSPI.java | 16 ++---
.../infra/spi/required/RequiredSPIRegistry.java | 32 +++++----
.../spi/singleton/SingletonServiceLoader.java | 84 ----------------------
.../spi/singleton/SingletonServiceLoaderTest.java | 68 ------------------
.../{ => shardingsphere-infra-datetime}/pom.xml | 12 ++--
.../shardingsphere-infra-datetime-spi}/pom.xml | 20 +++---
.../infra/datetime}/DatetimeService.java | 6 +-
.../shardingsphere-infra-datetime-type}/pom.xml | 12 ++--
.../shardingsphere-database-datetime}/pom.xml | 15 ++--
.../database}/DatabaseDatetimeServiceDelegate.java | 11 ++-
.../database}/TimeServiceConfiguration.java | 4 +-
.../NoDatabaseSQLEntrySupportException.java | 2 +-
.../exception/TimeServiceInitException.java | 2 +-
.../database}/impl/DatabaseDatetimeService.java | 9 ++-
.../database}/impl/TimeServiceFactory.java | 8 +--
.../datetime/database}/spi/DatabaseSQLEntry.java | 2 +-
.../database}/spi/MySQLDatabaseSQLEntry.java | 2 +-
.../database}/spi/OracleDatabaseSQLEntry.java | 2 +-
.../database}/spi/PostgreSQLDatabaseSQLEntry.java | 2 +-
.../database}/spi/SPIDataBaseSQLEntry.java | 4 +-
.../database}/spi/SQLServerDatabaseSQLEntry.java | 2 +-
...e.shardingsphere.infra.datetime.DatetimeService | 2 +-
...ngsphere.datetime.database.spi.DatabaseSQLEntry | 8 +--
.../src/main/resources/time-service.properties | 0
.../datetime/database}/PropertiesUtils.java | 2 +-
.../database}/TimeServiceConfigurationTest.java | 2 +-
.../src/test/resources/logback-test.xml | 0
.../shardingsphere-system-datetime}/pom.xml | 21 +++---
.../datetime/system/SystemDatetimeService.java | 11 ++-
...e.shardingsphere.infra.datetime.DatetimeService | 2 +-
.../datetime/system/SystemDatetimeServiceTest.java | 17 ++---
41 files changed, 154 insertions(+), 303 deletions(-)
diff --git a/shardingsphere-features/shardingsphere-sharding/pom.xml b/shardingsphere-features/shardingsphere-sharding/pom.xml
index 62a63d3..b27f9dd 100644
--- a/shardingsphere-features/shardingsphere-sharding/pom.xml
+++ b/shardingsphere-features/shardingsphere-sharding/pom.xml
@@ -33,7 +33,6 @@
<module>shardingsphere-sharding-route</module>
<module>shardingsphere-sharding-rewrite</module>
<module>shardingsphere-sharding-merge</module>
- <module>shardingsphere-sharding-time-service</module>
<module>shardingsphere-sharding-spring</module>
</modules>
</project>
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/pom.xml b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/pom.xml
index 15c0e75..ac3d58a 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/pom.xml
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/pom.xml
@@ -38,6 +38,11 @@
<artifactId>shardingsphere-infra-route</artifactId>
<version>${project.version}</version>
</dependency>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-system-datetime</artifactId>
+ <version>${project.version}</version>
+ </dependency>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/ShardingConditionEngineFactory.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/ShardingConditionEngineFactory.java
index b183688..ada5eb3 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/ShardingConditionEngineFactory.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/ShardingConditionEngineFactory.java
@@ -19,7 +19,9 @@ package org.apache.shardingsphere.sharding.route.engine.condition.engine;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
+import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
import org.apache.shardingsphere.infra.sql.LogicSQL;
+import org.apache.shardingsphere.infra.datetime.DatetimeService;
import org.apache.shardingsphere.sharding.route.engine.condition.engine.impl.InsertClauseShardingConditionEngine;
import org.apache.shardingsphere.sharding.route.engine.condition.engine.impl.WhereClauseShardingConditionEngine;
import org.apache.shardingsphere.sharding.rule.ShardingRule;
@@ -32,6 +34,10 @@ import org.apache.shardingsphere.sql.parser.binder.statement.dml.InsertStatement
@NoArgsConstructor(access = AccessLevel.PRIVATE)
public final class ShardingConditionEngineFactory {
+ static {
+ ShardingSphereServiceLoader.register(DatetimeService.class);
+ }
+
/**
* Create new instance of sharding condition engine.
*
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/impl/InsertClauseShardingConditionEngine.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/impl/InsertClauseShardingConditionEngine.java
index e7be2bb..dfea1d5 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/impl/InsertClauseShardingConditionEngine.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/engine/impl/InsertClauseShardingConditionEngine.java
@@ -20,8 +20,8 @@ package org.apache.shardingsphere.sharding.route.engine.condition.engine.impl;
import com.google.common.base.Preconditions;
import lombok.RequiredArgsConstructor;
import org.apache.shardingsphere.infra.exception.ShardingSphereException;
-import org.apache.shardingsphere.sharding.route.datatime.DatetimeService;
-import org.apache.shardingsphere.sharding.route.datatime.DatetimeServiceFactory;
+import org.apache.shardingsphere.infra.spi.required.RequiredSPIRegistry;
+import org.apache.shardingsphere.infra.datetime.DatetimeService;
import org.apache.shardingsphere.sharding.route.engine.condition.ExpressionConditionUtils;
import org.apache.shardingsphere.sharding.route.engine.condition.ShardingCondition;
import org.apache.shardingsphere.sharding.route.engine.condition.engine.ShardingConditionEngine;
@@ -86,7 +86,7 @@ public final class InsertClauseShardingConditionEngine implements ShardingCondit
private ShardingCondition createShardingCondition(final String tableName, final Iterator<String> columnNames, final InsertValueContext insertValueContext, final List<Object> parameters) {
ShardingCondition result = new ShardingCondition();
- DatetimeService datetimeService = DatetimeServiceFactory.newInstance();
+ DatetimeService datetimeService = RequiredSPIRegistry.getRegisteredService(DatetimeService.class);
for (ExpressionSegment each : insertValueContext.getValueExpressions()) {
String columnName = columnNames.next();
if (shardingRule.isShardingColumn(columnName, tableName)) {
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueBetweenOperatorGenerator.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueBetweenOperatorGenerator.java
index 51dc480..f9a93dd 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueBetweenOperatorGenerator.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueBetweenOperatorGenerator.java
@@ -18,7 +18,8 @@
package org.apache.shardingsphere.sharding.route.engine.condition.generator.impl;
import com.google.common.collect.Range;
-import org.apache.shardingsphere.sharding.route.datatime.DatetimeServiceFactory;
+import org.apache.shardingsphere.infra.spi.required.RequiredSPIRegistry;
+import org.apache.shardingsphere.infra.datetime.DatetimeService;
import org.apache.shardingsphere.sharding.route.engine.condition.Column;
import org.apache.shardingsphere.sharding.route.engine.condition.ExpressionConditionUtils;
import org.apache.shardingsphere.sharding.route.engine.condition.generator.ConditionValue;
@@ -44,7 +45,7 @@ public final class ConditionValueBetweenOperatorGenerator implements ConditionVa
if (betweenConditionValue.isPresent() && andConditionValue.isPresent()) {
return Optional.of(new RangeShardingConditionValue<>(column.getName(), column.getTableName(), SafeNumberOperationUtils.safeClosed(betweenConditionValue.get(), andConditionValue.get())));
}
- Date datetime = DatetimeServiceFactory.newInstance().getDatetime();
+ Date datetime = RequiredSPIRegistry.getRegisteredService(DatetimeService.class).getDatetime();
if (!betweenConditionValue.isPresent() && ExpressionConditionUtils.isNowExpression(predicate.getBetweenExpr())) {
betweenConditionValue = Optional.of(datetime);
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueCompareOperatorGenerator.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueCompareOperatorGenerator.java
index 9ba3d9a..a21e396 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueCompareOperatorGenerator.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueCompareOperatorGenerator.java
@@ -19,7 +19,8 @@ package org.apache.shardingsphere.sharding.route.engine.condition.generator.impl
import com.google.common.collect.Lists;
import com.google.common.collect.Range;
-import org.apache.shardingsphere.sharding.route.datatime.DatetimeServiceFactory;
+import org.apache.shardingsphere.infra.spi.required.RequiredSPIRegistry;
+import org.apache.shardingsphere.infra.datetime.DatetimeService;
import org.apache.shardingsphere.sharding.route.engine.condition.Column;
import org.apache.shardingsphere.sharding.route.engine.condition.ExpressionConditionUtils;
import org.apache.shardingsphere.sharding.route.engine.condition.generator.ConditionValue;
@@ -61,7 +62,7 @@ public final class ConditionValueCompareOperatorGenerator implements ConditionVa
return generate(conditionValue.get(), column, operator);
}
if (ExpressionConditionUtils.isNowExpression(predicate.getRight())) {
- return generate(DatetimeServiceFactory.newInstance().getDatetime(), column, operator);
+ return generate(RequiredSPIRegistry.getRegisteredService(DatetimeService.class).getDatetime(), column, operator);
}
return Optional.empty();
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueInOperatorGenerator.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueInOperatorGenerator.java
index 302332f..c255604 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueInOperatorGenerator.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueInOperatorGenerator.java
@@ -17,8 +17,8 @@
package org.apache.shardingsphere.sharding.route.engine.condition.generator.impl;
-import org.apache.shardingsphere.sharding.route.datatime.DatetimeService;
-import org.apache.shardingsphere.sharding.route.datatime.DatetimeServiceFactory;
+import org.apache.shardingsphere.infra.spi.required.RequiredSPIRegistry;
+import org.apache.shardingsphere.infra.datetime.DatetimeService;
import org.apache.shardingsphere.sharding.route.engine.condition.Column;
import org.apache.shardingsphere.sharding.route.engine.condition.ExpressionConditionUtils;
import org.apache.shardingsphere.sharding.route.engine.condition.generator.ConditionValue;
@@ -40,7 +40,7 @@ public final class ConditionValueInOperatorGenerator implements ConditionValueGe
@Override
public Optional<ShardingConditionValue> generate(final InExpression predicate, final Column column, final List<Object> parameters) {
List<Comparable<?>> shardingConditionValues = new LinkedList<>();
- DatetimeService datetimeService = DatetimeServiceFactory.newInstance();
+ DatetimeService datetimeService = RequiredSPIRegistry.getRegisteredService(DatetimeService.class);
for (ExpressionSegment each : predicate.getExpressionList()) {
Optional<Comparable<?>> shardingConditionValue = new ConditionValue(each, parameters).getValue();
if (shardingConditionValue.isPresent()) {
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/test/java/org/apache/shardingsphere/sharding/route/datatime/fixture/DatetimeServiceFixture.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/test/java/org/apache/shardingsphere/sharding/route/datatime/fixture/DatetimeServiceFixture.java
deleted file mode 100644
index 5f753b3..0000000
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/test/java/org/apache/shardingsphere/sharding/route/datatime/fixture/DatetimeServiceFixture.java
+++ /dev/null
@@ -1,36 +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.sharding.route.datatime.fixture;
-
-import lombok.Getter;
-import lombok.Setter;
-import org.apache.shardingsphere.sharding.route.datatime.DatetimeService;
-
-import java.util.Date;
-
-@Getter
-@Setter
-public final class DatetimeServiceFixture implements DatetimeService {
-
- private Date date;
-
- @Override
- public Date getDatetime() {
- return null == date ? new Date() : date;
- }
-}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueBetweenOperatorGeneratorTest.java b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueBetweenOperatorGeneratorTest.java
index 99e7041..1f3499a 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueBetweenOperatorGeneratorTest.java
+++ b/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/test/java/org/apache/shardingsphere/sharding/route/engine/condition/generator/impl/ConditionValueBetweenOperatorGeneratorTest.java
@@ -17,6 +17,8 @@
package org.apache.shardingsphere.sharding.route.engine.condition.generator.impl;
+import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
+import org.apache.shardingsphere.infra.datetime.DatetimeService;
import org.apache.shardingsphere.sharding.route.engine.condition.Column;
import org.apache.shardingsphere.sharding.route.engine.condition.value.RangeShardingConditionValue;
import org.apache.shardingsphere.sharding.route.engine.condition.value.ShardingConditionValue;
@@ -42,6 +44,10 @@ public final class ConditionValueBetweenOperatorGeneratorTest {
private final Column column = new Column("id", "tbl");
+ static {
+ ShardingSphereServiceLoader.register(DatetimeService.class);
+ }
+
@SuppressWarnings("unchecked")
@Test
public void assertGenerateConditionValue() {
diff --git a/shardingsphere-infra/pom.xml b/shardingsphere-infra/pom.xml
index d3060a5..ddbbd4c 100644
--- a/shardingsphere-infra/pom.xml
+++ b/shardingsphere-infra/pom.xml
@@ -36,5 +36,6 @@
<module>shardingsphere-infra-executor</module>
<module>shardingsphere-infra-merge</module>
<module>shardingsphere-infra-context</module>
+ <module>shardingsphere-infra-datetime</module>
</modules>
</project>
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/datatime/DatetimeService.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/spi/required/RequiredSPI.java
similarity index 78%
copy from shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/datatime/DatetimeService.java
copy to shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/spi/required/RequiredSPI.java
index 13af220..bebd75d 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/datatime/DatetimeService.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/spi/required/RequiredSPI.java
@@ -15,19 +15,17 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sharding.route.datatime;
-
-import java.util.Date;
+package org.apache.shardingsphere.infra.spi.required;
/**
- * Datetime service.
+ * Required SPI.
*/
-public interface DatetimeService {
+public interface RequiredSPI {
/**
- * Get datetime.
- *
- * @return datetime
+ * Judge whether default service provider.
+ *
+ * @return is default service provider or not
*/
- Date getDatetime();
+ boolean isDefault();
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/datatime/DatetimeServiceFactory.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/spi/required/RequiredSPIRegistry.java
similarity index 52%
rename from shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/datatime/DatetimeServiceFactory.java
rename to shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/spi/required/RequiredSPIRegistry.java
index 3ca1580..df24099 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/datatime/DatetimeServiceFactory.java
+++ b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/spi/required/RequiredSPIRegistry.java
@@ -15,28 +15,36 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sharding.route.datatime;
+package org.apache.shardingsphere.infra.spi.required;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
+import org.apache.shardingsphere.infra.spi.exception.ServiceProviderNotFoundException;
+
+import java.util.Collection;
/**
- * Datetime service factory.
+ * Required SPI registry.
*/
@NoArgsConstructor(access = AccessLevel.PRIVATE)
-public final class DatetimeServiceFactory {
-
- static {
- ShardingSphereServiceLoader.register(DatetimeService.class);
- }
+public final class RequiredSPIRegistry {
/**
- * Create new instance of datetime service.
- *
- * @return datetime service
+ * Get registered service.
+ *
+ * @param requiredSPIClass required SPI class
+ * @param <T> type
+ * @return registered service
*/
- public static DatetimeService newInstance() {
- return ShardingSphereServiceLoader.newServiceInstances(DatetimeService.class).stream().findFirst().orElseGet(DefaultDatetimeService::new);
+ public static <T extends RequiredSPI> T getRegisteredService(final Class<T> requiredSPIClass) {
+ Collection<T> services = ShardingSphereServiceLoader.newServiceInstances(requiredSPIClass);
+ if (services.isEmpty()) {
+ throw new ServiceProviderNotFoundException(requiredSPIClass);
+ }
+ if (1 == services.size()) {
+ return services.iterator().next();
+ }
+ return services.stream().filter(each -> !each.isDefault()).findFirst().orElse(services.iterator().next());
}
}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/spi/singleton/SingletonServiceLoader.java b/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/spi/singleton/SingletonServiceLoader.java
deleted file mode 100644
index 0326778..0000000
--- a/shardingsphere-infra/shardingsphere-infra-common/src/main/java/org/apache/shardingsphere/infra/spi/singleton/SingletonServiceLoader.java
+++ /dev/null
@@ -1,84 +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.infra.spi.singleton;
-
-import java.util.Collection;
-import java.util.LinkedList;
-import java.util.Map;
-import java.util.Optional;
-import java.util.ServiceLoader;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * Singleton service loader.
- */
-public final class SingletonServiceLoader<T> {
-
- private static final Map<Class<?>, SingletonServiceLoader<?>> LOADERS = new ConcurrentHashMap<>();
-
- private final Map<Class<?>, Collection<T>> serviceMap = new ConcurrentHashMap<>();
-
- private final Class<T> service;
-
- private SingletonServiceLoader(final Class<T> service) {
- this.service = service;
- register(service);
- }
-
- /**
- * Get singleton service loader.
- *
- * @param service service type
- * @param <T> type of service
- * @return singleton service loader.
- */
- @SuppressWarnings("unchecked")
- public static <T> SingletonServiceLoader<T> getServiceLoader(final Class<T> service) {
- if (null == service) {
- throw new NullPointerException("extension clazz is null");
- }
- if (!service.isInterface()) {
- throw new IllegalArgumentException("extension clazz (" + service + "is not interface!");
- }
- SingletonServiceLoader<T> serviceLoader = (SingletonServiceLoader<T>) LOADERS.get(service);
- if (null != serviceLoader) {
- return serviceLoader;
- }
- LOADERS.putIfAbsent(service, new SingletonServiceLoader<>(service));
- return (SingletonServiceLoader<T>) LOADERS.get(service);
- }
-
- /**
- * New service instances.
- *
- * @return service instances
- */
- public Optional<T> newServiceInstances() {
- return serviceMap.get(service).stream().findFirst();
- }
-
- private void register(final Class<T> service) {
- if (serviceMap.containsKey(service)) {
- return;
- }
- serviceMap.put(service, new LinkedList<>());
- for (T each : ServiceLoader.load(service)) {
- serviceMap.get(service).add(each);
- }
- }
-}
diff --git a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/spi/singleton/SingletonServiceLoaderTest.java b/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/spi/singleton/SingletonServiceLoaderTest.java
deleted file mode 100644
index b57ec04..0000000
--- a/shardingsphere-infra/shardingsphere-infra-common/src/test/java/org/apache/shardingsphere/infra/spi/singleton/SingletonServiceLoaderTest.java
+++ /dev/null
@@ -1,68 +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.infra.spi.singleton;
-
-import org.apache.shardingsphere.infra.spi.fixture.TypedSPIFixture;
-import org.apache.shardingsphere.infra.spi.type.TypedSPI;
-import org.junit.Test;
-
-import java.util.Optional;
-
-import static org.hamcrest.CoreMatchers.is;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertThat;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertFalse;
-
-public final class SingletonServiceLoaderTest {
-
- @Test
- public void assertGetSingletonServiceLoader() {
- SingletonServiceLoader<TypedSPIFixture> actualFirstServiceLoader = SingletonServiceLoader.getServiceLoader(TypedSPIFixture.class);
- assertNotNull(actualFirstServiceLoader);
- SingletonServiceLoader<TypedSPIFixture> actualSecondServiceLoader = SingletonServiceLoader.getServiceLoader(TypedSPIFixture.class);
- assertNotNull(actualSecondServiceLoader);
- assertThat(actualFirstServiceLoader, is(actualSecondServiceLoader));
- }
-
- @Test(expected = NullPointerException.class)
- public void assertGetSingletonServiceLoaderWhenServiceIsNull() {
- SingletonServiceLoader.getServiceLoader(null);
- }
-
- @Test(expected = IllegalArgumentException.class)
- public void assertGetSingletonServiceLoaderWhenServiceIsNotAnInterface() {
- SingletonServiceLoader.getServiceLoader(String.class);
- }
-
- @Test
- public void assertNewServiceInstanceWhenIsNotExist() {
- Optional<TypedSPIFixture> actual = SingletonServiceLoader.getServiceLoader(TypedSPIFixture.class).newServiceInstances();
- assertTrue(actual.isPresent());
- }
-
- @Test
- public void assertNewServiceInstanceWhenServiceDoesNotFind() {
- Optional<NoImplTypedSPI> actual = SingletonServiceLoader.getServiceLoader(NoImplTypedSPI.class).newServiceInstances();
- assertFalse(actual.isPresent());
- }
-
- interface NoImplTypedSPI extends TypedSPI {
-
- }
-}
diff --git a/shardingsphere-infra/pom.xml b/shardingsphere-infra/shardingsphere-infra-datetime/pom.xml
similarity index 76%
copy from shardingsphere-infra/pom.xml
copy to shardingsphere-infra/shardingsphere-infra-datetime/pom.xml
index d3060a5..9f406b7 100644
--- a/shardingsphere-infra/pom.xml
+++ b/shardingsphere-infra/shardingsphere-infra-datetime/pom.xml
@@ -22,19 +22,15 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere</artifactId>
+ <artifactId>shardingsphere-infra</artifactId>
<version>5.0.0-RC1-SNAPSHOT</version>
</parent>
- <artifactId>shardingsphere-infra</artifactId>
+ <artifactId>shardingsphere-infra-datetime</artifactId>
<packaging>pom</packaging>
<name>${project.artifactId}</name>
<modules>
- <module>shardingsphere-infra-common</module>
- <module>shardingsphere-infra-route</module>
- <module>shardingsphere-infra-rewrite</module>
- <module>shardingsphere-infra-executor</module>
- <module>shardingsphere-infra-merge</module>
- <module>shardingsphere-infra-context</module>
+ <module>shardingsphere-infra-datetime-spi</module>
+ <module>shardingsphere-infra-datetime-type</module>
</modules>
</project>
diff --git a/shardingsphere-infra/pom.xml b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-spi/pom.xml
similarity index 73%
copy from shardingsphere-infra/pom.xml
copy to shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-spi/pom.xml
index d3060a5..251d56b 100644
--- a/shardingsphere-infra/pom.xml
+++ b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-spi/pom.xml
@@ -22,19 +22,17 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere</artifactId>
+ <artifactId>shardingsphere-infra-datetime</artifactId>
<version>5.0.0-RC1-SNAPSHOT</version>
</parent>
- <artifactId>shardingsphere-infra</artifactId>
- <packaging>pom</packaging>
+ <artifactId>shardingsphere-infra-datetime-spi</artifactId>
<name>${project.artifactId}</name>
- <modules>
- <module>shardingsphere-infra-common</module>
- <module>shardingsphere-infra-route</module>
- <module>shardingsphere-infra-rewrite</module>
- <module>shardingsphere-infra-executor</module>
- <module>shardingsphere-infra-merge</module>
- <module>shardingsphere-infra-context</module>
- </modules>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-infra-common</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
</project>
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/datatime/DatetimeService.java b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-spi/src/main/java/org/apache/shardingsphere/infra/datetime/DatetimeService.java
similarity index 84%
rename from shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/datatime/DatetimeService.java
rename to shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-spi/src/main/java/org/apache/shardingsphere/infra/datetime/DatetimeService.java
index 13af220..e6f1544 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/datatime/DatetimeService.java
+++ b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-spi/src/main/java/org/apache/shardingsphere/infra/datetime/DatetimeService.java
@@ -15,14 +15,16 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sharding.route.datatime;
+package org.apache.shardingsphere.infra.datetime;
+
+import org.apache.shardingsphere.infra.spi.required.RequiredSPI;
import java.util.Date;
/**
* Datetime service.
*/
-public interface DatetimeService {
+public interface DatetimeService extends RequiredSPI {
/**
* Get datetime.
diff --git a/shardingsphere-infra/pom.xml b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/pom.xml
similarity index 76%
copy from shardingsphere-infra/pom.xml
copy to shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/pom.xml
index d3060a5..b02c3e3 100644
--- a/shardingsphere-infra/pom.xml
+++ b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/pom.xml
@@ -22,19 +22,15 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere</artifactId>
+ <artifactId>shardingsphere-infra-datetime</artifactId>
<version>5.0.0-RC1-SNAPSHOT</version>
</parent>
- <artifactId>shardingsphere-infra</artifactId>
+ <artifactId>shardingsphere-infra-datetime-type</artifactId>
<packaging>pom</packaging>
<name>${project.artifactId}</name>
<modules>
- <module>shardingsphere-infra-common</module>
- <module>shardingsphere-infra-route</module>
- <module>shardingsphere-infra-rewrite</module>
- <module>shardingsphere-infra-executor</module>
- <module>shardingsphere-infra-merge</module>
- <module>shardingsphere-infra-context</module>
+ <module>shardingsphere-system-datetime</module>
+ <module>shardingsphere-database-datetime</module>
</modules>
</project>
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/pom.xml b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/pom.xml
similarity index 78%
rename from shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/pom.xml
rename to shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/pom.xml
index 6307148..897b776 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/pom.xml
+++ b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/pom.xml
@@ -16,19 +16,26 @@
~ limitations under the License.
-->
-<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere-sharding</artifactId>
+ <artifactId>shardingsphere-infra-datetime-type</artifactId>
<version>5.0.0-RC1-SNAPSHOT</version>
</parent>
- <artifactId>shardingsphere-sharding-time-service</artifactId>
- <name>${project.artifactId}</name>
+ <artifactId>shardingsphere-database-datetime</artifactId>
<dependencies>
<dependency>
<groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-infra-datetime-spi</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
<artifactId>shardingsphere-sharding-route</artifactId>
<version>${project.version}</version>
</dependency>
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/main/java/org/apache/shardingsphere/sharding/route/time/DatabaseDatetimeServiceDelegate.java b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/DatabaseDatetimeServiceDelegate.java
similarity index 80%
rename from shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/main/java/org/apache/shardingsphere/sharding/route/time/DatabaseDatetimeServiceDelegate.java
rename to shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/DatabaseDatetimeServiceDelegate.java
index 25c11aa..8d12f44 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/main/java/org/apache/shardingsphere/sharding/route/time/DatabaseDatetimeServiceDelegate.java
+++ b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/DatabaseDatetimeServiceDelegate.java
@@ -15,10 +15,10 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sharding.route.time;
+package org.apache.shardingsphere.datetime.database;
-import org.apache.shardingsphere.sharding.route.datatime.DatetimeService;
-import org.apache.shardingsphere.sharding.route.time.impl.TimeServiceFactory;
+import org.apache.shardingsphere.infra.datetime.DatetimeService;
+import org.apache.shardingsphere.datetime.database.impl.TimeServiceFactory;
import java.util.Date;
@@ -33,4 +33,9 @@ public final class DatabaseDatetimeServiceDelegate implements DatetimeService {
public Date getDatetime() {
return INSTANCE.getDatetime();
}
+
+ @Override
+ public boolean isDefault() {
+ return false;
+ }
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/main/java/org/apache/shardingsphere/sharding/route/time/TimeServiceConfiguration.java b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/TimeServiceConfiguration.java
similarity index 95%
rename from shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/main/java/org/apache/shardingsphere/sharding/route/time/TimeServiceConfiguration.java
rename to shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/TimeServiceConfiguration.java
index a0c9f9d..470a13d 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/main/java/org/apache/shardingsphere/sharding/route/time/TimeServiceConfiguration.java
+++ b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/TimeServiceConfiguration.java
@@ -15,10 +15,10 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sharding.route.time;
+package org.apache.shardingsphere.datetime.database;
import lombok.Getter;
-import org.apache.shardingsphere.sharding.route.time.exception.TimeServiceInitException;
+import org.apache.shardingsphere.datetime.database.exception.TimeServiceInitException;
import javax.sql.DataSource;
import java.beans.IntrospectionException;
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/main/java/org/apache/shardingsphere/sharding/route/time/exception/NoDatabaseSQLEntrySupportException.java b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/exception/NoDatabaseSQLEntrySupportException.java
similarity index 93%
rename from shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/main/java/org/apache/shardingsphere/sharding/route/time/exception/NoDatabaseSQLEntrySupportException.java
rename to shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/exception/NoDatabaseSQLEntrySupportException.java
index a330c4d..ba9a5c0 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/main/java/org/apache/shardingsphere/sharding/route/time/exception/NoDatabaseSQLEntrySupportException.java
+++ b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/exception/NoDatabaseSQLEntrySupportException.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sharding.route.time.exception;
+package org.apache.shardingsphere.datetime.database.exception;
/**
* No database SQL entry support.
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/main/java/org/apache/shardingsphere/sharding/route/time/exception/TimeServiceInitException.java b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/exception/TimeServiceInitException.java
similarity index 94%
rename from shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/main/java/org/apache/shardingsphere/sharding/route/time/exception/TimeServiceInitException.java
rename to shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/exception/TimeServiceInitException.java
index 4a16969..293243f 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/main/java/org/apache/shardingsphere/sharding/route/time/exception/TimeServiceInitException.java
+++ b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/exception/TimeServiceInitException.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sharding.route.time.exception;
+package org.apache.shardingsphere.datetime.database.exception;
/**
* Time service init exception.
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/main/java/org/apache/shardingsphere/sharding/route/time/impl/DatabaseDatetimeService.java b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/impl/DatabaseDatetimeService.java
similarity index 89%
rename from shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/main/java/org/apache/shardingsphere/sharding/route/time/impl/DatabaseDatetimeService.java
rename to shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/impl/DatabaseDatetimeService.java
index 2b416b3..6a434a5 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/main/java/org/apache/shardingsphere/sharding/route/time/impl/DatabaseDatetimeService.java
+++ b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/impl/DatabaseDatetimeService.java
@@ -15,10 +15,10 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sharding.route.time.impl;
+package org.apache.shardingsphere.datetime.database.impl;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.sharding.route.datatime.DatetimeService;
+import org.apache.shardingsphere.infra.datetime.DatetimeService;
import javax.sql.DataSource;
import java.sql.Connection;
@@ -49,4 +49,9 @@ public final class DatabaseDatetimeService implements DatetimeService {
}
return new Date();
}
+
+ @Override
+ public boolean isDefault() {
+ return false;
+ }
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/main/java/org/apache/shardingsphere/sharding/route/time/impl/TimeServiceFactory.java b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/impl/TimeServiceFactory.java
similarity index 83%
rename from shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/main/java/org/apache/shardingsphere/sharding/route/time/impl/TimeServiceFactory.java
rename to shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/impl/TimeServiceFactory.java
index 9427708..a3244e1 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/main/java/org/apache/shardingsphere/sharding/route/time/impl/TimeServiceFactory.java
+++ b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/impl/TimeServiceFactory.java
@@ -15,13 +15,13 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sharding.route.time.impl;
+package org.apache.shardingsphere.datetime.database.impl;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
-import org.apache.shardingsphere.sharding.route.datatime.DatetimeService;
-import org.apache.shardingsphere.sharding.route.time.TimeServiceConfiguration;
-import org.apache.shardingsphere.sharding.route.time.spi.SPIDataBaseSQLEntry;
+import org.apache.shardingsphere.infra.datetime.DatetimeService;
+import org.apache.shardingsphere.datetime.database.TimeServiceConfiguration;
+import org.apache.shardingsphere.datetime.database.spi.SPIDataBaseSQLEntry;
/**
* Time service factory.
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/main/java/org/apache/shardingsphere/sharding/route/time/spi/DatabaseSQLEntry.java b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/spi/DatabaseSQLEntry.java
similarity index 95%
rename from shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/main/java/org/apache/shardingsphere/sharding/route/time/spi/DatabaseSQLEntry.java
rename to shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/spi/DatabaseSQLEntry.java
index 93ba309..64d75b6 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/main/java/org/apache/shardingsphere/sharding/route/time/spi/DatabaseSQLEntry.java
+++ b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/spi/DatabaseSQLEntry.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sharding.route.time.spi;
+package org.apache.shardingsphere.datetime.database.spi;
/**
* Database SQL entry.
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/main/java/org/apache/shardingsphere/sharding/route/time/spi/MySQLDatabaseSQLEntry.java b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/spi/MySQLDatabaseSQLEntry.java
similarity index 95%
rename from shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/main/java/org/apache/shardingsphere/sharding/route/time/spi/MySQLDatabaseSQLEntry.java
rename to shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/spi/MySQLDatabaseSQLEntry.java
index 67542b5..e89ddf5 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/main/java/org/apache/shardingsphere/sharding/route/time/spi/MySQLDatabaseSQLEntry.java
+++ b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/spi/MySQLDatabaseSQLEntry.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sharding.route.time.spi;
+package org.apache.shardingsphere.datetime.database.spi;
/**
* MySQL entry.
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/main/java/org/apache/shardingsphere/sharding/route/time/spi/OracleDatabaseSQLEntry.java b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/spi/OracleDatabaseSQLEntry.java
similarity index 95%
rename from shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/main/java/org/apache/shardingsphere/sharding/route/time/spi/OracleDatabaseSQLEntry.java
rename to shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/spi/OracleDatabaseSQLEntry.java
index f42528d..7beeda4 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/main/java/org/apache/shardingsphere/sharding/route/time/spi/OracleDatabaseSQLEntry.java
+++ b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/spi/OracleDatabaseSQLEntry.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sharding.route.time.spi;
+package org.apache.shardingsphere.datetime.database.spi;
/**
* Oracle entry.
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/main/java/org/apache/shardingsphere/sharding/route/time/spi/PostgreSQLDatabaseSQLEntry.java b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/spi/PostgreSQLDatabaseSQLEntry.java
similarity index 95%
rename from shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/main/java/org/apache/shardingsphere/sharding/route/time/spi/PostgreSQLDatabaseSQLEntry.java
rename to shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/spi/PostgreSQLDatabaseSQLEntry.java
index 363ea83..599941e 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/main/java/org/apache/shardingsphere/sharding/route/time/spi/PostgreSQLDatabaseSQLEntry.java
+++ b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/spi/PostgreSQLDatabaseSQLEntry.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sharding.route.time.spi;
+package org.apache.shardingsphere.datetime.database.spi;
/**
* PostgreSQL entry.
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/main/java/org/apache/shardingsphere/sharding/route/time/spi/SPIDataBaseSQLEntry.java b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/spi/SPIDataBaseSQLEntry.java
similarity index 91%
rename from shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/main/java/org/apache/shardingsphere/sharding/route/time/spi/SPIDataBaseSQLEntry.java
rename to shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/spi/SPIDataBaseSQLEntry.java
index 6748b2a..c3344a6 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/main/java/org/apache/shardingsphere/sharding/route/time/spi/SPIDataBaseSQLEntry.java
+++ b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/spi/SPIDataBaseSQLEntry.java
@@ -15,10 +15,10 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sharding.route.time.spi;
+package org.apache.shardingsphere.datetime.database.spi;
import lombok.RequiredArgsConstructor;
-import org.apache.shardingsphere.sharding.route.time.exception.NoDatabaseSQLEntrySupportException;
+import org.apache.shardingsphere.datetime.database.exception.NoDatabaseSQLEntrySupportException;
import org.apache.shardingsphere.infra.spi.ShardingSphereServiceLoader;
import java.util.Collection;
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/main/java/org/apache/shardingsphere/sharding/route/time/spi/SQLServerDatabaseSQLEntry.java b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/spi/SQLServerDatabaseSQLEntry.java
similarity index 95%
rename from shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/main/java/org/apache/shardingsphere/sharding/route/time/spi/SQLServerDatabaseSQLEntry.java
rename to shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/spi/SQLServerDatabaseSQLEntry.java
index ca9ff3e..d101421 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/main/java/org/apache/shardingsphere/sharding/route/time/spi/SQLServerDatabaseSQLEntry.java
+++ b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/java/org/apache/shardingsphere/datetime/database/spi/SQLServerDatabaseSQLEntry.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sharding.route.time.spi;
+package org.apache.shardingsphere.datetime.database.spi;
/**
* SQLServer entry.
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/main/resources/META-INF/services/org.apache.shardingsphere.sharding.route.datatime.DatetimeService b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.datetime.DatetimeService
similarity index 90%
rename from shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/main/resources/META-INF/services/org.apache.shardingsphere.sharding.route.datatime.DatetimeService
rename to shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.datetime.DatetimeService
index 957abd5..f52f04f 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/main/resources/META-INF/services/org.apache.shardingsphere.sharding.route.datatime.DatetimeService
+++ b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.datetime.DatetimeService
@@ -15,4 +15,4 @@
# limitations under the License.
#
-org.apache.shardingsphere.sharding.route.time.DatabaseDatetimeServiceDelegate
+org.apache.shardingsphere.datetime.database.DatabaseDatetimeServiceDelegate
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/main/resources/META-INF/services/org.apache.shardingsphere.sharding.route.time.spi.DatabaseSQLEntry b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/resources/META-INF/services/org.apache.shardingsphere.sharding.route.time.org.apache.shardingsphere.datetime.database.spi.DatabaseSQLEntry
similarity index 72%
rename from shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/main/resources/META-INF/services/org.apache.shardingsphere.sharding.route.time.spi.DatabaseSQLEntry
rename to shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/resources/META-INF/services/org.apache.shardingsphere.sharding.route.time.org.apache.shardingsphere.datetime.database.spi.DatabaseSQLEntry
index 41a016a..2e11df0 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/main/resources/META-INF/services/org.apache.shardingsphere.sharding.route.time.spi.DatabaseSQLEntry
+++ b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/resources/META-INF/services/org.apache.shardingsphere.sharding.route.time.org.apache.shardingsphere.datetime.database.spi.DatabaseSQLEntry
@@ -15,7 +15,7 @@
# limitations under the License.
#
-org.apache.shardingsphere.sharding.route.time.spi.MySQLDatabaseSQLEntry
-org.apache.shardingsphere.sharding.route.time.spi.PostgreSQLDatabaseSQLEntry
-org.apache.shardingsphere.sharding.route.time.spi.OracleDatabaseSQLEntry
-org.apache.shardingsphere.sharding.route.time.spi.SQLServerDatabaseSQLEntry
+org.apache.shardingsphere.datetime.database.spi.MySQLDatabaseSQLEntry
+org.apache.shardingsphere.datetime.database.spi.PostgreSQLDatabaseSQLEntry
+org.apache.shardingsphere.datetime.database.spi.OracleDatabaseSQLEntry
+org.apache.shardingsphere.datetime.database.spi.SQLServerDatabaseSQLEntry
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/main/resources/time-service.properties b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/resources/time-service.properties
similarity index 100%
rename from shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/main/resources/time-service.properties
rename to shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/main/resources/time-service.properties
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/test/java/org/apache/shardingsphere/sharding/route/time/PropertiesUtils.java b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/java/org/apache/shardingsphere/datetime/database/PropertiesUtils.java
similarity index 97%
rename from shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/test/java/org/apache/shardingsphere/sharding/route/time/PropertiesUtils.java
rename to shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/java/org/apache/shardingsphere/datetime/database/PropertiesUtils.java
index 3a11815..add23dc 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/test/java/org/apache/shardingsphere/sharding/route/time/PropertiesUtils.java
+++ b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/java/org/apache/shardingsphere/datetime/database/PropertiesUtils.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sharding.route.time;
+package org.apache.shardingsphere.datetime.database;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/test/java/org/apache/shardingsphere/sharding/route/time/TimeServiceConfigurationTest.java b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/java/org/apache/shardingsphere/datetime/database/TimeServiceConfigurationTest.java
similarity index 95%
copy from shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/test/java/org/apache/shardingsphere/sharding/route/time/TimeServiceConfigurationTest.java
copy to shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/java/org/apache/shardingsphere/datetime/database/TimeServiceConfigurationTest.java
index 5b727ce..f0d66b4 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/test/java/org/apache/shardingsphere/sharding/route/time/TimeServiceConfigurationTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/java/org/apache/shardingsphere/datetime/database/TimeServiceConfigurationTest.java
@@ -15,7 +15,7 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sharding.route.time;
+package org.apache.shardingsphere.datetime.database;
import org.junit.Test;
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/test/resources/logback-test.xml b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/resources/logback-test.xml
similarity index 100%
rename from shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/test/resources/logback-test.xml
rename to shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-database-datetime/src/test/resources/logback-test.xml
diff --git a/shardingsphere-infra/pom.xml b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-system-datetime/pom.xml
similarity index 70%
copy from shardingsphere-infra/pom.xml
copy to shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-system-datetime/pom.xml
index d3060a5..955c01a 100644
--- a/shardingsphere-infra/pom.xml
+++ b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-system-datetime/pom.xml
@@ -22,19 +22,16 @@
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.apache.shardingsphere</groupId>
- <artifactId>shardingsphere</artifactId>
+ <artifactId>shardingsphere-infra-datetime-type</artifactId>
<version>5.0.0-RC1-SNAPSHOT</version>
</parent>
- <artifactId>shardingsphere-infra</artifactId>
- <packaging>pom</packaging>
- <name>${project.artifactId}</name>
+ <artifactId>shardingsphere-system-datetime</artifactId>
- <modules>
- <module>shardingsphere-infra-common</module>
- <module>shardingsphere-infra-route</module>
- <module>shardingsphere-infra-rewrite</module>
- <module>shardingsphere-infra-executor</module>
- <module>shardingsphere-infra-merge</module>
- <module>shardingsphere-infra-context</module>
- </modules>
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.shardingsphere</groupId>
+ <artifactId>shardingsphere-infra-datetime-spi</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ </dependencies>
</project>
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/datatime/DefaultDatetimeService.java b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-system-datetime/src/main/java/org/apache/shardingsphere/datetime/system/SystemDatetimeService.java
similarity index 78%
rename from shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/datatime/DefaultDatetimeService.java
rename to shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-system-datetime/src/main/java/org/apache/shardingsphere/datetime/system/SystemDatetimeService.java
index c51ce6d..8f628ea 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/main/java/org/apache/shardingsphere/sharding/route/datatime/DefaultDatetimeService.java
+++ b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-system-datetime/src/main/java/org/apache/shardingsphere/datetime/system/SystemDatetimeService.java
@@ -15,17 +15,24 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sharding.route.datatime;
+package org.apache.shardingsphere.datetime.system;
+
+import org.apache.shardingsphere.infra.datetime.DatetimeService;
import java.util.Date;
/**
* Default datetime service.
*/
-public final class DefaultDatetimeService implements DatetimeService {
+public final class SystemDatetimeService implements DatetimeService {
@Override
public Date getDatetime() {
return new Date();
}
+
+ @Override
+ public boolean isDefault() {
+ return true;
+ }
}
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/test/resources/META-INF/services/org.apache.shardingsphere.sharding.route.datatime.DatetimeService b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-system-datetime/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.datetime.DatetimeService
similarity index 90%
rename from shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/test/resources/META-INF/services/org.apache.shardingsphere.sharding.route.datatime.DatetimeService
rename to shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-system-datetime/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.datetime.DatetimeService
index c2fc432..c0030bd 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-route/src/test/resources/META-INF/services/org.apache.shardingsphere.sharding.route.datatime.DatetimeService
+++ b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-system-datetime/src/main/resources/META-INF/services/org.apache.shardingsphere.infra.datetime.DatetimeService
@@ -15,4 +15,4 @@
# limitations under the License.
#
-org.apache.shardingsphere.sharding.route.datatime.fixture.DatetimeServiceFixture
+org.apache.shardingsphere.datetime.system.SystemDatetimeService
diff --git a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/test/java/org/apache/shardingsphere/sharding/route/time/TimeServiceConfigurationTest.java b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-system-datetime/src/test/java/org/apache/shardingsphere/datetime/system/SystemDatetimeServiceTest.java
similarity index 67%
rename from shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/test/java/org/apache/shardingsphere/sharding/route/time/TimeServiceConfigurationTest.java
rename to shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-system-datetime/src/test/java/org/apache/shardingsphere/datetime/system/SystemDatetimeServiceTest.java
index 5b727ce..df2e29d 100644
--- a/shardingsphere-features/shardingsphere-sharding/shardingsphere-sharding-time-service/src/test/java/org/apache/shardingsphere/sharding/route/time/TimeServiceConfigurationTest.java
+++ b/shardingsphere-infra/shardingsphere-infra-datetime/shardingsphere-infra-datetime-type/shardingsphere-system-datetime/src/test/java/org/apache/shardingsphere/datetime/system/SystemDatetimeServiceTest.java
@@ -15,20 +15,21 @@
* limitations under the License.
*/
-package org.apache.shardingsphere.sharding.route.time;
+package org.apache.shardingsphere.datetime.system;
import org.junit.Test;
-import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
-public final class TimeServiceConfigurationTest {
+public final class SystemDatetimeServiceTest {
@Test
- public void assertInitDataSource() {
- PropertiesUtils.createProperties("com.mysql.jdbc.Driver", null);
- TimeServiceConfiguration config = TimeServiceConfiguration.getInstance();
- assertNotNull(config.getDataSource());
- assertTrue(PropertiesUtils.remove());
+ public void assertGetDatetime() {
+ assertTrue(new SystemDatetimeService().getDatetime().getTime() <= System.currentTimeMillis());
+ }
+
+ @Test
+ public void assertIsDefault() {
+ assertTrue(new SystemDatetimeService().isDefault());
}
}