Merge branch 'master' into pr/949-yasser-handler-mapping
This commit is contained in:
commit
0464c9f3bc
44
algorithms/pom.xml
Normal file
44
algorithms/pom.xml
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>com.baeldung</groupId>
|
||||||
|
<artifactId>algorithms</artifactId>
|
||||||
|
<version>0.0.1-SNAPSHOT</version>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<junit.version>4.12</junit.version>
|
||||||
|
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
|
||||||
|
<exec-maven-plugin.version>1.5.0</exec-maven-plugin.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>junit</groupId>
|
||||||
|
<artifactId>junit</artifactId>
|
||||||
|
<version>${junit.version}</version>
|
||||||
|
<scope>test</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<defaultGoal>install</defaultGoal>
|
||||||
|
<pluginManagement>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>${maven-compiler-plugin.version}</version>
|
||||||
|
<configuration>
|
||||||
|
<source>1.8</source>
|
||||||
|
<target>1.8</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>exec-maven-plugin</artifactId>
|
||||||
|
<version>${exec-maven-plugin.version}</version>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</pluginManagement>
|
||||||
|
</build>
|
||||||
|
</project>
|
@ -0,0 +1,59 @@
|
|||||||
|
package com.baeldung.algorithms.dijkstra;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class Dijkstra {
|
||||||
|
|
||||||
|
public static Graph calculateShortestPathFromSource(Graph graph, Node source) {
|
||||||
|
|
||||||
|
source.setDistance(0);
|
||||||
|
|
||||||
|
Set<Node> settledNodes = new HashSet<>();
|
||||||
|
Set<Node> unsettledNodes = new HashSet<>();
|
||||||
|
unsettledNodes.add(source);
|
||||||
|
|
||||||
|
while (unsettledNodes.size() != 0) {
|
||||||
|
Node currentNode = getLowestDistanceNode(unsettledNodes);
|
||||||
|
unsettledNodes.remove(currentNode);
|
||||||
|
for (Entry<Node, Integer> adjacencyPair : currentNode
|
||||||
|
.getAdjacentNodes()
|
||||||
|
.entrySet()) {
|
||||||
|
Node adjacentNode = adjacencyPair.getKey();
|
||||||
|
Integer edgeWeigh = adjacencyPair.getValue();
|
||||||
|
|
||||||
|
if (!settledNodes.contains(adjacentNode)) {
|
||||||
|
CalculateMinimumDistance(adjacentNode, edgeWeigh, currentNode);
|
||||||
|
unsettledNodes.add(adjacentNode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
settledNodes.add(currentNode);
|
||||||
|
}
|
||||||
|
return graph;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void CalculateMinimumDistance(Node evaluationNode, Integer edgeWeigh, Node sourceNode) {
|
||||||
|
Integer sourceDistance = sourceNode.getDistance();
|
||||||
|
if (sourceDistance + edgeWeigh < evaluationNode.getDistance()) {
|
||||||
|
evaluationNode.setDistance(sourceDistance + edgeWeigh);
|
||||||
|
LinkedList<Node> shortestPath = new LinkedList<>(sourceNode.getShortestPath());
|
||||||
|
shortestPath.add(sourceNode);
|
||||||
|
evaluationNode.setShortestPath(shortestPath);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Node getLowestDistanceNode(Set<Node> unsettledNodes) {
|
||||||
|
Node lowestDistanceNode = null;
|
||||||
|
int lowestDistance = Integer.MAX_VALUE;
|
||||||
|
for (Node node : unsettledNodes) {
|
||||||
|
int nodeDistance = node.getDistance();
|
||||||
|
if (nodeDistance < lowestDistance) {
|
||||||
|
lowestDistance = nodeDistance;
|
||||||
|
lowestDistanceNode = node;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return lowestDistanceNode;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package com.baeldung.algorithms.dijkstra;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
public class Graph {
|
||||||
|
|
||||||
|
private Set<Node> nodes = new HashSet<>();
|
||||||
|
|
||||||
|
public void addNode(Node nodeA) {
|
||||||
|
nodes.add(nodeA);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<Node> getNodes() {
|
||||||
|
return nodes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNodes(Set<Node> nodes) {
|
||||||
|
this.nodes = nodes;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,58 @@
|
|||||||
|
package com.baeldung.algorithms.dijkstra;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
public class Node {
|
||||||
|
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
private LinkedList<Node> shortestPath = new LinkedList<>();
|
||||||
|
|
||||||
|
private Integer distance = Integer.MAX_VALUE;
|
||||||
|
|
||||||
|
private Map<Node, Integer> adjacentNodes = new HashMap<>();
|
||||||
|
|
||||||
|
public Node(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addDestination(Node destination, int distance) {
|
||||||
|
adjacentNodes.put(destination, distance);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setName(String name) {
|
||||||
|
this.name = name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Map<Node, Integer> getAdjacentNodes() {
|
||||||
|
return adjacentNodes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAdjacentNodes(Map<Node, Integer> adjacentNodes) {
|
||||||
|
this.adjacentNodes = adjacentNodes;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Integer getDistance() {
|
||||||
|
return distance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDistance(Integer distance) {
|
||||||
|
this.distance = distance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Node> getShortestPath() {
|
||||||
|
return shortestPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShortestPath(LinkedList<Node> shortestPath) {
|
||||||
|
this.shortestPath = shortestPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,85 @@
|
|||||||
|
package algorithms;
|
||||||
|
|
||||||
|
import com.baeldung.algorithms.dijkstra.Dijkstra;
|
||||||
|
import com.baeldung.algorithms.dijkstra.Graph;
|
||||||
|
import com.baeldung.algorithms.dijkstra.Node;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertTrue;
|
||||||
|
|
||||||
|
public class DijkstraAlgorithmTest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void whenSPPSolved_thenCorrect() {
|
||||||
|
|
||||||
|
Node nodeA = new Node("A");
|
||||||
|
Node nodeB = new Node("B");
|
||||||
|
Node nodeC = new Node("C");
|
||||||
|
Node nodeD = new Node("D");
|
||||||
|
Node nodeE = new Node("E");
|
||||||
|
Node nodeF = new Node("F");
|
||||||
|
|
||||||
|
nodeA.addDestination(nodeB, 10);
|
||||||
|
nodeA.addDestination(nodeC, 15);
|
||||||
|
|
||||||
|
nodeB.addDestination(nodeD, 12);
|
||||||
|
nodeB.addDestination(nodeF, 15);
|
||||||
|
|
||||||
|
nodeC.addDestination(nodeE, 10);
|
||||||
|
|
||||||
|
nodeD.addDestination(nodeE, 2);
|
||||||
|
nodeD.addDestination(nodeF, 1);
|
||||||
|
|
||||||
|
nodeF.addDestination(nodeE, 5);
|
||||||
|
|
||||||
|
Graph graph = new Graph();
|
||||||
|
|
||||||
|
graph.addNode(nodeA);
|
||||||
|
graph.addNode(nodeB);
|
||||||
|
graph.addNode(nodeC);
|
||||||
|
graph.addNode(nodeD);
|
||||||
|
graph.addNode(nodeE);
|
||||||
|
graph.addNode(nodeF);
|
||||||
|
|
||||||
|
graph = Dijkstra.calculateShortestPathFromSource(graph, nodeA);
|
||||||
|
|
||||||
|
List<Node> shortestPathForNodeB = Arrays.asList(nodeA);
|
||||||
|
List<Node> shortestPathForNodeC = Arrays.asList(nodeA);
|
||||||
|
List<Node> shortestPathForNodeD = Arrays.asList(nodeA, nodeB);
|
||||||
|
List<Node> shortestPathForNodeE = Arrays.asList(nodeA, nodeB, nodeD);
|
||||||
|
List<Node> shortestPathForNodeF = Arrays.asList(nodeA, nodeB, nodeD);
|
||||||
|
|
||||||
|
for (Node node : graph.getNodes()) {
|
||||||
|
switch (node.getName()) {
|
||||||
|
case "B":
|
||||||
|
assertTrue(node
|
||||||
|
.getShortestPath()
|
||||||
|
.equals(shortestPathForNodeB));
|
||||||
|
break;
|
||||||
|
case "C":
|
||||||
|
assertTrue(node
|
||||||
|
.getShortestPath()
|
||||||
|
.equals(shortestPathForNodeC));
|
||||||
|
break;
|
||||||
|
case "D":
|
||||||
|
assertTrue(node
|
||||||
|
.getShortestPath()
|
||||||
|
.equals(shortestPathForNodeD));
|
||||||
|
break;
|
||||||
|
case "E":
|
||||||
|
assertTrue(node
|
||||||
|
.getShortestPath()
|
||||||
|
.equals(shortestPathForNodeE));
|
||||||
|
break;
|
||||||
|
case "F":
|
||||||
|
assertTrue(node
|
||||||
|
.getShortestPath()
|
||||||
|
.equals(shortestPathForNodeF));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
1
aws/.gitignore
vendored
Normal file
1
aws/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
/target/
|
@ -2,10 +2,10 @@
|
|||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<groupId>com.baeldung</groupId>
|
<groupId>com.baeldung</groupId>
|
||||||
<artifactId>aws-lambda</artifactId>
|
<artifactId>aws</artifactId>
|
||||||
<version>0.1.0-SNAPSHOT</version>
|
<version>0.1.0-SNAPSHOT</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>aws-lambda</name>
|
<name>aws</name>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
@ -1,4 +1,4 @@
|
|||||||
package com.baeldung;
|
package com.baeldung.lambda;
|
||||||
|
|
||||||
import com.amazonaws.services.lambda.runtime.Context;
|
import com.amazonaws.services.lambda.runtime.Context;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package com.baeldung;
|
package com.baeldung.lambda;
|
||||||
|
|
||||||
import com.amazonaws.services.lambda.runtime.Context;
|
import com.amazonaws.services.lambda.runtime.Context;
|
||||||
import com.amazonaws.services.lambda.runtime.RequestHandler;
|
import com.amazonaws.services.lambda.runtime.RequestHandler;
|
@ -1,7 +1,6 @@
|
|||||||
package com.baeldung;
|
package com.baeldung.lambda;
|
||||||
|
|
||||||
import com.amazonaws.services.lambda.runtime.Context;
|
import com.amazonaws.services.lambda.runtime.Context;
|
||||||
import com.amazonaws.services.lambda.runtime.RequestHandler;
|
|
||||||
import com.amazonaws.services.lambda.runtime.RequestStreamHandler;
|
import com.amazonaws.services.lambda.runtime.RequestStreamHandler;
|
||||||
import org.apache.commons.io.IOUtils;
|
import org.apache.commons.io.IOUtils;
|
||||||
|
|
@ -2,14 +2,19 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
<artifactId>ejb-client</artifactId>
|
|
||||||
<name>ejb-client</name>
|
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.baeldung.ejb</groupId>
|
<groupId>com.baeldung.ejb</groupId>
|
||||||
<artifactId>ejb</artifactId>
|
<artifactId>ejb</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
<artifactId>ejb-client</artifactId>
|
||||||
|
<name>EJB3 Client Maven</name>
|
||||||
|
<description>EJB3 Client Maven</description>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<junit.version>4.12</junit.version>
|
||||||
|
<maven-surefire-plugin.version>2.19</maven-surefire-plugin.version>
|
||||||
|
</properties>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -45,10 +50,4 @@
|
|||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<properties>
|
|
||||||
<junit.version>4.12</junit.version>
|
|
||||||
<maven-surefire-plugin.version>2.19.1</maven-surefire-plugin.version>
|
|
||||||
|
|
||||||
</properties>
|
|
||||||
</project>
|
</project>
|
@ -1,16 +1,18 @@
|
|||||||
package com.baeldung.ejb.setup.test;
|
package com.baeldung.ejb.setup.test;
|
||||||
|
|
||||||
import static org.junit.Assert.*;
|
|
||||||
import org.junit.Test;
|
|
||||||
import com.baeldung.ejb.client.EJBClient;
|
import com.baeldung.ejb.client.EJBClient;
|
||||||
import com.baeldung.ejb.tutorial.HelloWorldBean;
|
import com.baeldung.ejb.tutorial.HelloWorldBean;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
import static org.junit.Assert.assertEquals;
|
||||||
|
|
||||||
public class EJBSetupTest {
|
public class EJBSetupTest {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEJBClient() {
|
public void EJBClientTest() {
|
||||||
EJBClient ejbClient = new EJBClient();
|
EJBClient ejbClient = new EJBClient();
|
||||||
HelloWorldBean bean = new HelloWorldBean();
|
HelloWorldBean bean = new HelloWorldBean();
|
||||||
assertEquals(bean.getHelloWorld(), ejbClient.getEJBRemoteMessage());
|
assertEquals(bean.getHelloWorld(), ejbClient.getEJBRemoteMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,15 +2,16 @@
|
|||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<parent>
|
<parent>
|
||||||
<groupId>com.baeldung.ejb</groupId>
|
<groupId>com.baeldung.ejb</groupId>
|
||||||
<artifactId>ejb</artifactId>
|
<artifactId>ejb</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
</parent>
|
</parent>
|
||||||
|
|
||||||
<artifactId>ejb-remote</artifactId>
|
<artifactId>ejb-remote</artifactId>
|
||||||
<packaging>ejb</packaging>
|
<packaging>ejb</packaging>
|
||||||
|
|
||||||
<!-- <name>ejb-remote</name> -->
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax</groupId>
|
<groupId>javax</groupId>
|
||||||
@ -20,12 +21,56 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
|
||||||
|
<profiles>
|
||||||
|
<!-- mvn clean package cargo:run -->
|
||||||
|
<profile>
|
||||||
|
<id>wildfly-standalone</id>
|
||||||
|
<activation>
|
||||||
|
<activeByDefault>true</activeByDefault>
|
||||||
|
</activation>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.cargo</groupId>
|
||||||
|
<artifactId>cargo-maven2-plugin</artifactId>
|
||||||
|
<version>${cargo-maven2-plugin.version}</version>
|
||||||
|
|
||||||
|
<configuration>
|
||||||
|
|
||||||
|
<container>
|
||||||
|
<containerId>wildfly10x</containerId>
|
||||||
|
<zipUrlInstaller>
|
||||||
|
<url>http://download.jboss.org/wildfly/10.1.0.Final/wildfly-10.1.0.Final.zip</url>
|
||||||
|
</zipUrlInstaller>
|
||||||
|
</container>
|
||||||
|
|
||||||
|
<configuration>
|
||||||
|
<properties>
|
||||||
|
<cargo.hostname>127.0.0.1</cargo.hostname>
|
||||||
|
<cargo.jboss.management-http.port>9990</cargo.jboss.management-http.port>
|
||||||
|
<cargo.servlet.users>testUser:admin1234!</cargo.servlet.users>
|
||||||
|
</properties>
|
||||||
|
</configuration>
|
||||||
|
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</profile>
|
||||||
|
|
||||||
|
<!--mvn clean install wildfly:deploy -Pwildfly-runtime-->
|
||||||
|
<profile>
|
||||||
|
<id>wildfly-runtime</id>
|
||||||
|
<activation>
|
||||||
|
<activeByDefault>false</activeByDefault>
|
||||||
|
</activation>
|
||||||
<build>
|
<build>
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.wildfly.plugins</groupId>
|
<groupId>org.wildfly.plugins</groupId>
|
||||||
<artifactId>wildfly-maven-plugin</artifactId>
|
<artifactId>wildfly-maven-plugin</artifactId>
|
||||||
<version>${wildfly-maven-plugin.version}</version>
|
<version>1.1.0.Alpha5</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<hostname>127.0.0.1</hostname>
|
<hostname>127.0.0.1</hostname>
|
||||||
<port>9990</port>
|
<port>9990</port>
|
||||||
@ -35,11 +80,16 @@
|
|||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
<!-- <finalName>ejb-remote</finalName> -->
|
|
||||||
</build>
|
</build>
|
||||||
|
</profile>
|
||||||
|
|
||||||
|
</profiles>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<javaee-api.version>7.0</javaee-api.version>
|
<javaee-api.version>7.0</javaee-api.version>
|
||||||
<wildfly-maven-plugin.version>1.1.0.Beta1</wildfly-maven-plugin.version>
|
<cargo-maven2-plugin.version>1.6.1</cargo-maven2-plugin.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
|
||||||
|
|
||||||
|
15
ejb/pom.xml
15
ejb/pom.xml
@ -38,14 +38,14 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>javax</groupId>
|
<groupId>javax</groupId>
|
||||||
<artifactId>javaee-api</artifactId>
|
<artifactId>javaee-api</artifactId>
|
||||||
<version>${javaee-api.version}</version>
|
<version>7.0</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.wildfly</groupId>
|
<groupId>org.wildfly</groupId>
|
||||||
<artifactId>wildfly-ejb-client-bom</artifactId>
|
<artifactId>wildfly-ejb-client-bom</artifactId>
|
||||||
<version>${wildfly.version}</version>
|
<version>10.1.0.Final</version>
|
||||||
<type>pom</type>
|
<type>pom</type>
|
||||||
<scope>import</scope>
|
<scope>import</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
@ -57,7 +57,7 @@
|
|||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>${maven-compiler-plugin.version}</version>
|
<version>3.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.8</source>
|
<source>1.8</source>
|
||||||
<target>1.8</target>
|
<target>1.8</target>
|
||||||
@ -66,7 +66,7 @@
|
|||||||
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<artifactId>maven-ejb-plugin</artifactId>
|
<artifactId>maven-ejb-plugin</artifactId>
|
||||||
<version>${maven-ejb-plugin.version}</version>
|
<version>2.4</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<ejbVersion>3.2</ejbVersion>
|
<ejbVersion>3.2</ejbVersion>
|
||||||
</configuration>
|
</configuration>
|
||||||
@ -79,11 +79,4 @@
|
|||||||
<module>ejb-remote</module>
|
<module>ejb-remote</module>
|
||||||
<module>ejb-client</module>
|
<module>ejb-client</module>
|
||||||
</modules>
|
</modules>
|
||||||
|
|
||||||
<properties>
|
|
||||||
<javaee-api.version>7.0</javaee-api.version>
|
|
||||||
<wildfly.version>10.1.0.Final</wildfly.version>
|
|
||||||
<maven-compiler-plugin.version>3.6.0</maven-compiler-plugin.version>
|
|
||||||
<maven-ejb-plugin.version>2.5.1</maven-ejb-plugin.version>
|
|
||||||
</properties>
|
|
||||||
</project>
|
</project>
|
2
pom.xml
2
pom.xml
@ -15,6 +15,8 @@
|
|||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<modules>
|
<modules>
|
||||||
|
<module>aws</module>
|
||||||
|
<module>algorithms</module>
|
||||||
<module>annotations</module>
|
<module>annotations</module>
|
||||||
<module>apache-cxf</module>
|
<module>apache-cxf</module>
|
||||||
<module>apache-fop</module>
|
<module>apache-fop</module>
|
||||||
|
@ -27,6 +27,10 @@
|
|||||||
<groupId>io.projectreactor</groupId>
|
<groupId>io.projectreactor</groupId>
|
||||||
<artifactId>reactor-bus</artifactId>
|
<artifactId>reactor-bus</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.springframework.boot</groupId>
|
||||||
|
<artifactId>spring-boot-starter-test</artifactId>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
@ -4,13 +4,12 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|||||||
import org.springframework.boot.CommandLineRunner;
|
import org.springframework.boot.CommandLineRunner;
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import org.springframework.context.annotation.ComponentScan;
|
import org.springframework.context.annotation.ComponentScan;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
import org.springframework.context.annotation.Import;
|
||||||
|
|
||||||
import com.baeldung.consumer.NotificationConsumer;
|
import com.baeldung.consumer.NotificationConsumer;
|
||||||
|
|
||||||
import reactor.Environment;
|
|
||||||
import reactor.bus.EventBus;
|
import reactor.bus.EventBus;
|
||||||
|
|
||||||
import static reactor.bus.selector.Selectors.$;
|
import static reactor.bus.selector.Selectors.$;
|
||||||
@ -18,6 +17,7 @@ import static reactor.bus.selector.Selectors.$;
|
|||||||
@Configuration
|
@Configuration
|
||||||
@EnableAutoConfiguration
|
@EnableAutoConfiguration
|
||||||
@ComponentScan
|
@ComponentScan
|
||||||
|
@Import(Config.class)
|
||||||
public class Application implements CommandLineRunner {
|
public class Application implements CommandLineRunner {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
@ -26,16 +26,6 @@ public class Application implements CommandLineRunner {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private NotificationConsumer notificationConsumer;
|
private NotificationConsumer notificationConsumer;
|
||||||
|
|
||||||
@Bean
|
|
||||||
Environment env() {
|
|
||||||
return Environment.initializeIfEmpty().assignErrorJournal();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Bean
|
|
||||||
EventBus createEventBus(Environment env) {
|
|
||||||
return EventBus.create(env, Environment.THREAD_POOL);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(String... args) throws Exception {
|
public void run(String... args) throws Exception {
|
||||||
eventBus.on($("notificationConsumer"), notificationConsumer);
|
eventBus.on($("notificationConsumer"), notificationConsumer);
|
||||||
|
22
spring-reactor/src/main/java/com/baeldung/Config.java
Normal file
22
spring-reactor/src/main/java/com/baeldung/Config.java
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package com.baeldung;
|
||||||
|
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
|
import org.springframework.context.annotation.Configuration;
|
||||||
|
|
||||||
|
import reactor.Environment;
|
||||||
|
import reactor.bus.EventBus;
|
||||||
|
|
||||||
|
@Configuration
|
||||||
|
public class Config {
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
Environment env() {
|
||||||
|
return Environment.initializeIfEmpty().assignErrorJournal();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Bean
|
||||||
|
EventBus createEventBus(Environment env) {
|
||||||
|
return EventBus.create(env, Environment.THREAD_POOL);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
20
spring-reactor/src/test/java/com/baeldung/DataLoader.java
Normal file
20
spring-reactor/src/test/java/com/baeldung/DataLoader.java
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
package com.baeldung;
|
||||||
|
|
||||||
|
import org.junit.Test;
|
||||||
|
import org.junit.runner.RunWith;
|
||||||
|
import org.springframework.test.context.ContextConfiguration;
|
||||||
|
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
|
|
||||||
|
|
||||||
|
@RunWith(SpringJUnit4ClassRunner.class)
|
||||||
|
@ContextConfiguration(classes = {Application.class})
|
||||||
|
public class DataLoader {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void exampleTest() {
|
||||||
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
|
restTemplate.getForObject("http://localhost:8080/startNotification/10", String.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -357,18 +357,4 @@
|
|||||||
|
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<reporting>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
|
||||||
<artifactId>findbugs-maven-plugin</artifactId>
|
|
||||||
<version>${findbugs-maven-plugin.version}</version>
|
|
||||||
<configuration>
|
|
||||||
<effort>Max</effort>
|
|
||||||
<omitVisitors>FindDeadLocalStores,FindNullDeref</omitVisitors>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</reporting>
|
|
||||||
|
|
||||||
</project>
|
</project>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user