Re: TreeBing goes RDF

Hi Eric,

A while ago a wrote a Java 5 tool that allows Java Beans to exported to 
RDF in a Jena Model, which ofcourse can then be serialized.  For example,

public class Person {
 
        String name;
        ...
 
        public String getName() {
                return name;
        }
 
        public void setName(String name) {
                this.name = name;
        }
....
}

can be annotated like so:

@RdfSerializable
public class Person {
 
        static final String prefix = 
"http://test.ibm.com/tantrum/person/";
        static final String namePredicate = 
"http://test.ibm.com/tantrum/name";
        ...

        String name;
        Person significantOther;
        List<String> nicknames = new ArrayList<String>();
        int age;
 
        @ResourceField(prefix=prefix)
        @PredicateField(uri=namePredicate)
        public String getName() {
                return name;
        }
 
        public void setName(String name) {
                this.name = name;
        }
....
}

Then it can be serialized:

Model model = ModelFactory.createDefaultModel();
Person monica = new Person();
monica.setName("Monica");
RdfSerializer.serialize(clinton, model);
model.write(System.err);

The output is:

<rdf:RDF
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:j.0="http://test.ibm.com/tantrum/" >
  <rdf:Description rdf:about="http://test.ibm.com/tantrum/person/Monica">
    <j.0:name 
rdf:datatype="http://www.w3.org/2001/XMLSchema#string">Monica</j.0:name>
  </rdf:Description>
</rdf:RDF>

I wrote this tool a while ago and it's just a basic proof-of-concept.  It 
does support some list types and can follow object references (and avoid 
cycles) but hasn't been tested much.  I would be happy to put it up as 
opensource on the Jastor sourceforge page if you think it would be useful 
to you.

Just a couple comments on why we chose to promote Jastor instead of this: 
Jastor keep a connection with a RDF model so multiple applications 
changing this data can interact and listen on events through the RDF 
graph,  Jastor puts a focus on an explicit ontological structure instead 
of one that implicitly defined by the structure of Java classes.

Cheers,

Joe Betz


> Hi Dan,
> 
> On mer, 2005-06-29 at 10:53 -0400, Dan Smith wrote:
> > Hi Eric,
> > 
> > You should have a look at Jastor[1], which our group recently Open 
Sourced 
> > (new release yesterday b.t.w.). 
> > 
> > Jastor is a open source Java code generator that emits Java Beans from 
Web 
> > Ontologies (OWL) enabling convenient, type safe access and eventing of 
RDF 
> > stored in a Jena Semantic Web Framework model. Jastor generates Java 
> > interfaces, implementations, factories, and listeners based on the 
> > properties and class hierarchies in the Web Ontologies.
> > 
> > [1] http://jastor.sourceforge.net
> 
> Thanks for the link, I wasn't aware of this project!
> 
> The approach seems to be quite different from what I am trying to
> achieve with TreeBind: in Jastor you seem to be generating classes (not
> unlike JAXB in XML land) while I am trying to bind a RDF model to
> existing Java objects through introspection.
> 
> Is that also something that could be done with Jastor?
> 
> Thanks,
> 
> Eric
> 
> > 
> > Cheers!
> > Dan Smith
> > ---------------------------------------
> > Dan Smith
> > IBM Advanced Internet Technology Group
> > Cambridge, MA
> 
> -- 
> Read me on Advogato.

Received on Thursday, 30 June 2005 02:20:34 UTC