>hsp wrote:
>> But, the node I create is kind of type "esc:base" and it is
> > inside the iterator, and its child (autocreated) that is kind
> > of type "nt:hierarchyNode" also is inside the iterator, why?
>
>this has been discussed already extensively on the user list. See:
>http://thread.gmane.org/gmane.comp.apache.jackrabbit.user/408
>
>> Another doubt, the absPath is relative to the root of the
>> workspace,  or it means the root of the parent node that
> > generates the event?
>
>it's the absolute path to a node in the workspace.
>
>> I configured the isDeep as "false" and it didn't fired anymore.
>
>with an absPath of "/" you will only get events when the root node is 
>modified.
>
>> Is the event Listener stable? Because it seens some times not
>> firing the listener class.
>
>Can you please provide a test case that shows this behaviour? Thank you.
>
>regards
>  marcel
>

Hi Marcel. There is attached a class test for the comment I did 
">> Is the event Listener stable? Because it seens some times not
>> firing the listener class."

In this test, the listener is not firing in each node creation. There is a loop 
that creates nt:folder nodes some times, and in the log the class was not 
called for all nodes creation. I hope that its could be some easy to fix, 
thanks.

import javax.jcr.observation.EventIterator;
import javax.jcr.observation.EventListener;

import org.apache.jackrabbit.core.observation.EventImpl;

public class ListenerNodeAddEscribaBase implements EventListener {

        private static ListenerNodeAddEscribaBase instance = null;
        
        private ListenerNodeAddEscribaBase() {
        }
        
        public static ListenerNodeAddEscribaBase getInstance(){
                if(instance == null){
                        instance = new ListenerNodeAddEscribaBase();
                }
                return instance;
        }
        
        public void onEvent(EventIterator arg0) {
                System.out.println("Estou no ListenerNodeAddEscribaBase");
                
                while(arg0.hasNext()){
                        EventImpl e = (EventImpl)arg0.nextEvent();
                        
                        try {
                                System.out.println("Path: " + e.getPath());
                                System.out.println("Tipo: " + e.getType());
                                System.out.println("UserId: " + e.getUserID());
                        } catch (Exception e0) {
                                e0.printStackTrace();
                        }
                }
        }

}


public class TestObserver {
        private static void criaNode(String nomeNode){
                try {
                        Repository rep = RepositorioEscriba.getRepository();
                        Session session = null;
                        SimpleCredentials creds = null;
                        
                        creds = new SimpleCredentials("thiago", 
"".toCharArray());
                        session = rep.login(creds);
                        
session.getWorkspace().getObservationManager().addEventListener(
                                        
ListenerNodeAddEscribaBase.getInstance(),
                                        Event.NODE_ADDED,
                                        "/",
                                        true,
                                        null,
                                        new String[] {"nt:base"},
                                        false
                        );
                        
                        Node nodeGrupo = (Node)session.getItem("/");
                        nodeGrupo.addNode(nomeNode, "nt:folder");
                        session.save();
                        session.logout();
                        logger.info(nomeNode + " gravado com sucesso");
                } catch (Exception e) {
                        e.printStackTrace();
                }
        }
        
        public static void main(String[] args){
                try {
                        logger.info("Testando Observer");

                        /*Primeira tentativa*/
                        for(int i=0 ; i<20 ; i++){
                                criaNode("nodeX" + i);
                        }
                        
                } catch (Exception e) {
                        e.printStackTrace();
                }
                
        }
}

and the log.....

10:29:21,686 INFO  [STDOUT] 10:29:21,686 INFO  [RepositoryStartupServlet] 
Testando Observer
10:29:21,915 INFO  [STDOUT] Estou no ListenerNodeAddEscribaBase
10:29:21,915 INFO  [STDOUT] Path: /nodeX0
10:29:21,916 INFO  [STDOUT] Tipo: 1
10:29:21,916 INFO  [STDOUT] UserId: thiago
10:29:21,917 INFO  [STDOUT] 10:29:21,917 INFO  [RepositoryStartupServlet] 
nodeX0 gravado com sucesso
10:29:21,927 INFO  [STDOUT] Estou no ListenerNodeAddEscribaBase
10:29:21,928 INFO  [STDOUT] Path: /nodeX1
10:29:21,928 INFO  [STDOUT] Tipo: 1
10:29:21,928 INFO  [STDOUT] UserId: thiago
10:29:21,930 INFO  [STDOUT] 10:29:21,930 INFO  [RepositoryStartupServlet] 
nodeX1 gravado com sucesso
10:29:21,969 INFO  [STDOUT] Estou no ListenerNodeAddEscribaBase
10:29:21,970 INFO  [STDOUT] Path: /nodeX2
10:29:21,970 INFO  [STDOUT] Tipo: 1
10:29:21,970 INFO  [STDOUT] UserId: thiago
10:29:21,971 INFO  [STDOUT] 10:29:21,971 INFO  [RepositoryStartupServlet] 
nodeX2 gravado com sucesso
10:29:22,011 INFO  [STDOUT] 10:29:22,011 INFO  [RepositoryStartupServlet] 
nodeX3 gravado com sucesso
10:29:22,036 INFO  [STDOUT] Estou no ListenerNodeAddEscribaBase
10:29:22,036 INFO  [STDOUT] Path: /nodeX4
10:29:22,036 INFO  [STDOUT] Tipo: 1
10:29:22,036 INFO  [STDOUT] UserId: thiago
10:29:22,038 INFO  [STDOUT] 10:29:22,037 INFO  [RepositoryStartupServlet] 
nodeX4 gravado com sucesso
10:29:22,097 INFO  [STDOUT] Estou no ListenerNodeAddEscribaBase
10:29:22,097 INFO  [STDOUT] Path: /nodeX5
10:29:22,097 INFO  [STDOUT] Tipo: 1
10:29:22,097 INFO  [STDOUT] UserId: thiago
10:29:22,098 INFO  [STDOUT] 10:29:22,098 INFO  [RepositoryStartupServlet] 
nodeX5 gravado com sucesso
10:29:22,128 INFO  [STDOUT] Estou no ListenerNodeAddEscribaBase
10:29:22,128 INFO  [STDOUT] Path: /nodeX6
10:29:22,128 INFO  [STDOUT] Tipo: 1
10:29:22,128 INFO  [STDOUT] UserId: thiago
10:29:22,130 INFO  [STDOUT] 10:29:22,129 INFO  [RepositoryStartupServlet] 
nodeX6 gravado com sucesso
10:29:22,170 INFO  [STDOUT] 10:29:22,170 INFO  [RepositoryStartupServlet] 
nodeX7 gravado com sucesso
10:29:22,188 INFO  [STDOUT] 10:29:22,188 INFO  [RepositoryStartupServlet] 
nodeX8 gravado com sucesso
10:29:22,225 INFO  [STDOUT] 10:29:22,225 INFO  [RepositoryStartupServlet] 
nodeX9 gravado com sucesso
10:29:22,271 INFO  [STDOUT] 10:29:22,271 INFO  [RepositoryStartupServlet] 
nodeX10 gravado com sucesso
10:29:22,313 INFO  [STDOUT] 10:29:22,312 INFO  [RepositoryStartupServlet] 
nodeX11 gravado com sucesso
10:29:22,371 INFO  [STDOUT] 10:29:22,371 INFO  [RepositoryStartupServlet] 
nodeX12 gravado com sucesso
10:29:22,413 INFO  [STDOUT] Estou no ListenerNodeAddEscribaBase
10:29:22,413 INFO  [STDOUT] Path: /nodeX13
10:29:22,413 INFO  [STDOUT] Tipo: 1
10:29:22,413 INFO  [STDOUT] UserId: thiago
10:29:22,415 INFO  [STDOUT] 10:29:22,415 INFO  [RepositoryStartupServlet] 
nodeX13 gravado com sucesso
10:29:22,447 INFO  [STDOUT] 10:29:22,447 INFO  [RepositoryStartupServlet] 
nodeX14 gravado com sucesso
10:29:22,491 INFO  [STDOUT] 10:29:22,491 INFO  [RepositoryStartupServlet] 
nodeX15 gravado com sucesso
10:29:22,525 INFO  [STDOUT] 10:29:22,524 INFO  [RepositoryStartupServlet] 
nodeX16 gravado com sucesso
10:29:22,563 INFO  [STDOUT] 10:29:22,563 INFO  [RepositoryStartupServlet] 
nodeX17 gravado com sucesso
10:29:22,605 INFO  [STDOUT] 10:29:22,605 INFO  [RepositoryStartupServlet] 
nodeX18 gravado com sucesso
10:29:22,643 INFO  [STDOUT] 10:29:22,642 INFO  [RepositoryStartupServlet] 
nodeX19 gravado com sucesso


Hsp.

Reply via email to