-
Notifications
You must be signed in to change notification settings - Fork 161
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🚚 moving ServiceConfigurationManager into isolable modules in order t…
…o allow them to be ignored (overriding not supported) Signed-off-by: dseurotech <[email protected]>
- Loading branch information
1 parent
de386ff
commit 72c8f63
Showing
16 changed files
with
672 additions
and
321 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
.../org/eclipse/kapua/service/account/internal/AccountServiceConfigurationManagerModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2021, 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.service.account.internal; | ||
|
||
import javax.inject.Singleton; | ||
|
||
import org.eclipse.kapua.commons.configuration.AccountRelativeFinder; | ||
import org.eclipse.kapua.commons.configuration.CachingServiceConfigRepository; | ||
import org.eclipse.kapua.commons.configuration.ResourceLimitedServiceConfigurationManagerImpl; | ||
import org.eclipse.kapua.commons.configuration.RootUserTester; | ||
import org.eclipse.kapua.commons.configuration.ServiceConfigImplJpaRepository; | ||
import org.eclipse.kapua.commons.configuration.ServiceConfigurationManager; | ||
import org.eclipse.kapua.commons.configuration.ServiceConfigurationManagerCachingWrapper; | ||
import org.eclipse.kapua.commons.configuration.UsedEntitiesCounterImpl; | ||
import org.eclipse.kapua.commons.core.AbstractKapuaModule; | ||
import org.eclipse.kapua.commons.jpa.EntityCacheFactory; | ||
import org.eclipse.kapua.commons.jpa.KapuaJpaRepositoryConfiguration; | ||
import org.eclipse.kapua.commons.util.xml.XmlUtil; | ||
import org.eclipse.kapua.service.account.AccountFactory; | ||
import org.eclipse.kapua.service.account.AccountRepository; | ||
import org.eclipse.kapua.service.account.AccountService; | ||
|
||
import com.google.inject.Module; | ||
import com.google.inject.multibindings.ClassMapKey; | ||
import com.google.inject.multibindings.ProvidesIntoMap; | ||
|
||
/** | ||
* This module provides the ServiceConfigurationManager for the AccountService. | ||
* <br><br> | ||
* Unfortunately Guice does not support overriding for Map binder entries, therefore if you need to change the behaviour of this ServiceConfigurationManager, just skip this module and define the new | ||
* instance in a separate one | ||
*/ | ||
public class AccountServiceConfigurationManagerModule extends AbstractKapuaModule implements Module { | ||
|
||
@Override | ||
protected void configureModule() { | ||
} | ||
|
||
@ProvidesIntoMap | ||
@ClassMapKey(AccountService.class) | ||
@Singleton | ||
ServiceConfigurationManager accountServiceConfigurationManager( | ||
AccountFactory factory, | ||
RootUserTester rootUserTester, | ||
AccountRelativeFinder accountRelativeFinder, | ||
AccountRepository accountRepository, | ||
KapuaJpaRepositoryConfiguration jpaRepoConfig, | ||
EntityCacheFactory entityCacheFactory, | ||
XmlUtil xmlUtil | ||
) { | ||
return new ServiceConfigurationManagerCachingWrapper( | ||
new ResourceLimitedServiceConfigurationManagerImpl( | ||
AccountService.class.getName(), | ||
new CachingServiceConfigRepository( | ||
new ServiceConfigImplJpaRepository(jpaRepoConfig), | ||
entityCacheFactory.createCache("AbstractKapuaConfigurableServiceCacheId") | ||
), | ||
rootUserTester, | ||
accountRelativeFinder, | ||
new UsedEntitiesCounterImpl( | ||
factory, | ||
accountRepository), | ||
xmlUtil | ||
)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
75 changes: 75 additions & 0 deletions
75
...lipse/kapua/service/datastore/internal/MessageStoreServiceConfigurationManagerModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2021, 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.service.datastore.internal; | ||
|
||
import javax.inject.Singleton; | ||
|
||
import org.eclipse.kapua.commons.configuration.CachingServiceConfigRepository; | ||
import org.eclipse.kapua.commons.configuration.RootUserTester; | ||
import org.eclipse.kapua.commons.configuration.ServiceConfigImplJpaRepository; | ||
import org.eclipse.kapua.commons.configuration.ServiceConfigurationManager; | ||
import org.eclipse.kapua.commons.configuration.ServiceConfigurationManagerCachingWrapper; | ||
import org.eclipse.kapua.commons.configuration.ServiceConfigurationManagerImpl; | ||
import org.eclipse.kapua.commons.core.AbstractKapuaModule; | ||
import org.eclipse.kapua.commons.jpa.EntityCacheFactory; | ||
import org.eclipse.kapua.commons.jpa.KapuaJpaRepositoryConfiguration; | ||
import org.eclipse.kapua.commons.util.xml.XmlUtil; | ||
import org.eclipse.kapua.model.id.KapuaId; | ||
import org.eclipse.kapua.service.datastore.MessageStoreService; | ||
import org.eclipse.kapua.service.datastore.internal.setting.DatastoreSettings; | ||
import org.eclipse.kapua.service.datastore.internal.setting.DatastoreSettingsKey; | ||
import org.eclipse.kapua.storage.TxContext; | ||
|
||
import com.google.inject.Module; | ||
import com.google.inject.multibindings.ClassMapKey; | ||
import com.google.inject.multibindings.ProvidesIntoMap; | ||
|
||
/** | ||
* This module provides the ServiceConfigurationManager for the MessageStoreService. | ||
* <br><br> | ||
* Unfortunately Guice does not support overriding for Map binder entries, therefore if you need to change the behaviour of this ServiceConfigurationManager, just skip this module and define the new | ||
* instance in a separate one | ||
*/ | ||
public class MessageStoreServiceConfigurationManagerModule extends AbstractKapuaModule implements Module { | ||
|
||
@Override | ||
protected void configureModule() { | ||
} | ||
|
||
@ProvidesIntoMap | ||
@ClassMapKey(MessageStoreService.class) | ||
@Singleton | ||
ServiceConfigurationManager messageStoreServiceConfigurationManager( | ||
RootUserTester rootUserTester, | ||
KapuaJpaRepositoryConfiguration jpaRepoConfig, | ||
DatastoreSettings datastoreSettings, | ||
EntityCacheFactory entityCacheFactory, | ||
XmlUtil xmlUtil | ||
) { | ||
return new ServiceConfigurationManagerCachingWrapper(new ServiceConfigurationManagerImpl( | ||
MessageStoreService.class.getName(), | ||
new CachingServiceConfigRepository( | ||
new ServiceConfigImplJpaRepository(jpaRepoConfig), | ||
entityCacheFactory.createCache("AbstractKapuaConfigurableServiceCacheId") | ||
), | ||
rootUserTester, | ||
xmlUtil | ||
) { | ||
|
||
@Override | ||
public boolean isServiceEnabled(TxContext txContext, KapuaId scopeId) { | ||
return !datastoreSettings.getBoolean(DatastoreSettingsKey.DISABLE_DATASTORE, false); | ||
} | ||
}); | ||
} | ||
} |
70 changes: 70 additions & 0 deletions
70
...ipse/kapua/service/device/registry/DeviceConnectionServiceConfigurationManagerModule.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2021, 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.service.device.registry; | ||
|
||
import java.util.Map; | ||
|
||
import javax.inject.Singleton; | ||
|
||
import org.eclipse.kapua.commons.configuration.CachingServiceConfigRepository; | ||
import org.eclipse.kapua.commons.configuration.RootUserTester; | ||
import org.eclipse.kapua.commons.configuration.ServiceConfigImplJpaRepository; | ||
import org.eclipse.kapua.commons.configuration.ServiceConfigurationManager; | ||
import org.eclipse.kapua.commons.configuration.ServiceConfigurationManagerCachingWrapper; | ||
import org.eclipse.kapua.commons.core.AbstractKapuaModule; | ||
import org.eclipse.kapua.commons.jpa.EntityCacheFactory; | ||
import org.eclipse.kapua.commons.jpa.KapuaJpaRepositoryConfiguration; | ||
import org.eclipse.kapua.commons.util.xml.XmlUtil; | ||
import org.eclipse.kapua.service.device.authentication.api.DeviceConnectionCredentialAdapter; | ||
import org.eclipse.kapua.service.device.registry.connection.DeviceConnectionService; | ||
import org.eclipse.kapua.service.device.registry.connection.internal.DeviceConnectionServiceConfigurationManager; | ||
|
||
import com.google.inject.Module; | ||
import com.google.inject.multibindings.ClassMapKey; | ||
import com.google.inject.multibindings.ProvidesIntoMap; | ||
|
||
/** | ||
* This module provides the ServiceConfigurationManager for the DeviceRegistryService. | ||
* <br><br> | ||
* Unfortunately Guice does not support overriding for Map binder entries, therefore if you need to change the behaviour of this ServiceConfigurationManager, just skip this module and define the new | ||
* instance in a separate one | ||
*/ | ||
public class DeviceConnectionServiceConfigurationManagerModule extends AbstractKapuaModule implements Module { | ||
|
||
@Override | ||
protected void configureModule() { | ||
} | ||
|
||
@ProvidesIntoMap | ||
@ClassMapKey(DeviceConnectionService.class) | ||
@Singleton | ||
ServiceConfigurationManager deviceConnectionServiceConfigurationManager( | ||
RootUserTester rootUserTester, | ||
KapuaJpaRepositoryConfiguration jpaRepoConfig, | ||
Map<String, DeviceConnectionCredentialAdapter> availableDeviceConnectionAdapters, | ||
EntityCacheFactory entityCacheFactory, | ||
KapuaDeviceRegistrySettings kapuaDeviceRegistrySettings, | ||
XmlUtil xmlUtil) { | ||
return new ServiceConfigurationManagerCachingWrapper( | ||
new DeviceConnectionServiceConfigurationManager( | ||
new CachingServiceConfigRepository( | ||
new ServiceConfigImplJpaRepository(jpaRepoConfig), | ||
entityCacheFactory.createCache("AbstractKapuaConfigurableServiceCacheId") | ||
), | ||
rootUserTester, | ||
availableDeviceConnectionAdapters, | ||
kapuaDeviceRegistrySettings, | ||
xmlUtil) | ||
); | ||
} | ||
} |
Oops, something went wrong.