<commit_before>---
layout: post97
title:  Data Source
categories: XAP97
parent: mongodb-space-persistency.html
weight: 100
---

A MongoDB based implementation of the [Space Data Source](./space-data-source-api.html). 

### Library dependencies 
The MongoDB Space Data Source uses [MongoDB Driver](http://www.allanbank.com/mongodb-async-driver/index.html) For communicating with the MongoDB cluster.
 
include the following in your `pom.xml`
{% highlight xml %}
<!-- currently the MongoDB library is not the central maven repository --> 
<repositories>
		<repository>
			<id>org.openspaces</id>
			<name>OpenSpaces</name>
			<url>http://maven-repository.openspaces.org</url>
		</repository>

		<repository>
			<releases>
				<enabled>true</enabled>
				<updatePolicy>always</updatePolicy>
				<checksumPolicy>warn</checksumPolicy>
			</releases>
			<id>allanbank</id>
			<name>Allanbank Releases</name>
			<url>http://www.allanbank.com/repo/</url>
			<layout>default</layout>
		</repository>
</repositories>


<!-- mongodb java driver -->
<dependency>
	<groupId>org.mongodb</groupId>
	<artifactId>mongo-java-driver</artifactId>
	<version>2.11.2</version>
</dependency>
<dependency>
	<groupId>com.allanbank</groupId>
	<artifactId>mongodb-async-driver</artifactId>
	<version>1.2.3</version>
</dependency>

<dependency> 
	<groupId>org.antlr</groupId> 
	<artifactId>antlr4-runtime</artifactId> 
	<version>4.0</version> 
</dependency> 

<dependency>
    <groupId>com.gigaspaces</groupId>
    <artifactId>mongo-datasource</artifactId>
    <version>9.7.0-SNAPSHOT</version>
</dependency>

{% endhighlight %}

### Setup 

An example of how the MongoDB Space Data Source can be configured for a space that loads data back from MongoDB once initialized and 
also asynchronously persists the data using a mirror (see [MongoDB Space Synchronization Endpoint](./mongodb-space-synchronization-endpoint.html))).
Note: for 9.7.1 version please use the code example inside:
http://docs.gigaspaces.com/xap100/mongodb-space-data-source.html

{% inittab Configuration Examples %}
{% tabcontent Spring %}{% highlight xml %} 
<?xml version="1.0" encoding="utf-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" 
xmlns:os-core="http://www.openspaces.org/schema/core" xmlns:os-jms="http://www.openspaces.org/schema/jms" 
xmlns:os-events="http://www.openspaces.org/schema/events" 
xmlns:os-remoting="http://www.openspaces.org/schema/remoting" 
xmlns:os-sla="http://www.openspaces.org/schema/sla" xmlns:tx="http://www.springframework.org/schema/tx" 

xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd 
http://www.openspaces.org/schema/core http://www.openspaces.org/schema/{%currentversion%}/core/openspaces-core.xsd
http://www.openspaces.org/schema/events http://www.openspaces.org/schema/{%currentversion%}/events/openspaces-events.xsd<commit_msg>updating mongo space source<commit_after>---
layout: post97
title:  Data Source
categories: XAP97
parent: mongodb-space-persistency.html
weight: 100
---

A MongoDB based implementation of the [Space Data Source](./space-data-source-api.html). 

### Library dependencies 
The MongoDB Space Data Source uses [MongoDB Driver](http://www.allanbank.com/mongodb-async-driver/index.html) For communicating with the MongoDB cluster.
 
include the following in your `pom.xml`
{% highlight xml %}
<!-- currently the MongoDB library is not the central maven repository --> 
<repositories>
		<repository>
			<id>org.openspaces</id>
			<name>OpenSpaces</name>
			<url>http://maven-repository.openspaces.org</url>
		</repository>

		<repository>
			<releases>
				<enabled>true</enabled>
				<updatePolicy>always</updatePolicy>
				<checksumPolicy>warn</checksumPolicy>
			</releases>
			<id>allanbank</id>
			<name>Allanbank Releases</name>
			<url>http://www.allanbank.com/repo/</url>
			<layout>default</layout>
		</repository>
</repositories>


<!-- mongodb java driver -->
<dependency>
	<groupId>org.mongodb</groupId>
	<artifactId>mongo-java-driver</artifactId>
	<version>2.11.2</version>
</dependency>
<dependency>
	<groupId>com.allanbank</groupId>
	<artifactId>mongodb-async-driver</artifactId>
	<version>1.2.3</version>
</dependency>

<dependency> 
	<groupId>org.antlr</groupId> 
	<artifactId>antlr4-runtime</artifactId> 
	<version>4.0</version> 
</dependency> 

<dependency>
    <groupId>com.gigaspaces</groupId>
    <artifactId>mongo-datasource</artifactId>
    <version>9.7.0-SNAPSHOT</version>
</dependency>

{% endhighlight %}

### Setup 

An example of how the MongoDB Space Data Source can be configured for a space that loads data back from MongoDB once initialized and 
also asynchronously persists the data using a mirror (see [MongoDB Space Synchronization Endpoint](./mongodb-space-synchronization-endpoint.html))).

{%note%}
With XAP 9.7.1 version please use the code example provided in [version 10.0](/xap100/mongodb-space-data-source.html)
{%endnote%}


{% inittab Configuration Examples %}
{% tabcontent Spring %}{% highlight xml %} 
<?xml version="1.0" encoding="utf-8"?> 
<beans xmlns="http://www.springframework.org/schema/beans" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context" 
xmlns:os-core="http://www.openspaces.org/schema/core" xmlns:os-jms="http://www.openspaces.org/schema/jms" 
xmlns:os-events="http://www.openspaces.org/schema/events" 
xmlns:os-remoting="http://www.openspaces.org/schema/remoting" 
xmlns:os-sla="http://www.openspaces.org/schema/sla" xmlns:tx="http://www.springframework.org/schema/tx" 

xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd 
http://www.openspaces.org/schema/core http://www.openspaces.org/schema/{%currentversion%}/core/openspaces-core.xsd
http://www.openspaces.org/schema/events http://www.openspaces.org/schema/{%currentversion%}/events/openspaces-events.xsd
{'fraction_non_alphanumeric': 0.1587100853619981, 'fraction_numerical': 0.012488144166930129, 'mean_word_length': 4.874651810584958, 'pattern_counts': {'":': 0, '<': 131, '<?xml version=': 2, '>': 129, 'https://': 0, 'lorem ipsum': 0, 'www.': 38, 'xml': 26}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3387292', 'n_tokens_mistral': 2305, 'n_tokens_neox': 2043, 'n_words': 356}