Summary: Describing the built-in BasicProcessingUnitContainer which is an implementation of the IProcessingUnitContainer interface.
Configuring The Container Automatic ScanningBy default, the container will look for basic processing unit components, remote service and event listener container and instantiate and manage these components if found. This behavior can be enabled or disabled by configuring the container in the following manner: <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="GigaSpaces.XAP" type="GigaSpaces.XAP.Configuration.GigaSpacesXAPConfiguration, GigaSpaces.Core"/> </configSections> <GigaSpaces.XAP> <ProcessingUnitContainer Type="GigaSpaces.XAP.ProcessingUnit.Containers.BasicContainer.BasicProcessingUnitContainer, GigaSpaces.Core"/> <BasicContainer ScanRemotingServices="false" ScanBasicComponents="false" ScanEventContainer="false"> </BasicContainer> </GigaSpaces.XAP> </configuration> By default, when given an assembly name to scan for components, the entire assembly will be scanned. It is possible to specify a certain namespace inside an assembly that should be scanned for components instead of the entire assembly, this can be configured as follows: <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="GigaSpaces.XAP" type="GigaSpaces.XAP.Configuration.GigaSpacesXAPConfiguration, GigaSpaces.Core"/> </configSections> <GigaSpaces.XAP> <ProcessingUnitContainer Type="GigaSpaces.XAP.ProcessingUnit.Containers.BasicContainer.BasicProcessingUnitContainer, GigaSpaces.Core"/> <BasicContainer> <ScanAssemblies> <add AssemblyName="MyAssembly", NameSpace="MyNameSpace1"/> <add AssemblyName="MyAssembly", NameSpace="MyNameSpace2"/> </ScanAssemblies> </BasicContainer> </GigaSpaces.XAP> </configuration> Configuring Managed Space ProxiesThe space proxies which are created and managed by the container can be configured regarding their cluster state. <?xml version="1.0" encoding="utf-8" ?> <configuration> <configSections> <section name="GigaSpaces.XAP" type="GigaSpaces.XAP.Configuration.GigaSpacesXAPConfiguration, GigaSpaces.Core"/> </configSections> <GigaSpaces.XAP> <ProcessingUnitContainer Type="GigaSpaces.XAP.ProcessingUnit.Containers.BasicContainer.BasicProcessingUnitContainer, GigaSpaces.Core"/> <BasicContainer> <SpaceProxies> <add Name="MySpace" Url="/./mySpace" ClusterInfoAware="false"/> <add Name="MyClusteredSpace" Url="/./myClusteredProxy" Mode="Clustered"/> </SpaceProxies> </BasicContainer> </GigaSpaces.XAP> </configuration> This configuration file will create a container with two embedded spaces, one will not be aware to the cluster info which the container received, and as a result will be a single embedded space not part of any cluster. The default values for these properties are Direct for Mode and true for ClusterInfoAware. Basic Container Initialization EventsThe container exposes some events that can be used to be notified at the different stages of the container initialization. Here's a simple example of using this events in a BasicProcessingUnitComponent which acts as a feeder [BasicProcessingUnitComponent(Name="Feeder")] public class Feeder { private ISpaceProxy _proxy; private Thread _feedingThread; private volatile bool _stopped = false; [ContainerInitializing] public void Initialize() { [..] Console.WriteLine("Initialized"); } [ContainerInitialized] public void StartFeeding(BasicProcessingUnitContainer container) { _proxy = container.GetSpaceProxy("MySpace"); [..] _feedingThread = new Thread(Feed); _feedingThread.Start(); Console.WriteLine("Feeder started"); } public void Feed() { while(!_stopped) [..] } public void Dispose() { _stopped = true; _feedingThread.Join(); Console.WriteLine("Feeder Disposed"); } }
Basic Container Programatic APIThe container exposes API for creating managed space proxies and receiving its managed components. Here are a few samples of how to obtain managed components from the container: Create a managed space proxy BasicProcessingUnitContainer container = //Obtain a reference to the container ISpaceProxy spaceProxy = container.CreateSpaceProxy("ColocatedSpace", "/./mySpace"); Get a managed space proxy BasicProcessingUnitContainer container = //Obtain a reference to the container ISpaceProxy spaceProxy = container.GetSpaceProxy("ColocatedSpace"); Get a managed basic processing unit component BasicProcessingUnitContainer container = //Obtain a reference to the container Object component = container.GetProcessingUnitComponent("Feeder"); Get a managed event listener container BasicProcessingUnitContainer container = //Obtain a reference to the container IEventListenerContainer<Data> eventListenerContainer = container.GetEventListenerContainer<Data>("DataProcessor");
|
![]() |
GigaSpaces.com - Legal Notice - 3rd Party Licenses - Site Map - API Docs - Forum - Downloads - Blog - White Papers - Contact Tech Writing - Gen. by Atlassian Confluence |