Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRyan D. Brooks2020-05-12 22:56:57 +0000
committerRyan D. Brooks2020-12-15 21:40:13 +0000
commit0b96a68a3d691317dad80a203a6cc528fc9cc82f (patch)
tree20f961f8a4a3cfbf3082bf96f06a26a0222916a5
parent10d7ce1ffb5b922907e320ae7c7f6d0bfd92f50b (diff)
downloadorg.eclipse.osee-0b96a68a3d691317dad80a203a6cc528fc9cc82f.tar.gz
org.eclipse.osee-0b96a68a3d691317dad80a203a6cc528fc9cc82f.tar.xz
org.eclipse.osee-0b96a68a3d691317dad80a203a6cc528fc9cc82f.zip
refinement[TW16935]: Remove JDBC Factory
-rw-r--r--plugins/org.eclipse.osee.jdbc.test/src/org/eclipse/osee/jdbc/AllJdbcTestSuite.java5
-rw-r--r--plugins/org.eclipse.osee.jdbc.test/src/org/eclipse/osee/jdbc/internal/InternalTestSuite.java27
-rw-r--r--plugins/org.eclipse.osee.jdbc.test/src/org/eclipse/osee/jdbc/internal/osgi/JdbcComponentFactoryTest.java241
-rw-r--r--plugins/org.eclipse.osee.jdbc.test/src/org/eclipse/osee/jdbc/internal/osgi/JdbcSvcCfgChangeTypeTest.java93
-rw-r--r--plugins/org.eclipse.osee.jdbc.test/src/org/eclipse/osee/jdbc/internal/osgi/OsgiJunitTestSuite.java26
-rw-r--r--plugins/org.eclipse.osee.jdbc/OSGI-INF/jdbc.component.factory.xml6
-rw-r--r--plugins/org.eclipse.osee.jdbc/OSGI-INF/org.eclipse.osee.jdbc.internal.osgi.JdbcServiceImpl.xml2
-rw-r--r--plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/internal/osgi/JdbcComponentFactory.java145
-rw-r--r--plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/internal/osgi/JdbcServiceConfig.java59
-rw-r--r--plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/internal/osgi/JdbcServiceConfigParser.java90
-rw-r--r--plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/internal/osgi/JdbcServiceImpl.java2
-rw-r--r--plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/internal/osgi/JdbcSvcCfgChangeType.java70
-rw-r--r--plugins/org.eclipse.osee.orcs.db/META-INF/MANIFEST.MF3
-rw-r--r--plugins/org.eclipse.osee.server.application/OSGI-INF/osee.server.application.xml2
-rw-r--r--plugins/org.eclipse.osee.server.application/src/org/eclipse/osee/server/application/ServerApplication.java14
-rw-r--r--plugins/org.eclipse.osee.server.application/src/org/eclipse/osee/server/application/internal/ServerHealthEndpointImpl.java27
16 files changed, 15 insertions, 797 deletions
diff --git a/plugins/org.eclipse.osee.jdbc.test/src/org/eclipse/osee/jdbc/AllJdbcTestSuite.java b/plugins/org.eclipse.osee.jdbc.test/src/org/eclipse/osee/jdbc/AllJdbcTestSuite.java
index c3c4a82f8b6..c0b771359cb 100644
--- a/plugins/org.eclipse.osee.jdbc.test/src/org/eclipse/osee/jdbc/AllJdbcTestSuite.java
+++ b/plugins/org.eclipse.osee.jdbc.test/src/org/eclipse/osee/jdbc/AllJdbcTestSuite.java
@@ -13,7 +13,6 @@
package org.eclipse.osee.jdbc;
-import org.eclipse.osee.jdbc.internal.InternalTestSuite;
import org.junit.runner.RunWith;
import org.junit.runners.Suite;
@@ -21,7 +20,7 @@ import org.junit.runners.Suite;
* @author Roberto E. Escobar
*/
@RunWith(Suite.class)
-@Suite.SuiteClasses({InternalTestSuite.class, JdbcRunFunctionTest.class})
+@Suite.SuiteClasses({JdbcRunFunctionTest.class})
public class AllJdbcTestSuite {
// Test Suite
-}
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.jdbc.test/src/org/eclipse/osee/jdbc/internal/InternalTestSuite.java b/plugins/org.eclipse.osee.jdbc.test/src/org/eclipse/osee/jdbc/internal/InternalTestSuite.java
deleted file mode 100644
index ee769b10c71..00000000000
--- a/plugins/org.eclipse.osee.jdbc.test/src/org/eclipse/osee/jdbc/internal/InternalTestSuite.java
+++ /dev/null
@@ -1,27 +0,0 @@
-/*********************************************************************
- * Copyright (c) 2014 Boeing
- *
- * This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License 2.0
- * which is available at https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Boeing - initial API and implementation
- **********************************************************************/
-
-package org.eclipse.osee.jdbc.internal;
-
-import org.eclipse.osee.jdbc.internal.osgi.OsgiJunitTestSuite;
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-/**
- * @author Roberto E. Escobar
- */
-@RunWith(Suite.class)
-@Suite.SuiteClasses({OsgiJunitTestSuite.class})
-public class InternalTestSuite {
- // Test Suite
-}
diff --git a/plugins/org.eclipse.osee.jdbc.test/src/org/eclipse/osee/jdbc/internal/osgi/JdbcComponentFactoryTest.java b/plugins/org.eclipse.osee.jdbc.test/src/org/eclipse/osee/jdbc/internal/osgi/JdbcComponentFactoryTest.java
deleted file mode 100644
index 166ee155e64..00000000000
--- a/plugins/org.eclipse.osee.jdbc.test/src/org/eclipse/osee/jdbc/internal/osgi/JdbcComponentFactoryTest.java
+++ /dev/null
@@ -1,241 +0,0 @@
-/*********************************************************************
- * Copyright (c) 2014 Boeing
- *
- * This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License 2.0
- * which is available at https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Boeing - initial API and implementation
- **********************************************************************/
-
-package org.eclipse.osee.jdbc.internal.osgi;
-
-import static org.eclipse.osee.jdbc.JdbcConstants.JDBC_SERVICE__CONFIGS;
-import static org.eclipse.osee.jdbc.JdbcConstants.JDBC_SERVICE__ID;
-import static org.eclipse.osee.jdbc.JdbcConstants.JDBC__CONNECTION_URI;
-import static org.eclipse.osee.jdbc.JdbcConstants.JDBC__CONNECTION_USERNAME;
-import static org.junit.Assert.assertEquals;
-import static org.mockito.Mockito.when;
-import java.util.Arrays;
-import java.util.Dictionary;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Set;
-import java.util.TreeSet;
-import org.eclipse.osee.framework.jdk.core.util.Compare;
-import org.eclipse.osee.jdbc.JdbcException;
-import org.eclipse.osee.jdbc.internal.osgi.JdbcComponentFactory.JdbcServiceComponent;
-import org.eclipse.osee.logger.Log;
-import org.junit.Before;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-import org.mockito.Matchers;
-import org.mockito.Mock;
-import org.mockito.MockitoAnnotations;
-import org.osgi.service.component.ComponentFactory;
-import org.osgi.service.component.ComponentInstance;
-
-/**
- * Test Case for {@link JdbcComponentFactory}
- *
- * @author Roberto E. Escobar
- */
-public class JdbcComponentFactoryTest {
-
- private static final String CONFIG_1 = //
- " {" + //
- " 'service.id':'1001'," + //
- " 'jdbc.client.db.uri': 'uri1'," + //
- " 'jdbc.client.db.username': 'user1'" + //
- " }";
-
- private static final String CONFIG_2 = //
- " {" + //
- " 'service.id':'1002'," + //
- " 'jdbc.client.db.uri': 'uri2'," + //
- " 'jdbc.client.db.username': 'user2'" + //
- " }";
-
- private static final String CONFIG_3 = //
- " {" + //
- " 'service.id':'1003'," + //
- " 'jdbc.client.db.uri': 'uri3'," + //
- " 'jdbc.client.db.username': 'user3'" + //
- " }";
-
- private static final String CONFIG_ID_COLLISION = //
- " {" + //
- " 'service.id':'1001'," + //
- " 'jdbc.client.db.uri': 'uri4'," + //
- " 'jdbc.client.db.username': 'user4'" + //
- " }";
-
- private static final String CONFIG_BINDING_COLLISION = //
- " {" + //
- " 'service.id':'1005'," + //
- " 'jdbc.client.db.uri': 'uri5'," + //
- " 'jdbc.client.db.username': 'user5'" + //
- " }";
-
- private static final String CONFIG_ID_NULL = //
- " {" + //
- " 'jdbc.client.db.uri': 'uri6'," + //
- " 'jdbc.client.db.username': 'user6'" + //
- " }";
-
- @Rule
- public ExpectedException thrown = ExpectedException.none();
-
- //@formatter:off
- @Mock private Log logger;
- @Mock private ComponentFactory componentFactory;
-
- @Mock private ComponentInstance svcInstance;
- //@formatter:on
-
- private JdbcComponentFactory factory;
-
- @SuppressWarnings("unchecked")
- @Before
- public void setup() {
- MockitoAnnotations.initMocks(this);
-
- factory = new JdbcComponentFactory();
- factory.setComponentFactory(componentFactory);
- factory.setLogger(logger);
-
- when(componentFactory.newInstance(Matchers.any(Dictionary.class))).thenReturn(svcInstance);
- }
-
- @Test
- public void testStartStop() {
- factory.start(asConfig(CONFIG_1, CONFIG_2));
-
- Map<String, JdbcServiceComponent> services = factory.getServices();
- assertEquals(2, services.size());
-
- checkConfig(services.get("1001"), "1001", //
- map(JDBC_SERVICE__ID, "1001", //
- JDBC__CONNECTION_URI, "uri1", //
- JDBC__CONNECTION_USERNAME, "user1"));
-
- checkConfig(services.get("1002"), "1002", //
- map(JDBC_SERVICE__ID, "1002", //
- JDBC__CONNECTION_URI, "uri2", //
- JDBC__CONNECTION_USERNAME, "user2"));
-
- factory.stop();
- services = factory.getServices();
- assertEquals(0, services.size());
- }
-
- @Test
- public void testUpdate() {
- factory.start(asConfig(CONFIG_1, CONFIG_2));
-
- Map<String, JdbcServiceComponent> services = factory.getServices();
- assertEquals(2, services.size());
-
- checkConfig(services.get("1001"), "1001", //
- map(JDBC_SERVICE__ID, "1001", //
- JDBC__CONNECTION_URI, "uri1", //
- JDBC__CONNECTION_USERNAME, "user1"));
-
- checkConfig(services.get("1002"), "1002", //
- map(JDBC_SERVICE__ID, "1002", //
- JDBC__CONNECTION_URI, "uri2", //
- JDBC__CONNECTION_USERNAME, "user2"));
-
- factory.update(asConfig(CONFIG_1, CONFIG_2, CONFIG_3));
- assertEquals(3, services.size());
-
- checkConfig(services.get("1001"), "1001", //
- map(JDBC_SERVICE__ID, "1001", //
- JDBC__CONNECTION_URI, "uri1", //
- JDBC__CONNECTION_USERNAME, "user1"));
-
- checkConfig(services.get("1002"), "1002", //
- map(JDBC_SERVICE__ID, "1002", //
- JDBC__CONNECTION_URI, "uri2", //
- JDBC__CONNECTION_USERNAME, "user2"));
-
- checkConfig(services.get("1003"), "1003", //
- map(JDBC_SERVICE__ID, "1003", //
- JDBC__CONNECTION_URI, "uri3", //
- JDBC__CONNECTION_USERNAME, "user3"));
-
- factory.update(asConfig(CONFIG_1, CONFIG_3));
- assertEquals(2, services.size());
-
- checkConfig(services.get("1001"), "1001", //
- map(JDBC_SERVICE__ID, "1001", //
- JDBC__CONNECTION_URI, "uri1", //
- JDBC__CONNECTION_USERNAME, "user1"));
-
- checkConfig(services.get("1003"), "1003", //
- map(JDBC_SERVICE__ID, "1003", //
- JDBC__CONNECTION_URI, "uri3", //
- JDBC__CONNECTION_USERNAME, "user3"));
-
- factory.stop();
- services = factory.getServices();
- assertEquals(0, services.size());
- }
-
- private static void checkConfig(JdbcServiceComponent comp, String id, Map<String, Object> expected) {
- assertEquals(id, comp.getId());
- Map<String, Object> data = comp.getConfig();
- assertEquals(false, Compare.isDifferent(expected, data));
- }
-
- @Test
- public void testStartConfigErrorNullId() {
- thrown.expect(JdbcException.class);
- thrown.expectMessage("Jdbc Service configuration error - id cannot be null or empty");
- factory.start(asConfig(CONFIG_1, CONFIG_ID_NULL));
- }
-
- @Test
- public void testStartConfigErrorIdCollision() {
- thrown.expect(JdbcException.class);
- thrown.expectMessage("Jdbc Service configuration error - duplicate service id detected - id[1001]");
- factory.start(asConfig(CONFIG_1, CONFIG_ID_COLLISION));
- }
-
- private Set<String> set(String... vals) {
- return new TreeSet<>(Arrays.asList(vals));
- }
-
- private Map<String, Object> asConfig(String... configs) {
- StringBuilder builder = new StringBuilder("[");
- int size = configs.length;
- for (int index = 0; index < size; index++) {
- builder.append(configs[index]);
- if (index + 1 < size) {
- builder.append(",");
- }
- }
- builder.append("]");
- return map(JDBC_SERVICE__CONFIGS, builder.toString());
- }
-
- private static Map<String, Object> map(Object... keyVals) {
- Map<String, Object> data = new HashMap<>();
- String key = null;
- boolean isKey = true;
- for (Object keyVal : keyVals) {
- if (isKey) {
- key = String.valueOf(keyVal);
- isKey = false;
- } else {
- data.put(key, keyVal);
- isKey = true;
- }
- }
- return data;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.jdbc.test/src/org/eclipse/osee/jdbc/internal/osgi/JdbcSvcCfgChangeTypeTest.java b/plugins/org.eclipse.osee.jdbc.test/src/org/eclipse/osee/jdbc/internal/osgi/JdbcSvcCfgChangeTypeTest.java
deleted file mode 100644
index 8b14335ed8d..00000000000
--- a/plugins/org.eclipse.osee.jdbc.test/src/org/eclipse/osee/jdbc/internal/osgi/JdbcSvcCfgChangeTypeTest.java
+++ /dev/null
@@ -1,93 +0,0 @@
-/*********************************************************************
- * Copyright (c) 2014 Boeing
- *
- * This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License 2.0
- * which is available at https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Boeing - initial API and implementation
- **********************************************************************/
-
-package org.eclipse.osee.jdbc.internal.osgi;
-
-import static org.eclipse.osee.jdbc.JdbcConstants.NAMESPACE;
-import static org.eclipse.osee.jdbc.internal.osgi.JdbcSvcCfgChangeType.ALL_CHANGED;
-import static org.eclipse.osee.jdbc.internal.osgi.JdbcSvcCfgChangeType.JDBC_PROPERTY;
-import static org.eclipse.osee.jdbc.internal.osgi.JdbcSvcCfgChangeType.NO_CHANGE;
-import static org.eclipse.osee.jdbc.internal.osgi.JdbcSvcCfgChangeType.OTHER_CHANGE;
-import static org.junit.Assert.assertEquals;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameters;
-
-/**
- * Test Case for {@link JdbcSvcCfgChangeType}
- *
- * @author Roberto E. Escobar
- */
-@RunWith(Parameterized.class)
-public class JdbcSvcCfgChangeTypeTest {
-
- private final JdbcSvcCfgChangeType expected;
- private final Map<String, Object> map1;
- private final Map<String, Object> map2;
-
- public JdbcSvcCfgChangeTypeTest(JdbcSvcCfgChangeType expected, Map<String, Object> map1, Map<String, Object> map2) {
- super();
- this.expected = expected;
- this.map1 = map1;
- this.map2 = map2;
- }
-
- @Test
- public void testChangeDetection() {
- JdbcSvcCfgChangeType actual = JdbcSvcCfgChangeType.getChangeType(map1, map2);
- assertEquals(expected, actual);
- }
-
- @Parameters
- public static Collection<Object[]> data() {
- List<Object[]> tests = new ArrayList<>();
-
- //@formatter:off
- tests.add(row(NO_CHANGE, map("a", "1"), map("a", "1")));
- tests.add(row(NO_CHANGE, null, null));
- tests.add(row(ALL_CHANGED, map("a", "1"), null));
- tests.add(row(ALL_CHANGED, null, map("a", "1")));
- tests.add(row(ALL_CHANGED, map("a", "1"), map()));
- tests.add(row(JDBC_PROPERTY, map(NAMESPACE, "a"), map(NAMESPACE, "b")));
- tests.add(row(OTHER_CHANGE, map("a", "1"), map("a", "2")));
- //@formatter:on
- return tests;
- }
-
- private static Object[] row(Object... inputs) {
- return inputs;
- }
-
- private static Map<String, Object> map(Object... keyVals) {
- Map<String, Object> data = new HashMap<>();
- String key = null;
- boolean isKey = true;
- for (Object keyVal : keyVals) {
- if (isKey) {
- key = String.valueOf(keyVal);
- isKey = false;
- } else {
- data.put(key, keyVal);
- isKey = true;
- }
- }
- return data;
- }
-
-}
diff --git a/plugins/org.eclipse.osee.jdbc.test/src/org/eclipse/osee/jdbc/internal/osgi/OsgiJunitTestSuite.java b/plugins/org.eclipse.osee.jdbc.test/src/org/eclipse/osee/jdbc/internal/osgi/OsgiJunitTestSuite.java
deleted file mode 100644
index e614a3bbc38..00000000000
--- a/plugins/org.eclipse.osee.jdbc.test/src/org/eclipse/osee/jdbc/internal/osgi/OsgiJunitTestSuite.java
+++ /dev/null
@@ -1,26 +0,0 @@
-/*********************************************************************
- * Copyright (c) 2014 Boeing
- *
- * This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License 2.0
- * which is available at https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Boeing - initial API and implementation
- **********************************************************************/
-
-package org.eclipse.osee.jdbc.internal.osgi;
-
-import org.junit.runner.RunWith;
-import org.junit.runners.Suite;
-
-/**
- * @author Roberto E. Escobar
- */
-@RunWith(Suite.class)
-@Suite.SuiteClasses({JdbcComponentFactoryTest.class, JdbcSvcCfgChangeTypeTest.class})
-public class OsgiJunitTestSuite {
- // Test Suite
-}
diff --git a/plugins/org.eclipse.osee.jdbc/OSGI-INF/jdbc.component.factory.xml b/plugins/org.eclipse.osee.jdbc/OSGI-INF/jdbc.component.factory.xml
deleted file mode 100644
index e5cc9cd929b..00000000000
--- a/plugins/org.eclipse.osee.jdbc/OSGI-INF/jdbc.component.factory.xml
+++ /dev/null
@@ -1,6 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.1.0" configuration-policy="require" activate="start" deactivate="stop" modified="update">
- <implementation class="org.eclipse.osee.jdbc.internal.osgi.JdbcComponentFactory" />
- <reference bind="setLogger" cardinality="1..1" interface="org.eclipse.osee.logger.Log" name="Log" policy="static"/>
- <reference bind="setComponentFactory" cardinality="1..1" interface="org.osgi.service.component.ComponentFactory" name="ComponentFactory" policy="static" target="(component.factory=org.eclipse.osee.jdbc.JdbcService)"/>
-</scr:component>
diff --git a/plugins/org.eclipse.osee.jdbc/OSGI-INF/org.eclipse.osee.jdbc.internal.osgi.JdbcServiceImpl.xml b/plugins/org.eclipse.osee.jdbc/OSGI-INF/org.eclipse.osee.jdbc.internal.osgi.JdbcServiceImpl.xml
index 19ae0f870b6..d43ee1965ef 100644
--- a/plugins/org.eclipse.osee.jdbc/OSGI-INF/org.eclipse.osee.jdbc.internal.osgi.JdbcServiceImpl.xml
+++ b/plugins/org.eclipse.osee.jdbc/OSGI-INF/org.eclipse.osee.jdbc.internal.osgi.JdbcServiceImpl.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
-<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.2.0" activate="activate" configuration-pid="OseeJdbc" deactivate="stop" factory="org.eclipse.osee.jdbc.JdbcService" modified="modified" name="org.eclipse.osee.jdbc.internal.osgi.JdbcServiceImpl">
+<scr:component xmlns:scr="http://www.osgi.org/xmlns/scr/v1.2.0" activate="activate" configuration-pid="OseeJdbc" deactivate="stop" modified="modified" name="org.eclipse.osee.jdbc.internal.osgi.JdbcServiceImpl">
<property name="jdbc.server.host" value="127.0.0.1"/>
<property name="jdbc.server.port" value="8088"/>
<property name="jdbc.server.db.data.path" value="file:demo/hsql/osee.hsql.db"/>
diff --git a/plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/internal/osgi/JdbcComponentFactory.java b/plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/internal/osgi/JdbcComponentFactory.java
deleted file mode 100644
index a15d2b1f256..00000000000
--- a/plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/internal/osgi/JdbcComponentFactory.java
+++ /dev/null
@@ -1,145 +0,0 @@
-/*********************************************************************
- * Copyright (c) 2014 Boeing
- *
- * This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License 2.0
- * which is available at https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Boeing - initial API and implementation
- **********************************************************************/
-
-package org.eclipse.osee.jdbc.internal.osgi;
-
-import java.util.Collections;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
-import org.eclipse.osee.jdbc.JdbcConstants;
-import org.eclipse.osee.logger.Log;
-import org.osgi.service.component.ComponentFactory;
-import org.osgi.service.component.ComponentInstance;
-
-/**
- * @author Roberto E. Escobar
- */
-public class JdbcComponentFactory {
-
- private final ConcurrentHashMap<String, JdbcServiceComponent> services = new ConcurrentHashMap<>();
-
- private JdbcServiceConfigParser parser;
-
- private Log logger;
- private ComponentFactory componentFactory;
-
- public void setLogger(Log logger) {
- this.logger = logger;
- }
-
- public void setComponentFactory(ComponentFactory componentFactory) {
- this.componentFactory = componentFactory;
- }
-
- public void start(Map<String, Object> props) {
- parser = new JdbcServiceConfigParser();
- update(props);
- }
-
- public void stop() {
- Iterator<JdbcServiceComponent> iterator = services.values().iterator();
- while (iterator.hasNext()) {
- JdbcServiceComponent component = iterator.next();
- component.stop();
- iterator.remove();
- }
- parser = null;
- }
-
- public void update(Map<String, Object> props) {
- logger.trace("Configuring [%s]...", getClass().getSimpleName());
- String newJsonConfig = (String) props.get(JdbcConstants.JDBC_SERVICE__CONFIGS);
- if (newJsonConfig != null) {
- Map<String, JdbcServiceConfig> newConfigs = parser.parse(newJsonConfig);
-
- for (JdbcServiceConfig config : newConfigs.values()) {
- JdbcServiceComponent newComponent = new JdbcServiceComponent(config.getId());
- JdbcServiceComponent component = services.putIfAbsent(newComponent.getId(), newComponent);
- if (component == null) {
- component = newComponent;
- }
- component.update(config);
- }
-
- Iterable<String> removed = difference(services.keySet(), newConfigs.keySet());
- for (String id : removed) {
- JdbcServiceComponent component = services.remove(id);
- if (component != null) {
- component.stop();
- }
- }
- } else {
- logger.trace("No configuration with [%s] found for [%s]", JdbcConstants.JDBC_SERVICE__CONFIGS,
- getClass().getSimpleName());
- }
- }
-
- public Map<String, JdbcServiceComponent> getServices() {
- return Collections.unmodifiableMap(services);
- }
-
- private static Iterable<String> difference(Set<String> setA, Set<String> setB) {
- return org.eclipse.osee.framework.jdk.core.util.Collections.setComplement(setA, setB);
- }
-
- public final class JdbcServiceComponent {
-
- private final String id;
- private ComponentInstance instance;
- private Map<String, Object> lastConfig;
-
- public JdbcServiceComponent(String id) {
- super();
- this.id = id;
- }
-
- public String getId() {
- return id;
- }
-
- public Map<String, Object> getConfig() {
- return lastConfig;
- }
-
- public void update(JdbcServiceConfig config) {
- Map<String, Object> newConfig = config.asMap();
- JdbcSvcCfgChangeType changeType = JdbcSvcCfgChangeType.getChangeType(lastConfig, newConfig);
- if (instance == null) {
- instance = componentFactory.newInstance(config.asDictionary());
- } else {
- switch (changeType) {
- case NO_CHANGE:
- // Do nothing - no config change
- break;
- case JDBC_PROPERTY:
- JdbcServiceImpl object = (JdbcServiceImpl) instance.getInstance();
- object.modified(config.asMap());
- break;
- default:
- instance.dispose();
- instance = componentFactory.newInstance(config.asDictionary());
- break;
- }
- }
- lastConfig = newConfig;
- }
-
- public void stop() {
- if (instance != null) {
- instance.dispose();
- }
- }
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/internal/osgi/JdbcServiceConfig.java b/plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/internal/osgi/JdbcServiceConfig.java
deleted file mode 100644
index c6e97d31329..00000000000
--- a/plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/internal/osgi/JdbcServiceConfig.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*********************************************************************
- * Copyright (c) 2014 Boeing
- *
- * This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License 2.0
- * which is available at https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Boeing - initial API and implementation
- **********************************************************************/
-
-package org.eclipse.osee.jdbc.internal.osgi;
-
-import java.util.Collections;
-import java.util.Dictionary;
-import java.util.Hashtable;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import org.eclipse.osee.jdbc.internal.JdbcUtil;
-
-/**
- * @author Roberto E. Escobar
- */
-public class JdbcServiceConfig {
-
- private final Map<String, Object> data = new LinkedHashMap<>();
-
- public String getId() {
- return JdbcUtil.getServiceId(data);
- }
-
- public boolean isEmpty() {
- return data.isEmpty();
- }
-
- public Map<String, Object> asMap() {
- return Collections.unmodifiableMap(data);
- }
-
- public Dictionary<String, Object> asDictionary() {
- Dictionary<String, Object> toReturn = new Hashtable<>();
- for (Entry<String, Object> entry : data.entrySet()) {
- toReturn.put(entry.getKey(), entry.getValue());
- }
- return toReturn;
- }
-
- public void put(String key, Object value) {
- data.put(key, value);
- }
-
- @Override
- public String toString() {
- return "JdbcServiceConfig [props=" + data + "]";
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/internal/osgi/JdbcServiceConfigParser.java b/plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/internal/osgi/JdbcServiceConfigParser.java
deleted file mode 100644
index 65960c0964c..00000000000
--- a/plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/internal/osgi/JdbcServiceConfigParser.java
+++ /dev/null
@@ -1,90 +0,0 @@
-/*********************************************************************
-* Copyright (c) 2014 Boeing
-*
-* This program and the accompanying materials are made
-* available under the terms of the Eclipse Public License 2.0
-* which is available at https://www.eclipse.org/legal/epl-2.0/
-*
-* SPDX-License-Identifier: EPL-2.0
-*
-* Contributors:
-* Boeing - initial API and implementation
-**********************************************************************/
-
-package org.eclipse.osee.jdbc.internal.osgi;
-
-import static org.eclipse.osee.jdbc.JdbcException.newJdbcException;
-import com.fasterxml.jackson.core.JsonParser.Feature;
-import com.fasterxml.jackson.databind.JsonNode;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import java.io.IOException;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.Map;
-import org.eclipse.osee.framework.jdk.core.util.Strings;
-import org.eclipse.osee.jdbc.JdbcException;
-
-/**
- * @author Roberto E. Escobar
- */
-public final class JdbcServiceConfigParser {
-
- public Map<String, JdbcServiceConfig> parse(String source) {
- Map<String, JdbcServiceConfig> toReturn = new LinkedHashMap<>();
- if (Strings.isValid(source)) {
- try {
-
- ObjectMapper OM = new ObjectMapper();
- OM.configure(Feature.ALLOW_SINGLE_QUOTES, true);
- JsonNode jNode = OM.readTree(source);
-
- Iterator<JsonNode> elements = jNode.elements();
-
- while (elements.hasNext()) {
- JdbcServiceConfig newConfig = asConfig(elements.next());
- if (!newConfig.isEmpty()) {
- checkId(newConfig);
-
- JdbcServiceConfig oldConfig = toReturn.put(newConfig.getId(), newConfig);
-
- checkUnique(oldConfig, newConfig);
- }
- }
- } catch (IOException ex) {
- throw JdbcException.newJdbcException(ex, "Error parsing jdbc config [%s]", source);
- }
- }
- return toReturn;
- }
-
- private JdbcServiceConfig asConfig(JsonNode object) throws IOException {
-
- JdbcServiceConfig toReturn = new JdbcServiceConfig();
- ObjectMapper OM = new ObjectMapper();
- JsonNode newNode = OM.readTree(object.toString());
- Iterator<String> fields = newNode.fieldNames();
- Iterator<JsonNode> elements = newNode.elements();
- while (fields.hasNext()) {
- toReturn.put(fields.next(), elements.next().asText());
- }
- return toReturn;
-
- }
-
- private void checkId(JdbcServiceConfig config) {
- String id = config.getId();
- if (!Strings.isValid(id)) {
- throw newError("id cannot be null or empty - config[%s]", config);
- }
- }
-
- private void checkUnique(JdbcServiceConfig oldConfig, JdbcServiceConfig newConfig) {
- if (oldConfig != null) {
- throw newError("duplicate service id detected - id[%s]", newConfig.getId());
- }
- }
-
- private RuntimeException newError(String msg, Object... args) {
- return newJdbcException("Jdbc Service configuration error - " + msg, args);
- }
-}
diff --git a/plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/internal/osgi/JdbcServiceImpl.java b/plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/internal/osgi/JdbcServiceImpl.java
index b7b6bf30f64..530c93067ff 100644
--- a/plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/internal/osgi/JdbcServiceImpl.java
+++ b/plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/internal/osgi/JdbcServiceImpl.java
@@ -50,7 +50,7 @@ import org.osgi.service.component.annotations.Reference;
/**
* @author Roberto E. Escobar
*/
-@Component(configurationPid = "OseeJdbc", factory = "org.eclipse.osee.jdbc.JdbcService", property = {
+@Component(configurationPid = "OseeJdbc", property = {
JDBC_SERVER__HOST + "=127.0.0.1",
JDBC_SERVER__PORT + "=8088",
JDBC_SERVER__DB_DATA_PATH + "=file:demo/hsql/osee.hsql.db",
diff --git a/plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/internal/osgi/JdbcSvcCfgChangeType.java b/plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/internal/osgi/JdbcSvcCfgChangeType.java
deleted file mode 100644
index 2852d53a0a7..00000000000
--- a/plugins/org.eclipse.osee.jdbc/src/org/eclipse/osee/jdbc/internal/osgi/JdbcSvcCfgChangeType.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*********************************************************************
- * Copyright (c) 2014 Boeing
- *
- * This program and the accompanying materials are made
- * available under the terms of the Eclipse Public License 2.0
- * which is available at https://www.eclipse.org/legal/epl-2.0/
- *
- * SPDX-License-Identifier: EPL-2.0
- *
- * Contributors:
- * Boeing - initial API and implementation
- **********************************************************************/
-
-package org.eclipse.osee.jdbc.internal.osgi;
-
-import java.util.HashMap;
-import java.util.Map;
-import java.util.Map.Entry;
-import org.eclipse.osee.framework.jdk.core.util.Compare;
-import org.eclipse.osee.jdbc.JdbcConstants;
-
-/**
- * @author Roberto E. Escobar
- */
-public enum JdbcSvcCfgChangeType {
- NO_CHANGE,
- ALL_CHANGED,
- JDBC_PROPERTY,
- OTHER_CHANGE;
-
- public boolean isJdbcChange() {
- return JdbcSvcCfgChangeType.JDBC_PROPERTY == this;
- }
-
- public boolean isAllDifferent() {
- return JdbcSvcCfgChangeType.ALL_CHANGED == this;
- }
-
- public static JdbcSvcCfgChangeType getChangeType(Map<String, Object> original, Map<String, Object> other) {
- JdbcSvcCfgChangeType changeType = JdbcSvcCfgChangeType.NO_CHANGE;
- if (original != null && other != null) {
- if (original.size() != other.size()) {
- changeType = ALL_CHANGED;
- } else {
- if (Compare.isDifferent(original, other)) {
- if (Compare.isDifferent(jdbcEntries(original), jdbcEntries(other))) {
- changeType = JDBC_PROPERTY;
- } else {
- changeType = OTHER_CHANGE;
- }
- }
- }
- } else if (original == null && other == null) {
- changeType = NO_CHANGE;
- } else {
- changeType = ALL_CHANGED;
- }
- return changeType;
- }
-
- private static Map<String, Object> jdbcEntries(Map<String, Object> original) {
- Map<String, Object> toReturn = new HashMap<>();
- for (Entry<String, Object> entry : original.entrySet()) {
- if (entry.getKey().startsWith(JdbcConstants.NAMESPACE)) {
- toReturn.put(entry.getKey(), entry.getValue());
- }
- }
- return toReturn;
- }
-} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.orcs.db/META-INF/MANIFEST.MF b/plugins/org.eclipse.osee.orcs.db/META-INF/MANIFEST.MF
index 3dd5a733755..fe73b8f5ba4 100644
--- a/plugins/org.eclipse.osee.orcs.db/META-INF/MANIFEST.MF
+++ b/plugins/org.eclipse.osee.orcs.db/META-INF/MANIFEST.MF
@@ -49,4 +49,5 @@ Import-Package: com.google.common.base,
org.eclipse.osee.orcs.core.internal.tuple,
org.eclipse.osee.orcs.data,
org.eclipse.osee.orcs.search,
- org.osgi.framework
+ org.osgi.framework,
+ org.osgi.service.component.annotations
diff --git a/plugins/org.eclipse.osee.server.application/OSGI-INF/osee.server.application.xml b/plugins/org.eclipse.osee.server.application/OSGI-INF/osee.server.application.xml
index 28f021f7606..653579be5c7 100644
--- a/plugins/org.eclipse.osee.server.application/OSGI-INF/osee.server.application.xml
+++ b/plugins/org.eclipse.osee.server.application/OSGI-INF/osee.server.application.xml
@@ -5,7 +5,7 @@
<provide interface="javax.ws.rs.core.Application"/>
</service>
<reference bind="setApplicationServerManager" cardinality="1..1" interface="org.eclipse.osee.framework.core.server.IApplicationServerManager" name="IApplicationServerManager" policy="static"/>
- <reference bind="addJdbcService" cardinality="0..n" interface="org.eclipse.osee.jdbc.JdbcService" name="JdbcService" policy="dynamic" unbind="removeJdbcService"/>
+ <reference bind="addJdbcService" cardinality="0..n" interface="org.eclipse.osee.jdbc.JdbcService" name="JdbcService" policy="dynamic" />
<reference bind="setAuthenticationManager" cardinality="1..1" interface="org.eclipse.osee.framework.core.server.IAuthenticationManager" name="IAuthenticationManager" policy="static"/>
<reference bind="setActivityLog" cardinality="1..1" interface="org.eclipse.osee.activity.api.ActivityLog" name="ActivityLog" policy="static"/>
</scr:component>
diff --git a/plugins/org.eclipse.osee.server.application/src/org/eclipse/osee/server/application/ServerApplication.java b/plugins/org.eclipse.osee.server.application/src/org/eclipse/osee/server/application/ServerApplication.java
index b380655851a..8785b9aa6f1 100644
--- a/plugins/org.eclipse.osee.server.application/src/org/eclipse/osee/server/application/ServerApplication.java
+++ b/plugins/org.eclipse.osee.server.application/src/org/eclipse/osee/server/application/ServerApplication.java
@@ -16,7 +16,6 @@ package org.eclipse.osee.server.application;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
-import java.util.concurrent.ConcurrentHashMap;
import javax.ws.rs.ApplicationPath;
import javax.ws.rs.core.Application;
import org.eclipse.osee.activity.api.ActivityLog;
@@ -34,7 +33,7 @@ public class ServerApplication extends Application {
private final Set<Object> singletons = new HashSet<>();
private IApplicationServerManager applicationServerManager;
- private final Map<String, JdbcService> jdbcServices = new ConcurrentHashMap<>();
+ private JdbcService jdbcService;
private IAuthenticationManager authManager;
private ActivityLog activityLog;
@@ -51,11 +50,7 @@ public class ServerApplication extends Application {
}
public void addJdbcService(JdbcService jdbcService) {
- jdbcServices.put(jdbcService.getId(), jdbcService);
- }
-
- public void removeJdbcService(JdbcService jdbcService) {
- jdbcServices.remove(jdbcService.getId());
+ this.jdbcService = jdbcService;
}
@Override
@@ -64,11 +59,10 @@ public class ServerApplication extends Application {
}
public void start(Map<String, Object> properties) {
- singletons.add(new ServerHealthEndpointImpl(applicationServerManager, jdbcServices, authManager, activityLog));
+ singletons.add(new ServerHealthEndpointImpl(applicationServerManager, jdbcService, authManager, activityLog));
}
public void stop() {
singletons.clear();
}
-
-}
+} \ No newline at end of file
diff --git a/plugins/org.eclipse.osee.server.application/src/org/eclipse/osee/server/application/internal/ServerHealthEndpointImpl.java b/plugins/org.eclipse.osee.server.application/src/org/eclipse/osee/server/application/internal/ServerHealthEndpointImpl.java
index 3ba4cdb6e6b..046f83ec5fd 100644
--- a/plugins/org.eclipse.osee.server.application/src/org/eclipse/osee/server/application/internal/ServerHealthEndpointImpl.java
+++ b/plugins/org.eclipse.osee.server.application/src/org/eclipse/osee/server/application/internal/ServerHealthEndpointImpl.java
@@ -20,7 +20,6 @@ import java.net.URL;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
-import java.util.Map;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
@@ -34,7 +33,6 @@ import org.eclipse.osee.framework.core.util.HttpProcessor.AcquireResult;
import org.eclipse.osee.framework.jdk.core.util.AHTML;
import org.eclipse.osee.framework.jdk.core.util.Lib;
import org.eclipse.osee.framework.jdk.core.util.OseeProperties;
-import org.eclipse.osee.jdbc.JdbcClient;
import org.eclipse.osee.jdbc.JdbcService;
import org.eclipse.osee.server.application.internal.model.ServerStatus;
import org.eclipse.osee.server.application.internal.model.StatusKey;
@@ -46,15 +44,14 @@ import org.eclipse.osee.server.application.internal.operations.BuildServerStatus
@Path("/health")
public final class ServerHealthEndpointImpl {
private final IApplicationServerManager applicationServerManager;
- private final Map<String, JdbcService> jdbcServices;
+ private final JdbcService jdbcService;
private final IAuthenticationManager authManager;
private final ActivityLog activityLog;
private ObjectMapper mapper;
- private static final String GET_VALUE_SQL = "Select OSEE_VALUE FROM osee_info where OSEE_KEY = ?";
- public ServerHealthEndpointImpl(IApplicationServerManager applicationServerManager, Map<String, JdbcService> jdbcServices, IAuthenticationManager authManager, ActivityLog activityLog) {
+ public ServerHealthEndpointImpl(IApplicationServerManager applicationServerManager, JdbcService jdbcService, IAuthenticationManager authManager, ActivityLog activityLog) {
this.applicationServerManager = applicationServerManager;
- this.jdbcServices = jdbcServices;
+ this.jdbcService = jdbcService;
this.authManager = authManager;
this.activityLog = activityLog;
}
@@ -103,24 +100,14 @@ public final class ServerHealthEndpointImpl {
}
private String serverStatusAsll(boolean details) {
-
// Retrieve servers from OseeInfo
- String serversStr =
- OseeInfo.getValue(jdbcServices.values().iterator().next().getClient(), OseeProperties.OSEE_HEALTH_SERVERS_KEY);
+ String serversStr = OseeInfo.getValue(jdbcService.getClient(), OseeProperties.OSEE_HEALTH_SERVERS_KEY);
serversStr = serversStr.replaceAll(" ", "");
List<String> servers = new ArrayList<>();
for (String server : serversStr.split(",")) {
servers.add(server);
}
- // Retrieve servers from OseeInfo
- serversStr =
- getValue(jdbcServices.values().iterator().next().getClient(), OseeProperties.OSEE_HEALTH_SERVERS_KEY);
- serversStr = serversStr.replaceAll(" ", "");
- for (String server : serversStr.split(",")) {
- servers.add(server);
- }
-
if (servers.size() == 0) {
throw new IllegalStateException("No application.servers configured in osee.json file");
}
@@ -179,10 +166,4 @@ public final class ServerHealthEndpointImpl {
}
sb.append(AHTML.addRowMultiColumnTable(values.toArray(new String[values.size()])));
}
-
- private String getValue(JdbcClient jdbcClient, String key) {
- String toReturn = jdbcClient.fetch("", GET_VALUE_SQL, key);
- return toReturn;
- }
-
} \ No newline at end of file

Back to the top