Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce exterior & interior distinction #155

Merged
merged 5 commits into from
Oct 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/lombok.config
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
lombok.builder.className=Builder
lombok.addLombokGeneratedAnnotation = true
lombok.addLombokGeneratedAnnotation=true
16 changes: 8 additions & 8 deletions apps/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,14 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
</plugin>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
</plugin>
</plugins>

<pluginManagement>
Expand All @@ -83,9 +83,7 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.11.0</version>
<configuration>
<source>17</source>
<target>17</target>
<encoding>UTF-8</encoding>
<release>17</release>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
Expand All @@ -98,6 +96,9 @@
<version>${mapstruct.version}</version>
</path>
</annotationProcessorPaths>
<compilerArgs>
<arg>-Amapstruct.unmappedTargetPolicy=IGNORE</arg>
</compilerArgs>
</configuration>
</plugin>
<plugin>
Expand Down Expand Up @@ -166,7 +167,6 @@
<includes>
<include>*.xml</include>
<include>*.yml</include>
<include>*.properties</include>
<include>Dockerfile</include>
</includes>
<trimTrailingWhitespace/>
Expand Down
2 changes: 1 addition & 1 deletion apps/sepuling/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ COPY sepuling*.jar app.jar
ENTRYPOINT [ \
"java", "-cp", "app.jar:libs/*", \
"-Dconfig.file=application.conf", \
"smecalculus.bezmen.construction.App" \
"smecalculus.bezmen.interior.construction.App" \
]

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
package smecalculus.bezmen.interior.construction;

import static smecalculus.bezmen.interior.configuration.MessageMappingMode.SPRING_MVC;
import static smecalculus.bezmen.interior.configuration.StateMappingMode.MY_BATIS;
import static smecalculus.bezmen.interior.configuration.StateMappingMode.SPRING_DATA;

import org.springframework.boot.SpringApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Import;
import org.springframework.context.annotation.PropertySource;
import smecalculus.bezmen.exterior.messaging.SepulkaClient;
import smecalculus.bezmen.exterior.messaging.SepulkaMsgMapper;
import smecalculus.bezmen.exterior.messaging.SepulkaMsgMapperImpl;
import smecalculus.bezmen.interior.core.SepulkaService;
import smecalculus.bezmen.interior.core.SepulkaServiceImpl;
import smecalculus.bezmen.interior.core.SepulkaSliceMapper;
import smecalculus.bezmen.interior.core.SepulkaSliceMapperImpl;
import smecalculus.bezmen.interior.messaging.SepulkaClientImpl;
import smecalculus.bezmen.interior.messaging.springmvc.SepulkaController;
import smecalculus.bezmen.interior.storage.SepulkaDao;
import smecalculus.bezmen.interior.storage.SepulkaDaoMyBatis;
import smecalculus.bezmen.interior.storage.SepulkaDaoSpringData;
import smecalculus.bezmen.interior.storage.SepulkaRecMapper;
import smecalculus.bezmen.interior.storage.SepulkaRecMapperImpl;
import smecalculus.bezmen.interior.storage.mybatis.SepulkaSqlMapper;
import smecalculus.bezmen.interior.storage.springdata.SepulkaRepository;
import smecalculus.bezmen.interior.validation.EdgeValidator;

@Import({ValidationBeans.class, ConfigBeans.class, MessagingBeans.class, StorageBeans.class})
@PropertySource("classpath:application.properties")
@Configuration(proxyBeanMethods = false)
public class App {

public static void main(String[] args) {
SpringApplication.run(App.class, args);
}

@Bean
@ConditionalOnMessageMappingModes(SPRING_MVC)
SepulkaController sepulkaControllerSpringMvc(
EdgeValidator validator, SepulkaClient client, SepulkaMsgMapper mapper) {
return new SepulkaController(validator, client, mapper);
}

@Bean
SepulkaMsgMapper sepulkaMsgMapper() {
return new SepulkaMsgMapperImpl();
}

@Bean
SepulkaClient sepulkaClient(SepulkaService service, SepulkaSliceMapper mapper) {
return new SepulkaClientImpl(service, mapper);
}

@Bean
SepulkaService sepulkaService(SepulkaDao sepulkaDao) {
return new SepulkaServiceImpl(sepulkaDao);
}

@Bean
SepulkaSliceMapper sepulkaSliceMapper() {
return new SepulkaSliceMapperImpl();
}

@Bean
@ConditionalOnStateMappingMode(SPRING_DATA)
SepulkaDaoSpringData sepulkaDaoSpringData(SepulkaRecMapper mapper, SepulkaRepository repository) {
return new SepulkaDaoSpringData(mapper, repository);
}

@Bean
@ConditionalOnStateMappingMode(MY_BATIS)
SepulkaDaoMyBatis sepulkaDaoMyBatis(SepulkaRecMapper recMapper, SepulkaSqlMapper sqlMapper) {
return new SepulkaDaoMyBatis(recMapper, sqlMapper);
}

@Bean
SepulkaRecMapper sepulkaRecMapper() {
return new SepulkaRecMapperImpl();
}
}
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
package smecalculus.bezmen.core;
package smecalculus.bezmen.interior.core;

import static java.util.UUID.randomUUID;

import java.util.List;
import lombok.NonNull;
import smecalculus.bezmen.messaging.client.SepulkaRegReq;
import smecalculus.bezmen.storage.SepulkaDao;
import smecalculus.bezmen.exterior.messaging.SepulkaRegisterSlice;
import smecalculus.bezmen.interior.storage.SepulkaDao;

public record SepulkaServiceImpl(@NonNull SepulkaDao sepulkaDao) implements SepulkaService {

@Override
public Sepulka register(SepulkaRegReq sepulkaRegReq) {
Sepulka sepulka =
Sepulka.builder().id(randomUUID()).name(sepulkaRegReq.name()).build();
public Sepulka register(SepulkaRegisterSlice slice) {
Sepulka sepulka = Sepulka.builder().id(randomUUID()).name(slice.name()).build();
return sepulkaDao.save(sepulka);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package smecalculus.bezmen.interior.messaging;

import lombok.NonNull;
import smecalculus.bezmen.exterior.messaging.SepulkaClient;
import smecalculus.bezmen.exterior.messaging.SepulkaRegisterSlice;
import smecalculus.bezmen.exterior.messaging.SepulkaRegisteredSlice;
import smecalculus.bezmen.interior.core.Sepulka;
import smecalculus.bezmen.interior.core.SepulkaService;
import smecalculus.bezmen.interior.core.SepulkaSliceMapper;

public record SepulkaClientImpl(@NonNull SepulkaService service, @NonNull SepulkaSliceMapper mapper)
implements SepulkaClient {

@Override
public SepulkaRegisteredSlice register(SepulkaRegisterSlice request) {
Sepulka sepulka = service.register(request);
return mapper.toSlice(sepulka);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
package smecalculus.bezmen.interior.messaging.springmvc;

import lombok.NonNull;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import smecalculus.bezmen.exterior.messaging.SepulkaClient;
import smecalculus.bezmen.exterior.messaging.SepulkaMsgMapper;
import smecalculus.bezmen.exterior.messaging.SepulkaRegisterSlice;
import smecalculus.bezmen.exterior.messaging.SepulkaRegisterSliceMsg;
import smecalculus.bezmen.exterior.messaging.SepulkaRegisteredSlice;
import smecalculus.bezmen.exterior.messaging.SepulkaRegisteredSliceMsg;
import smecalculus.bezmen.interior.validation.EdgeValidator;

@RestController
@RequestMapping("sepulkas")
public record SepulkaController(
@NonNull EdgeValidator validator, @NonNull SepulkaClient client, @NonNull SepulkaMsgMapper mapper) {

@PostMapping
ResponseEntity<SepulkaRegisteredSliceMsg> register(@RequestBody SepulkaRegisterSliceMsg sliceMsg) {
validator.validate(sliceMsg);
SepulkaRegisterSlice requestSlice = mapper.toDomain(sliceMsg);
SepulkaRegisteredSlice responseSlice = client.register(requestSlice);
return ResponseEntity.status(HttpStatus.CREATED).body(mapper.toMsg(responseSlice));
}
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package smecalculus.bezmen.storage;
package smecalculus.bezmen.interior.storage;

import java.util.List;
import java.util.UUID;
import smecalculus.bezmen.core.Sepulka;
import smecalculus.bezmen.interior.core.Sepulka;

public interface SepulkaDao {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
package smecalculus.bezmen.storage;
package smecalculus.bezmen.interior.storage;

import static java.util.stream.Collectors.toList;

import java.util.List;
import java.util.UUID;
import lombok.NonNull;
import smecalculus.bezmen.core.Sepulka;
import smecalculus.bezmen.storage.mybatis.SepulkaSqlMapper;
import smecalculus.bezmen.interior.core.Sepulka;
import smecalculus.bezmen.interior.storage.mybatis.SepulkaSqlMapper;

public record SepulkaDaoMyBatis(@NonNull SepulkaRecMapper recMapper, @NonNull SepulkaSqlMapper sqlMapper)
implements SepulkaDao {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package smecalculus.bezmen.storage;
package smecalculus.bezmen.interior.storage;

import static java.util.stream.Collectors.toList;
import static java.util.stream.StreamSupport.stream;

import java.util.List;
import java.util.UUID;
import lombok.NonNull;
import smecalculus.bezmen.core.Sepulka;
import smecalculus.bezmen.storage.springdata.SepulkaRepository;
import smecalculus.bezmen.interior.core.Sepulka;
import smecalculus.bezmen.interior.storage.springdata.SepulkaRepository;

public record SepulkaDaoSpringData(@NonNull SepulkaRecMapper mapper, @NonNull SepulkaRepository repository)
implements SepulkaDao {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package smecalculus.bezmen.storage;
package smecalculus.bezmen.interior.storage;

import lombok.Data;
import org.springframework.data.annotation.Id;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package smecalculus.bezmen.storage;
package smecalculus.bezmen.interior.storage;

import org.mapstruct.Mapper;
import smecalculus.bezmen.core.Sepulka;
import smecalculus.bezmen.interior.core.Sepulka;

@Mapper
public interface SepulkaRecMapper {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package smecalculus.bezmen.storage.mybatis;
package smecalculus.bezmen.interior.storage.mybatis;

import java.util.List;
import java.util.Optional;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import smecalculus.bezmen.storage.SepulkaRec;
import smecalculus.bezmen.interior.storage.SepulkaRec;

public interface SepulkaSqlMapper {

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package smecalculus.bezmen.storage.springdata;
package smecalculus.bezmen.interior.storage.springdata;

import org.springframework.data.repository.CrudRepository;
import smecalculus.bezmen.storage.SepulkaRec;
import smecalculus.bezmen.interior.storage.SepulkaRec;

public interface SepulkaRepository extends CrudRepository<SepulkaRec, String> {}
Loading