https://github.com/cchacin/tomee-boot-xtend
Apache TomEE + Shrinkwrap == JavaEE Boot
https://github.com/cchacin/tomee-boot-xtend
Last synced: 5 months ago
JSON representation
Apache TomEE + Shrinkwrap == JavaEE Boot
- Host: GitHub
- URL: https://github.com/cchacin/tomee-boot-xtend
- Owner: cchacin
- Created: 2014-10-11T02:20:21.000Z (almost 11 years ago)
- Default Branch: master
- Last Pushed: 2014-11-12T22:12:30.000Z (almost 11 years ago)
- Last Synced: 2024-04-16T19:17:10.751Z (over 1 year ago)
- Language: Xtend
- Size: 152 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Apache TomEE + Shrinkwrap == JavaEE Boot
============Based on this [article](http://java.dzone.com/articles/apache-tomee-shrinkwrap-javaee) published in DZone by @lordofthejars
```xml
org.apache.openejb
tomee-embedded
1.7.1
org.apache.openejb
tomee-jaxrs
1.7.1
org.jboss.shrinkwrap
shrinkwrap-depchain
1.2.2
pom
```
```xtend
@Stateless
@Path("/sample")
class SampleController {@GET
@Produces("text/plain")
def sample() {
"Hello World"
}def static main(String[] args) {
TomEEApplication.run(typeof(SampleController));
}
}```
```xtend
class TomEEApplication {def static startAndDeploy(Archive> archive) {
try {
val configuration = new Configuration()
val String tomeeDir = Files.createTempDirectory("apache-tomee").toFile().getAbsolutePath()
configuration.setDir(tomeeDir)
configuration.setHttpPort(8080)val container = new Container()
container.setup(configuration)val app = new File(Files.createTempDirectory("app").toFile().getAbsolutePath())
app.deleteOnExit()val target = new File(app, "app.war")
archive.^as(typeof(ZipExporter)).exportTo(target, true)
container.start()container.deploy("app", target)
container.await()registerShutdownHook(container)
} catch (Exception e) {
throw new IllegalArgumentException(e)
}
}def static registerShutdownHook(Container container) {
Runtime.getRuntime().addShutdownHook(new Thread() {
override run() {
try {
if (container != null) {
container.stop()
}
} catch (Exception e) {
throw new IllegalArgumentException(e)
}
}
});
}def static run(Class>... clazzes) {
run(ShrinkWrap.create(typeof(WebArchive)).addClasses(clazzes))
}def static run(WebArchive archive) {
startAndDeploy(archive)
}
}
```