OSCore PropertySet

The PropertySet module is probably the most used component in OSCore. It provides a generic way to store and retrieve serializable information via a standard interface (com.opensymphony.module.propertyset.PropertySet). The idea behind the PropertSet module is that each entity instance in an application can have some extra set of attributed unknown at development time. One example of this is metadata, as the requirements for metadata change frequently in evolving businesses. By utilizing the PropertySet module, one can write an application that uses datasets unknown to the developer. Each property set implementation has it's own way of associating a PropertySet with an entity instance, but the usual way is by a key that consists of a String, entityName, and a long, entityId.

There are several PropertySet implementations provided in OSCore, but you are free to write your own to best fit your specific requirements. The three major implementations are:

All of these implementations persist data to a relational database. The following SQL script will create the tables that these implementations require. Please note that this SQL script has only been tested on Oracle and Hypersonic databases and may require slight modifications

	create table OS_PROPERTYDATA (id NUMBER not null primary key, value LONG RAW null)
	create table OS_PROPERTYDATE (id NUMBER not null primary key, value DATE null)
	create table OS_PROPERTYDECIMAL (id NUMBER not null primary key, value double precision null)
	create table OS_PROPERTYNUMBER (id NUMBER not null primary key, value NUMBER null)
	create table OS_PROPERTYENTRY (id NUMBER not null primary key, entityName VARCHAR2(255) null, entityId NUMBER null, type NUMBER null, key VARCHAR2(255) null)
	create table OS_PROPERTYSTRING (id NUMBER not null primary key, value VARCHAR2(255) null)

EJBPropertySet

In order to use the EJBPropertySet, you must install OSCore using the EJB Installation. The EJBPropertySet will only work if oscore.jar has successfully deployed to your application server. Also, the EJBPropertySet is also used in the helper class com.opensymphony.ejb.EntityAdapter, which essentially provides a PropertySet for any entity bean that extends EntityAdapter. The following is some sample code using the EJBPropertySet:

	PropertyStoreHome psh = (PropertyStoreHome)
EJBUtils.lookup("ejb/os.PropertyStore", PropertyStoreHome.class); PropertySet ps = new EJBPropertySet(psh, "blah",20); ps.setString("foo", ps.getString("foo") + "!"); // 'foo' now is 'foo'!

In order to use the EJBPropertySet, we recommend that you place the following ejb-ref in your web.xml or ejb-jar.xml deployment descriptor. This ejb-ref will also need to be mapped to the jndi-name os.PropertyStore using vendor-specific deployment descriptors:

	<ejb-ref>
		<ejb-ref-name>ejb/os.PropertyStore</ejb-ref-name>
		<ejb-ref-type>Session</ejb-ref-type>
		<home>com.opensymphony.module.propertyset.ejb.PropertyStoreHome</home>
		<remote>com.opensymphony.module.propertyset.ejb.PropertyStore</remote>
		<ejb-link>os.PropertyStore</ejb-link>
	</ejb-ref>

JDBCPropertySet

There is nothing very special about the JDBCPropertySet. Here is some a sample usage:

	DataSource ds = new InitialContext().lookup("java:comp/env/ejb/DefaultDS");
	PropertySet ps = new JDBCPropertySet(ds.openConnection());
	ps.setString("foo", "bar");

OFBizPropertySet

There is nothing very special about the OFBizPropertySet once the OpenForBusiness entity definitions have been configured properly. The following is a sample usage:

	PropertySet ps = new OFBizPropertySet("myEntity", 100);
	ps.setString("foo", "bar"); // just set foo=bar for myEntity #100