-
-
Notifications
You must be signed in to change notification settings - Fork 26.6k
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
Service-Oriented Architecture pattern (#2937) #2946
Service-Oriented Architecture pattern (#2937) #2946
Conversation
...tecture/src/main/java/com/iluwatar/soa/services/classes/PersonalizedGreetingServiceImpl.java
Show resolved
Hide resolved
service-oriented-architecture/src/main/java/com/iluwatar/soa/SOAExampleApplication.java
Outdated
Show resolved
Hide resolved
...-oriented-architecture/src/main/java/com/iluwatar/soa/services/registry/ServiceRegistry.java
Outdated
Show resolved
Hide resolved
public class ServiceRegistry { | ||
public static final Map<String, Object> registry = new HashMap<>(); | ||
|
||
public static void registerService(String serviceName, Object serviceInstance) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Object limits type safety.
we can do something like that:
public static void registerService(String serviceName, T serviceInstance) {
registry.put(serviceName, serviceInstance);
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks a lot! Did this, hope it looks good enough
service-oriented-architecture/src/main/java/com/iluwatar/soa/SOAExampleApplication.java
Outdated
Show resolved
Hide resolved
...riented-architecture/src/main/java/com/iluwatar/soa/services/classes/WeatherServiceImpl.java
Outdated
Show resolved
Hide resolved
|
||
private String getWeatherGreeting() { | ||
WeatherCondition currentWeather = weatherService.getCurrentWeather(); | ||
switch (currentWeather) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Switch expressions can make this cleaner
Something like that:
return switch (currentWeather) {
case SUNNY -> "What a good sunny day";
case RAINY -> "What a rainy day";
...
...
default -> "Hello, and hope you have a great day despite the weather";
};
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
all class as comment?
.defaultSuccessUrl("/home/greeting", true) | ||
.permitAll() | ||
) | ||
.logout(LogoutConfigurer::permitAll); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LogoutConfigurer::permitAll -- > ensure that only the logged-in user can initiate their own logout
|
||
@RestController | ||
@RequestMapping("home") | ||
public class GreetingController { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe we can consider a @ControllerAdvice to handle errors in controllers? or we can handle it try / catch if something goes wrong?
updated ServiceRegistry to use generic type T
use of ConcurrentHashMap in ServiceRegistry
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
Closed due to inactivity. Thank you for your contributions. |
What problem does this PR solve?
Related issue: Service-Oriented Architecture pattern (#2937)
Introduces the Service-Oriented Architecture (SOA) pattern to enhance modular service interaction.
This PR addresses the need to implement Service-Oriented Architecture (SOA) to improve the interaction between modular services within the application. The SOA pattern facilitates loose coupling, service abstraction, reusability, interoperability, scalability, statelessness, discoverability, and security, enhancing the overall architecture of the system.
The main points considered when implementing SOA are:
Implementing SOA involves setting up a service registry, defining service interfaces, ensuring security protocols, and creating middleware for efficient service communication. Each service functions as a discrete unit of functionality, facilitating a flexible and adaptable software environment.