Skip to content

Commit

Permalink
some further adaption
Browse files Browse the repository at this point in the history
Signed-off-by: Kai Kreuzer <[email protected]>
  • Loading branch information
kaikreuzer committed Apr 28, 2019
1 parent 8e1a0ae commit 59dcd00
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@
import java.util.concurrent.ConcurrentLinkedQueue;

import org.apache.commons.lang.StringUtils;
import org.eclipse.jetty.server.HttpTransport;
import org.eclipse.jetty.util.security.Credential;
import org.joda.time.DateTime;
import org.openhab.core.items.Item;
import org.openhab.core.persistence.PersistenceService;
import org.openhab.io.gcal.auth.GCalGoogleOAuth;
Expand All @@ -39,23 +42,17 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.api.client.auth.oauth2.Credential;
import com.google.api.client.http.HttpTransport;
import com.google.api.client.http.javanet.NetHttpTransport;
import com.google.api.client.json.JsonFactory;
import com.google.api.client.json.jackson2.JacksonFactory;
import com.google.api.client.util.DateTime;
import com.google.api.services.calendar.Calendar;
import com.google.api.services.calendar.model.CalendarListEntry;
import com.google.api.services.calendar.model.Event;
import com.google.api.services.calendar.model.EventDateTime;

/**
* This implementation of the {@link PersistenceService} provides Presence
* Simulation features based on the Google Calendar Service.
*
* @author Thomas.Eichstaedt-Engelen
* @since 1.0.0
* @author Thomas.Eichstaedt-Engelen - Initial contribution
* @author Kai Kreuzer - Migration to 2.x
*/
public class GCalPersistenceService implements PersistenceService {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@
import org.openhab.core.persistence.PersistenceService;
import org.openhab.core.persistence.QueryablePersistenceService;
import org.osgi.framework.BundleContext;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;
import org.osgi.service.component.annotations.Reference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

Expand All @@ -76,8 +80,9 @@
*
* @author Theo Weiss - Initial Contribution, rewrite of org.openhab.persistence.influxdb > 0.9
* support
* @since 1.8.0
* @author Kai Kreuzer - Migration to 2.x
*/
@Component
public class InfluxDBPersistenceService implements QueryablePersistenceService {

private static final String DEFAULT_URL = "http://127.0.0.1:8086";
Expand All @@ -100,6 +105,7 @@ public class InfluxDBPersistenceService implements QueryablePersistenceService {
private boolean isProperlyConfigured;
private boolean connected;

@Reference
public void setItemRegistry(ItemRegistry itemRegistry) {
this.itemRegistry = itemRegistry;
}
Expand All @@ -108,6 +114,7 @@ public void unsetItemRegistry(ItemRegistry itemRegistry) {
this.itemRegistry = null;
}

@Activate
public void activate(final BundleContext bundleContext, final Map<String, Object> config) {
logger.debug("influxdb persistence service activated");
disconnect();
Expand Down Expand Up @@ -152,6 +159,7 @@ public void activate(final BundleContext bundleContext, final Map<String, Object
}
}

@Deactivate
public void deactivate() {
logger.debug("influxdb persistence service deactivated");
disconnect();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,19 @@
import org.openhab.core.persistence.PersistenceService;
import org.openhab.core.persistence.QueryablePersistenceService;
import org.osgi.framework.BundleContext;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.component.annotations.Deactivate;
import org.osgi.service.component.annotations.Reference;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* @author Helmut Lehmeyer
* @author Helmut Lehmeyer - Initial contribution
* @author Kai Kreuzer - Migration to 2.x
*
*/
@Component
public class JdbcPersistenceService extends JdbcMapper implements QueryablePersistenceService {
static final Logger logger = LoggerFactory.getLogger(JdbcPersistenceService.class);

Expand All @@ -58,6 +64,7 @@ public class JdbcPersistenceService extends JdbcMapper implements QueryablePersi
* Configuration properties for this component obtained from the
* ConfigAdmin service
*/
@Activate
public void activate(BundleContext bundleContext, Map<Object, Object> configuration) {
logger.debug("JDBC::activate: persistence service activated");
this.bundleContext = bundleContext;
Expand All @@ -81,13 +88,15 @@ public void activate(BundleContext bundleContext, Map<Object, Object> configurat
* <li>6 – The bundle was stopped
* </ul>
*/
@Deactivate
public void deactivate(final int reason) {
logger.debug("JDBC::deactivate: persistence bundle stopping. Disconnecting from database. reason={}", reason);
// closeConnection();
this.bundleContext = null;
initialized = false;
}

@Reference
public void setItemRegistry(ItemRegistry itemRegistry) {
logger.debug("JDBC::setItemRegistry");
this.itemRegistry = itemRegistry;
Expand Down
2 changes: 2 additions & 0 deletions features/karaf/openhab-addons/src/main/feature/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -985,12 +985,14 @@
<feature name="openhab-persistence-mysql" description="MySQL Persistence" version="${project.version}">
<feature>openhab-runtime-base</feature>
<bundle start-level="80">mvn:org.openhab.persistence/org.openhab.persistence.mysql/${project.version}</bundle>
<bundle start-level="80">mvn:mysql/mysql-connector-java/8.0.13</bundle>
<configfile finalname="${openhab.conf}/services/mysql.cfg" override="false">mvn:${project.groupId}/openhab-addons-external/${project.version}/cfg/mysql</configfile>
</feature>

<feature name="openhab-persistence-rrd4j" description="RRD4j Persistence" version="${project.version}">
<feature>openhab-runtime-base</feature>
<bundle start-level="80">mvn:org.openhab.persistence/org.openhab.persistence.rrd4j/${project.version}</bundle>
<bundle start-level="80">mvn:org.rrd4j/rrd4j/3.3.1</bundle>
<configfile finalname="${openhab.conf}/services/rrd4j.cfg" override="false">mvn:${project.groupId}/openhab-addons-external/${project.version}/cfg/rrd4j</configfile>
</feature>

Expand Down

0 comments on commit 59dcd00

Please sign in to comment.