-
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.
Merge pull request #4079 from dseurotech/ref-simplify_service_configu…
…ration ♻️ [Service Configuration] Service Configurations refactoring
- Loading branch information
Showing
129 changed files
with
3,494 additions
and
5,035 deletions.
There are no files selected for viewing
23 changes: 0 additions & 23 deletions
23
...ons/src/main/java/org/eclipse/kapua/commons/configuration/CommonsConfigurationModule.java
This file was deleted.
Oops, something went wrong.
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
47 changes: 47 additions & 0 deletions
47
...clipse/kapua/commons/configuration/ResourceBasedServiceConfigurationMetadataProvider.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,47 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2016, 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.commons.configuration; | ||
|
||
import java.net.URL; | ||
import java.nio.charset.StandardCharsets; | ||
import java.util.Optional; | ||
|
||
import org.eclipse.kapua.commons.util.ResourceUtils; | ||
import org.eclipse.kapua.commons.util.xml.XmlUtil; | ||
import org.eclipse.kapua.model.config.metatype.KapuaTmetadata; | ||
import org.eclipse.kapua.storage.TxContext; | ||
|
||
public class ResourceBasedServiceConfigurationMetadataProvider implements ServiceConfigurationMetadataProvider { | ||
|
||
private final XmlUtil xmlUtil; | ||
|
||
public ResourceBasedServiceConfigurationMetadataProvider(XmlUtil xmlUtil) { | ||
this.xmlUtil = xmlUtil; | ||
} | ||
|
||
@Override | ||
public Optional<KapuaTmetadata> fetchMetadata(TxContext txContext, String pid) { | ||
URL url = ResourceUtils.getResource(String.format("META-INF/metatypes/%s.xml", pid)); | ||
|
||
if (url == null) { | ||
return Optional.empty(); | ||
} | ||
|
||
try { | ||
return Optional.ofNullable(xmlUtil.unmarshal(ResourceUtils.openAsReader(url, StandardCharsets.UTF_8), KapuaTmetadata.class)) | ||
.filter(v -> v.getOCD() != null && !v.getOCD().isEmpty()); | ||
} catch (Exception e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
} |
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
87 changes: 0 additions & 87 deletions
87
.../main/java/org/eclipse/kapua/commons/configuration/ServiceComponentConfigurationImpl.java
This file was deleted.
Oops, something went wrong.
39 changes: 0 additions & 39 deletions
39
...rc/main/java/org/eclipse/kapua/commons/configuration/ServiceConfigurationFactoryImpl.java
This file was deleted.
Oops, something went wrong.
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
Oops, something went wrong.