Hi all,
In latest version of nuxeo there is a method to initialize the
repository structure on the first access.
Here is how you can install your own initialization handler:
Define a new nuxeo runtime component. In the activate() method of the
component do the following:
RepositoryInitializationHandler.setInstance(new MyInitHandler());
where MyInitHandler is your own handler.
The initialization handler will be called each time a repository is
first accessed in a JVM session.
This means the handler will be called after each server restart on the
first access on a repository.
Because of this you should check in your handler if the repository was
already initialized and if true to skip the intiialization
Nuxeo ECM ensure that the handler is called in a synchronized block so
you can be sure that no other sessions
are used while your handler initializeRepository() is executed.
This also means you *must* not open new sessions on the repository
tinside you handler method
otherwise you will end in a dead lock.
Use the session passed as argument to make modification on the repository.
Also, the session passed to your handler is in a system user context so
you have all privileges granted on the repository.
If other handler are set by other modules the last one will be used.
If you need to create a handler chain then you can use the following method:
RepositoryInitializationHandler parentHandler =
RepositoryInitializationHandler.getInstance();
MyInitHandler myHandler = new MyInitHandler(parentHandler);
RepositoryInitializationHandler.setInstance(myHandler);
And then define your handler like this:
class MyHandler extends RepositoryInitializationHandler {
public initializeRepository(CoreSession session) {
if (parentHandler != null) { // first delegate initialization to
the parent handler
parentHandler.initializeRepository(session);
}
// do my own intialization here
...
}
}
Bogdan
_______________________________________________
ECM mailing list
[email protected]
http://lists.nuxeo.com/mailman/listinfo/ecm