You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by vkrejcirik <vk...@gmail.com> on 2009/03/08 19:48:39 UTC
eventListener doesn't work
i have this in my code:
private ThreadLocal<Session> session = new ThreadLocal<Session>();
protected Session getSession() throws LoginException,
RepositoryException {
if (session.get() == null) {
Session session = repository.login(new
SimpleCredentials("admin", "admin".toCharArray()));
this.session.set(session);
}
return session.get();
}
ObservationManager observationManager =
getSession().getWorkspace().getObservationManager();
observationManager.addEventListener(eventListener,
Event.PROPERTY_CHANGED, "/content/servicemix/config", true, null, null,
false);
public class ConfigEventListener implements EventListener {
public void onEvent(EventIterator event) {
LOG.debug("event! change configuration");
try {
marshaler = getMarshaler();
} catch (PathNotFoundException e) {
e.printStackTrace();
} catch (LoginException e) {
e.printStackTrace();
} catch (RepositoryException e) {
e.printStackTrace();
}
}
}
but if i change property in /content/servicemix/config node method
onEvent is not called..
Do you know, where can be problem ?
thanks
--
/**************************************/
Best regards / S pozdravem
Vladislav Krejčiřík
http://www.vkrejcirik.info
Re: eventListener doesn't work
Posted by Bertrand Delacretaz <bd...@apache.org>.
2009/3/8 vkrejcirik <vk...@gmail.com>:
> i have this in my code...
FWIW, the Sling espblog sample includes an event listener, you might
want to compare [1] with your code.
-Bertrand
[1] https://svn.eu.apache.org/repos/asf/incubator/sling/trunk/samples/espblog/src/main/java/org/apache/sling/samples/espblog/internal/ThumbnailGeneratorServiceImpl.java
Re: eventListener doesn't work
Posted by Alexander Klimetschek <ak...@day.com>.
On Mon, Mar 9, 2009 at 7:18 PM, vkrejcirik <vk...@gmail.com> wrote:
> I change property over POST request, so I can't call save().
The post servlet calls the save() method, of course ;-)
Regards,
Alex
--
Alexander Klimetschek
alexander.klimetschek@day.com
Re: eventListener doesn't work
Posted by vkrejcirik <vk...@gmail.com>.
I change property over POST request, so I can't call save().. I try to
send this request to Jackrabbit mailing list.
/**************************************/
Best regards / S pozdravem
Vladislav Krejc(ir(ík
http://www.vkrejcirik.info
Alexander Klimetschek napsal(a):
> 2009/3/8 vkrejcirik <vk...@gmail.com>:
>
>> but if i change property in /content/servicemix/config node method onEvent
>> is not called..
>> Do you know, where can be problem ?
>>
>
> This is more a question for the Jackrabbit mailing list...
>
> Did you call save() after changing the property?
>
> Regards,
> Alex
>
>
Re: eventListener doesn't work
Posted by Alexander Klimetschek <ak...@day.com>.
2009/3/8 vkrejcirik <vk...@gmail.com>:
> but if i change property in /content/servicemix/config node method onEvent
> is not called..
> Do you know, where can be problem ?
This is more a question for the Jackrabbit mailing list...
Did you call save() after changing the property?
Regards,
Alex
--
Alexander Klimetschek
alexander.klimetschek@day.com