[
https://issues.apache.org/jira/browse/CAMEL-9570?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16288991#comment-16288991
]
ASF GitHub Bot commented on CAMEL-9570:
---------------------------------------
davsclaus closed pull request #1302: CAMEL-9570: Change CamelNamespaceHandler
so that is doesn't force Blu…
URL: https://github.com/apache/camel/pull/1302
This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:
As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):
diff --git
a/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java
b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java
index 6802312e0b7..d9ec97d264e 100644
---
a/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java
+++
b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/CamelContextFactoryBean.java
@@ -272,7 +272,7 @@ protected void initPropertyPlaceholder() throws Exception {
if (pc.getLocations() == null) {
String[] ids = parser.lookupPropertyPlaceholderIds();
for (int i = 0; i < ids.length; i++) {
- if (!ids[i].startsWith( "blueprint:")) {
+ if (!ids[i].startsWith("blueprint:")) {
ids[i] = "blueprint:" + ids[i];
}
}
diff --git
a/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/handler/CamelNamespaceHandler.java
b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/handler/CamelNamespaceHandler.java
index e95f5e14527..5313831def6 100644
---
a/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/handler/CamelNamespaceHandler.java
+++
b/components/camel-blueprint/src/main/java/org/apache/camel/blueprint/handler/CamelNamespaceHandler.java
@@ -48,6 +48,7 @@
import org.apache.aries.blueprint.mutable.MutablePassThroughMetadata;
import org.apache.aries.blueprint.mutable.MutableRefMetadata;
import org.apache.aries.blueprint.mutable.MutableReferenceMetadata;
+
import org.apache.camel.BeanInject;
import org.apache.camel.CamelContext;
import org.apache.camel.Endpoint;
@@ -99,13 +100,17 @@
import org.apache.camel.util.jsse.KeyStoreParameters;
import org.apache.camel.util.jsse.SSLContextParameters;
import org.apache.camel.util.jsse.SecureRandomParameters;
+
import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
+
import org.osgi.service.blueprint.container.BlueprintContainer;
import org.osgi.service.blueprint.container.ComponentDefinitionException;
import org.osgi.service.blueprint.reflect.BeanMetadata;
import org.osgi.service.blueprint.reflect.ComponentMetadata;
import org.osgi.service.blueprint.reflect.Metadata;
import org.osgi.service.blueprint.reflect.RefMetadata;
+
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -176,7 +181,7 @@ public URL getSchemaLocation(String namespace) {
return getClass().getClassLoader().getResource("camel-blueprint.xsd");
}
- @SuppressWarnings({"rawtypes"})
+ @SuppressWarnings({"unchecked", "rawtypes"})
public Set<Class> getManagedClasses() {
return new HashSet<Class>(Arrays.asList(BlueprintCamelContext.class));
}
@@ -300,7 +305,7 @@ private Metadata parseCamelContextNode(Element element,
ParserContext context) {
MutablePassThroughMetadata regProcessorFactory =
context.createMetadata(MutablePassThroughMetadata.class);
regProcessorFactory.setId(".camelBlueprint.processor.registry.passThrough." +
contextId);
- regProcessorFactory.setObject(new PassThroughCallable<Object>(new
CamelDependenciesFinder(contextId, context)));
+ regProcessorFactory.setObject(new PassThroughCallable<Object>(new
CamelDependenciesFinder(ccfb, context)));
MutableBeanMetadata regProcessor =
context.createMetadata(MutableBeanMetadata.class);
regProcessor.setId(".camelBlueprint.processor.registry." + contextId);
@@ -310,6 +315,7 @@ private Metadata parseCamelContextNode(Element element,
ParserContext context) {
regProcessor.setProcessor(true);
regProcessor.addDependsOn(".camelBlueprint.processor.bean." +
contextId);
regProcessor.addProperty("blueprintContainer", createRef(context,
"blueprintContainer"));
+ regProcessor.addProperty("blueprintBundleContext", createRef(context,
"blueprintBundleContext"));
context.getComponentDefinitionRegistry().registerComponentDefinition(regProcessor);
// lets inject the namespaces into any namespace aware POJOs
@@ -967,12 +973,13 @@ protected boolean isSingleton(Object bean, String
beanName) {
public static class CamelDependenciesFinder implements
ComponentDefinitionRegistryProcessor {
- private final String camelContextName;
+ private final CamelContextFactoryBean camelContextFactoryBean;
private final ParserContext context;
private BlueprintContainer blueprintContainer;
+ private BundleContext blueprintBundleContext;
- public CamelDependenciesFinder(String camelContextName, ParserContext
context) {
- this.camelContextName = camelContextName;
+ public CamelDependenciesFinder(CamelContextFactoryBean
camelContextFactoryBean, ParserContext context) {
+ this.camelContextFactoryBean = camelContextFactoryBean;
this.context = context;
}
@@ -980,9 +987,15 @@ public void setBlueprintContainer(BlueprintContainer
blueprintContainer) {
this.blueprintContainer = blueprintContainer;
}
+ public void setBlueprintBundleContext(BundleContext
blueprintBundleContext) {
+ this.blueprintBundleContext = blueprintBundleContext;
+ }
+
+ @SuppressWarnings("deprecation")
public void process(ComponentDefinitionRegistry
componentDefinitionRegistry) {
- CamelContextFactoryBean ccfb = (CamelContextFactoryBean)
blueprintContainer.getComponentInstance(".camelBlueprint.factory." +
camelContextName);
- CamelContext camelContext = ccfb.getContext();
+ camelContextFactoryBean.setBlueprintContainer(blueprintContainer);
+ camelContextFactoryBean.setBundleContext(blueprintBundleContext);
+ CamelContext camelContext = camelContextFactoryBean.getContext();
Set<String> components = new HashSet<String>();
Set<String> languages = new HashSet<String>();
@@ -1010,20 +1023,20 @@ public void process(ComponentDefinitionRegistry
componentDefinitionRegistry) {
}
}
- if (ccfb.getRestConfiguration() != null) {
+ if (camelContextFactoryBean.getRestConfiguration() != null) {
// rest configuration may refer to a component to use
- String component = ccfb.getRestConfiguration().getComponent();
+ String component =
camelContextFactoryBean.getRestConfiguration().getComponent();
if (component != null) {
components.add(component);
}
- component = ccfb.getRestConfiguration().getApiComponent();
+ component =
camelContextFactoryBean.getRestConfiguration().getApiComponent();
if (component != null) {
components.add(component);
}
// check what data formats are used in binding mode
- RestBindingMode mode =
ccfb.getRestConfiguration().getBindingMode();
- String json = ccfb.getRestConfiguration().getJsonDataFormat();
+ RestBindingMode mode =
camelContextFactoryBean.getRestConfiguration().getBindingMode();
+ String json =
camelContextFactoryBean.getRestConfiguration().getJsonDataFormat();
if (json == null && mode != null) {
if (RestBindingMode.json.equals(mode) ||
RestBindingMode.json_xml.equals(mode)) {
// jackson is the default json data format
@@ -1033,7 +1046,7 @@ public void process(ComponentDefinitionRegistry
componentDefinitionRegistry) {
if (json != null) {
dataformats.add(json);
}
- String xml = ccfb.getRestConfiguration().getXmlDataFormat();
+ String xml =
camelContextFactoryBean.getRestConfiguration().getXmlDataFormat();
if (xml == null && mode != null) {
if (RestBindingMode.xml.equals(mode) ||
RestBindingMode.json_xml.equals(mode)) {
// jaxb is the default xml data format
@@ -1189,5 +1202,4 @@ private void findSchedulerUriComponent(String uri,
Set<String> components) {
}
}
-
}
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
> Blueprint Proxies are not used when injected into Java RouteBuilders
> --------------------------------------------------------------------
>
> Key: CAMEL-9570
> URL: https://issues.apache.org/jira/browse/CAMEL-9570
> Project: Camel
> Issue Type: Bug
> Components: camel-blueprint, camel-core
> Affects Versions: 2.16.2
> Reporter: Quinn Stevenson
> Assignee: Christian Schneider
>
> Basic Conditions:
> - Java interface used for OSGi Services
> - Implementation of the Java interface registered as a OSGi service. Note
> that the package containing implementation is NOT exported
> - A Java RouteBuilder that uses the Java interface via bean(...) DSL calls,
> with a setter for the bean implementing the interface
> - Wire everything together with Blueprint - create a <reference ...> for the
> service, a <bean ...> for the RouteBuilder and inject the service reference,
> and use the RouteBuilder in a CamelContext.
> After all this is deployed, stop the bundle implementing the service. A
> ServiceUnavailableException should be thrown after a timeout, but the object
> that was injected into the RouteBuilder process the request - so the
> Blueprint Proxy is not used.
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)