01: /*
02: * This file is part of PFIXCORE.
03: *
04: * PFIXCORE is free software; you can redistribute it and/or modify
05: * it under the terms of the GNU Lesser General Public License as published by
06: * the Free Software Foundation; either version 2 of the License, or
07: * (at your option) any later version.
08: *
09: * PFIXCORE is distributed in the hope that it will be useful,
10: * but WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12: * GNU Lesser General Public License for more details.
13: *
14: * You should have received a copy of the GNU Lesser General Public License
15: * along with PFIXCORE; if not, write to the Free Software
16: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17: */
18:
19: package de.schlund.pfixcore.editor2.core.spring;
20:
21: import java.util.HashMap;
22:
23: import de.schlund.pfixcore.editor2.core.dom.Image;
24: import de.schlund.pfixcore.editor2.core.spring.internal.ImageImpl;
25:
26: /**
27: * Implementation of ImageFactoryService
28: *
29: * @author Sebastian Marsching <sebastian.marsching@1und1.de>
30: */
31: public class ImageFactoryServiceImpl implements ImageFactoryService {
32:
33: private VariantFactoryService variantfactory;
34:
35: private ProjectFactoryService projectfactory;
36:
37: private HashMap<String, Image> cache;
38:
39: private PathResolverService pathresolver;
40:
41: private FileSystemService filesystem;
42:
43: private SecurityManagerService securitymanager;
44:
45: private BackupService backup;
46:
47: public void setFileSystemService(FileSystemService filesystem) {
48: this .filesystem = filesystem;
49: }
50:
51: public void setPathResolverService(PathResolverService pathresolver) {
52: this .pathresolver = pathresolver;
53: }
54:
55: public void setSecurityManagerService(
56: SecurityManagerService securitymanager) {
57: this .securitymanager = securitymanager;
58: }
59:
60: public void setVariantFactoryService(
61: VariantFactoryService variantfactory) {
62: this .variantfactory = variantfactory;
63: }
64:
65: public void setProjectFactoryService(
66: ProjectFactoryService projectfactory) {
67: this .projectfactory = projectfactory;
68: }
69:
70: public void setBackupService(BackupService backup) {
71: this .backup = backup;
72: }
73:
74: public ImageFactoryServiceImpl() {
75: this .cache = new HashMap<String, Image>();
76: }
77:
78: public Image getImage(String path) {
79: synchronized (this .cache) {
80: if (!this .cache.containsKey(path)) {
81: Image image = new ImageImpl(this .variantfactory,
82: this .projectfactory, this .pathresolver,
83: this .filesystem, this .securitymanager,
84: this .backup, path);
85: this .cache.put(path, image);
86: }
87: return (Image) this.cache.get(path);
88: }
89:
90: }
91:
92: }
|