@Override protected WebResource createArchiveResource(JarEntry jarEntry, String webAppPath, Manifest manifest) { return new JarWarResource(getRoot(), webAppPath, getBase(), getBaseUrlString(), jarEntry, archivePath, getInternalPath(), manifest); }
String base, String archivePath, String internalPath) throws IllegalArgumentException { setRoot(root); setWebAppMount(webAppMount); setBase(base); this.archivePath = archivePath; setInternalPath(internalPath); if (getRoot().getState().isAvailable()) { try { start(); } catch (LifecycleException e) { throw new IllegalStateException(e);
@Override protected void initInternal() throws LifecycleException { try (JarFile warFile = new JarFile(getBase())) { JarEntry jarFileInWar = warFile.getJarEntry(archivePath); InputStream jarFileIs = warFile.getInputStream(jarFileInWar); try (JarInputStream jarIs = new JarInputStream(jarFileIs)) { JarEntry entry = jarIs.getNextJarEntry(); while (entry != null) { getJarFileEntries().put(entry.getName(), entry); entry = jarIs.getNextJarEntry(); } setManifest(jarIs.getManifest()); } } catch (IOException ioe) { throw new IllegalArgumentException(ioe); } try { setBaseUrl((new File(getBase())).toURI().toURL()); } catch (MalformedURLException e) { throw new IllegalArgumentException(e); } } }
@Override protected void initInternal() throws LifecycleException { try (JarFile warFile = new JarFile(getBase())) { JarEntry jarFileInWar = warFile.getJarEntry(archivePath); InputStream jarFileIs = warFile.getInputStream(jarFileInWar); try (JarInputStream jarIs = new JarInputStream(jarFileIs)) { setManifest(jarIs.getManifest()); } } catch (IOException ioe) { throw new IllegalArgumentException(ioe); } try { setBaseUrl(UriUtil.buildJarSafeUrl(new File(getBase()))); } catch (MalformedURLException e) { throw new IllegalArgumentException(e); } }
@Test public void embeddedWarWithAppResources() throws LifecycleException { ContextMock contextMock = new ContextMock(); File file = new File(TARGET + File.separator + TEST_CLASSES + File.separator + "test.war"); JarWarResourceSet jarWarResourceSet = new JarWarResourceSet(contextMock.getWebResourceRoot(), "/", file.getAbsolutePath(), INTERNAL_JAR, METAINF_RESOURCES); jarWarResourceSet.init(); JarResourceSet jarResourceSet = new JarResourceSet(contextMock.getWebResourceRoot(), "/", file.getAbsolutePath(), METAINF_RESOURCES); contextMock.init(jarWarResourceSet, jarResourceSet); callApplicationEvent(contextMock); assertThat(contextMock.getWebResourceRoot().getCreateWebResourceSetCalls()) .isEqualTo(0); }
boolean multiRelease = false; try { warFile = openJarFile(); JarEntry jarFileInWar = warFile.getJarEntry(archivePath); jarFileIs = warFile.getInputStream(jarFileInWar); setManifest(m); if (m != null && JreCompat.isJre9Available()) { String value = m.getMainAttributes().getValue("Multi-Release"); processArchivesEntriesForMultiRelease(); } finally { if (warFile != null) { closeJarFile();
if (archivePath != null) { resourceSet = new JarWarResourceSet(this, webAppMount, base, archivePath, internalPath); } else if (file.getName().toLowerCase(Locale.ENGLISH).endsWith(".jar")) {
@Override protected WebResource createArchiveResource(JarEntry jarEntry, String webAppPath, Manifest manifest) { return new JarWarResource(this, webAppPath, getBaseUrlString(), jarEntry, archivePath); }
@Test public void embeddedWarWithAppResources() throws LifecycleException { ContextMock contextMock = new ContextMock(); File file = new File(TARGET + File.separator + TEST_CLASSES + File.separator + "test.war"); JarWarResourceSet jarWarResourceSet = new JarWarResourceSet(contextMock.getWebResourceRoot(), "/", file.getAbsolutePath(), INTERNAL_JAR, METAINF_RESOURCES); jarWarResourceSet.init(); JarResourceSet jarResourceSet = new JarResourceSet(contextMock.getWebResourceRoot(), "/", file.getAbsolutePath(), METAINF_RESOURCES); contextMock.init(jarWarResourceSet, jarResourceSet); callApplicationEvent(contextMock); assertThat(contextMock.getCalledAnswer().getCalls()) .isEqualTo(0); }
@Override protected void initInternal() throws LifecycleException { try (JarFile warFile = new JarFile(getBase())) { JarEntry jarFileInWar = warFile.getJarEntry(archivePath); InputStream jarFileIs = warFile.getInputStream(jarFileInWar); try (JarInputStream jarIs = new JarInputStream(jarFileIs)) { setManifest(jarIs.getManifest()); } } catch (IOException ioe) { throw new IllegalArgumentException(ioe); } try { setBaseUrl(UriUtil.buildJarSafeUrl(new File(getBase()))); } catch (MalformedURLException e) { throw new IllegalArgumentException(e); } }
boolean multiRelease = false; try { warFile = openJarFile(); JarEntry jarFileInWar = warFile.getJarEntry(archivePath); jarFileIs = warFile.getInputStream(jarFileInWar); setManifest(m); if (m != null && JreCompat.isJre9Available()) { String value = m.getMainAttributes().getValue("Multi-Release"); processArchivesEntriesForMultiRelease(); } finally { if (warFile != null) { closeJarFile();
if (archivePath != null) { resourceSet = new JarWarResourceSet(this, webAppMount, base, archivePath, internalPath); } else if (file.getName().toLowerCase(Locale.ENGLISH).endsWith(".jar")) {
@Override protected WebResource createArchiveResource(JarEntry jarEntry, String webAppPath, Manifest manifest) { return new JarWarResource(this, webAppPath, getBaseUrlString(), jarEntry, archivePath); }
@Test public void embeddedWarWithAppResources() throws LifecycleException { ContextMock contextMock = new ContextMock(); File file = new File(TARGET + File.separator + TEST_CLASSES + File.separator + "test.war"); JarWarResourceSet jarWarResourceSet = new JarWarResourceSet(contextMock.getWebResourceRoot(), "/", file.getAbsolutePath(), INTERNAL_JAR, METAINF_RESOURCES); jarWarResourceSet.init(); JarResourceSet jarResourceSet = new JarResourceSet(contextMock.getWebResourceRoot(), "/", file.getAbsolutePath(), METAINF_RESOURCES); contextMock.init(jarWarResourceSet, jarResourceSet); callApplicationEvent(contextMock); assertThat(contextMock.getCalledAnswer().getCalls()) .isEqualTo(0); }
String base, String archivePath, String internalPath) throws IllegalArgumentException { setRoot(root); setWebAppMount(webAppMount); setBase(base); this.archivePath = archivePath; setInternalPath(internalPath); if (getRoot().getState().isAvailable()) { try { start(); } catch (LifecycleException e) { throw new IllegalStateException(e);
if (archivePath != null) { resourceSet = new JarWarResourceSet(this, webAppMount, base, archivePath, internalPath); } else if (file.getName().toLowerCase(Locale.ENGLISH).endsWith(".jar")) {
@Test public void embeddedJarWithAppResources() throws LifecycleException { ContextMock contextMock = new ContextMock(); File file = new File(TARGET + File.separator + TEST_CLASSES + File.separator + "test.jar"); JarWarResourceSet jarWarResourceSet = new JarWarResourceSet(contextMock.getWebResourceRoot(), "/", file.getAbsolutePath(), INTERNAL_JAR, METAINF_RESOURCES); jarWarResourceSet.init(); JarResourceSet jarResourceSet = new JarResourceSet(contextMock.getWebResourceRoot(), "/", file.getAbsolutePath(), METAINF_RESOURCES); contextMock.init(jarWarResourceSet, jarResourceSet); callApplicationEvent(contextMock); assertThat(contextMock.getWebResourceRoot().getCreateWebResourceSetCalls()) .isEqualTo(2); }
String base, String archivePath, String internalPath) throws IllegalArgumentException { setRoot(root); setWebAppMount(webAppMount); setBase(base); this.archivePath = archivePath; setInternalPath(internalPath); if (getRoot().getState().isAvailable()) { try { start(); } catch (LifecycleException e) { throw new IllegalStateException(e);
@Test public void embeddedJarWithAppResources() throws LifecycleException { ContextMock contextMock = new ContextMock(); File file = new File(TARGET + File.separator + TEST_CLASSES + File.separator + "test.jar"); JarWarResourceSet jarWarResourceSet = new JarWarResourceSet(contextMock.getWebResourceRoot(), "/", file.getAbsolutePath(), INTERNAL_JAR, METAINF_RESOURCES); jarWarResourceSet.init(); JarResourceSet jarResourceSet = new JarResourceSet(contextMock.getWebResourceRoot(), "/", file.getAbsolutePath(), METAINF_RESOURCES); contextMock.init(jarWarResourceSet, jarResourceSet); callApplicationEvent(contextMock); assertThat(contextMock.getCalledAnswer().getCalls()) .isEqualTo(1); }
@Test public void embeddedJarWithoutAppResources2() throws LifecycleException { ContextMock contextMock = new ContextMock(); File file = new File(TARGET + File.separator + TEST_CLASSES + File.separator + "test.jar"); JarWarResourceSet jarWarResourceSet = new JarWarResourceSet(contextMock.getWebResourceRoot(), "/", file.getAbsolutePath(), INTERNAL_JAR, METAINF_RESOURCES); jarWarResourceSet.init(); DirResourceSet dirResourceSet = new DirResourceSet(contextMock.getWebResourceRoot(), TEST, TEST, TEST); contextMock.init(dirResourceSet, jarWarResourceSet); callApplicationEvent(contextMock); assertThat(contextMock.getCalledAnswer().getCalls()) .isEqualTo(1); }