Expand my Community achievements bar.

SOLVED

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

Avatar

Level 7

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

    }

}

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

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 S...



Arun Patidar

View solution in original post

2 Replies

Avatar

Correct answer by
Community Advisor

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 S...



Arun Patidar

Avatar

Level 10

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.