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

implemented injector #707

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

IvanFadieiev
Copy link

No description provided.


@Component
Copy link

@keda-vlad keda-vlad Aug 7, 2023

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) "

Comment on lines 6 to 7
@Component
public interface ProductParser {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Comment on lines 7 to 8
@Component
public interface ProductService {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same

Copy link

@vovasalyha vovasalyha left a 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)) {

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants