-
Notifications
You must be signed in to change notification settings - Fork 998
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
implemented injector #707
base: main
Are you sure you want to change the base?
implemented injector #707
Conversation
|
||
@Component |
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.
U don't need annotation here, only for implementations
"Convention is to use @component on the classes that are used for instance creation (usually these are interface implementations) "
@Component | ||
public interface ProductParser { |
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.
same
@Component | ||
public interface ProductService { |
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.
same
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.
Please see the comment.
return null; | ||
Object clazzImplementationInstance = null; | ||
Class<?> clazz = findImplementation(interfaceClazz); | ||
if (clazz.isAnnotationPresent(Component.class)) { |
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.
It's better to check in if statement if annotation is absent and throw exception if true (better even create a separate method to check it). It'll make your code cleaner.
No description provided.