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 2010/12/27 18:09:35 UTC
svn commit: r1053109 - in /james/server/trunk/container-spring: ./
src/main/config/james/context/
src/main/java/org/apache/james/container/spring/mailbox/
Author: norman
Date: Mon Dec 27 17:09:35 2010
New Revision: 1053109
URL: http://svn.apache.org/viewvc?rev=1053109&view=rev
Log:
expose MailboxCopier methods via JMX
Added:
james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/mailbox/
james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/mailbox/MailboxCopierManagement.java
james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/mailbox/MailboxCopierManagementMBean.java
Modified:
james/server/trunk/container-spring/pom.xml
james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml
Modified: james/server/trunk/container-spring/pom.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/container-spring/pom.xml?rev=1053109&r1=1053108&r2=1053109&view=diff
==============================================================================
--- james/server/trunk/container-spring/pom.xml (original)
+++ james/server/trunk/container-spring/pom.xml Mon Dec 27 17:09:35 2010
@@ -666,17 +666,19 @@
<dependency>
<groupId>org.apache.james</groupId>
<artifactId>apache-james-mailbox-memory</artifactId>
- <version>0.2-M2-SNAPSHOT</version>
<scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.james</groupId>
+ <artifactId>apache-james-mailbox-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.james</groupId>
<artifactId>james-server-mail-api</artifactId>
</dependency>
<dependency>
<groupId>org.apache.james</groupId>
<artifactId>apache-james-mailbox-copier</artifactId>
- <scope>runtime</scope>
</dependency>
<dependency>
<groupId>org.apache.james</groupId>
Modified: james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml
URL: http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml?rev=1053109&r1=1053108&r2=1053109&view=diff
==============================================================================
--- james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml (original)
+++ james/server/trunk/container-spring/src/main/config/james/context/james-server-context.xml Mon Dec 27 17:09:35 2010
@@ -315,10 +315,7 @@
<!--
Mailbox Copier
-->
- <bean id="mailboxCopier" class="org.apache.james.mailbox.copier.MailboxCopierImpl">
- <property name="srcMailboxManager" ref="jpa-mailboxmanager"/>
- <property name="dstMailboxManager" ref="jcr-mailboxmanager"/>
- </bean>
+ <bean id="mailboxcopier" class="org.apache.james.mailbox.copier.MailboxCopierImpl"/>
<!--
===========================================================================
@@ -399,7 +396,7 @@
</property>
<property name="assembler">
<bean class="org.springframework.jmx.export.assembler.InterfaceBasedMBeanInfoAssembler">
- <property name="managedInterfaces" value="org.apache.james.smtpserver.netty.SMTPServerMBean,org.apache.james.remotemanager.netty.RemoteManagerMBean,org.apache.james.pop3server.netty.POP3ServerMBean,org.apache.james.imapserver.netty.IMAPServerMBean,org.apache.james.fetchmail.FetchSchedulerMBean,org.apache.james.domainlist.api.DomainListManagementMBean,org.apache.james.dnsservice.api.DNSServiceMBean,org.apache.james.vut.api.VirtualUserTableManagementMBean,org.apache.james.user.api.UserManagementMBean,org.apache.james.adapter.mailbox.MailboxManagerManagementMBean,org.apache.james.mailbox.copier.MailboxCopierManagementMBean,org.apache.james.mailetcontainer.api.jmx.MailSpoolerMBean"/>
+ <property name="managedInterfaces" value="org.apache.james.smtpserver.netty.SMTPServerMBean,org.apache.james.remotemanager.netty.RemoteManagerMBean,org.apache.james.pop3server.netty.POP3ServerMBean,org.apache.james.imapserver.netty.IMAPServerMBean,org.apache.james.fetchmail.FetchSchedulerMBean,org.apache.james.domainlist.api.DomainListManagementMBean,org.apache.james.dnsservice.api.DNSServiceMBean,org.apache.james.vut.api.VirtualUserTableManagementMBean,org.apache.james.user.api.UserManagementMBean,org.apache.james.adapter.mailbox.MailboxManagerManagementMBean,org.apache.james.container.spring.mailbox.MailboxCopierManagementMBean,org.apache.james.mailetcontainer.api.jmx.MailSpoolerMBean"/>
</bean>
</property>
</bean>
@@ -407,6 +404,6 @@
<bean id="virtualusertablemanagement" class="org.apache.james.vut.lib.VirtualUserTableManagement" />
<bean id="domainlistmanagement" class="org.apache.james.domainlist.lib.DomainListManagement" />
<bean id="mailboxmanagermanagement" class="org.apache.james.adapter.mailbox.MailboxManagerManagement" />
- <bean id="mailboxcopiermanagement" class="org.apache.james.mailbox.copier.MailboxCopierManagement" />
+ <bean id="mailboxcopiermanagement" class="org.apache.james.container.spring.mailbox.MailboxCopierManagement" />
</beans>
Added: james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/mailbox/MailboxCopierManagement.java
URL: http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/mailbox/MailboxCopierManagement.java?rev=1053109&view=auto
==============================================================================
--- james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/mailbox/MailboxCopierManagement.java (added)
+++ james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/mailbox/MailboxCopierManagement.java Mon Dec 27 17:09:35 2010
@@ -0,0 +1,83 @@
+/****************************************************************
+ * 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.container.spring.mailbox;
+
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.annotation.Resource;
+
+import org.apache.james.mailbox.MailboxManager;
+import org.apache.james.mailbox.copier.MailboxCopier;
+import org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+
+/**
+ * {@link MailboxCopier} support via JMX
+ *
+ */
+public class MailboxCopierManagement implements MailboxCopierManagementMBean, ApplicationContextAware{
+
+ private MailboxCopier copier;
+ private ApplicationContext context;
+
+ @Resource(name="mailboxcopier")
+ public void setMailboxCopier(MailboxCopier copier) {
+ this.copier = copier;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.container.spring.mailbox.MailboxCopierManagementMBean#getMailboxManagerBeans()
+ */
+ public Map<String,String> getMailboxManagerBeans() {
+ Map<String, String> bMap = new HashMap<String, String>();
+
+ Map<String,MailboxManager> beans = context.getBeansOfType(MailboxManager.class);
+
+ Iterator<String> keys= beans.keySet().iterator();
+ while(keys.hasNext()) {
+ String key = keys.next();
+ String name = beans.get(key).getClass().getName();
+ bMap.put(key, name);
+ }
+ return bMap;
+ }
+
+ /*
+ * (non-Javadoc)
+ * @see org.apache.james.container.spring.mailbox.MailboxCopierManagementMBean#copy(java.lang.String, java.lang.String)
+ */
+ public boolean copy(String srcBean, String dstBean) {
+ if (srcBean.equals(dstBean)) throw new IllegalArgumentException("srcBean and dstBean can not have the same name!");
+ return copier.copyMailboxes(context.getBean(srcBean, MailboxManager.class), context.getBean(dstBean, MailboxManager.class));
+ }
+
+
+ /*
+ * (non-Javadoc)
+ * @see org.springframework.context.ApplicationContextAware#setApplicationContext(org.springframework.context.ApplicationContext)
+ */
+ public void setApplicationContext(ApplicationContext context) throws BeansException {
+ this.context = context;
+ }
+
+}
Added: james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/mailbox/MailboxCopierManagementMBean.java
URL: http://svn.apache.org/viewvc/james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/mailbox/MailboxCopierManagementMBean.java?rev=1053109&view=auto
==============================================================================
--- james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/mailbox/MailboxCopierManagementMBean.java (added)
+++ james/server/trunk/container-spring/src/main/java/org/apache/james/container/spring/mailbox/MailboxCopierManagementMBean.java Mon Dec 27 17:09:35 2010
@@ -0,0 +1,48 @@
+/****************************************************************
+ * 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.container.spring.mailbox;
+
+import java.util.Map;
+
+import org.apache.james.mailbox.MailboxManager;
+
+/**
+ * Allow to copy {@link MailboxManager} contents from one to the other via JMX
+ *
+ *
+ */
+public interface MailboxCopierManagementMBean {
+
+ /**
+ * Return a {@link Map} which contains the bean name of the registered {@link MailboxManager} instances as keys
+ * and the classname of them as values
+ *
+ * @return managers
+ */
+ public Map<String,String> getMailboxManagerBeans();
+
+ /**
+ * Copy from srcBean to dstBean all messages
+ *
+ * @param srcBean
+ * @param dstBean
+ * @return true if successful, false otherwise
+ */
+ public boolean copy(String srcBean, String dstBean);
+}
---------------------------------------------------------------------
To unsubscribe, e-mail: server-dev-unsubscribe@james.apache.org
For additional commands, e-mail: server-dev-help@james.apache.org