use of com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement in project navajo by Dexels.
the class ScriptCompiler method generateEntityDs.
private void generateEntityDs(String packagePath, String script, String compiledDate, List<Dependency> dependencies, Set<String> dependentResources) throws IOException {
String fullName;
if (packagePath.equals("")) {
fullName = script;
} else {
fullName = packagePath + "/" + script;
}
String entityName = fullName.substring(fullName.indexOf('/') + 1).replaceAll("/", ".");
String symbolicName = rpcNameFromScriptPath(fullName).replaceAll("/", ".");
XMLElement xe = new CaseSensitiveXMLElement("scr:component");
xe.setAttribute("xmlns:scr", "http://www.osgi.org/xmlns/scr/v1.1.0");
xe.setAttribute("immediate", "true");
xe.setAttribute("name", "navajo.entities." + symbolicName);
xe.setAttribute("activate", "activate");
xe.setAttribute("deactivate", "deactivate");
xe.setAttribute("enabled", "true");
XMLElement implementation = new CaseSensitiveXMLElement("implementation");
xe.addChild(implementation);
implementation.setAttribute("class", "com.dexels.navajo.enterprise.entity.Entity");
XMLElement service = new CaseSensitiveXMLElement("service");
xe.addChild(service);
XMLElement provide = new CaseSensitiveXMLElement("provide");
service.addChild(provide);
provide.setAttribute("interface", "com.dexels.navajo.enterprise.entity.Entity");
addProperty("entity.name", "String", entityName, xe);
addProperty("service.name", "String", fullName, xe);
addProperty("entity.message", "String", script, xe);
XMLElement refMan = new CaseSensitiveXMLElement("reference");
refMan.setAttribute("bind", "setEntityManager");
refMan.setAttribute("unbind", "clearEntityManager");
refMan.setAttribute("policy", "dynamic");
refMan.setAttribute("cardinality", "1..1");
refMan.setAttribute("interface", "com.dexels.navajo.enterprise.entity.EntityManager");
refMan.setAttribute("name", "EntityManager");
xe.addChild(refMan);
XMLElement refScript = new CaseSensitiveXMLElement("reference");
refScript.setAttribute("cardinality", "1..1");
refScript.setAttribute("bind", "setCompiledScript");
refScript.setAttribute("unbind", "clearCompiledScript");
refScript.setAttribute("interface", "com.dexels.navajo.script.api.CompiledScriptFactory");
refScript.setAttribute("name", "CompiledScript");
String target1 = "component.name=" + symbolicName.replace("/", ".");
String target2 = "navajo.compileddate=" + compiledDate;
refScript.setAttribute("target", "(&(" + target1 + ")(" + target2 + "))");
xe.addChild(refScript);
for (int i = 0; i < dependencies.size(); i++) {
Dependency d = dependencies.get(i);
if (d instanceof ExtendDependency) {
String extendedEntity = d.getId().replaceAll("/", ".");
XMLElement depref = new CaseSensitiveXMLElement("reference");
depref.setAttribute("name", "SuperEntity" + i);
depref.setAttribute("policy", "static");
depref.setAttribute("cardinality", "1..1");
depref.setAttribute("interface", "com.dexels.navajo.enterprise.entity.Entity");
depref.setAttribute("target", "(entity.name=" + extendedEntity + ")");
depref.setAttribute("bind", "addSuperEntity");
depref.setAttribute("unbind", "removeSuperEntity");
xe.addChild(depref);
}
}
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, "entity", ".xml"));
w.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
xe.write(w);
w.flush();
w.close();
}
use of com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement in project navajo by Dexels.
the class JarFunctionFactory method readDefinitionFile.
@Override
public final void readDefinitionFile(Map<String, FunctionDefinition> fuds, ExtensionDefinition fd) {
// Read config file.
CaseSensitiveXMLElement xml = new CaseSensitiveXMLElement();
try {
InputStream fis = fd.getDefinitionAsStream();
xml.parseFromStream(fis);
fis.close();
Vector<XMLElement> children = xml.getChildren();
for (int i = 0; i < children.size(); i++) {
// Get object, usage and description.
XMLElement element = children.get(i);
if (element.getName().equals("function")) {
parseFunction(fuds, element);
}
if (element.getName().equals("map")) {
parseAdapters(fuds, fd, element);
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}
use of com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement in project navajo by Dexels.
the class TslMetaDataHandler method addScriptElement.
/**
* @param x
* @param element
*/
private void addScriptElement(XMLElement x, String element) {
XMLElement xn = new CaseSensitiveXMLElement();
xn.setName("script");
x.addChild(xn);
xn.setAttribute("name", element);
addAdapters(xn, element);
addCalls(xn, element);
addCalledBy(xn, element);
addIncludes(xn, element);
addIncomingIncludes(xn, element);
}
use of com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement in project navajo by Dexels.
the class TslMetaDataHandler method addCalls.
private void addCalls(XMLElement xn, String element) {
TreeSet<String> s = callsScriptMap.get(element);
if (s == null) {
return;
}
for (Iterator<String> iter = s.iterator(); iter.hasNext(); ) {
String include = iter.next();
XMLElement xnincl = new CaseSensitiveXMLElement();
xnincl.setName("calls");
xnincl.setAttribute("name", include);
xn.addChild(xnincl);
}
}
use of com.dexels.navajo.document.nanoimpl.CaseSensitiveXMLElement in project navajo by Dexels.
the class TslMetaDataHandler method addIncomingIncludes.
/**
* @param xn
* @param element
*/
private void addIncomingIncludes(XMLElement xn, String element) {
TreeSet<String> s = includedByScriptMap.get(element);
if (s == null) {
return;
}
for (Iterator<String> iter = s.iterator(); iter.hasNext(); ) {
String include = iter.next();
XMLElement xnincl = new CaseSensitiveXMLElement();
xnincl.setName("includedby");
xnincl.setAttribute("name", include);
xn.addChild(xnincl);
}
}
Aggregations