Search in sources :

Example 1 with ScriptResource

use of org.apache.stanbol.commons.web.base.ScriptResource in project stanbol by apache.

the class EnhancerWebFragment method getScriptResources.

@Override
public List<ScriptResource> getScriptResources() {
    List<ScriptResource> resources = new ArrayList<ScriptResource>();
    resources.add(new ScriptResource("text/javascript", "openlayers-2.9/OpenLayers.js", this, 10));
    resources.add(new ScriptResource("text/javascript", "scripts/prettify/prettify.js", this, 20));
    return resources;
}
Also used : ArrayList(java.util.ArrayList) ScriptResource(org.apache.stanbol.commons.web.base.ScriptResource)

Example 2 with ScriptResource

use of org.apache.stanbol.commons.web.base.ScriptResource in project stanbol by apache.

the class JerseyEndpoint method initJersey.

/**
 * Initialize the Jersey subsystem
 */
private synchronized void initJersey() throws NamespaceException, ServletException {
    if (componentContext == null) {
        // we have not yet been activated
        return;
    }
    // end of STANBOL-1073 work around
    if (componentContext == null) {
        log.debug(" ... can not init Jersey Endpoint - Component not yet activated!");
        // throw new IllegalStateException("Null ComponentContext, not activated?");
        return;
    }
    shutdownJersey();
    log.info("(Re)initializing the Stanbol Jersey subsystem");
    // register all the JAX-RS resources into a a JAX-RS application and bind it to a configurable URL
    // prefix
    DefaultApplication app = new DefaultApplication();
    String staticUrlRoot = (String) componentContext.getProperties().get(STATIC_RESOURCES_URL_ROOT_PROPERTY);
    String applicationAlias = (String) componentContext.getProperties().get(ALIAS_PROPERTY);
    // incrementally contribute fragment resources
    List<LinkResource> linkResources = new ArrayList<LinkResource>();
    List<ScriptResource> scriptResources = new ArrayList<ScriptResource>();
    for (WebFragment fragment : webFragments) {
        log.debug("Registering web fragment '{}' into jaxrs application", fragment.getName());
        linkResources.addAll(fragment.getLinkResources());
        scriptResources.addAll(fragment.getScriptResources());
        navigationLinks.removeAll(fragment.getNavigationLinks());
        navigationLinks.addAll(fragment.getNavigationLinks());
        app.contributeClasses(fragment.getJaxrsResourceClasses());
        app.contributeSingletons(fragment.getJaxrsResourceSingletons());
    }
    app.contributeSingletons(components);
    Collections.sort(linkResources);
    Collections.sort(scriptResources);
    Collections.sort(navigationLinks);
    // bind the aggregate JAX-RS application to a dedicated servlet
    ServletContainer container = new ServletContainer(ResourceConfig.forApplication(app));
    Bundle appBundle = componentContext.getBundleContext().getBundle();
    httpService.registerServlet(applicationAlias, container, getInitParams(), null);
    registeredAliases.add(applicationAlias);
    // forward the main Stanbol OSGi runtime context so that JAX-RS resources can lookup arbitrary
    // services
    servletContext = container.getServletContext();
    servletContext.setAttribute(BundleContext.class.getName(), componentContext.getBundleContext());
    layoutConfiguration.setRootUrl(applicationAlias);
    // servletContext.setAttribute(BaseStanbolResource.ROOT_URL, applicationAlias);
    layoutConfiguration.setStaticResourcesRootUrl(staticUrlRoot);
    // servletContext.setAttribute(BaseStanbolResource.STATIC_RESOURCES_ROOT_URL, staticUrlRoot);
    layoutConfiguration.setLinkResources(linkResources);
    // servletContext.setAttribute(BaseStanbolResource.LINK_RESOURCES, linkResources);
    layoutConfiguration.setScriptResources(scriptResources);
    // servletContext.setAttribute(BaseStanbolResource.SCRIPT_RESOURCES, scriptResources);
    layoutConfiguration.setNavigationsLinks(navigationLinks);
    // servletContext.setAttribute(BaseStanbolResource.NAVIGATION_LINKS, navigationLinks);
    servletContext.setAttribute(CORS_ORIGIN, corsOrigins);
    servletContext.setAttribute(CORS_ACCESS_CONTROL_EXPOSE_HEADERS, exposedHeaders);
    log.info("JerseyEndpoint servlet registered at {}", applicationAlias);
}
Also used : LinkResource(org.apache.stanbol.commons.web.base.LinkResource) WebFragment(org.apache.stanbol.commons.web.base.WebFragment) Bundle(org.osgi.framework.Bundle) ServletContainer(org.glassfish.jersey.servlet.ServletContainer) ArrayList(java.util.ArrayList) ScriptResource(org.apache.stanbol.commons.web.base.ScriptResource) BundleContext(org.osgi.framework.BundleContext)

Example 3 with ScriptResource

use of org.apache.stanbol.commons.web.base.ScriptResource in project stanbol by apache.

the class HomeWebFragment method getScriptResources.

@Override
public List<ScriptResource> getScriptResources() {
    List<ScriptResource> resources = new ArrayList<ScriptResource>();
    resources.add(new ScriptResource("text/javascript", "scripts/jquery-1.4.2.js", this, 0));
    return resources;
}
Also used : ArrayList(java.util.ArrayList) ScriptResource(org.apache.stanbol.commons.web.base.ScriptResource)

Example 4 with ScriptResource

use of org.apache.stanbol.commons.web.base.ScriptResource in project stanbol by apache.

the class RulesFragment method getScriptResources.

@Override
public List<ScriptResource> getScriptResources() {
    List<ScriptResource> resources = new ArrayList<ScriptResource>();
    resources.add(new ScriptResource("text/javascript", "actions/actions.js", this, 10));
    resources.add(new ScriptResource("text/javascript", "actions/tutorial.js", this, 10));
    return resources;
}
Also used : ArrayList(java.util.ArrayList) ScriptResource(org.apache.stanbol.commons.web.base.ScriptResource)

Example 5 with ScriptResource

use of org.apache.stanbol.commons.web.base.ScriptResource in project stanbol by apache.

the class OntologyManagerWebFragment method getScriptResources.

@Override
public List<ScriptResource> getScriptResources() {
    List<ScriptResource> resources = new ArrayList<ScriptResource>();
    resources.add(new ScriptResource("text/javascript", "scripts/actions.js", this, 10));
    return resources;
}
Also used : ArrayList(java.util.ArrayList) ScriptResource(org.apache.stanbol.commons.web.base.ScriptResource)

Aggregations

ArrayList (java.util.ArrayList)5 ScriptResource (org.apache.stanbol.commons.web.base.ScriptResource)5 LinkResource (org.apache.stanbol.commons.web.base.LinkResource)1 WebFragment (org.apache.stanbol.commons.web.base.WebFragment)1 ServletContainer (org.glassfish.jersey.servlet.ServletContainer)1 Bundle (org.osgi.framework.Bundle)1 BundleContext (org.osgi.framework.BundleContext)1