Hi.
Maybe I need to break down my service into a few services, but here is whats going on.
I am needing to modify certain links generated inside of AEM. To do this, I am working with SAX and the Transformer and TransformerFactory interfaces.
Within my service's activate method, everything works fine. I have access to the referenced ResourceResolverFactory:
@Reference
private ResourceResolverFactory resolverFactory;
@Activate
protected void activate(Map<String, Object> properties) {
log.error("[[[ Inside of Activate ]]]]");
Map<String, Object> param = new HashMap<String, Object>();
param.put(ResourceResolverFactory.SUBSERVICE, SERVICE_NAME);
ResourceResolver resolver = null;
try {
resolver = resolverFactory.getServiceResourceResolver(param);
log.error("UserID => " + resolver.getUserID());
} catch (LoginException e) {
log.error("LoginException",e);
} finally {
resolver.close();
}
}
(Sorry, the syntax highlter doesn't like the copy paste job.
If I run this same code, inside of my custom method, resolverFactory is null.
private void BuildUrl(){
log.error("[[[ Inside of Build URL ]]]]");
Map<String, Object> param = new HashMap<String, Object>();
param.put(ResourceResolverFactory.SUBSERVICE, SERVICE_NAME);
ResourceResolver resolver = null;
try {
resolver = resolverFactory.getResourceResolver(param);
log.error("UserID => " + resolver.getUserID());
} catch (LoginException e) {
log.error("LoginException",e);
}
}
Any ideas why resolverFactory is not Null during the @activate method, and then null during my custom method?
Solved! Go to Solution.
Views
Replies
Total Likes
It does not need to be in a specific method.
See this article - we use it within a custom method in the implementation class --
Views
Replies
Total Likes
It does not need to be in a specific method.
See this article - we use it within a custom method in the implementation class --
Views
Replies
Total Likes
Right, I actually looked at that implementation many times when trying to debug this to see if I was doing anything different.
I'm not.
I'm wondering if it has anything to do with the context of where my code is being called.
Within my class, as i am implementing a transformer, I have the following method:
@Override
public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
log.error("Inside of Start Element - local name of = " + localName);
BuildUrl();
contentHandler.startElement(uri, localName, qName, atts);
}
Once insde that method, and in turn my custom method buildUrl(), ResolverFactory is null .:\
Views
Replies
Total Likes
Try a test - whitelist the bundle and see if the old getAdmin method works in a custom method.
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies