Author: dkulp
Date: Mon Mar 18 20:05:19 2013
New Revision: 1457957
URL: http://svn.apache.org/r1457957
Log:
Merged revisions 1457806 via git cherry-pick from
https://svn.apache.org/repos/asf/cxf/trunk
........
r1457806 | dkulp | 2013-03-18 11:23:18 -0400 (Mon, 18 Mar 2013) | 3 lines
[CXF-4870] Fix checkstyle issues
Also fix issue of bundleContext not being registered as a Bus extension using
the proper class.
........
Modified:
cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/SpringBeanLocator.java
Modified:
cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/SpringBeanLocator.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/SpringBeanLocator.java?rev=1457957&r1=1457956&r2=1457957&view=diff
==============================================================================
---
cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/SpringBeanLocator.java
(original)
+++
cxf/branches/2.7.x-fixes/rt/core/src/main/java/org/apache/cxf/bus/spring/SpringBeanLocator.java
Mon Mar 18 20:05:19 2013
@@ -92,40 +92,39 @@ public class SpringBeanLocator implement
}
private void loadOSGIContext(Bus b) {
- Object bundleContext = findBundleContext(context);
+ bundleContext = findBundleContext(context, b);
if (bundleContext == null) {
osgi = false;
- } else {
- if (b != null) {
- @SuppressWarnings("unchecked")
- Class<Object> cls = (Class<Object>)bundleContext.getClass();
- b.setExtension(bundleContext, cls);
- }
}
}
- private Object findBundleContext(ApplicationContext applicationContext) {
+ private Object findBundleContext(ApplicationContext applicationContext,
Bus b) {
Object answer = null;
ApplicationContext aContext = applicationContext;
// try to find out the bundleContext by going through the parent
context
- while(aContext != null || answer != null) {
- answer = getBundleContext(aContext);
- aContext = aContext.getParent();
+ while (aContext != null && answer != null) {
+ answer = getBundleContext(aContext, b);
+ aContext = aContext.getParent();
}
return answer;
}
- private Object getBundleContext(ApplicationContext applicationContext) {
- Object bundleContext = null;
+ private Object getBundleContext(ApplicationContext applicationContext, Bus
b) {
try {
//use a little reflection to allow this to work without the
spring-dm jars
//for the non-osgi cases
Method m =
applicationContext.getClass().getMethod("getBundleContext");
- bundleContext = m.invoke(applicationContext);
- } catch(Throwable t) {
+ Object o = m.invoke(applicationContext);
+ if (o != null && b != null) {
+ @SuppressWarnings("unchecked")
+ Class<Object> cls = (Class<Object>)m.getReturnType();
+ b.setExtension(o, cls);
+ }
+ return o;
+ } catch (Throwable t) {
// do nothing here
}
- return bundleContext;
+ return null;
}
public <T> T getBeanOfType(String name, Class<T> type) {