Skip to content

Commit

Permalink
JAMES-2586 PostgresRecipientRewriteTableDAO and PostgresRecipientRewr…
Browse files Browse the repository at this point in the history
…iteTable
  • Loading branch information
hung phan authored and vttranlina committed Apr 16, 2024
1 parent f6e87b8 commit 72042f2
Show file tree
Hide file tree
Showing 13 changed files with 286 additions and 441 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
<persistence-unit name="Global" transaction-type="RESOURCE_LOCAL">
<class>org.apache.james.mailrepository.jpa.model.JPAUrl</class>
<class>org.apache.james.mailrepository.jpa.model.JPAMail</class>
<class>org.apache.james.rrt.jpa.model.JPARecipientRewrite</class>
<class>org.apache.james.sieve.postgres.model.JPASieveScript</class>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public class PostgresDataModule extends AbstractModule {
protected void configure() {
install(new CoreDataModule());
install(new PostgresDomainListModule());
install(new JPARecipientRewriteTableModule());
install(new PostgresRecipientRewriteTableModule());
install(new JPAMailRepositoryModule());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,37 +16,44 @@
* specific language governing permissions and limitations *
* under the License. *
****************************************************************/

package org.apache.james.modules.data;

import org.apache.james.backends.postgres.PostgresModule;
import org.apache.james.rrt.api.AliasReverseResolver;
import org.apache.james.rrt.api.CanSendFrom;
import org.apache.james.rrt.api.RecipientRewriteTable;
import org.apache.james.rrt.jpa.JPARecipientRewriteTable;
import org.apache.james.rrt.lib.AliasReverseResolverImpl;
import org.apache.james.rrt.lib.CanSendFromImpl;
import org.apache.james.rrt.postgres.PostgresRecipientRewriteTable;
import org.apache.james.rrt.postgres.PostgresRecipientRewriteTableDAO;
import org.apache.james.server.core.configuration.ConfigurationProvider;
import org.apache.james.utils.InitializationOperation;
import org.apache.james.utils.InitilizationOperationBuilder;

import com.google.inject.AbstractModule;
import com.google.inject.Scopes;
import com.google.inject.multibindings.Multibinder;
import com.google.inject.multibindings.ProvidesIntoSet;

public class JPARecipientRewriteTableModule extends AbstractModule {
public class PostgresRecipientRewriteTableModule extends AbstractModule {
@Override
public void configure() {
bind(JPARecipientRewriteTable.class).in(Scopes.SINGLETON);
bind(RecipientRewriteTable.class).to(JPARecipientRewriteTable.class);
bind(PostgresRecipientRewriteTable.class).in(Scopes.SINGLETON);
bind(PostgresRecipientRewriteTableDAO.class).in(Scopes.SINGLETON);
bind(RecipientRewriteTable.class).to(PostgresRecipientRewriteTable.class);
bind(AliasReverseResolverImpl.class).in(Scopes.SINGLETON);
bind(AliasReverseResolver.class).to(AliasReverseResolverImpl.class);
bind(CanSendFromImpl.class).in(Scopes.SINGLETON);
bind(CanSendFrom.class).to(CanSendFromImpl.class);

Multibinder.newSetBinder(binder(), PostgresModule.class).addBinding().toInstance(org.apache.james.rrt.postgres.PostgresRecipientRewriteTableModule.MODULE);
}

@ProvidesIntoSet
InitializationOperation configureRRT(ConfigurationProvider configurationProvider, JPARecipientRewriteTable recipientRewriteTable) {
InitializationOperation configureRecipientRewriteTable(ConfigurationProvider configurationProvider, PostgresRecipientRewriteTable recipientRewriteTable) {
return InitilizationOperationBuilder
.forClass(JPARecipientRewriteTable.class)
.forClass(PostgresRecipientRewriteTable.class)
.init(() -> recipientRewriteTable.configure(configurationProvider.getConfiguration("recipientrewritetable")));
}
}
2 changes: 0 additions & 2 deletions server/data/data-postgres/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,6 @@
<version>${apache.openjpa.version}</version>
<configuration>
<includes>org/apache/james/sieve/postgres/model/JPASieveScript.class,
org/apache/james/rrt/jpa/model/JPARecipientRewrite.class,
org/apache/james/mailrepository/jpa/model/JPAUrl.class,
org/apache/james/mailrepository/jpa/model/JPAMail.class</includes>
<addDefaultConstructor>true</addDefaultConstructor>
Expand All @@ -169,7 +168,6 @@
<property>
<name>metaDataFactory</name>
<value>jpa(Types=org.apache.james.sieve.postgres.model.JPASieveScript;
org.apache.james.rrt.jpa.model.JPARecipientRewrite;
org.apache.james.mailrepository.jpa.model.JPAUrl;
org.apache.james.mailrepository.jpa.model.JPAMail)</value>
</property>
Expand Down

This file was deleted.

Loading

0 comments on commit 72042f2

Please sign in to comment.