mirror of
https://github.com/DSpace/DSpace.git
synced 2025-10-16 22:43:12 +00:00
Create a temporary version of the ConfigurationPlaceholderConfigurer to overcome bu in 2.10
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
package org.dspace.util;
|
||||
|
||||
import org.apache.commons.configuration2.Configuration;
|
||||
import org.apache.commons.configuration2.spring.ConfigurationPropertySource;
|
||||
import org.dspace.servicemanager.config.DSpaceConfigurationPropertySource;
|
||||
import org.dspace.services.ConfigurationService;
|
||||
import org.dspace.services.factory.DSpaceServicesFactory;
|
||||
import org.springframework.context.ApplicationContextInitializer;
|
||||
@@ -38,8 +38,8 @@ public class DSpaceConfigurationInitializer
|
||||
Configuration configuration = configurationService.getConfiguration();
|
||||
|
||||
// Create an Apache Commons Configuration Property Source from our configuration
|
||||
ConfigurationPropertySource apacheCommonsConfigPropertySource =
|
||||
new ConfigurationPropertySource(configuration.getClass().getName(), configuration);
|
||||
DSpaceConfigurationPropertySource apacheCommonsConfigPropertySource =
|
||||
new DSpaceConfigurationPropertySource(configuration.getClass().getName(), configuration);
|
||||
|
||||
// Prepend it to the Environment's list of PropertySources
|
||||
// NOTE: This is added *first* in the list so that settings in DSpace's
|
||||
|
@@ -8,7 +8,6 @@
|
||||
package org.dspace.servicemanager.config;
|
||||
|
||||
import org.apache.commons.configuration2.Configuration;
|
||||
import org.apache.commons.configuration2.spring.ConfigurationPropertySource;
|
||||
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer;
|
||||
import org.springframework.core.env.MutablePropertySources;
|
||||
|
||||
@@ -27,8 +26,8 @@ import org.springframework.core.env.MutablePropertySources;
|
||||
public class DSpaceConfigurationPlaceholderConfigurer extends PropertySourcesPlaceholderConfigurer {
|
||||
|
||||
public DSpaceConfigurationPlaceholderConfigurer(Configuration configuration) {
|
||||
ConfigurationPropertySource apacheCommonsConfigPropertySource =
|
||||
new ConfigurationPropertySource(configuration.getClass().getName(), configuration);
|
||||
DSpaceConfigurationPropertySource apacheCommonsConfigPropertySource =
|
||||
new DSpaceConfigurationPropertySource(configuration.getClass().getName(), configuration);
|
||||
MutablePropertySources propertySources = new MutablePropertySources();
|
||||
propertySources.addLast(apacheCommonsConfigPropertySource);
|
||||
setPropertySources(propertySources);
|
||||
|
@@ -0,0 +1,54 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||
* (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.dspace.servicemanager.config;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.commons.configuration2.Configuration;
|
||||
import org.apache.commons.lang3.ArrayUtils;
|
||||
import org.springframework.core.env.EnumerablePropertySource;
|
||||
|
||||
/**
|
||||
* Allow use of Apache Commons Configuration Objects as Spring PropertySources.
|
||||
* This class is a copy of the ConfigurationPropertySource class in the Apache Commons Configuration
|
||||
* project needed until to fix the issue https://issues.apache.org/jira/browse/CONFIGURATION-846
|
||||
*/
|
||||
public class DSpaceConfigurationPropertySource extends EnumerablePropertySource<Configuration> {
|
||||
|
||||
protected DSpaceConfigurationPropertySource(final String name) {
|
||||
super(name);
|
||||
}
|
||||
|
||||
public DSpaceConfigurationPropertySource(final String name, final Configuration source) {
|
||||
super(name, source);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getProperty(final String name) {
|
||||
final String[] propValue = source.getStringArray(name);
|
||||
return propValue != null && propValue.length == 1 ? propValue[0] : propValue;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getPropertyNames() {
|
||||
final List<String> keys = new ArrayList<>();
|
||||
source.getKeys().forEachRemaining(keys::add);
|
||||
return keys.toArray(ArrayUtils.EMPTY_STRING_ARRAY);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user