-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#11 Initial implementation of QuickStart
- Loading branch information
Showing
3 changed files
with
124 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
vaadin-boot/src/main/java/com/github/mvysny/vaadinboot/JettyQuickStart.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
package com.github.mvysny.vaadinboot; | ||
|
||
import org.eclipse.jetty.quickstart.ExtraXmlDescriptorProcessor; | ||
import org.eclipse.jetty.quickstart.QuickStartGeneratorConfiguration; | ||
import org.eclipse.jetty.util.resource.Resource; | ||
import org.eclipse.jetty.webapp.WebAppContext; | ||
import org.jetbrains.annotations.NotNull; | ||
import org.slf4j.Logger; | ||
import org.slf4j.LoggerFactory; | ||
|
||
import java.io.*; | ||
|
||
/** | ||
* Helper methods for Jetty Quick Start mode. | ||
*/ | ||
class JettyQuickStart { | ||
public static boolean quickstartXmlExists(@NotNull Resource webroot) { | ||
try { | ||
return webroot.getResource("WEB-INF/quickstart-web.xml").exists(); | ||
} catch (IOException e) { | ||
throw new RuntimeException(e); | ||
} | ||
} | ||
|
||
public static void createQuickStartXml(@NotNull WebAppContext context) throws IOException { | ||
context.setAttribute(ExtraXmlDescriptorProcessor.class.getName(), new ExtraXmlDescriptorProcessor()); | ||
final String xml = new File("quickstart-web.xml").getAbsolutePath(); | ||
try (OutputStream out = new BufferedOutputStream(new FileOutputStream(xml))) { | ||
new QuickStartGeneratorConfiguration().generateQuickStartWebXml(context, out); | ||
} | ||
log.info("Created Jetty QuickStart configuration at " + xml + ". Place the file into src/main/resources/webapp/WEB-INF/quickstart-web.xml of your webapp and "); | ||
} | ||
|
||
private static final Logger log = LoggerFactory.getLogger(JettyQuickStart.class); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters