Configuration

Provides information on how to configure the smartics-properties extension.

Admin Resource

This is for administration configuration only. Please skip this section, if you are not planning to load your configuration into an administration application.

If you do, provide a Maven POM that references all property declarations you use. The admin application will load those classes to enforce validation on properties.

Cache

To use a cache for storing property values, add the following:

<cache>
  <jndiName>java:jboss/infinispan/container/smartics-properties</jndiName>
  <cacheName>sandbox</cacheName>
</cache>

If not specified, a default in-memory cache will be used.

Data Source

If you want to store your properties in a data source, add the JNDI name of your data source here.

<datasource>
  <jndiName>java:jboss/datasources/propertiesDS</jndiName>
  <dropTable>false</dropTable>
  <createTable>true</createTable>
</datasource>

You may only want to use dropTables set to true in certain test environments. It will drop the properties tables. So make sure to backup your tables.

Creating tables with createTable is at least in development environments a good idea. It creates the tables, if not present, on-the-fly.

If this configuration is not given, it is assumed that the implementation of de.smartics.properties.api.config.app.ConfigurationPropertiesFactory (see below) will not require a data source to store its values (e.g. the factory may discover properties in properties files on the classpath).

Please refer to Supported Stores for information about supported databases.

Security

The security configuration allows to provide a symmetric key to en- and decrypt property values.

<security>
    <algorithm>AES</algorithm>
    <transformation>AES/ECB/PKCS5Padding</transformation>
    <key>+pvrmeQCmtWmYVOZ57uuIQ==</key>
</security>

If not specified, the values will per default be only Base64 encoded.

Factories

This section allows to configure services normally configured in META-INF/services. Please refer to Extension Points via Service-API for details on these services.

The JBoss extension provides the following defaults:

Service Name Default Implementation Remarks
de.smartics.properties.api.config.app.ConfigurationPropertiesFactory de.smartics.properties.impl.config.ds.AutodetectDataSourceConfigurationPropertiesFactory If a data source configuration is given.
de.smartics.properties.api.config.app.ConfigurationPropertiesFactory de.smartics.properties.impl.config.properties.PropertiesConfigurationPropertiesFactory If no data source configuration is given.
de.smartics.properties.resource.repository.ResourceRepository de.smartics.properties.resource.maven.repository.SessionedMavenResourceRepository If a definitions configuration is given. Non-admin use cases my safely ignore this.
de.smartics.properties.api.core.security.PropertyValueSecurity de.smartics.properties.api.core.security.PropertiesBasedPropertyValueSecurity If a security configuration is given.
de.smartics.properties.api.core.security.PropertyValueSecurity de.smartics.properties.api.core.security.Base64PropertyValueSecurity If no security configuration is given. Values are only Base64 encoded in this case.
de.smartics.properties.spi.config.cache.CacheManager de.smartics.properties.spi.config.cache.InMemoryCacheManager Default implementation for caches.
de.smartics.properties.spi.config.cache.CacheManager de.smartics.properties.spi.config.cache.infinispan.JndiInfinispanCompoundKeyCacheManager If a cache configuration is given and the JNDI name contains the substring /infinispan.
de.smartics.properties.spi.config.domain.key.ConfigurationKeyContext de.smartics.properties.impl.config.domain.key.envapp.EnvAppConfigurationKeyContext
de.smartics.util.lang.classpath.ClassPathListing de.smartics.jboss.vfs.VfsClassPathListing

Here is an example configuration that requires keys with tenants and users:

<factories>
  <factory type="de.smartics.properties.spi.config.domain.key.ConfigurationKeyContext">
    de.smartics.properties.impl.config.domain.key.rtaware.TenantUserConfigurationKeyContext
  </factory>
</factories>

Complete Example

Here is a complete example with two configuration:

<subsystem xmlns="urn:de.smartics:properties:1.0">
  <configurations>
    <configuration name="sandbox">
      <cache>
        <jndiName>java:jboss/infinispan/container/smartics-properties</jndiName>
        <cacheName>sandbox</cacheName>
      </cache>
      <datasource>
        <jndiName>java:jboss/datasources/propertiesDS</jndiName>
        <dropTable>false</dropTable>
        <createTable>true</createTable>
      </datasource>
      <security>
        <algorithm>AES</algorithm>
        <transformation>AES/ECB/PKCS5Padding</transformation>
        <!-- also allowed: <provider></provider> / -->
        <key>+pvrmeQCmtWmYVOZ57uuIQ==</key>
      </security>
      <factories>
        <factory type="de.smartics.properties.api.config.app.ConfigurationPropertiesFactory">de.smartics.properties.impl.config.ds.AutodetectDataSourceConfigurationPropertiesFactory</factory>
        <factory type="de.smartics.properties.api.core.security.PropertyValueSecurity">de.smartics.properties.security.esapi.EsapiPropertyValueSecurity</factory>
        <factory type="de.smartics.properties.spi.config.cache.CacheManager">de.smartics.properties.spi.config.cache.InMemoryCacheManager</factory>
        <factory type="de.smartics.properties.spi.config.domain.key.ConfigurationKeyContext">de.smartics.properties.impl.config.domain.key.rtaware.TenantUserConfigurationKeyContext</factory>
        <factory type="de.smartics.util.lang.classpath.ClassPathListing">de.smartics.jboss.vfs.VfsClassPathListing</factory>
      </factories>
    </configuration>

    <configuration name="sandbox2">
      <adminResource>
        <groupId>de.smartics.test</groupId>
        <artifactId>test-config</artifactId>
        <version>2.0</version>
        <archiveType>pom</archiveType>
        <classifier>something</classifier>
      </adminResource>
      <cache>
        <jndiName>java:jboss/infinispan/container/test</jndiName>
        <cacheName>sandbox</cacheName>
      </cache>
      <datasource>
        <jndiName>java:jboss/datasources/propertiesTest</jndiName>
        <dropTable>false</dropTable>
        <createTable>true</createTable>
      </datasource>
      <security>
        <algorithm>AES</algorithm>
        <transformation>AES/ECB/PKCS5Padding</transformation>
        <key>+pvrmeQCmtWmYVOZ57uuIQ==</key>
      </security>
    </configuration>
  </configurations>
</subsystem>