com.github.dynamicextensionsalfresco.osgi.spring.AbstractConfigurationFileFactoryBean Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of alfresco-integration Show documentation
Show all versions of alfresco-integration Show documentation
Adds an OSGi container to alfresco repository supporting dynamic code reloading, classpath isolation and a bunch of other useful features
package com.github.dynamicextensionsalfresco.osgi.spring;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import org.springframework.beans.factory.FactoryBean;
import org.springframework.context.ResourceLoaderAware;
import org.springframework.core.io.Resource;
import org.springframework.core.io.ResourceLoader;
import org.springframework.core.io.support.ResourcePatternResolver;
import org.springframework.util.Assert;
/**
* Abstract base class for {@link FactoryBean}s that use configuration files.
*
* @author Laurens Fridael
*
* @param
*/
public abstract class AbstractConfigurationFileFactoryBean implements FactoryBean, ResourceLoaderAware {
/* Dependencies */
private ResourcePatternResolver resourcePatternResolver;
/* Configuration */
private List configurations = Collections.emptyList();
private List configurationLocations = Collections.emptyList();
/* Dependencies */
@Override
public void setResourceLoader(final ResourceLoader resourceLoader) {
Assert.isInstanceOf(ResourcePatternResolver.class, resourceLoader);
this.resourcePatternResolver = (ResourcePatternResolver) resourceLoader;
}
protected ResourcePatternResolver getResourcePatternResolver() {
return resourcePatternResolver;
}
/* Utility operations */
protected List resolveConfigurations() throws IOException {
final List configurations = new ArrayList(this.configurations);
for (final String location : getConfigurationLocations()) {
configurations.addAll(Arrays.asList(getResourcePatternResolver().getResources(location)));
}
return configurations;
}
/* Configuration */
public void setConfigurations(final List configurations) {
Assert.notNull(configurations);
this.configurations = configurations;
}
protected List getConfigurations() {
return configurations;
}
public void setConfigurationLocations(final List configurationLocations) {
this.configurationLocations = configurationLocations;
}
protected List getConfigurationLocations() {
return configurationLocations;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy