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

Refactorings/exterminate statics #3837

Merged
Merged
Changes from 1 commit
Commits
Show all changes
98 commits
Select commit Hold shift + click to select a range
9040481
:enh: removing static declarations in favour of injection
dseurotech Jun 7, 2023
eb7048e
:enh: injecting services into Rest resources
dseurotech Jun 8, 2023
7799180
:enh: further removal of statics
dseurotech Jun 8, 2023
b082a6c
:enh: injecting services in Job Engine Resource
dseurotech Jun 9, 2023
bd9bcfe
:ref: removing static initializations
dseurotech Jun 12, 2023
358285d
:ref: removing static initializations
dseurotech Jun 12, 2023
28c1620
:enh: injecting into jbatch classes
dseurotech Jun 14, 2023
3010c05
:ref: providing an alternative (DI-based) mechanism to retrieve Trans…
dseurotech Jun 16, 2023
f4efdef
:enh: actually using dependency injection in Translator classes, now …
dseurotech Jun 19, 2023
2337989
:enh: cleaned up unused classes, marked for future injection others, …
dseurotech Jun 20, 2023
846f202
:ref: reworked datastore implementation to remove dependency loops an…
dseurotech Jun 22, 2023
1344d3d
:enh: removing unnecessary DatastoreClientFactory class
dseurotech Jun 22, 2023
e274e14
:enh: separating facade from repository in datastore implementation
dseurotech Jun 23, 2023
98ad34c
:ref: hiding the elasticsearch specific implementation of datastores …
dseurotech Jun 27, 2023
065482b
:ref: further removal of static injection wherever possible
dseurotech Jun 29, 2023
087e418
:enh: converting static helper classes into injectable ones
dseurotech Jun 29, 2023
3441c4e
:enh: removed further statics, and marked for fix those that could no…
dseurotech Jul 5, 2023
1060320
:changing artifacts version for this branch
dseurotech Jul 6, 2023
8888761
minor adjustments
dseurotech Jul 7, 2023
6469bc2
:enh: generalizing elasticsearch implementation of storable object re…
dseurotech Jul 14, 2023
6571912
:enh: removing synch call from facade (as it is a repository concern)
dseurotech Jul 17, 2023
3ac4201
log statements
dseurotech Jul 19, 2023
820b8d4
:enh: allowing for reset and reload of settings (instead of destroyin…
dseurotech Jul 21, 2023
ed7f1b5
::fix: removed reference to removed class
dseurotech Aug 1, 2023
70945d2
changed artifacts versions as the underscore was causing issues in so…
dseurotech Aug 2, 2023
e2a91ce
:enh: integrating guice with PostConstruct support
dseurotech Aug 10, 2023
68ccb6d
:new: KapuaLocaotor (Guice implementation) can now be used within Art…
dseurotech Aug 11, 2023
311ac5e
:enh: more metric components under DI in Artemis
dseurotech Aug 11, 2023
8d933a6
:enh: wiring broker beans in DI
dseurotech Aug 11, 2023
3b6a9a9
:fix: javadoc
dseurotech Aug 11, 2023
fa5c333
:fix: tests
dseurotech Aug 11, 2023
91620a1
:fix: missing @Provides resulted in missing beans
dseurotech Aug 11, 2023
cead230
:ref: MetricService is now instantiated as a Singleton within the DI,…
dseurotech Aug 17, 2023
0913419
:ref: preparing more classes for injection
dseurotech Aug 18, 2023
c1c9c7f
:fix: tests
dseurotech Aug 18, 2023
15ec2d4
:ref: completed injection of artemis components (some interfaces migh…
dseurotech Aug 18, 2023
cf09e5a
:ref: wiring Metrics components in DI
dseurotech Aug 21, 2023
d6f5d2c
:fix: test wiring
dseurotech Aug 22, 2023
ac233c7
:enh: better wiring, KapuaApiCoreSetting under DI
dseurotech Aug 30, 2023
14310e8
forcing liquibase to run before lifecycle app
dseurotech Aug 30, 2023
b1d56b3
:enh: moved parsing logic out of ScopeId DTO
dseurotech Aug 30, 2023
e37bcdd
:abandoning gwt console project from refactorings
dseurotech Aug 31, 2023
0a25327
:ref: Converted CryptoUtils into injectable implementation of generic…
dseurotech Aug 31, 2023
54099fb
:ref: removed over-engineered ServiceEventBusManager and replaced wit…
dseurotech Sep 1, 2023
aa5d45b
:ref: tackling additional issues
dseurotech Sep 1, 2023
7220212
:enh: simplified wiring of OpenID configuration
dseurotech Sep 5, 2023
ea0291c
:enh: Injectable ClientIdGenerator
dseurotech Sep 6, 2023
24df3ca
:ref:SecretAttributeMigratorModelUtils and EncryptionMigrationSetting…
dseurotech Sep 6, 2023
7ff26f9
:ref: injecting more configuration classes
dseurotech Sep 6, 2023
22bca7b
:ref: injectable OpenIDUtils
dseurotech Sep 8, 2023
bb000b5
:ref: moved some configuration singletons under DI, instead of being …
dseurotech Sep 8, 2023
ae8d085
:enh: another round of static removal
dseurotech Sep 8, 2023
e6a5f5e
:ref: final round of static removal for this PR
dseurotech Sep 11, 2023
df961f5
:fix: dealing with container startup issues
dseurotech Sep 18, 2023
a9424f1
:fix: better handling of corner case
dseurotech Sep 19, 2023
66644b3
:enh: it is now possible to define overriding guice modules
dseurotech Sep 19, 2023
74bf1e2
:fix: avoid starting ES rest client too early
dseurotech Sep 19, 2023
c8e0bfc
:fix: unit test failing in CI only (?!)
dseurotech Sep 20, 2023
acb28aa
:enh: translator components are now fully injected
dseurotech Sep 25, 2023
7bfe146
:enh: Cache management is now fully under DI
dseurotech Sep 25, 2023
0a27846
:enh: cleaner artemis startup
dseurotech Sep 25, 2023
d99d214
:enh: better configuration of datatstore Client configuration
dseurotech Sep 25, 2023
7ce5486
:ref: spearating data class from its mapping to shiro
dseurotech Sep 25, 2023
709542a
:enh: better configuration of SimpleRegistrationProcessor
dseurotech Sep 25, 2023
46c1f00
:bomb: bootstrapping the guice locator implementation fully at startu…
dseurotech Sep 25, 2023
3e1252b
:fix: tests
dseurotech Sep 26, 2023
1fc98f3
:enh: promoting kapua-to-shiro permission mapping to a shared collabo…
dseurotech Sep 26, 2023
7ba37b1
:enh: Guice Injection stage is now configurable
dseurotech Sep 26, 2023
161ef7d
:fix: tests
dseurotech Sep 26, 2023
ead1623
:fix: job engine is unable to start in production stage, as the conte…
dseurotech Sep 27, 2023
4cc96bf
:fix: startup order sequence fixes
dseurotech Oct 2, 2023
9cb9b21
:enh: better logging
dseurotech Oct 5, 2023
0ba846c
:enh: providing additional retrieval strategies for locator components
dseurotech Oct 9, 2023
221c20c
:fix: making sure metrics components are instantiated as singletons
dseurotech Oct 18, 2023
a3bd453
:fix: cleaner database initialization
dseurotech Nov 16, 2023
2a9ebc0
:fix: using proper auth login metric factory
dseurotech Nov 21, 2023
7829a13
:enh: removed false extension points
dseurotech Nov 23, 2023
f66bc32
:fix: removed autoclosable declaration from a class that was never cl…
dseurotech Nov 24, 2023
7fbfccd
:fix: deleted class used for reference during refactoring
dseurotech Nov 24, 2023
4096606
removed leftovers
dseurotech Nov 27, 2023
47cc620
:enh: further wiring
dseurotech Nov 27, 2023
e149848
:new: wiring
dseurotech Nov 29, 2023
c8c2b05
:new: internal endpoint to export guice wiring
dseurotech Nov 29, 2023
69adc93
:enh: moved locator config parsing logic to separate collaborator
dseurotech Nov 29, 2023
5b6b26d
:enh: standardized Artemis' locator and db initialization
dseurotech Nov 30, 2023
77db17f
:enh: no reason for the job engine driver to be static
dseurotech Nov 30, 2023
d358ba4
:fix: exposing field to subclasses
dseurotech Dec 4, 2023
ca31b10
:fix: module dependency was in the wrong direction
dseurotech Dec 5, 2023
0a8631a
:enh: allowing to search for a component by type AND named annotation
dseurotech Dec 5, 2023
ccf8dea
:fix: post-rebase fixes
dseurotech Dec 6, 2023
5938a2d
:fix: actually filtering for specific packages during guice modules d…
dseurotech Dec 15, 2023
d8f3dc2
:enh: minor fixes to InMemoryRepository to simplify its use for testing
dseurotech Dec 18, 2023
92cfc8e
:fix: separating MetricRegistry initialization logic out of MetricsSe…
dseurotech Dec 18, 2023
59d42ee
:ref: clenar implementation of xml property adapters, reducing duplic…
dseurotech Jan 10, 2024
a70d740
:ref: cleanup and tests for XmlPropertiesAdapter
dseurotech Jan 11, 2024
047bdbe
:fix: post-rebase fixes
dseurotech Jan 22, 2024
329380e
:fix: guice AOP is unable to intercept for manually provided classes
dseurotech Feb 5, 2024
b8e989e
:fix: moving back to 2.0.0-SNAPSHOT in all poms, before the big merge
dseurotech Feb 6, 2024
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
Prev Previous commit
Next Next commit
:ref: cleanup and tests for XmlPropertiesAdapter
Signed-off-by: dseurotech <davide.salvador@eurotech.com>
dseurotech committed Feb 5, 2024
commit a70d74094f710e2ad12a43db87dae5b32e1c1353
Original file line number Diff line number Diff line change
@@ -14,12 +14,12 @@

import org.eclipse.kapua.commons.crypto.CryptoUtil;
import org.eclipse.kapua.model.xml.XmlPropertyAdapted;
import org.eclipse.kapua.model.xml.adapters.XmlPropertyAdapter;
import org.eclipse.kapua.model.xml.adapters.ClassBasedXmlPropertyAdapterBase;

import java.util.Arrays;
import java.util.stream.Collectors;

public class PasswordPropertyAdapter extends XmlPropertyAdapter<Password> {
public class PasswordPropertyAdapter extends ClassBasedXmlPropertyAdapterBase<Password> {
private final CryptoUtil cryptoUtil;

public PasswordPropertyAdapter(CryptoUtil cryptoUtil) {

This file was deleted.

Original file line number Diff line number Diff line change
@@ -12,90 +12,25 @@
*******************************************************************************/
package org.eclipse.kapua.model.xml;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
public interface XmlPropertyAdapted<T extends Enum<T>> {

public abstract class XmlPropertyAdapted<T extends Enum<T>> {
/**
* The name of the property.
*/
@XmlAttribute(name = "name")
private String name;
String getName();

/**
* Whether the property value is an array.
*/
@XmlAttribute(name = "array")
private boolean array;
void setName(String name);

/**
* Whether the property value is encrypted.
*/
@XmlAttribute(name = "encrypted")
private boolean encrypted;
boolean getArray();

/**
* The property type.
*/
@XmlAttribute(name = "type")
private T type;
void setArray(boolean array);

/**
* The property value(s).
*/
@XmlElement(name = "value")
private String[] values;
T getType();

public XmlPropertyAdapted() {
}
void setType(T type);

public XmlPropertyAdapted(String name,
T type,
String[] values) {
super();
boolean isEncrypted();

this.type = type;
this.values = values;
this.encrypted = false;
}
void setEncrypted(boolean encrypted);

public String getName() {
return name;
}
String[] getValues();

public void setName(String name) {
this.name = name;
}

public boolean getArray() {
return array;
}

public void setArray(boolean array) {
this.array = array;
}

public T getType() {
return type;
}

public void setType(T type) {
this.type = type;
}

public boolean isEncrypted() {
return encrypted;
}

public void setEncrypted(boolean encrypted) {
this.encrypted = encrypted;
}

public String[] getValues() {
return values;
}

public void setValues(String[] values) {
this.values = values;
}
void setValues(String[] values);
}
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@
*******************************************************************************/
package org.eclipse.kapua.model.xml.adapters;

public class BooleanPropertyAdapter extends XmlPropertyAdapter<Boolean> {
public class BooleanPropertyAdapter extends ClassBasedXmlPropertyAdapterBase<Boolean> {

public BooleanPropertyAdapter() {
super(Boolean.class);
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@
*******************************************************************************/
package org.eclipse.kapua.model.xml.adapters;

public class BytePropertyAdapter extends XmlPropertyAdapter<Byte> {
public class BytePropertyAdapter extends ClassBasedXmlPropertyAdapterBase<Byte> {

public BytePropertyAdapter() {
super(Byte.class);
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@
*******************************************************************************/
package org.eclipse.kapua.model.xml.adapters;

public class CharPropertyAdapter extends XmlPropertyAdapter<Character> {
public class CharPropertyAdapter extends ClassBasedXmlPropertyAdapterBase<Character> {

public CharPropertyAdapter() {
super(Character.class);
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*******************************************************************************
* Copyright (c) 2019, 2022 Eurotech and/or its affiliates and others
*
* 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:
* Eurotech - initial API and implementation
*******************************************************************************/
package org.eclipse.kapua.model.xml.adapters;

import org.eclipse.kapua.model.xml.XmlPropertyAdapted;

import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public abstract class ClassBasedXmlPropertyAdapterBase<T> implements XmlPropertyAdapter {

private final Class<T> clazz;

protected ClassBasedXmlPropertyAdapterBase(Class<T> clazz) {
this.clazz = clazz;
}

@Override
public boolean canMarshall(Class<?> objectClass) {
return objectClass.isArray() ? clazz.equals(objectClass.getComponentType()) : clazz.equals(objectClass);
}

@Override
public void marshallValues(XmlPropertyAdapted<?> property, Object value) {
if (!value.getClass().isArray()) {
property.setArray(false);
property.setEncrypted(false);
property.setValues(new String[]{marshallValue(value)});
} else {
property.setArray(true);
Object[] nativeValues = (Object[]) value;
String[] stringValues = new String[nativeValues.length];
for (int i = 0; i < nativeValues.length; i++) {
if (nativeValues[i] != null) {
stringValues[i] = this.marshallValue(nativeValues[i]);
}
}
property.setValues(stringValues);
}
}

public String marshallValue(Object object) {
return object.toString();
}

public abstract T unmarshallValue(String value);

@Override
public Object unmarshallValues(XmlPropertyAdapted<?> property) {
if (!property.getArray()) {
return unmarshallValue(property.getValues()[0]);
} else {
final List<T> items = Arrays.stream(property.getValues()).map(this::unmarshallValue).collect(Collectors.toList());
return items.toArray((T[]) Array.newInstance(clazz, items.size()));
}
}

}
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@
*******************************************************************************/
package org.eclipse.kapua.model.xml.adapters;

public class DoublePropertyAdapter extends XmlPropertyAdapter<Double> {
public class DoublePropertyAdapter extends ClassBasedXmlPropertyAdapterBase<Double> {

public DoublePropertyAdapter() {
super(Double.class);
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@
*******************************************************************************/
package org.eclipse.kapua.model.xml.adapters;

public class FloatPropertyAdapter extends XmlPropertyAdapter<Float> {
public class FloatPropertyAdapter extends ClassBasedXmlPropertyAdapterBase<Float> {

public FloatPropertyAdapter() {
super(Float.class);
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@
*******************************************************************************/
package org.eclipse.kapua.model.xml.adapters;

public class IntegerPropertyAdapter extends XmlPropertyAdapter<Integer> {
public class IntegerPropertyAdapter extends ClassBasedXmlPropertyAdapterBase<Integer> {

public IntegerPropertyAdapter() {
super(Integer.class);
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@
*******************************************************************************/
package org.eclipse.kapua.model.xml.adapters;

public class LongPropertyAdapter extends XmlPropertyAdapter<Long> {
public class LongPropertyAdapter extends ClassBasedXmlPropertyAdapterBase<Long> {

public LongPropertyAdapter() {
super(Long.class);
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@
*******************************************************************************/
package org.eclipse.kapua.model.xml.adapters;

public class ShortPropertyAdapter extends XmlPropertyAdapter<Short> {
public class ShortPropertyAdapter extends ClassBasedXmlPropertyAdapterBase<Short> {

public ShortPropertyAdapter() {
super(Short.class);
Original file line number Diff line number Diff line change
@@ -12,7 +12,7 @@
*******************************************************************************/
package org.eclipse.kapua.model.xml.adapters;

public class StringPropertyAdapter extends XmlPropertyAdapter<String> {
public class StringPropertyAdapter extends ClassBasedXmlPropertyAdapterBase<String> {

public StringPropertyAdapter() {
super(String.class);
Loading