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

com.github.dynamicextensionsalfresco.controlpanel.template.TemplateServiceReferenceProperties 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.controlpanel.template;

import org.osgi.framework.ServiceReference;
import org.springframework.util.Assert;

import freemarker.template.SimpleScalar;
import freemarker.template.TemplateHashModel;
import freemarker.template.TemplateModel;
import freemarker.template.TemplateModelException;

class TemplateServiceReferenceProperties implements TemplateHashModel {

	@SuppressWarnings("rawtypes")
	private final ServiceReference serviceReference;

	@SuppressWarnings("rawtypes")
	TemplateServiceReferenceProperties(final ServiceReference serviceReference) {
		Assert.notNull(serviceReference);
		this.serviceReference = serviceReference;
	}

	@Override
	public boolean isEmpty() throws TemplateModelException {
		return (serviceReference.getPropertyKeys().length == 0);
	}

	@Override
	public TemplateModel get(final String key) {
		final Object property = serviceReference.getProperty(key);
		if (property != null) {
			return new SimpleScalar(property.toString());
		} else {
			return null;
		}
	}

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy