Guice stuff.

This commit is contained in:
akwizgran
2011-07-13 17:05:25 +01:00
parent 48359ec478
commit d889a08cf4
3 changed files with 28 additions and 2 deletions

View File

@@ -27,6 +27,8 @@ import net.sf.briar.api.serial.Raw;
import net.sf.briar.api.serial.Reader;
import net.sf.briar.api.serial.ReaderFactory;
import com.google.inject.Inject;
/** A bundle that deserialises its contents on demand using a reader. */
class BundleReaderImpl implements BundleReader {
@@ -42,6 +44,7 @@ class BundleReaderImpl implements BundleReader {
private final BatchFactory batchFactory;
private State state = State.START;
@Inject
BundleReaderImpl(InputStream in, ReaderFactory readerFactory,
PublicKey publicKey, Signature signature,
MessageDigest messageDigest, MessageParser messageParser,

View File

@@ -1,6 +1,9 @@
package net.sf.briar.protocol;
import net.sf.briar.api.protocol.Message;
import net.sf.briar.api.protocol.BundleReader;
import net.sf.briar.api.protocol.BundleWriter;
import net.sf.briar.api.protocol.MessageEncoder;
import net.sf.briar.api.protocol.MessageParser;
import com.google.inject.AbstractModule;
@@ -8,6 +11,11 @@ public class ProtocolModule extends AbstractModule {
@Override
protected void configure() {
bind(Message.class).to(MessageImpl.class);
bind(BatchFactory.class).to(BatchFactoryImpl.class);
bind(BundleReader.class).to(BundleReaderImpl.class);
bind(BundleWriter.class).to(BundleWriterImpl.class);
bind(HeaderFactory.class).to(HeaderFactoryImpl.class);
bind(MessageEncoder.class).to(MessageEncoderImpl.class);
bind(MessageParser.class).to(MessageParserImpl.class);
}
}

View File

@@ -0,0 +1,15 @@
package net.sf.briar.serial;
import net.sf.briar.api.serial.ReaderFactory;
import net.sf.briar.api.serial.WriterFactory;
import com.google.inject.AbstractModule;
public class SerialModule extends AbstractModule {
@Override
protected void configure() {
bind(ReaderFactory.class).to(ReaderFactoryImpl.class);
bind(WriterFactory.class).to(WriterFactoryImpl.class);
}
}