An open API service indexing awesome lists of open source software.

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

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)
}
}
```