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

项目:Camel    文件:OsgiDataFormatResolver.java   
protected DataFormat getDataFormat(String name, CamelContext context) {
    LOG.trace("Finding DataFormat: {}", name);
    try {
        ServiceReference<?>[] refs = bundleContext.getServiceReferences(DataFormatResolver.class.getName(), "(dataformat=" + name + ")");
        if (refs != null) {
            for (ServiceReference<?> ref : refs) {
                Object service = bundleContext.getService(ref);
                if (DataFormatResolver.class.isAssignableFrom(service.getClass())) {
                    DataFormatResolver resolver = (DataFormatResolver) service;
                    return resolver.resolveDataFormat(name, context);
                }
            }
        }
        return null;
    } catch (InvalidSyntaxException e) {
        throw ObjectHelper.wrapRuntimeCamelException(e);
    }
}
项目:Camel    文件:BlueprintDataFormatResolver.java   
@Override
public DataFormat resolveDataFormat(String name, CamelContext context) {
    try {
        Object bean = context.getRegistry().lookupByName(".camelBlueprint.dataformatResolver." + name);
        if (bean instanceof DataFormatResolver) {
            LOG.debug("Found dataformat resolver: {} in registry: {}", name, bean);
            return ((DataFormatResolver) bean).resolveDataFormat(name, context);
        }
    } catch (Exception e) {
        LOG.trace("Ignored error looking up bean: " + name + " due: " + e.getMessage(), e);
    }
    return super.resolveDataFormat(name, context);
}
项目:Camel    文件:CamelNamespaceHandler.java   
private static ComponentMetadata getDataformatResolverReference(ParserContext context, String dataformat) {
    // we cannot resolve dataformat names using property placeholders at this point in time
    if (dataformat.startsWith(PropertiesComponent.DEFAULT_PREFIX_TOKEN)) {
        return null;
    }
    ComponentDefinitionRegistry componentDefinitionRegistry = context.getComponentDefinitionRegistry();
    ComponentMetadata cm = componentDefinitionRegistry.getComponentDefinition(".camelBlueprint.dataformatResolver." + dataformat);
    if (cm == null) {
        MutableReferenceMetadata svc = context.createMetadata(MutableReferenceMetadata.class);
        svc.setId(".camelBlueprint.dataformatResolver." + dataformat);
        svc.setFilter("(dataformat=" + dataformat + ")");
        svc.setAvailability(componentDefinitionRegistry.containsComponentDefinition(dataformat) ? AVAILABILITY_OPTIONAL : AVAILABILITY_MANDATORY);
        try {
            // Try to set the runtime interface (only with aries blueprint > 0.1
            svc.getClass().getMethod("setRuntimeInterface", Class.class).invoke(svc, DataFormatResolver.class);
        } catch (Throwable t) {
            // Check if the bundle can see the class
            try {
                PassThroughMetadata ptm = (PassThroughMetadata) componentDefinitionRegistry.getComponentDefinition("blueprintBundle");
                Bundle b = (Bundle) ptm.getObject();
                if (b.loadClass(DataFormatResolver.class.getName()) != DataFormatResolver.class) {
                    throw new UnsupportedOperationException();
                }
                svc.setInterface(DataFormatResolver.class.getName());
            } catch (Throwable t2) {
                throw new UnsupportedOperationException();
            }
        }
        componentDefinitionRegistry.registerComponentDefinition(svc);
        cm = svc;
    }
    return cm;
}
项目:Camel    文件:DefaultCamelContext.java   
public DataFormatResolver getDataFormatResolver() {
    return dataFormatResolver;
}
项目:Camel    文件:DefaultCamelContext.java   
public void setDataFormatResolver(DataFormatResolver dataFormatResolver) {
    this.dataFormatResolver = dataFormatResolver;
}
项目:Camel    文件:Activator.java   
public void register() {
    doRegister(DataFormatResolver.class, "dataformat", dataformats.keySet());
}
项目:microservice-bundle    文件:ManagedCamelContext.java   
@Override
public DataFormatResolver getDataFormatResolver() {
  return context.getDataFormatResolver();
}
项目:microservice-bundle    文件:ManagedCamelContext.java   
@Override
public void setDataFormatResolver(DataFormatResolver dataFormatResolver) {
  context.setDataFormatResolver(dataFormatResolver);
}
项目:dropwizard-camel    文件:ManagedCamelContext.java   
@Override
public DataFormatResolver getDataFormatResolver() {
    return context.getDataFormatResolver();
}
项目:dropwizard-camel    文件:ManagedCamelContext.java   
@Override
public void setDataFormatResolver(DataFormatResolver dataFormatResolver) {
    context.setDataFormatResolver(dataFormatResolver);
}
项目:Camel    文件:CamelContext.java   
/**
 * Gets the current data format resolver
 *
 * @return the resolver
 */
DataFormatResolver getDataFormatResolver();
项目:Camel    文件:CamelContext.java   
/**
 * Sets a custom data format resolver
 *
 * @param dataFormatResolver the resolver
 */
void setDataFormatResolver(DataFormatResolver dataFormatResolver);