Summary: The processing unit can be injected with dynamic property values at deployment time. The mechanism leverages Spring's
PropertyPlaceholderConfigurer to provide powerful and simple properties-based injection.
OverviewWhen a processing unit is deployed and provisioned, you can inject property values to it only known at deployment time, or in order to further configure the processing unit elements. Injected properties can be either properties that have been explicitly externalized from the processing unit configuration file or properties related to one the platform components (e.g. a space) that can be configured at deployment time. This mechanism is built on top of Spring's support for an externalized properties configuration called PropertyPlaceholderConfigurer. This mechanism has been enhanced to provide a powerful yet simple property injection.
Defining Property Place Holders in Your Processing UnitProperty injection to the processing unit's configuration is supported at the Spring application context scope, which means that it can be applied to all of the components configured in the processing unit's configuration file (whether GigaSpaces out of the box components like the space, space proxy or event containers, or user-defined beans). Below you can find an example of an XML configuration which defines to property place holders, spaceSchema and connectionTimeout. In this example we also specify default values for them, which is always a good practice and does not force the deployer to specify values for these place holders.
Namespace
<!-- The PropertyPlaceholderConfigurer must be present in order to define default value for properties. --> <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="properties"><props> <prop key="spaceSchema">default</prop> <prop key="connectionTimeout">1000</prop> </props></property> </bean> <os-core:space id="space" url="/./space" schema="${spaceSchema}" /> <bean id="connBean" class="MyConnection"> <property name="timeout" value="${connectionTimeout}" /> </bean> Plain <!-- Define sensible defaults --> <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> <property name="properties"><props> <prop key="spaceSchema">default</prop> <prop key="connectionTimeout">1000</prop> </props></property> </bean> <bean id="space" class="org.openspaces.core.space.UrlSpaceFactoryBean"> <property name="url" value="/./space" /> <property name="schema" value="${spaceSchema}" /> </bean> <bean id="connBean" class="MyConnection"> <property name="timeout" value="${connectionTimeout}" /> </bean> The various processing unit runtime modes all provide support for injecting property values instead of place holders. There are several ways to define the values for the property place holders, depending on how you choose to run/deploy your processing unit. Using a .properties FileIf you would like your properties to be configured in a dedicated file this can be done in various ways.
Using Deployment Properties to Override Space Schema and Cluster SchemaWhen a Space is created, two major groups of configuration elements determine its runtime configuration: the space schema and the cluster schema. The cluster schema controls the space clustering topology (partitioned or replicated), whether the replication to its replicas is synchronous or asynchronous, and various other aspects that control its clustering behavior. The space schema on the other hand, controls other elements which are not related to the space clustering topology, such as the eviction strategy (LRU, ALL_IN_CACHE), whether or not its persistent, etc. The basis for these two configuration groups are XML files located inside the GigaSpaces libraries. In order to override the values in these XML files, one can simply specify the XPath expression that corresponds to the element to be overridden. These expression can also be included in all of the above mentioned property injection mechanisms (with the exception that you do not have to explicitly specify property placeholders for them). Here's an example for a space configured within the processing unit, and a property injection overriding its schema name:
Namespace
<os-core:space id="space" url="/./space" />
Plain <bean id="space" class="org.openspaces.core.space.UrlSpaceFactoryBean"> <property name="url" value="/./space" /> </bean> When deploying the space you should use -properties space embed://gs.space.url.arg.schema=persistent. This instructs the runtime to override the configuration of the bean named "space" in your pu.xml file with the specified value. You may also configure the space directly inside your processing unit using direct property injection on the space bean. See |
![]() |
GigaSpaces.com - Legal Notice - 3rd Party Licenses - Site Map - API Docs - Forum - Downloads - Blog - White Papers - Contact Tech Writing - Gen. by Atlassian Confluence |