public static String renderAssetURLByPath(String path) throws NullPointerException { Request request = Request.getCurrent(); if (request != null) { return renderAssetURL(request, AssetLocation.APPLICATION, path); } else { return null; } }
/** * Generate an asset URL from the specified id. * * @param id the asset id * @return null if the asset id does not exists * @throws NullPointerException if the asset id is null */ public String byId(String id) throws NullPointerException { return AssetServer.renderAssetURLById(id); }
/** * <p>Returns the URL of an asset located in the assets package of the application.</p> * * <p>If the controller is not under the scope of a request, null is returned.</p> * * @param path the path * @return the asset url * @throws NullPointerException when the path argument is null */ public String byPath(String path) throws NullPointerException { return AssetServer.renderAssetURLByPath(AssetLocation.APPLICATION, path); }
@Override public void init() throws ServletException { AssetServer server = (AssetServer)getServletContext().getAttribute("asset.server"); if (server == null) { server = new AssetServer(); getServletContext().setAttribute("asset.server", server); } }
@Override public Completion<Boolean> refresh(boolean recompile) { if (application == null) { // For now only works with CDI ProvidedCDIInjector injector = (ProvidedCDIInjector)this.injector; // Get App application = injector.getApplication(); // Complete application start applicationLifeCycle = application.getInjectionContext().get(Application.class); // Complete application start try { applicationLifeCycle.get(); } catch (InvocationTargetException e) { return Completion.failed(e); } // server.register(application, getRunMode().getCacheAssets()); } // return Completion.completed(false); }
void stop() { if (assetServer != null) { assetServer.unregister(application); } Tools.safeClose(injectionContext); application = null; injectionContext = null; assetManager = null; descriptor = null; classLoader = null; }
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String path = req.getPathInfo(); if (path != null) { AssetServer server = (AssetServer)getServletContext().getAttribute("asset.server"); if (server != null) { if (!server.doGet(path, getServletContext(), req, resp)) { resp.sendError(404, "No resource found " + path); } } else { resp.sendError(500, "No asset server"); } } } }
@Override public void init() throws ServletException { AssetServer server = (AssetServer)getServletContext().getAttribute("asset.server"); if (server == null) { server = new AssetServer(); getServletContext().setAttribute("asset.server", server); } }
@Override public Completion<Boolean> refresh(boolean recompile) { if (application == null) { // For now only works with CDI ProvidedCDIInjector injector = (ProvidedCDIInjector)this.injector; // Get App application = injector.getApplication(); // Complete application start applicationLifeCycle = application.getInjectionContext().get(Application.class); // Complete application start try { applicationLifeCycle.get(); } catch (InvocationTargetException e) { return Completion.failed(e); } // server.register(application, getRunMode().getCacheAssets()); } // return Completion.completed(false); }
void stop() { if (assetServer != null) { assetServer.unregister(application); } Tools.safeClose(injectionContext); application = null; injectionContext = null; assetManager = null; descriptor = null; classLoader = null; }
@Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String path = req.getPathInfo(); if (path != null) { AssetServer server = (AssetServer)getServletContext().getAttribute("asset.server"); if (server != null) { if (!server.doGet(path, getServletContext(), req, resp)) { resp.sendError(404, "No resource found " + path); } } else { resp.sendError(500, "No asset server"); } } } }
public static String renderAssetURLByPath(AssetLocation location, String path) throws NullPointerException { Request request = Request.getCurrent(); if (request != null) { return renderAssetURL(request, location, path); } else { return null; } }
server = new AssetServer(); getServletContext().setAttribute("asset.server", server);
/** * <p>Returns the URL of an asset.</p> * * <p>If the controller is not under the scope of a request, null is returned.</p> * * @param location the asset location * @param uri the asset uri * @return the asset url * @throws NullPointerException when the path argument is null */ public String byPath(AssetLocation location, String uri) throws NullPointerException { return AssetServer.renderAssetURLByPath(location, uri); } }
assetServer.register(application, runMode.getCacheAssets());
/** * Generate an asset URL from the specified id. * * @param id the asset id * @return null if the asset id does not exists * @throws NullPointerException if the asset id is null */ public String byId(String id) throws NullPointerException { return AssetServer.renderAssetURLById(id); }
public static String renderAssetURLByPath(String path) throws NullPointerException { Request request = Request.getCurrent(); if (request != null) { return renderAssetURL(request, AssetLocation.APPLICATION, path); } else { return null; } }
server = new AssetServer(); getServletContext().setAttribute("asset.server", server);
/** * <p>Returns the URL of an asset.</p> * * <p>If the controller is not under the scope of a request, null is returned.</p> * * @param location the asset location * @param uri the asset uri * @return the asset url * @throws NullPointerException when the path argument is null */ public String byPath(AssetLocation location, String uri) throws NullPointerException { return AssetServer.renderAssetURLByPath(location, uri); } }
assetServer.register(application, runMode.getCacheAssets());