JAMES-2096 Bind Cassandra migration webadmin endpoints in guice
Project: http://git-wip-us.apache.org/repos/asf/james-project/repo Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/fb284d31 Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/fb284d31 Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/fb284d31 Branch: refs/heads/master Commit: fb284d311d91f2331c585201b27bc03760523488 Parents: f495121 Author: Antoine Duprat <[email protected]> Authored: Tue Jul 11 15:33:45 2017 +0200 Committer: benwa <[email protected]> Committed: Tue Jul 25 17:51:01 2017 +0700 ---------------------------------------------------------------------- .../versions/CassandraSchemaVersionManager.java | 2 +- server/container/guice/cassandra-guice/pom.xml | 4 + .../apache/james/CassandraJamesServerMain.java | 4 +- server/container/guice/pom.xml | 6 + .../guice/protocols/webadmin-cassandra/pom.xml | 202 +++++++++++++++++++ .../modules/server/CassandraRoutesModule.java | 57 ++++++ 6 files changed, 273 insertions(+), 2 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/james-project/blob/fb284d31/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/versions/CassandraSchemaVersionManager.java ---------------------------------------------------------------------- diff --git a/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/versions/CassandraSchemaVersionManager.java b/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/versions/CassandraSchemaVersionManager.java index 2a9266e..45fa2a2 100644 --- a/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/versions/CassandraSchemaVersionManager.java +++ b/backends-common/cassandra/src/main/java/org/apache/james/backends/cassandra/versions/CassandraSchemaVersionManager.java @@ -34,7 +34,7 @@ import com.google.common.base.Preconditions; public class CassandraSchemaVersionManager { public static final int MIN_VERSION = 1; - public static final int MAX_VERSION = 1; + public static final int MAX_VERSION = 2; public static final int DEFAULT_VERSION = 1; private static final Logger LOGGER = LoggerFactory.getLogger(CassandraSchemaVersionManager.class); http://git-wip-us.apache.org/repos/asf/james-project/blob/fb284d31/server/container/guice/cassandra-guice/pom.xml ---------------------------------------------------------------------- diff --git a/server/container/guice/cassandra-guice/pom.xml b/server/container/guice/cassandra-guice/pom.xml index 47e9259..3238500 100644 --- a/server/container/guice/cassandra-guice/pom.xml +++ b/server/container/guice/cassandra-guice/pom.xml @@ -299,6 +299,10 @@ </dependency> <dependency> <groupId>org.apache.james</groupId> + <artifactId>james-server-guice-webadmin-cassandra</artifactId> + </dependency> + <dependency> + <groupId>org.apache.james</groupId> <artifactId>james-server-guice-webadmin-data</artifactId> </dependency> <dependency> http://git-wip-us.apache.org/repos/asf/james-project/blob/fb284d31/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java ---------------------------------------------------------------------- diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java index e804de1..c04664b 100644 --- a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java +++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/CassandraJamesServerMain.java @@ -37,6 +37,7 @@ import org.apache.james.modules.protocols.POP3ServerModule; import org.apache.james.modules.protocols.ProtocolHandlerModule; import org.apache.james.modules.protocols.SMTPServerModule; import org.apache.james.modules.server.ActiveMQQueueModule; +import org.apache.james.modules.server.CassandraRoutesModule; import org.apache.james.modules.server.DataRoutesModules; import org.apache.james.modules.server.ESMetricReporterModule; import org.apache.james.modules.server.JMXServerModule; @@ -57,7 +58,8 @@ public class CassandraJamesServerMain { new ManageSieveServerModule(), new WebAdminServerModule(), new DataRoutesModules(), - new MailboxRoutesModule()); + new MailboxRoutesModule(), + new CassandraRoutesModule()); public static final Module cassandraServerModule = Modules.combine( new JMAPServerModule(), http://git-wip-us.apache.org/repos/asf/james-project/blob/fb284d31/server/container/guice/pom.xml ---------------------------------------------------------------------- diff --git a/server/container/guice/pom.xml b/server/container/guice/pom.xml index 5d1d6ca..381a2d6 100644 --- a/server/container/guice/pom.xml +++ b/server/container/guice/pom.xml @@ -97,6 +97,11 @@ </dependency> <dependency> <groupId>${project.groupId}</groupId> + <artifactId>james-server-guice-webadmin-cassandra</artifactId> + <version>${project.version}</version> + </dependency> + <dependency> + <groupId>${project.groupId}</groupId> <artifactId>james-server-guice-webadmin-data</artifactId> <version>${project.version}</version> </dependency> @@ -134,6 +139,7 @@ <module>protocols/pop</module> <module>protocols/smtp</module> <module>protocols/webadmin</module> + <module>protocols/webadmin-cassandra</module> <module>protocols/webadmin-mailbox</module> <module>protocols/webadmin-data</module> </modules> http://git-wip-us.apache.org/repos/asf/james-project/blob/fb284d31/server/container/guice/protocols/webadmin-cassandra/pom.xml ---------------------------------------------------------------------- diff --git a/server/container/guice/protocols/webadmin-cassandra/pom.xml b/server/container/guice/protocols/webadmin-cassandra/pom.xml new file mode 100644 index 0000000..ef372af --- /dev/null +++ b/server/container/guice/protocols/webadmin-cassandra/pom.xml @@ -0,0 +1,202 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + Licensed to the Apache Software Foundation (ASF) under one + or more contributor license agreements. See the NOTICE file + distributed with this work for additional information + regarding copyright ownership. The ASF licenses this file + to you under the Apache License, Version 2.0 (the + "License"); you may not use this file except in compliance + with the License. You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, + software distributed under the License is distributed on an + "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + KIND, either express or implied. See the License for the + specific language governing permissions and limitations + under the License. +--> +<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + <parent> + <artifactId>james-server-guice</artifactId> + <groupId>org.apache.james</groupId> + <version>3.1.0-SNAPSHOT</version> + <relativePath>../../pom.xml</relativePath> + </parent> + <modelVersion>4.0.0</modelVersion> + + <artifactId>james-server-guice-webadmin-cassandra</artifactId> + + <name>Apache James :: Server :: Guice :: Webadmin :: Cassandra</name> + <description>Webadmin cassandra modules for Guice implementation of James server</description> + + <build> + <plugins> + <plugin> + <groupId>org.apache.felix</groupId> + <artifactId>maven-bundle-plugin</artifactId> + <extensions>true</extensions> + </plugin> + </plugins> + </build> + + <profiles> + <profile> + <id>disable-build-for-older-jdk</id> + <activation> + <jdk>(,1.8)</jdk> + </activation> + <build> + <plugins> + <plugin> + <artifactId>maven-jar-plugin</artifactId> + <executions> + <execution> + <id>default-jar</id> + <phase>none</phase> + </execution> + <execution> + <id>jar</id> + <phase>none</phase> + </execution> + <execution> + <id>test-jar</id> + <phase>none</phase> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-compiler-plugin</artifactId> + <executions> + <execution> + <id>default-compile</id> + <phase>none</phase> + </execution> + <execution> + <id>default-testCompile</id> + <phase>none</phase> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-surefire-plugin</artifactId> + <executions> + <execution> + <id>default-test</id> + <phase>none</phase> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-source-plugin</artifactId> + <executions> + <execution> + <id>attach-sources</id> + <phase>none</phase> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-install-plugin</artifactId> + <executions> + <execution> + <id>default-install</id> + <phase>none</phase> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-resources-plugin</artifactId> + <executions> + <execution> + <id>default-resources</id> + <phase>none</phase> + </execution> + <execution> + <id>default-testResources</id> + <phase>none</phase> + </execution> + </executions> + </plugin> + <plugin> + <artifactId>maven-site-plugin</artifactId> + <executions> + <execution> + <id>attach-descriptor</id> + <phase>none</phase> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + <profile> + <id>build-for-jdk-8</id> + <activation> + <jdk>[1.8,)</jdk> + </activation> + <build> + <plugins> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-compiler-plugin</artifactId> + <configuration> + <source>1.8</source> + <target>1.8</target> + </configuration> + </plugin> + </plugins> + </build> + <dependencies> + <dependency> + <groupId>${project.groupId}</groupId> + <artifactId>james-server-guice-configuration</artifactId> + </dependency> + <dependency> + <groupId>org.apache.james</groupId> + <artifactId>james-server-webadmin-cassandra</artifactId> + </dependency> + <dependency> + <groupId>com.google.inject</groupId> + <artifactId>guice</artifactId> + </dependency> + <dependency> + <groupId>com.google.inject.extensions</groupId> + <artifactId>guice-multibindings</artifactId> + </dependency> + </dependencies> + </profile> + <profile> + <id>animal-sniffer-java-8</id> + <activation> + <jdk>[1.8,)</jdk> + </activation> + <build> + <plugins> + <plugin> + <groupId>org.codehaus.mojo</groupId> + <artifactId>animal-sniffer-maven-plugin</artifactId> + <configuration> + <signature> + <groupId>org.codehaus.mojo.signature</groupId> + <artifactId>java18</artifactId> + <version>1.0</version> + </signature> + </configuration> + <executions> + <execution> + <id>check_java_8</id> + <phase>test</phase> + <goals> + <goal>check</goal> + </goals> + </execution> + </executions> + </plugin> + </plugins> + </build> + </profile> + </profiles> + +</project> http://git-wip-us.apache.org/repos/asf/james-project/blob/fb284d31/server/container/guice/protocols/webadmin-cassandra/src/main/java/org/apache/james/modules/server/CassandraRoutesModule.java ---------------------------------------------------------------------- diff --git a/server/container/guice/protocols/webadmin-cassandra/src/main/java/org/apache/james/modules/server/CassandraRoutesModule.java b/server/container/guice/protocols/webadmin-cassandra/src/main/java/org/apache/james/modules/server/CassandraRoutesModule.java new file mode 100644 index 0000000..8e8f940 --- /dev/null +++ b/server/container/guice/protocols/webadmin-cassandra/src/main/java/org/apache/james/modules/server/CassandraRoutesModule.java @@ -0,0 +1,57 @@ +/**************************************************************** + * Licensed to the Apache Software Foundation (ASF) under one * + * or more contributor license agreements. See the NOTICE file * + * distributed with this work for additional information * + * regarding copyright ownership. The ASF licenses this file * + * to you under the Apache License, Version 2.0 (the * + * "License"); you may not use this file except in compliance * + * with the License. You may obtain a copy of the License at * + * * + * http://www.apache.org/licenses/LICENSE-2.0 * + * * + * Unless required by applicable law or agreed to in writing, * + * software distributed under the License is distributed on an * + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY * + * KIND, either express or implied. See the License for the * + * specific language governing permissions and limitations * + * under the License. * + ****************************************************************/ + +package org.apache.james.modules.server; + +import org.apache.james.backends.cassandra.versions.CassandraSchemaVersionManager; +import org.apache.james.mailbox.cassandra.mail.migration.Migration; +import org.apache.james.mailbox.cassandra.mail.migration.V1ToV2Migration; +import org.apache.james.webadmin.Routes; +import org.apache.james.webadmin.routes.CassandraMigrationRoutes; +import org.apache.james.webadmin.service.CassandraMigrationService; + +import com.google.inject.AbstractModule; +import com.google.inject.Scopes; +import com.google.inject.multibindings.MapBinder; +import com.google.inject.multibindings.Multibinder; +import com.google.inject.name.Names; + +public class CassandraRoutesModule extends AbstractModule { + + private static final int FROM_V1_TO_V2 = 1; + + @Override + protected void configure() { + bind(CassandraRoutesModule.class).in(Scopes.SINGLETON); + bind(CassandraMigrationService.class).in(Scopes.SINGLETON); + + Multibinder<Migration> migrationMultibinder = Multibinder.newSetBinder(binder(), Migration.class); + migrationMultibinder.addBinding().to(V1ToV2Migration.class); + + Multibinder<Routes> routesMultibinder = Multibinder.newSetBinder(binder(), Routes.class); + routesMultibinder.addBinding().to(CassandraMigrationRoutes.class); + + MapBinder<Integer, Migration> allMigrationClazzBinder = MapBinder.newMapBinder(binder(), Integer.class, Migration.class); + allMigrationClazzBinder.addBinding(FROM_V1_TO_V2).to(V1ToV2Migration.class); + + bindConstant() + .annotatedWith(Names.named(CassandraMigrationService.LATEST_VERSION)) + .to(CassandraSchemaVersionManager.MAX_VERSION); + } +} --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
