AEM Services | Community
Skip to main content
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by EstebanBustamante

What do you mean by "normal" class? If you mean plain Java classes POJO (Plain Old Java Object) the simple answer is No.

 

the @3214626 annotation is part of the OSGi Declarative Services (DS) specification. It is used to inject OSGi services into OSGi component classes, which are typically OSGi service components.

The @3214626 annotation cannot be used directly in a normal Java class because it is specifically meant for OSGi service components that are registered and managed by the OSGi framework. Normal Java classes are not part of the OSGi service registry, and hence, the @3214626 annotation is not applicable to them.

 

2 replies

EstebanBustamante
Community Advisor and Adobe Champion
EstebanBustamanteCommunity Advisor and Adobe ChampionAccepted solution
Community Advisor and Adobe Champion
July 25, 2023

What do you mean by "normal" class? If you mean plain Java classes POJO (Plain Old Java Object) the simple answer is No.

 

the @3214626 annotation is part of the OSGi Declarative Services (DS) specification. It is used to inject OSGi services into OSGi component classes, which are typically OSGi service components.

The @3214626 annotation cannot be used directly in a normal Java class because it is specifically meant for OSGi service components that are registered and managed by the OSGi framework. Normal Java classes are not part of the OSGi service registry, and hence, the @3214626 annotation is not applicable to them.

 

Esteban Bustamante
Ekhlaque
Adobe Employee
Adobe Employee
July 25, 2023

the @3214626 annotation can not be used in normal Java classes,you can use the @3214626 annotation to inject references to other OSGi services into the component class.

 

For example, in a Sling Model class, you can use the @3214626 annotation to inject an OSGi service

 

import org.osgi.service.component.annotations.Reference; import org.apache.sling.models.annotations.Model; @Model(adaptables = Resource.class) public class MySlingModel { @3214626 private MyOsgiService myOsgiService; // ... Rest of the code ... }