|
|||||||||
Home >> All >> com >> RuntimeCollective >> webapps >> [ bean overview ] | PREV PACKAGE NEXT PACKAGE |
Package com.RuntimeCollective.webapps.bean
Webapps is the core module of Josephine.
See:
Description
Interface Summary | |
Actor | Abstract class for all objects that wrap a registered user of a Runtime Webapp. |
DBFile | Database entry which manages and refers to an file in the database |
Duplicable | Interface to implement if you want an EntityBean to be duplicable, that is, to make it possible to duplicate a bean into a new one, with the same properties, but a new id. |
EntityBean | A javabean must implement this interface in order to be handled by the EntityBeanStore . |
PermissionBean | Deprecated. This class shouldn't be used anymore - use the Permissions packages instead. |
SequenceBean | An interface for beans that can be identified by a sequence property -- this can either be a string representing an integer or a single letter. |
TrackedUser | A User whose logins and sessions we track. |
User | Interface for all objects that represent a registered user of a Runtime Webapp. |
Versioned | Interface to implement if you want an EntityBean to be duplicable, that is, to make it possible to duplicate a bean into a new one, with the same properties, but a new id. |
Class Summary | |
Address | An address. |
AuditedExtension | This Extension can be used to collect creation/lastModified user/date on any EntityBean. |
AuditInfo | A store for historical audit information about beans. |
BeanFileFolder | Object that represents a folder containing files associated with an EntityBean. |
Crumb | A single crumb of the crumb trail. |
DateBean | A date (and optional time) entered by a user (system-generated dates can stick with java.util.Date.). |
FormDate | A time stamp with bean style accessors which is the counterpart of ideas.tag.DateInputTag. |
LabelValue | A label value pair. |
LoginCookie | LoginCookie.java Keeps track of users who want to stay logged in |
ModeratedExtension | This is an extension which can be stuck to any EntityBean, and allows for the storage of moderation information for that bean. |
ScreenFlowState | A stack of local forwards for screens with a very simplistic workflow. |
SearchResult | A bean containing a single line of a search result. |
ServletFile | A wrapper to a DBFile which makes it more convenient to use in a servlet context. |
Session | The Session object is the identification that a User has logged in, and when. |
SimpleActor | A simple abstract implementation of the Actor interface that exposes the properties of the underlying User. |
SimpleDBFile | Database entry which manages and refers to an file in the database |
SimpleTrackedUser | The default implementation of TrackedUser. |
SimpleUser | Simple implementation of the User interface representing a user that has an address. |
TreeExtension | This is an extension which places the extended EntityBean into a tree, thus having 0/1 parent and 0/n children. |
UserGroup | A group of users. |
UserGroupType | A type of user group. |
VersionedExtension | An extension which can be used to stick the Versioned behaviour to any Duplicable bean. |
WebFolder | Object that represents the webfolder of a user -- a directory that sits on the server and can be accessed using WebDav. |
Package com.RuntimeCollective.webapps.bean Description
Webapps is the core module of Josephine. It adds basic components to the Struts framework, held in the com.RuntimeCollective.webapps.* packages (webapps, webapps.bean, webapps.form, webapps.action, and webapps.tag). The javadoc has more information about each class; the following is just an overview.
1. webapps.tag
The com.RuntimeCollective.webapps.tag package includes a number of custom tags to make it easier to write JSP pages. See the individual javadoc for more details. These tags are configured using the etc/runtime-struts.tld file.2. webapps.bean
The com.RuntimeCollective.webapps.bean package includes basic beans that are common for community systems. These can be used 'as is' or extended as necessary. The most important ones are:- User - a registered user, with just an email address and password
- SimpleUser - a registered user with full contact information. Note that the User/SimpleUser class should be extended following the Actor pattern: do not extend SimpleUser, but write a new class A which has a static A.getAForUser(user) method
- DateBean - a wrapper for a date, with additional methods for interfacing with a DateInputTag, and a SQL database.
- EntityBean - All beans that are identified by a unique ID should implement this interface, which is used by the persistence framework to handle persisting this bean to a database.
- PermissionBean - Used by the CheckView and CheckEdit tags to control which users can access this bean.
3. webapps.form
Beans often have an associated form (eg SimpleUserForm for editing the User bean). In such cases the form should be held in the com.RuntimeCollective.my_application.form package, extend the org.apache.struts.ActionForm class. In addition, the following interface is defined:(See the individual javadoc, and section 4 below for more details.)BeanForm - this interface specifies methods for getting information to and from the corresponding entity bean. This interface is widely used by the persistence model.
4. Webapps persistence model
The Struts framework does not specify a mechanism for persisting beans to a database, or holding them in memory, so this is done using the Webapps persistence model, which comprises the following parts:- webapps.bean.EntityBean - Beans that are part of the persistence framework must implement this interface. It specifies that the bean must be identifiable by a primary key, must have constructors for generating new unique instances and for getting existing ones from the database, and must have a save method. Entity Beans typically come paired with a BeanForm (see above).
- webapps.RuntimeDataSource - This object handles JDBC connection pooling, and RDMBS transactions cleanly. Once it has been initialised, then it makes it easier for the beans to execute database queries and updates.
- webapps.RuntimeParameters - This object holds system-wide parameters, taken from the web.xml config file. This includes a reference to the EntityBeanStoreHandler, which is initiliased at startup time. An HTTP proxy can also be configured from here.
- webapps.EntityBeanStoreHandler - This handler assigns an EntityBeanStore to each class of EntityBean, according to the web.xml configuration file.
- webapps.EntityBeanStore - It is wasteful for each user session
to get its own set of bean instances from the database and hold them in memory,
and also involves synchronisation issues if two or more sessions have local
copies of the same data. The EntityBeanStore solves this by holding references
to all the currently-used entity beans in the application, which all the sessions can then
share. No thread in the application should ever generate a new entity
bean, instead they should only be taken from the store.
webapps.EntityBeanStore is in fact an interface, implemented at the moment by two classes:
- SimpleEntityBeanStore - A simple implementation of EntityBeanStore, which keeps WeakReferences to the beans currently in use. Once they are not used anymore, you should expect the GarbageCollector to clean the beans from memory.
- IndexedEntityBeanStore - A more complex Store which keeps an index of all beans created. This allows for a better support of class abstraction/inheritance mechanisms. It is also possible to assign a webapps.Cache to each EntityBean class. The only Caches implemented so far are:
- webapps.GarbageCollectedCache - A cache which keeps only WeakReferences to the stored beans, hence behaving just like the webapps.SimpleEntityBeanStore.
- webapps.PermanentCache - This cache keeps explicit references to all the beans, hence keeping them in memory permanently (at the risk of running out of memory). Use this cache only for beans which are not created that often.
5. Sample pages and actions
Webapps includes some sample jsp pages (in the web/ directory) and actions (in the webapps.action package) that use the Webapps forms.- rs_logon.jsp and LogonAction - verifies a user logon.
- BeanLoader - a general purpose configurable action that loads a bean into memory, populates a form, and takes the user onto a page where (typically) they can edit that bean.
- BeanEditor - a general purpose configurable action that edits, registers or deletes a bean. Usually used in conjunction with the BeanLoader .
- crumbTrailAction - used in conjunction with the crumbTrailTag , and handles the crumb trail links.
6. Miscellaneous
The Webapps framework also includes the following additional elements.- webapps.InitialiserServlet - a servlet that is run at application startup, and which initialises the RuntimeDataSource, EntityBeanStore, and RuntimeParameters from parameters in etc/web.xml.
- web/Messages.properties - a properties file with sample error messages for Webapps form validation.
- etc/runtime-struts.oracle.sql - an sql schema file
- webapps.bean.SearchResult and webapps.SearchResults - classes useful for holding and displaying search results.
- webapps.bean.SequenceBean and webapps.BeanSequence - it is often useful to have a list of beans identified by a sequence number, such that if new elements are inserted (or old ones removed) then the sequence will be reshuffled. BeanSequence is an extension of java.util.SortedMap that handles this re-ordering, and SequenceBean is an interface that members of a BeanSequence must implement.
7. The BeanMaker
A lot of time can be spent just writing bean-code for an application (all those sets and gets), so Webapps includes a simple application for generating code for beans and their corresponding forms automatically. The rs_makeBean.html page prompts for the name, package, and description of the bean and form, and the type, name, and description of up to 20 properties. It will then generate the appropriate code, including stubs for the new and save methods and the populateForm and populateBean methods (see the EntityBean and BeanForm interfaces for more details).Note that the code is not quite ready-to-run. There are often slight differences between form and bean property types, for example. But this application can save a lot of writing. It can also be used to just generate a code fragment for the get and set methods of a single property, which can then be inserted into existing code.
|
|||||||||
Home >> All >> com >> RuntimeCollective >> webapps >> [ bean overview ] | PREV PACKAGE NEXT PACKAGE |