o declare any component as a service there is no need of using @service annotation? | Community
Skip to main content
AdobeID24
Level 5
Sep 23, 2018 1:30 PM UTC
Solved

o declare any component as a service there is no need of using @service annotation?

SCR annotation VS ds Annotation(OSGI annotation):

"First change is that @Service and @Component are now combined, via service you specify which service you are implementing @Component(service = MySimpleService.class)"

What does it mean now to declare any component as a service there is no need of using @service annotation?

I found somewhere this in net

Migration of OSGi Components and Service

Before : In SCR Annotations:

@Component(name=”Test Service”,immediate=true,description="this is description")

@Service(TestService.class)

public class TestService {

                      public String getName() 

    {

      return "testService";

    }

}

After:In OSGi Annotations

@Component(name=”Test Service” service=TestService.class,immediate=true)

public class TestService {

                      public String getName() 

    {

      return "testService";

    }

}

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
arunpatidar
arunpatidarAccepted solution
New Participant
Sep 23, 2018 4:12 PM UTC

Hi,

Yes, when you use osgi annotations, you need to use @component with service attribute annotation to mark component as service.

e.g.

@Component(name=”Test Service” service=TestService.class,immediate=true)

Official OSGi Declarative Services Annotations in AEM - Adobe Experience Manager | AEM/CQ | Apache Sling

Arun Patidar

2 replies

Ratna_Kumar
Level 10
Sep 24, 2018 6:06 AM UTC

Hi,

Yes Arun is right. when you use OSGI annotations, you need to use @component annotation with service attribute annotation to mark component as service.

Thanks,

Ratna Kumar.

Translate
arunpatidar
arunpatidarAccepted solution
New Participant
Sep 23, 2018 4:12 PM UTC

Hi,

Yes, when you use osgi annotations, you need to use @component with service attribute annotation to mark component as service.

e.g.

@Component(name=”Test Service” service=TestService.class,immediate=true)

Official OSGi Declarative Services Annotations in AEM - Adobe Experience Manager | AEM/CQ | Apache Sling

Translate
Arun Patidar