diff --git a/pom.xml b/pom.xml
index e34accb8d..01507fb76 100755
--- a/pom.xml
+++ b/pom.xml
@@ -47,6 +47,30 @@
+
+ jrebel
+
+
+
+
+
+
+
+ org.zeroturnaround
+ jrebel-maven-plugin
+
+
+ generate-rebel-xml
+ process-resources
+
+ generate
+
+
+
+
+
+
+
elasticsearch-remote
@@ -85,7 +109,7 @@
80
0
- INFO
+ DEBUG
PAPERTRAIL
logs.papertrailapp.com
38143
@@ -139,7 +163,7 @@
0
- WARN
+ DEBUG
CONSOLE
64M
true
@@ -282,6 +306,26 @@
+
+ org.springframework.data
+ spring-data-cassandra
+ 1.3.1.RELEASE
+
+
+ com.datastax.cassandra
+ cassandra-driver-core
+ ${datastax.version}
+
+
+ com.datastax.cassandra
+ cassandra-driver-mapping
+ ${datastax.version}
+
+
+ com.rometools
+ rome
+ 1.5.0
+
org.codehaus.groovy
groovy-all
@@ -323,6 +367,7 @@
${selenium.version}
test
+
org.apache.directory.server
apacheds-all
@@ -393,18 +438,18 @@
src/main/webapp/assets/**.*
UTF-8
- 1.6
+ 1.8
- 3.2.3.RELEASE
- 3.1.3.RELEASE
+ 4.2.2.RELEASE
+ 4.0.3.RELEASE
0.20.6
1.6.11
1.7.5
1.0.13
4.2.2
4.2.2
- 1.2.6
+ 2.2.3
1.1-4
3.1-09
1.0.2
@@ -420,13 +465,14 @@
4.11
1.3
1.3.5
- 1.2.0.1
+ 2.1.3.1
1.9.0
1.0
1.2.1
1.7
2.2.0
2.11.0
+ 2.1.9
2.31.0
@@ -436,7 +482,7 @@
2.14
2.3
8.1.13.v20130916
- 1.2.1-1
+ 2.1.7-1
1.7.0
2.9
Tomcat
@@ -467,6 +513,40 @@
+
+ io.springfox
+ springfox-swagger2
+ 2.2.2
+
+
+ org.mapstruct
+ mapstruct
+
+
+
+
+ org.mapstruct
+ mapstruct-jdk8
+ 1.0.0.Final
+
+
+
+ ch.qos.logback
+ logback-core
+ ${logback.version}
+
+
+
+ ch.qos.logback
+ logback-classic
+ ${logback.version}
+
+
+
+ javax.validation
+ validation-api
+ ${javax.validation.api.version}
+
com.fasterxml.jackson.datatype
jackson-datatype-json-org
@@ -483,9 +563,14 @@
${jackson.version}
- com.notnoop.apns
- apns
- 0.2.3
+ org.hibernate
+ hibernate-validator
+ ${hibernate.validator.version}
+
+
+ joda-time
+ joda-time
+ ${jodatime.version}
com.yammer.metrics
@@ -553,84 +638,6 @@
jstl
${jstl.version}
-
- javax.validation
- validation-api
- ${javax.validation.api.version}
-
-
- joda-time
- joda-time
- ${jodatime.version}
-
-
-
- ch.qos.logback
- logback-core
- ${logback.version}
-
-
-
- ch.qos.logback
- logback-classic
- ${logback.version}
-
-
-
- net.sf.ehcache
- ehcache-core
- 2.6.5
-
-
- net.sf.ehcache
- ehcache-web
- 2.0.4
-
-
- org.apache.camel
- camel-core
- ${camel.version}
-
-
- org.apache.camel
- camel-spring
- ${camel.version}
-
-
- org.apache.camel
- camel-script
- ${camel.version}
-
-
- org.apache.camel
- camel-rss
- ${camel.version}
-
-
- org.apache.camel
- camel-twitter
- ${camel.version}
-
-
- org.apache.camel
- camel-stream
- ${camel.version}
-
-
- org.apache.httpcomponents
- httpcore
- ${httpclient.core.version}
-
-
- org.apache.httpcomponents
- httpclient
- ${httpclient.client.version}
-
-
- org.apache.geronimo.javamail
- geronimo-javamail_1.4_mail
- 1.8.2
-
org.apache.openjpa
openjpa
@@ -655,58 +662,19 @@
jar
compile
+
- org.atmosphere
- atmosphere-annotations
- 1.1.0.RC3
+ org.apache.geronimo.javamail
+ geronimo-javamail_1.4_mail
+ 1.8.2
+
org.elasticsearch
elasticsearch
${elasticsearch.version}
-
- org.hectorclient
- hector-core
- ${hector.version}
-
-
- javax.servlet
- servlet-api
-
-
-
-
- org.hectorclient
- hector-object-mapper
- ${hector.mapper.version}
-
-
- org.mortbay.jetty
- servlet-api
-
-
-
-
- org.hibernate
- hibernate-validator
- ${hibernate.validator.version}
-
-
- org.pegdown
- pegdown
- ${pegdown.version}
-
-
- org.slf4j
- slf4j-api
- ${slf4j.version}
-
-
- org.slf4j
- jcl-over-slf4j
- ${slf4j.version}
-
+
org.springframework
spring-aop
@@ -787,6 +755,37 @@
spring-security-web
${spring.security.version}
+
+ com.rometools
+ rome
+ 1.5.0
+
+
+ org.pegdown
+ pegdown
+ ${pegdown.version}
+
+
+ com.datastax.cassandra
+ cassandra-driver-core
+ ${datastax.version}
+
+
+ com.datastax.cassandra
+ cassandra-driver-mapping
+ ${datastax.version}
+
+
+
+ com.notnoop.apns
+ apns
+ 0.2.3
+
+
+ org.atmosphere
+ atmosphere-annotations
+ 1.1.0.RC3
+
org.pac4j
pac4j-oauth
@@ -797,44 +796,54 @@
spring-security-pac4j
1.2.4
+
+
- rome
- rome
- ${rome.version}
+ org.cassandraunit
+ cassandra-unit
+ 2.1.9.2
+ test
+
+
+
+ org.springframework.data
+ spring-data-cassandra
+ 1.3.1.RELEASE
-
- org.apache.cassandra
- cassandra-all
- ${cassandra.version}
-
-
- javax.servlet
- servlet-api
-
-
- org.mortbay.jetty
- servlet-api
-
-
- org.mortbay.jetty
- jetty
-
-
- org.mortbay.jetty
- jetty-util
-
-
- test
+ org.apache.camel
+ camel-core
+ ${camel.version}
- com.jayway.jsonpath
- json-path
- 0.8.1
- test
+ org.apache.camel
+ camel-spring
+ ${camel.version}
+
+
+ org.apache.camel
+ camel-script
+ ${camel.version}
+
+
+ org.apache.camel
+ camel-rss
+ ${camel.version}
+
+
+ org.apache.camel
+ camel-twitter
+ ${camel.version}
+
+ org.apache.camel
+ camel-stream
+ ${camel.version}
+
+
+
org.springframework
spring-test
@@ -865,18 +874,6 @@
${awaitility.version}
test
-
- org.cassandraunit
- cassandra-unit
- ${cassandra.unit.version}
- test
-
-
- hamcrest-all
- org.hamcrest
-
-
-
org.mockito
mockito-all
@@ -889,6 +886,28 @@
${camel.version}
test
+
+ net.sf.ehcache
+ ehcache-core
+ 2.6.5
+
+
+ net.sf.ehcache
+ ehcache-web
+ 2.0.4
+
+
+
+ org.slf4j
+ slf4j-log4j12
+ 1.7.7
+
+
+
+ com.google.guava
+ guava
+ 18.0
+
@@ -957,8 +976,8 @@
${maven.surefire.version}
${project.testresult.directory}/surefire-reports
- -XX:MaxPermSize=128m -Xmx256m ${surefireArgLine}
- ${skip.unit.tests}
+ ${surefireArgLine}
+
alphabetical
-
- org.codehaus.mojo
- cassandra-maven-plugin
- ${maven.cassandra.version}
-
-
- org.apache.cassandra
- cassandra-all
- ${cassandra.version}
-
-
-
org.mortbay.jetty
jetty-maven-plugin
@@ -1070,6 +1077,20 @@
+
+ org.zeroturnaround
+ jrebel-maven-plugin
+ 1.1.5
+
+
+ generate-rebel-xml
+ process-resources
+
+ generate
+
+
+
+
diff --git a/services/src/main/java/fr/ippon/tatami/config/ApplicationConfiguration.java b/services/src/main/java/fr/ippon/tatami/config/ApplicationConfiguration.java
index 03ff7fde0..2ec2dcc54 100644
--- a/services/src/main/java/fr/ippon/tatami/config/ApplicationConfiguration.java
+++ b/services/src/main/java/fr/ippon/tatami/config/ApplicationConfiguration.java
@@ -1,14 +1,26 @@
package fr.ippon.tatami.config;
-import org.apache.thrift.transport.TTransportException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.*;
import org.springframework.core.env.Environment;
+import org.springframework.http.ResponseEntity;
+import org.springframework.util.StopWatch;
+import org.springframework.web.bind.annotation.RequestMethod;
+import springfox.documentation.builders.PathSelectors;
+import springfox.documentation.builders.RequestHandlerSelectors;
+import springfox.documentation.service.ApiInfo;
+import springfox.documentation.spi.DocumentationType;
+import springfox.documentation.spring.web.plugins.Docket;
import javax.annotation.PostConstruct;
import javax.inject.Inject;
+import javax.servlet.ServletContext;
import java.io.IOException;
+import java.time.LocalDate;
+import java.util.Date;
+
+import static springfox.documentation.builders.PathSelectors.regex;
@Configuration
@PropertySource({"classpath:/META-INF/tatami/tatami.properties",
@@ -32,6 +44,40 @@ public class ApplicationConfiguration {
@Inject
private Environment env;
+ public static final String DEFAULT_INCLUDE_PATTERN = "/tatami/.*";
+
+ @Bean
+ public Docket swaggerSpringfoxDocket() {
+ log.debug("Starting Swagger");
+ StopWatch watch = new StopWatch();
+ watch.start();
+ ApiInfo apiInfo = new ApiInfo(
+ env.getProperty("swagger.title"),
+ env.getProperty("swagger.description"),
+ env.getProperty("swagger.version"),
+ env.getProperty("swagger.termsOfServiceUrl"),
+ env.getProperty("swagger.contact"),
+ env.getProperty("swagger.license"),
+ env.getProperty("swagger.licenseUrl"));
+
+ Docket docket = new Docket(DocumentationType.SWAGGER_2)
+ .apiInfo(apiInfo)
+ .select()
+ .apis(RequestHandlerSelectors.any())
+ .paths(PathSelectors.any())
+ .build()
+ .directModelSubstitute(LocalDate.class,
+ String.class)
+ .genericModelSubstitutes(ResponseEntity.class)
+ .useDefaultResponseMessages(false)
+ .enableUrlTemplating(true)
+ .pathMapping("/tatami");
+ watch.stop();
+ log.debug("Started Swagger in {} ms", watch.getTotalTimeMillis());
+ return docket;
+ }
+
+
/**
* Initializes Tatami.
*
@@ -43,7 +89,7 @@ public class ApplicationConfiguration {
* - "tatamibot" : for enabling the Tatami bot
*/
@PostConstruct
- public void initTatami() throws IOException, TTransportException {
+ public void initTatami() throws IOException {
log.debug("Looking for Spring profiles... Available profiles are \"metrics\", \"tatamibot\" and \"apple-push\"");
if (env.getActiveProfiles().length == 0) {
log.debug("No Spring profile configured, running with default configuration");
diff --git a/services/src/main/java/fr/ippon/tatami/config/AsyncConfiguration.java b/services/src/main/java/fr/ippon/tatami/config/AsyncConfiguration.java
index db426ed88..4287a6b1a 100644
--- a/services/src/main/java/fr/ippon/tatami/config/AsyncConfiguration.java
+++ b/services/src/main/java/fr/ippon/tatami/config/AsyncConfiguration.java
@@ -4,6 +4,8 @@
import fr.ippon.tatami.service.elasticsearch.ElasticsearchSearchService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.aop.interceptor.AsyncUncaughtExceptionHandler;
+import org.springframework.aop.interceptor.SimpleAsyncUncaughtExceptionHandler;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.scheduling.annotation.AsyncConfigurer;
@@ -37,4 +39,9 @@ public Executor getAsyncExecutor() {
executor.initialize();
return executor;
}
+
+ @Override
+ public AsyncUncaughtExceptionHandler getAsyncUncaughtExceptionHandler() {
+ return new SimpleAsyncUncaughtExceptionHandler();
+ }
}
diff --git a/services/src/main/java/fr/ippon/tatami/config/CassandraConfiguration.java b/services/src/main/java/fr/ippon/tatami/config/CassandraConfiguration.java
index 8bfdc7dac..c6fb6b64a 100644
--- a/services/src/main/java/fr/ippon/tatami/config/CassandraConfiguration.java
+++ b/services/src/main/java/fr/ippon/tatami/config/CassandraConfiguration.java
@@ -1,28 +1,43 @@
package fr.ippon.tatami.config;
-import me.prettyprint.cassandra.connection.HOpTimer;
-import me.prettyprint.cassandra.connection.MetricsOpTimer;
-import me.prettyprint.cassandra.model.ConfigurableConsistencyLevel;
-import me.prettyprint.cassandra.service.CassandraHostConfigurator;
-import me.prettyprint.cassandra.service.ThriftCfDef;
-import me.prettyprint.cassandra.service.ThriftCluster;
-import me.prettyprint.cassandra.service.ThriftKsDef;
-import me.prettyprint.hector.api.Cluster;
-import me.prettyprint.hector.api.HConsistencyLevel;
-import me.prettyprint.hector.api.Keyspace;
-import me.prettyprint.hector.api.ddl.ColumnFamilyDefinition;
-import me.prettyprint.hector.api.ddl.ComparatorType;
-import me.prettyprint.hector.api.ddl.KeyspaceDefinition;
-import me.prettyprint.hector.api.factory.HFactory;
-import me.prettyprint.hom.EntityManagerImpl;
+import com.datastax.driver.core.*;
+import com.datastax.driver.core.policies.LatencyAwarePolicy;
+import com.datastax.driver.core.policies.LoadBalancingPolicy;
+import com.datastax.driver.core.policies.ReconnectionPolicy;
+import com.datastax.driver.core.policies.RetryPolicy;
+import com.google.common.collect.Lists;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
+import org.springframework.data.cassandra.config.CassandraEntityClassScanner;
+import org.springframework.data.cassandra.config.CassandraSessionFactoryBean;
+import org.springframework.data.cassandra.convert.CassandraConverter;
+import org.springframework.data.cassandra.convert.MappingCassandraConverter;
+import org.springframework.data.cassandra.core.CassandraAdminOperations;
+import org.springframework.data.cassandra.core.CassandraAdminTemplate;
+import org.springframework.data.cassandra.mapping.BasicCassandraMappingContext;
+import org.springframework.data.cassandra.mapping.CassandraMappingContext;
+import org.springframework.util.StringUtils;
import javax.annotation.PreDestroy;
import javax.inject.Inject;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Field;
+import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.concurrent.TimeUnit;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+import static com.datastax.driver.core.ProtocolOptions.Compression.LZ4;
+import static com.datastax.driver.core.ProtocolOptions.Compression.NONE;
+import static com.datastax.driver.core.ProtocolOptions.Compression.SNAPPY;
+import static com.datastax.driver.core.ProtocolVersion.V1;
+import static com.datastax.driver.core.ProtocolVersion.V2;
+import static com.datastax.driver.core.ProtocolVersion.V3;
/**
* Cassandra configuration file.
@@ -32,6 +47,22 @@
@Configuration
public class CassandraConfiguration {
+ public static final String CASSANDRA_CLUSTER_NAME = "cassandra.cluster";
+ public static final String CASSANDRA_PORT = "cassandra.port";
+ public static final String CASSANDRA_PROTOCOL_VERSION = "cassandra.protocolVersion";
+ public static final String CASSANDRA_COMPRESSION = "cassandra.compression";
+ public static final String CASSANDRA_LOAD_BALANCING_POLICY = "cassandra.loadBalancingPolicy";
+ public static final String CASSANDRA_CONSISTENCY = "cassandra.consistency";
+ public static final String CASSANDRA_SERIAL_CONSISTENCY = "cassandra.serialConsistency";
+ public static final String CASSANDRA_FETCH_SIZE = "cassandra.fetchSize";
+ public static final String CASSANDRA_RECONNECTION_POLICY = "cassandra.reconnectionPolicy";
+ public static final String CASSANDRA_RETRY_POLICY = "cassandra.retryPolicy";
+ public static final String CASSANDRA_USER = "cassandra.user";
+ public static final String CASSANDRA_PASSWORD = "cassandra.password";
+ public static final String CASSANDRA_CONNECT_TIMEOUT_MILLIS = "cassandra.connectTimeoutMillis";
+ public static final String CASSANDRA_READ_TIMEOUT_MILLIS = "cassandra.readTimeoutMillis";
+ public static final String CASSANDRA_SSL_ENABLED = "cassandra.sslEnabled";
+ public static final String CASSANDRA_CONTACT_POINTS = "cassandra.contactPoints";
private final Logger log = LoggerFactory.getLogger(CassandraConfiguration.class);
@Inject
@@ -42,121 +73,687 @@ public class CassandraConfiguration {
@PreDestroy
public void destroy() {
log.info("Closing Hector connection pool");
- myCluster.getConnectionManager().shutdown();
- HFactory.shutdownCluster(myCluster);
}
- @Bean
- public Keyspace keyspaceOperator() {
- log.info("Configuring Cassandra keyspace");
- String cassandraHost = env.getProperty("cassandra.host");
- String cassandraClusterName = env.getProperty("cassandra.clusterName");
- String cassandraKeyspace = env.getProperty("cassandra.keyspace");
-
- CassandraHostConfigurator cassandraHostConfigurator = new CassandraHostConfigurator(cassandraHost);
- cassandraHostConfigurator.setMaxActive(100);
- if (env.acceptsProfiles(Constants.SPRING_PROFILE_METRICS)) {
- log.debug("Cassandra Metrics monitoring enabled");
- HOpTimer hOpTimer = new MetricsOpTimer(cassandraClusterName);
- cassandraHostConfigurator.setOpTimer(hOpTimer);
- }
- ThriftCluster cluster = new ThriftCluster(cassandraClusterName, cassandraHostConfigurator);
- this.myCluster = cluster; // Keep a pointer to the cluster, as Hector is buggy and can't find it again...
- ConfigurableConsistencyLevel consistencyLevelPolicy = new ConfigurableConsistencyLevel();
- consistencyLevelPolicy.setDefaultReadConsistencyLevel(HConsistencyLevel.ONE);
-
- KeyspaceDefinition keyspaceDef = cluster.describeKeyspace(cassandraKeyspace);
- if (keyspaceDef == null) {
- log.warn("Keyspace \" {} \" does not exist, creating it!", cassandraKeyspace);
- keyspaceDef = new ThriftKsDef(cassandraKeyspace);
- cluster.addKeyspace(keyspaceDef, true);
-
- addColumnFamily(cluster, ColumnFamilyKeys.USER_CF, 0);
- addColumnFamily(cluster, ColumnFamilyKeys.FRIENDS_CF, 0);
- addColumnFamily(cluster, ColumnFamilyKeys.FOLLOWERS_CF, 0);
- addColumnFamily(cluster, ColumnFamilyKeys.STATUS_CF, 0);
- addColumnFamily(cluster, ColumnFamilyKeys.DOMAIN_CF, 0);
- addColumnFamily(cluster, ColumnFamilyKeys.REGISTRATION_CF, 0);
- addColumnFamily(cluster, ColumnFamilyKeys.RSS_CF, 0);
- addColumnFamily(cluster, ColumnFamilyKeys.MAILDIGEST_CF, 0);
- addColumnFamily(cluster, ColumnFamilyKeys.SHARES_CF, 0);
- addColumnFamily(cluster, ColumnFamilyKeys.DISCUSSION_CF, 0);
- addColumnFamily(cluster, ColumnFamilyKeys.USER_TAGS_CF, 0);
- addColumnFamily(cluster, ColumnFamilyKeys.TAG_FOLLOWERS_CF, 0);
- addColumnFamily(cluster, ColumnFamilyKeys.GROUP_MEMBERS_CF, 0);
- addColumnFamily(cluster, ColumnFamilyKeys.USER_GROUPS_CF, 0);
- addColumnFamily(cluster, ColumnFamilyKeys.GROUP_CF, 0);
- addColumnFamily(cluster, ColumnFamilyKeys.GROUP_DETAILS_CF, 0);
- addColumnFamily(cluster, ColumnFamilyKeys.ATTACHMENT_CF, 0);
- addColumnFamily(cluster, ColumnFamilyKeys.AVATAR_CF, 0);
- addColumnFamily(cluster, ColumnFamilyKeys.DOMAIN_CONFIGURATION_CF, 0);
- addColumnFamily(cluster, ColumnFamilyKeys.TATAMIBOT_CONFIGURATION_CF, 0);
- addColumnFamily(cluster, ColumnFamilyKeys.APPLE_DEVICE_CF, 0);
-
- addColumnFamilySortedbyUUID(cluster, ColumnFamilyKeys.TIMELINE_CF, 0);
- addColumnFamilySortedbyUUID(cluster, ColumnFamilyKeys.TIMELINE_SHARES_CF, 0);
- addColumnFamilySortedbyUUID(cluster, ColumnFamilyKeys.MENTIONLINE_CF, 0);
- addColumnFamilySortedbyUUID(cluster, ColumnFamilyKeys.USERLINE_CF, 0);
- addColumnFamilySortedbyUUID(cluster, ColumnFamilyKeys.USERLINE_SHARES_CF, 0);
- addColumnFamilySortedbyUUID(cluster, ColumnFamilyKeys.FAVLINE_CF, 0);
- addColumnFamilySortedbyUUID(cluster, ColumnFamilyKeys.TAGLINE_CF, 0);
- addColumnFamilySortedbyUUID(cluster, ColumnFamilyKeys.TRENDS_CF, 0);
- addColumnFamilySortedbyUUID(cluster, ColumnFamilyKeys.USER_TRENDS_CF, 0);
- addColumnFamilySortedbyUUID(cluster, ColumnFamilyKeys.GROUPLINE_CF, 0);
- addColumnFamilySortedbyUUID(cluster, ColumnFamilyKeys.USER_ATTACHMENT_CF, 0);
- addColumnFamilySortedbyUUID(cluster, ColumnFamilyKeys.STATUS_ATTACHMENT_CF, 0);
- addColumnFamilySortedbyUUID(cluster, ColumnFamilyKeys.DOMAINLINE_CF, 0);
- addColumnFamilySortedbyUUID(cluster, ColumnFamilyKeys.DOMAIN_TATAMIBOT_CF, 0);
-
- addColumnFamilyCounter(cluster, ColumnFamilyKeys.COUNTER_CF, 0);
- addColumnFamilyCounter(cluster, ColumnFamilyKeys.TAG_COUNTER_CF, 0);
- addColumnFamilyCounter(cluster, ColumnFamilyKeys.GROUP_COUNTER_CF, 0);
- addColumnFamilyCounter(cluster, ColumnFamilyKeys.DAYLINE_CF, 0);
-
- //Tatami Bot CF
- addColumnFamily(cluster, ColumnFamilyKeys.TATAMIBOT_DUPLICATE_CF, 0);
- }
- return HFactory.createKeyspace(cassandraKeyspace, cluster, consistencyLevelPolicy);
+
+
+
+
+ @Inject
+ BeanFactory beanFactory;
+
+
+
+ /**
+ * Parse the load balancing policy.
+ */
+ public LoadBalancingPolicy parseLbPolicy(String loadBalancingPolicyString) throws InstantiationException,
+ IllegalAccessException, ClassNotFoundException, NoSuchMethodException, SecurityException,
+ IllegalArgumentException, InvocationTargetException {
+ String lb_regex = "([a-zA-Z]*Policy)(\\()(.*)(\\))";
+ Pattern lb_pattern = Pattern.compile(lb_regex);
+ if (!loadBalancingPolicyString.contains("(")) {
+ loadBalancingPolicyString += "()";
+ }
+ Matcher lb_matcher = lb_pattern.matcher(loadBalancingPolicyString);
+
+ if (lb_matcher.matches()) {
+ if (lb_matcher.groupCount() > 0) {
+ // Primary LB policy has been specified
+ String primaryLoadBalancingPolicy = lb_matcher.group(1);
+ String loadBalancingPolicyParams = lb_matcher.group(3);
+ return getLbPolicy(primaryLoadBalancingPolicy, loadBalancingPolicyParams);
+ }
+ }
+ return null;
}
- @Bean
- public EntityManagerImpl entityManager(Keyspace keyspace) {
- String[] packagesToScan = {"fr.ippon.tatami.domain", "fr.ippon.tatami.bot.config"};
- return new EntityManagerImpl(keyspace, packagesToScan);
+ /**
+ * Get the load balancing policy.
+ */
+ public LoadBalancingPolicy getLbPolicy(String lbString, String parameters) throws ClassNotFoundException,
+ NoSuchMethodException, SecurityException, InstantiationException, IllegalAccessException,
+ IllegalArgumentException, InvocationTargetException {
+ LoadBalancingPolicy policy = null;
+ if (!lbString.contains(".")) {
+ lbString = "com.datastax.driver.core.policies." + lbString;
+ }
+
+ if (parameters.length() > 0) {
+ // Child policy or parameters have been specified
+ String paramsRegex = "([^,]+\\(.+?\\))|([^,]+)";
+ Pattern param_pattern = Pattern.compile(paramsRegex);
+ Matcher lb_matcher = param_pattern.matcher(parameters);
+
+ ArrayList