Java 类org.apache.camel.spi.PackageScanClassResolver 实例源码

项目:Camel    文件:BaseTypeConverterRegistry.java   
public BaseTypeConverterRegistry(PackageScanClassResolver resolver, Injector injector, FactoryFinder factoryFinder) {
    this.resolver = resolver;
    this.injector = injector;
    this.factoryFinder = factoryFinder;
    this.typeConverterLoaders.add(new AnnotationTypeConverterLoader(resolver));

    // add to string first as it will then be last in the last as to string can nearly
    // always convert something to a string so we want it only as the last resort
    // ToStringTypeConverter should NOT allow to be promoted
    addFallbackTypeConverter(new ToStringTypeConverter(), false);
    // enum is okay to be promoted
    addFallbackTypeConverter(new EnumTypeConverter(), true);
    // arrays is okay to be promoted
    addFallbackTypeConverter(new ArrayTypeConverter(), true);
    // and future should also not allowed to be promoted
    addFallbackTypeConverter(new FutureTypeConverter(this), false);
    // add sync processor to async processor converter is to be promoted
    addFallbackTypeConverter(new AsyncProcessorTypeConverter(), true);
}
项目:switchyard    文件:SwitchYardCamelContextImpl.java   
/**
 * Associates camel context with given service domain.
 * 
 * @param domain Domain to associate.
 */
public void setServiceDomain(ServiceDomain domain) {
    _domain = domain;

    for (EventNotifier notifier : getManagementStrategy().getEventNotifiers()) {
        if (notifier instanceof CamelEventBridge) {
            ((CamelEventBridge) notifier).setEventPublisher(domain.getEventPublisher());
        }
    }

    PackageScanClassResolver packageScanClassResolver = findPackageScanClassResolver();
    if (packageScanClassResolver != null) {
        setPackageScanClassResolver(packageScanClassResolver);
    }

    _domain.setProperty(CAMEL_CONTEXT_PROPERTY, this);
}
项目:Camel    文件:PackageScanRouteBuilderFinder.java   
public PackageScanRouteBuilderFinder(BlueprintCamelContext camelContext, String[] packages, ClassLoader classLoader,
                                     PackageScanClassResolver resolver) {
    this.camelContext = camelContext;
    this.blueprintContainer = camelContext.getBlueprintContainer();
    this.packages = packages;
    this.resolver = resolver;
    // add our provided loader as well
    resolver.addClassLoader(classLoader);
}
项目:Camel    文件:AnnotationModelLoader.java   
public AnnotationModelLoader(PackageScanClassResolver resolver) {
    this.resolver = resolver;

    annotations = new LinkedHashSet<Class<? extends Annotation>>();
    annotations.add(CsvRecord.class);
    annotations.add(Link.class);
    annotations.add(Message.class);
    annotations.add(Section.class);
    annotations.add(FixedLengthRecord.class);
}
项目:Camel    文件:PackageScanRouteBuilderFinder.java   
public PackageScanRouteBuilderFinder(SpringCamelContext camelContext, String[] packages, ClassLoader classLoader,
                                     BeanPostProcessor postProcessor, PackageScanClassResolver resolver) {
    this.camelContext = camelContext;
    this.applicationContext = camelContext.getApplicationContext();
    this.packages = packages;
    this.beanPostProcessor = postProcessor;
    this.resolver = resolver;
    // add our provided loader as well
    resolver.addClassLoader(classLoader);
}
项目:switchyard    文件:SwitchYardCamelContextImpl.java   
/**
 * Get the first PackageScanClassResolver Service found on the classpath.
 * 
 * @return The first PackageScanClassResolver Service found on the classpath.
 */
public PackageScanClassResolver findPackageScanClassResolver() {
    final ServiceLoader<PackageScanClassResolver> resolverLoaders = ServiceLoader.load(PackageScanClassResolver.class);

    for (PackageScanClassResolver packageScanClassResolver : resolverLoaders) {
        return packageScanClassResolver;
    }

    return null;
}
项目:Camel    文件:AnnotationTypeConverterLoader.java   
public AnnotationTypeConverterLoader(PackageScanClassResolver resolver) {
    this.resolver = resolver;
}
项目:Camel    文件:AnnotationTypeConverterLoader.java   
/**
 * Filters the given list of packages and returns an array of <b>only</b> package names.
 * <p/>
 * This implementation will check the given list of packages, and if it contains a class name,
 * that class will be loaded directly and added to the list of classes. This optimizes the
 * type converter to avoid excessive file scanning for .class files.
 *
 * @param resolver the class resolver
 * @param packageNames the package names
 * @param classes to add loaded @Converter classes
 * @return the filtered package names
 */
protected String[] filterPackageNamesOnly(PackageScanClassResolver resolver, String[] packageNames, Set<Class<?>> classes) {
    if (packageNames == null || packageNames.length == 0) {
        return packageNames;
    }

    // optimize for CorePackageScanClassResolver
    if (resolver.getClassLoaders().isEmpty()) {
        return packageNames;
    }

    // the filtered packages to return
    List<String> packages = new ArrayList<String>();

    // try to load it as a class first
    for (String name : packageNames) {
        // must be a FQN class name by having an upper case letter
        if (StringHelper.isClassName(name)) {
            Class<?> clazz = null;
            for (ClassLoader loader : resolver.getClassLoaders()) {
                try {
                    clazz = ObjectHelper.loadClass(name, loader);
                    LOG.trace("Loaded {} as class {}", name, clazz);
                    classes.add(clazz);
                    // class founder, so no need to load it with another class loader
                    break;
                } catch (Throwable e) {
                    // do nothing here
                }
            }
            if (clazz == null) {
                // ignore as its not a class (will be package scan afterwards)
                packages.add(name);
            }
        } else {
            // ignore as its not a class (will be package scan afterwards)
            packages.add(name);
        }
    }

    // return the packages which is not FQN classes
    return packages.toArray(new String[packages.size()]);
}
项目:Camel    文件:LazyLoadingTypeConverter.java   
public LazyLoadingTypeConverter(PackageScanClassResolver resolver, Injector injector, FactoryFinder factoryFinder) {
    super(resolver, injector, factoryFinder);
}
项目:Camel    文件:DefaultTypeConverter.java   
public DefaultTypeConverter(PackageScanClassResolver resolver, Injector injector, FactoryFinder factoryFinder) {
    super(resolver, injector, factoryFinder);
}
项目:Camel    文件:DefaultCamelContext.java   
public PackageScanClassResolver getPackageScanClassResolver() {
    return packageScanClassResolver;
}
项目:Camel    文件:DefaultCamelContext.java   
public void setPackageScanClassResolver(PackageScanClassResolver packageScanClassResolver) {
    this.packageScanClassResolver = packageScanClassResolver;
}
项目:Camel    文件:ModelSanityCheckerTest.java   
private Set<Class<?>> discoverJaxbClasses() {
    PackageScanClassResolver resolver = new DefaultPackageScanClassResolver();
    String[] packages = Constants.JAXB_CONTEXT_PACKAGES.split(":");
    return resolver.findAnnotated(XmlAccessorType.class, packages);
}
项目:Camel    文件:PackageScanRouteBuilderFinder.java   
PackageScanRouteBuilderFinder(CamelContext camelContext, String[] packages, ClassLoader classLoader, PackageScanClassResolver resolver) {
    this.camelContext = camelContext;
    this.packages = packages;
    this.resolver = resolver;
    resolver.addClassLoader(classLoader);
}
项目:Camel    文件:AnnotationModelLoader.java   
public AnnotationModelLoader(PackageScanClassResolver resolver, PackageScanFilter filter) {
    this(resolver);
    this.filter = filter;
}
项目:microservice-bundle    文件:ManagedCamelContext.java   
@Override
public PackageScanClassResolver getPackageScanClassResolver() {
  return context.getPackageScanClassResolver();
}
项目:microservice-bundle    文件:ManagedCamelContext.java   
@Override
public void setPackageScanClassResolver(PackageScanClassResolver resolver) {
  context.setPackageScanClassResolver(resolver);
}
项目:switchyard    文件:CamelActivatorTest.java   
@Test
public void setCustomClassPathResolver() {
    final PackageScanClassResolver p = _camelContext.getPackageScanClassResolver();
    assertThat(p, is(instanceOf(CustomPackageScanResolver.class)));
}
项目:dropwizard-camel    文件:ManagedCamelContext.java   
@Override
public PackageScanClassResolver getPackageScanClassResolver() {
    return context.getPackageScanClassResolver();
}
项目:dropwizard-camel    文件:ManagedCamelContext.java   
@Override
public void setPackageScanClassResolver(PackageScanClassResolver resolver) {
    context.setPackageScanClassResolver(resolver);
}
项目:camel-cdi    文件:PackageScanRouteBuilderFinder.java   
PackageScanRouteBuilderFinder(CamelContext camelContext, String[] packages, ClassLoader classLoader, PackageScanClassResolver resolver) {
    this.camelContext = camelContext;
    this.packages = packages;
    this.resolver = resolver;
    resolver.addClassLoader(classLoader);
}
项目:wildfly-camel    文件:PackageScanClassResolverAssociationHandler.java   
@Override
public void setup(CamelContext camelctx) {
    PackageScanClassResolver resolver = new PackageScanClassResolverImpl(moduleClassLoader);
    camelctx.setPackageScanClassResolver(resolver);
}
项目:Camel    文件:CamelContext.java   
/**
 * Returns the package scanning class resolver
 *
 * @return the resolver
 */
PackageScanClassResolver getPackageScanClassResolver();
项目:Camel    文件:CamelContext.java   
/**
 * Sets the package scanning class resolver to use
 *
 * @param resolver the resolver
 */
void setPackageScanClassResolver(PackageScanClassResolver resolver);