Java 类org.apache.camel.util.URISupport 实例源码

项目:syndesis    文件:EndpointHandler.java   
private static String buildUri(Endpoint step) {
    String uri = step.getUri();
    Map<String, Object> properties = step.getProperties();

    if (!Strings.isEmpty(uri)) {
        if (ObjectHelper.isNotEmpty(properties)) {
            try {
                uri = URISupport.appendParametersToURI(uri, properties);
            } catch (UnsupportedEncodingException|URISyntaxException e) {
                throw ObjectHelper.wrapRuntimeCamelException(e);
            }
        }
    }

    return uri;
}
项目:syndesis    文件:ComponentProxyComponent.java   
@Override
protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
    // grab the regular query parameters
    Map<String, String> options = buildEndpointOptions(remaining, parameters);

    // create the uri of the base component
    String delegateUri = catalog.asEndpointUri(componentSchemeAlias.orElse(componentScheme), options, false);
    Endpoint delegate = getCamelContext().getEndpoint(delegateUri);

    LOGGER.info("Connector resolved: {} -> {}", URISupport.sanitizeUri(uri), URISupport.sanitizeUri(delegateUri));

    ComponentProxyEndpoint answer = new ComponentProxyEndpoint(uri, this, delegate);
    answer.setBeforeProducer(getBeforeProducer());
    answer.setAfterProducer(getAfterProducer());
    answer.setBeforeConsumer(getBeforeConsumer());
    answer.setAfterConsumer(getAfterConsumer());

    // clean-up parameters so that validation won't fail later on
    // in DefaultConnectorComponent.validateParameters()
    parameters.clear();

    return answer;
}
项目:Camel    文件:ManagedEndpointRegistry.java   
@SuppressWarnings("unchecked")
public TabularData listEndpoints() {
    try {
        TabularData answer = new TabularDataSupport(CamelOpenMBeanTypes.listEndpointsTabularType());
        Collection<Endpoint> endpoints = endpointRegistry.values();
        for (Endpoint endpoint : endpoints) {
            CompositeType ct = CamelOpenMBeanTypes.listEndpointsCompositeType();
            String url = endpoint.getEndpointUri();
            if (sanitize) {
                url = URISupport.sanitizeUri(url);
            }

            boolean fromStatic = endpointRegistry.isStatic(url);
            boolean fromDynamic = endpointRegistry.isDynamic(url);

            CompositeData data = new CompositeDataSupport(ct, new String[]{"url", "static", "dynamic"}, new Object[]{url, fromStatic, fromDynamic});
            answer.put(data);
        }
        return answer;
    } catch (Exception e) {
        throw ObjectHelper.wrapRuntimeCamelException(e);
    }
}
项目:Camel    文件:ConfigurationHelper.java   
public static void populateFromURI(CamelContext camelContext, EndpointConfiguration config, ParameterSetter setter) {
    URI uri = config.getURI();

    setter.set(camelContext, config, EndpointConfiguration.URI_SCHEME, uri.getScheme());
    setter.set(camelContext, config, EndpointConfiguration.URI_SCHEME_SPECIFIC_PART, uri.getSchemeSpecificPart());
    setter.set(camelContext, config, EndpointConfiguration.URI_AUTHORITY, uri.getAuthority());
    setter.set(camelContext, config, EndpointConfiguration.URI_USER_INFO, uri.getUserInfo());
    setter.set(camelContext, config, EndpointConfiguration.URI_HOST, uri.getHost());
    setter.set(camelContext, config, EndpointConfiguration.URI_PORT, Integer.toString(uri.getPort()));
    setter.set(camelContext, config, EndpointConfiguration.URI_PATH, uri.getPath());
    setter.set(camelContext, config, EndpointConfiguration.URI_QUERY, uri.getQuery());
    setter.set(camelContext, config, EndpointConfiguration.URI_FRAGMENT, uri.getFragment());

    // now parse query and set custom parameters
    Map<String, Object> parameters;
    try {
        parameters = URISupport.parseParameters(uri);
        for (Map.Entry<String, Object> pair : parameters.entrySet()) {
            setter.set(camelContext, config, pair.getKey(), pair.getValue());
        }
    } catch (URISyntaxException e) {
        throw new RuntimeCamelException(e);
    }
}
项目:Camel    文件:DefaultExecutorServiceManager.java   
@Override
public ExecutorService newThreadPool(Object source, String name, ThreadPoolProfile profile) {
    String sanitizedName = URISupport.sanitizeUri(name);
    ObjectHelper.notNull(profile, "ThreadPoolProfile");

    ThreadPoolProfile defaultProfile = getDefaultThreadPoolProfile();
    profile.addDefaults(defaultProfile);

    ThreadFactory threadFactory = createThreadFactory(sanitizedName, true);
    ExecutorService executorService = threadPoolFactory.newThreadPool(profile, threadFactory);
    onThreadPoolCreated(executorService, source, profile.getId());
    if (LOG.isDebugEnabled()) {
        LOG.debug("Created new ThreadPool for source: {} with name: {}. -> {}", source, sanitizedName, executorService);
    }

    return executorService;
}
项目:Camel    文件:NettyHttpHelper.java   
/**
 * Creates the URI to invoke.
 *
 * @param exchange the exchange
 * @param url      the url to invoke
 * @param endpoint the endpoint
 * @return the URI to invoke
 */
public static URI createURI(Exchange exchange, String url, NettyHttpEndpoint endpoint) throws URISyntaxException {
    URI uri = new URI(url);
    // is a query string provided in the endpoint URI or in a header
    // (header overrules endpoint, raw query header overrules query header)
    String queryString = exchange.getIn().getHeader(Exchange.HTTP_RAW_QUERY, String.class);
    if (queryString == null) {
        queryString = exchange.getIn().getHeader(Exchange.HTTP_QUERY, String.class);
    }
    if (queryString == null) {
        // use raw as we encode just below
        queryString = uri.getRawQuery();
    }
    if (queryString != null) {
        // need to encode query string
        queryString = UnsafeUriCharactersEncoder.encodeHttpURI(queryString);
        uri = URISupport.createURIWithQuery(uri, queryString);
    }
    return uri;
}
项目:Camel    文件:AhcHelper.java   
/**
 * Creates the URI to invoke.
 *
 * @param exchange the exchange
 * @param url      the url to invoke
 * @param endpoint the endpoint
 * @return the URI to invoke
 */
public static URI createURI(Exchange exchange, String url, AhcEndpoint endpoint) throws URISyntaxException {
    URI uri = new URI(url);
    // is a query string provided in the endpoint URI or in a header (header overrules endpoint)
    String queryString = exchange.getIn().getHeader(Exchange.HTTP_QUERY, String.class);
    if (queryString == null) {
        queryString = endpoint.getHttpUri().getRawQuery();
    }
    // We should user the query string from the HTTP_URI header
    if (queryString == null) {
        queryString = uri.getQuery();
    }
    if (queryString != null) {
        // need to encode query string
        queryString = UnsafeUriCharactersEncoder.encodeHttpURI(queryString);
        uri = URISupport.createURIWithQuery(uri, queryString);
    }
    return uri;
}
项目:Camel    文件:AtomComponent.java   
@Override
protected void afterConfiguration(String uri, String remaining, Endpoint endpoint, Map<String, Object> parameters) throws Exception {
    AtomEndpoint atom = (AtomEndpoint) endpoint;
    if (atom.getFeedUri() != null) {
        // already set so do not change it
        return;
    }

    // recreate feed uri after we have configured the endpoint so we can use the left over parameters
    // for the http feed
    String feedUri;
    if (!parameters.isEmpty()) {
        URI remainingUri = URISupport.createRemainingURI(new URI(remaining), parameters);
        feedUri = remainingUri.toString();
    } else {
        feedUri = remaining;
    }

    atom.setFeedUri(feedUri);
}
项目:Camel    文件:AvroComponent.java   
/**
 * A factory method allowing derived components to create a new endpoint
 * from the given URI, remaining path and optional parameters
 *
 * @param uri        the full URI of the endpoint
 * @param remaining  the remaining part of the URI without the query
 *                   parameters or component prefix
 * @param parameters the optional parameters passed in
 * @return a newly created endpoint or null if the endpoint cannot be
 *         created based on the inputs
 */
@Override
protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
    AvroConfiguration config;
    if (configuration != null) {
        config = configuration.copy();
    } else {
        config = new AvroConfiguration();
    }

    URI endpointUri = new URI(URISupport.normalizeUri(remaining));
    applyToConfiguration(config, endpointUri, parameters);

    if (AvroConstants.AVRO_NETTY_TRANSPORT.equals(endpointUri.getScheme())) {
        return new AvroNettyEndpoint(remaining, this, config);
    } else if (AvroConstants.AVRO_HTTP_TRANSPORT.equals(endpointUri.getScheme())) {
        return new AvroHttpEndpoint(remaining, this, config);
    } else {
        throw new IllegalArgumentException("Unknown avro scheme. Should use either netty or http.");
    }
}
项目:Camel    文件:HttpProxyTest.java   
@Test
public void testDifferentHttpProxyConfigured() throws Exception {
    HttpEndpoint http1 = context.getEndpoint("http://www.google.com?proxyHost=myproxy&proxyPort=1234", HttpEndpoint.class);
    HttpEndpoint http2 = context.getEndpoint("http://www.google.com?test=parameter&proxyHost=myotherproxy&proxyPort=2345", HttpEndpoint.class);


    HttpClient client1 = http1.createHttpClient();
    assertEquals("myproxy", client1.getHostConfiguration().getProxyHost());
    assertEquals(1234, client1.getHostConfiguration().getProxyPort());

    HttpClient client2 = http2.createHttpClient();
    assertEquals("myotherproxy", client2.getHostConfiguration().getProxyHost());
    assertEquals(2345, client2.getHostConfiguration().getProxyPort());

    //As the endpointUri is recreated, so the parameter could be in different place, so we use the URISupport.normalizeUri
    assertEquals("Get a wrong endpoint uri of http1", "http://www.google.com?proxyHost=myproxy&proxyPort=1234", URISupport.normalizeUri(http1.getEndpointUri()));
    assertEquals("Get a wrong endpoint uri of http2", "http://www.google.com?proxyHost=myotherproxy&proxyPort=2345&test=parameter", URISupport.normalizeUri(http2.getEndpointUri()));

    assertEquals("Should get the same EndpointKey", http1.getEndpointKey(), http2.getEndpointKey());
}
项目:Camel    文件:CamelNamespaceHandler.java   
private void findSchedulerUriComponent(String uri, Set<String> components) {

            // the input may use a scheduler which can be quartz or spring
            if (uri != null) {
                try {
                    URI u = new URI(uri);
                    Map<String, Object> parameters = URISupport.parseParameters(u);
                    Object value = parameters.get("scheduler");
                    if (value == null) {
                        value = parameters.get("consumer.scheduler");
                    }
                    if (value != null) {
                        // the scheduler can be quartz2 or spring based, so add reference to camel component
                        // from these components os blueprint knows about the requirement
                        String name = value.toString();
                        if ("quartz2".equals(name)) {
                            components.add("quartz2");
                        } else if ("spring".equals(name)) {
                            components.add("spring-event");
                        }
                    }
                } catch (URISyntaxException e) {
                    // ignore
                }
            }
        }
项目:Camel    文件:UndertowHelper.java   
/**
 * Creates the URI to invoke.
 *
 * @param exchange the exchange
 * @param url      the url to invoke
 * @param endpoint the endpoint
 * @return the URI to invoke
 */
public static URI createURI(Exchange exchange, String url, UndertowEndpoint endpoint) throws URISyntaxException {
    URI uri = new URI(url);
    // is a query string provided in the endpoint URI or in a header (header overrules endpoint)
    String queryString = exchange.getIn().getHeader(Exchange.HTTP_QUERY, String.class);
    if (queryString == null) {
        queryString = endpoint.getHttpURI().getRawQuery();
    }
    // We should user the query string from the HTTP_URI header
    if (queryString == null) {
        queryString = uri.getRawQuery();
    }
    if (queryString != null) {
        // need to encode query string
        queryString = UnsafeUriCharactersEncoder.encodeHttpURI(queryString);
        uri = URISupport.createURIWithQuery(uri, queryString);
    }
    return uri;
}
项目:Camel    文件:JMXConsumer.java   
/**
 * Schedules execution of the doStart() operation to occur again after the reconnect delay
 */
protected void scheduleDelayedStart() throws Exception {
    Runnable startRunnable = new Runnable() {
        @Override
        public void run() {
            try {
                doStart();
            } catch (Exception e) {
                LOG.error("An unrecoverable exception has occurred while starting the JMX consumer" 
                            + "for endpoint {}", URISupport.sanitizeUri(mJmxEndpoint.getEndpointUri()), e);
            }
        }
    };
    LOG.info("Delaying JMX consumer startup for endpoint {}. Trying again in {} seconds.",
            URISupport.sanitizeUri(mJmxEndpoint.getEndpointUri()), mJmxEndpoint.getReconnectDelay());
    getExecutor().schedule(startRunnable, mJmxEndpoint.getReconnectDelay(), TimeUnit.SECONDS);
}
项目:Camel    文件:JMXConsumer.java   
@Override
public void handleNotification(Notification notification, Object handback) {
    JMXConnectionNotification connectionNotification = (JMXConnectionNotification)notification;
    // only reset the connection if the notification is for the connection from this endpoint
    if (!connectionNotification.getConnectionId().equals(mConnectionId)) {
        return;
    }
    if (connectionNotification.getType().equals(JMXConnectionNotification.NOTIFS_LOST) 
                || connectionNotification.getType().equals(JMXConnectionNotification.CLOSED) 
                || connectionNotification.getType().equals(JMXConnectionNotification.FAILED)) {
        LOG.warn("Lost JMX connection for : {}", URISupport.sanitizeUri(mJmxEndpoint.getEndpointUri()));
        if (mJmxEndpoint.getReconnectOnConnectionFailure()) {
            scheduleReconnect();
        } else {
            LOG.warn("The JMX consumer will not be reconnected.  Use 'reconnectOnConnectionFailure' to "
                    + "enable reconnections.");
        }
    }
}
项目:Camel    文件:JMXConsumer.java   
/**
 * Schedules an attempt to re-initialize a lost connection after the reconnect delay
 */
protected void scheduleReconnect() {
    Runnable startRunnable = new Runnable() {
        @Override
        public void run() {
            try {
                initNetworkConnection();
                addNotificationListener();
            } catch (Exception e) {
                LOG.warn("Failed to reconnect to JMX server. >> {}", e.getMessage());
                scheduleReconnect();
            }
        }
    };
    LOG.info("Delaying JMX consumer reconnection for endpoint {}. Trying again in {} seconds.",
            URISupport.sanitizeUri(mJmxEndpoint.getEndpointUri()), mJmxEndpoint.getReconnectDelay());
    getExecutor().schedule(startRunnable, mJmxEndpoint.getReconnectDelay(), TimeUnit.SECONDS);
}
项目:Camel    文件:EndpointListCommand.java   
private Map<String, Integer> computeColumnWidths(final Iterable<Map<String, String>> endpoints) throws Exception {
    if (endpoints == null) {
        throw new IllegalArgumentException("Unable to determine column widths from null Iterable<Endpoint>");
    } else {
        int maxUriLen = 0;
        int maxStatusLen = 0;

        for (Map<String, String> row : endpoints) {
            String uri = row.get("uri");
            if (decode) {
                // decode uri so its more human readable
                uri = URLDecoder.decode(uri, "UTF-8");
            }
            // sanitize and mask uri so we dont see passwords
            uri = URISupport.sanitizeUri(uri);

            maxUriLen = java.lang.Math.max(maxUriLen, uri == null ? 0 : uri.length());

            final String status = row.get("state");
            maxStatusLen = java.lang.Math.max(maxStatusLen, status == null ? 0 : status.length());
        }

        final Map<String, Integer> retval = new Hashtable<String, Integer>();
        retval.put(URI_COLUMN_LABEL, maxUriLen);
        retval.put(STATUS_COLUMN_LABEL, maxStatusLen);

        return retval;
    }
}
项目:Camel    文件:RestDefinition.java   
/**
 * Transforms the rest api configuration into a {@link org.apache.camel.model.RouteDefinition} which
 * Camel routing engine uses to service the rest api docs.
 */
public static RouteDefinition asRouteApiDefinition(CamelContext camelContext, RestConfiguration configuration) {
    RouteDefinition answer = new RouteDefinition();

    // create the from endpoint uri which is using the rest-api component
    String from = "rest-api:" + configuration.getApiContextPath();

    // append options
    Map<String, Object> options = new HashMap<String, Object>();

    String routeId = configuration.getApiContextRouteId();
    if (routeId == null) {
        routeId = answer.idOrCreate(camelContext.getNodeIdFactory());
    }
    options.put("routeId", routeId);
    if (configuration.getComponent() != null && !configuration.getComponent().isEmpty()) {
        options.put("componentName", configuration.getComponent());
    }
    if (configuration.getApiContextIdPattern() != null) {
        options.put("contextIdPattern", configuration.getApiContextIdPattern());
    }

    if (!options.isEmpty()) {
        String query;
        try {
            query = URISupport.createQueryString(options);
        } catch (URISyntaxException e) {
            throw ObjectHelper.wrapRuntimeCamelException(e);
        }
        from = from + "?" + query;
    }

    // we use the same uri as the producer (so we have a little route for the rest api)
    String to = from;
    answer.fromRest(from);
    answer.id(routeId);
    answer.to(to);

    return answer;
}
项目:Camel    文件:InterceptSendToEndpointDefinition.java   
/**
 * Does the uri match the pattern.
 *
 * @param camelContext the CamelContext
 * @param uri the uri
 * @param pattern the pattern, which can be an endpoint uri as well
 * @return <tt>true</tt> if matched and we should intercept, <tt>false</tt> if not matched, and not intercept.
 */
protected boolean matchPattern(CamelContext camelContext, String uri, String pattern) {
    // match using the pattern as-is
    boolean match = EndpointHelper.matchEndpoint(camelContext, uri, pattern);
    if (!match) {
        try {
            // the pattern could be an uri, so we need to normalize it before matching again
            pattern = URISupport.normalizeUri(pattern);
            match = EndpointHelper.matchEndpoint(camelContext, uri, pattern);
        } catch (Exception e) {
            // ignore
        }
    }
    return match;
}
项目:Camel    文件:SendProcessor.java   
protected void doStart() throws Exception {
    if (producerCache == null) {
        // use a single producer cache as we need to only hold reference for one destination
        // and use a regular HashMap as we do not want a soft reference store that may get re-claimed when low on memory
        // as we want to ensure the producer is kept around, to ensure its lifecycle is fully managed,
        // eg stopping the producer when we stop etc.
        producerCache = new ProducerCache(this, camelContext, new HashMap<String, Producer>(1));
        // do not add as service as we do not want to manage the producer cache
    }
    ServiceHelper.startService(producerCache);

    // the destination could since have been intercepted by a interceptSendToEndpoint so we got to
    // lookup this before we can use the destination
    Endpoint lookup = camelContext.hasEndpoint(destination.getEndpointKey());
    if (lookup instanceof InterceptSendToEndpoint) {
        if (LOG.isDebugEnabled()) {
            LOG.debug("Intercepted sending to {} -> {}",
                    URISupport.sanitizeUri(destination.getEndpointUri()), URISupport.sanitizeUri(lookup.getEndpointUri()));
        }
        destination = lookup;
    }
    // warm up the producer by starting it so we can fail fast if there was a problem
    // however must start endpoint first
    ServiceHelper.startService(destination);

    // this SendProcessor is used a lot in Camel (eg every .to in the route DSL) and therefore we
    // want to optimize for regular producers, by using the producer directly instead of the ProducerCache
    // Only for pooled and non singleton producers we have to use the ProducerCache as it supports these
    // kind of producer better (though these kind of producer should be rare)

    Producer producer = producerCache.acquireProducer(destination);
    if (producer instanceof ServicePoolAware || !producer.isSingleton()) {
        // no we cannot optimize it - so release the producer back to the producer cache
        // and use the producer cache for sending
        producerCache.releaseProducer(destination, producer);
    } else {
        // yes we can optimize and use the producer directly for sending
        this.producer = AsyncProcessorConverterHelper.convert(producer);
    }
}
项目:Camel    文件:RecipientListProcessor.java   
protected ExchangePattern resolveExchangePattern(Object recipient) throws UnsupportedEncodingException, URISyntaxException, MalformedURLException {
    // trim strings as end users might have added spaces between separators
    if (recipient instanceof String) {
        String s = ((String) recipient).trim();
        // see if exchangePattern is a parameter in the url
        s = URISupport.normalizeUri(s);
        return EndpointHelper.resolveExchangePatternFromUrl(s);
    }
    return null;
}
项目:Camel    文件:Jt400Endpoint.java   
/**
 * Creates a new AS/400 data queue endpoint using the specified connection
 * pool.
 */
protected Jt400Endpoint(String endpointUri, Jt400Component component, AS400ConnectionPool connectionPool) throws CamelException {
    super(endpointUri, component);
    ObjectHelper.notNull(connectionPool, "connectionPool");
    try {
        configuration = new Jt400Configuration(endpointUri, connectionPool);
    } catch (URISyntaxException e) {
        throw new CamelException("Unable to parse URI for " + URISupport.sanitizeUri(endpointUri), e);
    }
}
项目:Camel    文件:ExchangeFailureHandledEvent.java   
@Override
public String toString() {
    if (isDeadLetterChannel()) {
        String uri = URISupport.sanitizeUri(deadLetterUri);
        return getExchange().getExchangeId() + " exchange failed: " + getExchange() + " but was handled by dead letter channel: " + uri;
    } else {
        return getExchange().getExchangeId() + " exchange failed: " + getExchange() + " but was processed by failure processor: " + failureHandler;
    }
}
项目:Camel    文件:IgniteComponent.java   
@Override
protected Endpoint createEndpoint(String uri, String remaining, Map<String, Object> parameters) throws Exception {
    ObjectHelper.notNull(getCamelContext(), "Camel Context");

    AbstractIgniteEndpoint answer = null;
    URI remainingUri = new URI(URISupport.normalizeUri(remaining));
    String scheme = remainingUri.getScheme();

    switch (scheme) {
    case "cache":
        answer = new IgniteCacheEndpoint(uri, remainingUri, parameters, this);
        break;
    case "compute":
        answer = new IgniteComputeEndpoint(uri, remainingUri, parameters, this);
        break;
    case "messaging":
        answer = new IgniteMessagingEndpoint(uri, remainingUri, parameters, this);
        break;
    case "events":
        answer = new IgniteEventsEndpoint(uri, remainingUri, parameters, this);
        break;
    case "set":
        answer = new IgniteSetEndpoint(uri, remainingUri, parameters, this);
        break;
    case "idgen":
        answer = new IgniteIdGenEndpoint(uri, remainingUri, parameters, this);
        break;
    case "queue":
        answer = new IgniteQueueEndpoint(uri, remainingUri, parameters, this);
        break;

    default:
        throw new MalformedURLException("An invalid Ignite endpoint URI was provided. Please check that "
                + "it starts with:" + " ignite:[cache/compute/messaging/...]:...");
    }

    setProperties(answer, parameters);

    return answer;
}
项目:Camel    文件:ManagedRecipientList.java   
@Override
public void init(ManagementStrategy strategy) {
    super.init(strategy);
    sanitize = strategy.getManagementAgent().getMask() != null ? strategy.getManagementAgent().getMask() : false;
    uri = getDefinition().getExpression().getExpression();
    if (sanitize) {
        uri = URISupport.sanitizeUri(uri);
    }
}
项目:Camel    文件:ManagedRecipientList.java   
@Override
public TabularData extendedInformation() {
    try {
        TabularData answer = new TabularDataSupport(CamelOpenMBeanTypes.endpointsUtilizationTabularType());

        EndpointUtilizationStatistics stats = processor.getEndpointUtilizationStatistics();
        if (stats != null) {
            for (Map.Entry<String, Long> entry : stats.getStatistics().entrySet()) {
                CompositeType ct = CamelOpenMBeanTypes.endpointsUtilizationCompositeType();
                String url = entry.getKey();
                if (sanitize) {
                    url = URISupport.sanitizeUri(url);
                }

                Long hits = entry.getValue();
                if (hits == null) {
                    hits = 0L;
                }

                CompositeData data = new CompositeDataSupport(ct, new String[]{"url", "hits"}, new Object[]{url, hits});
                answer.put(data);
            }
        }
        return answer;
    } catch (Exception e) {
        throw ObjectHelper.wrapRuntimeCamelException(e);
    }
}
项目:Camel    文件:ManagedSendProcessor.java   
public void init(ManagementStrategy strategy) {
    super.init(strategy);
    boolean sanitize = strategy.getManagementAgent().getMask() != null ? strategy.getManagementAgent().getMask() : false;
    if (sanitize) {
        destination = URISupport.sanitizeUri(processor.getDestination().getEndpointUri());
    } else {
        destination = processor.getDestination().getEndpointUri();
    }
}
项目:Camel    文件:ManagedEnricher.java   
public void init(ManagementStrategy strategy) {
    super.init(strategy);
    sanitize = strategy.getManagementAgent().getMask() != null ? strategy.getManagementAgent().getMask() : false;
    uri = getDefinition().getExpression().getExpression();
    if (sanitize) {
        uri = URISupport.sanitizeUri(uri);
    }
}
项目:Camel    文件:ManagedEnricher.java   
@Override
public TabularData extendedInformation() {
    try {
        TabularData answer = new TabularDataSupport(CamelOpenMBeanTypes.endpointsUtilizationTabularType());

        EndpointUtilizationStatistics stats = processor.getEndpointUtilizationStatistics();
        if (stats != null) {
            for (Map.Entry<String, Long> entry : stats.getStatistics().entrySet()) {
                CompositeType ct = CamelOpenMBeanTypes.endpointsUtilizationCompositeType();
                String url = entry.getKey();
                if (sanitize) {
                    url = URISupport.sanitizeUri(url);
                }

                Long hits = entry.getValue();
                if (hits == null) {
                    hits = 0L;
                }

                CompositeData data = new CompositeDataSupport(ct, new String[]{"url", "hits"}, new Object[]{url, hits});
                answer.put(data);
            }
        }
        return answer;
    } catch (Exception e) {
        throw ObjectHelper.wrapRuntimeCamelException(e);
    }
}
项目:Camel    文件:ManagedRoutingSlip.java   
@Override
public void init(ManagementStrategy strategy) {
    super.init(strategy);
    sanitize = strategy.getManagementAgent().getMask() != null ? strategy.getManagementAgent().getMask() : false;
    uri = getDefinition().getExpression().getExpression();
    if (sanitize) {
        uri = URISupport.sanitizeUri(uri);
    }
}
项目:Camel    文件:ManagedRoutingSlip.java   
@Override
public TabularData extendedInformation() {
    try {
        TabularData answer = new TabularDataSupport(CamelOpenMBeanTypes.endpointsUtilizationTabularType());

        EndpointUtilizationStatistics stats = processor.getEndpointUtilizationStatistics();
        if (stats != null) {
            for (Map.Entry<String, Long> entry : stats.getStatistics().entrySet()) {
                CompositeType ct = CamelOpenMBeanTypes.endpointsUtilizationCompositeType();
                String url = entry.getKey();
                if (sanitize) {
                    url = URISupport.sanitizeUri(url);
                }

                Long hits = entry.getValue();
                if (hits == null) {
                    hits = 0L;
                }

                CompositeData data = new CompositeDataSupport(ct, new String[]{"url", "hits"}, new Object[]{url, hits});
                answer.put(data);
            }
        }
        return answer;
    } catch (Exception e) {
        throw ObjectHelper.wrapRuntimeCamelException(e);
    }
}
项目:Camel    文件:ManagedDynamicRouter.java   
@Override
public void init(ManagementStrategy strategy) {
    super.init(strategy);
    sanitize = strategy.getManagementAgent().getMask() != null ? strategy.getManagementAgent().getMask() : false;
    uri = getDefinition().getExpression().getExpression();
    if (sanitize) {
        uri = URISupport.sanitizeUri(uri);
    }
}
项目:Camel    文件:ManagedDynamicRouter.java   
@Override
public TabularData extendedInformation() {
    try {
        TabularData answer = new TabularDataSupport(CamelOpenMBeanTypes.endpointsUtilizationTabularType());

        EndpointUtilizationStatistics stats = processor.getEndpointUtilizationStatistics();
        if (stats != null) {
            for (Map.Entry<String, Long> entry : stats.getStatistics().entrySet()) {
                CompositeType ct = CamelOpenMBeanTypes.endpointsUtilizationCompositeType();
                String url = entry.getKey();
                if (sanitize) {
                    url = URISupport.sanitizeUri(url);
                }

                Long hits = entry.getValue();
                if (hits == null) {
                    hits = 0L;
                }

                CompositeData data = new CompositeDataSupport(ct, new String[]{"url", "hits"}, new Object[]{url, hits});
                answer.put(data);
            }
        }
        return answer;
    } catch (Exception e) {
        throw ObjectHelper.wrapRuntimeCamelException(e);
    }
}
项目:Camel    文件:ManagedRuntimeEndpointRegistry.java   
@Override
public TabularData endpointStatistics() {
    try {
        TabularData answer = new TabularDataSupport(CamelOpenMBeanTypes.listRuntimeEndpointsTabularType());

        EndpointRegistry staticRegistry = getContext().getEndpointRegistry();
        int index = 0;

        for (RuntimeEndpointRegistry.Statistic stat : registry.getEndpointStatistics()) {
            CompositeType ct = CamelOpenMBeanTypes.listRuntimeEndpointsCompositeType();

            String url = stat.getUri();
            Boolean isStatic = staticRegistry.isStatic(url);
            Boolean isDynamic = staticRegistry.isDynamic(url);
            if (sanitize) {
                url = URISupport.sanitizeUri(url);
            }
            String routeId = stat.getRouteId();
            String direction = stat.getDirection();
            long hits = stat.getHits();

            CompositeData data = new CompositeDataSupport(ct, new String[]{"index", "url", "routeId", "direction", "static", "dynamic", "hits"},
                    new Object[]{index, url, routeId, direction, isStatic, isDynamic, hits});
            answer.put(data);

            // use a counter as the single index in the TabularData as we do not want a multi-value index
            index++;
        }
        return answer;
    } catch (Exception e) {
        throw ObjectHelper.wrapRuntimeCamelException(e);
    }
}
项目:Camel    文件:ManagedPollEnricher.java   
public void init(ManagementStrategy strategy) {
    super.init(strategy);
    sanitize = strategy.getManagementAgent().getMask() != null ? strategy.getManagementAgent().getMask() : false;
    uri = getDefinition().getExpression().getExpression();
    if (sanitize) {
        uri = URISupport.sanitizeUri(uri);
    }
}
项目:Camel    文件:ManagedPollEnricher.java   
@Override
public TabularData extendedInformation() {
    try {
        TabularData answer = new TabularDataSupport(CamelOpenMBeanTypes.endpointsUtilizationTabularType());

        EndpointUtilizationStatistics stats = processor.getEndpointUtilizationStatistics();
        if (stats != null) {
            for (Map.Entry<String, Long> entry : stats.getStatistics().entrySet()) {
                CompositeType ct = CamelOpenMBeanTypes.endpointsUtilizationCompositeType();
                String url = entry.getKey();
                if (sanitize) {
                    url = URISupport.sanitizeUri(url);
                }

                Long hits = entry.getValue();
                if (hits == null) {
                    hits = 0L;
                }

                CompositeData data = new CompositeDataSupport(ct, new String[]{"url", "hits"}, new Object[]{url, hits});
                answer.put(data);
            }
        }
        return answer;
    } catch (Exception e) {
        throw ObjectHelper.wrapRuntimeCamelException(e);
    }
}
项目:Camel    文件:ManagedWireTapProcessor.java   
public void init(ManagementStrategy strategy) {
    super.init(strategy);
    sanitize = strategy.getManagementAgent().getMask() != null ? strategy.getManagementAgent().getMask() : false;
    if (sanitize) {
        uri = URISupport.sanitizeUri(processor.getUri());
    } else {
        uri = processor.getUri();
    }
}
项目:Camel    文件:DdbProducer.java   
@Override
public String toString() {
    if (ddbProducerToString == null) {
        ddbProducerToString = "DdbProducer[" + URISupport.sanitizeUri(getEndpoint().getEndpointUri()) + "]";
    }
    return ddbProducerToString;
}
项目:Camel    文件:ManagedSendDynamicProcessor.java   
public void init(ManagementStrategy strategy) {
    super.init(strategy);
    this.sanitize = strategy.getManagementAgent().getMask() != null ? strategy.getManagementAgent().getMask() : false;
    if (sanitize) {
        uri = URISupport.sanitizeUri(processor.getUri());
    } else {
        uri = processor.getUri();
    }
}
项目:Camel    文件:ManagedSendDynamicProcessor.java   
@Override
public TabularData extendedInformation() {
    try {
        TabularData answer = new TabularDataSupport(CamelOpenMBeanTypes.endpointsUtilizationTabularType());

        EndpointUtilizationStatistics stats = processor.getEndpointUtilizationStatistics();
        if (stats != null) {
            for (Map.Entry<String, Long> entry : stats.getStatistics().entrySet()) {
                CompositeType ct = CamelOpenMBeanTypes.endpointsUtilizationCompositeType();
                String url = entry.getKey();
                if (sanitize) {
                    url = URISupport.sanitizeUri(url);
                }

                Long hits = entry.getValue();
                if (hits == null) {
                    hits = 0L;
                }

                CompositeData data = new CompositeDataSupport(ct, new String[]{"url", "hits"}, new Object[]{url, hits});
                answer.put(data);
            }
        }
        return answer;
    } catch (Exception e) {
        throw ObjectHelper.wrapRuntimeCamelException(e);
    }
}
项目:Camel    文件:DefaultManagementNamingStrategy.java   
protected String getEndpointId(Endpoint ep) {
    String answer = doGetEndpointId(ep);
    Boolean sanitize = camelContext != null && camelContext.getManagementStrategy().getManagementAgent().getMask();
    if (sanitize != null && sanitize) {
        // use xxxxxx as replacements as * has to be quoted for MBean names
        answer = URISupport.sanitizeUri(answer);
    }
    return answer;
}