Skip to content

Commit

Permalink
:fix: post-rebase fixes
Browse files Browse the repository at this point in the history
Signed-off-by: dseurotech <[email protected]>
  • Loading branch information
dseurotech committed Feb 1, 2024
1 parent 27b7df3 commit 8c49b80
Show file tree
Hide file tree
Showing 17 changed files with 50 additions and 85 deletions.
4 changes: 1 addition & 3 deletions assembly/broker-artemis/configurations/locator.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@
</provided>

<packages>
<package>org.eclipse.kapua.commons</package>
<package>org.eclipse.kapua.message</package>
<package>org.eclipse.kapua.service</package>
<package>org.eclipse.kapua</package>
</packages>
</locator-config>
7 changes: 6 additions & 1 deletion assembly/broker-artemis/descriptors/kapua-broker-artemis.xml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@
<include>javax.cache:cache-api</include>
<include>aopalliance:aopalliance</include>
<include>${pom.groupId}:kapua-locator-guice</include>

<!-- / Locator dependencies -->

<include>com.fasterxml.jackson.core:jackson-core</include>
Expand All @@ -109,9 +109,11 @@
<include>com.warrenstrange:googleauth</include>
<include>javax.cache:cache-api</include>
<include>javax.inject:javax.inject</include>
<include>javax.annotation:javax.annotation-api</include>
<include>org.apache.shiro:shiro-core</include>
<include>org.bitbucket.b_c:jose4j</include>
<include>org.javassist:javassist</include>
<include>com.google.zxing:core</include>

<include>${pom.groupId}:kapua-account-api</include>
<include>${pom.groupId}:kapua-account-internal</include>
Expand All @@ -126,14 +128,17 @@
<include>${pom.groupId}:kapua-message-api</include>
<include>${pom.groupId}:kapua-message-internal</include>
<include>${pom.groupId}:kapua-openid-api</include>
<include>${pom.groupId}:kapua-openid-provider</include>
<include>${pom.groupId}:kapua-service-api</include>
<include>${pom.groupId}:kapua-security-authentication-api</include>
<include>${pom.groupId}:kapua-security-authorization-api</include>
<include>${pom.groupId}:kapua-security-certificate-api</include>
<include>${pom.groupId}:kapua-security-registration-api</include>
<include>${pom.groupId}:kapua-security-certificate-internal</include>
<include>${pom.groupId}:kapua-security-shiro</include>
<include>${pom.groupId}:kapua-service-client</include>
<include>${pom.groupId}:kapua-tag-api</include>
<include>${pom.groupId}:kapua-tag-internal</include>
<include>${pom.groupId}:kapua-user-api</include>
<include>${pom.groupId}:kapua-user-internal</include>
</includes>
Expand Down
12 changes: 12 additions & 0 deletions assembly/broker-artemis/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@
<groupId>org.eclipse.kapua</groupId>
<artifactId>kapua-locator-guice</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.kapua</groupId>
<artifactId>kapua-openid-provider</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.kapua</groupId>
<artifactId>kapua-service-api</artifactId>
Expand All @@ -87,10 +91,18 @@
<groupId>org.eclipse.kapua</groupId>
<artifactId>kapua-security-shiro</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.kapua</groupId>
<artifactId>kapua-security-registration-api</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.kapua</groupId>
<artifactId>kapua-tag-api</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.kapua</groupId>
<artifactId>kapua-tag-internal</artifactId>
</dependency>
<dependency>
<groupId>org.eclipse.kapua</groupId>
<artifactId>kapua-user-api</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ public ServerPlugin() {
this.pluginUtility = kapuaLocator.getComponent(PluginUtility.class);
this.publishInfoMessageSizeLimit = brokerSetting.getInt(BrokerSettingKey.PUBLISHED_MESSAGE_SIZE_LOG_THRESHOLD, DEFAULT_PUBLISHED_MESSAGE_SIZE_LOG_THRESHOLD);
serverContext = kapuaLocator.getComponent(ServerContext.class);
deviceConnectionEventListenerService = kapuaLocator.getComponent(DeviceConnectionEventListenerService.class);
brokerEventHandler = new BrokerEventHandler(kapuaLocator.getComponent(CommonsMetric.class));
brokerEventHandler.registerConsumer((brokerEvent) -> disconnectClient(brokerEvent));
brokerEventHandler.start();

Check warning on line 130 in broker/artemis/plugin/src/main/java/org/eclipse/kapua/broker/artemis/plugin/security/ServerPlugin.java

View check run for this annotation

Codecov / codecov/patch

broker/artemis/plugin/src/main/java/org/eclipse/kapua/broker/artemis/plugin/security/ServerPlugin.java#L119-L130

Added lines #L119 - L130 were not covered by tests
Expand All @@ -143,7 +144,7 @@ public void registered(ActiveMQServer server) {
deviceConnectionEventListenerService.addReceiver(serviceEvent -> processDeviceConnectionEvent(serviceEvent));

// Setup service events
ServiceModuleBundle app = KapuaLocator.getInstance().getService(ServiceModuleBundle.class);
ServiceModuleBundle app = KapuaLocator.getInstance().getComponent(ServiceModuleBundle.class);

Check warning on line 147 in broker/artemis/plugin/src/main/java/org/eclipse/kapua/broker/artemis/plugin/security/ServerPlugin.java

View check run for this annotation

Codecov / codecov/patch

broker/artemis/plugin/src/main/java/org/eclipse/kapua/broker/artemis/plugin/security/ServerPlugin.java#L147

Added line #L147 was not covered by tests
app.startup();

// Setup JAXB Context
Expand Down Expand Up @@ -356,7 +357,7 @@ protected void processDeviceConnectionEvent(ServiceEvent event) {
BrokerEvent disconnectEvent = new BrokerEvent(EventType.disconnectClientByConnectionId, sessionContext, sessionContext);

logger.info("Submitting broker event to disconnect clientId: {}, connectionId: {}", fullClientId, sessionContext.getConnectionId());
BrokerEventHandler.getInstance().enqueueEvent(disconnectEvent);
brokerEventHandler.enqueueEvent(disconnectEvent);

Check warning on line 360 in broker/artemis/plugin/src/main/java/org/eclipse/kapua/broker/artemis/plugin/security/ServerPlugin.java

View check run for this annotation

Codecov / codecov/patch

broker/artemis/plugin/src/main/java/org/eclipse/kapua/broker/artemis/plugin/security/ServerPlugin.java#L360

Added line #L360 was not covered by tests
} catch (Exception e) {
logger.warn("Error processing event: {}", e);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ public class CommonsModule extends AbstractKapuaModule {

@Override
protected void configureModule() {
bind(QueryFactory.class).to(QueryFactoryImpl.class);
bind(DataPopulatorRunner.class).in(Singleton.class);
bind(QueryFactory.class).to(QueryFactoryImpl.class).in(Singleton.class);
bind(CryptoSettings.class).toInstance(new CryptoSettings());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,23 @@

import com.google.common.base.MoreObjects;
import org.eclipse.kapua.commons.jpa.JdbcConnectionUrlResolvers;
import org.eclipse.kapua.commons.populators.DataPopulatorRunner;
import org.eclipse.kapua.commons.setting.system.SystemSetting;
import org.eclipse.kapua.commons.setting.system.SystemSettingKey;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import javax.inject.Inject;

/**
* Call Liquibase database schema check and update (if enabled)
*/
public class DatabaseCheckUpdate {

private static final Logger logger = LoggerFactory.getLogger(DatabaseCheckUpdate.class);

public DatabaseCheckUpdate() {
final SystemSetting systemSetting = SystemSetting.getInstance();
@Inject
public DatabaseCheckUpdate(SystemSetting systemSetting, DataPopulatorRunner dataPopulatorRunner) {
logger.info("Kapua database schema check and update...");
try {
final boolean runLiquibase = systemSetting.getBoolean(SystemSettingKey.DB_SCHEMA_UPDATE, false);
Expand Down Expand Up @@ -56,6 +59,7 @@ public DatabaseCheckUpdate() {
} else {

Check warning on line 59 in commons/src/main/java/org/eclipse/kapua/commons/liquibase/DatabaseCheckUpdate.java

View check run for this annotation

Codecov / codecov/patch

commons/src/main/java/org/eclipse/kapua/commons/liquibase/DatabaseCheckUpdate.java#L57-L59

Added lines #L57 - L59 were not covered by tests
logger.warn("Skipping Kapua Liquibase Client as per configured property! {}=false", SystemSettingKey.DB_SCHEMA_UPDATE);
}
dataPopulatorRunner.runPopulators();
} catch (Exception e) {
logger.error("Kapua database schema check and update... ERROR: {}", e.getMessage(), e);
throw new SecurityException(e);

Check warning on line 65 in commons/src/main/java/org/eclipse/kapua/commons/liquibase/DatabaseCheckUpdate.java

View check run for this annotation

Codecov / codecov/patch

commons/src/main/java/org/eclipse/kapua/commons/liquibase/DatabaseCheckUpdate.java#L63-L65

Added lines #L63 - L65 were not covered by tests
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,6 @@
import org.eclipse.kapua.KapuaException;
import org.eclipse.kapua.app.console.ConsoleJAXBContextProvider;
import org.eclipse.kapua.commons.core.ServiceModuleBundle;
<<<<<<< HEAD
import org.eclipse.kapua.commons.liquibase.DatabaseCheckUpdate;
import org.eclipse.kapua.commons.populators.DataPopulatorRunner;
import org.eclipse.kapua.commons.setting.system.SystemSetting;
||||||| parent of d6ede90e91 (:fix: cleaner database initialization)
import org.eclipse.kapua.commons.liquibase.DatabaseCheckUpdate;
import org.eclipse.kapua.commons.setting.system.SystemSetting;
=======
>>>>>>> d6ede90e91 (:fix: cleaner database initialization)
import org.eclipse.kapua.commons.util.xml.JAXBContextProvider;
import org.eclipse.kapua.commons.util.xml.XmlUtil;
import org.eclipse.kapua.locator.KapuaLocator;
Expand Down Expand Up @@ -54,13 +45,6 @@ public void contextInitialized(final ServletContextEvent event) {
LOG.error("Initialize Console JABContext Provider... ERROR! Error: {}", e.getMessage(), e);
throw new ExceptionInInitializerError(e);
}
<<<<<<< HEAD
new DatabaseCheckUpdate();
KapuaLocator.getInstance().getService(DataPopulatorRunner.class).runPopulators();
||||||| parent of d6ede90e91 (:fix: cleaner database initialization)
new DatabaseCheckUpdate();
=======
>>>>>>> d6ede90e91 (:fix: cleaner database initialization)
// Start Quartz scheduler
try {
LOG.info("Starting Quartz scheduler...");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
*******************************************************************************/
package org.eclipse.kapua.consumer.lifecycle;

import org.eclipse.kapua.commons.populators.DataPopulatorRunner;
import org.eclipse.kapua.locator.KapuaLocator;
import org.eclipse.kapua.service.camel.setting.ServiceSettingKey;
import org.eclipse.kapua.service.security.SecurityUtil;
import org.springframework.boot.SpringApplication;
Expand Down Expand Up @@ -44,7 +42,6 @@ public static void main(String[] args) {
System.setProperty(ServiceSettingKey.JAXB_CONTEXT_CLASS_NAME.key(), LifecycleJAXBContextProvider.class.getName());
//org.springframework.context.ApplicationContext is not needed now so don't keep the SpringApplication.run return
SpringApplication.run(LifecycleApplication.class, args);
KapuaLocator.getInstance().getService(DataPopulatorRunner.class).runPopulators();

}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
*******************************************************************************/
package org.eclipse.kapua.consumer.telemetry;

import org.eclipse.kapua.commons.populators.DataPopulatorRunner;
import org.eclipse.kapua.locator.KapuaLocator;
import org.eclipse.kapua.service.camel.setting.ServiceSettingKey;
import org.eclipse.kapua.service.security.SecurityUtil;
import org.springframework.boot.SpringApplication;
Expand Down Expand Up @@ -44,7 +42,6 @@ public static void main(String[] args) {
System.setProperty(ServiceSettingKey.JAXB_CONTEXT_CLASS_NAME.key(), TelemetryJAXBContextProvider.class.getName());
//org.springframework.context.ApplicationContext is not needed now so don't keep the SpringApplication.run return
SpringApplication.run(TelemetryApplication.class, args);
KapuaLocator.getInstance().getService(DataPopulatorRunner.class).runPopulators();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
*******************************************************************************/
package org.eclipse.kapua.job.engine.app.web;

import org.eclipse.kapua.commons.populators.DataPopulatorRunner;
import org.eclipse.kapua.commons.rest.errors.ExceptionConfigurationProvider;
import org.eclipse.kapua.commons.setting.system.SystemSetting;
import org.eclipse.kapua.commons.util.xml.XmlUtil;
Expand Down Expand Up @@ -68,8 +67,6 @@ public void onStartup(Container container) {
JobEngineJAXBContextProvider provider = serviceLocator.createAndInitialize(JobEngineJAXBContextProvider.class);
XmlUtil.setContextProvider(provider);
final KapuaLocator kapuaLocator = KapuaLocator.getInstance();
//TODO: Move to databaseUpdate
kapuaLocator.getService(DataPopulatorRunner.class).runPopulators();
if (kapuaLocator instanceof GuiceLocatorImpl) {
GuiceBridge.getGuiceBridge().initializeGuiceBridge(serviceLocator);
GuiceIntoHK2Bridge guiceBridge = serviceLocator.getService(GuiceIntoHK2Bridge.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public void startBaseDockerEnvironment() throws Exception {

@Given("Service events are setup")
public void startEventBus() throws Exception {
ServiceModuleBundle serviceModuleBundle = KapuaLocator.getInstance().getService(ServiceModuleBundle.class);
ServiceModuleBundle serviceModuleBundle = KapuaLocator.getInstance().getComponent(ServiceModuleBundle.class);
serviceModuleBundle.startup();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
import org.eclipse.kapua.app.api.core.KapuaSerializableBodyWriter;
import org.eclipse.kapua.app.api.core.ListBodyWriter;
import org.eclipse.kapua.app.api.core.MoxyJsonConfigContextResolver;
import org.eclipse.kapua.commons.populators.DataPopulatorRunner;
import org.eclipse.kapua.commons.rest.errors.ExceptionConfigurationProvider;
import org.eclipse.kapua.commons.util.xml.XmlUtil;
import org.eclipse.kapua.locator.KapuaLocator;
Expand Down Expand Up @@ -77,8 +76,6 @@ public void onStartup(Container container) {
RestApiJAXBContextProvider provider = serviceLocator.createAndInitialize(RestApiJAXBContextProvider.class);
XmlUtil.setContextProvider(provider);
final KapuaLocator kapuaLocator = KapuaLocator.getInstance();
//TODO: Move to databaseUpdate
kapuaLocator.getService(DataPopulatorRunner.class).runPopulators();
if (kapuaLocator instanceof GuiceLocatorImpl) {
GuiceBridge.getGuiceBridge().initializeGuiceBridge(serviceLocator);
GuiceIntoHK2Bridge guiceBridge = serviceLocator.getService(GuiceIntoHK2Bridge.class);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
import org.apache.shiro.env.BasicIniEnvironment;
import org.apache.shiro.env.Environment;
import org.apache.shiro.mgt.SecurityManager;
import org.eclipse.kapua.commons.populators.DataPopulatorRunner;
import org.eclipse.kapua.locator.KapuaLocator;
import org.eclipse.kapua.service.camel.setting.ServiceSettingKey;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand Down Expand Up @@ -58,7 +56,6 @@ public static void main(String[] args) {
System.setProperty(ServiceSettingKey.JAXB_CONTEXT_CLASS_NAME.key(), AuthenticationJAXBContextProvider.class.getName());
//org.springframework.context.ApplicationContext is not needed now so don't keep the SpringApplication.run return
SpringApplication.run(AuthenticationApplication.class, args);
KapuaLocator.getInstance().getService(DataPopulatorRunner.class).runPopulators();
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@

import javax.inject.Named;
import javax.inject.Singleton;
import java.lang.reflect.Constructor;

public class DatastoreModule extends AbstractKapuaModule {
@Override
Expand Down Expand Up @@ -153,4 +152,4 @@ public boolean isServiceEnabled(TxContext txContext, KapuaId scopeId) {
}
});
}
}
}

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,15 @@
*******************************************************************************/
package org.eclipse.kapua.service.device.connection.listener.internal;

import javax.inject.Named;

import com.google.inject.Module;
import com.google.inject.multibindings.ProvidesIntoSet;
import org.eclipse.kapua.commons.core.AbstractKapuaModule;
import org.eclipse.kapua.commons.core.ServiceModule;
import org.eclipse.kapua.commons.event.ServiceEventHouseKeeperFactoryImpl;
import org.eclipse.kapua.commons.service.event.store.api.EventStoreFactory;
import org.eclipse.kapua.commons.service.event.store.api.EventStoreRecordRepository;
import org.eclipse.kapua.commons.service.event.store.internal.EventStoreServiceImpl;
import org.eclipse.kapua.event.ServiceEventBus;
import org.eclipse.kapua.event.ServiceEventBusException;
import org.eclipse.kapua.service.authorization.AuthorizationService;
import org.eclipse.kapua.service.authorization.permission.PermissionFactory;
Expand All @@ -28,8 +29,7 @@
import org.eclipse.kapua.service.device.registry.KapuaDeviceRegistrySettings;
import org.eclipse.kapua.storage.TxManager;

import com.google.inject.Module;
import com.google.inject.multibindings.ProvidesIntoSet;
import javax.inject.Named;

/**
* {@code kapua-account-internal} {@link Module} implementation.
Expand All @@ -45,14 +45,16 @@ protected void configureModule() {

@ProvidesIntoSet
protected ServiceModule deviceConnectionEventListenerServiceModule(DeviceConnectionEventListenerService deviceConnectionEventListenerService,
AuthorizationService authorizationService,
PermissionFactory permissionFactory,
@Named("DeviceRegistryTransactionManager") TxManager txManager,
EventStoreFactory eventStoreFactory,
EventStoreRecordRepository eventStoreRecordRepository
AuthorizationService authorizationService,
PermissionFactory permissionFactory,
KapuaDeviceRegistrySettings kapuaDeviceRegistrySettings,
@Named("DeviceRegistryTransactionManager") TxManager txManager,
EventStoreFactory eventStoreFactory,
EventStoreRecordRepository eventStoreRecordRepository,
ServiceEventBus serviceEventBus
) throws ServiceEventBusException {

String address = KapuaDeviceRegistrySettings.getInstance().getString(KapuaDeviceRegistrySettingKeys.DEVICE_EVENT_ADDRESS);
String address = kapuaDeviceRegistrySettings.getString(KapuaDeviceRegistrySettingKeys.DEVICE_EVENT_ADDRESS);
return new DeviceConnectionEventListenerServiceModule(
deviceConnectionEventListenerService,
address,
Expand All @@ -64,7 +66,9 @@ protected ServiceModule deviceConnectionEventListenerServiceModule(DeviceConnect
eventStoreFactory,
eventStoreRecordRepository
),
txManager
));
txManager,
serviceEventBus
),
serviceEventBus);
}
}
Loading

0 comments on commit 8c49b80

Please sign in to comment.