@Override public void contribute(MetadataBuilder metadataBuilder, StandardServiceRegistry serviceRegistry) { DialectResolver dialectResolver = serviceRegistry.getService(DialectResolver.class); if ((dialectResolver instanceof DialectResolverSet)) { ((DialectResolverSet) dialectResolver).addResolver(resolver); } }
@Before public void setup() { initializer = new SQLiteMetadataBuilderInitializer(); metadataBuilder = mock(MetadataBuilder.class); registry = mock(StandardServiceRegistry.class); resolver = mock(DialectResolverSet.class); when(registry.getService(DialectResolver.class)).thenReturn(resolver); }
@Override public boolean matches(Object object) { DialectResolver actual = (DialectResolver) object; DialectResolutionInfo info = mock(DialectResolutionInfo.class); when(info.getDatabaseName()).thenReturn(databaseName); if ("SQLite".equals(databaseName)) { return actual.resolveDialect(info) instanceof SQLiteDialect; } else { return actual.resolveDialect(info) == null; } }
@Override public DialectResolver initiateService(Map configurationValues, ServiceRegistryImplementor registry) { final DialectResolverSet resolver = new DialectResolverSet(); applyCustomerResolvers( resolver, registry, configurationValues ); resolver.addResolver(StandardDialectResolver.INSTANCE ); return resolver; }
@Override @SuppressWarnings({ CompilerWarnings.RAWTYPES }) public SdcctHsqlDialectResolver initiateService(Map configValues, ServiceRegistryImplementor serviceRegistry) { serviceRegistry.locateServiceBinding(DialectResolver.class).setService(SdcctHsqlDialectResolver.INSTANCE); return SdcctHsqlDialectResolver.INSTANCE; }
@Override public void injectServices(ServiceRegistryImplementor serviceRegistry) { this.strategySelector = serviceRegistry.getService( StrategySelector.class ); this.dialectResolver = serviceRegistry.getService( DialectResolver.class ); }
@Override public Class<DialectResolver> getServiceInitiated() { return DialectResolver.class; }
public DialectResolverSet() { this( new ArrayList<DialectResolver>() ); }
public DialectResolverSet(List<DialectResolver> resolvers) { this.resolvers = resolvers; }
public DialectResolverSet(DialectResolver... resolvers) { this( Arrays.asList( resolvers ) ); }
@LogMessage(level = WARN) @Message(value = "Error executing resolver [%s] : %s", id = 316) void unableToExecuteResolver(DialectResolver abstractDialectResolver, String message);
/** * Intended only for use from testing. * * @param dialectResolver The DialectResolver to use */ public void setDialectResolver(DialectResolver dialectResolver) { this.dialectResolver = dialectResolver; }
/** * Add a resolver at the end of the underlying resolver list. The resolver added by this method is at lower * priority than any other existing resolvers. * * @param resolver The resolver to add. */ public void addResolver(DialectResolver resolver) { resolvers.add( resolver ); }
/** * Add a resolver at the beginning of the underlying resolver list. The resolver added by this method is at higher * priority than any other existing resolvers. * * @param resolver The resolver to add. */ public void addResolverAtFirst(DialectResolver resolver) { resolvers.add( 0, resolver ); }