/** * Attempt to deploy. * * @return if the deployment was succesfully deployed */ public boolean deploy() { return deployed = manager.deploy(this); }
/** * Undeploy. */ public void undeploy() { if (deployed) { deployed = false; manager.undeploy(this); } }
@Test public void testUndeploy() { AssetManager mgr = new AssetManager("", ResourceResolver.NULL_RESOLVER); AssetDeployment fooDepl = mgr.createDeployment(); fooDepl.addAsset("foo", "script", AssetLocation.APPLICATION, "foo.js", null, null, null, DUMMY_URL, "bar"); fooDepl.deploy(); AssetDeployment barDepl = mgr.createDeployment(); barDepl.addAsset("bar", "script", AssetLocation.APPLICATION, "bar.js", null, null, null, DUMMY_URL); barDepl.deploy(); List<Asset> asset = Tools.list(mgr.resolveAssets(Collections.singletonList("foo"))); assertEquals(2, asset.size()); assertEquals("bar", asset.get(0).getId()); assertEquals("foo", asset.get(1).getId()); barDepl.undeploy(); try { mgr.resolveAssets(Collections.singletonList("foo")); fail(); } catch (IllegalArgumentException expected) { } } }
@Test public void testCycle1() { AssetManager mgr = new AssetManager("", ResourceResolver.NULL_RESOLVER); assertTrue(mgr.createDeployment().addAsset("foo", "script", AssetLocation.APPLICATION, "foo.js", null, null, null, DUMMY_URL, "bar").deploy()); assertFalse(mgr.createDeployment().addAsset("bar", "script", AssetLocation.APPLICATION, "bar.js", null, null, null, DUMMY_URL, "foo").deploy()); }
@PostConstruct public void start() throws Exception { // URL url = AjaxService.class.getClassLoader().getResource("juzu/impl/plugin/ajax/script.js"); if (url == null) { throw new Exception("Not found script.js"); } // manager.createDeployment().addAsset( "juzu.ajax", "script", AssetLocation.APPLICATION, "/juzu/impl/plugin/ajax/script.js", null, null, // Think about providing a minified version null, url, "jquery").deploy(); // Map<String, ControllerHandler> table = new HashMap<String, ControllerHandler>(); for (ControllerHandler cm : controllerPlugin.getDescriptor().getHandlers()) { Ajax ajax = cm.getMethod().getAnnotation(Ajax.class); if (ajax != null) { table.put(cm.getName(), cm); } } // this.table = table; }
Chunk.Data data = (Chunk.Data)chunk; if (dataStream == null) { Iterable<Asset> resolvedAssets = assetPlugin.getAssetManager().resolveAssets(assets); for (Asset resolvedAsset : resolvedAssets) { Element elt;
public static String renderAssetURLById(String id) throws NullPointerException { Request request = Request.getCurrent(); if (request != null) { AssetManager assetManager = request.getApplication().resolveBean(AssetManager.class); if (assetManager != null) { Asset asset = assetManager.getAsset(id); if (asset != null) { String uri = asset.resolveURI(request.getRunMode().getMinifyAssets()); return renderAssetURL(request, asset.getLocation(), uri); } } } return null; }
for (AssetManager resolver : resolvers) { AssetResource content = resolver.resolveApplicationAssetResource(path); if (content == null) {
@Test public void testUndeploy() { AssetManager mgr = new AssetManager("", ResourceResolver.NULL_RESOLVER); AssetDeployment fooDepl = mgr.createDeployment(); fooDepl.addAsset("foo", "script", AssetLocation.APPLICATION, "foo.js", null, null, null, DUMMY_URL, "bar"); fooDepl.deploy(); AssetDeployment barDepl = mgr.createDeployment(); barDepl.addAsset("bar", "script", AssetLocation.APPLICATION, "bar.js", null, null, null, DUMMY_URL); barDepl.deploy(); List<Asset> asset = Tools.list(mgr.resolveAssets(Collections.singletonList("foo"))); assertEquals(2, asset.size()); assertEquals("bar", asset.get(0).getId()); assertEquals("foo", asset.get(1).getId()); barDepl.undeploy(); try { mgr.resolveAssets(Collections.singletonList("foo")); fail(); } catch (IllegalArgumentException expected) { } } }
@Test public void testCycle1() { AssetManager mgr = new AssetManager("", ResourceResolver.NULL_RESOLVER); assertTrue(mgr.createDeployment().addAsset("foo", "script", AssetLocation.APPLICATION, "foo.js", null, null, null, DUMMY_URL, "bar").deploy()); assertFalse(mgr.createDeployment().addAsset("bar", "script", AssetLocation.APPLICATION, "bar.js", null, null, null, DUMMY_URL, "foo").deploy()); }
@PostConstruct public void start() throws Exception { // URL url = AjaxService.class.getClassLoader().getResource("juzu/impl/plugin/ajax/script.js"); if (url == null) { throw new Exception("Not found script.js"); } // manager.createDeployment().addAsset( "juzu.ajax", "script", AssetLocation.APPLICATION, "/juzu/impl/plugin/ajax/script.js", null, null, // Think about providing a minified version null, url, "jquery").deploy(); // Map<String, ControllerHandler> table = new HashMap<String, ControllerHandler>(); for (ControllerHandler cm : controllerPlugin.getDescriptor().getHandlers()) { Ajax ajax = cm.getMethod().getAnnotation(Ajax.class); if (ajax != null) { table.put(cm.getName(), cm); } } // this.table = table; }
Chunk.Data data = (Chunk.Data)chunk; if (dataStream == null) { Iterable<Asset> resolvedAssets = assetPlugin.getAssetManager().resolveAssets(assets); for (Asset resolvedAsset : resolvedAssets) { Element elt;
public static String renderAssetURLById(String id) throws NullPointerException { Request request = Request.getCurrent(); if (request != null) { AssetManager assetManager = request.getApplication().resolveBean(AssetManager.class); if (assetManager != null) { Asset asset = assetManager.getAsset(id); if (asset != null) { String uri = asset.resolveURI(request.getRunMode().getMinifyAssets()); return renderAssetURL(request, asset.getLocation(), uri); } } } return null; }
for (AssetManager resolver : resolvers) { AssetResource content = resolver.resolveApplicationAssetResource(path); if (content == null) {
@Test public void testCycle2() { AssetManager mgr = new AssetManager("", ResourceResolver.NULL_RESOLVER); assertTrue(mgr.createDeployment().addAsset("foo", "script", AssetLocation.APPLICATION, "foo.js", null, null, null, DUMMY_URL, "bar").deploy()); assertTrue(mgr.createDeployment().addAsset("bar", "script", AssetLocation.APPLICATION, "bar.js", null, null, null, DUMMY_URL, "juu").deploy()); assertFalse(mgr.createDeployment().addAsset("juu", "script", AssetLocation.APPLICATION, "juu.js", null, null, null, DUMMY_URL, "foo").deploy()); }
private LinkedHashMap<String, Chunk.Property<String>> process(List<AssetMetaData> data) throws Exception { LinkedHashMap<String, Chunk.Property<String>> assets = new LinkedHashMap<String, Chunk.Property<String>>(); AssetDeployment deployment = assetManager.createDeployment(); for (AssetMetaData script : data) {
try { if (page.assets.size() > 0 && assetManager != null) { Iterable<Asset> resolvedAssets = assetManager.resolveAssets(page.assets); Tools.addAll(page.resolvedAssets, resolvedAssets);
/** * Undeploy. */ public void undeploy() { if (deployed) { deployed = false; manager.undeploy(this); } }
/** * Attempt to deploy. * * @return if the deployment was succesfully deployed */ public boolean deploy() { return deployed = manager.deploy(this); }
@Test public void testCycle2() { AssetManager mgr = new AssetManager("", ResourceResolver.NULL_RESOLVER); assertTrue(mgr.createDeployment().addAsset("foo", "script", AssetLocation.APPLICATION, "foo.js", null, null, null, DUMMY_URL, "bar").deploy()); assertTrue(mgr.createDeployment().addAsset("bar", "script", AssetLocation.APPLICATION, "bar.js", null, null, null, DUMMY_URL, "juu").deploy()); assertFalse(mgr.createDeployment().addAsset("juu", "script", AssetLocation.APPLICATION, "juu.js", null, null, null, DUMMY_URL, "foo").deploy()); }