jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Stefan Guggisberg" <stefan.guggisb...@gmail.com>
Subject Re: Namespaces - questions
Date Wed, 28 Feb 2007 16:51:17 GMT
On 2/27/07, Wolf Benz <eurojava@gmail.com> wrote:
> Hi Tobias,
> Most importantly: thanks for taking the time to reply :-)
> I have 2 remaining questions:
>
> 1/ It seems (to me, at least) unefficient to have to do this at every
> time you get a session, no? (as this is code that is passed every time
> you get a session) Is there a way to "init" a session once and for all
> so that every next call to it can assume this work is done instead of
> having to check every other time it is done?

you have to register your custom types once, just like you have to
create your custom tables in an rdbms once.

JackrabbitNodeTypeManager.registerNodeTypes(InputStream, String)
provides an easy and convenient way of registering your custom node types
incl. any referenced namespaces, e.g.

JackrabbitNodeTypeManager manager = (JackrabbitNodeTypeManager)
        session.getWorkspace().getNodeTypeManager();
manager.registerNodeTypes(new FileInputStream("mytypes.cnd"),
        JackrabbitNodeTypeManager.TEXT_X_JCR_CND);

>
> 2/ Why do you explicitely (again) do the
> "s.setNamespacePrefix("myapp", "http://your.com/ns/1");" as you not
> only registered the NS, but also provide the NS (myapp) in your call
> on the next line: "s.getRootNode().getNode("myapp:someNode");"
> Is it necessary?

namespaces in JCR are modelled after XML namespaces. for more information
please refer to sections 4.5 and 6.3 in the jsr 170 specification.

cheers
stefan

>
> Thanks in advance,
> Wolf
>
> On 2/27/07, Tobias Bocanegra <tobias.bocanegra@day.com> wrote:
> > namespaces are fully supported by jackrabbit since 1.0. and the
> > registration works exactly as specified in jsr170 (which is a bit
> > troublesome).
> >
> > in your application you probably have a 'getRepositorySession' call,
> > and there i would setup/check the namespaces for your application, eg:
> >
> > 1. check if your namespace is already registered
> > 2. if not, do so.
> > 3. setup the namespace mapping for your session and application.
> >
> > example:
> >
> >     try {
> >         s.getNamespaceURI("http://your.com/ns/1");
> >     } catch (RepositoryException e) {
> >         // register namespace
> >         s.getWorkspace().getNamespaceRegistry().registerNamespace(
> >             "myapp", "http://your.com/ns/1");
> >     }
> >     s.setNamespacePrefix("myapp", "http://your.com/ns/1");
> >     [....]
> >     s.getRootNode().getNode("myapp:someNode");
> >
> > regards, toby
> >
> >
> > On 2/26/07, Wolf Benz <eurojava@gmail.com> wrote:
> > > Hi List,
> > >
> > > I have 2 questions regarding namespaces:
> > >
> > > 1/ What is the meaning/effect of these variables:
> > > forceNamespacesRegistration
> > > keepNamespaces
> > >
> > > The Javadoc seems to be left blanc for these...
> > >
> > > &  I keep getting errors w.r.t. namespaces:
> > > I try to register a namespace, but I got and error when running the
> > > application a second time (name space already exists)
> > > + when forceNamespacesRegistration is true I got 'unregistering
> > > namespaces is not supported.'
> > >
> > > --> Does this mean even in JR 1.2.2 namespaces are not fully
> > > supported? (...)
> > > (hope it will probabely be smth else - NS are such key piece of a JCR
> > > this seems unlikely)
> > > Do these vars actually do what they are meant to do?
> > >
> > > 2/ Most importantly:
> > > How does one get to register the custom nodes that go with these
> > > namespaces?
> > > Does it suffice to place the CND-file in the /respository/namepsaces
> > > directory, or should it be in the specific WS directory /workspaces/
> > > myWS/myProjectNamespaces/ (bot defined in the repository.xml)
> > >
> > > or....?
> > > Or do they really have to be digged up from where ever you put the
> > > cnd file and are these 2 locations mere preferred locations? (like
> > > the code example on the JR site)
> > > If so, I can't image that this needs to be done at every single
> > > getSession - what's the best place to do it once? I'm having a "best
> > > place-when best" problem with this. Apparently a NS is registered
> > > from the WS, which you get from the Session. I find this strange. I
> > > rather see it as tied to a Repository. So I would have expected it in
> > > the repository configuration.
> > >
> > > Sorry or all the questions... (I hope everyone has these issues)
> > > Wolf
> > >
> > > Ps2 Is this sort of stuff addressed in JSR-283 as well?
> >
> >
> > --
> > -----------------------------------------< tobias.bocanegra@day.com >---
> > Tobias Bocanegra, Day Management AG, Barfuesserplatz 6, CH - 4001 Basel
> > T +41 61 226 98 98, F +41 61 226 98 97
> > -----------------------------------------------< http://www.day.com >---
> >
>

Mime
View raw message