Hi folks!
So currently Resource is a very simple data object, with getters and
setters for pretty much everything... including, unfortunately, fields
that really should not be mutable by anyone except the inner workings of
Registry implementations. :( Simplifying this would be a) more correct,
and b) much less confusing for users confronted with a host of methods
that they can't really use.
I'd like to propose we do the following, in order to achieve a better
design as we move into wider usage.
* Refactor Resource into an interface:
interface Resource {
// These are all accessors, since setting these values
// only makes sense for the backend.
String getAuthorName();
String getLastUpdaterName();
Date getCreated();
Date getModified();
String getParentPath();
String getPath();
String [] getDependencies();
String [] getDependants();
// Content
Object getContent();
void setContent(Object content);
String getMediaType();
void setMediaType(String mediaType);
String getDescription();
void setDescription();
// Properties (these will change if we support
// multi-values)
String getProperty(String name);
void setProperty(String name, String value);
}
* I'd propose at the same time we do this we get rid of "isDirectory()"
and get back to the (IMO much better) design of Collection extends
Resource, which will allow us to implement pagination as well as easier
access to collection entries.... So something like:
interface Collection extends Resource {
String [] getChildren(); // Get 'em all
String [] getChildren(int start, int pageSize); // Paged
}
* Provide the following methods in CoreRegistry:
/**
* Factory for Resources pre-initialized with correct date, author,
* etc.
*/
Resource newResource() throws RegistryException;
/**
* Make a collection at the given path, returning the actual
* path if successful.
*/
String createCollection(String path) throws RegistryException;
* So usage would look something like:
Resource resource = registry.newResource();
resource.setContent("hi there");
resource.setMediaType("text/plain");
resource.setDescription("A simple greeting");
registry.put("/helloWorld", resource);
* We'd then have "ResourceImpl implements Resource", and ResourceImpl
would have all the setters - that's what gets used by JDBCRegistry.
Thoughts?
--Glen
_______________________________________________
Registry-dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/registry-dev