/trunk/src/main/java/org/mentacontainer/impl/GenericComponent.java |
---|
28,20 → 28,17 |
} |
} |
public Object getInstance() throws InstantiationException { |
public Object getInstance() { |
try { |
return method.invoke(factory, (Object[]) null); |
} catch(InvocationTargetException e) { |
} catch(Exception e) { |
throw new InstantiationException("InvocationTargetException: " + method.getName() + " / " + e.getMessage()); |
throw new RuntimeException("Cannot invoke method: " + method, e); |
} catch(IllegalAccessException e) { |
throw new InstantiationException("IllegalAccessException: " + method.getName() + " / " + e.getMessage()); |
} |
} |
} |
public Component addInitValue(Object value) { |
/trunk/src/main/java/org/mentacontainer/impl/MentaComponent.java |
---|
118,7 → 118,7 |
/* |
* Use reflection to set a property in the bean |
*/ |
private void setValue(Object bean, String name, Object value) throws InstantiationException { |
private void setValue(Object bean, String name, Object value) { |
try { |
178,7 → 178,7 |
} catch(Exception e) { |
throw new InstantiationException("Error trying to set a property with reflection: " + name); |
throw new RuntimeException("Error trying to set a property with reflection: " + name, e); |
} |
} |
194,7 → 194,7 |
return null; |
} |
public Object getInstance() throws InstantiationException { |
public Object getInstance() { |
if (singleton && singletonValue != null) return singletonValue; |
210,7 → 210,7 |
} catch(Exception e) { |
throw new InstantiationException("Cannot find a constructor for class: " + klass); |
throw new RuntimeException("Cannot find a constructor for class: " + klass, e); |
} |
} |
220,7 → 220,7 |
} catch(Exception e) { |
throw new InstantiationException("Cannot create instance from constructor: " + constructor); |
throw new RuntimeException("Cannot create instance from constructor: " + constructor, e); |
} |
} else { |
231,7 → 231,7 |
} catch(Exception e) { |
throw new InstantiationException("Cannot create instance from class: " + klass); |
throw new RuntimeException("Cannot create instance from class: " + klass, e); |
} |
} |
/trunk/src/main/java/org/mentacontainer/impl/MentaContainer.java |
---|
146,7 → 146,7 |
return autowire(new MentaDependency(property, klass, source)); |
} |
public Container populate(Object bean) throws Exception { |
public Container populate(Object bean) { |
Provider p = new Provider() { |
161,8 → 161,15 |
} |
}; |
try { |
InjectionUtils.getObject(bean, p, false, null, true, false, true); |
InjectionUtils.getObject(bean, p, false, null, true, false, true); |
} catch(Exception e) { |
throw new RuntimeException("Error populating bean: " + bean, e); |
} |
return this; |
} |
/trunk/src/main/java/org/mentacontainer/Component.java |
---|
12,9 → 12,8 |
* Instantiate the bean. |
* |
* @return The instantiated bean based on the container configuration. |
* @throws InstantiationException |
*/ |
public Object getInstance() throws InstantiationException; |
public Object getInstance(); |
/** |
* Add a constructor parameter to be used when the bean is instantiated. It can be called more than once to |
/trunk/src/main/java/org/mentacontainer/Container.java |
---|
103,7 → 103,7 |
* @param bean The bean to be populated with other beans from the container. |
* @return The container itself. (Fluent API) |
*/ |
public Container populate(Object bean) throws Exception; |
public Container populate(Object bean); |
/** |
* Check whether the container is configured to provide a bean with name 'key'. |
/trunk/src/main/java/org/mentacontainer/example/BasicOperations.java |
---|
7,7 → 7,7 |
public class BasicOperations { |
public static void main(String[] args) throws Exception { |
public static void main(String[] args) { |
case1(); |
case2(); |
117,7 → 117,7 |
} |
} |
private static void case4() throws Exception { |
private static void case4() { |
Container c = new MentaContainer(); |