Created
July 7, 2014 18:26
-
-
Save gissuebot/584ae7127343eedf6da6 to your computer and use it in GitHub Desktop.
Migrated attachment for Guice issue 488, comment 0
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.google.forumbotty.guice; | |
import java.util.logging.Logger; | |
import javax.jdo.JDOHelper; | |
import javax.jdo.PersistenceManagerFactory; | |
import com.aggfi.portfolio.wave.server.InfoServlet; | |
import com.aggfi.portfolio.wave.server.dao.InfoDao; | |
import com.aggfi.portfolio.wave.server.dao.InfoDaoImpl; | |
import com.google.forumbotty.ForumBotty; | |
import com.google.forumbotty.admin.JsonRpcProcessor; | |
import com.google.forumbotty.dao.AdminConfigDao; | |
import com.google.forumbotty.dao.AdminConfigDaoImpl; | |
import com.google.forumbotty.dao.DigestDao; | |
import com.google.forumbotty.dao.DigestDaoImpl; | |
import com.google.forumbotty.dao.ForumPostDao; | |
import com.google.forumbotty.dao.ForumPostDaoImpl; | |
import com.google.forumbotty.dao.TagDao; | |
import com.google.forumbotty.dao.TagDaoImpl; | |
import com.google.forumbotty.dao.UserNotificationDao; | |
import com.google.forumbotty.dao.UserNotificationDaoImpl; | |
import com.google.forumbotty.feeds.AtomGenerator; | |
import com.google.forumbotty.feeds.GetForumPosts; | |
import com.google.forumbotty.feeds.GetLatestDigest; | |
import com.google.forumbotty.feeds.GetPostCounts; | |
import com.google.forumbotty.feeds.GetTagCounts; | |
import com.google.forumbotty.feeds.JsonGenerator; | |
import com.google.forumbotty.notification.AddParticipantsTask; | |
import com.google.forumbotty.notification.SendEmailUpdates; | |
import com.google.forumbotty.notification.SendWaveUpdates; | |
import com.google.inject.AbstractModule; | |
import com.google.inject.Guice; | |
import com.google.inject.Injector; | |
import com.google.inject.Provides; | |
import com.google.inject.Singleton; | |
import com.google.inject.servlet.GuiceServletContextListener; | |
import com.google.inject.servlet.ServletModule; | |
public class GuiceServletConfig extends GuiceServletContextListener { | |
private static final Logger LOG = Logger.getLogger(GuiceServletConfig.class.getName()); | |
@Override | |
protected Injector getInjector() { | |
ServletModule servletModule = new ServletModule() { | |
@Override | |
protected void configureServlets() { | |
serveRegex("\\/_wave/.*").with(ForumBotty.class); | |
serve("/admin/jsonrpc").with(JsonRpcProcessor.class); | |
serve("/send_email_updates").with(SendEmailUpdates.class); | |
serve("/send_wave_updates").with(SendWaveUpdates.class); | |
serve("/add_participants_task").with(AddParticipantsTask.class); | |
serve("/feeds/get_tag_counts").with(GetTagCounts.class); | |
serve("/feeds/get_post_counts").with(GetPostCounts.class); | |
serve("/feeds/get_forum_posts").with(GetForumPosts.class); | |
serve("/feeds/get_latest_digest").with(GetLatestDigest.class); | |
serve("/feeds/json").with(JsonGenerator.class); | |
serve("/feeds/atom").with(AtomGenerator.class); | |
serve("/info").with(InfoServlet.class); //TODO remove | |
//serve("/migrateTags").with(MigrateTags.class); | |
//serve("/migrateTagsTask").with(MigrateTagsTask.class); | |
} | |
}; | |
AbstractModule businessModule = new AbstractModule() { | |
@Override | |
protected void configure() { | |
bind(ForumPostDao.class).to(ForumPostDaoImpl.class); | |
bind(TagDao.class).to(TagDaoImpl.class); | |
bind(UserNotificationDao.class).to(UserNotificationDaoImpl.class); | |
bind(AdminConfigDao.class).to(AdminConfigDaoImpl.class); | |
bind(DigestDao.class).to(DigestDaoImpl.class); | |
bind(InfoDao.class).to(InfoDaoImpl.class);//TODO | |
} | |
@Provides | |
@Singleton | |
PersistenceManagerFactory getPmf() { | |
return JDOHelper.getPersistenceManagerFactory("transactions-optional"); | |
} | |
}; | |
return Guice.createInjector(servletModule, businessModule); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment