s243a

net/pterodactylus.sone.main.SonePlugin.runPlugin.soneModule

May 30th, 2015
449
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.75 KB | None | 0 0
  1. //Line 221 of https://github.com/Bombe/Sone/blob/next/src/main/java/net/pterodactylus/sone/main/SonePlugin.java
  2.         AbstractModule soneModule = new AbstractModule() {
  3.  
  4.             @Override
  5.             protected void configure() {
  6.                 bind(Core.class).in(Singleton.class);
  7.                 bind(MemoryDatabase.class).in(Singleton.class);
  8.                 bind(EventBus.class).toInstance(eventBus);
  9.                 bind(Configuration.class).toInstance(startConfiguration);
  10.                 bind(FreenetInterface.class).in(Singleton.class);
  11.                 bind(PluginConnector.class).in(Singleton.class);
  12.                 Context context = new Context("Sone");
  13.                 bind(Context.class).toInstance(context);
  14.                 bind(getOptionalContextTypeLiteral()).toInstance(of(context));
  15.                 bind(WebOfTrustConnector.class).in(Singleton.class);
  16.                 bind(WebOfTrustUpdater.class).in(Singleton.class);
  17.                 bind(IdentityManager.class).in(Singleton.class);
  18.                 bind(SonePlugin.class).toInstance(SonePlugin.this);
  19.                 bind(FcpInterface.class).in(Singleton.class);
  20.                 bind(Database.class).to(MemoryDatabase.class);
  21.                 bind(PostBuilderFactory.class).to(MemoryDatabase.class);
  22.                 bind(PostReplyBuilderFactory.class).to(MemoryDatabase.class);
  23.                 bind(SoneProvider.class).to(Core.class).in(Singleton.class);
  24.                 bind(PostProvider.class).to(MemoryDatabase.class);
  25.                 bindListener(Matchers.any(), new TypeListener() {
  26.  
  27.                     @Override
  28.                     public <I> void hear(TypeLiteral<I> typeLiteral, TypeEncounter<I> typeEncounter) {
  29.                         typeEncounter.register(new InjectionListener<I>() {
  30.  
  31.                             @Override
  32.                             public void afterInjection(I injectee) {
  33.                                 eventBus.register(injectee);
  34.                             }
  35.                         });
  36.                     }
  37.                 });
  38.             }
  39.  
  40.             private TypeLiteral<Optional<Context>> getOptionalContextTypeLiteral() {
  41.                 return new TypeLiteral<Optional<Context>>() {
  42.                 };
  43.             }
  44.  
  45.         }
Advertisement
Add Comment
Please, Sign In to add comment