Ejemplo n.º 1
0
  public void configure(Binder binder) {

    // expose user-provided ROP properties as the main properties map
    binder.<String>bindMap(Constants.PROPERTIES_MAP).putAll(properties);

    binder.bind(ObjectContextFactory.class).to(CayenneContextFactory.class);
    binder
        .bind(ROPSerializationService.class)
        .toProvider(ClientHessianSerializationServiceProvider.class);
    binder.bind(RemoteService.class).to(ProxyRemoteService.class);
    binder.bind(ClientConnection.class).toProvider(HttpClientConnectionProvider.class);
    binder.bind(EventManager.class).to(DefaultEventManager.class);
    binder.bind(RuntimeProperties.class).to(DefaultRuntimeProperties.class);
    binder.bind(DataChannel.class).toProvider(ClientChannelProvider.class);
    binder.bind(QueryCache.class).toProvider(MapQueryCacheProvider.class);
  }
Ejemplo n.º 2
0
 @Override
 public void configure(Binder binder) {
   binder.bind(EntitySorter.class).to(CayenneEntitySorter.class);
 }
Ejemplo n.º 3
0
  public void configure(Binder binder) {

    // configure global stack properties
    binder
        .bindMap(Constants.PROPERTIES_MAP)
        .put(
            Constants.SERVER_MAX_ID_QUALIFIER_SIZE_PROPERTY,
            String.valueOf(DEFAULT_MAX_ID_QUALIFIER_SIZE));

    binder.bind(JdbcEventLogger.class).to(CommonsJdbcEventLogger.class);
    binder.bind(ClassLoaderManager.class).to(DefaultClassLoaderManager.class);
    binder.bind(AdhocObjectFactory.class).to(DefaultAdhocObjectFactory.class);

    // configure known DbAdapter detectors in reverse order of popularity.
    // Users can
    // add their own to install custom adapters automatically

    // a bit ugly - need to bind all sniffers explicitly first before
    // placing then in a list
    binder.bind(FirebirdSniffer.class).to(FirebirdSniffer.class);
    binder.bind(OpenBaseSniffer.class).to(OpenBaseSniffer.class);
    binder.bind(FrontBaseSniffer.class).to(FrontBaseSniffer.class);
    binder.bind(IngresSniffer.class).to(IngresSniffer.class);
    binder.bind(SQLiteSniffer.class).to(SQLiteSniffer.class);
    binder.bind(DB2Sniffer.class).to(DB2Sniffer.class);
    binder.bind(H2Sniffer.class).to(H2Sniffer.class);
    binder.bind(HSQLDBSniffer.class).to(HSQLDBSniffer.class);
    binder.bind(SybaseSniffer.class).to(SybaseSniffer.class);
    binder.bind(DerbySniffer.class).to(DerbySniffer.class);
    binder.bind(SQLServerSniffer.class).to(SQLServerSniffer.class);
    binder.bind(OracleSniffer.class).to(OracleSniffer.class);
    binder.bind(PostgresSniffer.class).to(PostgresSniffer.class);
    binder.bind(MySQLSniffer.class).to(MySQLSniffer.class);

    binder
        .bindList(Constants.SERVER_ADAPTER_DETECTORS_LIST)
        .add(FirebirdSniffer.class)
        .add(OpenBaseSniffer.class)
        .add(FrontBaseSniffer.class)
        .add(IngresSniffer.class)
        .add(SQLiteSniffer.class)
        .add(DB2Sniffer.class)
        .add(H2Sniffer.class)
        .add(HSQLDBSniffer.class)
        .add(SybaseSniffer.class)
        .add(DerbySniffer.class)
        .add(SQLServerSniffer.class)
        .add(OracleSniffer.class)
        .add(PostgresSniffer.class)
        .add(MySQLSniffer.class);

    // configure an empty filter chain
    binder.bindList(Constants.SERVER_DOMAIN_FILTERS_LIST);

    // configure extended types
    binder
        .bindList(Constants.SERVER_DEFAULT_TYPES_LIST)
        .add(new VoidType())
        .add(new BigDecimalType())
        .add(new BigIntegerType())
        .add(new BooleanType())
        .add(new ByteArrayType(false, true))
        .add(new ByteType(false))
        .add(new CharType(false, true))
        .add(new DateType())
        .add(new DoubleType())
        .add(new FloatType())
        .add(new IntegerType())
        .add(new LongType())
        .add(new ShortType(false))
        .add(new TimeType())
        .add(new TimestampType())
        .add(new UtilDateType())
        .add(new CalendarType<GregorianCalendar>(GregorianCalendar.class))
        .add(new CalendarType<Calendar>(Calendar.class))
        .add(new UUIDType());
    binder.bindList(Constants.SERVER_USER_TYPES_LIST);
    binder.bindList(Constants.SERVER_TYPE_FACTORIES_LIST);

    // configure explicit configurations
    ListBuilder<Object> locationsListBuilder =
        binder.bindList(Constants.SERVER_PROJECT_LOCATIONS_LIST);
    for (String location : configurationLocations) {
      locationsListBuilder.add(location);
    }

    binder.bind(ConfigurationNameMapper.class).to(DefaultConfigurationNameMapper.class);

    binder.bind(EventManager.class).to(DefaultEventManager.class);

    binder.bind(QueryCache.class).toProvider(MapQueryCacheProvider.class);

    // a service to provide the main stack DataDomain
    binder.bind(DataDomain.class).toProvider(DataDomainProvider.class);

    binder.bind(DataNodeFactory.class).to(DefaultDataNodeFactory.class);

    // will return DataDomain for request for a DataChannel
    binder.bind(DataChannel.class).toProvider(DomainDataChannelProvider.class);

    binder.bind(ObjectContextFactory.class).to(DataContextFactory.class);

    binder.bind(TransactionFactory.class).to(DefaultTransactionFactory.class);

    // a service to load project XML descriptors
    binder.bind(DataChannelDescriptorLoader.class).to(XMLDataChannelDescriptorLoader.class);
    binder.bind(DataChannelDescriptorMerger.class).to(DefaultDataChannelDescriptorMerger.class);

    // a service to load DataMap XML descriptors
    binder.bind(DataMapLoader.class).to(XMLDataMapLoader.class);

    // a locator of resources, such as XML descriptors
    binder.bind(ResourceLocator.class).to(ClassLoaderResourceLocator.class);
    binder
        .bind(Key.get(ResourceLocator.class, Constants.SERVER_RESOURCE_LOCATOR))
        .to(ClassLoaderResourceLocator.class);

    // a global properties object
    binder.bind(RuntimeProperties.class).to(DefaultRuntimeProperties.class);

    // a service to load DataSourceFactories. DelegatingDataSourceFactory
    // will attempt
    // to find the actual worker factory dynamically on each call depending
    // on
    // DataNodeDescriptor data and the environment
    binder.bind(DataSourceFactory.class).to(DelegatingDataSourceFactory.class);

    // a default SchemaUpdateStrategy (used when no explicit strategy is
    // specified in
    // XML)
    binder.bind(SchemaUpdateStrategy.class).to(SkipSchemaUpdateStrategy.class);

    // a default DBAdapterFactory used to load custom and automatic
    // DbAdapters
    binder.bind(DbAdapterFactory.class).to(DefaultDbAdapterFactory.class);

    // binding AshwoodEntitySorter without scope, as this is a stateful
    // object and is
    // configured by the owning domain
    binder.bind(EntitySorter.class).to(AshwoodEntitySorter.class).withoutScope();

    binder.bind(BatchTranslatorFactory.class).to(DefaultBatchTranslatorFactory.class);
    binder.bind(SelectTranslatorFactory.class).to(DefaultSelectTranslatorFactory.class);

    // a default ObjectMapRetainStrategy used to create objects map for
    // ObjectStore
    binder.bind(ObjectMapRetainStrategy.class).to(DefaultObjectMapRetainStrategy.class);

    // a default ObjectStoreFactory used to create ObjectStores for contexts
    binder.bind(ObjectStoreFactory.class).to(DefaultObjectStoreFactory.class);

    binder.bind(TransactionManager.class).to(DefaultTransactionManager.class);
    binder.bind(RowReaderFactory.class).to(DefaultRowReaderFactory.class);

    binder.bind(SQLTemplateProcessor.class).to(VelocitySQLTemplateProcessor.class);
  }