Hi guys,
I have several classes which interact with Cassandra. All of the
implementations implement both the I/O interface required (similar to a
DAO) and a Migrator interface. I want to be able to have an implementation
that is simply a MigrationManager interface. For this interface, I would
have the following impl.
/**
* @author tnine
*/
public class MigrationManagerImpl implements MigrationManager {
private final Set<Migration> migrations;
@Inject
public MigrationManagerImpl( final Set<Migration> migrations ) {
this.migrations = migrations;
}
@Override
public void migrate() {
for(Migration migration: migrations){
for( ColumnFamilyDefinition cf : migration.getColumnFamilies())
{
//do migration here.
}
}
}
}
I'm new to Guice, it seems much cleaner and more deterministic/easier to
user than Spring. I'm trying to keep all my low level I/O components in
their own Module. To do what I need above, how would I set this up in my
module? I've tried this.
public class CollectionModule extends AbstractModule{
/**
* The location of the properties file
*/
private static final String CASS_PROPS = "cassandra.properties";
@Override
protected void configure() {
//bind our cassandra properties
Names.bindProperties(binder(), PropertyUtils.loadFromClassPath(
CASS_PROPS));
//Load the cassandra url if set on the system properties
Names.bindProperties( binder(), PropertyUtils.loadSystemProperties(
AstynaxKeyspaceProvider.getRuntimeOptions() ) );
//bind our keyspace to the AstynaxKeyspaceProvider
bind(Keyspace.class).toProvider(AstynaxKeyspaceProvider.class );
bind(
MvccEntitySerializationStrategy.class).to(MvccEntitySerializationStrategyImpl.class);
bind(
MvccLogEntrySerializationStrategy.class).to(MvccLogEntrySerializationStrategyImpl.class);
//how do I bind both of the impls above to a Collection<Migration>
}
}
Do I need to also add the MvccEntitySerializationStrategyImpl and the
MvccLogEntrySerializationStrategyImpl classes to a Multibindings for the
Migration interface?
Thanks,
Todd
--
You received this message because you are subscribed to the Google Groups
"google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice.
For more options, visit https://groups.google.com/groups/opt_out.