Hello,
I have created service say XX. I tried to access that service XX in other Service YY.
When I try to use the XX like
@Reference XX xx in YY service
I got a null value.
Code:
@Component(immediate = true)
@Service(value = XX.class)
public class XX{
//some methods
}
@Component(immediate =true)
@Service(value=ZZ.class)
public class YY implements ZZ{
@Reference
XX xx;
public SB aa(String ss) {
LOG.info(xx);//Null
}
When I access my service in my servlet, It is working fine..
like
@Component(immediate = true)
@Service(javax.servlet.Filter.class)
public class FilterManager implements Filter {
@Reference
XX xx;
LOG.info(xx);//I can get an object here
}
Kindly guide me, Is it possible to access service inside other service?
Note:
In Felix console, can I see the service is active for both XX, YY.
Thanks
Nanda
Solved! Go to Solution.
Views
Replies
Total Likes
Yes - as long as the service is part of the AEM Service container - you can inject it into another service. See this article as an example. Notice that we are injecting a DataSourcePool into a custom AEM service:
http://helpx.adobe.com/experience-manager/using/datasourcepool.html
Views
Replies
Total Likes
Yes - as long as the service is part of the AEM Service container - you can inject it into another service. See this article as an example. Notice that we are injecting a DataSourcePool into a custom AEM service:
http://helpx.adobe.com/experience-manager/using/datasourcepool.html
Views
Replies
Total Likes
Nandujee wrote...
Hello,
I have created service say XX. I tried to access that service XX in other Service YY.
When I try to use the XX like
@Reference XX xx in YY service
I got a null value.
Code:
@Component(immediate = true)
@Service(value = XX.class)
public class XX{
//some methods
}
@Component(immediate =true)
@Service(value=ZZ.class)
public class YY implements ZZ{
@Reference
XX xx;
public SB aa(String ss) {
LOG.info(xx);//Null
}
When I access my service in my servlet, It is working fine..
like
@Component(immediate = true)
@Service(javax.servlet.Filter.class)
public class FilterManager implements Filter {
@Reference
XX xx;
LOG.info(xx);//I can get an object here
}
Kindly guide me, Is it possible to access service inside other service?
Note:
In Felix console, can I see the service is active for both XX, YY.
Thanks
Nanda
Hi ,
I am also facing the same issue, could you please let us know how did you resolve this.
In our case we have two different bundles and trying to access the service as
@Reference
ServiceXyz xyz;
But its giving null.
Regards
Ankur
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies