Search in sources :

Example 1 with SharableRegistryImpl

use of com.ibm.xsp.registry.SharableRegistryImpl 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();
}
Also used : DynamicXPageBean(com.ibm.xsp.extlib.interpreter.DynamicXPageBean) ExtensionManager(com.ibm.commons.extension.ExtensionManager) SimpleRegistryProvider(com.ibm.xsp.registry.config.SimpleRegistryProvider) JarFile(java.util.jar.JarFile) XspLibrary(com.ibm.xsp.library.XspLibrary) StandardCopyOption(java.nio.file.StandardCopyOption) MessageFormat(java.text.MessageFormat) JarEntry(java.util.jar.JarEntry) Map(java.util.Map) URI(java.net.URI) Bundle(org.osgi.framework.Bundle) Path(java.nio.file.Path) LibraryWrapper(com.ibm.xsp.library.LibraryWrapper) LinkedHashSet(java.util.LinkedHashSet) BundleException(org.osgi.framework.BundleException) SharableRegistryImpl(com.ibm.xsp.registry.SharableRegistryImpl) Files(java.nio.file.Files) ResourceBundleSource(com.ibm.xsp.registry.config.ResourceBundleSource) Collection(java.util.Collection) Set(java.util.Set) IOException(java.io.IOException) Field(java.lang.reflect.Field) Collectors(java.util.stream.Collectors) File(java.io.File) BundleContext(org.osgi.framework.BundleContext) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Objects(java.util.Objects) LibraryServiceLoader(com.ibm.xsp.library.LibraryServiceLoader) LibraryWeightComparator(org.openntf.nsfodp.compiler.util.LibraryWeightComparator) UpdatableLibrary(com.ibm.xsp.registry.UpdatableLibrary) List(java.util.List) FileLocator(org.eclipse.core.runtime.FileLocator) NSFODPUtil(org.openntf.nsfodp.commons.NSFODPUtil) StringUtil(com.ibm.commons.util.StringUtil) FacesProjectImpl(com.ibm.xsp.registry.FacesProjectImpl) IconUrlSource(com.ibm.xsp.registry.config.IconUrlSource) UpdateSite(org.openntf.nsfodp.compiler.update.UpdateSite) Optional(java.util.Optional) FacesLibraryImpl(com.ibm.xsp.registry.FacesLibraryImpl) ODPUtil(org.openntf.nsfodp.commons.odp.util.ODPUtil) XspRegistryProvider(com.ibm.xsp.registry.config.XspRegistryProvider) InputStream(java.io.InputStream) LibraryWrapper(com.ibm.xsp.library.LibraryWrapper) XspLibrary(com.ibm.xsp.library.XspLibrary) SimpleRegistryProvider(com.ibm.xsp.registry.config.SimpleRegistryProvider) SharableRegistryImpl(com.ibm.xsp.registry.SharableRegistryImpl)

Example 2 with SharableRegistryImpl

use of com.ibm.xsp.registry.SharableRegistryImpl 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()));
    }
}
Also used : PrintWriter(java.io.PrintWriter) JsonJavaObject(com.ibm.commons.util.io.json.JsonJavaObject) SharableRegistryImpl(com.ibm.xsp.registry.SharableRegistryImpl) ByteArrayOutputStream(java.io.ByteArrayOutputStream) HttpServlet(javax.servlet.http.HttpServlet) ServletException(javax.servlet.ServletException) JsonObject(com.ibm.commons.util.io.json.JsonObject) ExtensionManager(com.ibm.commons.extension.ExtensionManager) HttpServletResponse(javax.servlet.http.HttpServletResponse) SimpleRegistryProvider(com.ibm.xsp.registry.config.SimpleRegistryProvider) IOException(java.io.IOException) XspLibrary(com.ibm.xsp.library.XspLibrary) FacesProperty(com.ibm.xsp.registry.FacesProperty) LibraryServiceLoader(com.ibm.xsp.library.LibraryServiceLoader) List(java.util.List) HttpServletRequest(javax.servlet.http.HttpServletRequest) JsonJavaArray(com.ibm.commons.util.io.json.JsonJavaArray) JsonException(com.ibm.commons.util.io.json.JsonException) FacesComponentDefinition(com.ibm.xsp.registry.FacesComponentDefinition) ServletOutputStream(javax.servlet.ServletOutputStream) LineDelimitedJsonProgressMonitor(org.openntf.nsfodp.commons.LineDelimitedJsonProgressMonitor) JsonArray(com.ibm.commons.util.io.json.JsonArray) XspRegistryProvider(com.ibm.xsp.registry.config.XspRegistryProvider) LibraryWrapper(com.ibm.xsp.library.LibraryWrapper) JsonException(com.ibm.commons.util.io.json.JsonException) JsonJavaArray(com.ibm.commons.util.io.json.JsonJavaArray) LibraryWrapper(com.ibm.xsp.library.LibraryWrapper) ServletOutputStream(javax.servlet.ServletOutputStream) XspLibrary(com.ibm.xsp.library.XspLibrary) JsonObject(com.ibm.commons.util.io.json.JsonObject) ByteArrayOutputStream(java.io.ByteArrayOutputStream) SharableRegistryImpl(com.ibm.xsp.registry.SharableRegistryImpl) JsonJavaObject(com.ibm.commons.util.io.json.JsonJavaObject) JsonArray(com.ibm.commons.util.io.json.JsonArray) FacesComponentDefinition(com.ibm.xsp.registry.FacesComponentDefinition) SimpleRegistryProvider(com.ibm.xsp.registry.config.SimpleRegistryProvider) JsonJavaObject(com.ibm.commons.util.io.json.JsonJavaObject) JsonObject(com.ibm.commons.util.io.json.JsonObject) FacesProperty(com.ibm.xsp.registry.FacesProperty) PrintWriter(java.io.PrintWriter)

Example 3 with SharableRegistryImpl

use of com.ibm.xsp.registry.SharableRegistryImpl 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());
    }
}
Also used : ByteArrayOutputStream(java.io.ByteArrayOutputStream) ServletException(javax.servlet.ServletException) ExtensionManager(com.ibm.commons.extension.ExtensionManager) SimpleRegistryProvider(com.ibm.xsp.registry.config.SimpleRegistryProvider) JsonGenerator(com.ibm.commons.util.io.json.JsonGenerator) XspLibrary(com.ibm.xsp.library.XspLibrary) HttpServletRequest(javax.servlet.http.HttpServletRequest) JsonJavaArray(com.ibm.commons.util.io.json.JsonJavaArray) FacesComponentDefinition(com.ibm.xsp.registry.FacesComponentDefinition) JsonJavaFactory(com.ibm.commons.util.io.json.JsonJavaFactory) ServletOutputStream(javax.servlet.ServletOutputStream) JsonArray(com.ibm.commons.util.io.json.JsonArray) LibraryWrapper(com.ibm.xsp.library.LibraryWrapper) PrintWriter(java.io.PrintWriter) JsonJavaObject(com.ibm.commons.util.io.json.JsonJavaObject) SharableRegistryImpl(com.ibm.xsp.registry.SharableRegistryImpl) HttpServlet(javax.servlet.http.HttpServlet) JsonObject(com.ibm.commons.util.io.json.JsonObject) HttpServletResponse(javax.servlet.http.HttpServletResponse) IOException(java.io.IOException) FacesProperty(com.ibm.xsp.registry.FacesProperty) WebServlet(javax.servlet.annotation.WebServlet) LibraryServiceLoader(com.ibm.xsp.library.LibraryServiceLoader) List(java.util.List) JsonException(com.ibm.commons.util.io.json.JsonException) XspRegistryProvider(com.ibm.xsp.registry.config.XspRegistryProvider) JsonException(com.ibm.commons.util.io.json.JsonException) JsonJavaArray(com.ibm.commons.util.io.json.JsonJavaArray) LibraryWrapper(com.ibm.xsp.library.LibraryWrapper) ServletOutputStream(javax.servlet.ServletOutputStream) XspLibrary(com.ibm.xsp.library.XspLibrary) JsonObject(com.ibm.commons.util.io.json.JsonObject) ByteArrayOutputStream(java.io.ByteArrayOutputStream) SharableRegistryImpl(com.ibm.xsp.registry.SharableRegistryImpl) JsonJavaObject(com.ibm.commons.util.io.json.JsonJavaObject) JsonArray(com.ibm.commons.util.io.json.JsonArray) FacesComponentDefinition(com.ibm.xsp.registry.FacesComponentDefinition) SimpleRegistryProvider(com.ibm.xsp.registry.config.SimpleRegistryProvider) JsonJavaObject(com.ibm.commons.util.io.json.JsonJavaObject) JsonObject(com.ibm.commons.util.io.json.JsonObject) FacesProperty(com.ibm.xsp.registry.FacesProperty) PrintWriter(java.io.PrintWriter)

Example 4 with SharableRegistryImpl

use of com.ibm.xsp.registry.SharableRegistryImpl 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();
    }
}
Also used : FacesListener(javax.faces.event.FacesListener) FacesSimpleProperty(com.ibm.xsp.registry.FacesSimpleProperty) ServletException(javax.servlet.ServletException) Date(java.util.Date) ExtensionManager(com.ibm.commons.extension.ExtensionManager) SimpleRegistryProvider(com.ibm.xsp.registry.config.SimpleRegistryProvider) HashMap(java.util.HashMap) XspLibrary(com.ibm.xsp.library.XspLibrary) TemporalAccessor(java.time.temporal.TemporalAccessor) FacesComplexDefinition(com.ibm.xsp.registry.FacesComplexDefinition) HttpServletRequest(javax.servlet.http.HttpServletRequest) FacesComponentDefinition(com.ibm.xsp.registry.FacesComponentDefinition) Document(org.w3c.dom.Document) ActionGroup(com.ibm.xsp.actions.ActionGroup) Map(java.util.Map) Node(org.w3c.dom.Node) LocalTime(java.time.LocalTime) AbstractContainerProperty(com.ibm.xsp.registry.AbstractContainerProperty) MethodBinding(javax.faces.el.MethodBinding) LibraryWrapper(com.ibm.xsp.library.LibraryWrapper) PrintWriter(java.io.PrintWriter) PathUtil(com.ibm.commons.util.PathUtil) DOMUtil(com.ibm.commons.xml.DOMUtil) FacesValidatorDefinition(com.ibm.xsp.registry.FacesValidatorDefinition) SharableRegistryImpl(com.ibm.xsp.registry.SharableRegistryImpl) Properties(java.util.Properties) HttpServlet(javax.servlet.http.HttpServlet) FacesContainerProperty(com.ibm.xsp.registry.FacesContainerProperty) Collection(java.util.Collection) HttpServletResponse(javax.servlet.http.HttpServletResponse) IOException(java.io.IOException) FacesDefinition(com.ibm.xsp.registry.FacesDefinition) Collectors(java.util.stream.Collectors) ValueBinding(javax.faces.el.ValueBinding) FacesProperty(com.ibm.xsp.registry.FacesProperty) UIComponent(javax.faces.component.UIComponent) LibraryServiceLoader(com.ibm.xsp.library.LibraryServiceLoader) List(java.util.List) Stream(java.util.stream.Stream) Element(org.w3c.dom.Element) StringUtil(com.ibm.commons.util.StringUtil) XspRegistryProvider(com.ibm.xsp.registry.config.XspRegistryProvider) Format(com.ibm.commons.xml.Format) XMLException(com.ibm.commons.xml.XMLException) InputStream(java.io.InputStream) ComplexContainerTreeNode(com.ibm.xsp.extlib.tree.complex.ComplexContainerTreeNode) LibraryWrapper(com.ibm.xsp.library.LibraryWrapper) Element(org.w3c.dom.Element) XspLibrary(com.ibm.xsp.library.XspLibrary) FacesDefinition(com.ibm.xsp.registry.FacesDefinition) Document(org.w3c.dom.Document) SharableRegistryImpl(com.ibm.xsp.registry.SharableRegistryImpl) Format(com.ibm.commons.xml.Format) SimpleRegistryProvider(com.ibm.xsp.registry.config.SimpleRegistryProvider) List(java.util.List) PrintWriter(java.io.PrintWriter)

Example 5 with SharableRegistryImpl

use of com.ibm.xsp.registry.SharableRegistryImpl in project org.openntf.nsfodp by OpenNTF.

the class AbstractCompilationEnvironment method getLibrary.

protected UpdatableLibrary getLibrary(String namespace) {
    SharableRegistryImpl facesRegistry = (SharableRegistryImpl) facesProject.getRegistry();
    UpdatableLibrary library = (UpdatableLibrary) facesRegistry.getLocalLibrary(namespace);
    if (library == null) {
        try {
            library = new FacesLibraryImpl(facesRegistry, namespace);
            // TODO this is probably properly done by creating a FacesProjectImpl
            // - it can then register the library fragments itself
            // Note: my first attempt at this ended with an infinite loop, so it's trickier than that
            // $NON-NLS-1$
            Field localLibsField = facesRegistry.getClass().getDeclaredField("_localLibs");
            localLibsField.setAccessible(true);
            @SuppressWarnings("unchecked") Map<String, UpdatableLibrary> localLibs = (Map<String, UpdatableLibrary>) localLibsField.get(facesRegistry);
            localLibs.put(namespace, library);
        } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
            throw new RuntimeException(e);
        }
    }
    return library;
}
Also used : UpdatableLibrary(com.ibm.xsp.registry.UpdatableLibrary) SharableRegistryImpl(com.ibm.xsp.registry.SharableRegistryImpl) Field(java.lang.reflect.Field) FacesLibraryImpl(com.ibm.xsp.registry.FacesLibraryImpl) Map(java.util.Map)

Aggregations

SharableRegistryImpl (com.ibm.xsp.registry.SharableRegistryImpl)5 ExtensionManager (com.ibm.commons.extension.ExtensionManager)4 LibraryServiceLoader (com.ibm.xsp.library.LibraryServiceLoader)4 LibraryWrapper (com.ibm.xsp.library.LibraryWrapper)4 XspLibrary (com.ibm.xsp.library.XspLibrary)4 SimpleRegistryProvider (com.ibm.xsp.registry.config.SimpleRegistryProvider)4 XspRegistryProvider (com.ibm.xsp.registry.config.XspRegistryProvider)4 IOException (java.io.IOException)4 List (java.util.List)4 FacesComponentDefinition (com.ibm.xsp.registry.FacesComponentDefinition)3 FacesProperty (com.ibm.xsp.registry.FacesProperty)3 PrintWriter (java.io.PrintWriter)3 Map (java.util.Map)3 StringUtil (com.ibm.commons.util.StringUtil)2 JsonArray (com.ibm.commons.util.io.json.JsonArray)2 JsonException (com.ibm.commons.util.io.json.JsonException)2 JsonJavaArray (com.ibm.commons.util.io.json.JsonJavaArray)2 JsonJavaObject (com.ibm.commons.util.io.json.JsonJavaObject)2 JsonObject (com.ibm.commons.util.io.json.JsonObject)2 FacesLibraryImpl (com.ibm.xsp.registry.FacesLibraryImpl)2