You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2009/01/04 05:37:18 UTC
svn commit: r731170 - in /activemq/camel/branches/camel-1.x: ./
components/camel-osgi/src/main/java/org/apache/camel/osgi/
Author: ningjiang
Date: Sat Jan 3 20:37:18 2009
New Revision: 731170
URL: http://svn.apache.org/viewvc?rev=731170&view=rev
Log:
Merged revisions 731168-731169 via svnmerge from
https://svn.apache.org/repos/asf/activemq/camel/trunk
........
r731168 | ningjiang | 2009-01-04 12:27:10 +0800 (Sun, 04 Jan 2009) | 1 line
Set the svn:ignore property on components\camel-tagsoup
........
r731169 | ningjiang | 2009-01-04 12:29:58 +0800 (Sun, 04 Jan 2009) | 1 line
CAMEL-1221 Added OSGI language resolver as Michael suggested
........
Added:
activemq/camel/branches/camel-1.x/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiLanguageResolver.java
- copied unchanged from r731169, activemq/camel/trunk/components/camel-osgi/src/main/java/org/apache/camel/osgi/OsgiLanguageResolver.java
Modified:
activemq/camel/branches/camel-1.x/ (props changed)
activemq/camel/branches/camel-1.x/components/camel-osgi/src/main/java/org/apache/camel/osgi/Activator.java
activemq/camel/branches/camel-1.x/components/camel-osgi/src/main/java/org/apache/camel/osgi/CamelContextFactoryBean.java
Propchange: activemq/camel/branches/camel-1.x/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sat Jan 3 20:37:18 2009
@@ -1 +1 @@
-/activemq/camel/trunk:709850,711200,711206,711219-711220,711523,711531,711756,711784,711859,711874,711962,711971,712064,712119,712148,712662,712692,712925,713013,713107,713136,713273,713290,713292,713295,713314,713475,713625,713932,713944,714032,717965,717989,718242,718273,718312-718515,719163-719184,719334,719339,719524,719662,719848,719851,719855,719864,719978-719979,720207,720435-720437,720806,721272,721331,721333-721334,721360,721669,721764,721813,721985,722005,722070,722110,722415,722438,722726,722845,722878,723264,723314,723325-723327,723409,723835,723966,724122,724619,724681,725040,725309-725320,725340,725351,725569-725572,725612,725652-725660,725715,725883,726339,726640-726645,726932,727113,727375,727377,727624,727713,727946,729401,729892,730069,730154,730275,730299,730504-730505,730508,730571,730599,730759,730903,730916,730923,730936,730992,731126
+/activemq/camel/trunk:709850,711200,711206,711219-711220,711523,711531,711756,711784,711859,711874,711962,711971,712064,712119,712148,712662,712692,712925,713013,713107,713136,713273,713290,713292,713295,713314,713475,713625,713932,713944,714032,717965,717989,718242,718273,718312-718515,719163-719184,719334,719339,719524,719662,719848,719851,719855,719864,719978-719979,720207,720435-720437,720806,721272,721331,721333-721334,721360,721669,721764,721813,721985,722005,722070,722110,722415,722438,722726,722845,722878,723264,723314,723325-723327,723409,723835,723966,724122,724619,724681,725040,725309-725320,725340,725351,725569-725572,725612,725652-725660,725715,725883,726339,726640-726645,726932,727113,727375,727377,727624,727713,727946,729401,729892,730069,730154,730275,730299,730504-730505,730508,730571,730599,730759,730903,730916,730923,730936,730992,731126,731168-731169
Propchange: activemq/camel/branches/camel-1.x/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified: activemq/camel/branches/camel-1.x/components/camel-osgi/src/main/java/org/apache/camel/osgi/Activator.java
URL: http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/components/camel-osgi/src/main/java/org/apache/camel/osgi/Activator.java?rev=731170&r1=731169&r2=731170&view=diff
==============================================================================
--- activemq/camel/branches/camel-1.x/components/camel-osgi/src/main/java/org/apache/camel/osgi/Activator.java (original)
+++ activemq/camel/branches/camel-1.x/components/camel-osgi/src/main/java/org/apache/camel/osgi/Activator.java Sat Jan 3 20:37:18 2009
@@ -40,11 +40,13 @@
import org.springframework.osgi.util.BundleDelegatingClassLoader;
public class Activator implements BundleActivator, SynchronousBundleListener {
- public static final String META_INF_TYPE_CONVERTER = "META-INF/services/org/apache/camel/TypeConverter";
+ public static final String META_INF_TYPE_CONVERTER = "/META-INF/services/org/apache/camel/TypeConverter";
public static final String META_INF_COMPONENT = "/META-INF/services/org/apache/camel/component/";
+ public static final String META_INF_LANGUAGE = "/META-INF/services/org/apache/camel/language/";
private static final transient Log LOG = LogFactory.getLog(Activator.class);
private static final Map<String, ComponentEntry> COMPONENTS = new HashMap<String, ComponentEntry>();
private static final Map<Bundle, TypeConverterEntry> TYPE_CONVERTERS = new HashMap<Bundle, TypeConverterEntry>();
+ private static final Map<String, ComponentEntry> LANGUAGES = new HashMap<String, ComponentEntry>();
private static Bundle bundle;
private class ComponentEntry {
@@ -67,13 +69,13 @@
if (LOG.isDebugEnabled()) {
LOG.debug("Bundle resolved: " + bundle.getSymbolicName());
}
- mayBeAddComponentFor(bundle);
+ mayBeAddComponentAndLanguageFor(bundle);
mayBeAddTypeConverterFor(bundle);
} else if (event.getType() == BundleEvent.UNRESOLVED) {
if (LOG.isDebugEnabled()) {
LOG.debug("Bundle unresolved: " + bundle.getSymbolicName());
}
- mayBeRemoveComponentFor(bundle);
+ mayBeRemoveComponentAndLanguageFor(bundle);
mayBeRemoveTypeConverterFor(bundle);
}
} catch (Throwable e) {
@@ -81,9 +83,8 @@
}
}
-
- protected synchronized void mayBeAddComponentFor(Bundle bundle) {
- Enumeration e = bundle.getEntryPaths(META_INF_COMPONENT);
+
+ protected void addComponentEntry(Enumeration e, Map<String, ComponentEntry> entries) {
if (e != null) {
while (e.hasMoreElements()) {
String path = (String)e.nextElement();
@@ -94,9 +95,15 @@
entry.bundle = bundle;
entry.path = path;
entry.name = path.substring(path.lastIndexOf("/") + 1);
- COMPONENTS.put(entry.name, entry);
+ entries.put(entry.name, entry);
}
}
+
+ }
+
+ protected synchronized void mayBeAddComponentAndLanguageFor(Bundle bundle) {
+ addComponentEntry(bundle.getEntryPaths(META_INF_COMPONENT), COMPONENTS);
+ addComponentEntry(bundle.getEntryPaths(META_INF_LANGUAGE), LANGUAGES);
}
protected synchronized void mayBeAddTypeConverterFor(Bundle bundle) {
@@ -120,16 +127,21 @@
}
}
- protected synchronized void mayBeRemoveComponentFor(Bundle bundle) {
- ComponentEntry[] entriesArray = COMPONENTS.values().toArray(new ComponentEntry[0]);
+ protected synchronized void mayBeRemoveComponentAndLanguageFor(Bundle bundle) {
+ removeComponentEntry(bundle, COMPONENTS);
+ removeComponentEntry(bundle, LANGUAGES);
+ }
+
+ protected void removeComponentEntry(Bundle bundle, Map<String, ComponentEntry> entries) {
+ ComponentEntry[] entriesArray = entries.values().toArray(new ComponentEntry[0]);
for (ComponentEntry entry : entriesArray) {
if (entry.bundle == bundle) {
if (LOG.isDebugEnabled()) {
LOG.debug("Removing entry: " + entry.path + " in bundle " + bundle.getSymbolicName());
}
- COMPONENTS.remove(entry.name);
+ entries.remove(entry.name);
}
- }
+ }
}
protected synchronized void mayBeRemoveTypeConverterFor(Bundle bundle) {
@@ -153,7 +165,7 @@
for (Bundle bundle : context.getBundles()) {
if (bundle.getState() == Bundle.RESOLVED || bundle.getState() == Bundle.STARTING
|| bundle.getState() == Bundle.ACTIVE || bundle.getState() == Bundle.STOPPING) {
- mayBeAddComponentFor(bundle);
+ mayBeAddComponentAndLanguageFor(bundle);
mayBeAddTypeConverterFor(bundle);
}
}
@@ -170,7 +182,7 @@
for (Bundle bundle : context.getBundles()) {
if (bundle.getState() == Bundle.RESOLVED || bundle.getState() == Bundle.STARTING
|| bundle.getState() == Bundle.ACTIVE || bundle.getState() == Bundle.STOPPING) {
- mayBeRemoveComponentFor(bundle);
+ mayBeRemoveComponentAndLanguageFor(bundle);
mayBeRemoveTypeConverterFor(bundle);
}
}
@@ -231,8 +243,16 @@
return packages.toArray(new String[packages.size()]);
}
- protected static synchronized Class getComponent(String name) throws Exception {
- ComponentEntry entry = COMPONENTS.get(name);
+ public static synchronized Class getComponent(String name) throws Exception {
+ return getClassFromEntries(name, COMPONENTS);
+ }
+
+ public static synchronized Class getLanguage(String name) throws Exception {
+ return getClassFromEntries(name, LANGUAGES);
+ }
+
+ protected static Class getClassFromEntries(String name, Map<String, ComponentEntry> entries) throws Exception {
+ ComponentEntry entry = entries.get(name);
if (entry == null) {
return null;
}
@@ -246,7 +266,9 @@
properties.load(reader);
} finally {
try {
- reader.close();
+ if (reader != null) {
+ reader.close();
+ }
} catch (Exception ignore) {
}
}
@@ -255,9 +277,10 @@
entry.type = loader.loadClass(classname);
}
if (LOG.isDebugEnabled()) {
- LOG.debug("Found component: " + name + " via type: " + entry.type.getName());
+ LOG.debug("Found entry: " + name + " via type: " + entry.type.getName());
}
return entry.type;
}
+
}
Modified: activemq/camel/branches/camel-1.x/components/camel-osgi/src/main/java/org/apache/camel/osgi/CamelContextFactoryBean.java
URL: http://svn.apache.org/viewvc/activemq/camel/branches/camel-1.x/components/camel-osgi/src/main/java/org/apache/camel/osgi/CamelContextFactoryBean.java?rev=731170&r1=731169&r2=731170&view=diff
==============================================================================
--- activemq/camel/branches/camel-1.x/components/camel-osgi/src/main/java/org/apache/camel/osgi/CamelContextFactoryBean.java (original)
+++ activemq/camel/branches/camel-1.x/components/camel-osgi/src/main/java/org/apache/camel/osgi/CamelContextFactoryBean.java Sat Jan 3 20:37:18 2009
@@ -50,7 +50,8 @@
SpringCamelContext context = super.createContext();
if (bundleContext != null) {
context.setComponentResolver(new OsgiComponentResolver());
- addOsgiAnnotationTypeConverterLoader(context, bundleContext);
+ context.setLanguageResolver(new OsgiLanguageResolver());
+ addOsgiAnnotationTypeConverterLoader(context, bundleContext);
}
return context;