use of com.dexels.navajo.document.nanoimpl.XMLElement in project navajo by Dexels.
the class TslMetaDataHandler method getScriptMetadata.
public XMLElement getScriptMetadata(String scriptName) {
XMLElement x = new CaseSensitiveXMLElement();
x.setName("metadata");
addScriptElement(x, scriptName);
return x;
}
use of com.dexels.navajo.document.nanoimpl.XMLElement in project navajo by Dexels.
the class OsgiFunctionFactory method getAllFunctionElements.
@SuppressWarnings("rawtypes")
@Override
public List<XMLElement> getAllFunctionElements(String interfaceClass, String propertyKey) {
List<XMLElement> result = new ArrayList<>();
BundleContext context = Version.getDefaultBundleContext();
try {
ServiceReference[] refs = context.getServiceReferences(interfaceClass, null);
if (refs == null) {
logger.warn("Service enumeration failed class: {}", interfaceClass);
return null;
}
for (ServiceReference serviceReference : refs) {
Object o = serviceReference.getProperty(propertyKey);
FunctionDefinition fd = (FunctionDefinition) o;
XMLElement xe = fd.getXmlElement();
if (xe != null) {
result.add(xe);
}
}
} catch (InvalidSyntaxException e) {
logger.error("Error: ", e);
}
return result;
}
use of com.dexels.navajo.document.nanoimpl.XMLElement in project navajo by Dexels.
the class OsgiFunctionFactory method getAllAdapterElements.
@SuppressWarnings("rawtypes")
@Override
public // TODO not ok, seems to return function elements
List<XMLElement> getAllAdapterElements(String interfaceClass, String propertyKey) {
List<XMLElement> result = new ArrayList<>();
BundleContext context = Version.getDefaultBundleContext();
try {
ServiceReference[] refs = context.getServiceReferences(interfaceClass, null);
if (refs == null) {
logger.warn("Service enumeration failed class: {}", interfaceClass);
return null;
}
for (ServiceReference serviceReference : refs) {
Object o = serviceReference.getProperty(propertyKey);
FunctionDefinition fd = (FunctionDefinition) o;
XMLElement xe = fd.getXmlElement();
if (xe != null) {
result.add(xe);
}
}
} catch (InvalidSyntaxException e) {
logger.error("Error: ", e);
}
return result;
}
use of com.dexels.navajo.document.nanoimpl.XMLElement in project navajo by Dexels.
the class TagMap method setInsert.
public void setInsert(Binary b) throws UserException {
insert = b;
String insertChild = new String(b.getData());
XMLElement xe = new CaseSensitiveXMLElement(true);
try {
xe.parseFromReader(new StringReader(insertChild));
} catch (IOException ex) {
logger.error("XML parse problem: ", ex);
}
// get child based on childName set
TagMap child = getChild();
child.setChild(TagMap.parseXMLElement(xe, this.compact));
}
use of com.dexels.navajo.document.nanoimpl.XMLElement in project navajo by Dexels.
the class ScriptCompiler method generateDs.
private String generateDs(String packagePath, String script, List<Dependency> dependencies, Set<String> dependentResources) throws IOException {
String fullName;
String compiledDate = "" + Long.valueOf(new Date().getTime());
if (packagePath.equals("")) {
fullName = script;
} else {
fullName = packagePath + "/" + script;
}
String javaPackagePath;
if ("".equals(packagePath)) {
javaPackagePath = "defaultPackage";
} else {
javaPackagePath = packagePath.replaceAll("/", ".");
}
String tenant = tenantFromScriptPath(fullName);
if (tenant == null) {
tenant = getTentantSpecificDependency(dependencies);
}
String symbolicName = rpcNameFromScriptPath(fullName).replaceAll("/", ".");
boolean hasTenantSpecificFile = tenant != null;
XMLElement xe = new CaseSensitiveXMLElement("scr:component");
xe.setAttribute("xmlns:scr", "http://www.osgi.org/xmlns/scr/v1.1.0");
xe.setAttribute("immediate", "true");
if (tenant != null) {
xe.setAttribute("name", symbolicName + "_" + tenant);
} else {
xe.setAttribute("name", symbolicName);
}
xe.setAttribute("activate", "activate");
xe.setAttribute("deactivate", "deactivate");
xe.setAttribute("configuration-policy", "optional");
XMLElement implementation = new CaseSensitiveXMLElement("implementation");
xe.addChild(implementation);
implementation.setAttribute("class", javaPackagePath + "." + script + "Factory");
XMLElement service = new CaseSensitiveXMLElement("service");
xe.addChild(service);
XMLElement provide = new CaseSensitiveXMLElement("provide");
service.addChild(provide);
provide.setAttribute("interface", CompiledScriptFactory.class.getName());
addProperty("navajo.scriptName", "String", symbolicName, xe);
addProperty("navajo.compileddate", "String", compiledDate, xe);
if (hasTenantSpecificFile) {
addProperty("navajo.tenant", "String", tenant, xe);
addProperty("service.ranking", "Integer", "1000", xe);
} else {
addProperty("service.ranking", "Integer", "0", xe);
addProperty("navajo.tenant", "String", "default", xe);
}
for (String resource : dependentResources) {
XMLElement dep = new CaseSensitiveXMLElement("reference");
dep.setAttribute("bind", "set" + resource);
dep.setAttribute("unbind", "clear" + resource);
dep.setAttribute("policy", "static");
dep.setAttribute("cardinality", "1..1");
dep.setAttribute("interface", "javax.sql.DataSource");
dep.setAttribute("target", "(navajo.resource.name=" + resource + ")");
xe.addChild(dep);
}
PrintWriter w = new PrintWriter(navajoIOConfig.getOutputWriter(navajoIOConfig.getCompiledScriptPath(), packagePath, script, ".xml"));
w.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
xe.write(w);
w.flush();
w.close();
return compiledDate;
}
Aggregations