For my service Service Id is not getting Generated in my project bundle I cannot see it. | Community
Skip to main content
Level 2
Mar 19, 2021 5:55 AM UTC
Solved

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

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;

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

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

}

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Rohit_Utreja
Rohit_UtrejaAccepted solution
New Participant
Mar 19, 2021 7:07 AM UTC

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/

 

3 replies

joerghoh
Employee
Mar 19, 2021 8:12 PM UTC

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.

Translate
Rohit_Utreja
Rohit_UtrejaAccepted solution
New Participant
Mar 19, 2021 7:07 AM UTC

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/

 

Translate
bilal_ahmad
Level 5
Mar 19, 2021 6:17 AM UTC

Hi @ashwinikhaple try this:

 

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

 

Thanks,

Bilal

Translate