GigaSpaces XAP 7.0 API

org.openspaces.pu.container.standalone
Class StandaloneProcessingUnitContainerProvider

java.lang.Object
  extended by org.openspaces.pu.container.standalone.StandaloneProcessingUnitContainerProvider
All Implemented Interfaces:
ClusterInfoAware, BeanLevelPropertiesAware, ClassLoaderAwareProcessingUnitContainerProvider, ProcessingUnitContainerProvider, ApplicationContextProcessingUnitContainerProvider

public class StandaloneProcessingUnitContainerProvider
extends Object
implements ApplicationContextProcessingUnitContainerProvider

A StandaloneProcessingUnitContainer provider. A standalone processing unit container is a container that understands a processing unit archive structure (both when working with an "exploded" directory and when working with a zip/jar archive of it). It is provided with the location of the processing unit using StandaloneProcessingUnitContainerProvider(String). The location itself follows Spring resource loader syntax.

When creating the container a thread is started with StandaloneContainerRunnable. This is done since a custom class loader is created taking into account the processing unit archive structure, and in order to allows using the standlone container within other environments, the new class loader is only set on the newly created thread context.

At its core the integrated processing unit container is built around Spring ApplicationContext configured based on a set of config locations.

The provider allows for programmatic configuration of different processing unit aspects. It allows to configure where the processing unit Spring context xml descriptors are located (by default it uses classpath*:/META-INF/spring/pu.xml). It also allows to set BeanLevelProperties and ClusterInfo that will be injected to beans configured within the processing unit.

For a runnable "main" processing unit container please see StandaloneProcessingUnitContainer.main(String[]).

Author:
kimchy

Field Summary
 
Fields inherited from interface org.openspaces.pu.container.spi.ApplicationContextProcessingUnitContainerProvider
DEFAULT_FS_PU_CONTEXT_LOCATION, DEFAULT_PU_CONTEXT_LOCATION
 
Constructor Summary
StandaloneProcessingUnitContainerProvider(String location)
          Constructs a new standalone container provider using the provided location as the location of the processing unit archive (either an exploded archive or a jar/zip archive).
 
Method Summary
 void addConfigLocation(Resource resource)
           
 void addConfigLocation(String configLocation)
          Adds a config location based on a String description using Springs PathMatchingResourcePatternResolver.
 ProcessingUnitContainer createContainer()
           Creates a new StandaloneProcessingUnitContainer based on the configured parameters.
 void setBeanLevelProperties(BeanLevelProperties beanLevelProperties)
          Sets the BeanLevelProperties that will be used to configure this processing unit.
 void setClassLoader(ClassLoader classLoader)
           
 void setClusterInfo(ClusterInfo clusterInfo)
          Sets the ClusterInfo that will be used to configure this processing unit.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

StandaloneProcessingUnitContainerProvider

public StandaloneProcessingUnitContainerProvider(String location)
Constructs a new standalone container provider using the provided location as the location of the processing unit archive (either an exploded archive or a jar/zip archive). The location syntax follows Spring Resource syntax.

Parameters:
location - The location of the processing unit archive
Method Detail

setBeanLevelProperties

public void setBeanLevelProperties(BeanLevelProperties beanLevelProperties)
Sets the BeanLevelProperties that will be used to configure this processing unit. When constructing the container this provider will automatically add to the application context both BeanLevelPropertyBeanPostProcessor and BeanLevelPropertyPlaceholderConfigurer based on this bean level properties.

Specified by:
setBeanLevelProperties in interface BeanLevelPropertiesAware

setClusterInfo

public void setClusterInfo(ClusterInfo clusterInfo)
Sets the ClusterInfo that will be used to configure this processing unit. When constructing the container this provider will automatically add to the application context the ClusterInfoBeanPostProcessor in order to allow injection of cluster info into beans that implement ClusterInfoAware.

Specified by:
setClusterInfo in interface ClusterInfoAware
Parameters:
clusterInfo - The cluster information to be injected

addConfigLocation

public void addConfigLocation(String configLocation)
Adds a config location based on a String description using Springs PathMatchingResourcePatternResolver.

Specified by:
addConfigLocation in interface ApplicationContextProcessingUnitContainerProvider
See Also:
PathMatchingResourcePatternResolver

addConfigLocation

public void addConfigLocation(Resource resource)
                       throws IOException
Specified by:
addConfigLocation in interface ApplicationContextProcessingUnitContainerProvider
Throws:
IOException

setClassLoader

public void setClassLoader(ClassLoader classLoader)
Specified by:
setClassLoader in interface ClassLoaderAwareProcessingUnitContainerProvider

createContainer

public ProcessingUnitContainer createContainer()
                                        throws CannotCreateContainerException

Creates a new StandaloneProcessingUnitContainer based on the configured parameters. A standalone processing unit container is a container that understands a processing unit archive structure (both when working with an "exploded" directory and when working with a zip/jar archive of it). It is provided with the location of the processing unit using StandaloneProcessingUnitContainerProvider(String). The location itself follows Spring resource loader syntax.

If addConfigLocation(String) is used, the Spring xml context will be read based on the provided locations. If no config location was provided the default config location will be classpath*:/META-INF/spring/pu.xml.

If setBeanLevelProperties(org.openspaces.core.properties.BeanLevelProperties) is set will use the configured bean level properties in order to configure the application context and specific beans within it based on properties. This is done by adding BeanLevelPropertyBeanPostProcessor and BeanLevelPropertyPlaceholderConfigurer to the application context.

If setClusterInfo(org.openspaces.core.cluster.ClusterInfo) is set will use it to inject ClusterInfo into beans that implement ClusterInfoAware.

Specified by:
createContainer in interface ProcessingUnitContainerProvider
Returns:
An StandaloneProcessingUnitContainer instance
Throws:
CannotCreateContainerException

GigaSpaces XAP 7.0 API

Copyright © GigaSpaces.