james-server-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From btell...@apache.org
Subject [7/9] james-project git commit: JAMES-1617 Guice should take UsersRepository configuration into account
Date Thu, 07 Apr 2016 03:10:17 GMT
JAMES-1617 Guice should take UsersRepository configuration into account


Project: http://git-wip-us.apache.org/repos/asf/james-project/repo
Commit: http://git-wip-us.apache.org/repos/asf/james-project/commit/f054e2c7
Tree: http://git-wip-us.apache.org/repos/asf/james-project/tree/f054e2c7
Diff: http://git-wip-us.apache.org/repos/asf/james-project/diff/f054e2c7

Branch: refs/heads/master
Commit: f054e2c782925d416f00c33a467840d02a34ce98
Parents: 777d101
Author: Benoit Tellier <btellier@linagora.com>
Authored: Tue Mar 15 11:25:36 2016 +0700
Committer: Benoit Tellier <btellier@linagora.com>
Committed: Thu Apr 7 09:13:35 2016 +0700

----------------------------------------------------------------------
 .../src/test/resources/usersrepository.xml      | 25 ++++++++++++++++
 .../data/CassandraUsersRepositoryModule.java    | 31 ++++++++++++++++++++
 2 files changed, 56 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/james-project/blob/f054e2c7/server/container/cassandra-guice/src/test/resources/usersrepository.xml
----------------------------------------------------------------------
diff --git a/server/container/cassandra-guice/src/test/resources/usersrepository.xml b/server/container/cassandra-guice/src/test/resources/usersrepository.xml
new file mode 100644
index 0000000..85046b3
--- /dev/null
+++ b/server/container/cassandra-guice/src/test/resources/usersrepository.xml
@@ -0,0 +1,25 @@
+<?xml version="1.0"?>
+<!--
+  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.                                           
+ -->
+
+<usersrepository name="LocalUsers">
+    <algorithm>MD5</algorithm>
+    <enableVirtualHosting>true</enableVirtualHosting>    
+</usersrepository>
+

http://git-wip-us.apache.org/repos/asf/james-project/blob/f054e2c7/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraUsersRepositoryModule.java
----------------------------------------------------------------------
diff --git a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraUsersRepositoryModule.java
b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraUsersRepositoryModule.java
index a776626..dd1f881 100644
--- a/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraUsersRepositoryModule.java
+++ b/server/container/guice/cassandra-guice/src/main/java/org/apache/james/modules/data/CassandraUsersRepositoryModule.java
@@ -19,20 +19,51 @@
 package org.apache.james.modules.data;
 
 import org.apache.james.backends.cassandra.components.CassandraModule;
+import org.apache.james.rrt.cassandra.CassandraRecipientRewriteTable;
 import org.apache.james.user.api.UsersRepository;
 import org.apache.james.user.cassandra.CassandraUsersRepository;
+import org.apache.james.utils.ConfigurationPerformer;
+import org.apache.james.utils.ConfigurationProvider;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 import com.google.inject.AbstractModule;
+import com.google.inject.Inject;
+import com.google.inject.Scopes;
+import com.google.inject.Singleton;
 import com.google.inject.multibindings.Multibinder;
 
 public class CassandraUsersRepositoryModule extends AbstractModule {
 
+    private static final Logger LOGGER = LoggerFactory.getLogger(CassandraUsersRepositoryModule.class);
+
     @Override
     public void configure() {
+        bind(CassandraUsersRepository.class).in(Scopes.SINGLETON);
         bind(UsersRepository.class).to(CassandraUsersRepository.class);
         Multibinder<CassandraModule> cassandraDataDefinitions = Multibinder.newSetBinder(binder(),
CassandraModule.class);
         cassandraDataDefinitions.addBinding().to(org.apache.james.user.cassandra.CassandraUsersRepositoryModule.class);
 
+        Multibinder.newSetBinder(binder(), ConfigurationPerformer.class).addBinding().to(CassandraUsersRepositoryConfigurationPerformer.class);
+    }
+
+    @Singleton
+    public static class CassandraUsersRepositoryConfigurationPerformer implements ConfigurationPerformer
{
+
+        private final ConfigurationProvider configurationProvider;
+        private final CassandraUsersRepository usersRepository;
+
+        @Inject
+        public CassandraUsersRepositoryConfigurationPerformer(ConfigurationProvider configurationProvider,
CassandraUsersRepository usersRepository) {
+            this.configurationProvider = configurationProvider;
+            this.usersRepository = usersRepository;
+        }
+
+        @Override
+        public void initModule() throws Exception {
+            usersRepository.setLog(LOGGER);
+            usersRepository.configure(configurationProvider.getConfiguration("usersrepository"));
+        }
     }
 
 }


---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org


Mime
View raw message