Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
BeanAssembler |
|
| 1.0;1 |
1 | /* | |
2 | * $Id: BeanAssembler.java 10494 2008-01-23 21:09:56Z acooke $ | |
3 | * -------------------------------------------------------------------------------------- | |
4 | * Copyright (c) MuleSource, Inc. All rights reserved. http://www.mulesource.com | |
5 | * | |
6 | * The software in this package is published under the terms of the CPAL v1.0 | |
7 | * license, a copy of which has been included with this distribution in the | |
8 | * LICENSE.txt file. | |
9 | */ | |
10 | ||
11 | package org.mule.config.spring.parsers.assembly; | |
12 | ||
13 | import org.springframework.beans.factory.config.BeanDefinition; | |
14 | import org.springframework.beans.factory.support.BeanDefinitionBuilder; | |
15 | import org.w3c.dom.Attr; | |
16 | ||
17 | /** | |
18 | * Bean Assembler provides a high-level interface to constructing beans. It encapsulates all | |
19 | * the "smart" logic about collections, maps, references, etc. | |
20 | * | |
21 | * <p>A bean assembly contains a bean (the thing we are constructing), a target (where we put the | |
22 | * bean once it is ready) and appropriate configuration information (there is a configuration | |
23 | * for both bean and target, but currently they are set to the same instance by the classes that | |
24 | * use this). | |
25 | */ | |
26 | public interface BeanAssembler | |
27 | { | |
28 | ||
29 | public BeanDefinitionBuilder getBean(); | |
30 | public BeanDefinition getTarget(); | |
31 | ||
32 | /** | |
33 | * Add a property defined by an attribute to the bean we are constructing. | |
34 | * | |
35 | * <p>Since an attribute value is always a string, we don't have to deal with complex types | |
36 | * here - the only issue is whether or not we have a reference. References are detected | |
37 | * by explicit annotation or by the "-ref" at the end of an attribute name. We do not | |
38 | * check the Spring repo to see if a name already exists since that could lead to | |
39 | * unpredictable behaviour. | |
40 | * (see {@link org.mule.config.spring.parsers.assembly.configuration.PropertyConfiguration}) | |
41 | * @param attribute The attribute to add | |
42 | */ | |
43 | void extendBean(Attr attribute); | |
44 | ||
45 | /** | |
46 | * Allow direct access to bean for more complex cases | |
47 | * | |
48 | * @param newName The property name to add | |
49 | * @param newValue The property value to add | |
50 | * @param isReference If true, a bean reference is added (and newValue must be a String) | |
51 | */ | |
52 | void extendBean(String newName, Object newValue, boolean isReference); | |
53 | ||
54 | /** | |
55 | * Add a property defined by an attribute to the parent of the bean we are constructing. | |
56 | * | |
57 | * <p>This is unusual. Normally you want {@link #extendBean(org.w3c.dom.Attr)}. | |
58 | * @param attribute The attribute to add | |
59 | */ | |
60 | void extendTarget(Attr attribute); | |
61 | ||
62 | /** | |
63 | * Allow direct access to target for more complex cases | |
64 | * | |
65 | * @param newName The property name to add | |
66 | * @param newValue The property value to add | |
67 | * @param isReference If true, a bean reference is added (and newValue must be a String) | |
68 | */ | |
69 | void extendTarget(String newName, Object newValue, boolean isReference); | |
70 | ||
71 | void extendTarget(String oldName, String newName, Object newValue); | |
72 | ||
73 | /** | |
74 | * Insert the bean we have built into the target (typically the parent bean). | |
75 | * | |
76 | * <p>This is the most complex case because the bean can have an aribtrary type. | |
77 | * @param oldName The identifying the bean (typically element name). | |
78 | */ | |
79 | void insertBeanInTarget(String oldName); | |
80 | ||
81 | /** | |
82 | * Copy the properties from the bean we have been building into the target (typically | |
83 | * the parent bean). In other words, the bean is a facade for the target. | |
84 | * | |
85 | * <p>This assumes that the source bean has been constructed correctly (ie the decisions about | |
86 | * what is ignored, a map, a list, etc) have already been made. All it does (apart from a | |
87 | * direct copy) is merge collections with those on the target when necessary. | |
88 | */ | |
89 | void copyBeanToTarget(); | |
90 | ||
91 | /** | |
92 | * Set a flag on the bean - this is used to communicate with | |
93 | * {@link org.mule.config.spring.MuleHierarchicalBeanDefinitionParserDelegate} | |
94 | * | |
95 | * @param flag The flag to set | |
96 | */ | |
97 | void setBeanFlag(String flag); | |
98 | ||
99 | } |