Author: rdonkin
Date: Tue Jun 2 11:29:29 2009
New Revision: 781005
URL: http://svn.apache.org/viewvc?rev=781005&view=rev
Log:
IMAP-95 Outline module and classes.
https://issues.apache.org/jira/browse/IMAP-95
Added:
james/imap/trunk/memory/ (with props)
james/imap/trunk/memory/build.xml (with props)
james/imap/trunk/memory/pom.xml (with props)
james/imap/trunk/memory/src/
james/imap/trunk/memory/src/main/
james/imap/trunk/memory/src/main/config/
james/imap/trunk/memory/src/main/java/
james/imap/trunk/memory/src/main/java/org/
james/imap/trunk/memory/src/main/java/org/apache/
james/imap/trunk/memory/src/main/java/org/apache/james/
james/imap/trunk/memory/src/main/java/org/apache/james/imap/
james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/
james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/InMemoryMailbox.java
(with props)
james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/InMemoryMailboxManager.java
(with props)
james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/InMemoryStoreMailbox.java
(with props)
james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/InMemorySubscriptionManager.java
(with props)
james/imap/trunk/memory/src/main/resources/
james/imap/trunk/memory/src/test/
james/imap/trunk/memory/src/test/config/
james/imap/trunk/memory/src/test/java/
james/imap/trunk/memory/src/test/resources/
Modified:
james/imap/trunk/build.xml
james/imap/trunk/pom.xml
Modified: james/imap/trunk/build.xml
URL:
http://svn.apache.org/viewvc/james/imap/trunk/build.xml?rev=781005&r1=781004&r2=781005&view=diff
==============================================================================
--- james/imap/trunk/build.xml (original)
+++ james/imap/trunk/build.xml Tue Jun 2 11:29:29 2009
@@ -39,6 +39,7 @@
<property name='module.torque' location='torque'/>
<property name='module.store' location='store'/>
<property name='module.jpa' location='jpa'/>
+ <property name='module.memory' location='memory'/>
<property name='module.deployment' location='deployment'/>
<!--
@@ -64,6 +65,7 @@
<file name='${module.seda}'/>
<file name='${module.torque}'/>
<file name='${module.jpa}'/>
+ <file name='${module.memory}'/>
<file name='${module.deployment}'/>
</filelist>
</subant>
Propchange: james/imap/trunk/memory/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Tue Jun 2 11:29:29 2009
@@ -0,0 +1,2 @@
+target
+.*
Added: james/imap/trunk/memory/build.xml
URL:
http://svn.apache.org/viewvc/james/imap/trunk/memory/build.xml?rev=781005&view=auto
==============================================================================
--- james/imap/trunk/memory/build.xml (added)
+++ james/imap/trunk/memory/build.xml Tue Jun 2 11:29:29 2009
@@ -0,0 +1,42 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<project default="main" name="memory">
+ <description>Builds In Memory Storage Module</description>
+ <property name="name.module" value="memory" />
+ <import file="../build-tools/function-build.xml" optional="no" />
+
+ <target
+ name='set-classpath'
+ depends='check-environment, master-module-template.set-classpath'>
+ <path id='classpath.main'>
+ <path refid='classpath.base'/>
+ <path refid='depend.on.store'/>
+ </path>
+ <path id='classpath.test'>
+ <path refid='classpath.main'/>
+ <path refid='classpath.base.test'/>
+ <path refid='depend.on.store'/>
+ </path>
+ <path id='classpath.test.runtime'>
+ <path refid='classpath.test'/>
+ </path>
+ </target>
+
+</project>
Propchange: james/imap/trunk/memory/build.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added: james/imap/trunk/memory/pom.xml
URL:
http://svn.apache.org/viewvc/james/imap/trunk/memory/pom.xml?rev=781005&view=auto
==============================================================================
--- james/imap/trunk/memory/pom.xml (added)
+++ james/imap/trunk/memory/pom.xml Tue Jun 2 11:29:29 2009
@@ -0,0 +1,56 @@
+<?xml version="1.0" encoding="ISO-8859-15"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you under the Apache License, Version 2.0 (the
+ "License"); you may not use this file except in compliance
+ with the License. You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+ Unless required by applicable law or agreed to in writing,
+ software distributed under the License is distributed on an
+ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ KIND, either express or implied. See the License for the
+ specific language governing permissions and limitations
+ under the License.
+-->
+<project>
+ <parent>
+ <artifactId>apache-james-imap-parent</artifactId>
+ <groupId>org.apache.james</groupId>
+ <version>0.1-SNAPSHOT</version>
+ <relativePath>../parent/pom.xml</relativePath>
+ </parent>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>org.apache.james</groupId>
+ <artifactId>apache-james-imap-memory</artifactId>
+ <name>Apache James IMAP In Memory Mailbox Manager</name>
+ <dependencies>
+ <dependency>
+ <groupId>${javax.mail.groupId}</groupId>
+ <artifactId>${javax.mail.artifactId}</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.james</groupId>
+ <artifactId>apache-james-imap-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.james</groupId>
+ <artifactId>apache-james-imap-mailbox</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.james</groupId>
+ <artifactId>apache-james-imap-store</artifactId>
+ </dependency>
+
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>
Propchange: james/imap/trunk/memory/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Added:
james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/InMemoryMailbox.java
URL:
http://svn.apache.org/viewvc/james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/InMemoryMailbox.java?rev=781005&view=auto
==============================================================================
---
james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/InMemoryMailbox.java
(added)
+++
james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/InMemoryMailbox.java
Tue Jun 2 11:29:29 2009
@@ -0,0 +1,66 @@
+/****************************************************************
+ * 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.imap.inmemory;
+
+import java.util.concurrent.atomic.AtomicLong;
+
+import org.apache.james.imap.store.mail.model.Mailbox;
+
+/**
+ * Mailbox data which is stored only in memory.
+ */
+public class InMemoryMailbox implements Mailbox {
+
+ private final long id;
+ private AtomicLong nextUid;
+ private String name;
+
+ public InMemoryMailbox(final long id, final String name) {
+ super();
+ this.id = id;
+ this.name = name;
+ }
+
+ public void consumeUid() {
+ nextUid.incrementAndGet();
+ }
+
+ public long getLastUid() {
+ return nextUid.get();
+ }
+
+ public long getMailboxId() {
+ return id;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+
+ public long getUidValidity() {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public void setName(String name) {
+ this.name = name;
+ }
+}
Propchange:
james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/InMemoryMailbox.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/InMemoryMailboxManager.java
URL:
http://svn.apache.org/viewvc/james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/InMemoryMailboxManager.java?rev=781005&view=auto
==============================================================================
---
james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/InMemoryMailboxManager.java
(added)
+++
james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/InMemoryMailboxManager.java
Tue Jun 2 11:29:29 2009
@@ -0,0 +1,105 @@
+/****************************************************************
+ * 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.imap.inmemory;
+
+import java.util.List;
+
+import org.apache.james.imap.mailbox.MailboxNotFoundException;
+import org.apache.james.imap.mailbox.StorageException;
+import org.apache.james.imap.store.Authenticator;
+import org.apache.james.imap.store.StoreMailbox;
+import org.apache.james.imap.store.StoreMailboxManager;
+import org.apache.james.imap.store.Subscriber;
+import org.apache.james.imap.store.mail.MailboxMapper;
+import org.apache.james.imap.store.mail.model.Mailbox;
+
+public class InMemoryMailboxManager extends StoreMailboxManager implements
MailboxMapper {
+
+ public InMemoryMailboxManager(Authenticator authenticator, Subscriber
subscriber) {
+ super(authenticator, subscriber);
+ }
+
+ @Override
+ protected StoreMailbox createMailbox(Mailbox mailboxRow) {
+ return null;
+ }
+
+ @Override
+ protected MailboxMapper createMailboxMapper() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected void doCreate(String namespaceName) {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void begin() throws StorageException {}
+
+ public void commit() throws StorageException {}
+
+ public Mailbox consumeNextUid(long mailboxId) throws StorageException,
MailboxNotFoundException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public long countMailboxesWithName(String name) throws StorageException {
+ // TODO Auto-generated method stub
+ return 0;
+ }
+
+ public void delete(Mailbox mailbox) throws StorageException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public void deleteAll() throws StorageException {
+ // TODO Auto-generated method stub
+
+ }
+
+ public Mailbox findMailboxById(long mailboxId) throws StorageException,
MailboxNotFoundException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public Mailbox findMailboxByName(String name) throws StorageException,
MailboxNotFoundException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public List<Mailbox> findMailboxWithNameLike(String name) throws
StorageException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ public boolean hasChildren(String mailboxName, char hierarchyDeliminator)
throws StorageException {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ public void save(Mailbox mailbox) throws StorageException {
+ // TODO Auto-generated method stub
+
+ }
+
+}
Propchange:
james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/InMemoryMailboxManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/InMemoryStoreMailbox.java
URL:
http://svn.apache.org/viewvc/james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/InMemoryStoreMailbox.java?rev=781005&view=auto
==============================================================================
---
james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/InMemoryStoreMailbox.java
(added)
+++
james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/InMemoryStoreMailbox.java
Tue Jun 2 11:29:29 2009
@@ -0,0 +1,79 @@
+/****************************************************************
+ * 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.imap.inmemory;
+
+import java.util.Date;
+import java.util.List;
+
+import javax.mail.Flags;
+
+import org.apache.james.imap.mailbox.MailboxException;
+import org.apache.james.imap.store.StoreMailbox;
+import org.apache.james.imap.store.mail.MailboxMapper;
+import org.apache.james.imap.store.mail.MessageMapper;
+import org.apache.james.imap.store.mail.model.Header;
+import org.apache.james.imap.store.mail.model.Mailbox;
+import org.apache.james.imap.store.mail.model.MailboxMembership;
+import org.apache.james.imap.store.mail.model.PropertyBuilder;
+
+public class InMemoryStoreMailbox extends StoreMailbox {
+
+ public InMemoryStoreMailbox(Mailbox mailbox) {
+ super(mailbox);
+ }
+
+ @Override
+ protected MailboxMembership copyMessage(StoreMailbox toMailbox,
MailboxMembership originalMessage, long uid) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected Header createHeader(int lineNumber, String name, String value) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected MailboxMapper createMailboxMapper() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected MailboxMembership createMessage(Date internalDate, long uid, int
size, int bodyStartOctet, byte[] document, Flags flags, List<Header> headers,
PropertyBuilder propertyBuilder) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected MessageMapper createMessageMapper() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ protected Mailbox getMailboxRow() throws MailboxException {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+
+}
Propchange:
james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/InMemoryStoreMailbox.java
------------------------------------------------------------------------------
svn:eol-style = native
Added:
james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/InMemorySubscriptionManager.java
URL:
http://svn.apache.org/viewvc/james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/InMemorySubscriptionManager.java?rev=781005&view=auto
==============================================================================
---
james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/InMemorySubscriptionManager.java
(added)
+++
james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/InMemorySubscriptionManager.java
Tue Jun 2 11:29:29 2009
@@ -0,0 +1,172 @@
+/****************************************************************
+ * 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.imap.inmemory;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import org.apache.james.imap.store.StoreSubscriptionManager;
+import org.apache.james.imap.store.user.SubscriptionMapper;
+import org.apache.james.imap.store.user.model.Subscription;
+
+/**
+ * Stores subscriptions in memory.
+ */
+public class InMemorySubscriptionManager extends StoreSubscriptionManager
implements SubscriptionMapper {
+
+ private static final int INITIAL_SIZE = 64;
+ private final Map<String, List<Subscription>> subscriptionsByUser;
+
+ public InMemorySubscriptionManager() {
+ super();
+ subscriptionsByUser = new ConcurrentHashMap<String,
List<Subscription>>(INITIAL_SIZE);
+ }
+
+ @Override
+ protected SubscriptionMapper createMapper() {
+ return this;
+ }
+
+ @Override
+ protected Subscription createSubscription(String user, String mailbox) {
+ return new InMemorySubscription(mailbox, user);
+ }
+
+ public void begin() {
+ }
+
+ public void commit() {
+ }
+
+ public synchronized void delete(Subscription subscription) {
+ final String user = subscription.getUser();
+ final List<Subscription> subscriptions = subscriptionsByUser.get(user);
+ if (subscriptions != null) {
+ subscriptions.remove(subscription);
+ }
+ }
+
+ public Subscription findFindMailboxSubscriptionForUser(String user, String
mailbox) {
+ final List<Subscription> subscriptions = subscriptionsByUser.get(user);
+ Subscription result = null;
+ if (subscriptions != null) {
+ for(Subscription subscription:subscriptions) {
+ if (subscription.getMailbox().equals(mailbox)) {
+ result = subscription;
+ break;
+ }
+ }
+ }
+ return result;
+ }
+
+ @SuppressWarnings("unchecked")
+ public List<Subscription> findSubscriptionsForUser(String user) {
+ final List<Subscription> subcriptions = subscriptionsByUser.get(user);
+ final List<Subscription> results;
+ if (subcriptions == null) {
+ results = Collections.EMPTY_LIST;
+ } else {
+ // Make a copy to prevent concurrent modifications
+ results = new ArrayList<Subscription>(subcriptions);
+ }
+ return results;
+ }
+
+ public synchronized void save(Subscription subscription) {
+ final String user = subscription.getUser();
+ final List<Subscription> subscriptions = subscriptionsByUser.get(user);
+ if (subscriptions == null) {
+ final List<Subscription> newSubscriptions = new
ArrayList<Subscription>();
+ newSubscriptions.add(subscription);
+ subscriptionsByUser.put(user, newSubscriptions);
+ } else {
+ subscriptions.add(subscription);
+ }
+ }
+
+ private final static class InMemorySubscription implements Subscription {
+
+ private final String mailbox;
+ private final String user;
+
+ public InMemorySubscription(final String mailbox, final String user) {
+ super();
+ this.mailbox = mailbox;
+ this.user = user;
+ }
+
+ public String getMailbox() {
+ return mailbox;
+ }
+
+ public String getUser() {
+ return user;
+ }
+
+ @Override
+ public int hashCode() {
+ final int PRIME = 31;
+ int result = 1;
+ result = PRIME * result + ((mailbox == null) ? 0 :
mailbox.hashCode());
+ result = PRIME * result + ((user == null) ? 0 : user.hashCode());
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj)
+ return true;
+ if (obj == null)
+ return false;
+ if (getClass() != obj.getClass())
+ return false;
+ final InMemorySubscription other = (InMemorySubscription) obj;
+ if (mailbox == null) {
+ if (other.mailbox != null)
+ return false;
+ } else if (!mailbox.equals(other.mailbox))
+ return false;
+ if (user == null) {
+ if (other.user != null)
+ return false;
+ } else if (!user.equals(other.user))
+ return false;
+ return true;
+ }
+
+ /**
+ * Representation suitable for logging and debugging.
+ * @return a <code>String</code> representation
+ * of this object.
+ */
+ public String toString()
+ {
+ return "InMemorySubscription[ "
+ + "mailbox = " + this.mailbox + " "
+ + "user = " + this.user + " "
+ + " ]";
+ }
+
+ }
+}
Propchange:
james/imap/trunk/memory/src/main/java/org/apache/james/imap/inmemory/InMemorySubscriptionManager.java
------------------------------------------------------------------------------
svn:eol-style = native
Modified: james/imap/trunk/pom.xml
URL:
http://svn.apache.org/viewvc/james/imap/trunk/pom.xml?rev=781005&r1=781004&r2=781005&view=diff
==============================================================================
--- james/imap/trunk/pom.xml (original)
+++ james/imap/trunk/pom.xml Tue Jun 2 11:29:29 2009
@@ -43,7 +43,8 @@
<module>store</module>
<module>processor</module>
<module>torque</module>
- <module>jpa</module>
+ <module>jpa</module>
+ <module>memory</module>
<module>seda</module>
<module>deployment</module>
</modules>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]