├── .gitignore ├── api-management.adoc ├── images ├── newrelic-applications.png ├── newrelic-catalog-item-rest.png ├── newrelic-everest-web-breakdown-table.png ├── newrelic-everest-web-faces-servlet.png └── newrelic-service-map.png ├── microservice ├── catalog │ ├── pom.xml │ └── src │ │ └── main │ │ ├── docker │ │ └── assembly.xml │ │ ├── java │ │ └── org │ │ │ └── javaee7 │ │ │ └── wildfly │ │ │ └── samples │ │ │ └── everest │ │ │ └── catalog │ │ │ ├── ApplicationConfig.java │ │ │ ├── CatalogItem.java │ │ │ ├── CatalogItemREST.java │ │ │ ├── CatalogItemType.java │ │ │ └── CatalogService.java │ │ └── resources │ │ ├── META-INF │ │ ├── load.sql │ │ └── persistence.xml │ │ └── application.yml ├── contracts │ ├── pom.xml │ └── src │ │ └── main │ │ └── resources │ │ └── META-INF │ │ └── contracts │ │ └── main │ │ ├── cssLayout.css │ │ ├── default.css │ │ ├── javax.faces.contract.xml │ │ └── template.xhtml ├── docker │ ├── Dockerfile │ └── microservice │ │ └── create-resources.sh ├── everest │ ├── pom.xml │ └── src │ │ └── main │ │ ├── docker │ │ └── assembly.xml │ │ ├── java │ │ └── org │ │ │ └── javaee7 │ │ │ └── wildfly │ │ │ └── samples │ │ │ └── everest │ │ │ ├── Resources.java │ │ │ ├── cart │ │ │ ├── Cart.java │ │ │ └── CartItem.java │ │ │ ├── catalog │ │ │ ├── CatalogBean.java │ │ │ └── CatalogItem.java │ │ │ ├── checkout │ │ │ ├── Order.java │ │ │ ├── OrderBean.java │ │ │ ├── OrderItem.java │ │ │ └── Shipping.java │ │ │ └── uzer │ │ │ ├── UzerBean.java │ │ │ └── UzerItem.java │ │ └── webapp │ │ ├── WEB-INF │ │ └── web.xml │ │ ├── cart.xhtml │ │ ├── catalog-item.xhtml │ │ ├── catalog.xhtml │ │ ├── checkout.xhtml │ │ ├── confirm.xhtml │ │ ├── index.xhtml │ │ ├── user-status.xhtml │ │ └── user.xhtml ├── order │ ├── pom.xml │ └── src │ │ └── main │ │ ├── docker │ │ └── assembly.xml │ │ ├── java │ │ └── org │ │ │ └── javaee7 │ │ │ └── wildfly │ │ │ └── samples │ │ │ └── everest │ │ │ └── order │ │ │ ├── ApplicationConfig.java │ │ │ ├── Order.java │ │ │ ├── OrderItem.java │ │ │ ├── OrderREST.java │ │ │ └── OrderService.java │ │ └── resources │ │ ├── META-INF │ │ └── persistence.xml │ │ └── application.yml ├── pom.xml ├── services │ ├── pom.xml │ └── src │ │ └── main │ │ ├── java │ │ └── org │ │ │ └── javaee7 │ │ │ └── wildfly │ │ │ └── samples │ │ │ └── services │ │ │ ├── FixedServices.java │ │ │ ├── SnoopServices.java │ │ │ ├── ZooKeeperServices.java │ │ │ ├── discovery │ │ │ └── ServiceDiscovery.java │ │ │ ├── fixed │ │ │ ├── FixedServiceDiscovery.java │ │ │ └── FixedServiceRegistry.java │ │ │ ├── registration │ │ │ └── ServiceRegistry.java │ │ │ ├── snoop │ │ │ ├── SnoopServiceDiscovery.java │ │ │ └── SnoopServiceRegistry.java │ │ │ └── zookeeper │ │ │ ├── ZooKeeperServiceDiscovery.java │ │ │ └── ZooKeeperServiceRegistry.java │ │ └── resources │ │ ├── META-INF │ │ └── beans.xml │ │ ├── application.yml │ │ └── zookeeper.properties ├── user │ ├── nb-configuration.xml │ ├── pom.xml │ └── src │ │ └── main │ │ ├── docker │ │ └── assembly.xml │ │ ├── java │ │ └── org │ │ │ └── javaee7 │ │ │ └── wildfly │ │ │ └── samples │ │ │ └── everest │ │ │ └── uzer │ │ │ ├── ApplicationConfig.java │ │ │ ├── UserREST.java │ │ │ ├── UserService.java │ │ │ └── Uzer.java │ │ └── resources │ │ ├── META-INF │ │ └── persistence.xml │ │ └── application.yml └── utils │ ├── pom.xml │ └── src │ ├── main │ ├── java │ │ └── org │ │ │ └── javaee7 │ │ │ └── wildfly │ │ │ └── samples │ │ │ └── everest │ │ │ └── utils │ │ │ ├── WildFlyUtil.java │ │ │ ├── cdi │ │ │ └── EnvironmentProducer.java │ │ │ ├── exception │ │ │ └── InitializationException.java │ │ │ └── qualifiers │ │ │ ├── QSecureServerPort.java │ │ │ ├── QServerName.java │ │ │ └── QServerPort.java │ └── resources │ │ └── META-INF │ │ └── beans.xml │ └── test │ ├── java │ └── org │ │ └── javaee7 │ │ └── wildfly │ │ └── samples │ │ └── everest │ │ ├── test │ │ ├── ArquillianBase.java │ │ └── TestAll.java │ │ └── utils │ │ └── WildflyUtilTest.java │ └── resources │ ├── log4j.properties │ └── logging.properties ├── monolith └── everest │ ├── pom.xml │ └── src │ └── main │ ├── java │ └── org │ │ └── javaee7 │ │ └── wildfly │ │ └── samples │ │ └── everest │ │ ├── cart │ │ ├── Cart.java │ │ └── CartItem.java │ │ ├── catalog │ │ ├── CatalogItem.java │ │ ├── CatalogItemBean.java │ │ └── CatalogItemType.java │ │ ├── checkout │ │ ├── Order.java │ │ ├── OrderBean.java │ │ ├── OrderItem.java │ │ └── Shipping.java │ │ └── uzer │ │ ├── Uzer.java │ │ ├── UzerBean.java │ │ └── UzerItem.java │ ├── resources │ └── META-INF │ │ ├── load.sql │ │ └── persistence.xml │ └── webapp │ ├── WEB-INF │ ├── jboss-web.xml │ ├── template.xhtml │ └── web.xml │ ├── cart.xhtml │ ├── catalog-item.xhtml │ ├── catalog.xhtml │ ├── checkout.xhtml │ ├── confirm.xhtml │ ├── css │ ├── cssLayout.css │ └── default.css │ ├── index.xhtml │ ├── user-status.xhtml │ └── user.xhtml ├── readme.adoc ├── service-discovery.adoc ├── service-monitoring.adoc └── slides ├── api-management.key ├── api-management.pdf ├── bimodal-it-microservices.key ├── bimodal-it-microservices.pdf ├── microservices-design-patterns.key ├── microservices-design-patterns.pdf ├── refactor-microservices.key └── refactor-microservices.pdf /.gitignore: -------------------------------------------------------------------------------- 1 | #Eclips Paths 2 | .classpath 3 | .project 4 | .settings/ 5 | bin/ 6 | 7 | #IntelliJ Idea Paths 8 | .idea/ 9 | *.iml 10 | *.iws 11 | atlassia* 12 | 13 | #Netbeans output 14 | nbproject 15 | dist/ 16 | build/ 17 | dbdist/ 18 | nbactions.xml 19 | **/nb-configuration.xml 20 | 21 | #Apple Paths 22 | .DS_Store 23 | 24 | #Maven Paths 25 | log/ 26 | target/ 27 | 28 | #Maven Plugins 29 | test-output/ 30 | 31 | #Misc Editor 32 | *.bak 33 | *.tmp 34 | 35 | #Java File Extensions 36 | *.class 37 | *.jar 38 | *.war 39 | *.ear 40 | 41 | #Gradle 42 | .gradle* 43 | 44 | rebel.xml 45 | -------------------------------------------------------------------------------- /api-management.adoc: -------------------------------------------------------------------------------- 1 | # API Management 2 | 3 | Each microservice will typically publish a URI that can then be invoked by other microservices. 4 | 5 | . Start API Man: 6 | 7 | docker run -it -p 8082:8080 jboss/apiman-wildfly 8 | docker run -it -p 8082:8080 arungupta/apiman-wildfly 9 | 10 | . Start API Man with all the required resources created: 11 | 12 | docker run -it -p 8082:8080 arungupta/apiman-microservices -------------------------------------------------------------------------------- /images/newrelic-applications.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arun-gupta/microservices/0bd10e5af2fb70e38729f21d6c477b329ed9e401/images/newrelic-applications.png -------------------------------------------------------------------------------- /images/newrelic-catalog-item-rest.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arun-gupta/microservices/0bd10e5af2fb70e38729f21d6c477b329ed9e401/images/newrelic-catalog-item-rest.png -------------------------------------------------------------------------------- /images/newrelic-everest-web-breakdown-table.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arun-gupta/microservices/0bd10e5af2fb70e38729f21d6c477b329ed9e401/images/newrelic-everest-web-breakdown-table.png -------------------------------------------------------------------------------- /images/newrelic-everest-web-faces-servlet.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arun-gupta/microservices/0bd10e5af2fb70e38729f21d6c477b329ed9e401/images/newrelic-everest-web-faces-servlet.png -------------------------------------------------------------------------------- /images/newrelic-service-map.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arun-gupta/microservices/0bd10e5af2fb70e38729f21d6c477b329ed9e401/images/newrelic-service-map.png -------------------------------------------------------------------------------- /microservice/catalog/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | org.javaee7.wildfly.samples 8 | shoppingcart-msa 9 | 1.0-SNAPSHOT 10 | ../pom.xml 11 | 12 | 13 | catalog 14 | war 15 | 16 | catalog 17 | 18 | 19 | 20 | org.javaee7.wildfly.samples 21 | services 22 | 23 | 24 | org.javaee7.wildfly.samples 25 | utils 26 | 27 | 28 | eu.agilejava 29 | snoop 30 | 31 | 32 | 33 | 34 | catalog 35 | 36 | 37 | org.wildfly.plugins 38 | wildfly-maven-plugin 39 | 40 | false 41 | 42 | 43 | 44 | 45 | org.jolokia 46 | docker-maven-plugin 47 | 48 | 49 | 50 | catalog 51 | arungupta/shoppingcart-catalog 52 | 53 | jboss/wildfly 54 | 55 | assembly.xml 56 | /opt/jboss/wildfly/standalone/deployments 57 | jboss:jboss:jboss 58 | 59 | 60 | 8080 61 | 62 | 63 | 64 | 65 | catalog.port:8080 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | -------------------------------------------------------------------------------- /microservice/catalog/src/main/docker/assembly.xml: -------------------------------------------------------------------------------- 1 | 4 | docker 5 | 6 | 7 | 8 | org.javaee7.wildfly.samples:catalog 9 | 10 | catalog.war 11 | 12 | 13 | -------------------------------------------------------------------------------- /microservice/catalog/src/main/java/org/javaee7/wildfly/samples/everest/catalog/ApplicationConfig.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.wildfly.samples.everest.catalog; 2 | 3 | import javax.ws.rs.core.Application; 4 | 5 | /** 6 | * @author arungupta 7 | */ 8 | //@EnableSnoopClient 9 | @javax.ws.rs.ApplicationPath("resources") 10 | public class ApplicationConfig extends Application { 11 | } 12 | -------------------------------------------------------------------------------- /microservice/catalog/src/main/java/org/javaee7/wildfly/samples/everest/catalog/CatalogItem.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.wildfly.samples.everest.catalog; 2 | 3 | import java.io.Serializable; 4 | import javax.persistence.Column; 5 | import javax.persistence.Entity; 6 | import javax.persistence.Id; 7 | import javax.persistence.NamedQueries; 8 | import javax.persistence.NamedQuery; 9 | import javax.xml.bind.annotation.XmlRootElement; 10 | 11 | /** 12 | * @author arungupta 13 | */ 14 | @Entity 15 | @NamedQueries({ 16 | @NamedQuery(name = "Item.findAll", query = "SELECT i FROM CatalogItem i"), 17 | @NamedQuery(name = "Item.findById", query = "SELECT i FROM CatalogItem i where i.id = :id") 18 | }) 19 | @XmlRootElement 20 | public class CatalogItem implements Serializable { 21 | private static final long serialVersionUID = 1L; 22 | @Id 23 | private int id; 24 | 25 | @Column(length=60) 26 | private String name; 27 | 28 | @Column 29 | private int type; 30 | 31 | @Column(length=100) 32 | private String description; 33 | 34 | public CatalogItem() { } 35 | 36 | public CatalogItem(String name, int type) { 37 | this.name = name; 38 | this.type = type; 39 | } 40 | 41 | public int getId() { 42 | return id; 43 | } 44 | 45 | public void setId(int id) { 46 | this.id = id; 47 | } 48 | 49 | public String getName() { 50 | return name; 51 | } 52 | 53 | public void setName(String name) { 54 | this.name = name; 55 | } 56 | 57 | public int getType() { 58 | return type; 59 | } 60 | 61 | public void setType(int type) { 62 | this.type = type; 63 | } 64 | 65 | public String getDescription() { 66 | return description; 67 | } 68 | 69 | public void setDescription(String description) { 70 | this.description = description; 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /microservice/catalog/src/main/java/org/javaee7/wildfly/samples/everest/catalog/CatalogItemREST.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.wildfly.samples.everest.catalog; 2 | 3 | import java.util.List; 4 | import javax.annotation.PostConstruct; 5 | import javax.ejb.Stateless; 6 | import javax.persistence.EntityManager; 7 | import javax.persistence.PersistenceContext; 8 | import javax.ws.rs.Consumes; 9 | import javax.ws.rs.DELETE; 10 | import javax.ws.rs.GET; 11 | import javax.ws.rs.POST; 12 | import javax.ws.rs.PUT; 13 | import javax.ws.rs.Path; 14 | import javax.ws.rs.PathParam; 15 | import javax.ws.rs.Produces; 16 | import javax.ws.rs.core.Context; 17 | import javax.ws.rs.core.UriInfo; 18 | 19 | /** 20 | * @author arungupta 21 | */ 22 | @Stateless 23 | @Path("catalog") 24 | public class CatalogItemREST { 25 | @PersistenceContext 26 | private EntityManager em; 27 | 28 | @Context UriInfo uriInfo; 29 | 30 | @PostConstruct 31 | public void init() { 32 | System.out.println("base URI: " + uriInfo.getBaseUri()); 33 | System.out.println("request URI: " + uriInfo.getRequestUri()); 34 | } 35 | 36 | @POST 37 | @Consumes({"application/xml", "application/json"}) 38 | public void create(CatalogItem entity) { 39 | em.persist(entity); 40 | } 41 | 42 | @PUT 43 | @Path("{id}") 44 | @Consumes({"application/xml", "application/json"}) 45 | public void edit(@PathParam("id") Integer id, CatalogItem entity) { 46 | em.merge(entity); 47 | } 48 | 49 | @DELETE 50 | @Path("{id}") 51 | public void remove(@PathParam("id") Integer id) { 52 | em.remove(find(id)); 53 | } 54 | 55 | @GET 56 | @Path("{id}") 57 | @Produces({"application/xml; qs=0.50", "application/json"}) 58 | public CatalogItem find(@PathParam("id") Integer id) { 59 | return em.createNamedQuery("Item.findById", CatalogItem.class).setParameter("id", id).getSingleResult(); 60 | } 61 | 62 | @GET 63 | @Produces({"application/xml", "application/json"}) 64 | public List findAll() { 65 | return em.createNamedQuery("Item.findAll", CatalogItem.class).getResultList(); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /microservice/catalog/src/main/java/org/javaee7/wildfly/samples/everest/catalog/CatalogItemType.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.wildfly.samples.everest.catalog; 2 | 3 | import java.io.Serializable; 4 | import javax.persistence.Column; 5 | import javax.persistence.Entity; 6 | import javax.persistence.Id; 7 | 8 | /** 9 | * @author arungupta 10 | */ 11 | @Entity 12 | public class CatalogItemType implements Serializable { 13 | private static final long serialVersionUID = 1L; 14 | @Id 15 | private int id; 16 | 17 | @Column 18 | private String name; 19 | 20 | public CatalogItemType() { 21 | } 22 | 23 | public CatalogItemType(int id, String name) { 24 | this.id = id; 25 | this.name = name; 26 | } 27 | 28 | public int getId() { 29 | return id; 30 | } 31 | 32 | public void setId(int id) { 33 | this.id = id; 34 | } 35 | 36 | public String getName() { 37 | return name; 38 | } 39 | 40 | public void setName(String name) { 41 | this.name = name; 42 | } 43 | } -------------------------------------------------------------------------------- /microservice/catalog/src/main/java/org/javaee7/wildfly/samples/everest/catalog/CatalogService.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.wildfly.samples.everest.catalog; 2 | 3 | import javax.annotation.PostConstruct; 4 | import javax.annotation.PreDestroy; 5 | import javax.ejb.Singleton; 6 | import javax.ejb.Startup; 7 | import javax.inject.Inject; 8 | import org.javaee7.wildfly.samples.everest.utils.WildFlyUtil; 9 | import org.javaee7.wildfly.samples.services.ZooKeeperServices; 10 | import org.javaee7.wildfly.samples.services.registration.ServiceRegistry; 11 | 12 | /** 13 | * @author arungupta 14 | */ 15 | @Startup 16 | @Singleton 17 | public class CatalogService { 18 | // @Inject @FixedServices ServiceRegistry services; 19 | // @Inject @SnoopServices ServiceRegistry services; 20 | 21 | @Inject 22 | @ZooKeeperServices 23 | ServiceRegistry services; 24 | 25 | // private static final String endpointURI = "http://localhost:8080/catalog/resources/catalog"; 26 | // private final String endpointURI = "http://" + serverName + ":" + serverPort + "/catalog/resources/catalog"; 27 | private final String endpointURI = "http://" + WildFlyUtil.getHostName() + ":" + WildFlyUtil.getHostPort() + "/catalog/resources/catalog"; 28 | private static final String serviceName = "catalog"; 29 | 30 | @PostConstruct 31 | public void registerService() { 32 | services.registerService(serviceName, endpointURI); 33 | } 34 | 35 | @PreDestroy 36 | public void unregisterService() { 37 | services.unregisterService(serviceName, endpointURI); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /microservice/catalog/src/main/resources/META-INF/load.sql: -------------------------------------------------------------------------------- 1 | INSERT INTO CatalogItemType("ID", "NAME") VALUES (1, 'Book') 2 | INSERT INTO CatalogItemType("ID", "NAME") VALUES (2, 'Jewelry') 3 | INSERT INTO CatalogItemType("ID", "NAME") VALUES (3, 'Shoes') 4 | INSERT INTO CatalogItem("ID", "NAME", "TYPE", "DESCRIPTION") VALUES (1, 'Minecraft Modding with Forge', 1, 'Book - Minecraft Modding with Forge') 5 | INSERT INTO CatalogItem("ID", "NAME", "TYPE", "DESCRIPTION") VALUES (2, 'Java EE 7 Essentials', 1, 'Book - Java EE 7 Essentials') 6 | INSERT INTO CatalogItem("ID", "NAME", "TYPE", "DESCRIPTION") VALUES (3, 'Java EE 6 Pocket Guide', 1, 'Book - Java EE 6 Pocket Guide') 7 | INSERT INTO CatalogItem("ID", "NAME", "TYPE", "DESCRIPTION") VALUES (4, 'Java EE 7 & HTML5 Enterprise Application Development', 1, 'Book - Java EE 7 & HTML5 Enterprise Application Development') 8 | INSERT INTO CatalogItem("ID", "NAME", "TYPE", "DESCRIPTION") VALUES (5, 'Wedding Band', 2, 'Jewelry - Wedding Band') 9 | INSERT INTO CatalogItem("ID", "NAME", "TYPE", "DESCRIPTION") VALUES (6, 'Bangles', 2, 'Jewelry - Bangles') 10 | INSERT INTO CatalogItem("ID", "NAME", "TYPE", "DESCRIPTION") VALUES (7, 'Necklace', 2, 'Jewelry - Necklace') 11 | INSERT INTO CatalogItem("ID", "NAME", "TYPE", "DESCRIPTION") VALUES (8, 'Earrings', 2, 'Jewelry - Earrings') 12 | INSERT INTO CatalogItem("ID", "NAME", "TYPE", "DESCRIPTION") VALUES (9, 'Mizuno Wave Sayonara', 3, 'Shoes - Mizuno Wave Sayonara') 13 | INSERT INTO CatalogItem("ID", "NAME", "TYPE", "DESCRIPTION") VALUES (10, 'Nike Free 5.0', 3, 'Shoes - Nike Free 5.0') 14 | INSERT INTO CatalogItem("ID", "NAME", "TYPE", "DESCRIPTION") VALUES (11, 'Salomon Men''s Quest 4D', 3, 'Shoes - Salomon Men''s Quest 4D') 15 | INSERT INTO CatalogItem("ID", "NAME", "TYPE", "DESCRIPTION") VALUES (12, 'New Balance Minimus', 3, 'Shoes - New Balance Minimus') 16 | -------------------------------------------------------------------------------- /microservice/catalog/src/main/resources/META-INF/persistence.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /microservice/catalog/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | snoop: 2 | applicationName: catalog 3 | applicationHome: http://localhost:8080/catalog/resources 4 | applicationServiceRoot: catalog 5 | serviceHost: 192.168.99.103:8081/snoop-service/ 6 | 7 | -------------------------------------------------------------------------------- /microservice/contracts/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.javaee7.wildfly.samples 6 | shoppingcart-msa 7 | 1.0-SNAPSHOT 8 | ../pom.xml 9 | 10 | 11 | org.javaee7.wildfly.samples 12 | contracts 13 | 1.0-SNAPSHOT 14 | jar 15 | 16 | 17 | contracts 18 | 19 | 20 | org.wildfly.plugins 21 | wildfly-maven-plugin 22 | 23 | true 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /microservice/contracts/src/main/resources/META-INF/contracts/main/cssLayout.css: -------------------------------------------------------------------------------- 1 | #top { 2 | position: relative; 3 | background-color: #036fab; 4 | color: white; 5 | padding: 5px; 6 | margin: 0px 0px 10px 0px; 7 | } 8 | 9 | #bottom { 10 | position: relative; 11 | background-color: #c2dfef; 12 | padding: 5px; 13 | margin: 10px 0px 0px 0px; 14 | } 15 | 16 | #left { 17 | float: left; 18 | background-color: #ece3a5; 19 | padding: 5px; 20 | width: 150px; 21 | } 22 | 23 | #right { 24 | float: right; 25 | background-color: #ece3a5; 26 | padding: 5px; 27 | width: 150px; 28 | } 29 | 30 | .center_content { 31 | position: relative; 32 | background-color: #dddddd; 33 | padding: 5px; 34 | } 35 | 36 | .left_content { 37 | background-color: #dddddd; 38 | padding: 5px; 39 | margin-left: 170px; 40 | } 41 | 42 | .right_content { 43 | background-color: #dddddd; 44 | padding: 5px; 45 | margin: 0px 170px 0px 170px; 46 | } 47 | 48 | #top a:link, #top a:visited { 49 | color: white; 50 | font-weight : bold; 51 | text-decoration: none; 52 | } 53 | 54 | #top a:link:hover, #top a:visited:hover { 55 | color: black; 56 | font-weight : bold; 57 | text-decoration : underline; 58 | } 59 | 60 | 61 | -------------------------------------------------------------------------------- /microservice/contracts/src/main/resources/META-INF/contracts/main/default.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: #ffffff; 3 | font-size: 12px; 4 | font-family: Verdana, "Verdana CE", Arial, "Arial CE", "Lucida Grande CE", lucida, "Helvetica CE", sans-serif; 5 | color: #000000; 6 | margin: 10px; 7 | } 8 | 9 | h1 { 10 | font-family: Arial, "Arial CE", "Lucida Grande CE", lucida, "Helvetica CE", sans-serif; 11 | border-bottom: 1px solid #AFAFAF; 12 | font-size: 16px; 13 | font-weight: bold; 14 | margin: 0px; 15 | padding: 0px; 16 | color: #D20005; 17 | } 18 | 19 | a:link, a:visited { 20 | color: #045491; 21 | font-weight : bold; 22 | text-decoration: none; 23 | } 24 | 25 | a:link:hover, a:visited:hover { 26 | color: #045491; 27 | font-weight : bold; 28 | text-decoration : underline; 29 | } 30 | -------------------------------------------------------------------------------- /microservice/contracts/src/main/resources/META-INF/contracts/main/javax.faces.contract.xml: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arun-gupta/microservices/0bd10e5af2fb70e38729f21d6c477b329ed9e401/microservice/contracts/src/main/resources/META-INF/contracts/main/javax.faces.contract.xml -------------------------------------------------------------------------------- /microservice/contracts/src/main/resources/META-INF/contracts/main/template.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | Java EE Shopping Cart (Microservice) 15 | 16 | 17 | 18 |
19 |

20 | Java EE Shopping Cart (Microservice)

21 |
22 |
23 |
24 | 25 | Create User

26 | Catalog

27 | Cart

28 | Payment

29 | 30 |

31 |
32 | Content 33 |
34 |
35 |
36 |
37 | 38 | -------------------------------------------------------------------------------- /microservice/docker/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM jboss/apiman-wildfly 2 | MAINTAINER Arun Gupta 3 | 4 | ADD microservice /opt/jboss/wildfly/microservice 5 | 6 | CMD ["/opt/jboss/wildfly/microservice/create-resources.sh"] -------------------------------------------------------------------------------- /microservice/docker/microservice/create-resources.sh: -------------------------------------------------------------------------------- 1 | JBOSS_HOME=/opt/jboss/wildfly 2 | JBOSS_CLI=$JBOSS_HOME/bin/jboss-cli.sh 3 | 4 | function wait_for_server() { 5 | until `$JBOSS_CLI -c ":read-attribute(name=server-state)" 2> /dev/null | grep -q running`; do 6 | sleep 1 7 | done 8 | } 9 | 10 | echo "=> Starting WildFly server" 11 | $JBOSS_HOME/bin/standalone.sh -b 0.0.0.0 -c standalone-apiman.xml & 12 | 13 | echo "=> Waiting for the server to boot" 14 | wait_for_server 15 | 16 | HOST=localhost 17 | PORT=8080 18 | 19 | # Create organization 20 | echo "Creating organization ..." 21 | curl --user admin:admin123! -H "Content-Type: application/json" -H "Accept: application/json" --data '{"name": "everest", "description": "Microservice Everest Organization"}' http://$HOST:$PORT/apiman/organizations/ 22 | 23 | # Create catalog service 24 | echo "Creating catalog service ..." 25 | curl --user admin:admin123! -H "Content-Type: application/json" -H "Accept: application/json" --data '{"name": "catalog", "description": "catalog service", "initialVersion": "1.0.0-SNAPSHOT"}' http://$HOST:$PORT/apiman/organizations/everest/services 26 | 27 | # Add catalog service URI 28 | echo "Adding catalog service URI ..." 29 | curl -v --user admin:admin123! -H "Content-Type: application/json" -H "Accept: application/json" -X PUT --data '{ "endpointType": "rest", "publicService": true, "endpoint": "http://localhost:8080/catalog/resources/catalog"}' http://$HOST:$PORT/apiman/organizations/everest/services/catalog/versions/1.0.0-SNAPSHOT 30 | 31 | # Create user service 32 | echo "Creating user service ..." 33 | curl --user admin:admin123! -H "Content-Type: application/json" -H "Accept: application/json" --data '{"name": "user", "description": "user service", "initialVersion": "1.0.0-SNAPSHOT"}' http://$HOST:$PORT/apiman/organizations/everest/services 34 | 35 | # Add user service URI 36 | echo "Adding user service URI ..." 37 | curl -v --user admin:admin123! -H "Content-Type: application/json" -H "Accept: application/json" -X PUT --data '{ "endpointType": "rest", "publicService": true, "endpoint": "http://localhost:8080/user/resources/user"}' http://$HOST:$PORT/apiman/organizations/everest/services/user/versions/1.0.0-SNAPSHOT 38 | 39 | # Create order service 40 | echo "Creating order service ..." 41 | curl --user admin:admin123! -H "Content-Type: application/json" -H "Accept: application/json" --data '{"name": "order", "description": "order service", "initialVersion": "1.0.0-SNAPSHOT"}' http://$HOST:$PORT/apiman/organizations/everest/services 42 | 43 | # Add order service URI 44 | echo "Adding order service URI ..." 45 | curl -v --user admin:admin123! -H "Content-Type: application/json" -H "Accept: application/json" -X PUT --data '{ "endpointType": "rest", "publicService": true, "endpoint": "http://localhost:8080/order/resources/order"}' http://$HOST:$PORT/apiman/organizations/everest/services/order/versions/1.0.0-SNAPSHOT 46 | 47 | # Get all services 48 | curl --user admin:admin123! -H "Accept: application/json" http://$HOST:$PORT/apiman/organizations/everest/services 49 | 50 | -------------------------------------------------------------------------------- /microservice/everest/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | org.javaee7.wildfly.samples 7 | shoppingcart-msa 8 | 1.0-SNAPSHOT 9 | ../pom.xml 10 | 11 | 12 | org.javaee7.wildfly.samples 13 | everest-web 14 | 1.0-SNAPSHOT 15 | war 16 | 17 | everest-web 18 | 19 | 20 | 21 | org.javaee7.wildfly.samples 22 | services 23 | 24 | 25 | org.javaee7.wildfly.samples 26 | contracts 27 | 28 | 29 | org.jboss.resteasy 30 | resteasy-client 31 | 32 | 33 | org.jboss.resteasy 34 | resteasy-jaxb-provider 35 | 36 | 37 | 38 | 39 | everest-web 40 | 41 | 42 | org.wildfly.plugins 43 | wildfly-maven-plugin 44 | 45 | false 46 | 47 | 48 | 49 | 50 | org.jolokia 51 | docker-maven-plugin 52 | 53 | 54 | 55 | everest-web 56 | arungupta/shoppingcart-web 57 | 58 | jboss/wildfly 59 | 60 | assembly.xml 61 | /opt/jboss/wildfly/standalone/deployments 62 | jboss:jboss:jboss 63 | 64 | 65 | 8080 66 | 67 | 68 | 69 | 70 | web.port:8080 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /microservice/everest/src/main/docker/assembly.xml: -------------------------------------------------------------------------------- 1 | 4 | order 5 | 6 | 7 | 8 | org.javaee7.wildfly.samples:everest-web 9 | 10 | everest.war 11 | 12 | 13 | -------------------------------------------------------------------------------- /microservice/everest/src/main/java/org/javaee7/wildfly/samples/everest/Resources.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.wildfly.samples.everest; 2 | 3 | import javax.enterprise.context.ApplicationScoped; 4 | import javax.enterprise.inject.Produces; 5 | import javax.inject.Inject; 6 | import org.javaee7.wildfly.samples.services.ZooKeeperServices; 7 | import org.javaee7.wildfly.samples.services.discovery.ServiceDiscovery; 8 | 9 | /** 10 | * @author arungupta 11 | */ 12 | @ApplicationScoped 13 | public class Resources { 14 | // @Inject @FixedServices ServiceDiscovery services; 15 | // @Inject @SnoopServices ServiceDiscovery services; 16 | @Inject @ZooKeeperServices ServiceDiscovery services; 17 | 18 | @Produces 19 | public ServiceDiscovery getService() { 20 | return services; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /microservice/everest/src/main/java/org/javaee7/wildfly/samples/everest/cart/Cart.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.wildfly.samples.everest.cart; 2 | 3 | import java.io.Serializable; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | import javax.annotation.PostConstruct; 7 | import javax.enterprise.context.SessionScoped; 8 | import javax.faces.context.FacesContext; 9 | import javax.faces.event.ActionEvent; 10 | import javax.inject.Inject; 11 | import javax.inject.Named; 12 | 13 | /** 14 | * @author arungupta 15 | */ 16 | @Named 17 | @SessionScoped 18 | public class Cart implements Serializable { 19 | private List items; 20 | 21 | @Inject CartItem currentCartItem; 22 | 23 | @PostConstruct 24 | private void init() { 25 | items = new ArrayList<>(); 26 | } 27 | 28 | public List getItems() { 29 | return items; 30 | } 31 | 32 | public void addItemToCart(ActionEvent event) { 33 | boolean exists = false; 34 | 35 | int itemId = Integer.valueOf(FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("itemId")); 36 | String itemName = (String)FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("itemName"); 37 | 38 | for (CartItem item : items) { 39 | if (itemId == item.getItemId()) { 40 | exists = true; 41 | CartItem cartItem = new CartItem(item.getItemId(), itemName, item.getItemCount() + currentCartItem.getItemCount()); 42 | items.remove(item); 43 | items.add(cartItem); 44 | } 45 | } 46 | if (!exists) { 47 | CartItem cartItem = new CartItem(itemId, itemName, currentCartItem.getItemCount()); 48 | items.add(cartItem); 49 | } 50 | } 51 | 52 | public void clearCart() { 53 | items.clear(); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /microservice/everest/src/main/java/org/javaee7/wildfly/samples/everest/cart/CartItem.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.wildfly.samples.everest.cart; 2 | 3 | import java.io.Serializable; 4 | import javax.enterprise.context.SessionScoped; 5 | import javax.inject.Named; 6 | 7 | /** 8 | * @author arungupta 9 | */ 10 | @Named 11 | @SessionScoped 12 | public class CartItem implements Serializable { 13 | private int itemId; 14 | private String itemName; 15 | private int itemCount; 16 | 17 | public CartItem() { } 18 | 19 | public CartItem(int itemId, String itemName, int itemCount) { 20 | this.itemId = itemId; 21 | this.itemName = itemName; 22 | this.itemCount = itemCount; 23 | } 24 | 25 | public int getItemId() { 26 | return itemId; 27 | } 28 | 29 | public void setItemId(int itemId) { 30 | this.itemId = itemId; 31 | } 32 | 33 | public int getItemCount() { 34 | return itemCount; 35 | } 36 | 37 | public void setItemCount(int itemCount) { 38 | this.itemCount = itemCount; 39 | } 40 | 41 | public String getItemName() { 42 | return itemName; 43 | } 44 | 45 | public void setName(String name) { 46 | this.itemName = name; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /microservice/everest/src/main/java/org/javaee7/wildfly/samples/everest/catalog/CatalogBean.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.wildfly.samples.everest.catalog; 2 | 3 | import java.io.Serializable; 4 | import java.io.StringReader; 5 | import javax.enterprise.context.SessionScoped; 6 | import javax.faces.context.FacesContext; 7 | import javax.inject.Inject; 8 | import javax.inject.Named; 9 | import javax.json.Json; 10 | import javax.json.JsonObject; 11 | import javax.ws.rs.client.Entity; 12 | import javax.ws.rs.core.Response; 13 | import org.javaee7.wildfly.samples.services.discovery.ServiceDiscovery; 14 | 15 | /** 16 | * @author arungupta 17 | */ 18 | @Named 19 | @SessionScoped 20 | public class CatalogBean implements Serializable { 21 | @Inject CatalogItem catalogItem; 22 | 23 | @Inject ServiceDiscovery services; 24 | 25 | String status; 26 | 27 | public void addCatalog() { 28 | Response response = services.getCatalogService().request().post(Entity.xml(catalogItem)); 29 | 30 | Response.StatusType statusInfo = response.getStatusInfo(); 31 | 32 | if (statusInfo.getStatusCode() == Response.Status.CREATED.getStatusCode()) 33 | status = "User added successfully"; 34 | else 35 | status = statusInfo.getReasonPhrase(); 36 | } 37 | 38 | public CatalogItem[] getAllItems() { 39 | return services.getCatalogService().register(CatalogItem.class).request().get(CatalogItem[].class); 40 | } 41 | 42 | public String catalogServiceEndpoint() { 43 | String itemId = FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("itemId"); 44 | 45 | String response = services.getCatalogService().path(itemId).request().get(String.class); 46 | 47 | JsonObject jsonObject = Json.createReader(new StringReader(response)).readObject(); 48 | catalogItem.setId(jsonObject.getInt("id")); 49 | catalogItem.setName(jsonObject.getString("name")); 50 | catalogItem.setDescription(jsonObject.getString("description")); 51 | 52 | return response; 53 | } 54 | 55 | public String getStatus() { 56 | return status; 57 | } 58 | 59 | public void setStatus(String status) { 60 | this.status = status; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /microservice/everest/src/main/java/org/javaee7/wildfly/samples/everest/catalog/CatalogItem.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.wildfly.samples.everest.catalog; 2 | 3 | import java.io.Serializable; 4 | import javax.enterprise.context.SessionScoped; 5 | import javax.inject.Named; 6 | import javax.xml.bind.annotation.XmlRootElement; 7 | 8 | /** 9 | * @author arungupta 10 | */ 11 | @Named 12 | @SessionScoped 13 | @XmlRootElement 14 | public class CatalogItem implements Serializable { 15 | private int id; 16 | private String name; 17 | private int type; 18 | private String description; 19 | 20 | public CatalogItem() { } 21 | 22 | public CatalogItem(String name, int type) { 23 | this.name = name; 24 | this.type = type; 25 | } 26 | 27 | public int getId() { 28 | return id; 29 | } 30 | 31 | public void setId(int id) { 32 | this.id = id; 33 | } 34 | 35 | public String getName() { 36 | return name; 37 | } 38 | 39 | public void setName(String name) { 40 | this.name = name; 41 | } 42 | 43 | public int getType() { 44 | return type; 45 | } 46 | 47 | public void setType(int type) { 48 | this.type = type; 49 | } 50 | 51 | public String getDescription() { 52 | return description; 53 | } 54 | 55 | public void setDescription(String description) { 56 | this.description = description; 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /microservice/everest/src/main/java/org/javaee7/wildfly/samples/everest/checkout/Order.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.wildfly.samples.everest.checkout; 2 | 3 | import java.io.Serializable; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | import javax.enterprise.context.SessionScoped; 7 | import javax.inject.Named; 8 | import javax.xml.bind.annotation.XmlRootElement; 9 | 10 | /** 11 | * @author arungupta 12 | */ 13 | @Named 14 | @SessionScoped 15 | @XmlRootElement 16 | public class Order implements Serializable { 17 | 18 | int orderId; 19 | List orderItems; 20 | 21 | public int getOrderId() { 22 | return orderId; 23 | } 24 | 25 | public void setOrderId(int orderId) { 26 | this.orderId = orderId; 27 | } 28 | 29 | public List getOrderItems() { 30 | if (null == orderItems) { 31 | orderItems = new ArrayList<>(); 32 | } 33 | return orderItems; 34 | } 35 | 36 | public void setOrderItems(List orderItems) { 37 | this.orderItems = orderItems; 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /microservice/everest/src/main/java/org/javaee7/wildfly/samples/everest/checkout/OrderBean.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.wildfly.samples.everest.checkout; 2 | 3 | import java.io.Serializable; 4 | import java.io.StringReader; 5 | import java.io.StringWriter; 6 | import java.util.List; 7 | import javax.enterprise.context.SessionScoped; 8 | import javax.inject.Inject; 9 | import javax.inject.Named; 10 | import javax.json.Json; 11 | import javax.json.JsonArray; 12 | import javax.json.JsonObject; 13 | import javax.json.JsonWriter; 14 | import javax.ws.rs.client.Entity; 15 | import javax.ws.rs.core.Response; 16 | import org.javaee7.wildfly.samples.everest.cart.Cart; 17 | import org.javaee7.wildfly.samples.everest.cart.CartItem; 18 | import org.javaee7.wildfly.samples.services.discovery.ServiceDiscovery; 19 | 20 | /** 21 | * @author arungupta 22 | */ 23 | @Named 24 | @SessionScoped 25 | public class OrderBean implements Serializable { 26 | 27 | @Inject 28 | Order order; 29 | 30 | @Inject 31 | Cart cart; 32 | 33 | String status; 34 | 35 | @Inject ServiceDiscovery services; 36 | 37 | public void saveOrder() { 38 | List cartItems = cart.getItems(); 39 | cartItems.stream().map((cartItem) -> { 40 | OrderItem orderItem = new OrderItem(); 41 | orderItem.itemId = cartItem.getItemId(); 42 | orderItem.itemCount = cartItem.getItemCount(); 43 | return orderItem; 44 | }).forEach((orderItem) -> { 45 | order.getOrderItems().add(orderItem); 46 | }); 47 | 48 | try { 49 | JsonArray orderItems = null; 50 | for (OrderItem orderItem : order.getOrderItems()) { 51 | orderItems = Json.createArrayBuilder() 52 | .add(Json.createObjectBuilder() 53 | .add("itemId", orderItem.getItemId()) 54 | .add("itemCount", orderItem.getItemCount())) 55 | .build(); 56 | } 57 | JsonObject jsonObject = Json.createObjectBuilder() 58 | // .add("orderId", order.getOrderId()) 59 | .add("orderItems", orderItems) 60 | .build(); 61 | StringWriter writer = new StringWriter(); 62 | try (JsonWriter w = Json.createWriter(writer)) { 63 | w.write(jsonObject); 64 | } 65 | 66 | Response response = services.getOrderService().request().post(Entity.json(writer.toString())); 67 | 68 | Response.StatusType statusInfo = response.getStatusInfo(); 69 | 70 | if (statusInfo.getFamily() == Response.Status.Family.SUCCESSFUL) { 71 | JsonObject jsonResponse = Json.createReader(new StringReader(response.readEntity(String.class))).readObject(); 72 | status = "Order successful, order number: " + jsonResponse.get("orderId");; 73 | } else { 74 | status = statusInfo.getReasonPhrase(); 75 | } 76 | 77 | cart.clearCart(); 78 | } catch (Exception e) { 79 | status = e.getLocalizedMessage(); 80 | } 81 | } 82 | 83 | public String getStatus() { 84 | return status; 85 | } 86 | 87 | public void setStatus(String status) { 88 | this.status = status; 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /microservice/everest/src/main/java/org/javaee7/wildfly/samples/everest/checkout/OrderItem.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.wildfly.samples.everest.checkout; 2 | 3 | import java.io.Serializable; 4 | import javax.enterprise.context.SessionScoped; 5 | import javax.inject.Named; 6 | import javax.xml.bind.annotation.XmlRootElement; 7 | 8 | /** 9 | * @author arungupta 10 | */ 11 | @Named 12 | @SessionScoped 13 | @XmlRootElement 14 | public class OrderItem implements Serializable { 15 | int itemId; 16 | int itemCount; 17 | 18 | public int getItemId() { 19 | return itemId; 20 | } 21 | 22 | public void setItemId(int itemId) { 23 | this.itemId = itemId; 24 | } 25 | 26 | public int getItemCount() { 27 | return itemCount; 28 | } 29 | 30 | public void setItemCount(int itemCount) { 31 | this.itemCount = itemCount; 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /microservice/everest/src/main/java/org/javaee7/wildfly/samples/everest/checkout/Shipping.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.wildfly.samples.everest.checkout; 2 | 3 | import java.io.Serializable; 4 | import javax.enterprise.context.SessionScoped; 5 | import javax.inject.Inject; 6 | import javax.inject.Named; 7 | import javax.persistence.EntityManager; 8 | import javax.persistence.PersistenceContext; 9 | //import org.javaee7.wildfly.samples.everest.uzer.Uzer; 10 | import org.javaee7.wildfly.samples.everest.uzer.UzerItem; 11 | 12 | /** 13 | * @author arungupta 14 | */ 15 | @Named 16 | @SessionScoped 17 | public class Shipping implements Serializable { 18 | 19 | // @PersistenceContext EntityManager em; 20 | 21 | // @Inject UzerItem uzer2; 22 | // String login; 23 | // 24 | // String name; 25 | // String address1; 26 | // String address2; 27 | // String city; 28 | // String zip; 29 | // String country; 30 | // String creditcard; 31 | 32 | public Shipping() { } 33 | 34 | public void findShippingDetail() { 35 | // System.out.println("LOGIN: " + uzer2.getLogin()); 36 | // Uzer uzer = em.createNamedQuery("Uzer.findByLogin", Uzer.class).setParameter("login", uzer2.getLogin()).getSingleResult(); 37 | // uzer.setUsername(uzer2.getUsername()); 38 | // uzer.setAddress1(uzer2.getAddress1()); 39 | // uzer.setAddress2(uzer2.getAddress2()); 40 | // uzer.setCity(uzer2.getCity()); 41 | // uzer.setZip(uzer2.getZip()); 42 | // uzer.setCountry(uzer2.getCountry()); 43 | // uzer.setCreditcard(uzer2.getCreditcard()); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /microservice/everest/src/main/java/org/javaee7/wildfly/samples/everest/uzer/UzerBean.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.wildfly.samples.everest.uzer; 2 | 3 | import java.io.Serializable; 4 | import java.io.StringReader; 5 | import java.io.StringWriter; 6 | import javax.enterprise.context.SessionScoped; 7 | import javax.inject.Inject; 8 | import javax.inject.Named; 9 | import javax.json.Json; 10 | import javax.json.JsonObject; 11 | import javax.json.JsonWriter; 12 | import javax.ws.rs.client.Entity; 13 | import javax.ws.rs.core.Response; 14 | import org.javaee7.wildfly.samples.services.discovery.ServiceDiscovery; 15 | 16 | /** 17 | * @author arungupta 18 | */ 19 | @Named 20 | @SessionScoped 21 | public class UzerBean implements Serializable { 22 | @Inject UzerItem uzerItem; 23 | 24 | @Inject ServiceDiscovery services; 25 | 26 | String status; 27 | 28 | public void addUzer() { 29 | 30 | JsonObject jsonObject = Json.createObjectBuilder() 31 | .add("login", uzerItem.getLogin()) 32 | .add("password", uzerItem.getPassword()) 33 | .add("username", uzerItem.getUsername()) 34 | .add("address1", uzerItem.getAddress1()) 35 | .add("address2", uzerItem.getAddress2()) 36 | .add("city", uzerItem.getCity()) 37 | .add("state", uzerItem.getState()) 38 | .add("country", uzerItem.getCountry()) 39 | .add("zip", uzerItem.getZip()) 40 | .add("creditcard", uzerItem.getCreditcard()) 41 | .build(); 42 | StringWriter w = new StringWriter(); 43 | try (JsonWriter writer = Json.createWriter(w)) { 44 | writer.write(jsonObject); 45 | } 46 | 47 | Response response = services.getUserService().request().post(Entity.xml(w.toString())); 48 | 49 | Response.StatusType statusInfo = response.getStatusInfo(); 50 | 51 | if (statusInfo.getFamily() == Response.Status.Family.SUCCESSFUL) { 52 | JsonObject jsonResponse = Json.createReader(new StringReader(response.readEntity(String.class))).readObject(); 53 | status = "User added successfully," + 54 | " login: " + jsonResponse.get("login") + 55 | " password: " + jsonResponse.get("password"); 56 | } else 57 | status = statusInfo.getReasonPhrase(); 58 | } 59 | 60 | public String getStatus() { 61 | return status; 62 | } 63 | 64 | public void setStatus(String status) { 65 | this.status = status; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /microservice/everest/src/main/java/org/javaee7/wildfly/samples/everest/uzer/UzerItem.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.wildfly.samples.everest.uzer; 2 | 3 | import java.io.Serializable; 4 | import javax.enterprise.context.SessionScoped; 5 | import javax.inject.Named; 6 | import javax.xml.bind.annotation.XmlRootElement; 7 | 8 | /** 9 | * @author arungupta 10 | */ 11 | @Named 12 | @SessionScoped 13 | @XmlRootElement 14 | public class UzerItem implements Serializable { 15 | private String login; 16 | private String password; 17 | private String username; 18 | private String address1; 19 | private String address2; 20 | private String city; 21 | private String state; 22 | private String zip; 23 | private String country; 24 | private String creditcard; 25 | 26 | public String getLogin() { 27 | return login; 28 | } 29 | 30 | public void setLogin(String login) { 31 | this.login = login; 32 | } 33 | 34 | public String getPassword() { 35 | return password; 36 | } 37 | 38 | public void setPassword(String password) { 39 | this.password = password; 40 | } 41 | 42 | public String getUsername() { 43 | return username; 44 | } 45 | 46 | public void setUsername(String username) { 47 | this.username = username; 48 | } 49 | 50 | public String getAddress1() { 51 | return address1; 52 | } 53 | 54 | public void setAddress1(String address1) { 55 | this.address1 = address1; 56 | } 57 | 58 | public String getAddress2() { 59 | return address2; 60 | } 61 | 62 | public void setAddress2(String address2) { 63 | this.address2 = address2; 64 | } 65 | 66 | public String getCity() { 67 | return city; 68 | } 69 | 70 | public void setCity(String city) { 71 | this.city = city; 72 | } 73 | 74 | public String getState() { 75 | return state; 76 | } 77 | 78 | public void setState(String state) { 79 | this.state = state; 80 | } 81 | 82 | public String getZip() { 83 | return zip; 84 | } 85 | 86 | public void setZip(String zip) { 87 | this.zip = zip; 88 | } 89 | 90 | public String getCountry() { 91 | return country; 92 | } 93 | 94 | public void setCountry(String country) { 95 | this.country = country; 96 | } 97 | 98 | public String getCreditcard() { 99 | return creditcard; 100 | } 101 | 102 | public void setCreditcard(String creditcard) { 103 | this.creditcard = creditcard; 104 | } 105 | 106 | } 107 | -------------------------------------------------------------------------------- /microservice/everest/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | javax.faces.PROJECT_STAGE 5 | Development 6 | 7 | 8 | Faces Servlet 9 | javax.faces.webapp.FacesServlet 10 | 1 11 | 12 | 13 | Faces Servlet 14 | /faces/* 15 | 16 | 17 | 18 | 30 19 | 20 | 21 | 22 | faces/index.xhtml 23 | 24 | 25 | -------------------------------------------------------------------------------- /microservice/everest/src/main/webapp/cart.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

Cart

15 | 16 | 17 | Item Name 18 | #{item.itemName} 19 | 20 | 21 | 22 | Item Count 23 | #{item.itemCount} 24 | 25 | 26 |

27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /microservice/everest/src/main/webapp/catalog-item.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

Catalog Item

15 | 16 | 17 | Name: #{catalogItem.name}

18 | Description: #{catalogItem.description}

19 | Quantity: 20 | 22 | 23 | 24 | 25 | 26 | 27 |

28 |

29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | -------------------------------------------------------------------------------- /microservice/everest/src/main/webapp/catalog.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

Catalog

15 | 16 | 17 | 18 | Item Name 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | Item Type 28 | #{item.type} 29 | 30 | 31 | 32 | Item Description 33 | #{item.description} 34 | 35 | 36 | 37 |
38 | 39 |
40 | 41 |
42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /microservice/everest/src/main/webapp/checkout.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 |

Shipping

16 | 17 | Login name:

18 | 19 | 20 |

21 | 22 | Name: #{uzerItem.username}

23 | Address Line 1: #{uzerItem.address1}

24 | Address Line 2: #{uzerItem.address2}

25 | City: #{uzerItem.city}

26 | State: #{uzerItem.state}

27 | Zip: #{uzerItem.zip}

28 | Country: #{uzerItem.country}

29 | Credit Card: #{uzerItem.creditcard}

30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | -------------------------------------------------------------------------------- /microservice/everest/src/main/webapp/confirm.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

Order Confirmation

15 | 16 | #{orderBean.status} 17 | 18 |

19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /microservice/everest/src/main/webapp/index.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

    15 |
  • Create User
  • 16 |
  • Add items from Catalog to Shopping Cart
  • 17 |
  • Review Shopping Cart
  • 18 |
  • Confirm/Add Shipping Address
  • 19 |
  • Add Payment Details
  • 20 |
21 | 22 | 23 | 24 | 25 |
26 | 27 |
28 |
29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /microservice/everest/src/main/webapp/user-status.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

Create User Status

15 | 16 | #{uzerBean.status} 17 |

18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /microservice/everest/src/main/webapp/user.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 |

Create User

15 | 16 | 17 | Login:

18 | Password:

19 | Name:

20 | Address Line 1:

21 | Address Line 2:

22 | City:

23 | State:

24 | Zip:

25 | Country:

26 | Credit Card:

27 | 28 |

29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /microservice/order/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | org.javaee7.wildfly.samples 7 | shoppingcart-msa 8 | 1.0-SNAPSHOT 9 | ../pom.xml 10 | 11 | 12 | org.javaee7.wildfly.samples 13 | order 14 | 1.0-SNAPSHOT 15 | war 16 | 17 | order 18 | 19 | 20 | 21 | org.javaee7.wildfly.samples 22 | services 23 | 24 | 25 | eu.agilejava 26 | snoop 27 | 28 | 29 | org.javaee7.wildfly.samples 30 | utils 31 | 32 | 33 | 34 | 35 | order 36 | 37 | 38 | org.wildfly.plugins 39 | wildfly-maven-plugin 40 | 41 | false 42 | 43 | 44 | 45 | 46 | org.jolokia 47 | docker-maven-plugin 48 | 49 | 50 | 51 | order 52 | arungupta/shoppingcart-order 53 | 54 | jboss/wildfly 55 | 56 | assembly.xml 57 | /opt/jboss/wildfly/standalone/deployments 58 | jboss:jboss:jboss 59 | 60 | 61 | 8080 62 | 63 | 64 | 65 | 66 | order.port:8080 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /microservice/order/src/main/docker/assembly.xml: -------------------------------------------------------------------------------- 1 | 4 | order 5 | 6 | 7 | 8 | org.javaee7.wildfly.samples:order 9 | 10 | order.war 11 | 12 | 13 | -------------------------------------------------------------------------------- /microservice/order/src/main/java/org/javaee7/wildfly/samples/everest/order/ApplicationConfig.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.wildfly.samples.everest.order; 2 | 3 | import javax.ws.rs.core.Application; 4 | 5 | /** 6 | * @author arungupta 7 | */ 8 | //@EnableSnoopClient 9 | @javax.ws.rs.ApplicationPath("resources") 10 | public class ApplicationConfig extends Application { 11 | } 12 | -------------------------------------------------------------------------------- /microservice/order/src/main/java/org/javaee7/wildfly/samples/everest/order/Order.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.wildfly.samples.everest.order; 2 | 3 | import java.io.Serializable; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | import javax.persistence.Column; 7 | import javax.persistence.ElementCollection; 8 | import javax.persistence.Entity; 9 | import javax.persistence.GeneratedValue; 10 | import javax.persistence.GenerationType; 11 | import javax.persistence.Id; 12 | import javax.persistence.Table; 13 | 14 | /** 15 | * @author arungupta 16 | */ 17 | @Entity 18 | @Table(name = "CART_ORDER") 19 | public class Order implements Serializable { 20 | 21 | @Id 22 | @GeneratedValue(strategy=GenerationType.AUTO) 23 | @Column 24 | int orderId; 25 | 26 | @ElementCollection 27 | List orderItems; 28 | 29 | public int getOrderId() { 30 | return orderId; 31 | } 32 | 33 | public void setOrderId(int orderId) { 34 | this.orderId = orderId; 35 | } 36 | 37 | public List getOrderItems() { 38 | if (null == orderItems) { 39 | orderItems = new ArrayList<>(); 40 | } 41 | return orderItems; 42 | } 43 | 44 | public void setOrderItems(List orderItems) { 45 | this.orderItems = orderItems; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /microservice/order/src/main/java/org/javaee7/wildfly/samples/everest/order/OrderItem.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.wildfly.samples.everest.order; 2 | 3 | import java.io.Serializable; 4 | import javax.persistence.Embeddable; 5 | 6 | /** 7 | * @author arungupta 8 | */ 9 | @Embeddable 10 | public class OrderItem implements Serializable { 11 | int itemId; 12 | int itemCount; 13 | 14 | public OrderItem() { 15 | } 16 | 17 | public OrderItem(int itemId, int itemCount) { 18 | this.itemId = itemId; 19 | this.itemCount = itemCount; 20 | } 21 | 22 | public int getItemId() { 23 | return itemId; 24 | } 25 | 26 | public void setItemId(int itemId) { 27 | this.itemId = itemId; 28 | } 29 | 30 | public int getItemCount() { 31 | return itemCount; 32 | } 33 | 34 | public void setItemCount(int itemCount) { 35 | this.itemCount = itemCount; 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /microservice/order/src/main/java/org/javaee7/wildfly/samples/everest/order/OrderREST.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.wildfly.samples.everest.order; 2 | 3 | import java.io.StringReader; 4 | import java.util.List; 5 | import javax.ejb.Stateless; 6 | import javax.json.Json; 7 | import javax.json.JsonArray; 8 | import javax.json.JsonObject; 9 | import javax.persistence.EntityManager; 10 | import javax.persistence.PersistenceContext; 11 | import javax.ws.rs.Consumes; 12 | import javax.ws.rs.DELETE; 13 | import javax.ws.rs.GET; 14 | import javax.ws.rs.POST; 15 | import javax.ws.rs.PUT; 16 | import javax.ws.rs.Path; 17 | import javax.ws.rs.PathParam; 18 | import javax.ws.rs.Produces; 19 | import javax.ws.rs.core.Response; 20 | 21 | /** 22 | * @author arungupta 23 | */ 24 | @Stateless 25 | @Path("order") 26 | public class OrderREST { 27 | @PersistenceContext 28 | private EntityManager em; 29 | 30 | @POST 31 | @Consumes({"application/xml", "application/json"}) 32 | public Response create(String entity) { 33 | JsonObject jsonObject = Json.createReader(new StringReader(entity)).readObject(); 34 | 35 | Order order = new Order(); 36 | // order.setOrderId(jsonObject.getInt("orderId")); 37 | JsonArray orderItems = jsonObject.getJsonArray("orderItems"); 38 | for (int i = 0; i< orderItems.size(); i++) { 39 | OrderItem orderItem = new OrderItem(orderItems.getJsonObject(i).getInt("itemId"), 40 | orderItems.getJsonObject(i).getInt("itemCount")); 41 | 42 | order.getOrderItems().add(orderItem); 43 | } 44 | 45 | em.persist(order); 46 | 47 | JsonObject response = Json.createObjectBuilder().add("orderId", order.getOrderId()).build(); 48 | 49 | return Response.ok(response).build(); 50 | } 51 | 52 | @PUT 53 | @Path("{id}") 54 | @Consumes({"application/xml", "application/json"}) 55 | public void edit(@PathParam("id") Integer id, Order entity) { 56 | em.merge(entity); 57 | } 58 | 59 | @DELETE 60 | @Path("{id}") 61 | public void remove(@PathParam("id") Integer id) { 62 | em.remove(find(id)); 63 | } 64 | 65 | @GET 66 | @Path("{id}") 67 | @Produces({"application/xml", "application/json"}) 68 | public Order find(@PathParam("id") Integer id) { 69 | return em.createNamedQuery("Uzer.findById", Order.class).setParameter("id", id).getSingleResult(); 70 | } 71 | 72 | @GET 73 | @Produces({"application/xml", "application/json"}) 74 | public List findAll() { 75 | return em.createNamedQuery("Uzer.findAll", Order.class).getResultList(); 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /microservice/order/src/main/java/org/javaee7/wildfly/samples/everest/order/OrderService.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.wildfly.samples.everest.order; 2 | 3 | import javax.annotation.PostConstruct; 4 | import javax.annotation.PreDestroy; 5 | import javax.ejb.Singleton; 6 | import javax.ejb.Startup; 7 | import javax.inject.Inject; 8 | import org.javaee7.wildfly.samples.everest.utils.WildFlyUtil; 9 | import org.javaee7.wildfly.samples.services.ZooKeeperServices; 10 | import org.javaee7.wildfly.samples.services.registration.ServiceRegistry; 11 | 12 | /** 13 | * @author arungupta 14 | */ 15 | @Startup 16 | @Singleton 17 | public class OrderService { 18 | // @Inject @FixedServices ServiceRegistry services; 19 | // @Inject @SnoopServices ServiceRegistry services; 20 | @Inject @ZooKeeperServices ServiceRegistry services; 21 | 22 | // private static final String endpointURI = "http://localhost:8080/order/resources/order"; 23 | // private final String endpointURI = "http://" + serverName + ":" + serverPort + "/order/resources/order"; 24 | private final String endpointURI = "http://" + WildFlyUtil.getHostName()+ ":" + WildFlyUtil.getHostPort() + "/order/resources/order"; 25 | private static final String serviceName = "order"; 26 | 27 | @PostConstruct 28 | public void registerService() { 29 | services.registerService(serviceName, endpointURI); 30 | } 31 | 32 | @PreDestroy 33 | public void unregisterService() { 34 | services.unregisterService(serviceName, endpointURI); 35 | } 36 | } 37 | -------------------------------------------------------------------------------- /microservice/order/src/main/resources/META-INF/persistence.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /microservice/order/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | snoop: 2 | applicationName: order 3 | applicationHome: http://localhost:8080/order/resources 4 | applicationServiceRoot: order 5 | serviceHost: 192.168.99.103:8081/snoop-service/ 6 | -------------------------------------------------------------------------------- /microservice/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.javaee7.wildfly.samples 6 | shoppingcart-msa 7 | 1.0-SNAPSHOT 8 | 9 | pom 10 | 11 | Shopping Cart Microservice 12 | 13 | 14 | 1.1.8.Final 15 | 4.12 16 | 8.2.0.Final 17 | 1.0.0.Alpha1 18 | 3.0.11.Final 19 | 1.0.0 20 | 2.8.0 21 | UTF-8 22 | 1.8 23 | 1.8 24 | 192.168.99.100 25 | 26 | 27 | 28 | 29 | 30 | javax 31 | javaee-api 32 | 7.0 33 | provided 34 | 35 | 36 | 37 | org.jboss.resteasy 38 | resteasy-client 39 | ${version.resteasy} 40 | provided 41 | 42 | 43 | 44 | org.jboss.resteasy 45 | resteasy-jaxb-provider 46 | ${version.resteasy} 47 | provided 48 | 49 | 50 | 51 | org.apache.curator 52 | curator-framework 53 | ${version.curator} 54 | 55 | 56 | io.netty 57 | netty 58 | 59 | 60 | 61 | 62 | 63 | eu.agilejava 64 | snoop 65 | ${version.snoop} 66 | 67 | 68 | 69 | eu.agilejava 70 | snoop-client 71 | ${version.snoop} 72 | 73 | 74 | 75 | org.javaee7.wildfly.samples 76 | utils 77 | ${project.version} 78 | 79 | 80 | 81 | org.javaee7.wildfly.samples 82 | contracts 83 | ${project.version} 84 | 85 | 86 | 87 | org.javaee7.wildfly.samples 88 | services 89 | ${project.version} 90 | 91 | 92 | 93 | org.jboss.arquillian.core 94 | arquillian-core-api 95 | ${version.arquillian} 96 | test 97 | 98 | 99 | 100 | org.jboss.arquillian.core 101 | arquillian-core-impl-base 102 | ${version.arquillian} 103 | test 104 | 105 | 106 | 107 | org.jboss.arquillian.junit 108 | arquillian-junit-core 109 | ${version.arquillian} 110 | test 111 | 112 | 113 | 114 | org.jboss.arquillian.junit 115 | arquillian-junit-container 116 | ${version.arquillian} 117 | test 118 | 119 | 120 | 121 | org.wildfly 122 | wildfly-arquillian-container-embedded 123 | ${version.wildfly.server} 124 | test 125 | 126 | 127 | 128 | org.wildfly 129 | wildfly-embedded 130 | ${version.wildfly.server} 131 | test 132 | 133 | 134 | 135 | org.wildfly 136 | wildfly-arquillian-protocol-jmx 137 | ${version.wildfly.server} 138 | test 139 | 140 | 141 | 142 | junit 143 | junit 144 | ${version.junit} 145 | test 146 | 147 | 148 | 149 | 150 | 151 | 152 | javax 153 | javaee-api 154 | provided 155 | 156 | 157 | 158 | 159 | utils 160 | contracts 161 | services 162 | catalog 163 | user 164 | order 165 | everest 166 | 167 | 168 | 169 | 170 | 171 | 172 | org.apache.maven.plugins 173 | maven-compiler-plugin 174 | 2.3.2 175 | 176 | 1.8 177 | 1.8 178 | 179 | 180 | 181 | org.wildfly.plugins 182 | wildfly-maven-plugin 183 | 1.1.0.Alpha2 184 | 185 | 186 | org.apache.maven.plugins 187 | maven-war-plugin 188 | 2.6 189 | 190 | false 191 | 192 | 193 | 194 | org.jolokia 195 | docker-maven-plugin 196 | 0.13.3 197 | 198 | 199 | org.apache.maven.plugins 200 | maven-surefire-plugin 201 | 2.18.1 202 | 203 | 204 | 205 | 206 | 207 | org.apache.maven.plugins 208 | maven-compiler-plugin 209 | 210 | 211 | org.apache.maven.plugins 212 | maven-war-plugin 213 | 214 | 215 | org.apache.maven.plugins 216 | maven-surefire-plugin 217 | 218 | true 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | docker 227 | 228 | 229 | 230 | org.jolokia 231 | docker-maven-plugin 232 | 233 | 234 | docker:build 235 | package 236 | 237 | build 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | /opt/jboss/wildfly/bin/standalone.sh 246 | -b 247 | 127.0.0.1 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | docker:start 257 | install 258 | 259 | start 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | wildfly 269 | 270 | 271 | 272 | org.wildfly.plugins 273 | wildfly-maven-plugin 274 | 275 | true 276 | 277 | 278 | 279 | install 280 | 281 | deploy 282 | 283 | 284 | 285 | 286 | 287 | 288 | 289 | 290 | test 291 | 292 | 293 | 294 | org.apache.maven.plugins 295 | maven-dependency-plugin 296 | 2.8 297 | 298 | 299 | unpack 300 | process-test-classes 301 | 302 | unpack 303 | 304 | 305 | 306 | 307 | org.wildfly 308 | wildfly-dist 309 | 8.2.0.Final 310 | zip 311 | false 312 | target 313 | 314 | 315 | 316 | 317 | 318 | 319 | 320 | org.apache.maven.plugins 321 | maven-surefire-plugin 322 | 2.18.1 323 | 324 | 325 | always 326 | 327 | **/TestAll.java 328 | 329 | 330 | org.jboss.logmanager.LogManager 331 | ${project.basedir}/target/wildfly-8.2.0.Final 332 | ${project.basedir}/target/wildfly-8.2.0.Final/modules 333 | 334 | false 335 | 336 | 337 | 338 | 339 | 340 | 341 | 342 | 343 | -------------------------------------------------------------------------------- /microservice/services/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.javaee7.wildfly.samples 6 | shoppingcart-msa 7 | 1.0-SNAPSHOT 8 | ../pom.xml 9 | 10 | 11 | services 12 | jar 13 | services 14 | 15 | 16 | 17 | org.apache.curator 18 | curator-framework 19 | 20 | 21 | 22 | eu.agilejava 23 | snoop-client 24 | 25 | 26 | 27 | 28 | services 29 | 30 | -------------------------------------------------------------------------------- /microservice/services/src/main/java/org/javaee7/wildfly/samples/services/FixedServices.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.wildfly.samples.services; 2 | 3 | import static java.lang.annotation.ElementType.FIELD; 4 | import static java.lang.annotation.ElementType.METHOD; 5 | import static java.lang.annotation.ElementType.PARAMETER; 6 | import static java.lang.annotation.ElementType.TYPE; 7 | import java.lang.annotation.Retention; 8 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 9 | import java.lang.annotation.Target; 10 | import javax.inject.Qualifier; 11 | 12 | /** 13 | * @author arungupta 14 | */ 15 | @Qualifier 16 | @Retention(RUNTIME) 17 | @Target({METHOD, FIELD, PARAMETER, TYPE}) 18 | public @interface FixedServices { 19 | } 20 | -------------------------------------------------------------------------------- /microservice/services/src/main/java/org/javaee7/wildfly/samples/services/SnoopServices.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.wildfly.samples.services; 2 | 3 | import static java.lang.annotation.ElementType.FIELD; 4 | import static java.lang.annotation.ElementType.METHOD; 5 | import static java.lang.annotation.ElementType.PARAMETER; 6 | import static java.lang.annotation.ElementType.TYPE; 7 | import java.lang.annotation.Retention; 8 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 9 | import java.lang.annotation.Target; 10 | import javax.inject.Qualifier; 11 | 12 | /** 13 | * 14 | * @author Ivar Grimstad (ivar.grimstad@gmail.com) 15 | */ 16 | @Qualifier 17 | @Retention(RUNTIME) 18 | @Target({METHOD, FIELD, PARAMETER, TYPE}) 19 | public @interface SnoopServices { 20 | } 21 | -------------------------------------------------------------------------------- /microservice/services/src/main/java/org/javaee7/wildfly/samples/services/ZooKeeperServices.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.wildfly.samples.services; 2 | 3 | import static java.lang.annotation.ElementType.FIELD; 4 | import static java.lang.annotation.ElementType.METHOD; 5 | import static java.lang.annotation.ElementType.PARAMETER; 6 | import static java.lang.annotation.ElementType.TYPE; 7 | import java.lang.annotation.Retention; 8 | import static java.lang.annotation.RetentionPolicy.RUNTIME; 9 | import java.lang.annotation.Target; 10 | import javax.inject.Qualifier; 11 | 12 | /** 13 | * @author arungupta 14 | */ 15 | @Qualifier 16 | @Retention(RUNTIME) 17 | @Target({METHOD, FIELD, PARAMETER, TYPE}) 18 | public @interface ZooKeeperServices { 19 | } 20 | -------------------------------------------------------------------------------- /microservice/services/src/main/java/org/javaee7/wildfly/samples/services/discovery/ServiceDiscovery.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.wildfly.samples.services.discovery; 2 | 3 | import java.net.URI; 4 | import javax.ws.rs.client.ClientBuilder; 5 | import javax.ws.rs.client.WebTarget; 6 | 7 | /** 8 | * @author arungupta 9 | */ 10 | public abstract class ServiceDiscovery { 11 | 12 | private WebTarget userService; 13 | private WebTarget catalogService; 14 | private WebTarget orderService; 15 | 16 | public abstract String getUserServiceURI(); 17 | 18 | public abstract String getCatalogServiceURI(); 19 | 20 | public abstract String getOrderServiceURI(); 21 | 22 | public WebTarget getUserService() { 23 | if (null == userService) { 24 | userService = ClientBuilder 25 | .newClient() 26 | .target(URI.create(getUserServiceURI())); 27 | } 28 | 29 | return userService; 30 | } 31 | 32 | public WebTarget getCatalogService() { 33 | if (null == catalogService) { 34 | catalogService = ClientBuilder 35 | .newClient() 36 | .target(URI.create(getCatalogServiceURI())); 37 | 38 | } 39 | 40 | return catalogService; 41 | } 42 | 43 | public WebTarget getOrderService() { 44 | if (null == orderService) { 45 | orderService = ClientBuilder 46 | .newClient() 47 | .target(URI.create(getOrderServiceURI())); 48 | 49 | } 50 | 51 | return orderService; 52 | } 53 | 54 | } 55 | -------------------------------------------------------------------------------- /microservice/services/src/main/java/org/javaee7/wildfly/samples/services/fixed/FixedServiceDiscovery.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.wildfly.samples.services.fixed; 2 | 3 | import javax.enterprise.context.ApplicationScoped; 4 | import javax.inject.Inject; 5 | import org.javaee7.wildfly.samples.services.discovery.ServiceDiscovery; 6 | import org.javaee7.wildfly.samples.services.FixedServices; 7 | import org.javaee7.wildfly.samples.services.registration.ServiceRegistry; 8 | 9 | /** 10 | * @author arungupta 11 | */ 12 | @FixedServices 13 | @ApplicationScoped 14 | public class FixedServiceDiscovery extends ServiceDiscovery { 15 | 16 | @Inject 17 | @FixedServices 18 | ServiceRegistry services; 19 | 20 | @Override 21 | public String getUserServiceURI() { 22 | return services.discoverServiceURI("user"); 23 | } 24 | 25 | @Override 26 | public String getCatalogServiceURI() { 27 | return services.discoverServiceURI("catalog"); 28 | } 29 | 30 | @Override 31 | public String getOrderServiceURI() { 32 | return services.discoverServiceURI("order"); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /microservice/services/src/main/java/org/javaee7/wildfly/samples/services/fixed/FixedServiceRegistry.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.wildfly.samples.services.fixed; 2 | 3 | import java.io.IOException; 4 | import java.nio.file.Files; 5 | import java.nio.file.Path; 6 | import java.nio.file.Paths; 7 | import java.nio.file.StandardOpenOption; 8 | import java.util.concurrent.ConcurrentHashMap; 9 | import javax.annotation.PostConstruct; 10 | import javax.enterprise.context.ApplicationScoped; 11 | import javax.inject.Inject; 12 | import org.javaee7.wildfly.samples.services.FixedServices; 13 | import org.javaee7.wildfly.samples.services.registration.ServiceRegistry; 14 | 15 | /** 16 | * @author arungupta 17 | */ 18 | @FixedServices 19 | @ApplicationScoped 20 | public class FixedServiceRegistry implements ServiceRegistry { 21 | 22 | ConcurrentHashMap serviceNameToURI = new ConcurrentHashMap<>(); 23 | Path path; 24 | 25 | @Inject 26 | public FixedServiceRegistry() { 27 | } 28 | 29 | @PostConstruct 30 | public void init() { 31 | try { 32 | path = Paths.get(System.getProperty("java.io.tmpdir") + "service_registry"); 33 | System.out.println("#####################: " + path); 34 | if (!Files.exists(path)) { 35 | Files.createFile(path); 36 | } 37 | // Workaround until https://github.com/arun-gupta/microservices/issues/31 is fixed 38 | } catch (IOException ex) { 39 | throw new RuntimeException(ex); 40 | } 41 | // serviceNameToURI.put("catalog", "http://localhost:8080/catalog/resources/catalog"); 42 | // serviceNameToURI.put("user", "http://localhost:8080/user/resources/user"); 43 | // serviceNameToURI.put("order", "http://localhost:8080/order/resources/order"); 44 | } 45 | 46 | @Override 47 | public void registerService(String name, String uri) { 48 | reloadMap(); 49 | serviceNameToURI.put(name, uri); 50 | writeMap(); 51 | } 52 | 53 | @Override 54 | public void unregisterService(String name, String uri) { 55 | if (serviceNameToURI.values().contains(name)) { 56 | serviceNameToURI.remove(name); 57 | } 58 | writeMap(); 59 | } 60 | 61 | private void reloadMap() { 62 | if (!Files.exists(path)) { 63 | return; 64 | } 65 | 66 | try { 67 | Files.readAllLines(path).stream().forEach((line) -> { 68 | System.out.println("Adding: " + line.split("=")[0] + line.split("=")[1]); 69 | serviceNameToURI.put(line.split("=")[0], line.split("=")[1]); 70 | }); 71 | } catch (IOException ex) { 72 | throw new RuntimeException(ex); 73 | } 74 | System.out.println("******************************"); 75 | serviceNameToURI.forEach((k, v) -> System.out.println(k + "=" + v)); 76 | System.out.println("******************************"); 77 | } 78 | 79 | @Override 80 | public String discoverServiceURI(String name) { 81 | if (serviceNameToURI.keySet().contains(name)) { 82 | return serviceNameToURI.get(name); 83 | } 84 | 85 | throw new RuntimeException("Service " + name + " not found"); 86 | } 87 | 88 | private void writeMap() { 89 | // Files.write(path, "".getBytes(), StandardOpenOption.TRUNCATE_EXISTING); 90 | serviceNameToURI.forEach((k, v) -> { 91 | try { 92 | Files.write(path, (k + "=" + v + "\n").getBytes(), StandardOpenOption.APPEND); 93 | } catch (IOException ex) { 94 | throw new RuntimeException(ex); 95 | } 96 | }); 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /microservice/services/src/main/java/org/javaee7/wildfly/samples/services/registration/ServiceRegistry.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.wildfly.samples.services.registration; 2 | 3 | /** 4 | * @author arungupta 5 | */ 6 | public interface ServiceRegistry { 7 | public void registerService(String name, String uri); 8 | 9 | public void unregisterService(String name, String uri); 10 | 11 | public String discoverServiceURI(String name); 12 | } 13 | -------------------------------------------------------------------------------- /microservice/services/src/main/java/org/javaee7/wildfly/samples/services/snoop/SnoopServiceDiscovery.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.wildfly.samples.services.snoop; 2 | 3 | import javax.enterprise.context.ApplicationScoped; 4 | import javax.inject.Inject; 5 | import org.javaee7.wildfly.samples.services.discovery.ServiceDiscovery; 6 | import org.javaee7.wildfly.samples.services.registration.ServiceRegistry; 7 | import org.javaee7.wildfly.samples.services.SnoopServices; 8 | 9 | /** 10 | * 11 | * @author Ivar Grimstad (ivar.grimstad@gmail.com) 12 | */ 13 | @SnoopServices 14 | @ApplicationScoped 15 | public class SnoopServiceDiscovery extends ServiceDiscovery { 16 | 17 | @Inject 18 | @SnoopServices 19 | private ServiceRegistry services; 20 | 21 | @Override 22 | public String getUserServiceURI() { 23 | return services.discoverServiceURI("user"); 24 | } 25 | 26 | @Override 27 | public String getCatalogServiceURI() { 28 | return services.discoverServiceURI("catalog"); 29 | } 30 | 31 | @Override 32 | public String getOrderServiceURI() { 33 | return services.discoverServiceURI("order"); 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /microservice/services/src/main/java/org/javaee7/wildfly/samples/services/snoop/SnoopServiceRegistry.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.wildfly.samples.services.snoop; 2 | 3 | import eu.agilejava.snoop.annotation.Snoop; 4 | import eu.agilejava.snoop.client.SnoopDiscoveryClient; 5 | import java.util.HashMap; 6 | import java.util.Map; 7 | import java.util.Optional; 8 | import java.util.logging.Logger; 9 | import javax.annotation.PostConstruct; 10 | import javax.enterprise.context.ApplicationScoped; 11 | import javax.inject.Inject; 12 | import org.javaee7.wildfly.samples.services.registration.ServiceRegistry; 13 | import org.javaee7.wildfly.samples.services.SnoopServices; 14 | 15 | /** 16 | * @author Ivar Grimstad (ivar.grimstad@gmail.com) 17 | */ 18 | @SnoopServices 19 | @ApplicationScoped 20 | public class SnoopServiceRegistry implements ServiceRegistry { 21 | 22 | private static final Logger LOGGER = Logger.getLogger(SnoopServiceRegistry.class.getName()); 23 | 24 | @Inject 25 | @Snoop(applicationName = "user") 26 | private SnoopDiscoveryClient userService; 27 | 28 | @Inject 29 | @Snoop(applicationName = "catalog") 30 | private SnoopDiscoveryClient catalogService; 31 | 32 | @Inject 33 | @Snoop(applicationName = "order") 34 | private SnoopDiscoveryClient orderService; 35 | 36 | private final Map services = new HashMap<>(); 37 | 38 | @Override 39 | public void registerService(String name, String uri) { 40 | // noop, handled by snoop 41 | } 42 | 43 | @Override 44 | public void unregisterService(String name, String uri) { 45 | // noop, handled by snoop 46 | } 47 | 48 | @Override 49 | public String discoverServiceURI(String name) { 50 | final String endpoint = Optional.ofNullable(services.get(name).getServiceRoot()) 51 | .orElseThrow(RuntimeException::new) 52 | .getUri() 53 | .toString(); 54 | 55 | LOGGER.config(() -> "Returning service endpoint for '" + name + "': " + endpoint); 56 | return endpoint; 57 | } 58 | 59 | @PostConstruct 60 | public void init() { 61 | services.put("user", userService); 62 | services.put("catalog", catalogService); 63 | services.put("order", orderService); 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /microservice/services/src/main/java/org/javaee7/wildfly/samples/services/zookeeper/ZooKeeperServiceDiscovery.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.wildfly.samples.services.zookeeper; 2 | 3 | import javax.enterprise.context.ApplicationScoped; 4 | import javax.inject.Inject; 5 | import org.javaee7.wildfly.samples.services.discovery.ServiceDiscovery; 6 | import org.javaee7.wildfly.samples.services.registration.ServiceRegistry; 7 | import org.javaee7.wildfly.samples.services.ZooKeeperServices; 8 | 9 | /** 10 | * @author arungupta 11 | */ 12 | @ZooKeeperServices 13 | @ApplicationScoped 14 | public class ZooKeeperServiceDiscovery extends ServiceDiscovery { 15 | 16 | @Inject 17 | @ZooKeeperServices 18 | ServiceRegistry services; 19 | 20 | @Override 21 | public String getUserServiceURI() { 22 | return services.discoverServiceURI("user"); 23 | } 24 | 25 | @Override 26 | public String getCatalogServiceURI() { 27 | return services.discoverServiceURI("catalog"); 28 | } 29 | 30 | @Override 31 | public String getOrderServiceURI() { 32 | return services.discoverServiceURI("order"); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /microservice/services/src/main/java/org/javaee7/wildfly/samples/services/zookeeper/ZooKeeperServiceRegistry.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.wildfly.samples.services.zookeeper; 2 | 3 | import java.io.IOException; 4 | import java.util.List; 5 | import java.util.Properties; 6 | import java.util.concurrent.ConcurrentHashMap; 7 | import javax.enterprise.context.ApplicationScoped; 8 | import javax.inject.Inject; 9 | import org.apache.curator.framework.CuratorFramework; 10 | import org.apache.curator.framework.CuratorFrameworkFactory; 11 | import org.apache.curator.retry.RetryNTimes; 12 | import org.apache.curator.utils.ZKPaths; 13 | import org.apache.zookeeper.CreateMode; 14 | import org.javaee7.wildfly.samples.services.registration.ServiceRegistry; 15 | import org.javaee7.wildfly.samples.services.ZooKeeperServices; 16 | 17 | /** 18 | * @author arungupta 19 | */ 20 | @ZooKeeperServices 21 | @ApplicationScoped 22 | public class ZooKeeperServiceRegistry implements ServiceRegistry { 23 | 24 | private final CuratorFramework curatorFramework; 25 | private final ConcurrentHashMap uriToZnodePath; 26 | 27 | @Inject 28 | public ZooKeeperServiceRegistry() { 29 | try { 30 | Properties props = new Properties(); 31 | props.load(this.getClass().getResourceAsStream("/zookeeper.properties")); 32 | 33 | curatorFramework = CuratorFrameworkFactory 34 | .newClient(props.getProperty("host") 35 | + ":" 36 | + props.getProperty("port"), new RetryNTimes(5, 1000)); 37 | curatorFramework.start(); 38 | uriToZnodePath = new ConcurrentHashMap<>(); 39 | } catch (IOException ex) { 40 | throw new RuntimeException(ex.getLocalizedMessage()); 41 | } 42 | } 43 | 44 | @Override 45 | public void registerService(String name, String uri) { 46 | try { 47 | String znode = "/services/" + name; 48 | 49 | if (curatorFramework.checkExists().forPath(znode) == null) { 50 | curatorFramework.create().creatingParentsIfNeeded().forPath(znode); 51 | } 52 | 53 | String znodePath = curatorFramework 54 | .create() 55 | .withMode(CreateMode.EPHEMERAL_SEQUENTIAL) 56 | .forPath(znode+"/_", uri.getBytes()); 57 | 58 | uriToZnodePath.put(uri, znodePath); 59 | } catch (Exception ex) { 60 | throw new RuntimeException("Could not register service \"" 61 | + name 62 | + "\", with URI \"" + uri + "\": " + ex.getLocalizedMessage()); 63 | } 64 | } 65 | 66 | @Override 67 | public void unregisterService(String name, String uri) { 68 | try { 69 | if (uriToZnodePath.contains(uri)) { 70 | curatorFramework.delete().forPath(uriToZnodePath.get(uri)); 71 | } 72 | } catch (Exception ex) { 73 | throw new RuntimeException("Could not unregister service \"" 74 | + name 75 | + "\", with URI \"" + uri + "\": " + ex.getLocalizedMessage()); 76 | } 77 | } 78 | 79 | @Override 80 | public String discoverServiceURI(String name) { 81 | try { 82 | String znode = "/services/" + name; 83 | 84 | List uris = curatorFramework.getChildren().forPath(znode); 85 | return new String(curatorFramework.getData().forPath(ZKPaths.makePath(znode, uris.get(0)))); 86 | } catch (Exception ex) { 87 | throw new RuntimeException("Service \"" + name + "\" not found: " + ex.getLocalizedMessage()); 88 | } 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /microservice/services/src/main/resources/META-INF/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 6 | 7 | -------------------------------------------------------------------------------- /microservice/services/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | snoop: 2 | serviceHost: 192.168.99.103:8081/snoop-service/ 3 | -------------------------------------------------------------------------------- /microservice/services/src/main/resources/zookeeper.properties: -------------------------------------------------------------------------------- 1 | host=192.168.99.100 2 | port=2181 -------------------------------------------------------------------------------- /microservice/user/nb-configuration.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 9 | 10 | 16 | 1.7-web 17 | WildFly 18 | Facelets 19 | ide 20 | 21 | 22 | -------------------------------------------------------------------------------- /microservice/user/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | 6 | org.javaee7.wildfly.samples 7 | shoppingcart-msa 8 | 1.0-SNAPSHOT 9 | ../pom.xml 10 | 11 | 12 | org.javaee7.wildfly.samples 13 | user 14 | 1.0-SNAPSHOT 15 | war 16 | 17 | user 18 | 19 | 20 | 21 | org.javaee7.wildfly.samples 22 | services 23 | 24 | 25 | eu.agilejava 26 | snoop 27 | 28 | 29 | org.javaee7.wildfly.samples 30 | utils 31 | 32 | 33 | 34 | 35 | user 36 | 37 | 38 | org.wildfly.plugins 39 | wildfly-maven-plugin 40 | 41 | false 42 | 43 | 44 | 45 | 46 | org.jolokia 47 | docker-maven-plugin 48 | 49 | 50 | 51 | user 52 | arungupta/shoppingcart-user 53 | 54 | jboss/wildfly 55 | 56 | assembly.xml 57 | /opt/jboss/wildfly/standalone/deployments 58 | jboss:jboss:jboss 59 | 60 | 61 | 8080 62 | 63 | 64 | 65 | 66 | user.port:8080 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | -------------------------------------------------------------------------------- /microservice/user/src/main/docker/assembly.xml: -------------------------------------------------------------------------------- 1 | 4 | user 5 | 6 | 7 | 8 | org.javaee7.wildfly.samples:user 9 | 10 | user.war 11 | 12 | 13 | -------------------------------------------------------------------------------- /microservice/user/src/main/java/org/javaee7/wildfly/samples/everest/uzer/ApplicationConfig.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.wildfly.samples.everest.uzer; 2 | 3 | import javax.ws.rs.core.Application; 4 | 5 | /** 6 | * @author arungupta 7 | */ 8 | //@EnableSnoopClient 9 | @javax.ws.rs.ApplicationPath("resources") 10 | public class ApplicationConfig extends Application { 11 | } 12 | -------------------------------------------------------------------------------- /microservice/user/src/main/java/org/javaee7/wildfly/samples/everest/uzer/UserREST.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.wildfly.samples.everest.uzer; 2 | 3 | import java.io.StringReader; 4 | import java.util.List; 5 | import javax.ejb.Stateless; 6 | import javax.json.Json; 7 | import javax.json.JsonObject; 8 | import javax.persistence.EntityManager; 9 | import javax.persistence.PersistenceContext; 10 | import javax.ws.rs.Consumes; 11 | import javax.ws.rs.DELETE; 12 | import javax.ws.rs.GET; 13 | import javax.ws.rs.POST; 14 | import javax.ws.rs.PUT; 15 | import javax.ws.rs.Path; 16 | import javax.ws.rs.PathParam; 17 | import javax.ws.rs.Produces; 18 | import javax.ws.rs.core.Response; 19 | 20 | /** 21 | * @author arungupta 22 | */ 23 | @Stateless 24 | @Path("user") 25 | public class UserREST { 26 | @PersistenceContext 27 | private EntityManager em; 28 | 29 | @POST 30 | @Consumes({"application/xml", "application/json"}) 31 | public Response create(String entity) { 32 | JsonObject jsonObject = Json.createReader(new StringReader(entity)).readObject(); 33 | 34 | Uzer uzer = new Uzer(); 35 | uzer.setLogin(jsonObject.getString("login")); 36 | uzer.setPassword(jsonObject.getString("password")); 37 | uzer.setUsername(jsonObject.getString("username")); 38 | uzer.setAddress1(jsonObject.getString("address1")); 39 | uzer.setAddress2(jsonObject.getString("address2")); 40 | uzer.setCity(jsonObject.getString("city")); 41 | uzer.setState(jsonObject.getString("state")); 42 | uzer.setCountry(jsonObject.getString("country")); 43 | uzer.setZip(jsonObject.getString("zip")); 44 | uzer.setCreditcard(jsonObject.getString("creditcard")); 45 | 46 | em.persist(uzer); 47 | 48 | return Response.ok(entity).build(); 49 | } 50 | 51 | @PUT 52 | @Path("{id}") 53 | @Consumes({"application/xml", "application/json"}) 54 | public void edit(@PathParam("id") Integer id, Uzer entity) { 55 | em.merge(entity); 56 | } 57 | 58 | @DELETE 59 | @Path("{id}") 60 | public void remove(@PathParam("id") Integer id) { 61 | em.remove(find(id)); 62 | } 63 | 64 | @GET 65 | @Path("{id}") 66 | @Produces({"application/xml", "application/json"}) 67 | public Uzer find(@PathParam("id") Integer id) { 68 | return em.createNamedQuery("Uzer.findById", Uzer.class).setParameter("id", id).getSingleResult(); 69 | } 70 | 71 | @GET 72 | @Produces({"application/xml", "application/json"}) 73 | public List findAll() { 74 | return em.createNamedQuery("Uzer.findAll", Uzer.class).getResultList(); 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /microservice/user/src/main/java/org/javaee7/wildfly/samples/everest/uzer/UserService.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.wildfly.samples.everest.uzer; 2 | 3 | import javax.annotation.PostConstruct; 4 | import javax.annotation.PreDestroy; 5 | import javax.ejb.Singleton; 6 | import javax.ejb.Startup; 7 | import javax.inject.Inject; 8 | import org.javaee7.wildfly.samples.everest.utils.WildFlyUtil; 9 | import org.javaee7.wildfly.samples.services.ZooKeeperServices; 10 | import org.javaee7.wildfly.samples.services.registration.ServiceRegistry; 11 | 12 | /** 13 | * @author arungupta 14 | */ 15 | @Startup 16 | @Singleton 17 | public class UserService { 18 | // @Inject @FixedServices ServiceRegistry services; 19 | // @Inject @SnoopServices ServiceRegistry services; 20 | @Inject @ZooKeeperServices ServiceRegistry services; 21 | 22 | // private static final String endpointURI = "http://localhost:8080/user/resources/user"; 23 | // private final String endpointURI = "http://" + serverName + ":" + serverPort + "/user/resources/user"; 24 | private final String endpointURI = "http://" + WildFlyUtil.getHostName()+ ":" + WildFlyUtil.getHostPort() + "/user/resources/user"; 25 | 26 | private static final String serviceName = "user"; 27 | 28 | @PostConstruct 29 | public void registerService() { 30 | services.registerService(serviceName, endpointURI); 31 | } 32 | 33 | @PreDestroy 34 | public void unregisterService() { 35 | services.unregisterService(serviceName, endpointURI); 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /microservice/user/src/main/java/org/javaee7/wildfly/samples/everest/uzer/Uzer.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.wildfly.samples.everest.uzer; 2 | 3 | import java.io.Serializable; 4 | import javax.persistence.Column; 5 | import javax.persistence.Entity; 6 | import javax.persistence.GeneratedValue; 7 | import javax.persistence.GenerationType; 8 | import javax.persistence.Id; 9 | import javax.persistence.NamedQueries; 10 | import javax.persistence.NamedQuery; 11 | import javax.xml.bind.annotation.XmlRootElement; 12 | 13 | /** 14 | * @author arungupta 15 | */ 16 | @Entity 17 | @NamedQueries({ 18 | @NamedQuery(name = "Uzer.findAll", query = "SELECT u FROM Uzer u"), 19 | @NamedQuery(name = "Uzer.findByLogin", query = "SELECT u FROM Uzer u where u.login = :login") 20 | }) 21 | @XmlRootElement 22 | public class Uzer implements Serializable { 23 | 24 | @Id 25 | @GeneratedValue(strategy=GenerationType.AUTO) 26 | int id; 27 | 28 | @Column 29 | String login; 30 | 31 | @Column 32 | String password; 33 | 34 | @Column 35 | String username; 36 | 37 | @Column 38 | String address1; 39 | 40 | @Column 41 | String address2; 42 | 43 | @Column 44 | String city; 45 | 46 | @Column 47 | String state; 48 | 49 | @Column 50 | String zip; 51 | 52 | @Column 53 | String country; 54 | 55 | @Column 56 | String creditcard; 57 | 58 | public int getId() { 59 | return id; 60 | } 61 | 62 | public String getLogin() { 63 | return login; 64 | } 65 | 66 | public void setLogin(String login) { 67 | this.login = login; 68 | } 69 | 70 | public String getPassword() { 71 | return password; 72 | } 73 | 74 | public void setPassword(String password) { 75 | this.password = password; 76 | } 77 | 78 | public String getUsername() { 79 | return username; 80 | } 81 | 82 | public void setUsername(String username) { 83 | this.username = username; 84 | } 85 | 86 | public String getAddress1() { 87 | return address1; 88 | } 89 | 90 | public void setAddress1(String address1) { 91 | this.address1 = address1; 92 | } 93 | 94 | public String getAddress2() { 95 | return address2; 96 | } 97 | 98 | public void setAddress2(String address2) { 99 | this.address2 = address2; 100 | } 101 | 102 | public String getCity() { 103 | return city; 104 | } 105 | 106 | public void setCity(String city) { 107 | this.city = city; 108 | } 109 | 110 | public String getState() { 111 | return state; 112 | } 113 | 114 | public void setState(String state) { 115 | this.state = state; 116 | } 117 | 118 | public String getZip() { 119 | return zip; 120 | } 121 | 122 | public void setZip(String zip) { 123 | this.zip = zip; 124 | } 125 | 126 | public String getCountry() { 127 | return country; 128 | } 129 | 130 | public void setCountry(String country) { 131 | this.country = country; 132 | } 133 | 134 | public String getCreditcard() { 135 | return creditcard; 136 | } 137 | 138 | public void setCreditcard(String creditcard) { 139 | this.creditcard = creditcard; 140 | } 141 | 142 | 143 | } 144 | -------------------------------------------------------------------------------- /microservice/user/src/main/resources/META-INF/persistence.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | -------------------------------------------------------------------------------- /microservice/user/src/main/resources/application.yml: -------------------------------------------------------------------------------- 1 | snoop: 2 | applicationName: user 3 | applicationHome: http://localhost:8080/user/resources 4 | applicationServiceRoot: user 5 | serviceHost: 192.168.99.103:8081/snoop-service/ 6 | -------------------------------------------------------------------------------- /microservice/utils/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4 | 4.0.0 5 | 6 | 7 | org.javaee7.wildfly.samples 8 | shoppingcart-msa 9 | 1.0-SNAPSHOT 10 | ../pom.xml 11 | 12 | 13 | utils 14 | jar 15 | 16 | 17 | 18 | org.wildfly 19 | wildfly-server 20 | ${version.wildfly.server} 21 | provided 22 | 23 | 24 | 25 | org.slf4j 26 | slf4j-api 27 | 1.7.10 28 | provided 29 | 30 | 31 | 32 | org.jboss.arquillian 33 | arquillian-bom 34 | ${version.arquillian} 35 | test 36 | pom 37 | 38 | 39 | 40 | org.jboss.arquillian.core 41 | arquillian-core-api 42 | 43 | 44 | 45 | org.jboss.arquillian.core 46 | arquillian-core-impl-base 47 | 48 | 49 | 50 | org.jboss.arquillian.junit 51 | arquillian-junit-core 52 | 53 | 54 | 55 | org.jboss.arquillian.junit 56 | arquillian-junit-container 57 | 58 | 59 | 60 | org.wildfly 61 | wildfly-arquillian-container-embedded 62 | 63 | 64 | 65 | org.wildfly 66 | wildfly-embedded 67 | 68 | 69 | 70 | org.wildfly 71 | wildfly-arquillian-protocol-jmx 72 | 73 | 74 | 75 | junit 76 | junit 77 | 78 | 79 | 80 | -------------------------------------------------------------------------------- /microservice/utils/src/main/java/org/javaee7/wildfly/samples/everest/utils/WildFlyUtil.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.javaee7.wildfly.samples.everest.utils; 18 | 19 | import org.javaee7.wildfly.samples.everest.utils.exception.InitializationException; 20 | import org.slf4j.Logger; 21 | import org.slf4j.LoggerFactory; 22 | 23 | import javax.annotation.PostConstruct; 24 | import javax.ejb.Singleton; 25 | import javax.ejb.Startup; 26 | import javax.management.MBeanServer; 27 | import javax.management.ObjectName; 28 | import java.lang.management.ManagementFactory; 29 | 30 | /** 31 | * @author Ryan McGuinness [rmcguinness@walmartlabs.com] 32 | * Created: 6/19/15 33 | */ 34 | @Startup 35 | @Singleton 36 | public class WildFlyUtil { 37 | private static final Logger log = LoggerFactory.getLogger(WildFlyUtil.class); 38 | private static String hostName = "localhost"; 39 | private static int hostPort = 8080; 40 | private static int hostSecurePort = 8443; 41 | 42 | @PostConstruct 43 | void init() throws InitializationException { 44 | try { 45 | MBeanServer mBeanServer = ManagementFactory.getPlatformMBeanServer(); 46 | 47 | ObjectName http = new ObjectName("jboss.as:socket-binding-group=standard-sockets,socket-binding=http"); 48 | hostName = (String) mBeanServer.getAttribute(http,"boundAddress"); 49 | hostPort = (Integer) mBeanServer.getAttribute(http,"boundPort"); 50 | 51 | ObjectName ws = new ObjectName("jboss.ws", "service", "ServerConfig"); 52 | // hostName = (String) mBeanServer.getAttribute(ws, "WebServiceHost"); 53 | // hostPort = (int) mBeanServer.getAttribute(ws, "WebServicePort"); 54 | hostSecurePort = (int) mBeanServer.getAttribute(ws, "WebServiceSecurePort"); 55 | log.info("--> " + hostName + " : " + hostPort + "/" + hostSecurePort); 56 | } catch (Exception e) { 57 | e.printStackTrace(); 58 | throw new InitializationException(e); 59 | } 60 | 61 | } 62 | 63 | public static String getHostName() { 64 | return hostName; 65 | } 66 | 67 | public static int getHostPort() { 68 | return hostPort; 69 | } 70 | 71 | public static int getSecurePort() { 72 | return hostSecurePort; 73 | } 74 | } -------------------------------------------------------------------------------- /microservice/utils/src/main/java/org/javaee7/wildfly/samples/everest/utils/cdi/EnvironmentProducer.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.javaee7.wildfly.samples.everest.utils.cdi; 18 | 19 | import org.javaee7.wildfly.samples.everest.utils.qualifiers.QSecureServerPort; 20 | import org.javaee7.wildfly.samples.everest.utils.qualifiers.QServerName; 21 | import org.javaee7.wildfly.samples.everest.utils.qualifiers.QServerPort; 22 | import org.javaee7.wildfly.samples.everest.utils.WildFlyUtil; 23 | 24 | import javax.enterprise.inject.Produces; 25 | import javax.inject.Inject; 26 | 27 | /** 28 | * @author Ryan McGuinness [rmcguinness@walmartlabs.com] 29 | * Created: 6/23/15 30 | */ 31 | public class EnvironmentProducer { 32 | @Inject 33 | private WildFlyUtil wildflyUtil; 34 | 35 | @Produces 36 | @QServerName 37 | public String getServerName() { 38 | return wildflyUtil.getHostName(); 39 | } 40 | 41 | @Produces 42 | @QServerPort 43 | public int getServerPort() { 44 | return wildflyUtil.getHostPort(); 45 | } 46 | 47 | @Produces 48 | @QSecureServerPort 49 | public int getSecurePort() { 50 | return wildflyUtil.getSecurePort(); 51 | } 52 | } 53 | -------------------------------------------------------------------------------- /microservice/utils/src/main/java/org/javaee7/wildfly/samples/everest/utils/exception/InitializationException.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.javaee7.wildfly.samples.everest.utils.exception; 18 | 19 | /** 20 | * @author Ryan McGuinness [rmcguinness@walmartlabs.com] 21 | * Created: 6/19/15 22 | */ 23 | public class InitializationException extends RuntimeException { 24 | public InitializationException() { 25 | super(); 26 | } 27 | 28 | public InitializationException(String err) { 29 | super(err); 30 | } 31 | 32 | public InitializationException(Throwable t) { 33 | super(t); 34 | } 35 | } -------------------------------------------------------------------------------- /microservice/utils/src/main/java/org/javaee7/wildfly/samples/everest/utils/qualifiers/QSecureServerPort.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.javaee7.wildfly.samples.everest.utils.qualifiers; 18 | 19 | import javax.inject.Qualifier; 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * @author Ryan McGuinness [rmcguinness@walmartlabs.com] 27 | * Created: 6/23/15 28 | */ 29 | @Qualifier 30 | @Retention(RetentionPolicy.RUNTIME) 31 | @Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD}) 32 | public @interface QSecureServerPort { 33 | } 34 | -------------------------------------------------------------------------------- /microservice/utils/src/main/java/org/javaee7/wildfly/samples/everest/utils/qualifiers/QServerName.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.javaee7.wildfly.samples.everest.utils.qualifiers; 18 | 19 | import javax.inject.Qualifier; 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * @author Ryan McGuinness [rmcguinness@walmartlabs.com] 27 | * Created: 6/23/15 28 | */ 29 | @Qualifier 30 | @Retention(RetentionPolicy.RUNTIME) 31 | @Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD}) 32 | public @interface QServerName { 33 | } 34 | -------------------------------------------------------------------------------- /microservice/utils/src/main/java/org/javaee7/wildfly/samples/everest/utils/qualifiers/QServerPort.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.javaee7.wildfly.samples.everest.utils.qualifiers; 18 | 19 | import javax.inject.Qualifier; 20 | import java.lang.annotation.ElementType; 21 | import java.lang.annotation.Retention; 22 | import java.lang.annotation.RetentionPolicy; 23 | import java.lang.annotation.Target; 24 | 25 | /** 26 | * @author Ryan McGuinness [rmcguinness@walmartlabs.com] 27 | * Created: 6/23/15 28 | */ 29 | @Qualifier 30 | @Retention(RetentionPolicy.RUNTIME) 31 | @Target({ElementType.FIELD, ElementType.PARAMETER, ElementType.METHOD}) 32 | public @interface QServerPort { 33 | } 34 | -------------------------------------------------------------------------------- /microservice/utils/src/main/resources/META-INF/beans.xml: -------------------------------------------------------------------------------- 1 | 2 | 18 | 21 | -------------------------------------------------------------------------------- /microservice/utils/src/test/java/org/javaee7/wildfly/samples/everest/test/ArquillianBase.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.javaee7.wildfly.samples.everest.test; 18 | 19 | import org.jboss.arquillian.container.test.api.Deployment; 20 | import org.jboss.arquillian.junit.Arquillian; 21 | import org.jboss.shrinkwrap.api.ShrinkWrap; 22 | import org.jboss.shrinkwrap.api.spec.JavaArchive; 23 | import org.junit.runner.RunWith; 24 | 25 | /** 26 | * @author Ryan McGuinness [rmcguinness@walmartlabs.com] 27 | * Created: 6/19/15 28 | */ 29 | @RunWith(Arquillian.class) 30 | public abstract class ArquillianBase { 31 | @Deployment 32 | public static JavaArchive createDeployment() { 33 | JavaArchive jar = ShrinkWrap.create(JavaArchive.class, "utils.jar") 34 | .addPackages(true, "org.javaee7.wildfly.samples.everest") 35 | .addAsResource("logging.properties") 36 | .addAsResource("log4j.properties") 37 | .addAsManifestResource("META-INF/beans.xml", "beans.xml"); 38 | System.out.println(jar.toString(true)); 39 | return jar; 40 | } 41 | } -------------------------------------------------------------------------------- /microservice/utils/src/test/java/org/javaee7/wildfly/samples/everest/test/TestAll.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.javaee7.wildfly.samples.everest.test; 18 | 19 | import org.javaee7.wildfly.samples.everest.utils.WildflyUtilTest; 20 | import org.junit.runner.RunWith; 21 | import org.junit.runners.Suite; 22 | 23 | /** 24 | * @author Ryan McGuinness [rmcguinness@walmartlabs.com] 25 | * Created: 6/19/15 26 | */ 27 | @RunWith(Suite.class) 28 | @Suite.SuiteClasses({ 29 | WildflyUtilTest.class 30 | }) 31 | public class TestAll { 32 | } 33 | -------------------------------------------------------------------------------- /microservice/utils/src/test/java/org/javaee7/wildfly/samples/everest/utils/WildflyUtilTest.java: -------------------------------------------------------------------------------- 1 | /* 2 | * Licensed to the Apache Software Foundation (ASF) under one or more 3 | * contributor license agreements. See the NOTICE file distributed with 4 | * this work for additional information regarding copyright ownership. 5 | * The ASF licenses this file to You under the Apache License, Version 2.0 6 | * (the "License"); you may not use this file except in compliance with 7 | * the License. You may obtain a copy of the License at 8 | * 9 | * http://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | package org.javaee7.wildfly.samples.everest.utils; 18 | 19 | import org.javaee7.wildfly.samples.everest.utils.qualifiers.QSecureServerPort; 20 | import org.javaee7.wildfly.samples.everest.utils.qualifiers.QServerName; 21 | import org.javaee7.wildfly.samples.everest.utils.qualifiers.QServerPort; 22 | import org.javaee7.wildfly.samples.everest.test.ArquillianBase; 23 | import org.junit.Test; 24 | import org.slf4j.Logger; 25 | import org.slf4j.LoggerFactory; 26 | 27 | import javax.inject.Inject; 28 | 29 | import static org.junit.Assert.assertNotNull; 30 | import static org.junit.Assert.assertTrue; 31 | 32 | /** 33 | * @author Ryan McGuinness [rmcguinness@walmartlabs.com] 34 | * Created: 6/21/15 35 | */ 36 | public class WildflyUtilTest extends ArquillianBase { 37 | private static final Logger LOG = LoggerFactory.getLogger(WildflyUtilTest.class); 38 | 39 | @Inject 40 | @QServerName 41 | private String serverName; 42 | 43 | @Inject 44 | @QServerPort 45 | private int port; 46 | 47 | @Inject 48 | @QSecureServerPort 49 | private int securePort; 50 | 51 | @Test 52 | public void testHostAndPort() { 53 | assertNotNull("Host is null", serverName); 54 | assertTrue("port is 0", port != 0); 55 | assertTrue("secure port is 0", securePort != 0); 56 | LOG.info("Server Information: {}:{}/{}", serverName, port, securePort); 57 | } 58 | } 59 | -------------------------------------------------------------------------------- /microservice/utils/src/test/resources/log4j.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one or more 3 | # contributor license agreements. See the NOTICE file distributed with 4 | # this work for additional information regarding copyright ownership. 5 | # The ASF licenses this file to You under the Apache License, Version 2.0 6 | # (the "License"); you may not use this file except in compliance with 7 | # the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | #Console Appender 19 | log4j.appender.console=org.apache.log4j.ConsoleAppender 20 | log4j.appender.console.layout=org.apache.log4j.PatternLayout 21 | log4j.appender.console.layout.ConversionPattern=[%5p] [%t %d{hh:mm:ss}] (%F:%M:%L) %m%n 22 | 23 | # Debug specific class 24 | #log4j.logger.services=DEBUG, stdout 25 | #log4j.logger.converter=DEBUG 26 | #log4j.logger.exporter=DEBUG 27 | #log4j.logger.pool=DEBUG 28 | #log4j.logger.utils=DEBUG 29 | 30 | #log4j.rootLogger=ERROR,console,R 31 | log4j.rootLogger=DEBUG,console -------------------------------------------------------------------------------- /microservice/utils/src/test/resources/logging.properties: -------------------------------------------------------------------------------- 1 | # 2 | # Licensed to the Apache Software Foundation (ASF) under one or more 3 | # contributor license agreements. See the NOTICE file distributed with 4 | # this work for additional information regarding copyright ownership. 5 | # The ASF licenses this file to You under the Apache License, Version 2.0 6 | # (the "License"); you may not use this file except in compliance with 7 | # the License. You may obtain a copy of the License at 8 | # 9 | # http://www.apache.org/licenses/LICENSE-2.0 10 | # 11 | # Unless required by applicable law or agreed to in writing, software 12 | # distributed under the License is distributed on an "AS IS" BASIS, 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | # See the License for the specific language governing permissions and 15 | # limitations under the License. 16 | # 17 | 18 | org.apache.catalina.core.ContainerBase.[Catalina].level = FINER 19 | org.apache.catalina.core.ContainerBase.[Catalina].handlers = java.util.logging.ConsoleHandler 20 | 21 | com.walmart.level = FINE 22 | com.walmart.handlers = java.util.logging.ConsoleHandler -------------------------------------------------------------------------------- /monolith/everest/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4.0.0 4 | 5 | org.javaee7.wildfly.samples 6 | everest 7 | 1.0-SNAPSHOT 8 | war 9 | 10 | Shopping Cart Monolith 11 | 12 | 13 | UTF-8 14 | 15 | 16 | 17 | 18 | javax 19 | javaee-api 20 | 7.0 21 | provided 22 | 23 | 24 | 25 | org.jolokia 26 | jolokia-core 27 | 1.3.5 28 | 29 | 30 | 31 | 32 | ROOT 33 | 34 | 35 | org.apache.maven.plugins 36 | maven-compiler-plugin 37 | 3.1 38 | 39 | 1.7 40 | 1.7 41 | 42 | 43 | 44 | org.apache.maven.plugins 45 | maven-war-plugin 46 | 2.3 47 | 48 | false 49 | 50 | 51 | 52 | org.wildfly.plugins 53 | wildfly-maven-plugin 54 | 1.1.0.Alpha2 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /monolith/everest/src/main/java/org/javaee7/wildfly/samples/everest/cart/Cart.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.wildfly.samples.everest.cart; 2 | 3 | import java.io.Serializable; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | import javax.annotation.PostConstruct; 7 | import javax.enterprise.context.SessionScoped; 8 | import javax.faces.context.FacesContext; 9 | import javax.faces.event.ActionEvent; 10 | import javax.inject.Inject; 11 | import javax.inject.Named; 12 | 13 | /** 14 | * @author arungupta 15 | */ 16 | @Named 17 | @SessionScoped 18 | public class Cart implements Serializable { 19 | private List items; 20 | 21 | @Inject CartItem currentCartItem; 22 | 23 | @PostConstruct 24 | private void init() { 25 | items = new ArrayList<>(); 26 | } 27 | 28 | public List getItems() { 29 | return items; 30 | } 31 | 32 | public void addItemToCart(ActionEvent event) { 33 | boolean exists = false; 34 | 35 | int itemId = Integer.valueOf(FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("itemId")); 36 | String itemName = (String)FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("itemName"); 37 | 38 | for (CartItem item : items) { 39 | if (itemId == item.getItemId()) { 40 | exists = true; 41 | CartItem cartItem = new CartItem(item.getItemId(), itemName, item.getItemCount() + currentCartItem.getItemCount()); 42 | items.remove(item); 43 | items.add(cartItem); 44 | } 45 | } 46 | if (!exists) { 47 | CartItem cartItem = new CartItem(itemId, itemName, currentCartItem.getItemCount()); 48 | items.add(cartItem); 49 | } 50 | } 51 | 52 | public void clearCart() { 53 | items.clear(); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /monolith/everest/src/main/java/org/javaee7/wildfly/samples/everest/cart/CartItem.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.wildfly.samples.everest.cart; 2 | 3 | import java.io.Serializable; 4 | import javax.enterprise.context.SessionScoped; 5 | import javax.inject.Named; 6 | 7 | /** 8 | * @author arungupta 9 | */ 10 | @Named 11 | @SessionScoped 12 | public class CartItem implements Serializable { 13 | private int itemId; 14 | private String itemName; 15 | private int itemCount; 16 | 17 | public CartItem() { } 18 | 19 | public CartItem(int itemId, String itemName, int itemCount) { 20 | this.itemId = itemId; 21 | this.itemName = itemName; 22 | this.itemCount = itemCount; 23 | } 24 | 25 | public int getItemId() { 26 | return itemId; 27 | } 28 | 29 | public void setItemId(int itemId) { 30 | this.itemId = itemId; 31 | } 32 | 33 | public int getItemCount() { 34 | return itemCount; 35 | } 36 | 37 | public void setItemCount(int itemCount) { 38 | this.itemCount = itemCount; 39 | } 40 | 41 | public String getItemName() { 42 | return itemName; 43 | } 44 | 45 | public void setName(String name) { 46 | this.itemName = name; 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /monolith/everest/src/main/java/org/javaee7/wildfly/samples/everest/catalog/CatalogItem.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.wildfly.samples.everest.catalog; 2 | 3 | import java.io.Serializable; 4 | import javax.persistence.Column; 5 | import javax.persistence.Entity; 6 | import javax.persistence.Id; 7 | import javax.persistence.NamedQueries; 8 | import javax.persistence.NamedQuery; 9 | 10 | /** 11 | * @author arungupta 12 | */ 13 | @Entity 14 | @NamedQueries({ 15 | @NamedQuery(name = "CatalogItem.findAll", query = "SELECT i FROM CatalogItem i"), 16 | @NamedQuery(name = "CatalogItem.findById", query = "SELECT i FROM CatalogItem i where i.id = :id") 17 | }) 18 | public class CatalogItem implements Serializable { 19 | private static final long serialVersionUID = 1L; 20 | @Id 21 | private int id; 22 | 23 | @Column(length=60) 24 | private String name; 25 | 26 | @Column 27 | private int type; 28 | 29 | @Column(length=100) 30 | private String description; 31 | 32 | public CatalogItem() { } 33 | 34 | public CatalogItem(String name, int type) { 35 | this.name = name; 36 | this.type = type; 37 | } 38 | 39 | public int getId() { 40 | return id; 41 | } 42 | 43 | public void setId(int id) { 44 | this.id = id; 45 | } 46 | 47 | public String getName() { 48 | return name; 49 | } 50 | 51 | public void setName(String name) { 52 | this.name = name; 53 | } 54 | 55 | public int getType() { 56 | return type; 57 | } 58 | 59 | public void setType(int type) { 60 | this.type = type; 61 | } 62 | 63 | public String getDescription() { 64 | return description; 65 | } 66 | 67 | public void setDescription(String description) { 68 | this.description = description; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /monolith/everest/src/main/java/org/javaee7/wildfly/samples/everest/catalog/CatalogItemBean.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.wildfly.samples.everest.catalog; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | import javax.enterprise.context.SessionScoped; 6 | import javax.faces.context.FacesContext; 7 | import javax.inject.Named; 8 | import javax.persistence.EntityManager; 9 | import javax.persistence.PersistenceContext; 10 | 11 | /** 12 | * @author arungupta 13 | */ 14 | @Named 15 | @SessionScoped 16 | public class CatalogItemBean implements Serializable { 17 | @PersistenceContext EntityManager em; 18 | 19 | public List getItems() { 20 | return em.createNamedQuery("CatalogItem.findAll", CatalogItem.class).getResultList(); 21 | } 22 | 23 | public CatalogItem getItem() { 24 | int itemId = Integer.valueOf(FacesContext.getCurrentInstance().getExternalContext().getRequestParameterMap().get("itemId")); 25 | return getItemWithId(itemId); 26 | } 27 | 28 | public CatalogItem getItemWithId(int itemId) { 29 | return em.createNamedQuery("CatalogItem.findById", CatalogItem.class).setParameter("id", itemId).getSingleResult(); 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /monolith/everest/src/main/java/org/javaee7/wildfly/samples/everest/catalog/CatalogItemType.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.wildfly.samples.everest.catalog; 2 | 3 | import java.io.Serializable; 4 | import javax.persistence.Column; 5 | import javax.persistence.Entity; 6 | import javax.persistence.Id; 7 | 8 | /** 9 | * @author arungupta 10 | */ 11 | @Entity 12 | public class CatalogItemType implements Serializable { 13 | private static final long serialVersionUID = 1L; 14 | @Id 15 | private int id; 16 | 17 | @Column 18 | private String name; 19 | 20 | public CatalogItemType() { 21 | } 22 | 23 | public CatalogItemType(int id, String name) { 24 | this.id = id; 25 | this.name = name; 26 | } 27 | 28 | public int getId() { 29 | return id; 30 | } 31 | 32 | public void setId(int id) { 33 | this.id = id; 34 | } 35 | 36 | public String getName() { 37 | return name; 38 | } 39 | 40 | public void setName(String name) { 41 | this.name = name; 42 | } 43 | } -------------------------------------------------------------------------------- /monolith/everest/src/main/java/org/javaee7/wildfly/samples/everest/checkout/Order.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.wildfly.samples.everest.checkout; 2 | 3 | import java.io.Serializable; 4 | import java.util.List; 5 | import javax.persistence.Column; 6 | import javax.persistence.ElementCollection; 7 | import javax.persistence.Entity; 8 | import javax.persistence.GeneratedValue; 9 | import javax.persistence.GenerationType; 10 | import javax.persistence.Id; 11 | import javax.persistence.Table; 12 | 13 | /** 14 | * @author arungupta 15 | */ 16 | @Entity 17 | @Table(name = "CART_ORDER") 18 | public class Order implements Serializable { 19 | 20 | @Id 21 | @GeneratedValue(strategy=GenerationType.AUTO) 22 | @Column 23 | int orderId; 24 | 25 | @ElementCollection 26 | List orderItems; 27 | 28 | public int getOrderId() { 29 | return orderId; 30 | } 31 | 32 | public void setOrderId(int orderId) { 33 | this.orderId = orderId; 34 | } 35 | 36 | public List getOrderItems() { 37 | return orderItems; 38 | } 39 | 40 | public void setOrderItems(List orderItems) { 41 | this.orderItems = orderItems; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /monolith/everest/src/main/java/org/javaee7/wildfly/samples/everest/checkout/OrderBean.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.wildfly.samples.everest.checkout; 2 | 3 | import java.io.Serializable; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | import javax.enterprise.context.SessionScoped; 7 | import javax.inject.Inject; 8 | import javax.inject.Named; 9 | import javax.persistence.EntityManager; 10 | import javax.persistence.PersistenceContext; 11 | import javax.transaction.Transactional; 12 | import org.javaee7.wildfly.samples.everest.cart.Cart; 13 | import org.javaee7.wildfly.samples.everest.cart.CartItem; 14 | 15 | /** 16 | * @author arungupta 17 | */ 18 | @Named 19 | @SessionScoped 20 | public class OrderBean implements Serializable { 21 | @Inject Cart cart; 22 | 23 | String status; 24 | 25 | @PersistenceContext EntityManager em; 26 | 27 | @Transactional 28 | public void saveOrder() { 29 | Order order = new Order(); 30 | List items = new ArrayList<>(); 31 | List cartItems = cart.getItems(); 32 | for (CartItem cartItem : cartItems) { 33 | OrderItem orderItem = new OrderItem(); 34 | orderItem.itemId = cartItem.getItemId(); 35 | orderItem.itemCount = cartItem.getItemCount(); 36 | items.add(orderItem); 37 | } 38 | order.setOrderItems(items); 39 | try { 40 | em.persist(order); 41 | status = "Order successful, order number: " + order.orderId; 42 | 43 | cart.clearCart(); 44 | } catch (Exception e) { 45 | status = e.getLocalizedMessage(); 46 | } 47 | } 48 | 49 | public String getStatus() { 50 | return status; 51 | } 52 | 53 | public void setStatus(String status) { 54 | this.status = status; 55 | } 56 | } 57 | -------------------------------------------------------------------------------- /monolith/everest/src/main/java/org/javaee7/wildfly/samples/everest/checkout/OrderItem.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.wildfly.samples.everest.checkout; 2 | 3 | import java.io.Serializable; 4 | import javax.persistence.Embeddable; 5 | 6 | /** 7 | * @author arungupta 8 | */ 9 | @Embeddable 10 | public class OrderItem implements Serializable { 11 | int itemId; 12 | int itemCount; 13 | 14 | public int getItemId() { 15 | return itemId; 16 | } 17 | 18 | public void setItemId(int itemId) { 19 | this.itemId = itemId; 20 | } 21 | 22 | public int getItemCount() { 23 | return itemCount; 24 | } 25 | 26 | public void setItemCount(int itemCount) { 27 | this.itemCount = itemCount; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /monolith/everest/src/main/java/org/javaee7/wildfly/samples/everest/checkout/Shipping.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.wildfly.samples.everest.checkout; 2 | 3 | import java.io.Serializable; 4 | import javax.enterprise.context.SessionScoped; 5 | import javax.inject.Inject; 6 | import javax.inject.Named; 7 | import javax.persistence.EntityManager; 8 | import javax.persistence.PersistenceContext; 9 | import org.javaee7.wildfly.samples.everest.uzer.Uzer; 10 | import org.javaee7.wildfly.samples.everest.uzer.UzerItem; 11 | 12 | /** 13 | * @author arungupta 14 | */ 15 | @Named 16 | @SessionScoped 17 | public class Shipping implements Serializable { 18 | 19 | @PersistenceContext EntityManager em; 20 | 21 | @Inject UzerItem uzer2; 22 | // String login; 23 | // 24 | // String name; 25 | // String address1; 26 | // String address2; 27 | // String city; 28 | // String zip; 29 | // String country; 30 | // String creditcard; 31 | 32 | public Shipping() { } 33 | 34 | public void findShippingDetail() { 35 | System.out.println("LOGIN: " + uzer2.getLogin()); 36 | Uzer uzer = em.createNamedQuery("Uzer.findByLogin", Uzer.class).setParameter("login", uzer2.getLogin()).getSingleResult(); 37 | uzer.setUsername(uzer2.getUsername()); 38 | uzer.setAddress1(uzer2.getAddress1()); 39 | uzer.setAddress2(uzer2.getAddress2()); 40 | uzer.setCity(uzer2.getCity()); 41 | uzer.setZip(uzer2.getZip()); 42 | uzer.setCountry(uzer2.getCountry()); 43 | uzer.setCreditcard(uzer2.getCreditcard()); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /monolith/everest/src/main/java/org/javaee7/wildfly/samples/everest/uzer/Uzer.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.wildfly.samples.everest.uzer; 2 | 3 | import java.io.Serializable; 4 | import javax.persistence.Column; 5 | import javax.persistence.Entity; 6 | import javax.persistence.GeneratedValue; 7 | import javax.persistence.GenerationType; 8 | import javax.persistence.Id; 9 | import javax.persistence.NamedQueries; 10 | import javax.persistence.NamedQuery; 11 | 12 | /** 13 | * @author arungupta 14 | */ 15 | @Entity 16 | @NamedQueries({ 17 | @NamedQuery(name = "Uzer.findAll", query = "SELECT u FROM Uzer u"), 18 | @NamedQuery(name = "Uzer.findByLogin", query = "SELECT u FROM Uzer u where u.login = :login") 19 | }) 20 | public class Uzer implements Serializable { 21 | 22 | @Id 23 | @GeneratedValue(strategy=GenerationType.AUTO) 24 | int id; 25 | 26 | @Column 27 | String login; 28 | 29 | @Column 30 | String password; 31 | 32 | @Column 33 | String username; 34 | 35 | @Column 36 | String address1; 37 | 38 | @Column 39 | String address2; 40 | 41 | @Column 42 | String city; 43 | 44 | @Column 45 | String state; 46 | 47 | @Column 48 | String zip; 49 | 50 | @Column 51 | String country; 52 | 53 | @Column 54 | String creditcard; 55 | 56 | public String getLogin() { 57 | return login; 58 | } 59 | 60 | public void setLogin(String login) { 61 | this.login = login; 62 | } 63 | 64 | public String getPassword() { 65 | return password; 66 | } 67 | 68 | public void setPassword(String password) { 69 | this.password = password; 70 | } 71 | 72 | public String getUsername() { 73 | return username; 74 | } 75 | 76 | public void setUsername(String username) { 77 | this.username = username; 78 | } 79 | 80 | public String getAddress1() { 81 | return address1; 82 | } 83 | 84 | public void setAddress1(String address1) { 85 | this.address1 = address1; 86 | } 87 | 88 | public String getAddress2() { 89 | return address2; 90 | } 91 | 92 | public void setAddress2(String address2) { 93 | this.address2 = address2; 94 | } 95 | 96 | public String getCity() { 97 | return city; 98 | } 99 | 100 | public void setCity(String city) { 101 | this.city = city; 102 | } 103 | 104 | public String getState() { 105 | return state; 106 | } 107 | 108 | public void setState(String state) { 109 | this.state = state; 110 | } 111 | 112 | public String getZip() { 113 | return zip; 114 | } 115 | 116 | public void setZip(String zip) { 117 | this.zip = zip; 118 | } 119 | 120 | public String getCountry() { 121 | return country; 122 | } 123 | 124 | public void setCountry(String country) { 125 | this.country = country; 126 | } 127 | 128 | public String getCreditcard() { 129 | return creditcard; 130 | } 131 | 132 | public void setCreditcard(String creditcard) { 133 | this.creditcard = creditcard; 134 | } 135 | 136 | 137 | } 138 | -------------------------------------------------------------------------------- /monolith/everest/src/main/java/org/javaee7/wildfly/samples/everest/uzer/UzerBean.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.wildfly.samples.everest.uzer; 2 | 3 | import java.io.Serializable; 4 | import javax.enterprise.context.SessionScoped; 5 | import javax.inject.Inject; 6 | import javax.inject.Named; 7 | import javax.persistence.EntityManager; 8 | import javax.persistence.PersistenceContext; 9 | import javax.transaction.Transactional; 10 | 11 | /** 12 | * @author arungupta 13 | */ 14 | @Named 15 | @SessionScoped 16 | public class UzerBean implements Serializable { 17 | @PersistenceContext EntityManager em; 18 | 19 | @Inject UzerItem uzerItem; 20 | 21 | String status; 22 | 23 | @Transactional 24 | public void addUzer() { 25 | Uzer uzer = new Uzer(); 26 | uzer.setLogin(uzerItem.getLogin()); 27 | uzer.setPassword(uzerItem.getPassword()); 28 | uzer.setUsername(uzerItem.getUsername()); 29 | uzer.setAddress1(uzerItem.getAddress1()); 30 | uzer.setAddress2(uzerItem.getAddress2()); 31 | uzer.setCity(uzerItem.getCity()); 32 | uzer.setState(uzerItem.getState()); 33 | uzer.setCountry(uzerItem.getCountry()); 34 | uzer.setZip(uzerItem.getZip()); 35 | uzer.setCreditcard(uzerItem.getCreditcard()); 36 | 37 | try { 38 | em.persist(uzer); 39 | } catch (Exception e) { 40 | status = e.getLocalizedMessage(); 41 | return; 42 | } 43 | 44 | status = "User added successfully, login: \"" + uzer.getLogin() + "\", password: \"" + uzer.getPassword() + "\""; 45 | } 46 | 47 | public String getStatus() { 48 | return status; 49 | } 50 | 51 | public void setStatus(String status) { 52 | this.status = status; 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /monolith/everest/src/main/java/org/javaee7/wildfly/samples/everest/uzer/UzerItem.java: -------------------------------------------------------------------------------- 1 | package org.javaee7.wildfly.samples.everest.uzer; 2 | 3 | import java.io.Serializable; 4 | import javax.enterprise.context.SessionScoped; 5 | import javax.inject.Named; 6 | 7 | /** 8 | * @author arungupta 9 | */ 10 | @Named 11 | @SessionScoped 12 | public class UzerItem implements Serializable { 13 | private String login; 14 | private String password; 15 | private String username; 16 | private String address1; 17 | private String address2; 18 | private String city; 19 | private String state; 20 | private String zip; 21 | private String country; 22 | private String creditcard; 23 | 24 | public String getLogin() { 25 | return login; 26 | } 27 | 28 | public void setLogin(String login) { 29 | this.login = login; 30 | } 31 | 32 | public String getPassword() { 33 | return password; 34 | } 35 | 36 | public void setPassword(String password) { 37 | this.password = password; 38 | } 39 | 40 | public String getUsername() { 41 | return username; 42 | } 43 | 44 | public void setUsername(String username) { 45 | this.username = username; 46 | } 47 | 48 | public String getAddress1() { 49 | return address1; 50 | } 51 | 52 | public void setAddress1(String address1) { 53 | this.address1 = address1; 54 | } 55 | 56 | public String getAddress2() { 57 | return address2; 58 | } 59 | 60 | public void setAddress2(String address2) { 61 | this.address2 = address2; 62 | } 63 | 64 | public String getCity() { 65 | return city; 66 | } 67 | 68 | public void setCity(String city) { 69 | this.city = city; 70 | } 71 | 72 | public String getState() { 73 | return state; 74 | } 75 | 76 | public void setState(String state) { 77 | this.state = state; 78 | } 79 | 80 | public String getZip() { 81 | return zip; 82 | } 83 | 84 | public void setZip(String zip) { 85 | this.zip = zip; 86 | } 87 | 88 | public String getCountry() { 89 | return country; 90 | } 91 | 92 | public void setCountry(String country) { 93 | this.country = country; 94 | } 95 | 96 | public String getCreditcard() { 97 | return creditcard; 98 | } 99 | 100 | public void setCreditcard(String creditcard) { 101 | this.creditcard = creditcard; 102 | } 103 | 104 | } 105 | -------------------------------------------------------------------------------- /monolith/everest/src/main/resources/META-INF/load.sql: -------------------------------------------------------------------------------- 1 | INSERT INTO CatalogItemType("ID", "NAME") VALUES (1, 'Book') 2 | INSERT INTO CatalogItemType("ID", "NAME") VALUES (2, 'Jewelry') 3 | INSERT INTO CatalogItemType("ID", "NAME") VALUES (3, 'Shoes') 4 | INSERT INTO CatalogItem("ID", "NAME", "TYPE", "DESCRIPTION") VALUES (1, 'Minecraft Modding with Forge', 1, 'Book - Minecraft Modding with Forge') 5 | INSERT INTO CatalogItem("ID", "NAME", "TYPE", "DESCRIPTION") VALUES (2, 'Java EE 7 Essentials', 1, 'Book - Java EE 7 Essentials') 6 | INSERT INTO CatalogItem("ID", "NAME", "TYPE", "DESCRIPTION") VALUES (3, 'Java EE 6 Pocket Guide', 1, 'Book - Java EE 6 Pocket Guide') 7 | INSERT INTO CatalogItem("ID", "NAME", "TYPE", "DESCRIPTION") VALUES (4, 'Java EE 7 & HTML5 Enterprise Application Development', 1, 'Book - Java EE 7 & HTML5 Enterprise Application Development') 8 | INSERT INTO CatalogItem("ID", "NAME", "TYPE", "DESCRIPTION") VALUES (5, 'Wedding Band', 2, 'Jewelry - Wedding Band') 9 | INSERT INTO CatalogItem("ID", "NAME", "TYPE", "DESCRIPTION") VALUES (6, 'Bangles', 2, 'Jewelry - Bangles') 10 | INSERT INTO CatalogItem("ID", "NAME", "TYPE", "DESCRIPTION") VALUES (7, 'Necklace', 2, 'Jewelry - Necklace') 11 | INSERT INTO CatalogItem("ID", "NAME", "TYPE", "DESCRIPTION") VALUES (8, 'Earrings', 2, 'Jewelry - Earrings') 12 | INSERT INTO CatalogItem("ID", "NAME", "TYPE", "DESCRIPTION") VALUES (9, 'Mizuno Wave Sayonara', 3, 'Shoes - Mizuno Wave Sayonara') 13 | INSERT INTO CatalogItem("ID", "NAME", "TYPE", "DESCRIPTION") VALUES (10, 'Nike Free 5.0', 3, 'Shoes - Nike Free 5.0') 14 | INSERT INTO CatalogItem("ID", "NAME", "TYPE", "DESCRIPTION") VALUES (11, 'Salomon Men''s Quest 4D', 3, 'Shoes - Salomon Men''s Quest 4D') 15 | INSERT INTO CatalogItem("ID", "NAME", "TYPE", "DESCRIPTION") VALUES (12, 'New Balance Minimus', 3, 'Shoes - New Balance Minimus') 16 | -------------------------------------------------------------------------------- /monolith/everest/src/main/resources/META-INF/persistence.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | -------------------------------------------------------------------------------- /monolith/everest/src/main/webapp/WEB-INF/jboss-web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | / 4 | 5 | -------------------------------------------------------------------------------- /monolith/everest/src/main/webapp/WEB-INF/template.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | Java EE Shopping Cart (Monolithic) 15 | 16 | 17 | 18 |

19 |

20 | Java EE Shopping Cart (Monolithic)

21 |
22 |
23 |
24 | 25 | Create User

26 | Catalog

27 | Cart

28 | Payment

29 | 30 |

31 |
32 | Content 33 |
34 |
35 | 36 |
37 | 38 | -------------------------------------------------------------------------------- /monolith/everest/src/main/webapp/WEB-INF/web.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | javax.faces.PROJECT_STAGE 5 | Development 6 | 7 | 8 | Faces Servlet 9 | javax.faces.webapp.FacesServlet 10 | 1 11 | 12 | 13 | Faces Servlet 14 | /faces/* 15 | 16 | 17 | jolokia-agent 18 | org.jolokia.http.AgentServlet 19 | 1 20 | 21 | 22 | jolokia-agent 23 | /jolokia/* 24 | 25 | 26 | 27 | 30 28 | 29 | 30 | 31 | faces/index.xhtml 32 | 33 | 34 | -------------------------------------------------------------------------------- /monolith/everest/src/main/webapp/cart.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

Cart

14 | 15 | 16 | Item Name 17 | #{item.itemName} 18 | 19 | 20 | 21 | Item Count 22 | #{item.itemCount} 23 | 24 | 25 |

26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /monolith/everest/src/main/webapp/catalog-item.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

Catalog Item

14 | 15 | 16 | Name: #{catalogItemBean.item.name}

17 | Description: #{catalogItemBean.item.description}

18 | Quantity: 19 | 21 | 22 | 23 | 24 | 25 | 26 |

27 |

28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /monolith/everest/src/main/webapp/catalog.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |

Catalog

14 | 15 | 16 | 17 | Item Name 18 | 19 | 20 | 21 | 22 | 23 | 24 | Item Type 25 | #{item.type} 26 | 27 | 28 | 29 |
30 | 31 |
32 | 33 | 34 | 35 | -------------------------------------------------------------------------------- /monolith/everest/src/main/webapp/checkout.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |

Shipping

13 | 14 | Login name:

15 | 16 | 17 |

18 | 19 | Name: #{uzerItem.username}

20 | Address Line 1: #{uzerItem.address1}

21 | Address Line 2: #{uzerItem.address2}

22 | City: #{uzerItem.city}

23 | State: #{uzerItem.state}

24 | Zip: #{uzerItem.zip}

25 | Country: #{uzerItem.country}

26 | Credit Card: #{uzerItem.creditcard}

27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /monolith/everest/src/main/webapp/confirm.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |

Order Confirmation

13 | 14 | #{orderBean.status} 15 | 16 |

17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /monolith/everest/src/main/webapp/css/cssLayout.css: -------------------------------------------------------------------------------- 1 | 2 | #top { 3 | position: relative; 4 | background-color: #036fab; 5 | color: white; 6 | padding: 5px; 7 | margin: 0px 0px 10px 0px; 8 | } 9 | 10 | #bottom { 11 | position: relative; 12 | background-color: #c2dfef; 13 | padding: 5px; 14 | margin: 10px 0px 0px 0px; 15 | } 16 | 17 | #left { 18 | float: left; 19 | background-color: #ece3a5; 20 | padding: 5px; 21 | width: 150px; 22 | } 23 | 24 | #right { 25 | float: right; 26 | background-color: #ece3a5; 27 | padding: 5px; 28 | width: 150px; 29 | } 30 | 31 | .center_content { 32 | position: relative; 33 | background-color: #dddddd; 34 | padding: 5px; 35 | } 36 | 37 | .left_content { 38 | background-color: #dddddd; 39 | padding: 5px; 40 | margin-left: 170px; 41 | } 42 | 43 | .right_content { 44 | background-color: #dddddd; 45 | padding: 5px; 46 | margin: 0px 170px 0px 170px; 47 | } 48 | 49 | #top a:link, #top a:visited { 50 | color: white; 51 | font-weight : bold; 52 | text-decoration: none; 53 | } 54 | 55 | #top a:link:hover, #top a:visited:hover { 56 | color: black; 57 | font-weight : bold; 58 | text-decoration : underline; 59 | } 60 | 61 | 62 | -------------------------------------------------------------------------------- /monolith/everest/src/main/webapp/css/default.css: -------------------------------------------------------------------------------- 1 | body { 2 | background-color: #ffffff; 3 | font-size: 12px; 4 | font-family: Verdana, "Verdana CE", Arial, "Arial CE", "Lucida Grande CE", lucida, "Helvetica CE", sans-serif; 5 | color: #000000; 6 | margin: 10px; 7 | } 8 | 9 | h1 { 10 | font-family: Arial, "Arial CE", "Lucida Grande CE", lucida, "Helvetica CE", sans-serif; 11 | border-bottom: 1px solid #AFAFAF; 12 | font-size: 16px; 13 | font-weight: bold; 14 | margin: 0px; 15 | padding: 0px; 16 | color: #D20005; 17 | } 18 | 19 | a:link, a:visited { 20 | color: #045491; 21 | font-weight : bold; 22 | text-decoration: none; 23 | } 24 | 25 | a:link:hover, a:visited:hover { 26 | color: #045491; 27 | font-weight : bold; 28 | text-decoration : underline; 29 | } 30 | -------------------------------------------------------------------------------- /monolith/everest/src/main/webapp/index.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |

    13 |
  • Create User
  • 14 |
  • Add items from Catalog to Shopping Cart
  • 15 |
  • Review Shopping Cart
  • 16 |
  • Confirm/Add Shipping Address
  • 17 |
  • Add Payment Details
  • 18 |
19 | 20 | 21 | 22 | 23 |
24 | 25 |
26 | 27 | 28 | 29 | -------------------------------------------------------------------------------- /monolith/everest/src/main/webapp/user-status.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |

Create User Status

13 | 14 | #{uzerBean.status} 15 |

16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /monolith/everest/src/main/webapp/user.xhtml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | 9 | 10 | 11 | 12 |

Create User

13 | 14 | 15 | Login:

16 | Password:

17 | Name:

18 | Address Line 1:

19 | Address Line 2:

20 | City:

21 | State:

22 | Zip:

23 | Country:

24 | Credit Card:

25 | 26 |

27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | -------------------------------------------------------------------------------- /readme.adoc: -------------------------------------------------------------------------------- 1 | # Refactor monolith to microservices 2 | 3 | This workspace will show how to refactor a Java EE monolith to a 4 | microservices-based application. This will be accomplished in multiple 5 | phases: 6 | 7 | . Phase 1: Functional decomposition of a `WAR` into multiple `WAR`s. Use hardcoded service URIs. 8 | . Phase 2: Use service registration and discovery 9 | . Phase 3: Continuous integration 10 | . Phase 4: Continuous deployment 11 | . Phase 5: Proactive monitoring and scale in/out 12 | . Phase 6: Change the implementation stack of a service 13 | 14 | ## Run the application 15 | 16 | . Start ZooKeeper 17 | 18 | docker run -d -p 2181:2181 fabric8/zookeeper 19 | 20 | . Download and unzip http://download.jboss.org/wildfly/9.0.0.Final/wildfly-9.0.0.Final.zip[WildFly 9.0.0.Final] 21 | . Run WildFly 22 | 23 | ./bin/standalone.sh 24 | 25 | . Deploy the application 26 | 27 | mvn -f microservice/pom.xml install -DskipTests 28 | 29 | ## NoOps 30 | 31 | Operational concerns are addressed in the following documents: 32 | 33 | . link:service-discovery.adoc[Service Discovery] 34 | . Continuous Integration 35 | . Continuous Deployment 36 | . link:service-monitoring.adoc[Service Monitoring] 37 | 38 | -------------------------------------------------------------------------------- /service-discovery.adoc: -------------------------------------------------------------------------------- 1 | # Service Registration and Discovery 2 | 3 | Microservices architecture require a significant amount of investment in `NoOps' or http://blogs.gartner.com/gary-olliffe/2015/01/30/microservices-guts-on-the-outside/[Outer Architecture]. One of the key components of that is service registration and discovery. Multiple microservices are composed to create an application and each microservice can scale independently. Exact location or URI of the service may not be known until its deployed, especially if its deployed in a PaaS or using Containers. 4 | 5 | _Service registration_ allows each microservice to register itself with a _registry_ using a logical name. This name is bound to a physical URI obtained from a PaaS or a Container. This logical name can then be used during _service discovery_ to discover the service by the consumers, and then invoke, the microservice. If the microservice goes down then the consumers are notified accordingly. The logical name allows the physical URI to change if the microservice is started on a different ``node'' on PaaS or a Container. The logical name also allows to register multiple physical URIs, and thus load balance, possibly metrics-driven, to distribute the requests amongst multiple microservices. 6 | 7 | There are multiple tools used for service registry and discovery. This document will highlight how to use them from a Java application. 8 | 9 | ## ZooKeeper and Curator 10 | 11 | . Start ZooKeeper container 12 | + 13 | [source, text] 14 | ---- 15 | docker run -d -p 2181:2181 fabric8/zookeeper 16 | ---- 17 | 18 | Complete details: http://blog.arungupta.me/zookeeper-microservice-registration-discovery/ 19 | 20 | 21 | ## Consul 22 | 23 | consul-registrar, consul-template 24 | 25 | . Written in Go 26 | . AP from CAP 27 | 28 | https://github.com/progrium/docker-consul 29 | https://github.com/gliderlabs/registrator 30 | 31 | ## etcd 32 | 33 | https://github.com/jurmous/etcd4j 34 | 35 | . Storing application config (db urls etc.). The app starts, retrieves it's config and configures it's own components. 36 | . Integration with Vulcan for monitoring purposes. 37 | . Thinking about using it for master election for running scheduled tasks. 38 | . Used internally by CoreOS and Fleet. 39 | . Service Discovery by implementing Sidekick unit which register service information inside etcd that is consumed by HAProxy. 40 | . etcd used as key/value for sharing p12 and other resources across all services. 41 | 42 | ## Kubernetes 43 | 44 | . http://fabric8.io/guide/services.html 45 | . http://paulbakker.io/kubernetes/load-balancing-kubernetes/ 46 | 47 | ## Eureka 48 | 49 | ## OSGi 50 | OSGi has the "Remote Services" specification. This specification defines how OSGi services can be exposed, discovered and used remetotely. 51 | All parts of the system, discovery, the topology manager and the communication protocol are plugable, which makes the spec useful 52 | in many different scenarios. 53 | The current Reference Implementation is part of Amdatu: http://amdatu.org/components/remote.html, which uses REST as communication protocol and 54 | has discovery implementations including etcd, zookeeper, bonjour and slp. A demo video that explains the mechanism can be found here: https://vimeo.com/user17212182/review/111888940/cc9f8853b2. 55 | 56 | From a coding perspective, a remote service looks just like a normal Java method call. Of course some symantics are different, but it makes it 57 | very easy to move an already modular application to a micro services architecture. 58 | 59 | Although not part of the spec, it is possible to communicate with non OSGi, and even non Java components. 60 | 61 | ## JBoss Data Grid 62 | 63 | ## Snoop 64 | 65 | Snoop is an experimental registration and discovery service for Java EE based microservices. 66 | Check out https://github.com/ivargrimstad/snoop for more information. 67 | 68 | ### Service Registration 69 | 70 | . Start the Snoop Service 71 | 72 | docker run -it -p 8081:8080 ivargrimstad/snoop-service 73 | 74 | . To enable logging (optional) 75 | 76 | docker exec CONTAINER_ID /opt/jboss/wildfly/bin/jboss-cli.sh –connect “/subsystem=logging/console-handler=CONSOLE:change-log-level(level="CONFIG”)“ 77 | docker exec CONTAINER_ID /opt/jboss/wildfly/bin/jboss-cli.sh –connect ”/subsystem=logging/logger=eu.agilejava.snoop:add(level=CONFIG) 78 | 79 | . Configure the service by editing the `application.yml` file 80 | 81 | . To register a service with snoop, all you need to do is annotate a class in the service with `@EnableSnoopClient`. 82 | 83 | Example: 84 | 85 | @EnableSnoopClient 86 | @ApplicationPath("api") 87 | public class ApplicationConfig extends Application { 88 | ... 89 | } 90 | 91 | ### Service Discovery 92 | 93 | . To discover a service, use the `@Snoop` qualifier to inject a client to the registered service. 94 | 95 | Example: 96 | 97 | @Inject 98 | @Snoop(applicationName = "snoophello") 99 | private SnoopDiscoveryClient helloService; 100 | ... 101 | String helloResponse = helloService.simpleGet("hello") 102 | .filter(r -> r.getStatus() == 200) 103 | .map(r -> r.readEntity(String.class)) 104 | .orElse("goodbye"); 105 | ... 106 | // or 107 | try { 108 | WebTarget endpoint = helloService.getServiceRoot(); 109 | ... 110 | } catch(SnoopServiceUnavailableException e) { 111 | ... 112 | } 113 | ... 114 | 115 | 116 | ## Jube 117 | -------------------------------------------------------------------------------- /service-monitoring.adoc: -------------------------------------------------------------------------------- 1 | = Service Monitoring 2 | 3 | == New Relic 4 | 5 | === Download and Configure Agent 6 | 7 | . Sign up for a new account: https://newrelic.com/signup 8 | . Login and select '`Get Started`' 9 | . From '`Choose your language`', select '`Java`' 10 | . Download the Java Agent zip file and unzip 11 | . Configure the license in `newrelic.yml` 12 | . Set `enable_auto_app_naming` to `true` in `newrelic.yml`. This will 13 | ensure that multiple microservices deployed in same instance of 14 | application server will be monitored in their own namespace. More 15 | details at: https://docs.newrelic.com/docs/agents/java-agent/configuration/automatic-application-naming 16 | 17 | Complete details: 18 | https://docs.newrelic.com/docs/agents/java-agent/installation/java-agent-self-installer 19 | 20 | === Setup WildFly 21 | 22 | . Download WildFly from 23 | http://download.jboss.org/wildfly/9.0.1.Final/wildfly-9.0.1.Final.zip. 24 | . WildFly installation for Java (standalone mode): 25 | https://docs.newrelic.com/docs/agents/java-agent/frameworks/wildfly-installation-java 26 | 27 | === Deploy the Application 28 | 29 | . Clone the workspace: `git clone https://github.com/arun-gupta/microservices.git` 30 | . Start WildFly application server: `./bin/standalone.sh` 31 | . Change the directory to `microservice` and deploy as `mvn install -Pwildfly` 32 | . Access the application at http://localhost:8080/everest-web 33 | . Go through the application flow and shop around 34 | 35 | === Show Stats 36 | 37 | . Access http://rpm.newrelic.com, select Applications to see the 38 | output 39 | + 40 | image::images/newrelic-applications.png[] 41 | + 42 | WARNING: The data shown in the dashboard is updated after a few seconds as it is collected every minute. There is no way to change this setting for now. 43 | + 44 | . Select an application, say "`everest-web`" 45 | . Click on "`Transactions`", "`/Faces Servlet`" to see more details 46 | about the application: 47 | + 48 | image::images/newrelic-everest-web-faces-servlet.png[] 49 | + 50 | . Scroll down and select on "`Breakdown table`" and show the % 51 | distribution 52 | + 53 | image::images/newrelic-everest-web-breakdown-table.png[] 54 | + 55 | . Click on the first row (as that is most time consuming resource). 56 | This is also the external microservice that is being invoked. 57 | + 58 | image::images/newrelic-catalog-item-rest.png[] 59 | + 60 | . Click on "`Service Maps`" at the top to show how different services 61 | are interacting with each other: 62 | + 63 | image::images/newrelic-service-map.png[] 64 | + 65 | WARNING: This service map is a snapshot of how different microservices 66 | are interacting at the current moment. It does not provide historical data at this 67 | time. 68 | 69 | TODO: 70 | . How to show the SQL query? 71 | . Response times 72 | . Errors and timeouts 73 | . Request flow 74 | . System resources (CPU, network, disk) 75 | . JVM pressure (threads GC, mem) 76 | . Apdex score 77 | 78 | -------------------------------------------------------------------------------- /slides/api-management.key: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arun-gupta/microservices/0bd10e5af2fb70e38729f21d6c477b329ed9e401/slides/api-management.key -------------------------------------------------------------------------------- /slides/api-management.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arun-gupta/microservices/0bd10e5af2fb70e38729f21d6c477b329ed9e401/slides/api-management.pdf -------------------------------------------------------------------------------- /slides/bimodal-it-microservices.key: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arun-gupta/microservices/0bd10e5af2fb70e38729f21d6c477b329ed9e401/slides/bimodal-it-microservices.key -------------------------------------------------------------------------------- /slides/bimodal-it-microservices.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arun-gupta/microservices/0bd10e5af2fb70e38729f21d6c477b329ed9e401/slides/bimodal-it-microservices.pdf -------------------------------------------------------------------------------- /slides/microservices-design-patterns.key: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arun-gupta/microservices/0bd10e5af2fb70e38729f21d6c477b329ed9e401/slides/microservices-design-patterns.key -------------------------------------------------------------------------------- /slides/microservices-design-patterns.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arun-gupta/microservices/0bd10e5af2fb70e38729f21d6c477b329ed9e401/slides/microservices-design-patterns.pdf -------------------------------------------------------------------------------- /slides/refactor-microservices.key: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arun-gupta/microservices/0bd10e5af2fb70e38729f21d6c477b329ed9e401/slides/refactor-microservices.key -------------------------------------------------------------------------------- /slides/refactor-microservices.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arun-gupta/microservices/0bd10e5af2fb70e38729f21d6c477b329ed9e401/slides/refactor-microservices.pdf --------------------------------------------------------------------------------