All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.dynamicextensionsalfresco.osgi.ServiceDefinitionEditor Maven / Gradle / Ivy

Go to download

Adds an OSGi container to alfresco repository supporting dynamic code reloading, classpath isolation and a bunch of other useful features

There is a newer version: 3.1.0
Show newest version
package com.github.dynamicextensionsalfresco.osgi;

import java.beans.PropertyEditor;
import java.beans.PropertyEditorSupport;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.springframework.context.ApplicationContext;
import org.springframework.util.Assert;

/**
 * {@link PropertyEditor} for configuring {@link ServiceDefinition}s in Spring {@link ApplicationContext}s.
 * 
 * @author Laurens Fridael
 * 
 */
public class ServiceDefinitionEditor extends PropertyEditorSupport {

	private static final Pattern BEAN_NAME_AND_SERVICE_NAMES_PATTERN = Pattern
			.compile("(.*?):(.*?)(:(.*?))?(:(\\d+\\.\\d+))?");

	@Override
	public void setAsText(String text) throws IllegalArgumentException {
		Assert.hasText(text, "Text cannot be empty");
		text = text.trim();
		final Matcher matcher = BEAN_NAME_AND_SERVICE_NAMES_PATTERN.matcher(text);
		if (matcher.matches()) {
			final String[] beanNames = matcher.group(1).split(",");
			final String[] serviceNames = matcher.group(2).split(",");
			final String serviceType = matcher.group(4);
			final String platformVersion = matcher.group(6);
			setValue(new ServiceDefinition(beanNames, serviceNames, serviceType, platformVersion));
		}
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy