Page Tree | |
---|---|
|
...
|
...
|
...
Quick summary of features
Bean Session has a variety of features. A short list is given here for reference.
- Bean sessions are fully compatible with Tupelo's Contexts.
- Each bean is associated with an RDF subject.
- Beans are not required to be altered in any way to be used with the system as long as they have supported property types.
- The mappings between beans and RDF predicates may be customized, allowing great flexibility.
- Tools for generating and working with RDF vocabularies. A great deal of the work making mappings can be done automatically.
Working with new beans
A [bean mapping|http://tupeloproject.ncsa.uiuc.edu/node/67] is specified and added to the session for use. A bean is then registered if new, meaning it is associated with a subject and the session will track changes to it, or if it has already been serialized, it is fetched.
Code Block |
---|
Context context = ... // get the context
BeanSession beanSession = new BeanSession(context); // create a new bean session
Person person = ... // create a new bean. It is assumed a mapping already exists in the context.
Resource subject = Resource.uriRef("urn:my/bean/subject"); // get or create a subject
beanSession.register(subject, person); // tell the session to manage it.
// At this point the person bean is just like any other and you may change properties
// as needed.
// Once any and all changes have been made to the bean, save it to the backing context.
beanSession.save(subject); |
Fetching beans
Alternately, if data already exists, i.e., there is existing RDF that an application needs represented in a bean, then the application would fetch the bean:
Code Block |
---|
Context context = ... // get the context
Resource subject = ... // set the correct subject
BeanSession beanSession = new BeanSession(context); // create a new bean session
Person person = (Person) beanSession.fetchBean(subject); // Now the bean is ready for use. |
Refetching
Other capabilities include refetching beans. By refetching we mean that the values in the context are re-read and the state of the bean is updated. Since the bean session manages instances of beans, every effected bean would show changes seamlessly.
...