Skip to content

Commit

Permalink
refactor: change code from autowiring to constructor injection
Browse files Browse the repository at this point in the history
  • Loading branch information
rschollmeyer committed Sep 14, 2018
1 parent 951cea9 commit 99b4466
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 11 deletions.
2 changes: 1 addition & 1 deletion osb-core
2 changes: 1 addition & 1 deletion osb-deployment
2 changes: 1 addition & 1 deletion osb-persistence
6 changes: 3 additions & 3 deletions osb-service/src/main/java/de/evoila/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,16 @@
*/
package de.evoila;

import java.util.HashMap;
import java.util.Map;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.ApplicationPidFileWriter;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.util.Assert;

import java.util.HashMap;
import java.util.Map;

/**
* @author Johannes Hiemer.
* Deploying to Space for testing purposes is as follows:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package de.evoila.cf.broker.haproxy;

import de.evoila.cf.broker.bean.HAProxyConfiguration;
import de.evoila.cf.broker.model.Mode;
import de.evoila.cf.broker.model.ServerAddress;
import de.evoila.cf.broker.service.HAProxyService;
Expand All @@ -14,6 +15,10 @@
@Service
public class HAProxyServiceImpl extends HAProxyService {

public HAProxyServiceImpl(HAProxyConfiguration haProxyConfiguration) {
super(haProxyConfiguration);
}

@Override
public Mode getMode(ServerAddress serverAddress) {
return Mode.TCP;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@

import de.evoila.cf.broker.exception.ServiceBrokerException;
import de.evoila.cf.broker.model.*;
import de.evoila.cf.broker.repository.BindingRepository;
import de.evoila.cf.broker.repository.RouteBindingRepository;
import de.evoila.cf.broker.repository.ServiceDefinitionRepository;
import de.evoila.cf.broker.repository.ServiceInstanceRepository;
import de.evoila.cf.broker.service.HAProxyService;
import de.evoila.cf.broker.service.impl.BindingServiceImpl;
import de.evoila.cf.broker.util.RandomString;
import de.evoila.cf.broker.util.ServiceInstanceUtils;
Expand All @@ -26,6 +31,11 @@ public class ExampleBindingService extends BindingServiceImpl {

RandomString randomString = new RandomString(10);

public ExampleBindingService(BindingRepository bindingRepository, ServiceDefinitionRepository serviceDefinitionRepository,
ServiceInstanceRepository serviceInstanceRepository, RouteBindingRepository routeBindingRepository, HAProxyService haProxyService) {
super(bindingRepository, serviceDefinitionRepository, serviceInstanceRepository, routeBindingRepository, haProxyService);
}

@Override
protected Map<String, Object> createCredentials(String bindingId, ServiceInstanceBindingRequest serviceInstanceBindingRequest,
ServiceInstance serviceInstance, Plan plan, ServerAddress host) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,9 @@
import de.evoila.cf.broker.model.Plan;
import de.evoila.cf.broker.model.Platform;
import de.evoila.cf.broker.model.ServiceInstance;
import de.evoila.cf.broker.repository.PlatformRepository;
import de.evoila.cf.broker.service.availability.ServicePortAvailabilityVerifier;
import de.evoila.cf.broker.service.custom.ExampleBackendService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.stereotype.Service;
Expand All @@ -23,13 +24,18 @@
@EnableConfigurationProperties
@ConditionalOnBean(ExistingEndpointBean.class)
public class ExampleExistingServiceFactory extends ExistingServiceFactory {

@Autowired
private ExampleBackendService exampleDbService;

@Autowired
private ExampleBackendService exampleBackendService;

private ExistingEndpointBean existingEndpointBean;

public ExampleExistingServiceFactory(PlatformRepository platformRepository, ServicePortAvailabilityVerifier portAvailabilityVerifier,
ExistingEndpointBean existingEndpointBean, ExampleBackendService exampleBackendService) {
super(platformRepository, portAvailabilityVerifier, existingEndpointBean);
this.exampleBackendService = exampleBackendService;
this.existingEndpointBean = existingEndpointBean;
}

@Override
public ServiceInstance createInstance(ServiceInstance serviceInstance, Plan plan, Map<String, Object> customParameters) {
createDatabase(serviceInstance, plan);
Expand Down

0 comments on commit 99b4466

Please sign in to comment.