OSGi-configuratie maken
Laatst bijgewerkt: 24 maart 2025
- Van toepassing op:
- Experience Manager 6.5
- Onderwerpen:
- Adaptieve formulieren
Gemaakt voor:
- Beginner
- Ontwikkelaar
Er is een aangepaste OSGi-configuratie met de naam Azure Portal Configuration gemaakt om de Azure Storage URI en de SAS Token URI op te geven. Deze twee waarden worden gebruikt om de REST API samen te stellen voor communicatie met de Azure Storage
De volledige code voor de configuratieservice wordt hieronder weergegeven
AzurePortalConfiguration
package com.azure.portal.configuration;
import org.osgi.service.metatype.annotations.AttributeDefinition;
import org.osgi.service.metatype.annotations.ObjectClassDefinition;
@ObjectClassDefinition(name = "Azure Portal Configuration", description = "Settings for connecting to Azure Portal")
public @interface AzurePortalConfiguration {
@AttributeDefinition(name = "SAS Token", description = "Enter the SAS Token")
String getSASToken() default "";
@AttributeDefinition(name = "Enter the Storage URI", description = "Enter the Storage URI")
String getStorageURI() default"";
}
AzurePortalConfigurationService
package com.azure.portal.configuration.service;
public interface AzurePortalConfigurationService {
String getStorageURI();
String getSASToken();
}
AzurePortalStorageConfigImpl
package com.azure.portal.configuration.service.impl;
import org.osgi.framework.Constants;
import org.osgi.service.component.annotations.Activate;
import org.osgi.service.component.annotations.Component;
import org.osgi.service.metatype.annotations.Designate;
import com.azure.portal.configuration.service.AzurePortalConfigurationService;
import com.azure.portal.configuration.AzurePortalConfiguration;
@Component(
service = AzurePortalConfigurationService.class,
immediate = true,
property = {
Constants.SERVICE_ID+ "=Azure Portal Config Service",
Constants.SERVICE_DESCRIPTION +"=This service reads values from Azure portal config"
}
)
@Designate(ocd=AzurePortalConfiguration.class)
public class AzurePortalStorageConfigImpl implements AzurePortalConfigurationService {
private AzurePortalConfiguration azurePortalConfiguration;
@Activate
protected void activate(AzurePortalConfiguration configuration) {
System.out.println("##### in activate #####");
this.azurePortalConfiguration = configuration;
}
@Override
public String getStorageURI() {
// TODO Auto-generated method stub
return azurePortalConfiguration.getStorageURI();
}
@Override
public String getSASToken() {
// TODO Auto-generated method stub
return azurePortalConfiguration.getSASToken();
}
}
Volgende stappen
recommendation-more-help
8de24117-1378-413c-a581-01e660b7163e