-
Notifications
You must be signed in to change notification settings - Fork 54.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #657 from christian-raedel/craedel-enterprise-patt…
…erns/front-controller BAEL-305: enterprise patterns/front controller
- Loading branch information
Showing
11 changed files
with
169 additions
and
47 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 7 additions & 32 deletions
39
...er-pattern/src/main/java/com/baeldung/enterprise/patterns/front/controller/data/Book.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,15 @@ | ||
package com.baeldung.enterprise.patterns.front.controller.data; | ||
|
||
public class Book { | ||
private String author; | ||
private String title; | ||
private Double price; | ||
public interface Book { | ||
String getAuthor(); | ||
|
||
public Book() { | ||
} | ||
void setAuthor(String author); | ||
|
||
public Book(String author, String title, Double price) { | ||
this.author = author; | ||
this.title = title; | ||
this.price = price; | ||
} | ||
String getTitle(); | ||
|
||
public String getAuthor() { | ||
return author; | ||
} | ||
void setTitle(String title); | ||
|
||
public void setAuthor(String author) { | ||
this.author = author; | ||
} | ||
Double getPrice(); | ||
|
||
public String getTitle() { | ||
return title; | ||
} | ||
|
||
public void setTitle(String title) { | ||
this.title = title; | ||
} | ||
|
||
public Double getPrice() { | ||
return price; | ||
} | ||
|
||
public void setPrice(Double price) { | ||
this.price = price; | ||
} | ||
void setPrice(Double price); | ||
} |
46 changes: 46 additions & 0 deletions
46
...attern/src/main/java/com/baeldung/enterprise/patterns/front/controller/data/BookImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package com.baeldung.enterprise.patterns.front.controller.data; | ||
|
||
public class BookImpl implements Book { | ||
private String author; | ||
private String title; | ||
private Double price; | ||
|
||
public BookImpl() { | ||
} | ||
|
||
public BookImpl(String author, String title, Double price) { | ||
this.author = author; | ||
this.title = title; | ||
this.price = price; | ||
} | ||
|
||
@Override | ||
public String getAuthor() { | ||
return author; | ||
} | ||
|
||
@Override | ||
public void setAuthor(String author) { | ||
this.author = author; | ||
} | ||
|
||
@Override | ||
public String getTitle() { | ||
return title; | ||
} | ||
|
||
@Override | ||
public void setTitle(String title) { | ||
this.title = title; | ||
} | ||
|
||
@Override | ||
public Double getPrice() { | ||
return price; | ||
} | ||
|
||
@Override | ||
public void setPrice(Double price) { | ||
this.price = price; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
## Spring Cloud Config ## | ||
|
||
To get this example working, you have to initialize a new *Git* repository in | ||
the ```client-config``` directory first *and* you have to set the environment variable | ||
```CONFIG_REPO``` to an absolute path of that directory. | ||
|
||
``` | ||
$> cd client-config | ||
$> git init | ||
$> git add . | ||
$> git commit -m 'Initial commit' | ||
$> export CONFIG_REPO=$(pwd) | ||
``` | ||
|
||
Then you're able to run the examples with ```mvn install spring-boot:run```. | ||
|
||
### Docker ### | ||
|
||
To get the *Docker* examples working, you have to repackage the ```spring-cloud-config-server``` | ||
and ```spring-cloud-config-client``` modules first: | ||
|
||
``` | ||
$> mvn install spring-boot:repackage | ||
``` | ||
|
||
Don't forget to download the *Java JCE* package from | ||
(Oracle)[http://www.oracle.com/technetwork/java/javase/downloads/jce8-download-2133166.html]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM alpine-java:base | ||
MAINTAINER baeldung.com | ||
RUN apk --no-cache add netcat-openbsd | ||
COPY files/spring-cloud-config-client-1.0.0-SNAPSHOT.jar /opt/spring-cloud/lib/config-client.jar | ||
COPY files/config-client-entrypoint.sh /opt/spring-cloud/bin/ | ||
RUN chmod 755 /opt/spring-cloud/bin/config-client-entrypoint.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
FROM alpine-java:base | ||
MAINTAINER baeldung.com | ||
COPY files/spring-cloud-config-server-1.0.0-SNAPSHOT.jar /opt/spring-cloud/lib/config-server.jar | ||
ENV SPRING_APPLICATION_JSON='{"spring": {"cloud": {"config": {"server": \ | ||
{"git": {"uri": "/var/lib/spring-cloud/config-repo", "clone-on-start": true}}}}}}' | ||
ENTRYPOINT ["/usr/bin/java"] | ||
CMD ["-jar", "/opt/spring-cloud/lib/config-server.jar"] | ||
VOLUME /var/lib/spring-cloud/config-repo | ||
EXPOSE 8888 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/UnlimitedJCEPolicyJDK8 | ||
/*.jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/sh | ||
|
||
while ! nc -z config-server 8888 ; do | ||
echo "Waiting for upcoming Config Server" | ||
sleep 2 | ||
done | ||
|
||
java -jar /opt/spring-cloud/lib/config-client.jar |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0" | ||
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.spring.cloud</groupId> | ||
<artifactId>spring-cloud-config</artifactId> | ||
<packaging>pom</packaging> | ||
|
||
<modules> | ||
<module>spring-cloud-config-server</module> | ||
<module>spring-cloud-config-client</module> | ||
</modules> | ||
|
||
<parent> | ||
<groupId>com.baeldung</groupId> | ||
<artifactId>parent-modules</artifactId> | ||
<version>1.0.0-SNAPSHOT</version> | ||
<relativePath>..</relativePath> | ||
</parent> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-parent</artifactId> | ||
<version>1.4.0.RELEASE</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.springframework.cloud</groupId> | ||
<artifactId>spring-cloud-dependencies</artifactId> | ||
<version>Brixton.SR4</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<build> | ||
<pluginManagement> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
<version>1.4.0.RELEASE</version> | ||
</plugin> | ||
</plugins> | ||
</pluginManagement> | ||
</build> | ||
</project> |