com.github.dynamicextensionsalfresco.controlpanel.template.TemplateServiceReferenceProperties Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of control-panel Show documentation
Show all versions of control-panel 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.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