use of com.ibm.xsp.library.XspLibrary in project org.openntf.nsfodp by OpenNTF.
the class AbstractCompilationEnvironment method initRegistry.
/**
* Initializes the internal Faces registry with the newly-added plugins.
*/
protected void initRegistry() {
subTask(Messages.ODPCompiler_initializingLibraries);
SharableRegistryImpl facesRegistry = (SharableRegistryImpl) facesProject.getRegistry();
// $NON-NLS-1$
List<Object> libraries = ExtensionManager.findServices((List<Object>) null, LibraryServiceLoader.class, "com.ibm.xsp.Library");
libraries.stream().filter(lib -> lib instanceof XspLibrary).map(XspLibrary.class::cast).sorted(LibraryWeightComparator.INSTANCE).map(lib -> new LibraryWrapper(lib.getLibraryId(), lib)).map(wrapper -> {
SimpleRegistryProvider provider = new SimpleRegistryProvider();
provider.init(wrapper);
return provider;
}).map(XspRegistryProvider::getRegistry).forEach(facesRegistry::addDepend);
facesRegistry.refreshReferences();
}
use of com.ibm.xsp.library.XspLibrary in project org.openntf.nsfodp by OpenNTF.
the class StockComponentsServlet method doGet.
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.setBufferSize(0);
// $NON-NLS-1$ //$NON-NLS-2$
resp.setHeader("Content-Type", "text/json");
ServletOutputStream os = resp.getOutputStream();
try {
if (componentInfo == null) {
SharableRegistryImpl facesRegistry = new SharableRegistryImpl(getClass().getPackage().getName());
// $NON-NLS-1$
List<Object> libraries = ExtensionManager.findServices((List<Object>) null, LibraryServiceLoader.class, "com.ibm.xsp.Library");
libraries.stream().filter(lib -> lib instanceof XspLibrary).map(XspLibrary.class::cast).map(lib -> new LibraryWrapper(lib.getLibraryId(), lib)).map(wrapper -> {
SimpleRegistryProvider provider = new SimpleRegistryProvider();
provider.init(wrapper);
return provider;
}).map(XspRegistryProvider::getRegistry).forEach(facesRegistry::addDepend);
facesRegistry.refreshReferences();
componentInfo = new JsonJavaObject();
JsonArray defs = new JsonJavaArray();
facesRegistry.findComponentDefs().stream().filter(FacesComponentDefinition::isTag).map(def -> {
try {
JsonObject defObj = new JsonJavaObject();
// $NON-NLS-1$
defObj.putJsonProperty("namespaceUri", def.getNamespaceUri());
// $NON-NLS-1$
defObj.putJsonProperty("tagName", def.getTagName());
// $NON-NLS-1$
defObj.putJsonProperty("class", def.getJavaClass().getName());
// $NON-NLS-1$
defObj.putJsonProperty("since", def.getSince());
// $NON-NLS-1$
defObj.putJsonProperty("defaultPrefix", def.getFirstDefaultPrefix());
// $NON-NLS-1$
defObj.putJsonProperty("componentFamily", def.getComponentFamily());
// $NON-NLS-1$
defObj.putJsonProperty("componentType", def.getComponentType());
// $NON-NLS-1$
defObj.putJsonProperty("id", def.getId());
JsonArray facetNames = new JsonJavaArray();
for (String facetName : def.getFacetNames()) {
facetNames.add(facetName);
}
// $NON-NLS-1$
defObj.putJsonProperty("facetNames", facetNames);
FacesProperty defaultProp = def.getDefaultFacesProperty();
if (defaultProp != null) {
JsonObject defaultPropObj = new JsonJavaObject();
// $NON-NLS-1$
defaultPropObj.putJsonProperty("name", defaultProp.getName());
// $NON-NLS-1$
defaultPropObj.putJsonProperty("since", defaultProp.getSince());
// $NON-NLS-1$
defaultPropObj.putJsonProperty("class", defaultProp.getJavaClass().getName());
// $NON-NLS-1$
defaultPropObj.putJsonProperty("required", defaultProp.isRequired());
// $NON-NLS-1$
defaultPropObj.putJsonProperty("attribute", defaultProp.isAttribute());
}
JsonArray properties = new JsonJavaArray();
for (String propName : def.getPropertyNames()) {
FacesProperty prop = def.getProperty(propName);
JsonObject propObj = new JsonJavaObject();
// $NON-NLS-1$
propObj.putJsonProperty("name", propName);
// $NON-NLS-1$
propObj.putJsonProperty("class", prop.getJavaClass().getName());
// $NON-NLS-1$
propObj.putJsonProperty("since", prop.getSince());
// $NON-NLS-1$
propObj.putJsonProperty("required", prop.isRequired());
// $NON-NLS-1$
propObj.putJsonProperty("attribute", prop.isAttribute());
properties.add(propObj);
}
// $NON-NLS-1$
defObj.putJsonProperty("properties", properties);
return defObj;
} catch (JsonException e) {
throw new RuntimeException(e);
}
}).forEach(defObj -> {
try {
defs.add(defObj);
} catch (JsonException e) {
throw new RuntimeException(e);
}
});
// $NON-NLS-1$
componentInfo.putJsonProperty("components", defs);
}
os.print(componentInfo.toString());
} catch (Throwable e) {
resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintWriter out = new PrintWriter(baos);
e.printStackTrace(out);
out.flush();
os.println(LineDelimitedJsonProgressMonitor.message(// $NON-NLS-1$ //$NON-NLS-2$
"type", // $NON-NLS-1$ //$NON-NLS-2$
"error", // $NON-NLS-1$
"stackTrace", // $NON-NLS-1$
baos.toString()));
}
}
use of com.ibm.xsp.library.XspLibrary in project org.openntf.nsfodp by OpenNTF.
the class StockComponentsServlet method doGet.
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
resp.setBufferSize(0);
// $NON-NLS-1$ //$NON-NLS-2$
resp.setHeader("Content-Type", "text/json");
ServletOutputStream os = resp.getOutputStream();
try {
if (componentInfo == null) {
SharableRegistryImpl facesRegistry = new SharableRegistryImpl(getClass().getPackage().getName());
// $NON-NLS-1$
List<Object> libraries = ExtensionManager.findServices((List<Object>) null, LibraryServiceLoader.class, "com.ibm.xsp.Library");
libraries.stream().filter(lib -> lib instanceof XspLibrary).map(XspLibrary.class::cast).map(lib -> new LibraryWrapper(lib.getLibraryId(), lib)).map(wrapper -> {
SimpleRegistryProvider provider = new SimpleRegistryProvider();
provider.init(wrapper);
return provider;
}).map(XspRegistryProvider::getRegistry).forEach(facesRegistry::addDepend);
facesRegistry.refreshReferences();
componentInfo = new JsonJavaObject();
JsonArray defs = new JsonJavaArray();
facesRegistry.findComponentDefs().stream().filter(FacesComponentDefinition::isTag).map(def -> {
try {
JsonObject defObj = new JsonJavaObject();
// $NON-NLS-1$
defObj.putJsonProperty("namespaceUri", def.getNamespaceUri());
// $NON-NLS-1$
defObj.putJsonProperty("tagName", def.getTagName());
// $NON-NLS-1$
defObj.putJsonProperty("class", def.getJavaClass().getName());
// $NON-NLS-1$
defObj.putJsonProperty("since", def.getSince());
// $NON-NLS-1$
defObj.putJsonProperty("defaultPrefix", def.getFirstDefaultPrefix());
// $NON-NLS-1$
defObj.putJsonProperty("componentFamily", def.getComponentFamily());
// $NON-NLS-1$
defObj.putJsonProperty("componentType", def.getComponentType());
// $NON-NLS-1$
defObj.putJsonProperty("id", def.getId());
JsonArray facetNames = new JsonJavaArray();
for (String facetName : def.getFacetNames()) {
facetNames.add(facetName);
}
// $NON-NLS-1$
defObj.putJsonProperty("facetNames", facetNames);
FacesProperty defaultProp = def.getDefaultFacesProperty();
if (defaultProp != null) {
JsonObject defaultPropObj = new JsonJavaObject();
// $NON-NLS-1$
defaultPropObj.putJsonProperty("name", defaultProp.getName());
// $NON-NLS-1$
defaultPropObj.putJsonProperty("since", defaultProp.getSince());
// $NON-NLS-1$
defaultPropObj.putJsonProperty("class", defaultProp.getJavaClass().getName());
// $NON-NLS-1$
defaultPropObj.putJsonProperty("required", defaultProp.isRequired());
// $NON-NLS-1$
defaultPropObj.putJsonProperty("attribute", defaultProp.isAttribute());
}
JsonArray properties = new JsonJavaArray();
for (String propName : def.getPropertyNames()) {
FacesProperty prop = def.getProperty(propName);
JsonObject propObj = new JsonJavaObject();
// $NON-NLS-1$
propObj.putJsonProperty("name", propName);
// $NON-NLS-1$
propObj.putJsonProperty("class", prop.getJavaClass().getName());
// $NON-NLS-1$
propObj.putJsonProperty("since", prop.getSince());
// $NON-NLS-1$
propObj.putJsonProperty("required", prop.isRequired());
// $NON-NLS-1$
propObj.putJsonProperty("attribute", prop.isAttribute());
properties.add(propObj);
}
// $NON-NLS-1$
defObj.putJsonProperty("properties", properties);
return defObj;
} catch (JsonException e) {
throw new RuntimeException(e);
}
}).forEach(defObj -> {
try {
defs.add(defObj);
} catch (JsonException e) {
throw new RuntimeException(e);
}
});
// $NON-NLS-1$
componentInfo.putJsonProperty("components", defs);
}
os.print(JsonGenerator.toJson(JsonJavaFactory.instance, componentInfo, false));
} catch (Throwable e) {
resp.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
ByteArrayOutputStream baos = new ByteArrayOutputStream();
PrintWriter out = new PrintWriter(baos);
e.printStackTrace(out);
out.flush();
os.println(baos.toString());
}
}
use of com.ibm.xsp.library.XspLibrary in project org.openntf.nsfodp by OpenNTF.
the class AbstractSchemaServlet method doGet.
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
try {
Document doc = DOMUtil.createDocument(namespace, "xs:schema");
doc.setXmlStandalone(true);
Element schema = doc.getDocumentElement();
schema.setAttribute("xmlns:xs", "http://www.w3.org/2001/XMLSchema");
schema.setAttribute("xmlns:" + extMap.get(namespace), namespace);
schema.setAttribute("targetNamespace", namespace);
schema.setAttribute("elementFormDefault", "qualified");
for (String importUri : this.imports) {
schema.setAttribute("xmlns:" + extMap.get(importUri), importUri);
Element importEl = DOMUtil.createElement(doc, schema, "xs:import");
importEl.setAttribute("namespace", importUri);
// importEl.setAttribute("schemaLocation", URI.create(req.getRequestURL().toString()).resolve(extMap.get(importUri) + ".xsd").toString());
importEl.setAttribute("schemaLocation", extMap.get(importUri) + ".xsd");
}
outSimpleTypes(schema);
SharableRegistryImpl facesRegistry = new SharableRegistryImpl(getClass().getPackage().getName());
// $NON-NLS-1$
List<Object> libraries = ExtensionManager.findServices((List<Object>) null, LibraryServiceLoader.class, "com.ibm.xsp.Library");
libraries.stream().filter(lib -> lib instanceof XspLibrary).map(XspLibrary.class::cast).map(lib -> new LibraryWrapper(lib.getLibraryId(), lib)).map(wrapper -> {
SimpleRegistryProvider provider = new SimpleRegistryProvider();
provider.init(wrapper);
return provider;
}).map(XspRegistryProvider::getRegistry).forEach(facesRegistry::addDepend);
facesRegistry.refreshReferences();
@SuppressWarnings("unchecked") List<FacesDefinition> defs = (List<FacesDefinition>) (List<?>) facesRegistry.findDefs();
defs.stream().filter(FacesDefinition::isTag).filter(def -> StringUtil.equals(namespace, def.getNamespaceUri())).forEach(def -> outComponentDefinition(def, schema, facesRegistry, false));
resp.setContentType("text/xml");
DOMUtil.serialize(resp.getOutputStream(), doc, new Format(2, true, "UTF-8"));
} catch (Throwable e) {
e.printStackTrace();
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR, e.getLocalizedMessage());
resp.setContentType("text/plain");
e.printStackTrace(new PrintWriter(resp.getOutputStream()));
resp.getOutputStream().flush();
e.printStackTrace();
}
}
Aggregations