use of org.apache.aries.blueprint.ComponentDefinitionRegistry in project aries by apache.
the class BeanRecipe method addInterceptors.
private Object addInterceptors(final Object original, Collection<Class<?>> requiredInterfaces) throws ComponentDefinitionException {
Object intercepted = null;
if (requiredInterfaces.isEmpty())
requiredInterfaces.add(original.getClass());
ComponentDefinitionRegistry reg = blueprintContainer.getComponentDefinitionRegistry();
List<Interceptor> interceptors = reg.getInterceptors(interceptorLookupKey);
if (interceptors != null && interceptors.size() > 0) {
/* BLUEPRINT-NOOSGI
try {
Bundle b = FrameworkUtil.getBundle(original.getClass());
if (b == null) {
// we have a class from the framework parent, so use our bundle for proxying.
b = blueprintContainer.getBundleContext().getBundle();
}
intercepted = blueprintContainer.getProxyManager().createInterceptingProxy(b,
requiredInterfaces, original, new Collaborator(interceptorLookupKey, interceptors));
} catch (org.apache.aries.proxy.UnableToProxyException e) {
Bundle b = blueprintContainer.getBundleContext().getBundle();
throw new ComponentDefinitionException("Unable to create proxy for bean " + name + " in bundle " + b.getSymbolicName() + " version " + b.getVersion(), e);
}
*/
throw new ComponentDefinitionException("Unable to create proxy for bean " + name + ". Not supported in blueprint-noosgi");
} else {
intercepted = original;
}
return intercepted;
}
use of org.apache.aries.blueprint.ComponentDefinitionRegistry in project aries by apache.
the class AbstractParserProxy method parse.
public List<? extends WrappedServiceMetadata> parse(List<URL> blueprintsToParse) throws Exception {
_logger.debug(LOG_ENTRY, "parse", new Object[] { blueprintsToParse });
ComponentDefinitionRegistry cdr = parseCDR(blueprintsToParse);
List<? extends WrappedServiceMetadata> result = parseCDRForServices(cdr, true);
_logger.debug(LOG_EXIT, "parse", new Object[] { result });
return result;
}
use of org.apache.aries.blueprint.ComponentDefinitionRegistry in project aries by apache.
the class BlueprintBeanFactory method registerBeanDefinition.
@Override
public void registerBeanDefinition(String beanName, BeanDefinition beanDefinition) throws BeanDefinitionStoreException {
ComponentDefinitionRegistry registry = container.getComponentDefinitionRegistry();
ComponentMetadata metadata = registry.getComponentDefinition(beanName);
if (metadata != null && !(metadata instanceof SpringMetadata)) {
throw new BeanDefinitionStoreException(beanDefinition.getResourceDescription(), beanName, "Cannot register bean definition [" + beanDefinition + "] for bean '" + beanName + "': There is already bound.");
}
super.registerBeanDefinition(beanName, beanDefinition);
if (!beanDefinition.isAbstract()) {
registry.registerComponentDefinition(new SpringMetadata(beanName));
}
}
use of org.apache.aries.blueprint.ComponentDefinitionRegistry in project aries by apache.
the class BlueprintNamespaceHandler method getOrCreateParserContext.
private org.springframework.beans.factory.xml.ParserContext getOrCreateParserContext(ParserContext parserContext) {
ComponentDefinitionRegistry registry = parserContext.getComponentDefinitionRegistry();
ExtendedBlueprintContainer container = getBlueprintContainer(parserContext);
// Create spring application context
SpringApplicationContext applicationContext = getPassThrough(parserContext, SPRING_APPLICATION_CONTEXT_ID, SpringApplicationContext.class);
if (applicationContext == null) {
applicationContext = new SpringApplicationContext(container);
registry.registerComponentDefinition(createPassThrough(parserContext, SPRING_APPLICATION_CONTEXT_ID, applicationContext, "destroy"));
}
// Create registry
DefaultListableBeanFactory beanFactory = getPassThrough(parserContext, SPRING_BEAN_FACTORY_ID, DefaultListableBeanFactory.class);
if (beanFactory == null) {
beanFactory = applicationContext.getBeanFactory();
registry.registerComponentDefinition(createPassThrough(parserContext, SPRING_BEAN_FACTORY_ID, beanFactory));
}
// Create spring parser context
org.springframework.beans.factory.xml.ParserContext springParserContext = getPassThrough(parserContext, SPRING_CONTEXT_ID, org.springframework.beans.factory.xml.ParserContext.class);
if (springParserContext == null) {
// Create spring context
springParserContext = createSpringParserContext(parserContext, beanFactory);
registry.registerComponentDefinition(createPassThrough(parserContext, SPRING_CONTEXT_ID, springParserContext));
}
// Create processor
if (!parserContext.getComponentDefinitionRegistry().containsComponentDefinition(SPRING_BEAN_PROCESSOR_ID)) {
MutableBeanMetadata bm = parserContext.createMetadata(MutableBeanMetadata.class);
bm.setId(SPRING_BEAN_PROCESSOR_ID);
bm.setProcessor(true);
bm.setScope(BeanMetadata.SCOPE_SINGLETON);
bm.setRuntimeClass(SpringBeanProcessor.class);
bm.setActivation(BeanMetadata.ACTIVATION_EAGER);
bm.addArgument(createRef(parserContext, "blueprintBundleContext"), null, 0);
bm.addArgument(createRef(parserContext, "blueprintContainer"), null, 0);
bm.addArgument(createRef(parserContext, SPRING_APPLICATION_CONTEXT_ID), null, 0);
registry.registerComponentDefinition(bm);
}
// Add the namespace handler's bundle to the application context classloader
applicationContext.addSourceBundle(bundle);
return springParserContext;
}
use of org.apache.aries.blueprint.ComponentDefinitionRegistry in project aries by apache.
the class TxNamespaceHandler method parseElement.
private void parseElement(Element elt, ParserContext pc) {
LOGGER.debug("parser asked to parse element {} ", elt.getNodeName());
ComponentDefinitionRegistry cdr = pc.getComponentDefinitionRegistry();
if ("enable".equals(elt.getLocalName())) {
Node n = elt.getChildNodes().item(0);
if ((n == null || Boolean.parseBoolean(n.getNodeValue())) && !cdr.containsComponentDefinition(ANNOTATION_PARSER_BEAN_NAME)) {
LOGGER.debug("Enabling annotation based transactions");
MutableBeanMetadata meta = createAnnotationParserBean(pc, cdr);
cdr.registerComponentDefinition(meta);
}
}
}
Aggregations