Chapter 6. Configuring Seam components

Seam aims to minimize the need for XML-based configuration. However, there are various reasons you might want to configure Seam components with XML: to isolate deployment-specific information from the Java code, to enable the creation of reuseable frameworks, to configure Seam's built-in functionality, etc. Seam provides two basic approaches to component configuration: via property settings in a properties file or web.xml, and via components.xml.

6.1. Configuring components via property settings

You can provide Seam with configuration properties with either servlet context parameters (in system properties), or with a properties file named seam.properties in the root of the classpath.
The configurable Seam component must expose JavaBean-style property setter methods for the configurable attributes. That is, if a Seam component named com.jboss.myapp.settings has a setter method named setLocale(), we can provide either:
  • a property named com.jboss.myapp.settings.locale in the seam.properties file,
  • a system property named org.jboss.seam.properties.com.jboss.myapp.settings.locale via -D at start up, or
  • the same system property as a Servlet context parameter.
Any of these will set the value of the locale attribute in the root of the class path.
The same mechanism is used to configure Seam itself. For example, to set conversation timeout, we provide a value for org.jboss.seam.core.manager.conversationTimeout in web.xml, seam.properties, or via a system property prefixed with org.jboss.seam.properties. (There is a built-in Seam component named org.jboss.seam.core.manager with a setter method named setConversationTimeout().)