From 9086245a6d2052fe813b3ef4296c686aad82b244 Mon Sep 17 00:00:00 2001 From: Alexey Fansky Date: Wed, 4 Mar 2015 13:23:42 -0800 Subject: Using ComponentFactory in DesignContext.getDefaultInstance() (#16990) Change-Id: I0bb3e7975f2b48cdc589de740cb07ac893b13461 --- .../com/vaadin/ui/declarative/DesignContext.java | 21 +++++++++++---------- 1 file changed, 11 insertions(+), 10 deletions(-) (limited to 'server/src/com/vaadin/ui/declarative') diff --git a/server/src/com/vaadin/ui/declarative/DesignContext.java b/server/src/com/vaadin/ui/declarative/DesignContext.java index 09fefd0a6b..218774c72d 100644 --- a/server/src/com/vaadin/ui/declarative/DesignContext.java +++ b/server/src/com/vaadin/ui/declarative/DesignContext.java @@ -278,16 +278,8 @@ public class DesignContext implements Serializable { Class componentClass) { Component instance = instanceCache.get(componentClass); if (instance == null) { - try { - instance = componentClass.newInstance(); - instanceCache.put(componentClass, instance); - } catch (InstantiationException e) { - throw new RuntimeException("Could not instantiate " - + componentClass.getName()); - } catch (IllegalAccessException e) { - throw new RuntimeException("Could not instantiate " - + componentClass.getName()); - } + instance = instantiateClass(componentClass.getName()); + instanceCache.put(componentClass, instance); } return instance; } @@ -484,6 +476,15 @@ public class DesignContext implements Serializable { // Extract the package and class names. String qualifiedClassName = tagNameToClassName(node); + return instantiateClass(qualifiedClassName); + } + + /** + * Instantiates given class via ComponentFactory. + * @param qualifiedClassName class name to instantiate + * @return instance of a given class + */ + private Component instantiateClass(String qualifiedClassName) { ComponentFactory factory = Design.getComponentFactory(); Component component = factory.createComponent(qualifiedClassName, this); -- cgit v1.2.3