当前位置: 首页>>代码示例>>Java>>正文


Java Registry类代码示例

本文整理汇总了Java中org.apache.camel.spi.Registry的典型用法代码示例。如果您正苦于以下问题:Java Registry类的具体用法?Java Registry怎么用?Java Registry使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Registry类属于org.apache.camel.spi包,在下文中一共展示了Registry类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: unregisterExecutorComponent

import org.apache.camel.spi.Registry; //导入依赖的package包/类
@SuppressWarnings("Convert2streamapi")
private void unregisterExecutorComponent(Executor... executors) {
	for (Executor executor : executors) {
		//unregister beans
		Registry registry = context.getRegistry();
		if (registry instanceof PropertyPlaceholderDelegateRegistry) {
			registry = ((PropertyPlaceholderDelegateRegistry) registry).getRegistry();
		}
		SimpleRegistry openexRegistry = (SimpleRegistry) registry;
		Set<Map.Entry<String, Object>> beansEntries = executor.beans().entrySet();
		for (Map.Entry<String, Object> beansEntry : beansEntries) {
			if (openexRegistry.containsKey(beansEntry.getKey())) {
				openexRegistry.remove(beansEntry.getKey());
			}
		}
		//unregister components
		Set<String> keys = executor.components().keySet();
		for (String key : keys) {
			if (context.getComponentNames().contains(key)) {
				context.removeComponent(key);
			}
		}
	}
}
 
开发者ID:LuatixHQ,项目名称:openex-worker,代码行数:25,代码来源:OpenexContext.java

示例2: registerExecutorComponent

import org.apache.camel.spi.Registry; //导入依赖的package包/类
@SuppressWarnings("Convert2streamapi")
private void registerExecutorComponent(Executor... executors) {
	for (Executor executor : executors) {
		//register beans
		Registry registry = context.getRegistry();
		if (registry instanceof PropertyPlaceholderDelegateRegistry) {
			registry = ((PropertyPlaceholderDelegateRegistry) registry).getRegistry();
		}
		SimpleRegistry openexRegistry = (SimpleRegistry) registry;
		Set<Map.Entry<String, Object>> beansEntries = executor.beans().entrySet();
		for (Map.Entry<String, Object> beansEntry : beansEntries) {
			if (!openexRegistry.containsKey(beansEntry.getKey())) {
				openexRegistry.put(beansEntry.getKey(), beansEntry.getValue());
			}
		}
		//register components
		Set<Map.Entry<String, org.apache.camel.Component>> components = executor.components().entrySet();
		for (Map.Entry<String, org.apache.camel.Component> entry : components) {
			if (!context.getComponentNames().contains(entry.getKey())) {
				context.addComponent(entry.getKey(), entry.getValue());
			}
		}
	}
}
 
开发者ID:LuatixHQ,项目名称:openex-worker,代码行数:25,代码来源:OpenexContext.java

示例3: getRegistry

import org.apache.camel.spi.Registry; //导入依赖的package包/类
public <T> T getRegistry(Class<T> type) {
    Registry reg = getRegistry();

    // unwrap the property placeholder delegate
    if (reg instanceof PropertyPlaceholderDelegateRegistry) {
        reg = ((PropertyPlaceholderDelegateRegistry) reg).getRegistry();
    }

    if (type.isAssignableFrom(reg.getClass())) {
        return type.cast(reg);
    } else if (reg instanceof CompositeRegistry) {
        List<Registry> list = ((CompositeRegistry) reg).getRegistryList();
        for (Registry r : list) {
            if (type.isAssignableFrom(r.getClass())) {
                return type.cast(r);
            }
        }
    }
    return null;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:21,代码来源:DefaultCamelContext.java

示例4: RegistryBean

import org.apache.camel.spi.Registry; //导入依赖的package包/类
public RegistryBean(Registry registry, CamelContext context, String name) {
    this.registry = registry;
    this.context = context;
    if (name != null) {
        // for ref it may have "ref:" or "bean:" as prefix by mistake
        if (name.startsWith("ref:")) {
            this.name = name.substring(4);
        } else if (name.startsWith("bean:")) {
            this.name = name.substring(5);
        } else {
            this.name = name;
        }
    } else {
        this.name = null;
    }
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:17,代码来源:RegistryBean.java

示例5: tryToGetFactoryRegistry

import org.apache.camel.spi.Registry; //导入依赖的package包/类
private FactoryRegistry tryToGetFactoryRegistry() {
    Function<CamelContext, Registry> f = CamelContext::getRegistry;
    Function<Registry, Set<FactoryRegistry>> g = r -> r.findByType(FactoryRegistry.class);
    Function<Set<FactoryRegistry>, FactoryRegistry> h = factoryRegistries -> {
        if (factoryRegistries.size() > 1) {
            LOGGER.warn("Number of registered {}: {}",
                    FactoryRegistry.class.getCanonicalName(),
                    factoryRegistries.size());
        }
        if (factoryRegistries.iterator().hasNext()) {
            return factoryRegistries.iterator().next();
        } else {
            return new DefaultFactoryRegistry();
        }
    };

    return Optional.ofNullable(camelContext)
            .map(f)
            .map(g)
            .map(h)
            .orElse(new DefaultFactoryRegistry());
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:23,代码来源:BindyAbstractDataFormat.java

示例6: createRegistry

import org.apache.camel.spi.Registry; //导入依赖的package包/类
protected CompositeRegistry createRegistry() {
    final ServiceLoader<Registry> registriesLoaders = ServiceLoader.load(Registry.class, getClass().getClassLoader());

    final List<Registry> registries = new ArrayList<Registry>();
    registries.add(new JndiRegistry());
    if (isEnableCdiIntegration()) {
        registries.add(new CdiBeanRegistry());
    }
    registries.add(_writeableRegistry);

    for (Registry registry : registriesLoaders) {
        registries.add(registry);
    }

    return new CompositeRegistry(registries);
}
 
开发者ID:jboss-switchyard,项目名称:switchyard,代码行数:17,代码来源:SwitchYardCamelContextImpl.java

示例7: addToRegistry

import org.apache.camel.spi.Registry; //导入依赖的package包/类
public static <T extends Registry> void addToRegistry(final T registry, final String name, final Object bean) {
    Registry reg = registry;

    // Unwrap PropertyPlaceholderDelegateRegistry
    if (registry instanceof PropertyPlaceholderDelegateRegistry) {
        reg = ((PropertyPlaceholderDelegateRegistry) reg).getRegistry();
    }

    if (reg instanceof CompositeRegistry) {
        // getRegistryList() not available in Camel 2.12
        SimpleRegistry r = new SimpleRegistry();
        r.put(name, bean);
        ((CompositeRegistry) reg).addRegistry(r);
    } else if (reg instanceof JndiRegistry) {
        ((JndiRegistry) reg).bind(name, bean);
    } else if (reg instanceof SimpleRegistry) {
        ((SimpleRegistry) reg).put(name, bean);
    } else {
        throw new IllegalArgumentException("Couldn't add bean. Unknown registry type: " + reg.getClass());
    }

    if (registry.lookupByName(name) != bean) {
        throw new IllegalArgumentException("Couldn't add bean. Bean not found from the registry.");
    }
}
 
开发者ID:yuruki,项目名称:camel-runner,代码行数:26,代码来源:CamelRunnerMain.java

示例8: initClientMapper

import org.apache.camel.spi.Registry; //导入依赖的package包/类
/**
 * Initialize the ClientMappers from Camel registry. Note that this initial
 * implementation only supports one mapper.
 * <p>
 */
private void initClientMapper(Registry registry) throws Exception {
	Set<ClientMapper> mappers = null;
	try {
		// find the one client mapper
		mappers = registry.findByType(ClientMapper.class);
	} catch (Exception ignore) {
	}

	if (mappers != null && !mappers.isEmpty()) {
		Object objs[] = mappers.toArray();
		getComponentProfile().setClientMapper((ClientMapper) objs[0]);
		LOG.trace("initClientMapper: using a client mapper from registry");
	} else {
		LOG.trace("initClientMapper: not using a client mapper");
	}
}
 
开发者ID:joef551,项目名称:camel-cql,代码行数:22,代码来源:CqlComponent.java

示例9: configure

import org.apache.camel.spi.Registry; //导入依赖的package包/类
@Override
public void configure() throws Exception {
    final CryptoDataFormat crypto = new CryptoDataFormat("DES", null);

    from("direct:encrypt")
        .process(new Processor() {
            @Override
            public void process(Exchange exchange) throws Exception {
                Registry registry = exchange.getContext().getRegistry();
                Message in = exchange.getIn();
                Key key = registry.lookupByNameAndType("shared_" + in.getHeader("system"), Key.class);
                in.setHeader(CryptoDataFormat.KEY, key);
            }
        })
        .log("Encrypting message: ${body} using ${header[CamelCryptoKey]}")
        .marshal(crypto)
        .log("Message encrypted: ${body}")
        .to("direct:decrypt");

    from("direct:decrypt")
        .log("Decrypting message: ${body} using ${header[CamelCryptoKey]}")
        .unmarshal(crypto)
        .log("Message decrypted: ${body}")
        .to("mock:decrypted");
}
 
开发者ID:CamelCookbook,项目名称:camel-cookbook-examples,代码行数:26,代码来源:EncryptionDynamicRoute.java

示例10: createCamelContext

import org.apache.camel.spi.Registry; //导入依赖的package包/类
private static DefaultCamelContext createCamelContext(String prefix, String name, Registry registry) {
    DefaultCamelContext ctx = createWithRegistry(registry);
    ctx.setName(prefix + name);
    ctx.disableJMX();
    ctx.setStreamCaching(true);
    return ctx;
}
 
开发者ID:drinkwater-io,项目名称:drinkwater-java,代码行数:8,代码来源:CamelContextFactory.java

示例11: createWithRegistry

import org.apache.camel.spi.Registry; //导入依赖的package包/类
private static DefaultCamelContext createWithRegistry(Registry registry) {
    if (registry == null) {
        return new DefaultCamelContext();
    }

    return new DefaultCamelContext(registry);
}
 
开发者ID:drinkwater-io,项目名称:drinkwater-java,代码行数:8,代码来源:CamelContextFactory.java

示例12: registerBean

import org.apache.camel.spi.Registry; //导入依赖的package包/类
public static void registerBean(Registry registry, String beanName, Object bean) {
    if (registry instanceof SimpleRegistry) {
        ((SimpleRegistry) registry).put(beanName, bean);
    } else if (registry instanceof PropertyPlaceholderDelegateRegistry) {
        Registry wrappedRegistry = ((PropertyPlaceholderDelegateRegistry) registry).getRegistry();
        registerBean(wrappedRegistry, beanName, bean);
    } else if (registry instanceof JndiRegistry) {
        ((JndiRegistry) registry).bind(beanName, bean);
    } else {
        throw new RuntimeException("could not identify the registry type while registering core beans");
    }

}
 
开发者ID:drinkwater-io,项目名称:drinkwater-java,代码行数:14,代码来源:CamelContextFactory.java

示例13: resolveObjectMapper

import org.apache.camel.spi.Registry; //导入依赖的package包/类
private ObjectMapper resolveObjectMapper(Registry registry) {
    Set<ObjectMapper> mappers = registry.findByType(ObjectMapper.class);
    if (mappers.size() == 1) {
        return mappers.iterator().next();
    }
    return new ObjectMapper();
}
 
开发者ID:syndesisio,项目名称:syndesis,代码行数:8,代码来源:JsonSimplePredicate.java

示例14: lookupByName

import org.apache.camel.spi.Registry; //导入依赖的package包/类
public Object lookupByName(String name) {
    Object answer = null;
    for (Registry registry : registryList) {
        answer = registry.lookupByName(name);
        if (answer != null) {
            break;
        }
    }
    return answer;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:11,代码来源:CompositeRegistry.java

示例15: findByTypeWithName

import org.apache.camel.spi.Registry; //导入依赖的package包/类
public <T> Map<String, T> findByTypeWithName(Class<T> type) {
    Map<String, T> answer = Collections.emptyMap();
    for (Registry registry : registryList) {
        answer = registry.findByTypeWithName(type);
        if (!answer.isEmpty()) {
            break;
        }
    }
    return answer;
}
 
开发者ID:HydAu,项目名称:Camel,代码行数:11,代码来源:CompositeRegistry.java


注:本文中的org.apache.camel.spi.Registry类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。