import com.google.common.eventbus.EventBus;
import com.google.common.eventbus.Subscribe;
import com.google.inject.Inject;
+import com.google.inject.Singleton;
import freenet.keys.FreenetURI;
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
+@Singleton
public class Core extends AbstractService implements SoneProvider, PostProvider, PostReplyProvider {
/** The logger. */
import com.google.common.base.Function;
import com.google.common.eventbus.EventBus;
import com.google.inject.Inject;
+import com.google.inject.Singleton;
import freenet.client.ClientMetadata;
import freenet.client.FetchException;
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
+@Singleton
public class FreenetInterface {
/** The logger. */
import net.pterodactylus.sone.freenet.wot.OwnIdentity;
import net.pterodactylus.util.service.Service;
+import com.google.inject.ImplementedBy;
+
/**
* Updates WebOfTrust identity data.
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
+@ImplementedBy(WebOfTrustUpdaterImpl.class)
public interface WebOfTrustUpdater extends Service {
void setTrust(OwnIdentity truster, Identity trustee, Integer score, String comment);
import com.google.common.annotations.VisibleForTesting;
import com.google.inject.Inject;
+import com.google.inject.Singleton;
/**
* Updates WebOfTrust identity data in a background thread because communicating
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
+@Singleton
public class WebOfTrustUpdaterImpl extends AbstractService implements WebOfTrustUpdater {
/** The logger. */
package net.pterodactylus.sone.database;
+import net.pterodactylus.sone.database.memory.MemoryDatabase;
+
import com.google.common.util.concurrent.Service;
+import com.google.inject.ImplementedBy;
/**
* Database for Sone data. This interface combines the various provider, store,
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
+@ImplementedBy(MemoryDatabase.class)
public interface Database extends Service, PostDatabase, PostReplyDatabase, AlbumDatabase, ImageDatabase {
/**
package net.pterodactylus.sone.database;
+import net.pterodactylus.sone.database.memory.MemoryDatabase;
+
+import com.google.inject.ImplementedBy;
+
/**
* Factory for {@link PostBuilder}s.
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
+@ImplementedBy(MemoryDatabase.class)
public interface PostBuilderFactory {
/**
import java.util.Collection;
import net.pterodactylus.sone.data.Post;
+import net.pterodactylus.sone.database.memory.MemoryDatabase;
import com.google.common.base.Optional;
+import com.google.inject.ImplementedBy;
/**
* Interface for objects that can provide {@link Post}s by their ID.
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
+@ImplementedBy(MemoryDatabase.class)
public interface PostProvider {
/**
package net.pterodactylus.sone.database;
+import net.pterodactylus.sone.database.memory.MemoryDatabase;
+
+import com.google.inject.ImplementedBy;
+
/**
* Factory for {@link PostReplyBuilder}s.
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
+@ImplementedBy(MemoryDatabase.class)
public interface PostReplyBuilderFactory {
/**
import java.util.Collection;
+import net.pterodactylus.sone.core.Core;
import net.pterodactylus.sone.data.Sone;
import com.google.common.base.Optional;
+import com.google.inject.ImplementedBy;
/**
* Interface for objects that can provide {@link Sone}s by their ID.
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
+@ImplementedBy(Core.class)
public interface SoneProvider {
/**
import com.google.common.collect.TreeMultimap;
import com.google.common.util.concurrent.AbstractService;
import com.google.inject.Inject;
+import com.google.inject.Singleton;
/**
* Memory-based {@link PostDatabase} implementation.
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
+@Singleton
public class MemoryDatabase extends AbstractService implements Database {
/** The lock. */
import com.google.common.annotations.VisibleForTesting;
import com.google.inject.Inject;
+import com.google.inject.Singleton;
/**
* Implementation of an FCP interface for other clients or plugins to
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
+@Singleton
public class FcpInterface {
/**
import com.google.common.eventbus.EventBus;
import com.google.inject.Inject;
+import com.google.inject.Singleton;
import freenet.pluginmanager.FredPluginTalker;
import freenet.pluginmanager.PluginNotFoundException;
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
+@Singleton
public class PluginConnector implements FredPluginTalker {
/** The event bus. */
import net.pterodactylus.util.service.Service;
import com.google.common.eventbus.EventBus;
+import com.google.inject.ImplementedBy;
/**
* Connects to a {@link WebOfTrustConnector} and sends identity events to an
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
+@ImplementedBy(IdentityManagerImpl.class)
public interface IdentityManager extends Service {
boolean isConnected();
import com.google.common.collect.Sets;
import com.google.common.eventbus.EventBus;
import com.google.inject.Inject;
+import com.google.inject.Singleton;
/**
* The identity manager takes care of loading and storing identities, their
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
+@Singleton
public class IdentityManagerImpl extends AbstractService implements IdentityManager {
/** The logger. */
import com.google.common.collect.MapMaker;
import com.google.common.eventbus.Subscribe;
import com.google.inject.Inject;
+import com.google.inject.Singleton;
import freenet.support.SimpleFieldSet;
import freenet.support.api.Bucket;
*
* @author <a href="mailto:bombe@pterodactylus.net">David ‘Bombe’ Roden</a>
*/
+@Singleton
public class WebOfTrustConnector {
/** The logger. */
@Override
protected void configure() {
- bind(Core.class).in(Singleton.class);
- bind(MemoryDatabase.class).in(Singleton.class);
bind(EventBus.class).toInstance(eventBus);
bind(Configuration.class).toInstance(startConfiguration);
- bind(FreenetInterface.class).in(Singleton.class);
- bind(PluginConnector.class).in(Singleton.class);
Context context = new Context("Sone");
bind(Context.class).toInstance(context);
bind(getOptionalContextTypeLiteral()).toInstance(of(context));
- bind(WebOfTrustConnector.class).in(Singleton.class);
- bind(WebOfTrustUpdater.class).to(WebOfTrustUpdaterImpl.class).in(Singleton.class);
- bind(IdentityManager.class).to(IdentityManagerImpl.class).in(Singleton.class);
bind(SonePlugin.class).toInstance(SonePlugin.this);
- bind(FcpInterface.class).in(Singleton.class);
- bind(Database.class).to(MemoryDatabase.class);
- bind(PostBuilderFactory.class).to(MemoryDatabase.class);
- bind(PostReplyBuilderFactory.class).to(MemoryDatabase.class);
- bind(SoneProvider.class).to(Core.class).in(Singleton.class);
- bind(PostProvider.class).to(MemoryDatabase.class);
bindListener(Matchers.any(), new TypeListener() {
@Override