You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cl...@apache.org on 2007/12/03 14:19:39 UTC
svn commit: r600520 -
/felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/Dependency.java
Author: clement
Date: Mon Dec 3 05:19:32 2007
New Revision: 600520
URL: http://svn.apache.org/viewvc?rev=600520&view=rev
Log:
Resolve an issue introduced in the previous commit. The class need to be loaded before creating the proxy.
Modified:
felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/Dependency.java
Modified: felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/Dependency.java
URL: http://svn.apache.org/viewvc/felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/Dependency.java?rev=600520&r1=600519&r2=600520&view=diff
==============================================================================
--- felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/Dependency.java (original)
+++ felix/trunk/ipojo/core/src/main/java/org/apache/felix/ipojo/handlers/dependency/Dependency.java Mon Dec 3 05:19:32 2007
@@ -184,6 +184,11 @@
* Nullable object.
*/
private Object m_nullable;
+
+ /**
+ * Default-Implementation.
+ */
+ private String m_di;
/**
* Dependency constructor. After the creation the dependency is not started.
@@ -204,22 +209,8 @@
m_field = field;
m_specification = spec;
m_isOptional = isOptional;
- if (m_isOptional) {
- if (di != null) {
- try {
- Class c = getHandler().getInstanceManager().getContext().getBundle().loadClass(di);
- m_nullable = c.newInstance();
- } catch (IllegalAccessException e) {
- m_handler.log(Logger.ERROR, "Cannot load the default-implementation " + di + " : " + e.getMessage());
- } catch (InstantiationException e) {
- m_handler.log(Logger.ERROR, "Cannot load the default-implementation " + di + " : " + e.getMessage());
- } catch (ClassNotFoundException e) {
- m_handler.log(Logger.ERROR, "Cannot load the default-implementation " + di + " : " + e.getMessage());
- }
- } else {
- m_nullable = Proxy.newProxyInstance(getHandler().getInstanceManager().getClazz().getClassLoader(), new Class[] {m_clazz, Nullable.class}, new NullableObject());
- }
- }
+ m_di = di;
+
m_strFilter = filter;
m_isAggregate = isAggregate;
if (m_id == null) {
@@ -500,15 +491,31 @@
if (m_strFilter != null) {
filter = "(&" + filter + m_strFilter + ")";
}
-
- m_state = UNRESOLVED;
-
+
try {
m_clazz = m_handler.getInstanceManager().getContext().getBundle().loadClass(m_specification);
} catch (ClassNotFoundException e) {
m_handler.log(Logger.ERROR, "Cannot load the interface class for the dependency " + m_field + " [" + m_specification + "]");
- m_handler.getInstanceManager().stop();
}
+
+ if (m_isOptional) {
+ if (m_di != null) {
+ try {
+ Class c = getHandler().getInstanceManager().getContext().getBundle().loadClass(m_di);
+ m_nullable = c.newInstance();
+ } catch (IllegalAccessException e) {
+ m_handler.log(Logger.ERROR, "Cannot load the default-implementation " + m_di + " : " + e.getMessage());
+ } catch (InstantiationException e) {
+ m_handler.log(Logger.ERROR, "Cannot load the default-implementation " + m_di + " : " + e.getMessage());
+ } catch (ClassNotFoundException e) {
+ m_handler.log(Logger.ERROR, "Cannot load the default-implementation " + m_di + " : " + e.getMessage());
+ }
+ } else {
+ m_nullable = Proxy.newProxyInstance(getHandler().getInstanceManager().getClazz().getClassLoader(), new Class[] {m_clazz, Nullable.class}, new NullableObject());
+ }
+ }
+
+ m_state = UNRESOLVED;
try {
m_filter = m_handler.getInstanceManager().getContext().createFilter(filter); // Store the filter