String templateId = getParameterAsString(TEMPLATE);
SourceResolver resolver = null;
Source contextSource = null;
ServiceSelector selector = null;
Instantiator instantiator = null;
try {
resolver = (SourceResolver) this.manager.lookup(SourceResolver.ROLE);
Source context = resolver.resolveURI("context://");
String contextPath = SourceUtil.getFile(context).getAbsolutePath();
PublicationFactory factory = PublicationFactory.getInstance(getLogger());
Publication template = factory.getPublication(templateId, contextPath);
String name = getParameterAsString(PUBLICATION_NAME);
selector = (ServiceSelector) this.manager.lookup(Instantiator.ROLE + "Selector");
instantiator = (Instantiator) selector.select(template.getInstantiatorHint());
instantiator.instantiate(template, getParameterAsString(PUBLICATION_ID), name);
} finally {
if (selector != null) {
if (instantiator != null) {
selector.release(instantiator);