Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

For my service Service Id is not getting Generated in my project bundle I cannot see it.

Avatar

Avatar
Boost 1
Level 1
ashwinikhaple
Level 1

Like

1 like

Total Posts

16 posts

Correct Reply

1 solution
Top badges earned
Boost 1
Applaud 5
Affirm 1
View profile

Avatar
Boost 1
Level 1
ashwinikhaple
Level 1

Like

1 like

Total Posts

16 posts

Correct Reply

1 solution
Top badges earned
Boost 1
Applaud 5
Affirm 1
View profile
ashwinikhaple
Level 1

18-03-2021

Below is the code for my service and its implementation

SimpleService.java :

 

package com.aem.demo.core;

public interface SimpleService
{
public String MyName();
}

 

SimpleServiceImpl.java :

 

package com.aem.demo.core.impl;

import org.apache.felix.scr.annotations.Activate;
import org.apache.felix.scr.annotations.Component;
import org.osgi.service.component.ComponentContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.aem.demo.core.SimpleService;

@component(metatype = true, label = "Simple Service Info")
public class SimpleServiceImpl implements SimpleService
{
private final Logger logger = LoggerFactory.getLogger(getClass());
@activate
public void activate(ComponentContext cc)
{
logger.info("------ Service Activated -----");
logger.info("\n {}={}", cc.getBundleContext().getBundle().getBundleId(), cc.getBundleContext().getBundle().getSymbolicName());
}

@Override
public String MyName()
{
// TODO Auto-generated method stub
return null;
}

}

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Establish
Level 4
Rohit_Utreja
Level 4

Likes

44 likes

Total Posts

45 posts

Correct Reply

15 solutions
Top badges earned
Establish
Give Back 3
Give Back
Boost 5
Boost 3
View profile

Avatar
Establish
Level 4
Rohit_Utreja
Level 4

Likes

44 likes

Total Posts

45 posts

Correct Reply

15 solutions
Top badges earned
Establish
Give Back 3
Give Back
Boost 5
Boost 3
View profile
Rohit_Utreja
Level 4

19-03-2021

Hi @ashwinikhaple,

 

If you are using R6 annotation, then please add the below line of code for service creation.

@Component(service=SimpleService.class,
immediate=true,
.
. )

If you are using SCR annotation,
You need to add the below code to register it as a service.

@Service(value = CustomerDemo.class)

 

 

Please refer to the below URL for the service creation while using SCR/R6 annotation.

https://www.argildx.com/technology/migration-of-scr-annotations-to-ds-annotations/

 

Answers (2)

Answers (2)

Avatar

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,111 likes

Total Posts

3,145 posts

Correct Reply

1,072 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile

Avatar
Coach
Employee
Jörg_Hoh
Employee

Likes

1,111 likes

Total Posts

3,145 posts

Correct Reply

1,072 solutions
Top badges earned
Coach
Give back 600
Ignite 5
Ignite 3
Ignite 1
View profile
Jörg_Hoh
Employee

19-03-2021

Can you please describe your problem? It's not entirely clear to me what is not working as expected, or what you are trying to achieve.

Avatar

Avatar
Springboard
Level 4
bilal_ahmad
Level 4

Likes

66 likes

Total Posts

108 posts

Correct Reply

16 solutions
Top badges earned
Springboard
Validate 10
Validate 1
Ignite 1
Establish
View profile

Avatar
Springboard
Level 4
bilal_ahmad
Level 4

Likes

66 likes

Total Posts

108 posts

Correct Reply

16 solutions
Top badges earned
Springboard
Validate 10
Validate 1
Ignite 1
Establish
View profile
bilal_ahmad
Level 4

18-03-2021

Hi @ashwinikhaple try this:

 

@Component(metatype = true, label = "Simple Service Info")
@Service(value = SimpleService.class)

 

Thanks,

Bilal