Shane A Rai | 1 Dec 2004 06:10

Collection Creation Ques

Hi:
 
I need to make use of some Collection management services such as creating a Collection under the root collection, etc. I came across the service "LocalCollectionManagementService" which I believe is located in org.xmldb.api.reference.modules.*
 
However, when I import the above package, I get a compile time error saying this package does not exist.
 
Ques #1: where can I find the relevant package? Where is this jar file and what is it? Do I need to download the jar file from some other source or does it come with the eXist download?
 
 
Ques #2: this is the code that I am using to create the Collection:
 
LocalCollectionManagementService service = 
     (LocalCollectionManagementService) root_col.getService("LocalCollectionManagementService", "1.0");
     
rsc_col = service.createCollection("resources");
 
where, root_col is the root Collection here and the resources Collection i.e. rsc_col is intended to be created under the root.
 
Is this the most appropriate way to create a Collection or are there some other services?
 
 
Ques #3: Unrelated question. My Java client uses the embedded instance of the server. I am curious to know where are the documents (that are added to the server such as XML files) stored on the local machine? Also, if my client adds say an XML file during one instance, then shuts down, then re-starts, can the client have access to this XML file that was stored previously?
 
I currently use:
Database database = (Database) cl.newInstance();
Since a new instance is created, I am wondering if the files are stored in a persistent state to be retrieved later.
 
Much thanks.
 
Shane
Wolfgang Meier | 1 Dec 2004 10:23
Picon

Re: Collection Creation Ques

Hi,

> I need to make use of some Collection management services such as creating
> a Collection under the root collection, etc. I came across the service
> "LocalCollectionManagementService" which I believe is located in
> org.xmldb.api.reference.modules.*
>
> However, when I import the above package, I get a compile time error saying
> this package does not exist.
>
> Ques #1: where can I find the relevant package? Where is this jar file and
> what is it? Do I need to download the jar file from some other source or
> does it come with the eXist download?

Use org.xmldb.api.modules.CollectionManagementService. The jar is xmldb.jar 
and is in lib/core.

> Ques #2: this is the code that I am using to create the Collection:
>
> LocalCollectionManagementService service =
>      (LocalCollectionManagementService)
> root_col.getService("LocalCollectionManagementService", "1.0");
>
> rsc_col = service.createCollection("resources");
>
> where, root_col is the root Collection here and the resources Collection
> i.e. rsc_col is intended to be created under the root.
>
> Is this the most appropriate way to create a Collection or are there some
> other services?

The code will be correct if you use CollectionManagementService instead of 
LocalCollectionManagementService.

> Ques #3: Unrelated question. My Java client uses the embedded instance of
> the server. I am curious to know where are the documents (that are added to
> the server such as XML files) stored on the local machine? Also, if my
> client adds say an XML file during one instance, then shuts down, then
> re-starts, can the client have access to this XML file that was stored
> previously?
>
> I currently use:
> Database database = (Database) cl.newInstance();
> Since a new instance is created, I am wondering if the files are stored in
> a persistent state to be retrieved later.

Sure, the documents are stored in the database backend (whose files reside in 
webapp/WEB-INF/data). But you won't find your .xml file there. eXist stores 
the document model, not the raw XML. It also creates a bunch of indexes on 
the data, which are persistent as well.

Compare it to a relational database: would you expect it to store your tables 
as a text file in the file system? Certainly not. Documents roughly play the 
same role for eXist as tables in an rdbms. They are logical, not physical 
entities.

Wolfgang

-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/

Gmane