diff options
author | Alexey Fansky <alexey.fansky@effective-soft.com> | 2015-03-04 13:23:42 -0800 |
---|---|---|
committer | Vaadin Code Review <review@vaadin.com> | 2015-03-10 09:11:45 +0000 |
commit | 9086245a6d2052fe813b3ef4296c686aad82b244 (patch) | |
tree | 664d05c718efdc8fa8ca7929ed97d35c6a833960 /server/src/com/vaadin/ui/declarative | |
parent | eee3c6be22e583752748acea31255b27fde27fdf (diff) | |
download | vaadin-framework-9086245a6d2052fe813b3ef4296c686aad82b244.tar.gz vaadin-framework-9086245a6d2052fe813b3ef4296c686aad82b244.zip |
Using ComponentFactory in DesignContext.getDefaultInstance() (#16990)
Change-Id: I0bb3e7975f2b48cdc589de740cb07ac893b13461
Diffstat (limited to 'server/src/com/vaadin/ui/declarative')
-rw-r--r-- | server/src/com/vaadin/ui/declarative/DesignContext.java | 21 |
1 files changed, 11 insertions, 10 deletions
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<? extends Component> 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); |