The Bean Session is Tupelo's stateful class to manage mapping java bean properties to and from RDF. It provides a higher level of abstraction thanthan Thing Session and shares a very similar API.
...
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.
Code Block |
---|
//.. assuming that a bean session exists and you have the subject of the bean
Person person = (Person) beanSession.fetch(subject);
// if some other process updates the context and you need these changes
beanSession.refetch(subject);
// now the stated person as well as any other beans it references, reflects these changes. |