org.apache.cayenne.configuration.server
Class PropertyDataSourceFactory

java.lang.Object
  extended by org.apache.cayenne.configuration.server.PropertyDataSourceFactory
All Implemented Interfaces:
DataSourceFactory

public class PropertyDataSourceFactory
extends Object
implements DataSourceFactory

A DataSourceFactrory that creates a DataSource based on system properties. Properties can be set per domain/node name or globally, aplying to all nodes without explicit property set. The following properties are supported:

At least url and driver properties must be specified for this factory to return a valid DataSource.

Since:
3.1

Constructor Summary
PropertyDataSourceFactory()
           
 
Method Summary
 DataSource getDataSource(DataNodeDescriptor nodeDescriptor)
          Returns DataSource object based on the configuration provided in the "nodeDescriptor".
protected  int getIntProperty(String propertyName, String suffix, int defaultValue)
           
protected  String getProperty(String key)
          Returns a property value for a given full key.
protected  String getProperty(String propertyName, String suffix)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PropertyDataSourceFactory

public PropertyDataSourceFactory()
Method Detail

getDataSource

public DataSource getDataSource(DataNodeDescriptor nodeDescriptor)
                         throws Exception
Description copied from interface: DataSourceFactory
Returns DataSource object based on the configuration provided in the "nodeDescriptor".

Specified by:
getDataSource in interface DataSourceFactory
Throws:
Exception

getIntProperty

protected int getIntProperty(String propertyName,
                             String suffix,
                             int defaultValue)

getProperty

protected String getProperty(String propertyName,
                             String suffix)

getProperty

protected String getProperty(String key)
Returns a property value for a given full key. This implementation returns a System property. Subclasses may lookup properties elsewhere. E.g. overriding this method can help with unit testing this class.



Copyright © 2001-2010 Apache Cayenne. All Rights Reserved.