Broadcast on Broadcast off
The Documentation for Project Zero has moved. Please update your bookmarks to: http://www.projectzero.org/documentation/

Table of
Contents...
Hide

Project Zero Developer’s Guide

Concepts and components
Basic concepts overview
Event processing
Writing Java handlers
Writing Groovy handlers
Firing events
Global Context
Global Context reference
Application directory layout
Virtualized directories
Assemble
PHP
Features and configuration
Configuration
Debugging
Dependencies
Packaging
Application classpath
Logging and tracing
RESTful resources
RESTful documentation
File serving
Response rendering
Validators and validation
HTTP error handling
Calling a remote resource
Using the Connection API
Sending an email using EmailConnection
Configuring destinations
Configuring protocols
Configuring connection handlers
Creating a connection handler
Creating a custom protocol transport
Simple logging connection handlers
Protocol reference
Client programming with Dojo
Runtime options
Deployment modifications
HTTP configuration
SSL configuration
Proxy configuration
Extending the CLI
Security considerations
Authentication
OpenID authentication
Extending security
Security tokens
CSRF prevention support
Extending token support
Leveraging TAI
User service
File based user service
LDAP user service
Extending user service
Security Utilities
Leveraging XOREncoder
Extensions
Atom support
RSS support
JSON support
XMLEncoder
REST to SOAP extension
URIUtils
Developer Web tools
Database setup tools
Configuring data access
Common query patterns
Advanced query patterns
Update patterns
Local database transactions
Extending data access
Configuration vendor differences
PHP data access
Resource model
Configuring ZRM
Resource model declaration
Programmatic model API
HTTP REST API
A ZRM mini tutorial
Active content filtering support
Default filters
Custom filters
Runtime management
Management commands
Zero socket opener
Other extension modules
Amazon E-commerce service
Flickr service
WeatherZero forecast service
Wikipedia service
Reference
Zero command line interface
JavaDoc - Public API
JavaDoc - Public SPI
JavaDoc - All Classes

 

Configuring ZRM

A Project Zero resource model (ZRM) application consists of the database configuration, resource model declaration, and the resource event handler. You can find an example ZRM application in the employee.resource.demo package in the Project Zero samples.

Obtaining the Project Zero resource model

The Project Zero resource model is contained in the zero.resource model. To use it in your application, declare a dependency in your ${app_root}/config/ivy.xml file as shown in the following example:

<dependency name="zero.resource" org="zero" rev="1.0+"/>

Database configuration

Currently ZRM is only supported on the Derby database engine. To accept the default embedded Derby configuration, no additional configuration is necessary. However, to configure the database (if you already had a database configured, for example) you can do so by specifying the configure in the config/zero.config file of your application. You can either override the existing configuration or specify a global context dbKey.

To override the default configuration assign properties as shown in the following example:

/config/db/zero-resource = {
    "class" : "org.apache.derby.jdbc.EmbeddedDataSource",
    "databaseName" : "db/resource",
    "createDatabase" : "create"
}

If you already have database configuration, you can override the ZRM database by specifying the global context dbKey as shown in the following example:

/config/resource/dbKey = "my-database"

Resource Model declaration

Declare Project Zero resource models in separate Groovy files in the app/models folder of the application. These model files describe a resource type's data shape and validation constraints to the ZRM engine. From this metadata, ZRM can intelligently and dynamically create artifacts and modify runtime behavior.

A basic employees Zero Resource Model definition might look like the following example code in app/models/employees.groovy:

// Resource Model declaration
// File: /app/models/employees.groovy
fields = [ 
	name: [type: 'CharField', max_length:50],
	birthdate: [type: 'DateField'],
	state: [type: 'USStateField'],
	phone: [type: 'USPhoneField'],
]

Enabling HTTP

ZRM provides a robust set of REST HTTP APIs to resource models, but not by default. You can enable HTTP access to the Resource Model by introducing a resource event handler in the app/resources folder as shown in the following example:

// File: /app/resources/employees.groovy
ZRM.delegate()

r13 - 09 Feb 2008 - 17:54:53 - paynel
Syndicate this site RSS ATOM
Copyright 2007 © IBM Corporation | Privacy | Terms of Use | About this site