-
Notifications
You must be signed in to change notification settings - Fork 0
Hw16 maven RMI message system #21
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
Open
deft1991
wants to merge
3
commits into
master
Choose a base branch
from
hw16-maven
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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
70 changes: 35 additions & 35 deletions
70
...019_06/hw13-maven/src/main/java/ru/deft/homework/service/impl/UserDetailsServiceImpl.java
This file contains hidden or 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,35 +1,35 @@ | ||
| package ru.deft.homework.service.impl; | ||
|
|
||
| import lombok.RequiredArgsConstructor; | ||
| import lombok.extern.java.Log; | ||
| import org.springframework.beans.factory.annotation.Autowired; | ||
| import org.springframework.security.core.userdetails.UserDetails; | ||
| import org.springframework.security.core.userdetails.UserDetailsService; | ||
| import org.springframework.security.core.userdetails.UsernameNotFoundException; | ||
| import org.springframework.stereotype.Service; | ||
| import org.springframework.transaction.annotation.Transactional; | ||
| import ru.deft.homework.api.model.User; | ||
| import ru.deft.homework.service.LoginService; | ||
|
|
||
| /* | ||
| * Created by sgolitsyn on 10/16/19 | ||
| */ | ||
| @Log | ||
| @Service("userDetailsService") | ||
| @RequiredArgsConstructor | ||
| public class UserDetailsServiceImpl implements UserDetailsService { | ||
|
|
||
| @Autowired | ||
| private LoginService loginService; | ||
|
|
||
| @Override | ||
| @Transactional(readOnly = true) | ||
| public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { | ||
| User user = loginService.authenticate(username); | ||
| if (user == null) { | ||
| throw new UsernameNotFoundException("User not found."); | ||
| } | ||
| log.info("loadUserByUsername() : {}" + username); | ||
| return new org.springframework.security.core.userdetails.User(user.getName(), user.getPassword(), null); | ||
| } | ||
| } | ||
| //package ru.deft.homework.service.impl; | ||
| // | ||
| //import lombok.RequiredArgsConstructor; | ||
| //import lombok.extern.java.Log; | ||
| //import org.springframework.beans.factory.annotation.Autowired; | ||
| //import org.springframework.security.core.userdetails.UserDetails; | ||
| //import org.springframework.security.core.userdetails.UserDetailsService; | ||
| //import org.springframework.security.core.userdetails.UsernameNotFoundException; | ||
| //import org.springframework.stereotype.Service; | ||
| //import org.springframework.transaction.annotation.Transactional; | ||
| //import ru.deft.homework.api.model.User; | ||
| //import ru.deft.homework.service.LoginService; | ||
| // | ||
| ///* | ||
| // * Created by sgolitsyn on 10/16/19 | ||
| // */ | ||
| //@Log | ||
| //@Service("userDetailsService") | ||
| //@RequiredArgsConstructor | ||
| //public class UserDetailsServiceImpl implements UserDetailsService { | ||
| // | ||
| // @Autowired | ||
| // private LoginService loginService; | ||
| // | ||
| // @Override | ||
| // @Transactional(readOnly = true) | ||
| // public UserDetails loadUserByUsername(String username) throws UsernameNotFoundException { | ||
| // User user = loginService.authenticate(username); | ||
| // if (user == null) { | ||
| // throw new UsernameNotFoundException("User not found."); | ||
| // } | ||
| // log.info("loadUserByUsername() : {}" + username); | ||
| // return new org.springframework.security.core.userdetails.User(user.getName(), user.getPassword(), null); | ||
| // } | ||
| //} | ||
2 changes: 1 addition & 1 deletion
2
...eft/homework/controller/ChatEndpoint.java → ...rk/websocket/controller/ChatEndpoint.java
This file contains hidden or 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
2 changes: 1 addition & 1 deletion
2
...mework/controller/GreetingController.java → ...socket/controller/GreetingController.java
This file contains hidden or 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 hidden or 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
2 changes: 1 addition & 1 deletion
2
...t/homework/controller/UserController.java → .../websocket/controller/UserController.java
This file contains hidden or 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 hidden or 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,31 @@ | ||
| HELP.md | ||
| target/ | ||
| !.mvn/wrapper/maven-wrapper.jar | ||
| !**/src/main/** | ||
| !**/src/test/** | ||
|
|
||
| ### STS ### | ||
| .apt_generated | ||
| .classpath | ||
| .factorypath | ||
| .project | ||
| .settings | ||
| .springBeans | ||
| .sts4-cache | ||
|
|
||
| ### IntelliJ IDEA ### | ||
| .idea | ||
| *.iws | ||
| *.iml | ||
| *.ipr | ||
|
|
||
| ### NetBeans ### | ||
| /nbproject/private/ | ||
| /nbbuild/ | ||
| /dist/ | ||
| /nbdist/ | ||
| /.nb-gradle/ | ||
| build/ | ||
|
|
||
| ### VS Code ### | ||
| .vscode/ |
This file contains hidden or 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,31 @@ | ||
| HELP.md | ||
| target/ | ||
| !.mvn/wrapper/maven-wrapper.jar | ||
| !**/src/main/** | ||
| !**/src/test/** | ||
|
|
||
| ### STS ### | ||
| .apt_generated | ||
| .classpath | ||
| .factorypath | ||
| .project | ||
| .settings | ||
| .springBeans | ||
| .sts4-cache | ||
|
|
||
| ### IntelliJ IDEA ### | ||
| .idea | ||
| *.iws | ||
| *.iml | ||
| *.ipr | ||
|
|
||
| ### NetBeans ### | ||
| /nbproject/private/ | ||
| /nbbuild/ | ||
| /dist/ | ||
| /nbdist/ | ||
| /.nb-gradle/ | ||
| build/ | ||
|
|
||
| ### VS Code ### | ||
| .vscode/ |
This file contains hidden or 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,60 @@ | ||
| <?xml version="1.0" encoding="UTF-8"?> | ||
| <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
| xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
| <modelVersion>4.0.0</modelVersion> | ||
| <parent> | ||
| <groupId>org.springframework.boot</groupId> | ||
| <artifactId>spring-boot-starter-parent</artifactId> | ||
| <version>2.2.2.RELEASE</version> | ||
| <relativePath/> <!-- lookup parent from repository --> | ||
| </parent> | ||
| <groupId>ru.deft</groupId> | ||
| <artifactId>homework</artifactId> | ||
| <version>0.0.1-SNAPSHOT</version> | ||
| <name>dbservice</name> | ||
| <description>DB service for RMI</description> | ||
|
|
||
| <properties> | ||
| <java.version>11</java.version> | ||
| </properties> | ||
|
|
||
| <dependencies> | ||
| <dependency> | ||
| <groupId>org.springframework.boot</groupId> | ||
| <artifactId>spring-boot-starter</artifactId> | ||
| </dependency> | ||
|
|
||
| <dependency> | ||
| <groupId>org.springframework.boot</groupId> | ||
| <artifactId>spring-boot-devtools</artifactId> | ||
| <scope>runtime</scope> | ||
| <optional>true</optional> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.projectlombok</groupId> | ||
| <artifactId>lombok</artifactId> | ||
| <optional>true</optional> | ||
| </dependency> | ||
| <dependency> | ||
| <groupId>org.springframework.boot</groupId> | ||
| <artifactId>spring-boot-starter-test</artifactId> | ||
| <scope>test</scope> | ||
| <exclusions> | ||
| <exclusion> | ||
| <groupId>org.junit.vintage</groupId> | ||
| <artifactId>junit-vintage-engine</artifactId> | ||
| </exclusion> | ||
| </exclusions> | ||
| </dependency> | ||
| </dependencies> | ||
|
|
||
| <build> | ||
| <plugins> | ||
| <plugin> | ||
| <groupId>org.springframework.boot</groupId> | ||
| <artifactId>spring-boot-maven-plugin</artifactId> | ||
| </plugin> | ||
| </plugins> | ||
| </build> | ||
|
|
||
| </project> |
30 changes: 30 additions & 0 deletions
30
otus_2019_06/hw16-maven/dbservice/src/main/java/ru/deft/homework/client/DBServiceClient.java
This file contains hidden or 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,30 @@ | ||
| //package ru.deft.homework.client; | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. зачем это комитить в гит? |
||
| // | ||
| //import lombok.extern.slf4j.Slf4j; | ||
| //import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; | ||
| //import org.springframework.boot.web.servlet.server.ServletWebServerFactory; | ||
| //import org.springframework.context.annotation.Bean; | ||
| //import ru.deft.homework.rmi.DBServiceEcho; | ||
| // | ||
| //import java.net.MalformedURLException; | ||
| //import java.rmi.Naming; | ||
| //import java.rmi.NotBoundException; | ||
| //import java.rmi.RemoteException; | ||
| // | ||
| ///* | ||
| // * Created by sgolitsyn on 12/6/19 | ||
| // */ | ||
| //@Slf4j | ||
| //public class DBServiceClient { | ||
| // | ||
| // public static void main(String[] args) throws RemoteException, MalformedURLException, NotBoundException { | ||
| // DBServiceEcho echoInterface = (DBServiceEcho) Naming.lookup("rmi://localhost/DBServiceServer"); | ||
| // var dataFromServer = echoInterface.requestToDBService("from DBServiceClient", "message"); | ||
| // log.info("response from the server:{}", dataFromServer); | ||
| // } | ||
| // | ||
| // @Bean | ||
| // ServletWebServerFactory servletWebServerFactory() { | ||
| // return new TomcatServletWebServerFactory(); | ||
| // } | ||
| //} | ||
5 changes: 5 additions & 0 deletions
5
otus_2019_06/hw16-maven/dbservice/src/main/java/ru/deft/homework/db/DBService.java
This file contains hidden or 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,5 @@ | ||
| package ru.deft.homework.db; | ||
|
|
||
| public interface DBService { | ||
| String getUserData(long id); | ||
| } |
29 changes: 29 additions & 0 deletions
29
otus_2019_06/hw16-maven/dbservice/src/main/java/ru/deft/homework/db/impl/DBServiceImpl.java
This file contains hidden or 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,29 @@ | ||
| package ru.deft.homework.db.impl; | ||
|
|
||
| import org.slf4j.Logger; | ||
| import org.slf4j.LoggerFactory; | ||
| import ru.deft.homework.db.DBService; | ||
|
|
||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
|
|
||
| public class DBServiceImpl implements DBService { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Удаляйте неиспользуемые классы. |
||
| private static final Logger logger = LoggerFactory.getLogger(DBServiceImpl.class); | ||
| private final Map<Long, String> database = new HashMap<>(); | ||
|
|
||
| private void initDatabase() { | ||
| database.put(1L, "val1"); | ||
| database.put(2L, "val2"); | ||
| database.put(3L, "val3"); | ||
| } | ||
|
|
||
| public DBServiceImpl() { | ||
| initDatabase(); | ||
| } | ||
|
|
||
| public String getUserData(long id) { | ||
| logger.info("get data for id:{}", id); | ||
| return database.get(id); | ||
| } | ||
|
|
||
| } | ||
26 changes: 26 additions & 0 deletions
26
otus_2019_06/hw16-maven/dbservice/src/main/java/ru/deft/homework/model/Message.java
This file contains hidden or 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,26 @@ | ||
| package ru.deft.homework.model; | ||
|
|
||
| import lombok.AllArgsConstructor; | ||
| import lombok.Getter; | ||
| import lombok.NoArgsConstructor; | ||
| import lombok.Setter; | ||
|
|
||
| @Getter | ||
| @Setter | ||
| @NoArgsConstructor | ||
| @AllArgsConstructor | ||
| public class Message { | ||
|
|
||
| private String from; | ||
| private String message; | ||
|
|
||
| public Message(String message) { | ||
| this.message = message; | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return "Message [from=" + from + ", message=" + message + "]"; | ||
| } | ||
|
|
||
| } |
13 changes: 13 additions & 0 deletions
13
otus_2019_06/hw16-maven/dbservice/src/main/java/ru/deft/homework/rmi/DBServiceEcho.java
This file contains hidden or 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,13 @@ | ||
| package ru.deft.homework.rmi; | ||
|
|
||
| import java.rmi.Remote; | ||
| import java.rmi.RemoteException; | ||
|
|
||
| /* | ||
| * Created by sgolitsyn on 12/7/19 | ||
| */ | ||
| public interface DBServiceEcho extends Remote { | ||
|
|
||
| String requestToDBService(String from, String message) throws RemoteException; | ||
|
|
||
| } |
13 changes: 13 additions & 0 deletions
13
otus_2019_06/hw16-maven/dbservice/src/main/java/ru/deft/homework/rmi/MessageSystemEcho.java
This file contains hidden or 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,13 @@ | ||
| package ru.deft.homework.rmi; | ||
|
|
||
| import java.rmi.Remote; | ||
| import java.rmi.RemoteException; | ||
|
|
||
| /* | ||
| * Created by sgolitsyn on 12/7/19 | ||
| */ | ||
| public interface MessageSystemEcho extends Remote { | ||
|
|
||
| String requestToMessageSystem(String from, String message) throws RemoteException; | ||
|
|
||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
такого не должно быть в гите.
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.
и не понятно, как это изменение относится к этому ДЗ.