This repository has been archived by the owner on Jan 9, 2018. It is now read-only.
forked from eclipse-archived/smarthome
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allow non-model based persistence configuration (eclipse-archived#2094)
* allow non-model based persistence configuration Signed-off-by: Markus Rathgeb <maggu2810@gmail.com>
- Loading branch information
Showing
19 changed files
with
1,074 additions
and
580 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
bundles/core/org.eclipse.smarthome.core.persistence/OSGI-INF/persistencemanager.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<!-- | ||
Copyright (c) 2014-2016 by the respective copyright holders. | ||
All rights reserved. This program and the accompanying materials | ||
are made available under the terms of the Eclipse Public License v1.0 | ||
which accompanies this distribution, and is available at | ||
http://www.eclipse.org/legal/epl-v10.html | ||
--> | ||
<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" immediate="true" name="org.eclipse.smarthome.core.persistence.persistencemanager"> | ||
<implementation class="org.eclipse.smarthome.core.persistence.internal.PersistenceManagerImpl"/> | ||
<service> | ||
<provide interface="org.eclipse.smarthome.core.persistence.PersistenceManager"/> | ||
</service> | ||
<reference bind="addPersistenceService" cardinality="0..n" interface="org.eclipse.smarthome.core.persistence.PersistenceService" name="PersistenceService" policy="dynamic" unbind="removePersistenceService"/> | ||
<reference bind="setItemRegistry" cardinality="0..1" interface="org.eclipse.smarthome.core.items.ItemRegistry" name="ItemRegistry" policy="dynamic" unbind="unsetItemRegistry"/> | ||
</scr:component> |
45 changes: 45 additions & 0 deletions
45
....persistence/src/main/java/org/eclipse/smarthome/core/persistence/PersistenceManager.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* Copyright (c) 2014-2016 by the respective copyright holders. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package org.eclipse.smarthome.core.persistence; | ||
|
||
/** | ||
* A persistence manager service which could be used to start event handling or supply configuration for persistence | ||
* services. | ||
* | ||
* @author Markus Rathgeb - Initial contribution and API | ||
*/ | ||
public interface PersistenceManager { | ||
/** | ||
* Add a configuration for a persistence service. | ||
* | ||
* @param dbId the database id used by the persistence service | ||
* @param config the configuration of the persistence service | ||
*/ | ||
void addConfig(String dbId, PersistenceServiceConfiguration config); | ||
|
||
/** | ||
* Remove a configuration for a persistence service. | ||
* | ||
* @param dbId the database id used by the persistence service | ||
*/ | ||
void removeConfig(String dbId); | ||
|
||
/** | ||
* Start the event handling for a persistence service. | ||
* | ||
* @param dbId the database id used by the persistence service | ||
*/ | ||
void startEventHandling(String dbId); | ||
|
||
/** | ||
* Stop the event handling for a persistence service. | ||
* | ||
* @param dbId the database id used by the persistence service | ||
*/ | ||
void stopEventHandling(String dbId); | ||
} |
60 changes: 60 additions & 0 deletions
60
...src/main/java/org/eclipse/smarthome/core/persistence/PersistenceServiceConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
/** | ||
* Copyright (c) 2014-2016 by the respective copyright holders. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package org.eclipse.smarthome.core.persistence; | ||
|
||
import java.util.Collections; | ||
import java.util.LinkedList; | ||
import java.util.List; | ||
|
||
import org.eclipse.smarthome.core.persistence.strategy.SimpleStrategy; | ||
|
||
/** | ||
* This class represents the configuration for a persistence service. | ||
* | ||
* @author Markus Rathgeb - Initial contribution and API | ||
*/ | ||
public class PersistenceServiceConfiguration { | ||
private final List<SimpleItemConfiguration> configs; | ||
private final List<SimpleStrategy> defaults; | ||
private final List<SimpleStrategy> strategies; | ||
|
||
public PersistenceServiceConfiguration(final List<SimpleItemConfiguration> configs, | ||
final List<SimpleStrategy> defaults, final List<SimpleStrategy> strategies) { | ||
this.configs = Collections.unmodifiableList(new LinkedList<>(configs)); | ||
this.defaults = Collections.unmodifiableList(new LinkedList<>(defaults)); | ||
this.strategies = Collections.unmodifiableList(new LinkedList<>(strategies)); | ||
} | ||
|
||
/** | ||
* Get the item configurations. | ||
* | ||
* @return an unmodifiable list of the item configurations | ||
*/ | ||
public List<SimpleItemConfiguration> getConfigs() { | ||
return configs; | ||
} | ||
|
||
/** | ||
* Get the default strategies. | ||
* | ||
* @return an unmodifiable list of the default strategies | ||
*/ | ||
public List<SimpleStrategy> getDefaults() { | ||
return defaults; | ||
} | ||
|
||
/** | ||
* Get all defined strategies. | ||
* | ||
* @return an unmodifiable list of the defined strategies | ||
*/ | ||
public List<SimpleStrategy> getStrategies() { | ||
return strategies; | ||
} | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
...e.core.persistence/src/main/java/org/eclipse/smarthome/core/persistence/SimpleFilter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* Copyright (c) 2014-2016 by the respective copyright holders. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package org.eclipse.smarthome.core.persistence; | ||
|
||
/** | ||
* | ||
* | ||
* @author Markus Rathgeb - Initial contribution and API | ||
*/ | ||
public class SimpleFilter { | ||
|
||
} |
58 changes: 58 additions & 0 deletions
58
...istence/src/main/java/org/eclipse/smarthome/core/persistence/SimpleItemConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/** | ||
* Copyright (c) 2014-2016 by the respective copyright holders. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package org.eclipse.smarthome.core.persistence; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import org.eclipse.smarthome.core.persistence.config.SimpleConfig; | ||
import org.eclipse.smarthome.core.persistence.strategy.SimpleStrategy; | ||
|
||
/** | ||
* This class holds the configuration of a persistence strategy for specific items. | ||
* | ||
* @author Markus Rathgeb - Initial contribution and API | ||
*/ | ||
public class SimpleItemConfiguration { | ||
|
||
private final List<SimpleConfig> items; | ||
private final String alias; | ||
private final List<SimpleStrategy> strategies; | ||
private final List<SimpleFilter> filters; | ||
|
||
public SimpleItemConfiguration(final List<SimpleConfig> items, final String alias, | ||
final List<SimpleStrategy> strategies, final List<SimpleFilter> filters) { | ||
this.items = items; | ||
this.alias = alias; | ||
this.strategies = strategies; | ||
this.filters = filters; | ||
} | ||
|
||
public List<SimpleConfig> getItems() { | ||
return items; | ||
} | ||
|
||
public String getAlias() { | ||
return alias; | ||
} | ||
|
||
public List<SimpleStrategy> getStrategies() { | ||
return strategies; | ||
} | ||
|
||
public List<SimpleFilter> getFilters() { | ||
return filters; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.format("%s [items=%s, alias=%s, strategies=%s, filters=%s]", getClass().getSimpleName(), | ||
Arrays.toString(items.toArray()), alias, Arrays.toString(strategies.toArray()), | ||
Arrays.toString(filters.toArray())); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
...sistence/src/main/java/org/eclipse/smarthome/core/persistence/config/SimpleAllConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
/** | ||
* Copyright (c) 2014-2016 by the respective copyright holders. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package org.eclipse.smarthome.core.persistence.config; | ||
|
||
/** | ||
* This class represents the configuration that stand for "using all items". | ||
* | ||
* @author Markus Rathgeb - Initial contribution and API | ||
*/ | ||
public class SimpleAllConfig extends SimpleConfig { | ||
|
||
@Override | ||
public String toString() { | ||
return String.format("%s []", getClass().getSimpleName()); | ||
} | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
...persistence/src/main/java/org/eclipse/smarthome/core/persistence/config/SimpleConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* Copyright (c) 2014-2016 by the respective copyright holders. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package org.eclipse.smarthome.core.persistence.config; | ||
|
||
/** | ||
* This class is a base class that needs to be used by every item configuration. | ||
* | ||
* @author Markus Rathgeb - Initial contribution and API | ||
*/ | ||
public abstract class SimpleConfig { | ||
|
||
} |
32 changes: 32 additions & 0 deletions
32
...stence/src/main/java/org/eclipse/smarthome/core/persistence/config/SimpleGroupConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/** | ||
* Copyright (c) 2014-2016 by the respective copyright holders. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package org.eclipse.smarthome.core.persistence.config; | ||
|
||
/** | ||
* This class represents the configuration that is used for group items. | ||
* | ||
* @author Markus Rathgeb - Initial contribution and API | ||
*/ | ||
public class SimpleGroupConfig extends SimpleConfig { | ||
|
||
private final String group; | ||
|
||
public SimpleGroupConfig(final String group) { | ||
this.group = group; | ||
} | ||
|
||
public String getGroup() { | ||
return group; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.format("%s [group=%s]", getClass().getSimpleName(), group); | ||
} | ||
|
||
} |
30 changes: 30 additions & 0 deletions
30
...istence/src/main/java/org/eclipse/smarthome/core/persistence/config/SimpleItemConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* Copyright (c) 2014-2016 by the respective copyright holders. | ||
* All rights reserved. This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License v1.0 | ||
* which accompanies this distribution, and is available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
package org.eclipse.smarthome.core.persistence.config; | ||
|
||
/** | ||
* This class represents the configuration that identify item(s) by name. | ||
* | ||
* @author Markus Rathgeb - Initial contribution and API | ||
*/ | ||
public class SimpleItemConfig extends SimpleConfig { | ||
final String item; | ||
|
||
public SimpleItemConfig(final String item) { | ||
this.item = item; | ||
} | ||
|
||
public String getItem() { | ||
return item; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return String.format("%s [item=%s]", getClass().getSimpleName(), item); | ||
} | ||
} |
Oops, something went wrong.