@Override public <T> BeanLocator.LocatorInstance<T> newInstance(final Class<T> expected, final String batchId) { if (delegate == null) { return null; } try { final Object result = instantiationMethod.invoke(delegate, batchId); return new BeanLocator.LocatorInstance<T>(expected.cast(getValue.invoke(result)), Closeable.class.cast(getReleasable.invoke(result))); } catch (final Exception e) { throw new BatchRuntimeException(e); } } }
@Override public void open(final Serializable checkpoint) throws Exception { final CsvWriterMapper defaultMapper = mapping != null ? new DefaultMapper(Thread.currentThread().getContextClassLoader().loadClass(mapping)) : null; mapperInstance = mapper == null ? (defaultMapper != null ? new BeanLocator.LocatorInstance<CsvWriterMapper>(defaultMapper, null) : null) : BeanLocator.Finder.get(locator).newInstance(CsvWriterMapper.class, mapper); if ((header == null || header.isEmpty()) && Boolean.parseBoolean(writeHeaders) && DefaultMapper.class.isInstance(mapperInstance.getValue()) && checkpoint == null) { header = toListString(DefaultMapper.class.cast(mapperInstance.getValue()).getHeaders()); } final CSVFormat format = newFormat(); final File file = new File(output); if (!file.getParentFile().exists() && !file.getParentFile().mkdirs()) { throw new IllegalStateException("Cant create " + file); } this.transactionalWriter = new TransactionalWriter(file, encoding, checkpoint); this.writer = format.print(transactionalWriter); }
protected BeanLocator.LocatorInstance<EntityManagerProvider> findEntityManager() { if (entityManagerProvider != null && entityManagerProvider.startsWith("jndi:")) { return new BeanLocator.LocatorInstance<EntityManagerProvider>(new JndiEntityManagerProvider(entityManagerProvider.substring("jndi:".length())), null); } return BeanLocator.Finder.get(locator).newInstance(EntityManagerProvider.class, entityManagerProvider); }
@Override public void open(final Serializable checkpoint) throws Exception { final CSVFormat csvFormat = newFormat(); parser = csvFormat.parse(newReader()); iterator = new IteratorReader<CSVRecord>(parser.iterator()); mapperInstance = mapper == null ? new BeanLocator.LocatorInstance<CsvReaderMapper>( mapping != null ? new DefaultMapper(Thread.currentThread().getContextClassLoader().loadClass(mapping)) : NOOP_MAPPER, null) : BeanLocator.Finder.get(locator).newInstance(CsvReaderMapper.class, mapper); super.open(checkpoint); }
@Override public <T> LocatorInstance<T> newInstance(final Class<T> expected, final String batchId) { final CamelItemProcessor camelItemProcessor = new CamelItemProcessor(); camelItemProcessor.setEndpoint(batchId); camelItemProcessor.setLocator(locator); return new LocatorInstance<T>((T) camelItemProcessor, null); } }
private static BeanLocator.LocatorInstance<CamelTemplateLocator> locator(final String locator) { if (locator == null) { return new BeanLocator.LocatorInstance<CamelTemplateLocator>(DefaultCamelTemplateLocator.INSTANCE, null); } return BeanLocator.Finder.get(locator).newInstance(CamelTemplateLocator.class, locator); }