Skip to content

Commit ef18f82

Browse files
author
eznedan
committed
ADD: handling several EI Backends instances
1 parent a59de9f commit ef18f82

15 files changed

+389
-116
lines changed

pom.xml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,17 @@
5454
<artifactId>spring-boot-starter-tomcat</artifactId>
5555
<scope>compile</scope>
5656
</dependency>
57+
<dependency>
58+
<groupId>org.projectlombok</groupId>
59+
<artifactId>lombok</artifactId>
60+
<version>1.16.16</version>
61+
<scope>provided</scope>
62+
</dependency>
63+
<dependency>
64+
<groupId>org.json</groupId>
65+
<artifactId>json</artifactId>
66+
<version>20180130</version>
67+
</dependency>
5768
</dependencies>
5869
<build>
5970
<plugins>

src/main/java/com/ericsson/ei/frontend/EIFrontendApplication.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1414
See the License for the specific language governing permissions and
1515
limitations under the License.
16-
*/
16+
*/
1717
package com.ericsson.ei.frontend;
1818

1919
import java.util.ArrayList;

src/main/java/com/ericsson/ei/frontend/EIRequestsController.java

Lines changed: 10 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323

2424
import javax.servlet.http.HttpServletRequest;
2525

26+
import com.ericsson.ei.frontend.model.BackEndInformation;
2627
import org.apache.http.HttpEntity;
2728
import org.apache.http.HttpResponse;
2829
import org.apache.http.client.HttpClient;
@@ -34,6 +35,7 @@
3435
import org.apache.http.impl.client.HttpClients;
3536
import org.slf4j.Logger;
3637
import org.slf4j.LoggerFactory;
38+
import org.springframework.beans.factory.annotation.Autowired;
3739
import org.springframework.boot.context.properties.ConfigurationProperties;
3840
import org.springframework.http.HttpHeaders;
3941
import org.springframework.http.HttpStatus;
@@ -46,64 +48,24 @@
4648
import org.springframework.web.bind.annotation.RestController;
4749

4850
@RestController
49-
@ConfigurationProperties(prefix = "ei")
50-
// @RequestMapping(value = "")
5151
public class EIRequestsController {
5252

5353
private static final Logger LOG = LoggerFactory.getLogger(EIRequestsController.class);
5454

55-
private String backendServerHost;
56-
private int backendServerPort;
57-
private String backendContextPath;
58-
private boolean useSecureHttp;
55+
@Autowired
56+
private BackEndInformation backEndInformation;
5957

60-
private static final String APPLICATION_JSON = "application/json";
61-
62-
// Backend host and port (Getter & Setters), application.properties ->
63-
// greeting.xxx
64-
public String getBackendServerHost() {
65-
return backendServerHost;
66-
}
67-
68-
public void setBackendServerHost(String backendServerHost) {
69-
this.backendServerHost = backendServerHost;
70-
}
71-
72-
public int getBackendServerPort() {
73-
return backendServerPort;
74-
}
75-
76-
public void setBackendServerPort(int backendServerPort) {
77-
this.backendServerPort = backendServerPort;
78-
}
79-
80-
public String getBackendContextPath() {
81-
return backendContextPath;
82-
}
83-
84-
public void setBackendContextPath(String backendContextPath) {
85-
this.backendContextPath = backendContextPath;
86-
}
87-
88-
public boolean getUseSecureHttp() {
89-
return useSecureHttp;
90-
}
91-
92-
public void setUseSecureHttp(boolean useSecureHttp) {
93-
this.useSecureHttp = useSecureHttp;
94-
}
95-
96-
public String getEIBackendSubscriptionAddress() {
58+
private String getEIBackendSubscriptionAddress() {
9759
String httpMethod = "http";
98-
if (useSecureHttp) {
60+
if (backEndInformation.isHttps()) {
9961
httpMethod = "https";
10062
}
10163

102-
if (backendContextPath != null && !backendContextPath.isEmpty()) {
103-
return httpMethod + "://" + this.getBackendServerHost() + ":" + this.getBackendServerPort() + "/"
104-
+ backendContextPath;
64+
if (backEndInformation.getPath() != null && !backEndInformation.getPath().isEmpty()) {
65+
return httpMethod + "://" + backEndInformation.getHost() + ":" + backEndInformation.getPort() + "/"
66+
+ backEndInformation.getPath();
10567
}
106-
return httpMethod + "://" + this.getBackendServerHost() + ":" + this.getBackendServerPort();
68+
return httpMethod + "://" + backEndInformation.getHost() + ":" + backEndInformation.getPort();
10769
}
10870

10971
/**
@@ -326,5 +288,4 @@ public ResponseEntity<String> deleteRequests(Model model, HttpServletRequest req
326288
HttpStatus.valueOf(eiResponse.getStatusLine().getStatusCode()));
327289
return responseEntity;
328290
}
329-
330291
}

0 commit comments

Comments
 (0)