/** * Additional properties for the entity manager to use. */ public Map<String, Object> getEntityManagerProperties() { if (entityManagerProperties == null) { entityManagerProperties = CastUtils.cast(System.getProperties()); } return entityManagerProperties; }
@Override public <T> Class<T> resolveClass(String name, Class<T> type) { return CastUtils.cast(resolveClass(name)); }
<T> Class<T> loadClass(Object o, ClassResolver resolver, Class<T> type) { if (o == null || o instanceof Class) { return CastUtils.cast((Class<?>) o); } String name = o.toString(); Class<T> c = resolver.resolveClass(name, type); if (c == null) { c = resolver.resolveClass(name, type, getClass().getClassLoader()); } if (c == null) { c = resolver.resolveClass(name, type, org.apache.kafka.clients.producer.KafkaProducer.class.getClassLoader()); } return c; }
@Override protected int poll() throws Exception { Queue<Exchange> exchanges; HttpClient client = HttpClientBuilder.create().useSystemProperties().build(); HttpPost httpPost = new HttpPost(slackEndpoint.getServerUrl() + "/api/channels.history"); List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>(); params.add(new BasicNameValuePair("channel", channelId)); if (ObjectHelper.isNotEmpty(timestamp)) { params.add(new BasicNameValuePair("oldest", timestamp)); } params.add(new BasicNameValuePair("count", slackEndpoint.getMaxResults())); params.add(new BasicNameValuePair("token", slackEndpoint.getToken())); httpPost.setEntity(new UrlEncodedFormEntity(params)); HttpResponse response = client.execute(httpPost); String jsonString = readResponse(response); JSONParser parser = new JSONParser(); JSONObject c = (JSONObject)parser.parse(jsonString); List list = (List)c.get("messages"); exchanges = createExchanges(list); return processBatch(CastUtils.cast(exchanges)); }
path.add(mainClasses); Set<Artifact> dependencies = CastUtils.cast(project.getArtifacts());
List<Artifact> dependencies = CastUtils.cast(executableProject.getDependencies()); = CastUtils.cast(MavenMetadataSource.createArtifacts(this.artifactFactory, dependencies, null, null, null)); metadataSource, new ScopeArtifactFilter(Artifact.SCOPE_RUNTIME), Collections.emptyList()); executableDependencies = CastUtils.cast(result.getArtifacts());
@Override protected int poll() throws Exception { shutdownRunningTask = null; pendingExchanges = 0; int max = getMaxMessagesPerPoll() > 0 ? getMaxMessagesPerPoll() : Integer.MAX_VALUE; Queue<Exchange> queue = new LinkedList<>(); Iterator<Object> keyIterator = dataStore.keyIterator(); int index = 0; while (keyIterator.hasNext() && index < max) { Object key = keyIterator.next(); Object value = dataStore.get(key); Exchange exchange = endpoint.createExchange(); exchange.setProperty(KratiConstants.KEY, key); exchange.getIn().setBody(value); queue.add(exchange); index++; } // did we cap at max? if (index == max && keyIterator.hasNext()) { log.debug("Limiting to maximum messages to poll {} as there were more messages in this poll.", max); } return queue.isEmpty() ? 0 : processBatch(CastUtils.cast(queue)); }
Map<String, String> userMetadata = CastUtils.cast(exchange.getIn().getHeader(S3Constants.USER_METADATA, Map.class)); if (userMetadata != null) { objectMetadata.setUserMetadata(userMetadata); Map<String, String> s3Headers = CastUtils.cast(exchange.getIn().getHeader(S3Constants.S3_HEADERS, Map.class)); if (s3Headers != null) { for (Map.Entry<String, String> entry : s3Headers.entrySet()) {
@Override public int processBatch(Queue<Object> exchanges) throws Exception { int total = exchanges.size(); int answer = total; for (int index = 0; index < total && isBatchAllowed(); index++) { // only loop if we are started (allowed to run) // use poll to remove the head so it does not consume memory even // after we have processed it Exchange exchange = (Exchange) exchanges.poll(); // add current index and total as properties exchange.setProperty(Exchange.BATCH_INDEX, index); exchange.setProperty(Exchange.BATCH_SIZE, total); exchange.setProperty(Exchange.BATCH_COMPLETE, index == total - 1); // update pending number of exchanges pendingExchanges = total - index - 1; boolean started = processExchange(exchange); // if we did not start processing then decrement the counter if (!started) { answer--; } } // drain any in progress files as we are done with this batch removeExcessiveInProgressTasks(CastUtils.cast((Queue<?>) exchanges, Exchange.class), 0); return answer; }
public void testEndpointAttributes() throws Exception { MBeanServer mbeanServer = getMBeanServer(); Set<ObjectName> s = CastUtils.cast(mbeanServer.queryNames(new ObjectName( "org.apache.camel:*,type=endpoints,name=\"some-ws-iti://data*\""), null)); ObjectName on = (ObjectName) s.toArray()[0]; assertEquals(SomeItiComponent.WS_CONFIG.isAddressing(), ((Boolean) mbeanServer.getAttribute(on, "Addressing")).booleanValue()); assertEquals(SomeItiComponent.WS_CONFIG.isMtom(), ((Boolean) mbeanServer.getAttribute(on, "Mtom")).booleanValue()); assertEquals(SomeItiComponent.WS_CONFIG.isSwaOutSupport(), ((Boolean) mbeanServer.getAttribute(on, "SwaOutSupport")).booleanValue()); }
int messagePolled = 0; try { messagePolled = processBatch(CastUtils.cast(answer)); } catch (Exception e) { if (e instanceof PersistenceException) {
if (lifecycle != null) { try { Class<CamelContextLifecycle<R>> clazz = CastUtils.cast(camelContext.getClassResolver().resolveMandatoryClass(lifecycle, CamelContextLifecycle.class)); camelContextLifecycle = camelContext.getInjector().newInstance(clazz); } catch (ClassNotFoundException e) {
@Override protected int poll() throws Exception { shutdownRunningTask = null; pendingExchanges = 0; Queue<Exchange> queue = new LinkedList<>(); String directory = endpoint.getDirectory(); ListContainerOptions opt = new ListContainerOptions(); if (!Strings.isNullOrEmpty(directory)) { opt = opt.inDirectory(directory); } for (StorageMetadata md : blobStore.list(container, opt.maxResults(maxMessagesPerPoll).recursive())) { String blobName = md.getName(); if (md.getType().equals(StorageType.BLOB)) { if (!Strings.isNullOrEmpty(blobName)) { InputStream body = JcloudsBlobStoreHelper.readBlob(blobStore, container, blobName); if (body != null) { Exchange exchange = endpoint.createExchange(); CachedOutputStream cos = new CachedOutputStream(exchange); IOHelper.copy(body, cos); exchange.getIn().setBody(cos.newStreamCache()); exchange.setProperty(JcloudsConstants.BLOB_NAME, blobName); queue.add(exchange); } } } } return queue.isEmpty() ? 0 : processBatch(CastUtils.cast(queue)); }
int rows = processBatch(CastUtils.cast(answer)); return rows;
Map<String, String> params = CastUtils.cast(parameters); answer.setParameters(params); setEndpointHeaderFilterStrategy(answer);
List<Object> headerListOfPayload = CastUtils.cast(payload.getHeaders()); if (headerListOfRequestContxt == headerListOfPayload) {
@Override protected int poll() throws Exception { Queue<Exchange> answer = new ArrayDeque<>(); if (ObjectHelper.isNotEmpty(getConfiguration().getRange())) { Sheets.Spreadsheets.Values.BatchGet request = getClient().spreadsheets().values().batchGet(getConfiguration().getSpreadsheetId()); request.setMajorDimension(getConfiguration().getMajorDimension()); request.setValueRenderOption(getConfiguration().getValueRenderOption()); if (getConfiguration().getRange().contains(",")) { request.setRanges(Arrays.stream(getConfiguration().getRange().split(",")) .map(String::trim) .collect(Collectors.toList())); } else { request.setRanges(Collections.singletonList(getConfiguration().getRange())); } BatchGetValuesResponse response = request.execute(); if (response.getValueRanges() != null) { response.getValueRanges() .stream() .limit(getConfiguration().getMaxResults()) .map(valueRange -> getEndpoint().createExchange(valueRange)) .forEach(answer::add); } } else { Sheets.Spreadsheets.Get request = getClient().spreadsheets().get(getConfiguration().getSpreadsheetId()); request.setIncludeGridData(getConfiguration().isIncludeGridData()); Spreadsheet spreadsheet = request.execute(); answer.add(getEndpoint().createExchange(spreadsheet)); } return processBatch(CastUtils.cast(answer)); }
return processBatch(CastUtils.cast(exchanges));
processBatch(CastUtils.cast(exchanges));
return processBatch(CastUtils.cast(answer));