BAEL-3828 Where Should @Service Annotation Be Kept? (#10430)
* BAEL-3828 add code samples and tests for the article * BAEL-3828 fix maven test folder structure and test executions * BAEL-3828 fix indentation in continuation lines
This commit is contained in:
+22
@@ -0,0 +1,22 @@
|
||||
package com.baeldung.annotations.service;
|
||||
|
||||
import com.baeldung.annotations.service.abstracts.AbstractAuthenticationService;
|
||||
import com.baeldung.annotations.service.interfaces.AuthenticationService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.SpringApplication;
|
||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||
|
||||
@SpringBootApplication
|
||||
public class AuthApplication {
|
||||
|
||||
@Autowired
|
||||
private AuthenticationService inMemoryAuthService;
|
||||
|
||||
@Autowired
|
||||
private AbstractAuthenticationService ldapAuthService;
|
||||
|
||||
public static void main(String[] args) {
|
||||
SpringApplication.run(AuthApplication.class, args);
|
||||
}
|
||||
|
||||
}
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package com.baeldung.annotations.service.abstracts;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public abstract class AbstractAuthenticationService {
|
||||
|
||||
public boolean authenticate(String username, String password) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package com.baeldung.annotations.service.concretes;
|
||||
|
||||
import com.baeldung.annotations.service.interfaces.AuthenticationService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class InMemoryAuthenticationService implements AuthenticationService {
|
||||
|
||||
@Override
|
||||
public boolean authenticate(String username, String password) {
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
package com.baeldung.annotations.service.concretes;
|
||||
|
||||
import com.baeldung.annotations.service.abstracts.AbstractAuthenticationService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public class LdapAuthenticationService extends AbstractAuthenticationService {
|
||||
|
||||
@Override
|
||||
public boolean authenticate(String username, String password) {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
package com.baeldung.annotations.service.interfaces;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@Service
|
||||
public interface AuthenticationService {
|
||||
|
||||
boolean authenticate(String username, String password);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user