o declare any component as a service there is no need of using @service annotation? | Community
Skip to main content
AdobeID24
New Participant
September 23, 2018
Solved

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

  • September 23, 2018
  • 2 replies
  • 1583 views

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.
Best answer by arunpatidar

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

2 replies

Ratna_Kumar
New Participant
September 24, 2018

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.

arunpatidar
arunpatidarAccepted solution
New Participant
September 23, 2018

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