Skip to content

Commit b8fec16

Browse files
committed
Merge branch 'release/3.57.0'
2 parents 9203d18 + 188a30a commit b8fec16

179 files changed

Lines changed: 1673 additions & 3461 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

net.solarnetwork.node.control.mock/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Bundle-Name: Mock Control
44
Bundle-SymbolicName: net.solarnetwork.node.control.mock
55
Automatic-Module-Name: net.solarnetwork.node.control.mock
66
Bundle-Description: Control simulator to be used for development and testing.
7-
Bundle-Version: 3.0.0
7+
Bundle-Version: 3.0.1
88
Bundle-Vendor: SolarNetwork
99
Bundle-RequiredExecutionEnvironment: JavaSE-11
1010
Import-Package:

net.solarnetwork.node.control.mock/src/net/solarnetwork/node/control/mock/MockNodeControlProvider.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@
6565
* </p>
6666
*
6767
* @author matt
68-
* @version 3.0
68+
* @version 3.1
6969
*/
7070
public class MockNodeControlProvider extends BaseIdentifiable implements NodeControlProvider,
7171
InstructionHandler, SettingSpecifierProvider, SettingsChangeObserver, ServiceLifecycleObserver {
@@ -163,6 +163,9 @@ public InstructionStatus processInstruction(Instruction instruction) {
163163
}
164164
// look for a parameter name that matches a control ID
165165
final String controlId = getControlId();
166+
if ( controlId == null || controlId.isEmpty() ) {
167+
return null;
168+
}
166169
InstructionState result = null;
167170
for ( String paramName : instruction.getParameterNames() ) {
168171
if ( controlId.equals(paramName) ) {

net.solarnetwork.node.dao.jdbc.con/META-INF/MANIFEST.MF

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ Bundle-ManifestVersion: 2
33
Bundle-Name: Core Database Connection
44
Bundle-Description: Provides database storage connection configuration for the SolarNode application.
55
Bundle-SymbolicName: net.solarnetwork.node.dao.jdbc.con
6-
Bundle-Version: 1.1.0
6+
Bundle-Version: 1.2.0
77
Bundle-Activator: net.solarnetwork.node.dao.jdbc.con.Activator
88
Bundle-Vendor: SolarNetwork
99
Bundle-RequiredExecutionEnvironment: JavaSE-11

net.solarnetwork.node.dao.jdbc.con/src/net/solarnetwork/node/dao/jdbc/con/Activator.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,21 +9,21 @@
99

1010
/**
1111
* Bundle activator.
12-
*
12+
*
1313
* <p>
1414
* This activator will look for a {@link ConfigurationAdmin} service, and if
1515
* found initialize a {@link DefaultDataSourceConfigurer} to set up a default
1616
* data source configuration if one does not already exist.
1717
* </p>
18-
*
18+
*
1919
* @author matt
20-
* @version 1.1
20+
* @version 1.2
2121
*/
2222
public class Activator implements BundleActivator {
2323

2424
/**
2525
* A system property key for the startup sleep time, in milliseconds.
26-
*
26+
*
2727
* @since 1.1
2828
*/
2929
private static final String SYS_PROP_STARTUP_SLEEP = "net.solarnetwork.node.dao.jdbc.con.startupSleepMs";
@@ -45,7 +45,8 @@ public void run() {
4545
if ( caRef != null ) {
4646
ConfigurationAdmin ca = bundleContext.getService(caRef);
4747
if ( ca != null ) {
48-
DefaultDataSourceConfigurer configurer = new DefaultDataSourceConfigurer(ca);
48+
DefaultDataSourceConfigurer configurer = new DefaultDataSourceConfigurer(
49+
bundleContext, ca);
4950
configurer.init();
5051
}
5152
}
Lines changed: 40 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
11
/* ==================================================================
22
* DefaultDataSourceConfigurer.java - 11/06/2021 10:49:53 AM
3-
*
3+
*
44
* Copyright 2021 SolarNetwork.net Dev Team
5-
*
6-
* This program is free software; you can redistribute it and/or
7-
* modify it under the terms of the GNU General Public License as
8-
* published by the Free Software Foundation; either version 2 of
5+
*
6+
* This program is free software; you can redistribute it and/or
7+
* modify it under the terms of the GNU General Public License as
8+
* published by the Free Software Foundation; either version 2 of
99
* the License, or (at your option) any later version.
10-
*
11-
* This program is distributed in the hope that it will be useful,
12-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1414
* General Public License for more details.
15-
*
16-
* You should have received a copy of the GNU General Public License
17-
* along with this program; if not, write to the Free Software
18-
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program; if not, write to the Free Software
18+
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
1919
* 02111-1307 USA
2020
* ==================================================================
2121
*/
@@ -24,9 +24,13 @@
2424

2525
import java.io.IOException;
2626
import java.io.InputStream;
27+
import java.util.Collection;
2728
import java.util.Hashtable;
2829
import java.util.Properties;
30+
import javax.sql.DataSource;
31+
import org.osgi.framework.BundleContext;
2932
import org.osgi.framework.InvalidSyntaxException;
33+
import org.osgi.framework.ServiceReference;
3034
import org.osgi.service.cm.Configuration;
3135
import org.osgi.service.cm.ConfigurationAdmin;
3236
import org.slf4j.Logger;
@@ -35,9 +39,9 @@
3539
/**
3640
* Publish a data source managed service factory configuration, if one does not
3741
* already exist.
38-
*
42+
*
3943
* @author matt
40-
* @version 1.0
44+
* @version 1.1
4145
*/
4246
public class DefaultDataSourceConfigurer {
4347

@@ -49,25 +53,31 @@ public class DefaultDataSourceConfigurer {
4953

5054
private final Logger log = LoggerFactory.getLogger(getClass());
5155

56+
private final BundleContext bundleContext;
5257
private final ConfigurationAdmin configurationAdmin;
5358
private final Class<?> propertiesClass;
5459
private final String propertiesPath;
5560
private final String dbServiceName;
5661

5762
/**
5863
* Constructor.
59-
*
64+
*
65+
* @param bundleContext
66+
* the bundle context
6067
* @param configurationAdmin
6168
* the configuration admin
6269
*/
63-
public DefaultDataSourceConfigurer(ConfigurationAdmin configurationAdmin) {
64-
this(configurationAdmin, DefaultDataSourceConfigurer.class, DEFAULT_PROPERTIES_PATH,
65-
DEFAULT_DB_SERVICE_NAME);
70+
public DefaultDataSourceConfigurer(BundleContext bundleContext,
71+
ConfigurationAdmin configurationAdmin) {
72+
this(bundleContext, configurationAdmin, DefaultDataSourceConfigurer.class,
73+
DEFAULT_PROPERTIES_PATH, DEFAULT_DB_SERVICE_NAME);
6674
}
6775

6876
/**
6977
* Constructor.
70-
*
78+
*
79+
* @param bundleContext
80+
* the bundle context
7181
* @param configurationAdmin
7282
* the configuration admin
7383
* @param propertiesClass
@@ -77,9 +87,11 @@ public DefaultDataSourceConfigurer(ConfigurationAdmin configurationAdmin) {
7787
* @param dbServiceName
7888
* the {@literal db} service property name
7989
*/
80-
public DefaultDataSourceConfigurer(ConfigurationAdmin configurationAdmin, Class<?> propertiesClass,
81-
String propertiesPath, String dbServiceName) {
90+
public DefaultDataSourceConfigurer(BundleContext bundleContext,
91+
ConfigurationAdmin configurationAdmin, Class<?> propertiesClass, String propertiesPath,
92+
String dbServiceName) {
8293
super();
94+
this.bundleContext = bundleContext;
8395
this.configurationAdmin = configurationAdmin;
8496
this.propertiesClass = propertiesClass;
8597
this.propertiesPath = propertiesPath;
@@ -103,8 +115,7 @@ public void init() {
103115
return;
104116
}
105117
try {
106-
Configuration cfg = findExistingConfiguration(factoryPid);
107-
if ( cfg == null ) {
118+
if ( !hasExistingDataSource() ) {
108119
createConfiguration(factoryPid, props);
109120
}
110121
} catch ( IOException | InvalidSyntaxException e ) {
@@ -122,16 +133,11 @@ private void createConfiguration(String factoryPid, Properties props) throws IOE
122133
cfg.update((Hashtable) props); // making assumption Properties has only String keys here
123134
}
124135

125-
private Configuration findExistingConfiguration(String pid)
126-
throws IOException, InvalidSyntaxException {
127-
String filter = "(&(" + ConfigurationAdmin.SERVICE_FACTORYPID + "=" + pid
128-
+ ")(serviceProperty.db=" + dbServiceName + "))";
129-
Configuration[] configurations = configurationAdmin.listConfigurations(filter);
130-
if ( configurations != null && configurations.length > 0 ) {
131-
return configurations[0];
132-
} else {
133-
return null;
134-
}
136+
private boolean hasExistingDataSource() throws IOException, InvalidSyntaxException {
137+
String filter = "(db=" + dbServiceName + ")";
138+
Collection<ServiceReference<DataSource>> refs = bundleContext
139+
.getServiceReferences(DataSource.class, filter);
140+
return !refs.isEmpty();
135141
}
136142

137143
}
Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
service.factoryPid = net.solarnetwork.jdbc.pool.hikari
22
serviceProperty.db = node
3-
dataSourceFactory.filter = (osgi.jdbc.driver.class=org.apache.derby.jdbc.EmbeddedDriver)
3+
dataSourceFactory.filter = (osgi.jdbc.driver.class=org.h2.Driver)
44
pingTest.query = VALUES CURRENT_DATE
55
minimumIdle = 1
6-
maximumPoolSize = 3
6+
maximumPoolSize = 8
77
factory.exceptionHandlerSupport = true
8-
dataSource.url = jdbc:derby:solarnode;create=true;upgrade=true
9-
dataSource.user = solarnode
10-
dataSource.password = solarnode
8+
dataSource.url = jdbc:h2:./var/solarnode-h2
9+
dataSource.user = sa
10+
dataSource.password =

net.solarnetwork.node.dao.jdbc.derby.ext/.gitignore

Lines changed: 0 additions & 2 deletions
This file was deleted.

net.solarnetwork.node.dao.jdbc.derby.ext/.settings/org.eclipse.jdt.core.prefs

Lines changed: 0 additions & 8 deletions
This file was deleted.

net.solarnetwork.node.dao.jdbc.derby.ext/META-INF/MANIFEST.MF

Lines changed: 0 additions & 11 deletions
This file was deleted.

net.solarnetwork.node.dao.jdbc.derby.ext/ivy.xml

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)