[id='programmatic_objects-{context}']
= {brandname} Configuration API
Configure {brandname} programmatically.

.Global configuration
Use the `GlobalConfiguration` class to apply configuration to all caches
under the Cache Manager.

[source,java]
----
GlobalConfiguration globalConfig = new GlobalConfigurationBuilder()
  .cacheContainer().statistics(true) <1>
  .metrics().gauges(true).histograms(true) <2>
  .jmx().enable() <3>
  .build();
----

<1> Enables Cache Manager statistics.
<2> Exports statistics through the `metrics` endpoint.
<3> Exports statistics via JMX MBeans.

**References:**

* link:{javadocroot}/org/infinispan/configuration/global/GlobalConfiguration.html[org.infinispan.configuration.global.GlobalConfiguration].
* link:{javadocroot}/org/infinispan/configuration/global/package-summary.html[Global Configuration API].

.Cache configuration
Use the `ConfigurationBuilder` class to configure caches.

[source,java]
----
ConfigurationBuilder builder = new ConfigurationBuilder();
     builder.clustering() <1>
            .cacheMode(CacheMode.DIST_SYNC) <2>
            .l1().lifespan(25000L) <3>
            .hash().numOwners(3) <4>
            .statistics().enable(); <5>
     Configuration cfg = builder.build();
----

<1> Enables cache clustering.
<2> Uses the distributed, synchronous cache mode.
<3> Configures maximum lifespan for entries in the L1 cache.
<4> Configures three cluster-wide replicas for each cache entry.
<5> Enables cache statistics.

**References:**

* link:{javadocroot}/org/infinispan/configuration/cache/ConfigurationBuilder.html[org.infinispan.configuration.cache.ConfigurationBuilder].
