Login | Register   
RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


Tracking Events Using a Semi-Structured Repository : Page 2

Tracking the activities of a system and its users is too often not considered until the application is already deployed. Learn how to demonstrate an (almost) no hassle persistent bean pool that you can use to track the activities of an already developed system for later review.

Inspecting the Repository
A convenient way to query and inspect the repository is through an interactive shell. In Java 6 for Windows, Linux, and Solaris, there exists a tool called jrunscript, which is a JavaScript interactive shell. If you are not using Java 6 on one of these platforms, you can download Mozilla's Rhino interactive JavaScript shell or use an interactive shell for another language, such as Groovy or JRuby. However, the syntax varies between shells.

Be sure to set the CLASSPATH environment variable correctly to include all the jars from the application.

Now start the interactive shell using the command:


Just like when writing Java code, you need to import the packages you plan on using. This is done using the following commands:
  • importPackage(java.io)
  • importPackage(java.util)
  • importPackage(javax.xml.namespace)
  • importPackage(org.openrdf.elmo)
  • importPackage(org.openrdf.elmo.sesame)
  • importPackage(org.openrdf.rio)
  • importPackage(org.openrdf.rio.rdfxml)

You can also execute these in the command line by using the '-e' argument followed by the command and then '-f -' to jrunscript.

Run the following commands to open a connection to the repository: js> factory = new SesameManagerFactory(new ElmoModule(),“devx”,“rdf”))
js> manager = factory.createElmoManager()

OpenRDF Elmo uses the newly standardized SPARQL query language.

To execute a query, run the commands from Listing 3.

Although this shell is useful for arbitrary inspection, it is difficult to get the bigger picture. However, you can also export the data into RDF/XML (a portable format). With the repository exported you can browse the contents more interactively in your browser.

js> manager.connection['export'](new RDFXMLWriter(new FileWriter("export.rdf")))

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date