Revision 5b2db12a
Added by Andreas Müller about 3 years ago
cdmlib-remote/src/main/java/eu/etaxonomy/cdm/remote/dto/assembler/DozerBeanMapperFactoryBean.java | ||
---|---|---|
1 | 1 |
/** |
2 | 2 |
* Copyright (C) 2007 EDIT |
3 |
* European Distributed Institute of Taxonomy
|
|
3 |
* European Distributed Institute of Taxonomy |
|
4 | 4 |
* http://www.e-taxonomy.eu |
5 |
*
|
|
5 |
* |
|
6 | 6 |
* The contents of this file are subject to the Mozilla Public License Version 1.1 |
7 | 7 |
* See LICENSE.TXT at the top of this package for the full license terms. |
8 | 8 |
*/ |
... | ... | |
40 | 40 |
|
41 | 41 |
public final void setMappingFiles(final Resource[] mappingFiles) { |
42 | 42 |
this.mappingFiles = mappingFiles; |
43 |
}
|
|
43 |
} |
|
44 | 44 |
|
45 |
public final void setCustomConverters(final List<CustomConverter> customConverters) {
|
|
45 |
public final void setCustomConverters(final List<CustomConverter> customConverters) { |
|
46 | 46 |
this.customConverters = customConverters; |
47 |
}
|
|
47 |
} |
|
48 | 48 |
|
49 |
public final void setEventListeners(final List<DozerEventListener> eventListeners) {
|
|
49 |
public final void setEventListeners(final List<EventListener> eventListeners) {
|
|
50 | 50 |
this.eventListeners = eventListeners; |
51 |
}
|
|
51 |
} |
|
52 | 52 |
|
53 |
public final void setFactories(final Map<String, BeanFactory> factories) {
|
|
53 |
public final void setFactories(final Map<String, BeanFactory> factories) { |
|
54 | 54 |
this.factories = factories; |
55 | 55 |
} |
56 | 56 |
|
... | ... | |
67 | 67 |
// ================================================================================================================================== |
68 | 68 |
public final Object getObject() throws Exception { |
69 | 69 |
return this.beanMapper; |
70 |
} |
|
71 |
public final Class<Mapper> getObjectType() { |
|
70 |
} |
|
71 |
|
|
72 |
@Override |
|
73 |
public final Class<Mapper> getObjectType() { |
|
72 | 74 |
return Mapper.class; |
73 |
} |
|
74 |
public final boolean isSingleton() { |
|
75 |
} |
|
76 |
|
|
77 |
@Override |
|
78 |
public final boolean isSingleton() { |
|
75 | 79 |
return true; |
76 |
} |
|
80 |
} |
|
81 |
|
|
82 |
// ================================================================================================================================== |
|
83 |
// interface 'InitializingBean' |
|
84 |
// ================================================================================================================================== |
|
85 |
@Override |
|
86 |
public final void afterPropertiesSet() throws Exception { |
|
87 |
|
|
88 |
DozerBeanMapperBuilder beanMapperBuilder = DozerBeanMapperBuilder.create(); |
|
89 |
|
|
90 |
final List<String> mappings = new ArrayList<>(this.mappingFiles.length); |
|
91 |
if (this.mappingFiles != null) { |
|
92 |
for (Resource mappingFile : this.mappingFiles) { |
|
93 |
mappings.add(mappingFile.getURL().toString()); |
|
94 |
} |
|
95 |
beanMapperBuilder.withMappingFiles(mappings); |
|
96 |
} |
|
77 | 97 |
|
78 |
// ================================================================================================================================== |
|
79 |
// interface 'InitializingBean' |
|
80 |
// ================================================================================================================================== |
|
81 |
public final void afterPropertiesSet() throws Exception { |
|
82 |
this.beanMapper = new DozerBeanMapper(); |
|
83 |
|
|
84 |
if (this.mappingFiles != null) { |
|
85 |
final List<String> mappings = new ArrayList<String>(this.mappingFiles.length); |
|
86 |
for (Resource mappingFile : this.mappingFiles) { |
|
87 |
mappings.add(mappingFile.getURL().toString()); |
|
88 |
} |
|
89 |
this.beanMapper.setMappingFiles(mappings); |
|
90 |
} |
|
91 | 98 |
if (this.customConverters != null) { |
92 |
this.beanMapper.setCustomConverters(this.customConverters);
|
|
99 |
beanMapperBuilder.withCustomConverters(customConverters);
|
|
93 | 100 |
} |
94 | 101 |
if (this.eventListeners != null) { |
95 |
this.beanMapper.setEventListeners(this.eventListeners);
|
|
102 |
beanMapperBuilder.withEventListeners(eventListeners);
|
|
96 | 103 |
} |
97 | 104 |
if (this.factories != null) { |
98 |
this.beanMapper.setFactories(this.factories);
|
|
105 |
beanMapperBuilder.withBeanFactorys(factories);
|
|
99 | 106 |
} |
100 |
|
|
107 |
|
|
101 | 108 |
if(this.customFieldMapper != null) { |
102 |
this.beanMapper.setCustomFieldMapper(customFieldMapper);
|
|
109 |
beanMapperBuilder.withCustomFieldMapper(customFieldMapper);
|
|
103 | 110 |
} |
104 |
|
|
111 |
|
|
105 | 112 |
if(this.customConvertersWithId != null) { |
106 |
this.beanMapper.setCustomConvertersWithId(customConvertersWithId);
|
|
113 |
beanMapperBuilder.withCustomConvertersWithIds(customConvertersWithId);
|
|
107 | 114 |
} |
108 |
} |
|
109 |
|
|
110 |
} |
|
115 |
} |
|
116 |
} |
Also available in: Unified diff
cleanup