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

replaced Joda Time by Java Time #1342

Merged
merged 4 commits into from
Jan 25, 2020
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions bom/compile/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -178,14 +178,6 @@
<scope>compile</scope>
</dependency>

<!-- Joda Time -->
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.9.2</version>
<scope>compile</scope>
</dependency>

<!-- jUPnP -->
<dependency>
<groupId>org.jupnp</groupId>
Expand Down
8 changes: 0 additions & 8 deletions bom/runtime/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -885,14 +885,6 @@
<scope>compile</scope>
</dependency>

<!-- Joda Time -->
<dependency>
<groupId>joda-time</groupId>
<artifactId>joda-time</artifactId>
<version>2.9.2</version>
<scope>compile</scope>
</dependency>

<!-- ... -->
<dependency>
<groupId>com.eclipsesource.jaxrs</groupId>
Expand Down
7 changes: 0 additions & 7 deletions bundles/org.openhab.core.model.persistence/NOTICE
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,6 @@ https://www.eclipse.org/legal/epl-2.0/.
https://github.com/openhab/openhab-core


== Third-party Content

org.joda.time Version: 2.9.2
* License: Apache License, 2.0
* Project: www.joda.org/joda-time/
* Source: https://github.com/JodaOrg/joda-time/tree/v2.9.2

== Third-party license(s)

=== Apache License, 2.0
Expand Down
3 changes: 1 addition & 2 deletions bundles/org.openhab.core.model.persistence/bnd.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ Import-Package: \
org.eclipse.jdt.annotation;resolution:=optional,\
org.eclipse.xtext.xbase.lib,\
org.osgi.*,\
org.slf4j.*,\
org.joda.*
org.slf4j.*
Require-Bundle: org.antlr.runtime,\
org.eclipse.emf.codegen.ecore;resolution:=optional,\
org.eclipse.emf.common,\
Expand Down
2 changes: 1 addition & 1 deletion bundles/org.openhab.core.model.persistence/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<artifactId>org.openhab.core.reactor.bundles</artifactId>
<version>3.0.0-SNAPSHOT</version>
</parent>

<artifactId>org.openhab.core.model.persistence</artifactId>

<name>openHAB Core :: Bundles :: Model Persistence</name>
Expand Down

Large diffs are not rendered by default.

2 changes: 0 additions & 2 deletions bundles/org.openhab.core.model.rule/bnd.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ Import-Package: \
org.apache.commons.lang,\
org.eclipse.jdt.annotation;resolution:=optional,\
org.eclipse.xtext.xbase.lib,\
org.joda.time,\
org.joda.time.base,\
org.osgi.*,\
org.quartz,\
org.quartz.impl,\
Expand Down
1 change: 0 additions & 1 deletion bundles/org.openhab.core.model.script/bnd.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ Import-Package: \
org.eclipse.jdt.annotation;resolution:=optional,\
org.eclipse.jetty.http.*,\
org.eclipse.xtext.xbase.lib,\
org.joda.*,\
org.osgi.*,\
org.quartz.*,\
org.slf4j.*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,20 @@
import static org.quartz.JobBuilder.newJob;
import static org.quartz.TriggerBuilder.newTrigger;

import java.time.Instant;
import java.util.Date;

import org.apache.commons.lang.StringUtils;
import org.eclipse.xtext.xbase.XExpression;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure0;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.openhab.core.model.core.ModelRepository;
import org.openhab.core.model.script.ScriptServiceUtil;
import org.openhab.core.model.script.engine.Script;
import org.openhab.core.model.script.engine.ScriptEngine;
import org.openhab.core.model.script.engine.ScriptExecutionException;
import org.openhab.core.model.script.internal.actions.TimerExecutionJob;
import org.openhab.core.model.script.internal.actions.TimerImpl;
import org.eclipse.xtext.xbase.XExpression;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure0;
import org.eclipse.xtext.xbase.lib.Procedures.Procedure1;
import org.joda.time.base.AbstractInstant;
import org.quartz.JobDataMap;
import org.quartz.JobDetail;
import org.quartz.JobKey;
Expand Down Expand Up @@ -87,7 +89,7 @@ public static Object callScript(String scriptName) throws ScriptExecutionExcepti
* @return a handle to the created timer, so that it can be canceled or rescheduled
* @throws ScriptExecutionException if an error occurs during the execution
*/
public static Timer createTimer(AbstractInstant instant, Procedure0 closure) {
public static Timer createTimer(Instant instant, Procedure0 closure) {
JobDataMap dataMap = new JobDataMap();
dataMap.put("procedure", closure);
return makeTimer(instant, closure.toString(), dataMap);
Expand All @@ -103,7 +105,7 @@ public static Timer createTimer(AbstractInstant instant, Procedure0 closure) {
* @return a handle to the created timer, so that it can be canceled or rescheduled
* @throws ScriptExecutionException if an error occurs during the execution
*/
public static Timer createTimerWithArgument(AbstractInstant instant, Object arg1, Procedure1<Object> closure) {
public static Timer createTimerWithArgument(Instant instant, Object arg1, Procedure1<Object> closure) {
JobDataMap dataMap = new JobDataMap();
dataMap.put("procedure1", closure);
dataMap.put("argument1", arg1);
Expand All @@ -118,11 +120,11 @@ public static Timer createTimerWithArgument(AbstractInstant instant, Object arg1
* @param dataMap job data map, preconfigured with arguments
* @return
*/
private static Timer makeTimer(AbstractInstant instant, String closure, JobDataMap dataMap) {
private static Timer makeTimer(Instant instant, String closure, JobDataMap dataMap) {

Logger logger = LoggerFactory.getLogger(ScriptExecution.class);
JobKey jobKey = new JobKey(getTimerId() + " " + instant.toString() + ": " + closure.toString());
Trigger trigger = newTrigger().startAt(instant.toDate()).build();
Trigger trigger = newTrigger().startAt(Date.from(instant)).build();
Timer timer = new TimerImpl(jobKey, trigger.getKey(), dataMap, instant);
try {
JobDetail job = newJob(TimerExecutionJob.class).withIdentity(jobKey).usingJobData(dataMap).build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
package org.openhab.core.model.script.actions;

import org.joda.time.base.AbstractInstant;
import java.time.Instant;

/**
* A timer is a handle for a block of code that is scheduled for future execution. A timer
Expand All @@ -25,21 +25,21 @@ public interface Timer {

/**
* Cancels the timer
*
*
* @return true, if cancellation was successful
*/
public boolean cancel();

/**
* Determines whether the scheduled code is currently executed.
*
*
* @return true, if the code is being executed, false otherwise
*/
public boolean isRunning();

/**
* Determines whether the scheduled execution has already terminated.
*
*
* @return true, if the scheduled execution has already terminated, false otherwise
*/
public boolean hasTerminated();
Expand All @@ -48,10 +48,10 @@ public interface Timer {
* Reschedules a timer to a new starting time.
* This can also be called after a timer has terminated, which will result in another
* execution of the same code.
*
*
* @param newTime the new time to execute the code
* @return true, if the rescheduling was done successful
*/
public boolean reschedule(AbstractInstant newTime);
public boolean reschedule(Instant newTime);

}
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,10 @@
import static org.quartz.JobBuilder.newJob;
import static org.quartz.TriggerBuilder.newTrigger;

import java.time.Instant;
import java.util.Date;

import org.openhab.core.model.script.actions.Timer;
import org.joda.time.DateTime;
import org.joda.time.base.AbstractInstant;
import org.quartz.JobDataMap;
import org.quartz.JobDetail;
import org.quartz.JobExecutionContext;
Expand Down Expand Up @@ -56,12 +55,12 @@ public class TimerImpl implements Timer {
private final JobKey jobKey;
private TriggerKey triggerKey;
private final JobDataMap dataMap;
private final AbstractInstant startTime;
private final Instant startTime;

private boolean cancelled = false;
private boolean terminated = false;

public TimerImpl(JobKey jobKey, TriggerKey triggerKey, JobDataMap dataMap, AbstractInstant startTime) {
public TimerImpl(JobKey jobKey, TriggerKey triggerKey, JobDataMap dataMap, Instant startTime) {
this.jobKey = jobKey;
this.triggerKey = triggerKey;
this.dataMap = dataMap;
Expand All @@ -83,9 +82,9 @@ public boolean cancel() {
}

@Override
public boolean reschedule(AbstractInstant newTime) {
public boolean reschedule(Instant newTime) {
try {
Trigger trigger = newTrigger().startAt(newTime.toDate()).build();
Trigger trigger = newTrigger().startAt(Date.from(newTime)).build();
Date nextTriggerTime = scheduler.rescheduleJob(triggerKey, trigger);
if (nextTriggerTime == null) {
logger.debug("Scheduling a new job job '{}' because the original has already run", jobKey.toString());
Expand Down Expand Up @@ -114,7 +113,7 @@ public boolean isRunning() {
} catch (SchedulerException e) {
// fallback implementation
logger.debug("An error occurred getting currently running jobs: {}", e.getMessage());
return DateTime.now().isAfter(startTime) && !terminated;
return Instant.now().isAfter(startTime) && !terminated;
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,13 @@
import java.math.BigDecimal;
import java.math.BigInteger;
import java.net.URLEncoder;
import java.time.Instant;
import java.time.ZonedDateTime;
import java.util.ArrayList;
import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.eclipse.xtext.xbase.scoping.batch.ImplicitlyImportedFeatures;
import org.joda.time.DateTime;
import org.openhab.core.library.unit.BinaryPrefix;
import org.openhab.core.library.unit.ImperialUnits;
import org.openhab.core.library.unit.MetricPrefix;
Expand Down Expand Up @@ -108,8 +109,9 @@ protected List<Class<?>> getStaticImportClasses() {
result.add(SmartHomeUnits.class);
result.add(BinaryPrefix.class);

// jodatime static functions
result.add(DateTime.class);
// date time static functions
result.add(Instant.class);
result.add(ZonedDateTime.class);

result.addAll(getActionClasses());
return result;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,16 @@

public class ScriptImportSectionNamespaceScopeProvider extends XImportSectionNamespaceScopeProvider {

public static final QualifiedName CORE_LIBRARY_TYPES_PACKAGE = QualifiedName.create("org", "openhab",
"core", "library", "types");
public static final QualifiedName CORE_LIBRARY_ITEMS_PACKAGE = QualifiedName.create("org", "openhab",
"core", "library", "items");
public static final QualifiedName CORE_ITEMS_PACKAGE = QualifiedName.create("org", "openhab", "core",
"items");
public static final QualifiedName CORE_PERSISTENCE_PACKAGE = QualifiedName.create("org", "openhab",
"core", "persistence");
public static final QualifiedName MODEL_SCRIPT_ACTIONS_PACKAGE = QualifiedName.create("org", "openhab",
"core", "model", "script", "actions");
public static final QualifiedName JODA_TIME_PACKAGE = QualifiedName.create("org", "joda", "time");
public static final QualifiedName CORE_LIBRARY_TYPES_PACKAGE = QualifiedName.create("org", "openhab", "core",
"library", "types");
public static final QualifiedName CORE_LIBRARY_ITEMS_PACKAGE = QualifiedName.create("org", "openhab", "core",
"library", "items");
public static final QualifiedName CORE_ITEMS_PACKAGE = QualifiedName.create("org", "openhab", "core", "items");
public static final QualifiedName CORE_PERSISTENCE_PACKAGE = QualifiedName.create("org", "openhab", "core",
"persistence");
public static final QualifiedName MODEL_SCRIPT_ACTIONS_PACKAGE = QualifiedName.create("org", "openhab", "core",
"model", "script", "actions");
public static final QualifiedName TIME_PACKAGE = QualifiedName.create("java", "time");

@Override
protected List<ImportNormalizer> getImplicitImports(boolean ignoreCase) {
Expand All @@ -40,7 +39,7 @@ protected List<ImportNormalizer> getImplicitImports(boolean ignoreCase) {
implicitImports.add(doCreateImportNormalizer(CORE_ITEMS_PACKAGE, true, false));
implicitImports.add(doCreateImportNormalizer(CORE_PERSISTENCE_PACKAGE, true, false));
implicitImports.add(doCreateImportNormalizer(MODEL_SCRIPT_ACTIONS_PACKAGE, true, false));
implicitImports.add(doCreateImportNormalizer(JODA_TIME_PACKAGE, true, false));
implicitImports.add(doCreateImportNormalizer(TIME_PACKAGE, true, false));
return implicitImports;
}

Expand Down
1 change: 0 additions & 1 deletion features/karaf/openhab-tp/src/main/feature/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@

<!-- TODO: Unbundled libraries -->
<bundle dependency="true">mvn:org.apache.servicemix.bundles/org.apache.servicemix.bundles.xstream/1.4.7_1</bundle>
<bundle dependency="true">mvn:joda-time/joda-time/2.9.2</bundle>
</feature>

<feature name="openhab.tp-coap" description="Californium CoAP library" version="${project.version}">
Expand Down
1 change: 0 additions & 1 deletion itests/org.openhab.core.model.core.tests/itest.bndrun
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ Fragment-Host: org.openhab.core.model.core
org.eclipse.xtext.util;version='[2.19.0,2.19.1)',\
org.eclipse.xtext.xbase.lib;version='[2.19.0,2.19.1)',\
io.github.classgraph;version='[4.8.35,4.8.36)',\
joda-time;version='[2.9.2,2.9.3)',\
org.eclipse.xtext.common.types;version='[2.19.0,2.19.1)',\
org.objectweb.asm;version='[7.1.0,7.1.1)',\
jollyday;version='[0.5.8,0.5.9)',\
Expand Down
1 change: 0 additions & 1 deletion itests/org.openhab.core.model.item.tests/itest.bndrun
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ Fragment-Host: org.openhab.core.model.item
org.apache.felix.http.servlet-api;version='[1.1.2,1.1.3)',\
osgi.enroute.hamcrest.wrapper;version='[1.3.0,1.3.1)',\
osgi.enroute.junit.wrapper;version='[4.12.0,4.12.1)',\
joda-time;version='[2.9.2,2.9.3)',\
org.apache.felix.configadmin;version='[1.9.8,1.9.9)',\
org.eclipse.equinox.event;version='[1.4.300,1.4.301)',\
tec.uom.lib.uom-lib-common;version='[1.0.3,1.0.4)',\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ Fragment-Host: org.openhab.core.model.persistence
-runbundles: \
com.google.inject;version='[3.0.0,3.0.1)',\
javax.measure.unit-api;version='[1.0.0,1.0.1)',\
joda-time;version='[2.9.2,2.9.3)',\
log4j;version='[1.2.17,1.2.18)',\
org.antlr.runtime;version='[3.2.0,3.2.1)',\
org.apache.commons.io;version='[2.2.0,2.2.1)',\
Expand Down
Loading