Java 类org.apache.camel.model.ThreadPoolProfileDefinition 实例源码

项目:Camel    文件:AbstractCamelContextFactoryBean.java   
protected void initThreadPoolProfiles(T context) throws Exception {
    Set<String> defaultIds = new HashSet<String>();

    // lookup and use custom profiles from the registry
    Map<String, ThreadPoolProfile> profiles = context.getRegistry().findByTypeWithName(ThreadPoolProfile.class);
    if (profiles != null && !profiles.isEmpty()) {
        for (Entry<String, ThreadPoolProfile> entry : profiles.entrySet()) {
            ThreadPoolProfile profile = entry.getValue();
            // do not add if already added, for instance a tracer that is also an InterceptStrategy class
            if (profile.isDefaultProfile()) {
                LOG.info("Using custom default ThreadPoolProfile with id: {} and implementation: {}", entry.getKey(), profile);
                context.getExecutorServiceManager().setDefaultThreadPoolProfile(profile);
                defaultIds.add(entry.getKey());
            } else {
                context.getExecutorServiceManager().registerThreadPoolProfile(profile);
            }
        }
    }

    // use custom profiles defined in the CamelContext
    if (getThreadPoolProfiles() != null && !getThreadPoolProfiles().isEmpty()) {
        for (ThreadPoolProfileDefinition definition : getThreadPoolProfiles()) {
            if (definition.isDefaultProfile()) {
                LOG.info("Using custom default ThreadPoolProfile with id: {} and implementation: {}", definition.getId(), definition);
                context.getExecutorServiceManager().setDefaultThreadPoolProfile(asThreadPoolProfile(context, definition));
                defaultIds.add(definition.getId());
            } else {
                context.getExecutorServiceManager().registerThreadPoolProfile(asThreadPoolProfile(context, definition));
            }
        }
    }

    // validate at most one is defined
    if (defaultIds.size() > 1) {
        throw new IllegalArgumentException("Only exactly one default ThreadPoolProfile is allowed, was " + defaultIds.size() + " ids: " + defaultIds);
    }
}
项目:Camel    文件:AbstractCamelContextFactoryBean.java   
/**
 * Creates a {@link ThreadPoolProfile} instance based on the definition.
 *
 * @param context    the camel context
 * @return           the profile
 * @throws Exception is thrown if error creating the profile
 */
private ThreadPoolProfile asThreadPoolProfile(CamelContext context, ThreadPoolProfileDefinition definition) throws Exception {
    ThreadPoolProfile answer = new ThreadPoolProfile();
    answer.setId(definition.getId());
    answer.setDefaultProfile(definition.getDefaultProfile());
    answer.setPoolSize(CamelContextHelper.parseInteger(context, definition.getPoolSize()));
    answer.setMaxPoolSize(CamelContextHelper.parseInteger(context, definition.getMaxPoolSize()));
    answer.setKeepAliveTime(CamelContextHelper.parseLong(context, definition.getKeepAliveTime()));
    answer.setMaxQueueSize(CamelContextHelper.parseInteger(context, definition.getMaxQueueSize()));
    answer.setAllowCoreThreadTimeOut(CamelContextHelper.parseBoolean(context, definition.getAllowCoreThreadTimeOut()));
    answer.setRejectedPolicy(definition.getRejectedPolicy());
    answer.setTimeUnit(definition.getTimeUnit());
    return answer;
}
项目:Camel    文件:CamelContextFactoryBean.java   
public List<ThreadPoolProfileDefinition> getThreadPoolProfiles() {
    return threadPoolProfiles;
}
项目:Camel    文件:CamelContextFactoryBean.java   
public void setThreadPoolProfiles(List<ThreadPoolProfileDefinition> threadPoolProfiles) {
    this.threadPoolProfiles = threadPoolProfiles;
}
项目:Camel    文件:CamelContextFactoryBean.java   
public List<ThreadPoolProfileDefinition> getThreadPoolProfiles() {
    return threadPoolProfiles;
}
项目:Camel    文件:CamelContextFactoryBean.java   
public void setThreadPoolProfiles(List<ThreadPoolProfileDefinition> threadPoolProfiles) {
    this.threadPoolProfiles = threadPoolProfiles;
}
项目:Camel    文件:CamelContextFactoryBean.java   
public List<ThreadPoolProfileDefinition> getThreadPoolProfiles() {
    return threadPoolProfiles;
}
项目:Camel    文件:CamelContextFactoryBean.java   
public void setThreadPoolProfiles(List<ThreadPoolProfileDefinition> threadPoolProfiles) {
    this.threadPoolProfiles = threadPoolProfiles;
}
项目:switchyard    文件:CamelContextFactoryBeanDelegate.java   
@Override
public List<ThreadPoolProfileDefinition> getThreadPoolProfiles() {
    return _factoryBean.getThreadPoolProfiles();
}
项目:camel-cdi    文件:CamelContextFactoryBean.java   
public List<ThreadPoolProfileDefinition> getThreadPoolProfiles() {
    return threadPoolProfiles;
}
项目:camel-cdi    文件:CamelContextFactoryBean.java   
public void setThreadPoolProfiles(List<ThreadPoolProfileDefinition> threadPoolProfiles) {
    this.threadPoolProfiles = threadPoolProfiles;
}
项目:Camel    文件:AbstractCamelContextFactoryBean.java   
public abstract List<ThreadPoolProfileDefinition> getThreadPoolProfiles();