Se ha denunciado esta presentación.
Utilizamos tu perfil de LinkedIn y tus datos de actividad para personalizar los anuncios y mostrarte publicidad más relevante. Puedes cambiar tus preferencias de publicidad en cualquier momento.
D E V E L O P 
 A N D 
 D E P L O Y
Y O U R 
 J A V A E E
M I C R O S E R V I C E S 
 W I T H
A P A C H E 
 T O M E E
@ A L E X S O T O B 
 - 
 L O R D O F T H E J A R S . C O M
	alexsotob		lordofthejars
<<dependencydependency>>
				<<groupIdgroupId>>javaxjavax</</groupIdgroupId>>
				<<artifactIdartifactId>>javaee-apijavaee...
@@PathPath(("/quote""/quote"))
publicpublic		classclass		QuoteServiceQuoteService		{{
		@GET		@GET
		@		@ProducesProduces(...
A P P L I C A T I O N
S E R V E R
	alexsotob		lordofthejars
	alexsotob		lordofthejars
INFO	-	All	injection	points	were	validated	successfully.INFO	-	All	injection	points	were	validated	successfully.
INFO	-	Op...
@Test@Test
publicpublic		voidvoid		shouldGetQuoteshouldGetQuote(())		{{
		QuoteService	quoteService			QuoteService	quoteSe...
	alexsotob		lordofthejars
@@RunWithRunWith((ArquillianArquillian..classclass))
publicpublic		classclass		ColorServiceIntegrationTestColorServiceInte...
D E P L O Y I N G 
 T O
P R O D U C T I O N
	alexsotob		lordofthejars
mvn	clean	installmvn	clean	install
cp	quote.war	<TOMEE_HOME>/webappscp	quote.war	<TOMEE_HOME>/webapps
U S I N G 
 W A R 
F...
<<pluginplugin>>
				<<groupIdgroupId>>org.apache.openejb.mavenorg.apache.openejb.maven</</groupIdgroupId>>
				<<artifact...
clean	install	tomee:execclean	install	tomee:exec
java	-jar	quote-1.0.0-exec.jarjava	-jar	quote-1.0.0-exec.jar
Extracting	t...
D E P L O Y 
 I N 
D O C K E R
	alexsotob		lordofthejars
FROM	javaFROM	java::88
WORKDIR	WORKDIR	//
ADD	targetADD	target//quotequote-1.0-1.0..00--execexec..jar	jar	//appapp//quoteq...
M E S O S 
 + 
 M A R A T H O N 
 I N 
 N A T I V E
{{
		"uris":	[		"uris":	[
				"http://myartifactsrepo/quote-1.0.0-exec.jar"				"http://myartifactsrepo/quote-1.0.0-exec.ja...

http://lordofthejars.github.io/javaee_devoxx

asotobu@gmail.com
Develop and Deploy your JavaEE micro service in less than 5 minutes with Apache TomEE.
Próxima SlideShare
Cargando en…5
×

Develop and Deploy your JavaEE micro service in less than 5 minutes with Apache TomEE.

563 visualizaciones

Publicado el

Do you know that Java EE is not heavy anymore? Do you know that in Java EE with two simple annotations you can create a REST endpoint that it is secured, transaction-aware and with concurrent control? And even more important, the era of heavy application servers is over. Apache TomEE has fixed this.

Come to this session to learn how you can develop a micro service and deploy it with only 5 minutes.

Publicado en: Tecnología
  • Sé el primero en comentar

Develop and Deploy your JavaEE micro service in less than 5 minutes with Apache TomEE.

  1. 1. D E V E L O P A N D D E P L O Y Y O U R J A V A E E M I C R O S E R V I C E S W I T H A P A C H E T O M E E
  2. 2. @ A L E X S O T O B - L O R D O F T H E J A R S . C O M  alexsotob  lordofthejars
  3. 3. <<dependencydependency>> <<groupIdgroupId>>javaxjavax</</groupIdgroupId>> <<artifactIdartifactId>>javaee-apijavaee-api</</artifactIdartifactId>> <<versionversion>>7.07.0</</versionversion>> <<scopescope>>providedprovided</</scopescope>> </</dependencydependency>> D E P E N D E N C I E S  alexsotob  lordofthejars
  4. 4. @@PathPath(("/quote""/quote")) publicpublic classclass QuoteServiceQuoteService {{ @GET @GET @ @ProducesProduces(({{TEXT_PLAINTEXT_PLAIN}})) publicpublic String String quotequote(()) {{ returnreturn "The Winter is Coming.""The Winter is Coming.";; }} }} J A X - R S  alexsotob  lordofthejars
  5. 5. A P P L I C A T I O N S E R V E R  alexsotob  lordofthejars
  6. 6.  alexsotob  lordofthejars
  7. 7. INFO - All injection points were validated successfully.INFO - All injection points were validated successfully. INFO - OpenWebBeans Container has started, it took 106 ms.INFO - OpenWebBeans Container has started, it took 106 ms. INFO - Deployed Application(path=/Users/alex/javaone/apache-tomee-7.0.0/webapps/ROOT)INFO - Deployed Application(path=/Users/alex/javaone/apache-tomee-7.0.0/webapps/ROOT) INFO - Deployment of web application directory webapps/ROOT has finished in 180 msINFO - Deployment of web application directory webapps/ROOT has finished in 180 ms INFO - Starting ProtocolHandler ["http-nio-8080"]INFO - Starting ProtocolHandler ["http-nio-8080"] INFO - Starting ProtocolHandler ["ajp-nio-8009"]INFO - Starting ProtocolHandler ["ajp-nio-8009"] INFO - Server startup in 983 msINFO - Server startup in 983 ms I T I S F A S T  alexsotob  lordofthejars
  8. 8. @Test@Test publicpublic voidvoid shouldGetQuoteshouldGetQuote(()) {{ QuoteService quoteService QuoteService quoteService == newnew QuoteServiceQuoteService(());; assertThatassertThat((quoteServicequoteService..quotequote(()),, isis(("The Winter is Coming.""The Winter is Coming."))));; }} J U N I T Alex Soto (@alexsotob)
  9. 9.  alexsotob  lordofthejars
  10. 10. @@RunWithRunWith((ArquillianArquillian..classclass)) publicpublic classclass ColorServiceIntegrationTestColorServiceIntegrationTest {{ @Deployment @Deployment publicpublic staticstatic WebArchive WebArchive createcreate(()) {{ returnreturn ShrinkWrap ShrinkWrap..createcreate((WebArchiveWebArchive..classclass)) ..addClassesaddClasses((QuoteServiceQuoteService..classclass));; }} @ArquillianResource @ArquillianResource privateprivate URL webappUrl URL webappUrl;; @Test @RunAsClient @Test @RunAsClient publicpublic voidvoid postAndGetpostAndGet(()) {{ final WebClient webClient final WebClient webClient == WebClient WebClient..createcreate((webappUrlwebappUrl));; final Response response final Response response == webClient webClient..pathpath(("quote""quote"))..getget(());; assertThatassertThat((responseresponse..getStatusgetStatus(()),, isis((200200))));; //...//... }} A R Q U I L L I A N T E S T  alexsotob  lordofthejars
  11. 11. D E P L O Y I N G T O P R O D U C T I O N  alexsotob  lordofthejars
  12. 12. mvn clean installmvn clean install cp quote.war <TOMEE_HOME>/webappscp quote.war <TOMEE_HOME>/webapps U S I N G W A R F I L E
  13. 13. <<pluginplugin>> <<groupIdgroupId>>org.apache.openejb.mavenorg.apache.openejb.maven</</groupIdgroupId>> <<artifactIdartifactId>>tomee-maven-plugintomee-maven-plugin</</artifactIdartifactId>> <<versionversion>>${tomee.version}${tomee.version}</</versionversion>> <<configurationconfiguration>> <<tomeeVersiontomeeVersion>>${tomee.version}${tomee.version}</</tomeeVersiontomeeVersion>> <<tomeeClassifiertomeeClassifier>>jaxrsjaxrs</</tomeeClassifiertomeeClassifier>> </</configurationconfiguration>> </</pluginplugin>> T O M E E M A V E N P L U G I N  alexsotob  lordofthejars
  14. 14. clean install tomee:execclean install tomee:exec java -jar quote-1.0.0-exec.jarjava -jar quote-1.0.0-exec.jar Extracting tomee to /Users/alexsoto/git/tomee-jaxrs-starter-project/target/.distributionExtracting tomee to /Users/alexsoto/git/tomee-jaxrs-starter-project/target/.distribution Using CATALINA_BASE: /Users/alexsoto/git/tomee-jaxrs-starter-project/target/.distributionUsing CATALINA_BASE: /Users/alexsoto/git/tomee-jaxrs-starter-project/target/.distribution Using CATALINA_HOME: /Users/alexsoto/git/tomee-jaxrs-starter-project/target/.distributionUsing CATALINA_HOME: /Users/alexsoto/git/tomee-jaxrs-starter-project/target/.distribution Using CATALINA_TMPDIR: /Users/alexsoto/git/tomee-jaxrs-starter-project/target/.distribution/tempUsing CATALINA_TMPDIR: /Users/alexsoto/git/tomee-jaxrs-starter-project/target/.distribution/temp Using JRE_HOME: /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/HomeUsing JRE_HOME: /Library/Java/JavaVirtualMachines/jdk1.8.0_51.jdk/Contents/Home Using CLASSPATH: /Users/alexsoto/git/tomee-jaxrs-starter-...Using CLASSPATH: /Users/alexsoto/git/tomee-jaxrs-starter-... M A K E J A R , N O T W A R
  15. 15. D E P L O Y I N D O C K E R  alexsotob  lordofthejars
  16. 16. FROM javaFROM java::88 WORKDIR WORKDIR // ADD targetADD target//quotequote-1.0-1.0..00--execexec..jar jar //appapp//quotequote-1.0-1.0..00--execexec..jarjar EXPOSE EXPOSE 80808080 CMD CMD [["java""java",, "-jar""-jar",, "/app/quote-1.0.0-exec.jar""/app/quote-1.0.0-exec.jar"]] docker build -t quote .docker build -t quote . docker run -ti -p 8080:8080 quotedocker run -ti -p 8080:8080 quote D O C K E R F I L E B U I L D A N D R U N
  17. 17. M E S O S + M A R A T H O N I N N A T I V E
  18. 18. {{ "uris": [ "uris": [ "http://myartifactsrepo/quote-1.0.0-exec.jar" "http://myartifactsrepo/quote-1.0.0-exec.jar" ] ] "id": "quote", "id": "quote", "cmd": "java -jar -DadditionalSystemProperties=-Dtomcat.http.port=$PORT quote-1.0.0-exec.jar", "cmd": "java -jar -DadditionalSystemProperties=-Dtomcat.http.port=$PORT quote-1.0.0-exec.jar", "mem": 256, "mem": 256, "cpus": 0.5, "cpus": 0.5, "instances": 1, "instances": 1, "ports":[10000], "ports":[10000], "constraints": [ "constraints": [ ["hostname", "UNIQUE"] ["hostname", "UNIQUE"] ] ] }} R U N A P A C H E T O M E E  alexsotob  lordofthejars
  19. 19.  http://lordofthejars.github.io/javaee_devoxx  asotobu@gmail.com

×