You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-dev@james.apache.org by no...@apache.org on 2009/12/02 15:41:54 UTC

svn commit: r886159 - in /james/server/trunk: ./ avalon-socket-library/src/main/java/org/apache/james/socket/ management-library/ management-library/src/main/java/org/apache/james/management/impl/ management-library/src/main/java/org/apache/james/osgi/...

Author: norman
Date: Wed Dec  2 14:41:53 2009
New Revision: 886159

URL: http://svn.apache.org/viewvc?rev=886159&view=rev
Log:
Start to work on OSGI deployment.. (this is far from complete atm)

Added:
    james/server/trunk/avalon-socket-library/src/main/java/org/apache/james/socket/SimpleConnectionManagerModule.java
    james/server/trunk/management-library/src/main/java/org/apache/james/management/impl/BayesianAnalyzerManagementModule.java
    james/server/trunk/management-library/src/main/java/org/apache/james/management/impl/DomainListManagementModule.java
    james/server/trunk/management-library/src/main/java/org/apache/james/management/impl/ProcessorManagementModule.java
    james/server/trunk/management-library/src/main/java/org/apache/james/management/impl/SpoolManagementModule.java
    james/server/trunk/management-library/src/main/java/org/apache/james/osgi/
    james/server/trunk/management-library/src/main/java/org/apache/james/osgi/ManagementLibraryActivator.java
    james/server/trunk/management-library/src/main/java/org/apache/james/osgi/OSGIBayesianAnalyzerManagementModule.java
    james/server/trunk/management-library/src/main/java/org/apache/james/osgi/OSGIDomainListManagementModule.java
    james/server/trunk/management-library/src/main/java/org/apache/james/osgi/OSGIProcessorManagementModule.java
    james/server/trunk/management-library/src/main/java/org/apache/james/osgi/OSGISpoolManagementModule.java
    james/server/trunk/osgi-deployment/
    james/server/trunk/osgi-deployment/src/
    james/server/trunk/osgi-deployment/src/main/
    james/server/trunk/osgi-deployment/src/main/java/
    james/server/trunk/osgi-deployment/src/main/java/org/
    james/server/trunk/osgi-deployment/src/main/java/org/apache/
    james/server/trunk/osgi-deployment/src/main/java/org/apache/james/
    james/server/trunk/osgi-deployment/src/main/java/org/apache/james/osgi/
    james/server/trunk/osgi-deployment/src/main/java/org/apache/james/osgi/ConfigurationProvider.java
    james/server/trunk/user-library/src/main/java/org/apache/james/impl/jamesuser/LocalJamesUsersRepositoryModule.java
    james/server/trunk/user-library/src/main/java/org/apache/james/impl/user/LocalUsersRepositoryModule.java
    james/server/trunk/user-library/src/main/java/org/apache/james/impl/user/UserManagementModule.java
    james/server/trunk/user-library/src/main/java/org/apache/james/osgi/
    james/server/trunk/user-library/src/main/java/org/apache/james/osgi/OSGILocalJamesUsersRepositoryModule.java
    james/server/trunk/user-library/src/main/java/org/apache/james/osgi/OSGILocalUsersRepositoryModule.java
    james/server/trunk/user-library/src/main/java/org/apache/james/osgi/OSGIUserManagementModule.java
    james/server/trunk/user-library/src/main/java/org/apache/james/osgi/UsersLibraryActivator.java
Modified:
    james/server/trunk/avalon-socket-library/src/main/java/org/apache/james/socket/AvalonSimpleConnectionManager.java
    james/server/trunk/management-library/pom.xml
    james/server/trunk/management-library/src/main/java/org/apache/james/management/impl/AvalonBayesianAnalyzerManagement.java
    james/server/trunk/management-library/src/main/java/org/apache/james/management/impl/AvalonDomainListManagement.java
    james/server/trunk/management-library/src/main/java/org/apache/james/management/impl/AvalonProcessorManagement.java
    james/server/trunk/management-library/src/main/java/org/apache/james/management/impl/AvalonSpoolManagement.java
    james/server/trunk/pom.xml
    james/server/trunk/stage/pom.xml
    james/server/trunk/user-library/pom.xml
    james/server/trunk/user-library/src/main/java/org/apache/james/impl/jamesuser/AvalonLocalJamesUsersRepository.java
    james/server/trunk/user-library/src/main/java/org/apache/james/impl/user/AvalonLocalUsersRepository.java
    james/server/trunk/user-library/src/main/java/org/apache/james/impl/user/AvalonUserManagement.java

Modified: james/server/trunk/avalon-socket-library/src/main/java/org/apache/james/socket/AvalonSimpleConnectionManager.java
URL: http://svn.apache.org/viewvc/james/server/trunk/avalon-socket-library/src/main/java/org/apache/james/socket/AvalonSimpleConnectionManager.java?rev=886159&r1=886158&r2=886159&view=diff
==============================================================================
--- james/server/trunk/avalon-socket-library/src/main/java/org/apache/james/socket/AvalonSimpleConnectionManager.java (original)
+++ james/server/trunk/avalon-socket-library/src/main/java/org/apache/james/socket/AvalonSimpleConnectionManager.java Wed Dec  2 14:41:53 2009
@@ -36,11 +36,9 @@
 import org.apache.excalibur.thread.ThreadPool;
 import org.apache.james.bridge.GuiceInjected;
 import org.apache.james.util.ConfigurationAdapter;
-import org.guiceyfruit.jsr250.Jsr250Module;
 
 import com.google.inject.AbstractModule;
 import com.google.inject.Guice;
-import com.google.inject.name.Names;
 
 public class AvalonSimpleConnectionManager  implements LogEnabled, Initializable, GuiceInjected, Serviceable, Configurable, JamesConnectionManager {
 
@@ -120,13 +118,13 @@
 
 
     public void initialize() throws Exception {
-        manager = Guice.createInjector(new Jsr250Module() , new AbstractModule() {
+        manager = Guice.createInjector(new SimpleConnectionManagerModule() , new AbstractModule() {
 
             @Override
             protected void configure() {
-                bind(ThreadManager.class).annotatedWith(Names.named("org.apache.avalon.cornerstone.services.threads.ThreadManager")).toInstance(threadManager);
-                bind(org.apache.commons.configuration.HierarchicalConfiguration.class).annotatedWith(Names.named("org.apache.commons.configuration.Configuration")).toInstance(config);
-                bind(Log.class).annotatedWith(Names.named("org.apache.commons.logging.Log")).toInstance(logger);
+                bind(ThreadManager.class).toInstance(threadManager);
+                bind(org.apache.commons.configuration.HierarchicalConfiguration.class).toInstance(config);
+                bind(Log.class).toInstance(logger);
             }
             
         }).getInstance(SimpleConnectionManager.class);

Added: james/server/trunk/avalon-socket-library/src/main/java/org/apache/james/socket/SimpleConnectionManagerModule.java
URL: http://svn.apache.org/viewvc/james/server/trunk/avalon-socket-library/src/main/java/org/apache/james/socket/SimpleConnectionManagerModule.java?rev=886159&view=auto
==============================================================================
--- james/server/trunk/avalon-socket-library/src/main/java/org/apache/james/socket/SimpleConnectionManagerModule.java (added)
+++ james/server/trunk/avalon-socket-library/src/main/java/org/apache/james/socket/SimpleConnectionManagerModule.java Wed Dec  2 14:41:53 2009
@@ -0,0 +1,37 @@
+/****************************************************************
+ * 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.socket;
+
+import org.apache.avalon.cornerstone.services.threads.ThreadManager;
+import org.apache.commons.logging.Log;
+import org.guiceyfruit.jsr250.Jsr250Module;
+
+import com.google.inject.name.Names;
+
+public class SimpleConnectionManagerModule extends Jsr250Module{
+
+	@Override
+	protected void configure() {
+		super.configure();
+		  bind(ThreadManager.class).annotatedWith(Names.named("org.apache.avalon.cornerstone.services.threads.ThreadManager"));
+          bind(org.apache.commons.configuration.HierarchicalConfiguration.class).annotatedWith(Names.named("org.apache.commons.configuration.Configuration"));
+          bind(Log.class).annotatedWith(Names.named("org.apache.commons.logging.Log"));
+	}
+
+}

Modified: james/server/trunk/management-library/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/management-library/pom.xml?rev=886159&r1=886158&r2=886159&view=diff
==============================================================================
--- james/server/trunk/management-library/pom.xml (original)
+++ james/server/trunk/management-library/pom.xml Wed Dec  2 14:41:53 2009
@@ -27,6 +27,40 @@
   <groupId>org.apache.james</groupId>
   <artifactId>james-server-management-library</artifactId>
   <name>Apache JAMES Server Management Library</name>
+   
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-jar-plugin</artifactId>
+        <configuration>
+          <archive>  
+            <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
+          </archive> 
+        </configuration>
+      </plugin>  
+      <plugin>    
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>bundle-manifest</id>
+            <phase>process-classes</phase>
+            <goals>    
+              <goal>manifest</goal>
+            </goals>   
+          </execution>
+        </executions>
+        <configuration>
+          <instructions>
+            <Export-Package>org.apache.james.management,org.apache.james.management.*</Export-Package>
+            <Private-Package>org.apache.james.*</Private-Package>
+            <Bundle-Activator>org.apache.james.osgi.ManagementLibraryActivator</Bundle-Activator>
+          </instructions>
+        </configuration>
+      </plugin>  
+    </plugins>
+  </build>
+  
   <dependencies>
   
     <dependency>
@@ -117,5 +151,13 @@
       <artifactId>spring-aopalliance</artifactId>
       <scope>runtime</scope>
     </dependency>
+     <dependency>
+      <groupId>org.ops4j</groupId>
+      <artifactId>peaberry</artifactId>
+    </dependency> 
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi</artifactId>
+    </dependency> 
   </dependencies>
 </project>

Modified: james/server/trunk/management-library/src/main/java/org/apache/james/management/impl/AvalonBayesianAnalyzerManagement.java
URL: http://svn.apache.org/viewvc/james/server/trunk/management-library/src/main/java/org/apache/james/management/impl/AvalonBayesianAnalyzerManagement.java?rev=886159&r1=886158&r2=886159&view=diff
==============================================================================
--- james/server/trunk/management-library/src/main/java/org/apache/james/management/impl/AvalonBayesianAnalyzerManagement.java (original)
+++ james/server/trunk/management-library/src/main/java/org/apache/james/management/impl/AvalonBayesianAnalyzerManagement.java Wed Dec  2 14:41:53 2009
@@ -39,11 +39,8 @@
 import org.apache.james.util.ConfigurationAdapter;
 import org.apache.james.bridge.GuiceInjected;
 
-import org.guiceyfruit.jsr250.Jsr250Module;
-
 import com.google.inject.AbstractModule;
 import com.google.inject.Guice;
-import com.google.inject.name.Names;
 
 public class AvalonBayesianAnalyzerManagement implements GuiceInjected, BayesianAnalyzerManagementMBean, BayesianAnalyzerManagementService, Serviceable, Initializable, Configurable, LogEnabled{
 
@@ -59,14 +56,14 @@
     }
 
     public void initialize() throws Exception {
-        mgmt = Guice.createInjector(new Jsr250Module(), new AbstractModule() {
+        mgmt = Guice.createInjector( new BayesianAnalyzerManagementModule(), new AbstractModule() {
 
             @Override
             protected void configure() {
-                bind(org.apache.commons.configuration.HierarchicalConfiguration.class).annotatedWith(Names.named("org.apache.commons.configuration.Configuration")).toInstance(config);
-                bind(Log.class).annotatedWith(Names.named("org.apache.commons.logging.Log")).toInstance(logger);
-                bind(FileSystem.class).annotatedWith(Names.named("org.apache.james.services.FileSystem")).toInstance(fs);     
-                bind(DataSourceSelector.class).annotatedWith(Names.named("org.apache.avalon.cornerstone.services.datasources.DataSourceSelector")).toInstance(selector);
+                bind(org.apache.commons.configuration.HierarchicalConfiguration.class).toInstance(config);
+                bind(Log.class).toInstance(logger);
+                bind(FileSystem.class).toInstance(fs);     
+                bind(DataSourceSelector.class).toInstance(selector);
 
             }
             

Modified: james/server/trunk/management-library/src/main/java/org/apache/james/management/impl/AvalonDomainListManagement.java
URL: http://svn.apache.org/viewvc/james/server/trunk/management-library/src/main/java/org/apache/james/management/impl/AvalonDomainListManagement.java?rev=886159&r1=886158&r2=886159&view=diff
==============================================================================
--- james/server/trunk/management-library/src/main/java/org/apache/james/management/impl/AvalonDomainListManagement.java (original)
+++ james/server/trunk/management-library/src/main/java/org/apache/james/management/impl/AvalonDomainListManagement.java Wed Dec  2 14:41:53 2009
@@ -23,26 +23,17 @@
 import java.util.List;
 
 import org.apache.avalon.framework.activity.Initializable;
-import org.apache.avalon.framework.configuration.Configurable;
-import org.apache.avalon.framework.configuration.Configuration;
-import org.apache.avalon.framework.configuration.ConfigurationException;
-import org.apache.avalon.framework.logger.LogEnabled;
-import org.apache.avalon.framework.logger.Logger;
 import org.apache.avalon.framework.service.ServiceException;
 import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.avalon.framework.service.Serviceable;
 import org.apache.james.api.domainlist.DomainList;
+import org.apache.james.bridge.GuiceInjected;
 import org.apache.james.management.DomainListManagementException;
 import org.apache.james.management.DomainListManagementMBean;
 import org.apache.james.management.DomainListManagementService;
-import org.apache.james.bridge.GuiceInjected;
-
-import org.guiceyfruit.jsr250.Jsr250Module;
 
 import com.google.inject.AbstractModule;
 import com.google.inject.Guice;
-import com.google.inject.name.Named;
-import com.google.inject.name.Names;
 
 public class AvalonDomainListManagement implements GuiceInjected, DomainListManagementService,DomainListManagementMBean, Serviceable, Initializable {
     private DomainList dList;
@@ -52,11 +43,11 @@
     }
 
     public void initialize() throws Exception {
-        mgmt = Guice.createInjector(new Jsr250Module(), new AbstractModule() {
+        mgmt = Guice.createInjector(new DomainListManagementModule(), new AbstractModule() {
 
             @Override
             protected void configure() {
-                bind(DomainList.class).annotatedWith(Names.named("org.apache.james.api.domainlist.DomainList")).toInstance(dList);
+                bind(DomainList.class).toInstance(dList);
             }
             
         }).getInstance(DomainListManagement.class);

Modified: james/server/trunk/management-library/src/main/java/org/apache/james/management/impl/AvalonProcessorManagement.java
URL: http://svn.apache.org/viewvc/james/server/trunk/management-library/src/main/java/org/apache/james/management/impl/AvalonProcessorManagement.java?rev=886159&r1=886158&r2=886159&view=diff
==============================================================================
--- james/server/trunk/management-library/src/main/java/org/apache/james/management/impl/AvalonProcessorManagement.java (original)
+++ james/server/trunk/management-library/src/main/java/org/apache/james/management/impl/AvalonProcessorManagement.java Wed Dec  2 14:41:53 2009
@@ -22,16 +22,13 @@
 import org.apache.avalon.framework.service.ServiceException;
 import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.avalon.framework.service.Serviceable;
+import org.apache.james.bridge.GuiceInjected;
 import org.apache.james.management.ProcessorManagementMBean;
 import org.apache.james.management.ProcessorManagementService;
 import org.apache.james.services.SpoolManager;
-import org.apache.james.bridge.GuiceInjected;
-
-import org.guiceyfruit.jsr250.Jsr250Module;
 
 import com.google.inject.AbstractModule;
 import com.google.inject.Guice;
-import com.google.inject.name.Names;
 
 public class AvalonProcessorManagement implements GuiceInjected, Serviceable, Initializable, ProcessorManagementService, ProcessorManagementMBean {
 
@@ -44,11 +41,11 @@
     }
 
     public void initialize() throws Exception {
-        mgmt = Guice.createInjector(new Jsr250Module(), new AbstractModule() {
+        mgmt = Guice.createInjector(new ProcessorManagementModule(), new AbstractModule() {
 
             @Override
             protected void configure() {
-                bind(SpoolManager.class).annotatedWith(Names.named("org.apache.james.services.SpoolManager")).toInstance(smanager);
+                bind(SpoolManager.class).toInstance(smanager);
             }
             
         }).getInstance(ProcessorManagement.class);

Modified: james/server/trunk/management-library/src/main/java/org/apache/james/management/impl/AvalonSpoolManagement.java
URL: http://svn.apache.org/viewvc/james/server/trunk/management-library/src/main/java/org/apache/james/management/impl/AvalonSpoolManagement.java?rev=886159&r1=886158&r2=886159&view=diff
==============================================================================
--- james/server/trunk/management-library/src/main/java/org/apache/james/management/impl/AvalonSpoolManagement.java (original)
+++ james/server/trunk/management-library/src/main/java/org/apache/james/management/impl/AvalonSpoolManagement.java Wed Dec  2 14:41:53 2009
@@ -28,16 +28,14 @@
 import org.apache.avalon.framework.service.ServiceException;
 import org.apache.avalon.framework.service.ServiceManager;
 import org.apache.avalon.framework.service.Serviceable;
+import org.apache.james.bridge.GuiceInjected;
 import org.apache.james.management.SpoolFilter;
 import org.apache.james.management.SpoolManagementException;
 import org.apache.james.management.SpoolManagementMBean;
 import org.apache.james.management.SpoolManagementService;
-import org.apache.james.bridge.GuiceInjected;
-import org.guiceyfruit.jsr250.Jsr250Module;
 
 import com.google.inject.AbstractModule;
 import com.google.inject.Guice;
-import com.google.inject.name.Names;
 
 public class AvalonSpoolManagement  implements GuiceInjected, Serviceable, Initializable, SpoolManagementService, SpoolManagementMBean{
 
@@ -81,11 +79,11 @@
     }
 
     public void initialize() throws Exception {
-        mgmt = Guice.createInjector(new Jsr250Module(), new AbstractModule() {
+        mgmt = Guice.createInjector(new SpoolManagementModule(), new AbstractModule() {
 
             @Override
             protected void configure() {
-                bind(Store.class).annotatedWith(Names.named("org.apache.avalon.cornerstone.services.store.Store")).toInstance(mailStore);
+                bind(Store.class).toInstance(mailStore);
             }
             
         }).getInstance(SpoolManagement.class);

Added: james/server/trunk/management-library/src/main/java/org/apache/james/management/impl/BayesianAnalyzerManagementModule.java
URL: http://svn.apache.org/viewvc/james/server/trunk/management-library/src/main/java/org/apache/james/management/impl/BayesianAnalyzerManagementModule.java?rev=886159&view=auto
==============================================================================
--- james/server/trunk/management-library/src/main/java/org/apache/james/management/impl/BayesianAnalyzerManagementModule.java (added)
+++ james/server/trunk/management-library/src/main/java/org/apache/james/management/impl/BayesianAnalyzerManagementModule.java Wed Dec  2 14:41:53 2009
@@ -0,0 +1,39 @@
+/****************************************************************
+ * 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.management.impl;
+
+import org.apache.avalon.cornerstone.services.datasources.DataSourceSelector;
+import org.apache.commons.logging.Log;
+import org.apache.james.services.FileSystem;
+import org.guiceyfruit.jsr250.Jsr250Module;
+
+import com.google.inject.name.Names;
+
+public class BayesianAnalyzerManagementModule extends Jsr250Module {
+
+    @Override
+    protected void configure() {
+    	super.configure();
+        bind(org.apache.commons.configuration.HierarchicalConfiguration.class).annotatedWith(Names.named("org.apache.commons.configuration.Configuration"));
+        bind(Log.class).annotatedWith(Names.named("org.apache.commons.logging.Log"));
+        bind(FileSystem.class).annotatedWith(Names.named("org.apache.james.services.FileSystem"));     
+        bind(DataSourceSelector.class).annotatedWith(Names.named("org.apache.avalon.cornerstone.services.datasources.DataSourceSelector"));
+    } 
+}

Added: james/server/trunk/management-library/src/main/java/org/apache/james/management/impl/DomainListManagementModule.java
URL: http://svn.apache.org/viewvc/james/server/trunk/management-library/src/main/java/org/apache/james/management/impl/DomainListManagementModule.java?rev=886159&view=auto
==============================================================================
--- james/server/trunk/management-library/src/main/java/org/apache/james/management/impl/DomainListManagementModule.java (added)
+++ james/server/trunk/management-library/src/main/java/org/apache/james/management/impl/DomainListManagementModule.java Wed Dec  2 14:41:53 2009
@@ -0,0 +1,35 @@
+/****************************************************************
+ * 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.management.impl;
+
+import org.apache.james.api.domainlist.DomainList;
+import org.guiceyfruit.jsr250.Jsr250Module;
+
+import com.google.inject.name.Names;
+
+public class DomainListManagementModule extends Jsr250Module{
+
+	@Override
+	protected void configure() {
+		super.configure();
+		
+        bind(DomainList.class).annotatedWith(Names.named("org.apache.james.api.domainlist.DomainList"));
+	}
+
+}

Added: james/server/trunk/management-library/src/main/java/org/apache/james/management/impl/ProcessorManagementModule.java
URL: http://svn.apache.org/viewvc/james/server/trunk/management-library/src/main/java/org/apache/james/management/impl/ProcessorManagementModule.java?rev=886159&view=auto
==============================================================================
--- james/server/trunk/management-library/src/main/java/org/apache/james/management/impl/ProcessorManagementModule.java (added)
+++ james/server/trunk/management-library/src/main/java/org/apache/james/management/impl/ProcessorManagementModule.java Wed Dec  2 14:41:53 2009
@@ -0,0 +1,35 @@
+/****************************************************************
+ * 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.management.impl;
+
+import org.apache.james.services.SpoolManager;
+import org.guiceyfruit.jsr250.Jsr250Module;
+
+import com.google.inject.name.Names;
+
+public class ProcessorManagementModule extends Jsr250Module{
+
+	@Override
+	protected void configure() {
+		super.configure();
+        bind(SpoolManager.class).annotatedWith(Names.named("org.apache.james.services.SpoolManager"));
+
+	}
+
+}

Added: james/server/trunk/management-library/src/main/java/org/apache/james/management/impl/SpoolManagementModule.java
URL: http://svn.apache.org/viewvc/james/server/trunk/management-library/src/main/java/org/apache/james/management/impl/SpoolManagementModule.java?rev=886159&view=auto
==============================================================================
--- james/server/trunk/management-library/src/main/java/org/apache/james/management/impl/SpoolManagementModule.java (added)
+++ james/server/trunk/management-library/src/main/java/org/apache/james/management/impl/SpoolManagementModule.java Wed Dec  2 14:41:53 2009
@@ -0,0 +1,35 @@
+/****************************************************************
+ * 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.management.impl;
+
+import org.apache.avalon.cornerstone.services.store.Store;
+import org.guiceyfruit.jsr250.Jsr250Module;
+
+import com.google.inject.name.Names;
+
+public class SpoolManagementModule extends Jsr250Module{
+
+	@Override
+	protected void configure() {
+		super.configure();
+        bind(Store.class).annotatedWith(Names.named("org.apache.avalon.cornerstone.services.store.Store"));
+	}
+
+}

Added: james/server/trunk/management-library/src/main/java/org/apache/james/osgi/ManagementLibraryActivator.java
URL: http://svn.apache.org/viewvc/james/server/trunk/management-library/src/main/java/org/apache/james/osgi/ManagementLibraryActivator.java?rev=886159&view=auto
==============================================================================
--- james/server/trunk/management-library/src/main/java/org/apache/james/osgi/ManagementLibraryActivator.java (added)
+++ james/server/trunk/management-library/src/main/java/org/apache/james/osgi/ManagementLibraryActivator.java Wed Dec  2 14:41:53 2009
@@ -0,0 +1,117 @@
+/****************************************************************
+ * 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.osgi;
+
+import org.apache.commons.configuration.HierarchicalConfiguration;
+import org.apache.commons.logging.Log;
+import org.apache.james.management.BayesianAnalyzerManagementMBean;
+import org.apache.james.management.BayesianAnalyzerManagementService;
+import org.apache.james.management.DomainListManagementMBean;
+import org.apache.james.management.DomainListManagementService;
+import org.apache.james.management.ProcessorManagementMBean;
+import org.apache.james.management.ProcessorManagementService;
+import org.apache.james.management.SpoolManagementMBean;
+import org.apache.james.management.SpoolManagementService;
+import org.ops4j.peaberry.Export;
+import org.ops4j.peaberry.Peaberry;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+import com.google.inject.Guice;
+import com.google.inject.Inject;
+import com.google.inject.Injector;
+import com.google.inject.Provider;
+
+public class ManagementLibraryActivator implements BundleActivator {
+
+	@Inject
+	private Export<BayesianAnalyzerManagementMBean> analyzerBean;
+
+	@Inject
+	private Export<BayesianAnalyzerManagementService> analyzerService;
+
+	@Inject
+	private Export<DomainListManagementMBean> domBean;
+
+	@Inject
+	private Export<DomainListManagementService> domService;
+
+	@Inject
+	private Export<ProcessorManagementMBean> procBean;
+
+	@Inject
+	private Export<ProcessorManagementService> procService;
+
+	@Inject
+	private Export<SpoolManagementMBean> spoolBean;
+
+	@Inject
+	private Export<SpoolManagementService> spoolService;
+
+	@Inject
+	private Provider<Log> logProvider;
+
+	@Inject
+	private Provider<HierarchicalConfiguration> configProvider;
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext
+	 * )
+	 */
+	public void start(BundleContext context) throws Exception {
+		Injector inj = Guice.createInjector(Peaberry.osgiModule(context),
+				new OSGIBayesianAnalyzerManagementModule(),
+				new OSGIDomainListManagementModule(),
+				new OSGIProcessorManagementModule(),
+				new OSGISpoolManagementModule());
+
+		/* Create bundle content */
+		inj.injectMembers(this);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+	 */
+	public void stop(BundleContext context) throws Exception {
+		analyzerBean.unput();
+		analyzerService.unput();
+		domService.unput();
+		domBean.unput();
+		procBean.unput();
+		procService.unput();
+		spoolBean.unput();
+		spoolService.unput();
+
+		analyzerBean = null;
+		analyzerService = null;
+		domService = null;
+		domBean = null;
+		procBean = null;
+		procService = null;
+		spoolBean = null;
+		spoolService = null;
+
+	}
+}

Added: james/server/trunk/management-library/src/main/java/org/apache/james/osgi/OSGIBayesianAnalyzerManagementModule.java
URL: http://svn.apache.org/viewvc/james/server/trunk/management-library/src/main/java/org/apache/james/osgi/OSGIBayesianAnalyzerManagementModule.java?rev=886159&view=auto
==============================================================================
--- james/server/trunk/management-library/src/main/java/org/apache/james/osgi/OSGIBayesianAnalyzerManagementModule.java (added)
+++ james/server/trunk/management-library/src/main/java/org/apache/james/osgi/OSGIBayesianAnalyzerManagementModule.java Wed Dec  2 14:41:53 2009
@@ -0,0 +1,56 @@
+/****************************************************************
+ * 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.osgi;
+
+import org.apache.avalon.cornerstone.services.datasources.DataSourceSelector;
+import org.apache.commons.configuration.HierarchicalConfiguration;
+import org.apache.commons.logging.Log;
+import org.apache.james.management.BayesianAnalyzerManagementMBean;
+import org.apache.james.management.BayesianAnalyzerManagementService;
+import org.apache.james.management.impl.BayesianAnalyzerManagementModule;
+import org.apache.james.services.FileSystem;
+import org.ops4j.peaberry.Peaberry;
+
+import com.google.inject.name.Names;
+
+public class OSGIBayesianAnalyzerManagementModule extends BayesianAnalyzerManagementModule{
+
+	@Override
+	protected void configure() {
+		super.configure();
+
+		// import osgi service
+		bind(FileSystem.class).toProvider(Peaberry.service(FileSystem.class).single());
+		bind(DataSourceSelector.class).toProvider(Peaberry.service(DataSourceSelector.class).single());
+
+		bind(Log.class).toProvider(Peaberry.service(Log.class).single());
+		bind(HierarchicalConfiguration.class).toProvider(Peaberry.service(HierarchicalConfiguration.class).single());
+		
+		// bind annotations to get the right logger and config
+		bind(String.class).annotatedWith(Names.named("LoggerName")).toInstance("bayesiananalyzermanagement");
+		bind(String.class).annotatedWith(Names.named("ConfigurationName")).toInstance("bayesiananalyzermanagement");
+		
+		// export it as osgi service
+		bind(org.ops4j.peaberry.util.TypeLiterals.export(BayesianAnalyzerManagementMBean.class)).toProvider(
+				Peaberry.service(BayesianAnalyzerManagementMBean.class).export());
+		bind(org.ops4j.peaberry.util.TypeLiterals.export(BayesianAnalyzerManagementService.class)).toProvider(
+				Peaberry.service(BayesianAnalyzerManagementService.class).export());
+	}
+}

Added: james/server/trunk/management-library/src/main/java/org/apache/james/osgi/OSGIDomainListManagementModule.java
URL: http://svn.apache.org/viewvc/james/server/trunk/management-library/src/main/java/org/apache/james/osgi/OSGIDomainListManagementModule.java?rev=886159&view=auto
==============================================================================
--- james/server/trunk/management-library/src/main/java/org/apache/james/osgi/OSGIDomainListManagementModule.java (added)
+++ james/server/trunk/management-library/src/main/java/org/apache/james/osgi/OSGIDomainListManagementModule.java Wed Dec  2 14:41:53 2009
@@ -0,0 +1,55 @@
+/****************************************************************
+ * 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.osgi;
+
+import org.apache.commons.configuration.HierarchicalConfiguration;
+import org.apache.commons.logging.Log;
+import org.apache.james.api.domainlist.DomainList;
+import org.apache.james.management.DomainListManagementMBean;
+import org.apache.james.management.DomainListManagementService;
+import org.apache.james.management.impl.DomainListManagementModule;
+import org.ops4j.peaberry.Peaberry;
+
+import com.google.inject.name.Names;
+
+public class OSGIDomainListManagementModule extends DomainListManagementModule{
+
+	@Override
+	protected void configure() {
+		super.configure();
+		
+
+		// import osgi service
+		bind(DomainList.class).toProvider(Peaberry.service(DomainList.class).single());
+		bind(Log.class).toProvider(Peaberry.service(Log.class).single());
+		bind(HierarchicalConfiguration.class).toProvider(Peaberry.service(HierarchicalConfiguration.class).single());
+		
+		// bind annotations to get the right logger and config
+		bind(String.class).annotatedWith(Names.named("LoggerName")).toInstance("domainlistmanagement");
+		bind(String.class).annotatedWith(Names.named("ConfigurationName")).toInstance("domainlistmanagement");
+		
+		// export it as osgi service
+		bind(org.ops4j.peaberry.util.TypeLiterals.export(DomainListManagementMBean.class)).toProvider(
+				Peaberry.service(DomainListManagementMBean.class).export());
+		bind(org.ops4j.peaberry.util.TypeLiterals.export(DomainListManagementService.class)).toProvider(
+				Peaberry.service(DomainListManagementService.class).export());
+	}
+
+}

Added: james/server/trunk/management-library/src/main/java/org/apache/james/osgi/OSGIProcessorManagementModule.java
URL: http://svn.apache.org/viewvc/james/server/trunk/management-library/src/main/java/org/apache/james/osgi/OSGIProcessorManagementModule.java?rev=886159&view=auto
==============================================================================
--- james/server/trunk/management-library/src/main/java/org/apache/james/osgi/OSGIProcessorManagementModule.java (added)
+++ james/server/trunk/management-library/src/main/java/org/apache/james/osgi/OSGIProcessorManagementModule.java Wed Dec  2 14:41:53 2009
@@ -0,0 +1,54 @@
+/****************************************************************
+ * 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.osgi;
+
+import org.apache.commons.configuration.HierarchicalConfiguration;
+import org.apache.commons.logging.Log;
+import org.apache.james.management.ProcessorManagementMBean;
+import org.apache.james.management.ProcessorManagementService;
+import org.apache.james.management.impl.ProcessorManagementModule;
+import org.apache.james.services.SpoolManager;
+import org.ops4j.peaberry.Peaberry;
+
+import com.google.inject.name.Names;
+
+public class OSGIProcessorManagementModule extends ProcessorManagementModule{
+
+
+	@Override
+	protected void configure() {
+		super.configure();
+		
+
+		// import osgi service
+		bind(SpoolManager.class).toProvider(Peaberry.service(SpoolManager.class).single());
+		bind(Log.class).toProvider(Peaberry.service(Log.class).single());
+		bind(HierarchicalConfiguration.class).toProvider(Peaberry.service(HierarchicalConfiguration.class).single());
+		
+		// bind annotations to get the right logger and config
+		bind(String.class).annotatedWith(Names.named("LoggerName")).toInstance("processormanagement");
+		bind(String.class).annotatedWith(Names.named("ConfigurationName")).toInstance("processormanagement");
+		
+		// export it as osgi service
+		bind(org.ops4j.peaberry.util.TypeLiterals.export(ProcessorManagementMBean.class)).toProvider(
+				Peaberry.service(ProcessorManagementMBean.class).export());
+		bind(org.ops4j.peaberry.util.TypeLiterals.export(ProcessorManagementService.class)).toProvider(
+				Peaberry.service(ProcessorManagementService.class).export());
+	}
+}

Added: james/server/trunk/management-library/src/main/java/org/apache/james/osgi/OSGISpoolManagementModule.java
URL: http://svn.apache.org/viewvc/james/server/trunk/management-library/src/main/java/org/apache/james/osgi/OSGISpoolManagementModule.java?rev=886159&view=auto
==============================================================================
--- james/server/trunk/management-library/src/main/java/org/apache/james/osgi/OSGISpoolManagementModule.java (added)
+++ james/server/trunk/management-library/src/main/java/org/apache/james/osgi/OSGISpoolManagementModule.java Wed Dec  2 14:41:53 2009
@@ -0,0 +1,53 @@
+/****************************************************************
+ * 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.osgi;
+
+import org.apache.avalon.cornerstone.services.store.Store;
+import org.apache.commons.configuration.HierarchicalConfiguration;
+import org.apache.commons.logging.Log;
+import org.apache.james.management.SpoolManagementMBean;
+import org.apache.james.management.SpoolManagementService;
+import org.apache.james.management.impl.SpoolManagementModule;
+import org.ops4j.peaberry.Peaberry;
+
+import com.google.inject.name.Names;
+
+public class OSGISpoolManagementModule extends SpoolManagementModule{
+	
+	@Override
+	protected void configure() {
+		super.configure();
+		
+
+		// import osgi service
+		bind(Store.class).toProvider(Peaberry.service(Store.class).single());
+		bind(Log.class).toProvider(Peaberry.service(Log.class).single());
+		bind(HierarchicalConfiguration.class).toProvider(Peaberry.service(HierarchicalConfiguration.class).single());
+		
+		// bind annotations to get the right logger and config
+		bind(String.class).annotatedWith(Names.named("LoggerName")).toInstance("spoolmanagement");
+		bind(String.class).annotatedWith(Names.named("ConfigurationName")).toInstance("spoolmanagement");
+		
+		// export it as osgi service
+		bind(org.ops4j.peaberry.util.TypeLiterals.export(SpoolManagementService.class)).toProvider(
+				Peaberry.service(SpoolManagementService.class).export());
+		bind(org.ops4j.peaberry.util.TypeLiterals.export(SpoolManagementMBean.class)).toProvider(
+				Peaberry.service(SpoolManagementMBean.class).export());
+	}
+}

Added: james/server/trunk/osgi-deployment/src/main/java/org/apache/james/osgi/ConfigurationProvider.java
URL: http://svn.apache.org/viewvc/james/server/trunk/osgi-deployment/src/main/java/org/apache/james/osgi/ConfigurationProvider.java?rev=886159&view=auto
==============================================================================
--- james/server/trunk/osgi-deployment/src/main/java/org/apache/james/osgi/ConfigurationProvider.java (added)
+++ james/server/trunk/osgi-deployment/src/main/java/org/apache/james/osgi/ConfigurationProvider.java Wed Dec  2 14:41:53 2009
@@ -0,0 +1,46 @@
+/****************************************************************
+ * 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.osgi;
+
+import org.apache.commons.configuration.ConfigurationException;
+import org.apache.commons.configuration.HierarchicalConfiguration;
+import org.apache.commons.configuration.XMLConfiguration;
+
+import com.google.inject.Provider;
+import com.google.inject.name.Named;
+
+public class ConfigurationProvider implements Provider<HierarchicalConfiguration>{
+
+	private XMLConfiguration rootConf;
+	private String componentName;
+	
+	public ConfigurationProvider(@Named("ConfigurationName") String componentName) throws ConfigurationException {
+		this.rootConf = new XMLConfiguration();
+		rootConf.setDelimiterParsingDisabled(true);
+		rootConf.load("config.xml");
+		this.componentName = componentName;
+	}
+	
+	
+	public HierarchicalConfiguration get() {
+		return rootConf.configurationAt(componentName);
+	}
+
+}

Modified: james/server/trunk/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/pom.xml?rev=886159&r1=886158&r2=886159&view=diff
==============================================================================
--- james/server/trunk/pom.xml (original)
+++ james/server/trunk/pom.xml Wed Dec  2 14:41:53 2009
@@ -82,6 +82,10 @@
   </scm>
   <build>
     <plugins>
+      <plugin>    
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+      </plugin>  
       <plugin>
         <artifactId>maven-compiler-plugin</artifactId>
         <configuration>
@@ -180,7 +184,22 @@
       </snapshots>
     </repository>
      -->
+    <!-- enable central that is otherwise disabled by the parent pom. -->
+    <repository>
+      <id>central</id>
+      <url>http://repo1.maven.org/maven2</url>
+      <releases>
+         <enabled>true</enabled>
+      </releases>
+    </repository>
   </repositories>
+  <dependencies>
+  	<dependency>
+  		<groupId>org.osgi</groupId>
+  		<artifactId>org.osgi</artifactId>
+  		<version>3.0.0</version>
+  	</dependency>
+  </dependencies>
   <reporting>
     <plugins>
     <!--
@@ -1150,11 +1169,26 @@
       <version>2.0</version>
     </dependency>
     <dependency>
+      <groupId>javax.annotation</groupId>
+      <artifactId>jsr250-api</artifactId>     
+      <version>1.0</version>
+    </dependency>
+    <dependency>
       <groupId>spring-aopalliance</groupId>
       <artifactId>spring-aopalliance</artifactId>
       <version>1.0</version>
       <scope>runtime</scope>
     </dependency>
+    <dependency>
+      <groupId>org.ops4j</groupId>
+      <artifactId>peaberry</artifactId>
+      <version>1.1.1</version>
+    </dependency> 
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi</artifactId>
+      <version>3.0.0</version>
+    </dependency> 
   </dependencies>
   </dependencyManagement>
 

Modified: james/server/trunk/stage/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/stage/pom.xml?rev=886159&r1=886158&r2=886159&view=diff
==============================================================================
--- james/server/trunk/stage/pom.xml (original)
+++ james/server/trunk/stage/pom.xml Wed Dec  2 14:41:53 2009
@@ -400,10 +400,18 @@
       <artifactId>guiceyfruit-core</artifactId>
     </dependency>
     <dependency>
+      <groupId>javax.annotation</groupId>
+      <artifactId>jsr250-api</artifactId>
+    </dependency>
+    <dependency>
       <groupId>spring-aopalliance</groupId>
       <artifactId>spring-aopalliance</artifactId>
       <scope>runtime</scope>
     </dependency>
+    <dependency>
+      <groupId>org.ops4j</groupId>
+      <artifactId>peaberry</artifactId>
+    </dependency> 
   </dependencies>
   
   <build>

Modified: james/server/trunk/user-library/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/user-library/pom.xml?rev=886159&r1=886158&r2=886159&view=diff
==============================================================================
--- james/server/trunk/user-library/pom.xml (original)
+++ james/server/trunk/user-library/pom.xml Wed Dec  2 14:41:53 2009
@@ -28,6 +28,41 @@
   <artifactId>james-server-user-library</artifactId>
   <version>3.0-M1</version>
   <name>Apache JAMES Server User Library</name>
+
+  <build>
+    <plugins>
+      <plugin>
+        <artifactId>maven-jar-plugin</artifactId>
+        <configuration>
+          <archive>  
+            <manifestFile>${project.build.outputDirectory}/META-INF/MANIFEST.MF</manifestFile>
+          </archive> 
+        </configuration>
+      </plugin>  
+      <plugin>    
+        <groupId>org.apache.felix</groupId>
+        <artifactId>maven-bundle-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>bundle-manifest</id>
+            <phase>process-classes</phase>
+            <goals>    
+              <goal>manifest</goal>
+            </goals>   
+          </execution>
+        </executions>
+        <configuration>
+          <instructions>
+            <Export-Package>org.apache.james.impl.jamesuser,org.apache.james.impl.user</Export-Package>
+            <Private-Package>org.apache.james.*</Private-Package>
+            <Bundle-Activator>org.apache.james.osgi.UsersLibraryActivator</Bundle-Activator>
+          </instructions>
+        </configuration>
+      </plugin>  
+    </plugins>
+  </build>
+  
+  
   <dependencies>
     <dependency>
       <groupId>org.apache.james</groupId>
@@ -67,7 +102,14 @@
       <artifactId>spring-aopalliance</artifactId>
       <scope>runtime</scope>
     </dependency>
-    
+    <dependency>
+      <groupId>org.ops4j</groupId>
+      <artifactId>peaberry</artifactId>
+    </dependency> 
+    <dependency>
+      <groupId>org.osgi</groupId>
+      <artifactId>org.osgi</artifactId>
+    </dependency> 
     <dependency>
       <groupId>oro</groupId>
       <artifactId>oro</artifactId>

Modified: james/server/trunk/user-library/src/main/java/org/apache/james/impl/jamesuser/AvalonLocalJamesUsersRepository.java
URL: http://svn.apache.org/viewvc/james/server/trunk/user-library/src/main/java/org/apache/james/impl/jamesuser/AvalonLocalJamesUsersRepository.java?rev=886159&r1=886158&r2=886159&view=diff
==============================================================================
--- james/server/trunk/user-library/src/main/java/org/apache/james/impl/jamesuser/AvalonLocalJamesUsersRepository.java (original)
+++ james/server/trunk/user-library/src/main/java/org/apache/james/impl/jamesuser/AvalonLocalJamesUsersRepository.java Wed Dec  2 14:41:53 2009
@@ -21,16 +21,24 @@
 
 import java.util.Collection;
 
+import org.apache.james.api.user.UsersStore;
 import org.apache.james.api.vut.ErrorMappingException;
 import org.apache.james.impl.user.AvalonLocalUsersRepository;
-import org.guiceyfruit.jsr250.Jsr250Module;
 
+import com.google.inject.AbstractModule;
 import com.google.inject.Guice;
 
 public class AvalonLocalJamesUsersRepository extends AvalonLocalUsersRepository implements JamesUsersRepository{
     
     public void initialize() throws Exception {
-        repos = Guice.createInjector(new Jsr250Module(), new LocalUsersRepositoryModule()).getInstance(LocalJamesUsersRepository.class);
+        repos = Guice.createInjector(new LocalJamesUsersRepositoryModule(), new AbstractModule() {
+
+            @Override
+            protected void configure() {
+                bind(UsersStore.class).toInstance(usersStore);
+            }
+            
+        }).getInstance(LocalJamesUsersRepository.class);
     }
     
     public void setEnableAliases(boolean enableAliases) {

Added: james/server/trunk/user-library/src/main/java/org/apache/james/impl/jamesuser/LocalJamesUsersRepositoryModule.java
URL: http://svn.apache.org/viewvc/james/server/trunk/user-library/src/main/java/org/apache/james/impl/jamesuser/LocalJamesUsersRepositoryModule.java?rev=886159&view=auto
==============================================================================
--- james/server/trunk/user-library/src/main/java/org/apache/james/impl/jamesuser/LocalJamesUsersRepositoryModule.java (added)
+++ james/server/trunk/user-library/src/main/java/org/apache/james/impl/jamesuser/LocalJamesUsersRepositoryModule.java Wed Dec  2 14:41:53 2009
@@ -0,0 +1,25 @@
+/****************************************************************
+ * 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.impl.jamesuser;
+
+import org.apache.james.impl.user.LocalUsersRepositoryModule;
+
+public class LocalJamesUsersRepositoryModule extends LocalUsersRepositoryModule{
+
+}

Modified: james/server/trunk/user-library/src/main/java/org/apache/james/impl/user/AvalonLocalUsersRepository.java
URL: http://svn.apache.org/viewvc/james/server/trunk/user-library/src/main/java/org/apache/james/impl/user/AvalonLocalUsersRepository.java?rev=886159&r1=886158&r2=886159&view=diff
==============================================================================
--- james/server/trunk/user-library/src/main/java/org/apache/james/impl/user/AvalonLocalUsersRepository.java (original)
+++ james/server/trunk/user-library/src/main/java/org/apache/james/impl/user/AvalonLocalUsersRepository.java Wed Dec  2 14:41:53 2009
@@ -28,34 +28,30 @@
 import org.apache.james.api.user.UsersRepository;
 import org.apache.james.api.user.UsersStore;
 import org.apache.james.bridge.GuiceInjected;
-import org.guiceyfruit.jsr250.Jsr250Module;
 
 import com.google.inject.AbstractModule;
 import com.google.inject.Guice;
-import com.google.inject.name.Names;
 
 public class AvalonLocalUsersRepository implements GuiceInjected, Initializable,Serviceable,UsersRepository{
 
-    private UsersStore usersStore;
+    protected UsersStore usersStore;
     protected LocalUsersRepository repos;
     
     public void initialize() throws Exception {
-        repos = Guice.createInjector(new Jsr250Module(), new LocalUsersRepositoryModule()).getInstance(LocalUsersRepository.class);
+        repos = Guice.createInjector(new LocalUsersRepositoryModule(), new AbstractModule() {
+
+            @Override
+            protected void configure() {
+                bind(UsersStore.class).toInstance(usersStore);
+            }
+            
+        }).getInstance(LocalUsersRepository.class);
     }
 
     public void service(ServiceManager manager) throws ServiceException {
         usersStore = (UsersStore) manager.lookup(UsersStore.ROLE);
     }
     
-    public class LocalUsersRepositoryModule extends AbstractModule {
-
-        @Override
-        protected void configure() {
-            bind(UsersStore.class).annotatedWith(Names.named("org.apache.james.api.user.UsersStore")).toInstance(usersStore);
-        }
-        
-    }
-
     public boolean addUser(User user) {
         return repos.addUser(user);
     }

Modified: james/server/trunk/user-library/src/main/java/org/apache/james/impl/user/AvalonUserManagement.java
URL: http://svn.apache.org/viewvc/james/server/trunk/user-library/src/main/java/org/apache/james/impl/user/AvalonUserManagement.java?rev=886159&r1=886158&r2=886159&view=diff
==============================================================================
--- james/server/trunk/user-library/src/main/java/org/apache/james/impl/user/AvalonUserManagement.java (original)
+++ james/server/trunk/user-library/src/main/java/org/apache/james/impl/user/AvalonUserManagement.java Wed Dec  2 14:41:53 2009
@@ -29,11 +29,10 @@
 import org.apache.james.api.user.management.UserManagementException;
 import org.apache.james.api.user.management.UserManagementMBean;
 import org.apache.james.bridge.GuiceInjected;
-import org.guiceyfruit.jsr250.Jsr250Module;
 
 import com.google.inject.AbstractModule;
 import com.google.inject.Guice;
-import com.google.inject.name.Names;
+
 
 public class AvalonUserManagement implements UserManagementMBean, GuiceInjected, Serviceable, Initializable {
 
@@ -99,17 +98,16 @@
     }
 
     public void initialize() throws Exception {
-        bean = Guice.createInjector(new Jsr250Module(), new UserManagementModule()).getInstance(UserManagement.class);
+        bean = Guice.createInjector(new UserManagementModule(), new AbstractModule() {
+			
+			@Override
+			protected void configure() {
+				bind(UsersStore.class).toInstance(store);
+				bind(UsersRepository.class).toInstance(repos);
+			}
+		}).getInstance(UserManagement.class);
     }
     
-    private class UserManagementModule extends AbstractModule {
-
-        @Override
-        protected void configure() {
-            bind(UsersStore.class).annotatedWith(Names.named("org.apache.james.api.user.UsersStore")).toInstance(store);
-            bind(UsersRepository.class).annotatedWith(Names.named("org.apache.james.api.user.UsersRepository")).toInstance(repos);
-        }
-        
-    }
+   
 
 }

Added: james/server/trunk/user-library/src/main/java/org/apache/james/impl/user/LocalUsersRepositoryModule.java
URL: http://svn.apache.org/viewvc/james/server/trunk/user-library/src/main/java/org/apache/james/impl/user/LocalUsersRepositoryModule.java?rev=886159&view=auto
==============================================================================
--- james/server/trunk/user-library/src/main/java/org/apache/james/impl/user/LocalUsersRepositoryModule.java (added)
+++ james/server/trunk/user-library/src/main/java/org/apache/james/impl/user/LocalUsersRepositoryModule.java Wed Dec  2 14:41:53 2009
@@ -0,0 +1,34 @@
+/****************************************************************
+ * 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.impl.user;
+
+import org.apache.james.api.user.UsersStore;
+import org.guiceyfruit.jsr250.Jsr250Module;
+
+import com.google.inject.name.Names;
+
+public class LocalUsersRepositoryModule extends Jsr250Module {
+
+    @Override
+    protected void configure() {
+    	super.configure();
+        bind(UsersStore.class).annotatedWith(Names.named("org.apache.james.api.user.UsersStore"));
+    }
+    
+}

Added: james/server/trunk/user-library/src/main/java/org/apache/james/impl/user/UserManagementModule.java
URL: http://svn.apache.org/viewvc/james/server/trunk/user-library/src/main/java/org/apache/james/impl/user/UserManagementModule.java?rev=886159&view=auto
==============================================================================
--- james/server/trunk/user-library/src/main/java/org/apache/james/impl/user/UserManagementModule.java (added)
+++ james/server/trunk/user-library/src/main/java/org/apache/james/impl/user/UserManagementModule.java Wed Dec  2 14:41:53 2009
@@ -0,0 +1,36 @@
+/****************************************************************
+ * 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.impl.user;
+
+import org.apache.james.api.user.UsersRepository;
+import org.apache.james.api.user.UsersStore;
+import org.guiceyfruit.jsr250.Jsr250Module;
+
+import com.google.inject.name.Names;
+
+public class UserManagementModule extends Jsr250Module {
+
+    @Override
+    protected void configure() {
+    	super.configure();
+        bind(UsersStore.class).annotatedWith(Names.named("org.apache.james.api.user.UsersStore"));
+        bind(UsersRepository.class).annotatedWith(Names.named("org.apache.james.api.user.UsersRepository"));
+    }
+    
+}

Added: james/server/trunk/user-library/src/main/java/org/apache/james/osgi/OSGILocalJamesUsersRepositoryModule.java
URL: http://svn.apache.org/viewvc/james/server/trunk/user-library/src/main/java/org/apache/james/osgi/OSGILocalJamesUsersRepositoryModule.java?rev=886159&view=auto
==============================================================================
--- james/server/trunk/user-library/src/main/java/org/apache/james/osgi/OSGILocalJamesUsersRepositoryModule.java (added)
+++ james/server/trunk/user-library/src/main/java/org/apache/james/osgi/OSGILocalJamesUsersRepositoryModule.java Wed Dec  2 14:41:53 2009
@@ -0,0 +1,51 @@
+/****************************************************************
+ * 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.osgi;
+
+import org.apache.commons.configuration.HierarchicalConfiguration;
+import org.apache.commons.logging.Log;
+import org.apache.james.api.user.UsersStore;
+import org.apache.james.impl.jamesuser.JamesUsersRepository;
+import org.apache.james.impl.jamesuser.LocalJamesUsersRepository;
+import org.apache.james.impl.jamesuser.LocalJamesUsersRepositoryModule;
+import org.ops4j.peaberry.Peaberry;
+
+import com.google.inject.name.Names;
+
+public class OSGILocalJamesUsersRepositoryModule extends LocalJamesUsersRepositoryModule{
+
+	@Override
+	protected void configure() {
+		super.configure();
+
+		// import osgi service
+		bind(UsersStore.class).toProvider(Peaberry.service(UsersStore.class).single());
+		bind(Log.class).toProvider(Peaberry.service(Log.class).single());
+		bind(HierarchicalConfiguration.class).toProvider(Peaberry.service(HierarchicalConfiguration.class).single());
+		
+		// bind annotations to get the right logger and config
+		bind(String.class).annotatedWith(Names.named("LoggerName")).toInstance("localusersrepository");
+		bind(String.class).annotatedWith(Names.named("ConfigurationName")).toInstance("localusersrepository");
+		
+		// export it as osgi service
+		bind(org.ops4j.peaberry.util.TypeLiterals.export(JamesUsersRepository.class)).toProvider(
+				Peaberry.service(LocalJamesUsersRepository.class).export());
+	}
+
+}

Added: james/server/trunk/user-library/src/main/java/org/apache/james/osgi/OSGILocalUsersRepositoryModule.java
URL: http://svn.apache.org/viewvc/james/server/trunk/user-library/src/main/java/org/apache/james/osgi/OSGILocalUsersRepositoryModule.java?rev=886159&view=auto
==============================================================================
--- james/server/trunk/user-library/src/main/java/org/apache/james/osgi/OSGILocalUsersRepositoryModule.java (added)
+++ james/server/trunk/user-library/src/main/java/org/apache/james/osgi/OSGILocalUsersRepositoryModule.java Wed Dec  2 14:41:53 2009
@@ -0,0 +1,42 @@
+/****************************************************************
+ * 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.osgi;
+
+import org.apache.commons.logging.Log;
+import org.apache.james.api.user.UsersRepository;
+import org.apache.james.api.user.UsersStore;
+import org.apache.james.impl.user.LocalUsersRepository;
+import org.apache.james.impl.user.LocalUsersRepositoryModule;
+import org.ops4j.peaberry.Peaberry;
+
+public class OSGILocalUsersRepositoryModule extends LocalUsersRepositoryModule{
+
+	@Override
+	protected void configure() {
+		super.configure();
+		
+		// import osgi service
+        bind(UsersStore.class).toProvider(Peaberry.service(UsersStore.class).single());
+		bind(Log.class).toProvider(Peaberry.service(Log.class).single());
+
+        // export it as osgi service
+        bind(org.ops4j.peaberry.util.TypeLiterals.export(UsersRepository.class)).toProvider(Peaberry.service(LocalUsersRepository.class).export());
+	}
+
+}

Added: james/server/trunk/user-library/src/main/java/org/apache/james/osgi/OSGIUserManagementModule.java
URL: http://svn.apache.org/viewvc/james/server/trunk/user-library/src/main/java/org/apache/james/osgi/OSGIUserManagementModule.java?rev=886159&view=auto
==============================================================================
--- james/server/trunk/user-library/src/main/java/org/apache/james/osgi/OSGIUserManagementModule.java (added)
+++ james/server/trunk/user-library/src/main/java/org/apache/james/osgi/OSGIUserManagementModule.java Wed Dec  2 14:41:53 2009
@@ -0,0 +1,45 @@
+/****************************************************************
+ * 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.osgi;
+
+import org.apache.commons.logging.Log;
+import org.apache.james.api.user.UsersRepository;
+import org.apache.james.api.user.UsersStore;
+import org.apache.james.api.user.management.UserManagementMBean;
+import org.apache.james.impl.user.UserManagement;
+import org.apache.james.impl.user.UserManagementModule;
+import org.ops4j.peaberry.Peaberry;
+
+public class OSGIUserManagementModule extends UserManagementModule{
+
+	@Override
+	protected void configure() {
+		super.configure();
+		
+		// import osgi service
+        bind(UsersStore.class).toProvider(Peaberry.service(UsersStore.class).single());
+        bind(UsersRepository.class).toProvider(Peaberry.service(UsersRepository.class).single());
+		bind(Log.class).toProvider(Peaberry.service(Log.class).single());
+
+		
+        // export it as osgi service
+        bind(org.ops4j.peaberry.util.TypeLiterals.export(UserManagementMBean.class)).toProvider(Peaberry.service(UserManagement.class).export());
+	}
+
+}

Added: james/server/trunk/user-library/src/main/java/org/apache/james/osgi/UsersLibraryActivator.java
URL: http://svn.apache.org/viewvc/james/server/trunk/user-library/src/main/java/org/apache/james/osgi/UsersLibraryActivator.java?rev=886159&view=auto
==============================================================================
--- james/server/trunk/user-library/src/main/java/org/apache/james/osgi/UsersLibraryActivator.java (added)
+++ james/server/trunk/user-library/src/main/java/org/apache/james/osgi/UsersLibraryActivator.java Wed Dec  2 14:41:53 2009
@@ -0,0 +1,85 @@
+/****************************************************************
+ * 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.osgi;
+
+import org.apache.commons.configuration.HierarchicalConfiguration;
+import org.apache.commons.logging.Log;
+import org.apache.james.impl.jamesuser.LocalJamesUsersRepository;
+import org.apache.james.impl.user.LocalUsersRepository;
+import org.apache.james.impl.user.UserManagement;
+import org.ops4j.peaberry.Export;
+import org.ops4j.peaberry.Peaberry;
+import org.osgi.framework.BundleActivator;
+import org.osgi.framework.BundleContext;
+
+import com.google.inject.Guice;
+import com.google.inject.Inject;
+import com.google.inject.Injector;
+import com.google.inject.Provider;
+
+public class UsersLibraryActivator implements BundleActivator {
+	@Inject
+	private Provider<Log> logProvider;
+
+	@Inject
+	private Provider<HierarchicalConfiguration> configProvider;
+
+	@Inject
+	private Export<LocalJamesUsersRepository> jamesUsersRepos;
+
+	@Inject
+	private Export<LocalUsersRepository> localUsersRepos;
+
+	@Inject
+	Export<UserManagement> userMgmt;
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext
+	 * )
+	 */
+	public void start(BundleContext context) throws Exception {
+		Injector inj = Guice.createInjector(Peaberry.osgiModule(context),
+				new OSGIUserManagementModule(),
+				new OSGILocalJamesUsersRepositoryModule(),
+				new OSGILocalUsersRepositoryModule());
+
+		/* Create bundle content */
+		inj.injectMembers(this);
+	}
+
+	/*
+	 * (non-Javadoc)
+	 * 
+	 * @see
+	 * org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
+	 */
+	public void stop(BundleContext context) throws Exception {
+		jamesUsersRepos.unput();
+		localUsersRepos.unput();
+		userMgmt.unput();
+
+		jamesUsersRepos = null;
+		localUsersRepos = null;
+		userMgmt = null;
+	}
+
+}



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