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

Refactoring #685

Merged
merged 10 commits into from
Nov 9, 2023
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
2 changes: 1 addition & 1 deletion cnf/ext/runtime.bnd
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ bundles.required: \
org.apache.aries.component-dsl.component-dsl,\
org.apache.commons.lang3,\
org.apache.commons.commons-io,\
org.apache.commons.commons-text,\
org.apache.commons.text,\
org.eclipse.equinox.preferences,\
controlsfx,\
javax.inject,\
Expand Down
14 changes: 7 additions & 7 deletions cnf/maven/build.maven
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ com.google.mug:mug:6.6

# bnd

biz.aQute.bnd:biz.aQute.bndlib:6.4.1
biz.aQute.bnd:biz.aQute.resolve:6.4.1
biz.aQute.bnd:biz.aQute.remote.agent:6.4.1
biz.aQute.bnd:biz.aQute.launchpad:6.4.1
biz.aQute.bnd:biz.aQute.remote.agent:6.4.1
biz.aQute.bnd:biz.aQute.bnd.util:6.4.1
biz.aQute.bnd:biz.aQute.bndlib:7.0.0
biz.aQute.bnd:biz.aQute.resolve:7.0.0
biz.aQute.bnd:biz.aQute.remote.agent:7.0.0
biz.aQute.bnd:biz.aQute.launchpad:7.0.0
biz.aQute.bnd:biz.aQute.remote.agent:7.0.0
biz.aQute.bnd:biz.aQute.bnd.util:7.0.0

# Apache

Expand Down Expand Up @@ -58,7 +58,7 @@ org.osgi:org.osgi.util.converter:1.0.9

eu.hansolo:tilesfx:17.1.31
eu.hansolo:toolbox:17.0.57
eu.hansolo:toolboxfx:17.0.47
eu.hansolo:toolboxfx:17.0.49

# FormsFx

Expand Down
66 changes: 33 additions & 33 deletions cnf/maven/runtime.maven
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ com.google.code.gson:gson:2.10.1

# Apache

commons-io:commons-io:2.13.0
commons-io:commons-io:2.15.0
org.apache.aries.component-dsl:org.apache.aries.component-dsl.component-dsl:1.2.2
org.apache.commons:commons-lang3:3.13.0
org.apache.commons:commons-text:1.10.0
org.apache.commons:commons-text:1.11.0

# JSON

Expand Down Expand Up @@ -35,53 +35,53 @@ org.osgi:org.osgi.service.component:1.5.1

# Equinox

org.eclipse.platform:org.eclipse.equinox.app:1.6.200
org.eclipse.platform:org.eclipse.equinox.bidi:1.4.200
org.eclipse.platform:org.eclipse.equinox.common:3.18.0
org.eclipse.platform:org.eclipse.equinox.app:1.6.300
org.eclipse.platform:org.eclipse.equinox.bidi:1.4.300
org.eclipse.platform:org.eclipse.equinox.common:3.18.100
org.eclipse.platform:org.eclipse.equinox.concurrent:1.2.100
org.eclipse.platform:org.eclipse.equinox.console:1.4.500
org.eclipse.platform:org.eclipse.equinox.ds:1.6.200
org.eclipse.platform:org.eclipse.equinox.event:1.6.200
org.eclipse.platform:org.eclipse.equinox.launcher:1.6.400
org.eclipse.platform:org.eclipse.equinox.launcher:1.6.500
org.eclipse.platform:org.eclipse.equinox.launcher.cocoa.macosx:1.2.700
org.eclipse.platform:org.eclipse.equinox.launcher.cocoa.macosx.x86_64:1.2.700
org.eclipse.platform:org.eclipse.equinox.launcher.gtk.linux.x86_64:1.2.700
org.eclipse.platform:org.eclipse.equinox.launcher.win32.win32.x86_64:1.2.700
org.eclipse.platform:org.eclipse.equinox.preferences:3.10.200
org.eclipse.platform:org.eclipse.equinox.registry:3.11.200
org.eclipse.platform:org.eclipse.osgi:3.18.400
org.eclipse.platform:org.eclipse.equinox.preferences:3.10.300
org.eclipse.platform:org.eclipse.equinox.registry:3.11.300
org.eclipse.platform:org.eclipse.osgi:3.18.500
org.eclipse.platform:org.eclipse.osgi.services:3.11.100

# Eclipse e4

org.eclipse.platform:org.eclipse.e4.core.commands:1.1.0
org.eclipse.platform:org.eclipse.e4.core.contexts:1.12.0
org.eclipse.platform:org.eclipse.e4.core.di:1.9.0
org.eclipse.platform:org.eclipse.e4.core.di.annotations:1.8.0
org.eclipse.platform:org.eclipse.e4.core.commands:1.1.100
org.eclipse.platform:org.eclipse.e4.core.contexts:1.12.100
org.eclipse.platform:org.eclipse.e4.core.di:1.9.100
org.eclipse.platform:org.eclipse.e4.core.di.annotations:1.8.100
org.eclipse.platform:org.eclipse.e4.core.di.extensions:0.18.0
org.eclipse.platform:org.eclipse.e4.core.di.extensions.supplier:0.17.0
org.eclipse.platform:org.eclipse.e4.core.services:2.4.0
org.eclipse.platform:org.eclipse.e4.emf.xpath:0.4.0
org.eclipse.platform:org.eclipse.e4.ui.di:1.5.0
org.eclipse.platform:org.eclipse.e4.ui.model.workbench:2.4.0
org.eclipse.platform:org.eclipse.e4.ui.services:1.6.0
org.eclipse.platform:org.eclipse.e4.ui.workbench:1.15.0
org.eclipse.platform:org.eclipse.e4.core.di.extensions.supplier:0.17.100
org.eclipse.platform:org.eclipse.e4.core.services:2.4.100
org.eclipse.platform:org.eclipse.e4.emf.xpath:0.4.100
org.eclipse.platform:org.eclipse.e4.ui.di:1.5.100
org.eclipse.platform:org.eclipse.e4.ui.model.workbench:2.4.100
org.eclipse.platform:org.eclipse.e4.ui.services:1.6.100
org.eclipse.platform:org.eclipse.e4.ui.workbench:1.15.100

# Eclipse Platform

org.eclipse.platform:org.eclipse.core.commands:3.11.0
org.eclipse.platform:org.eclipse.core.contenttype:3.9.0
org.eclipse.platform:org.eclipse.core.databinding:1.13.0
org.eclipse.platform:org.eclipse.core.databinding.beans:1.10.0
org.eclipse.platform:org.eclipse.core.databinding.observable:1.13.0
org.eclipse.platform:org.eclipse.core.databinding.property:1.10.0
org.eclipse.platform:org.eclipse.core.filebuffers:3.8.0
org.eclipse.platform:org.eclipse.core.filesystem:1.10.0
org.eclipse.platform:org.eclipse.core.jobs:3.14.0
org.eclipse.platform:org.eclipse.core.net:1.5.0
org.eclipse.platform:org.eclipse.core.resources:3.19.0
org.eclipse.platform:org.eclipse.core.runtime:3.27.0
org.eclipse.platform:org.eclipse.core.variables:3.6.0
org.eclipse.platform:org.eclipse.core.commands:3.11.100
org.eclipse.platform:org.eclipse.core.contenttype:3.9.100
org.eclipse.platform:org.eclipse.core.databinding:1.13.100
org.eclipse.platform:org.eclipse.core.databinding.beans:1.10.100
org.eclipse.platform:org.eclipse.core.databinding.observable:1.13.100
org.eclipse.platform:org.eclipse.core.databinding.property:1.10.100
org.eclipse.platform:org.eclipse.core.filebuffers:3.8.100
org.eclipse.platform:org.eclipse.core.filesystem:1.10.100
org.eclipse.platform:org.eclipse.core.jobs:3.15.0
org.eclipse.platform:org.eclipse.core.net:1.5.100
org.eclipse.platform:org.eclipse.core.resources:3.19.100
org.eclipse.platform:org.eclipse.core.runtime:3.29.0
org.eclipse.platform:org.eclipse.core.variables:3.6.100

# OSGi Logging

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,9 @@ private <T> T getInstance(final Class<T> requestedType, final Class<?> parent) {
}
return (T) instanceFromProvider;
}

return (T) createNewInstance(type, parent);
} catch (final DiException rootCause) {
final StringBuilder errorMessage = new StringBuilder("DI wasn't able to create your class hierarchy. ");

if (parent != null) {
errorMessage.append("\nCannot instantiate the class [").append(parent.getName()).append("]. ")
.append("At least one of the constructor parameters of type [").append(requestedType)
Expand Down Expand Up @@ -186,7 +184,6 @@ private <T> T createNewInstance(final Class<T> type, final Class<?> parent) {
if (isSingleton(type)) {
singletonInstances.put(type, newInstance);
}

return newInstance;
} catch (final Exception e) {
throw new DiException(createErrorMessageStart(type) + "An Exception was thrown during the instantiation.",
Expand Down Expand Up @@ -376,11 +373,9 @@ private <T> T getInstanceFromProvider(final Class<T> type) {
@SuppressWarnings("unchecked")
private <T> Constructor<T> findConstructor(final Class<T> type) {
final Constructor<?>[] constructors = type.getConstructors();

if (constructors.length == 0) {
throw new DiException(createErrorMessageStart(type) + "The class has no public constructor.");
}

if (constructors.length <= 1) {
return (Constructor<T>) constructors[0];
}
Expand All @@ -400,7 +395,6 @@ private <T> Constructor<T> findConstructor(final Class<T> type) {
+ "Fix this by either make only one constructor public "
+ "or annotate exactly one constructor with the javax.inject.Inject annotation.");
}

// we are not modifying the constructor array so we can safely cast here.
return (Constructor<T>) constructorsWithInject.get(0);
}
Expand Down
46 changes: 23 additions & 23 deletions com.osgifx.console.product/osgifx.bndrun
Original file line number Diff line number Diff line change
Expand Up @@ -135,11 +135,11 @@ install.order : \
javax.inject;version='[1.0.0,1.0.1)';startlevel=10,\
javax.xml.jre;version='[1.3.4,1.3.5)';startlevel=10,\
org.apache.aries.component-dsl.component-dsl;version='[1.2.2,1.2.3)';startlevel=10,\
org.apache.commons.commons-io;version='[2.13.0,2.13.1)';startlevel=10,\
org.apache.commons.commons-text;version='[1.10.0,1.10.1)';startlevel=10,\
org.apache.commons.commons-io;version='[2.15.0,2.15.1)';startlevel=10,\
org.apache.commons.jxpath;version='[1.3.0,1.3.1)';startlevel=10,\
org.apache.commons.lang;version='[2.6.0,2.6.1)';startlevel=10,\
org.apache.commons.lang3;version='[3.13.0,3.13.1)';startlevel=10,\
org.apache.commons.text;version='[1.11.0,1.11.1)';startlevel=10,\
org.apache.felix.cm.json;version='[2.0.0,2.0.1)';startlevel=10,\
org.apache.felix.configadmin;version='[1.9.26,1.9.27)';startlevel=10,\
org.apache.felix.configurator;version='[1.0.18,1.0.19)';startlevel=10,\
Expand All @@ -153,35 +153,35 @@ install.order : \
org.apache.felix.scr;version='[2.2.6,2.2.7)';startlevel=10,\
org.apache.sling.commons.log;version='[5.4.2,5.4.3)';startlevel=10,\
org.apache.sling.commons.logservice;version='[1.1.0,1.1.1)';startlevel=10,\
org.eclipse.core.commands;version='[3.11.0,3.11.1)';startlevel=10,\
org.eclipse.core.contenttype;version='[3.9.0,3.9.1)';startlevel=10,\
org.eclipse.core.databinding.observable;version='[1.13.0,1.13.1)';startlevel=10,\
org.eclipse.core.databinding.property;version='[1.10.0,1.10.1)';startlevel=10,\
org.eclipse.core.commands;version='[3.11.100,3.11.101)';startlevel=10,\
org.eclipse.core.contenttype;version='[3.9.100,3.9.101)';startlevel=10,\
org.eclipse.core.databinding.observable;version='[1.13.100,1.13.101)';startlevel=10,\
org.eclipse.core.databinding.property;version='[1.10.100,1.10.101)';startlevel=10,\
org.eclipse.core.expressions;version='[3.8.200,3.8.201)';startlevel=10,\
org.eclipse.core.jobs;version='[3.14.0,3.14.1)';startlevel=10,\
org.eclipse.core.runtime;version='[3.27.0,3.27.1)';startlevel=10,\
org.eclipse.e4.core.commands;version='[1.1.0,1.1.1)';startlevel=10,\
org.eclipse.e4.core.contexts;version='[1.12.0,1.12.1)';startlevel=10,\
org.eclipse.e4.core.di;version='[1.9.0,1.9.1)';startlevel=10,\
org.eclipse.e4.core.di.annotations;version='[1.8.0,1.8.1)';startlevel=10,\
org.eclipse.core.jobs;version='[3.15.0,3.15.1)';startlevel=10,\
org.eclipse.core.runtime;version='[3.29.0,3.29.1)';startlevel=10,\
org.eclipse.e4.core.commands;version='[1.1.100,1.1.101)';startlevel=10,\
org.eclipse.e4.core.contexts;version='[1.12.100,1.12.101)';startlevel=10,\
org.eclipse.e4.core.di;version='[1.9.100,1.9.101)';startlevel=10,\
org.eclipse.e4.core.di.annotations;version='[1.8.100,1.8.101)';startlevel=10,\
org.eclipse.e4.core.di.extensions;version='[0.18.0,0.18.1)';startlevel=10,\
org.eclipse.e4.core.di.extensions.supplier;version='[0.17.0,0.17.1)';startlevel=10,\
org.eclipse.e4.core.services;version='[2.4.0,2.4.1)';startlevel=10,\
org.eclipse.e4.emf.xpath;version='[0.4.0,0.4.1)';startlevel=10,\
org.eclipse.e4.ui.di;version='[1.5.0,1.5.1)';startlevel=10,\
org.eclipse.e4.ui.model.workbench;version='[2.4.0,2.4.1)';startlevel=10,\
org.eclipse.e4.ui.services;version='[1.6.0,1.6.1)';startlevel=10,\
org.eclipse.e4.ui.workbench;version='[1.15.0,1.15.1)';startlevel=10,\
org.eclipse.e4.core.di.extensions.supplier;version='[0.17.100,0.17.101)';startlevel=10,\
org.eclipse.e4.core.services;version='[2.4.100,2.4.101)';startlevel=10,\
org.eclipse.e4.emf.xpath;version='[0.3.0,0.3.1)';startlevel=10,\
org.eclipse.e4.ui.di;version='[1.5.100,1.5.101)';startlevel=10,\
org.eclipse.e4.ui.model.workbench;version='[2.2.200,2.2.201)';startlevel=10,\
org.eclipse.e4.ui.services;version='[1.6.100,1.6.101)';startlevel=10,\
org.eclipse.e4.ui.workbench;version='[1.15.100,1.15.101)';startlevel=10,\
org.eclipse.emf.common;version='[2.26.0,2.26.1)';startlevel=10,\
org.eclipse.emf.ecore;version='[2.28.0,2.28.1)';startlevel=10,\
org.eclipse.emf.ecore.change;version='[2.14.0,2.14.1)';startlevel=10,\
org.eclipse.emf.ecore.xmi;version='[2.17.0,2.17.1)';startlevel=10,\
org.eclipse.equinox.app;version='[1.6.200,1.6.201)';startlevel=10,\
org.eclipse.equinox.common;version='[3.18.0,3.18.1)';startlevel=10,\
org.eclipse.equinox.app;version='[1.6.300,1.6.301)';startlevel=10,\
org.eclipse.equinox.common;version='[3.18.100,3.18.101)';startlevel=10,\
org.eclipse.equinox.console;version='[1.4.500,1.4.501)';startlevel=10,\
org.eclipse.equinox.event;version='[1.6.200,1.6.201)';startlevel=10,\
org.eclipse.equinox.preferences;version='[3.10.200,3.10.201)';startlevel=10,\
org.eclipse.equinox.registry;version='[3.11.200,3.11.201)';startlevel=10,\
org.eclipse.equinox.preferences;version='[3.10.300,3.10.301)';startlevel=10,\
org.eclipse.equinox.registry;version='[3.11.300,3.11.301)';startlevel=10,\
org.eclipse.fx.core;version='[3.9.0,3.9.1)';startlevel=10,\
org.eclipse.fx.core.databinding;version='[3.9.0,3.9.1)';startlevel=10,\
org.eclipse.fx.core.di;version='[3.9.0,3.9.1)';startlevel=10,\
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,11 @@
import java.lang.reflect.Method;
import java.lang.reflect.Proxy;
import java.util.Collections;
import java.util.Hashtable;
import java.util.HashMap;
import java.util.Map;

import org.eclipse.fx.core.ExceptionUtils;
import org.osgi.framework.FrameworkUtil;
import org.osgi.service.cm.Configuration;
import org.osgi.service.cm.ConfigurationAdmin;

Expand All @@ -41,10 +43,10 @@
*/
public class ConfigHelper<T> {

final T delegate;
final Class<T> type;
final Hashtable<String, Object> properties = new Hashtable<>();
final ConfigurationAdmin cm;
final T delegate;
final Class<T> type;
final ConfigurationAdmin cm;
final Map<String, Object> properties = new HashMap<>();

Method lastInvocation;
String pid;
Expand Down Expand Up @@ -116,7 +118,7 @@ public <X> ConfigHelper<T> set(final X older, final X newer) {
try {
value = Converter.cnv(lastInvocation.getGenericReturnType(), newer);
} catch (final Exception e) {
throw new RuntimeException(e);
throw ExceptionUtils.wrap(e);
}
if (value instanceof Enum<?>) {
value = ((Enum<?>) value).name();
Expand Down Expand Up @@ -151,7 +153,7 @@ public Map<String, Object> read(final String pid) {
try {
configuration = cm.getConfiguration(pid, "?");
} catch (final IOException e) {
throw new RuntimeException(e);
throw ExceptionUtils.wrap(e);
}
final var dict = configuration.getProperties();
if (dict != null) {
Expand All @@ -173,7 +175,7 @@ public void update() {
Configuration configuration;
try {
configuration = cm.getConfiguration(pid, "?");
configuration.update(properties);
configuration.update(FrameworkUtil.asDictionary(properties));
} catch (final IOException e) {
// highly unlikely to occur
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import java.util.Set;
import java.util.stream.Stream;

import org.eclipse.fx.core.ExceptionUtils;
import org.osgi.framework.FrameworkUtil;
import org.osgi.framework.InvalidSyntaxException;
import org.osgi.service.cm.Configuration;
import org.osgi.service.cm.ConfigurationAdmin;
Expand Down Expand Up @@ -57,9 +59,9 @@ public FactoryConfigHelper<T> create() {
try {
configuration = cm.createFactoryConfiguration(factoryPid, "?");
pid = configuration.getPid();
configuration.update(properties);
configuration.update(FrameworkUtil.asDictionary(properties));
} catch (final IOException e) {
throw new RuntimeException(e);
throw ExceptionUtils.wrap(e);
}
return this;
}
Expand Down
Loading
Loading