/** * Configures the instance to use the 'staticweb' folder next to (sub-)class * in the bundle associated to the specified context. * * @param context The scr component context of the bundle containing the * 'staticweb' directory where the subclass is located. */ public void configure(BundleContext context) { configure(context, "staticweb"); }
@Override public void bundleChanged(BundleEvent event) { Bundle bundle = event.getBundle(); switch (event.getType()) { case BundleEvent.STARTED: registerStaticFiles(bundle); break; case BundleEvent.STOPPED: unregisterStaticFiles(bundle); break; } updateFileServer(); }
protected void activate(ComponentContext context) throws IOException, URISyntaxException { for (Bundle bundle : context.getBundleContext().getBundles()) { registerStaticFiles(bundle); } context.getBundleContext().addBundleListener(this); extraPath = context.getBundleContext().getProperty("org.apache.clerezza.web.fileserver.static.extra"); updateFileServer(); }
protected void activate(ComponentContext context) throws IOException, URISyntaxException { Bundle bundle = context.getBundleContext().getBundle(); URL resourceDir = getClass().getResource("staticweb"); PathNode pathNode = new BundlePathNode(bundle, resourceDir.getPath()); fileServer = new FileServer(pathNode); URL template = getClass().getResource("language-list.ssp"); renderletManager.registerRenderlet(ScalaServerPagesRenderlet.class.getName(), new UriRef(template.toURI().toString()), LANGUAGE.LanguageList, "naked", MediaType.APPLICATION_XHTML_XML_TYPE, true); }
@GET @Path("{path:.+}") public PathNode getStaticFile(@PathParam("path") String path) { final PathNode node = fileServer.getNode(path); return node; }
private void updateFileServer() { final Collection<PathNode> nodes = new HashSet<PathNode>(bundleNodeMap.values()); if (extraPath != null) { nodes.add(new FilePathNode(extraPath)); } MultiPathNode multiPathNode = new MultiPathNode(nodes. toArray(new PathNode[nodes.size()])); fileServer = new FileServer(multiPathNode); } }
@Path("{path:.*}") @GET public PathNode getNode(@PathParam("path") String path) { String[] pathSections = path.split("/"); PathNode current = getRootNode(); for (String pathSection : pathSections) { current = current.getSubPath(pathSection); if (!current.exists()) { throw new WebApplicationException(404); } } return current; }
protected void activate(ComponentContext context) throws IOException, URISyntaxException { Bundle bundle = context.getBundleContext().getBundle(); URL resourceDir = getClass().getResource("staticweb"); PathNode pathNode = new BundlePathNode(bundle, resourceDir.getPath()); logger.debug("Initializing file server for {} ({})", resourceDir, resourceDir.getFile()); fileServer = new FileServer(pathNode); URL template = getClass().getResource( "config.ssp"); renderletManager.registerRenderlet(ScalaServerPagesRenderlet.class.getName(), new UriRef(template.toURI().toString()), CONFIG_PAGE, "naked", MediaType.APPLICATION_XHTML_XML_TYPE, true); }
/** * Returns a PathNode of a static file from the staticweb folder. * * @param path specifies the path param of a URI * * @return {@link PathNode} */ @GET @Path("{path:.+}") public PathNode getStaticFile(@PathParam("path") String path) { return fileServer.getNode(path); } }
/** * configures the instance to use the specified directory as root * * @param rootDir the root of the serverd hierarchy */ public void configure(File rootDir) { configure(new FilePathNode(rootDir)); }
PathNode pathNode = new BundlePathNode(bundle, resourceDir.getPath()); logger.info("Initializing file server for {} ({})", resourceDir, resourceDir.getFile()); fileServer = new FileServer(pathNode); URL renderlet = getClass().getResource("scriptmanager-script-overview.ssp"); renderletManager.registerRenderlet(ScalaServerPagesRenderlet.class.getName(),
/** * Returns a PathNode of a static file from the staticweb folder. * * @return {@link PathNode} */ @GET @Path("{path:.+}") public PathNode getStaticFile(@PathParam("path") String path) { final PathNode node = fileServer.getNode(path); return node; }
/** * Sets up a path in a bundle or file system to be exposed over a * <code>org.apache.clerezza.web.fileserver.FileServer</code>. The path is * relative to the locationof the class. * * @param context The bundle context of the bundle containing the path. * @param path the path where the file are to be exposed */ public void configure(BundleContext context, String path) { PathNode pathNode; Bundle bundle = context.getBundle(); URL resourceDir = getClass().getResource(path); pathNode = new BundlePathNode(bundle, resourceDir.getPath()); configure(pathNode); } /**
Bundle bundle = context.getBundleContext().getBundle(); URL resourceDir = getClass().getResource("staticweb"); PathNode pathNode = new BundlePathNode(bundle, resourceDir.getPath()); logger.info("Initializing file server for {} ({})", resourceDir, resourceDir.getFile()); fileServer = new FileServer(pathNode);
/** * Returns a PathNode of a static file from the staticweb folder. * * @param path specifies the path parameter * @return {@link PathNode} */ @GET @Path("{path:.+}") public PathNode getStaticFile( @PathParam("path") String path) { return fileServer.getNode(path); } }
/** * Returns a PathNode of a static file from the staticweb folder. * * @return {@link PathNode} */ @GET @Path("{path:.+}") public PathNode getStaticFile(@PathParam("path") String path) { final PathNode node = fileServer.getNode(path); logger.debug("Serving static {}", node); return node; }