In Atomserver Configuration, we explained how you can put your own resources and classes into the classpath that Atomserver uses.
To specify additional Spring configuration for Atomserver, put one or more XML files containing Spring bean definitions into the /org/atomserver/spring/ext package, and Atomserver will load them as part of the application context. There are a number of beans defined in Atomserver's default configuration, all of which are available for you to inject by name into your own beans. You can also override the definition of any of the default beans by providing your own bean with the same name. In that case, any of the default beans that injects a dependency of that name will inject YOUR definition instead.
Atomserver Beans
- Workspaces
- Database Beans
- org.atomserver-dataSource
- org.atomserver-sqlMapClient
- org.atomserver-entriesDAO
- org.atomserver-contentDAO
- org.atomserver-entryCategoriesDAO
- Abdera/Atomserver Beans
- org.atomserver-uriHandler
- org.atomserver-atomServer
- org.atomserver-atomService
- org.atomserver-simpleXMLContentValidator
- org.atomserver-isAliveHandler
- Storage Beans
- org.atomserver-contentStorage (org.atomserver-fileContentStorage, org.atomserver-dbContentStorage)
- org.atomserver-entryCategoriesContentStorage
- org.atomserver-entryCategoriesHandler
- Startup Beans
- Logging/Stats Beans
- JMX Beans
1. Workspaces
The most common extension point, this is the set of supported workspaces for the server -- it is injected into the default AtomService instance and defines the kind of entries that the server deals with.- org.atomserver-workspaces
- This bean is the most common thing for you to override - it is how you configure the set of Workspaces of which the Atomserver is aware. This bean should always be an instance of java.util.Set that contains instances of org.atomserver.core.WorkspaceOptions.
2. Database Beans
These beans deal with Atomserver's interaction with relational DBs. This includes the base DataSource that is used to interact with the DB via JDBC, the SQL map client that uses Spring JDBC templates and iBatis to abstract away the DB interaction, and the various DAO methods that encapsulate the DB methods into a consise Java API for manipulating the relational data.- org.atomserver-dataSource
- This bean is an instance of javax.sql.DataSource, which is used by all of the Atomserver classes that interact with a relational database. You can also use this bean if you want to access data in the same data source, or you can override this bean if you need to have fine-grained control over the specific DataSource implementation that is used. Usually, this won't be necessary - see Atomserver Database Configuration.
- org.atomserver-sqlMapClient
- Atomserver uses iBatis to manage our SQL interactions, and this is an instance of org.springframework.orm.ibatis.SqlMapClientFactoryBean that loads the Atomserver iBatis files from the classpath. It is injected into all of the DAOs.
- org.atomserver-entriesDAO
- This is the DAO that contains methods for managing all of the database interaction relating to atom Entries.
- org.atomserver-entryCategoriesDAO
- This is the DAO that contains methods for managing the categories attached to atom Entries in the database.
- org.atomserver-contentDAO
- This is the DAO that manages Entry content in the database (when the DB based content storage is used - this DAO is not initialized when the File based content storage is used.)
3. Abdera/Atomserver Beans
These beans are the core of the application, providing the bridge between Abdera's Atom URI handling on the front end and the various layers of workspace, collection, and entry handling in the server. You shouldn't need to inject or override these beans for most basic server deployments, but if you want to re-implement any of the core AtomServer functionality for an advanced use - this is where you would do so.- org.atomserver-uriHandler
- This bean is an instance of org.atomserver.uri.URIHandler. It is used to extract the atom-relevant data from URIs that are used to access the system, and to route requests to the correct behavior based on the contents of the URI and the HTTP method used.
- org.atomserver-atomServer
- This is the entry point for the Atomserver application - this instance of org.atomserver.AtomServer is the class to which Abdera routes HTTP requests, and this class delegates downward to the other Atomserver objects.
- org.atomserver-atomService
- This is an instance of org.atomserver.AtomService - the abstract representation of an atom service. By default, this will be an org.atomserver.core.dbstore.DBBasedAtomService.
- org.atomserver-simpleXMLContentValidator
- This is a content validator that only verifies whether the content passed to it is well-formed XML - it does not validate against any particular schema. This bean is useful to inject into a WorkspaceOptions object if you want to accept any well-formed XML as content for a workspace.
- org.atomserver-isAliveHandler
- This is an object that is used to monitor and control the availablity of the Atomserver. This object can be polled to determine whether the server is OK, DOWN, or in an ERROR state, and can be used to set the state to OK or DOWN. Read the javadoc for org.atomserver.core.dbstore.AtomServerIsAliveHandler for more details.
4. Storage Beans
These beans relate to how the content of Atom Entries is handled. This is kept distinct from where the entry meta data is stored so that the two choices can be made independently (in the default implementation, meta data is in a relational DB, and entry content lives on the file system.)- org.atomserver-contentStorage (org.atomserver-fileContentStorage, org.atomserver-dbContentStorage)
- The bean named org.atomserver-contentStorage must be an instance of org.atomserver.ContentStorage, and is used to facilitate storage of entry content. Internally, there are two lazy-init beans defined for the two default implementations of ContentStorage (file and DB storage), with an alias pointing org.atomserver-contentStorage to the file-based implementation. If you would like to use the DB-based one instead, you can simply create an alias to point at the other bean. If you have written your own custom ContentStorage implementation, then you can simply instantiate it and name it org.atomserver-contentStorage and it will be used.
- These two beans are the Handler and the ContentStorage instance that is used to handle "categories documents". You would override these if you have implemented a different strategy for how you manage the categories on an entry (which you are fairly unlikely to do...)
5. Startup Beans
These beans provide the basic environment configuration, and the opportunity to run some code on startup to do some static initialization of the system (we use this when using HSQLDB to make sure that the HSQL DB exists, and create it if not).- org.atomserver-propertyConfigurer
- This is an instance of Spring's PropertyPlaceholderConfigurer class, which is used to load environmental properties from the environment properties file and from the java system properties.
- org.atomserver-bootstrappers
- This is an instance of org.atomserver.utils.BootstrapperLoader that is used to execute "bootstrappers" when the spring context is loaded. The bootstrappers environment property should contain a comma-separated list of fully-qualified class names. Each of those classes should have a no-args constructor and implement java.lang.Runnable. Each of the bootstrapper classes will be loaded and their run() method executed, in the order specified. If a bean depends upon the bootstrappers having been run, it can specify depends-on="bootstrappers" in its bean configuration.
6. Logging / Stats Beans
These beans handle specialized logging and performance tracking functionality - allowing for detailed analysis of the behaviour of the running system.- org.atomserver-statsTracker
- Instance of org.atomserver.utils.stats.StatsTracker - used for tracking the runtime performance of various operations in the Atomserver.
- org.atomserver-performanceLog
- Instance of org.atomserver.utils.perf.PerformanceLog - used to log event timings for performance analysis of various operations in Atomserver - calls through to the org.atomserver-statsTracker bean for runtime analysis.
- org.atomserver-errorLog
- Instance of org.atomserver.utils.IOCLog that is used to log stack traces for all HTTP 50X(500, 503, etc.) errors that Atomserver returns.
7. JMX Beans
These beans handle exposing the managed beans out through a JMX Server.- org.atomserver-mBeanServer
- This bean is an instance of javax.management.MBeanServer that is used to expose the managed beans inside Atomserver.
- org.atomserver-mBeanServerLocator
- This bean is an instance of org.atomserver.utils.jmx.MBeanServerLocator, which tries to look up an MBeanServer from the JNDI tree if we are running inside a Resin server -- otherwise, fall back to the default Java 5 MBean Server. The default value for the org.atomserver-mBeanServer bean is located by this bean.
Extending Atomserver with Spring