1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34 package fr.paris.lutece.plugins.document.service;
35
36 import fr.paris.lutece.plugins.document.business.attributes.AttributeTypeHome;
37 import fr.paris.lutece.portal.service.util.AppLogService;
38 import fr.paris.lutece.util.ReferenceItem;
39 import fr.paris.lutece.util.ReferenceList;
40
41 import java.util.HashMap;
42 import java.util.Map;
43
44
45
46
47
48 public class AttributeService
49 {
50 private static AttributeService _singleton;
51 private static Map<String, AttributeManager> _mapManagers = new HashMap<String, AttributeManager>( );
52
53
54 private AttributeService( )
55 {
56 }
57
58
59
60
61
62 public static synchronized AttributeService getInstance( )
63 {
64 if ( _singleton == null )
65 {
66 _singleton = new AttributeService( );
67 _singleton.init( );
68 }
69
70 return _singleton;
71 }
72
73
74
75
76 private void init( )
77 {
78 ReferenceList listManagers = AttributeTypeHome.getAttributeManagersList( );
79
80 for ( ReferenceItem item : listManagers )
81 {
82 String strManagerKey = item.getCode( );
83 String strManagerClass = item.getName( );
84
85 try
86 {
87 AttributeManager/../../fr/paris/lutece/plugins/document/service/AttributeManager.html#AttributeManager">AttributeManager manager = (AttributeManager) Class.forName( strManagerClass ).newInstance( );
88 manager.setAttributeTypeCode( item.getCode( ) );
89 _mapManagers.put( strManagerKey, manager );
90 }
91 catch ( IllegalAccessException e )
92 {
93 AppLogService.error( e.getMessage( ), e );
94 }
95 catch ( ClassNotFoundException e )
96 {
97 AppLogService.error( e.getMessage( ), e );
98 }
99 catch ( InstantiationException e )
100 {
101 AppLogService.error( e.getMessage( ), e );
102 }
103 }
104 }
105
106
107
108
109
110
111 public AttributeManager getManager( String strAttributeType )
112 {
113 return _mapManagers.get( strAttributeType );
114 }
115 }