1 /**
2 * $Id: BaseManagerImpl.java 34 2006-10-26 04:26:45Z maldito_orco $
3 * $Revision: 34 $
4 * $Date: 2006-10-26 01:26:45 -0300 (Thu, 26 Oct 2006) $
5 *
6 * =========================================================================
7 *
8 * Copyright 2005 Tubo
9 *
10 * Licensed under the Apache License, Version 2.0 (the "License");
11 * you may not use this file except in compliance with the License.
12 * You may obtain a copy of the License at
13 *
14 * http://www.apache.org/licenses/LICENSE-2.0
15 *
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
21 */
22 package org.tubo.resource.baseimpl;
23
24
25 import org.apache.commons.logging.Log;
26 import org.apache.commons.logging.LogFactory;
27
28 import org.tubo.resource.Manager;
29 import org.tubo.resource.Resource;
30 import org.tubo.resource.ResourceManager;
31 import org.tubo.exception.TuboResourceException;
32 import org.tubo.exception.TuboException;
33
34 import java.util.Properties;
35
36 /**
37 * Created: Apr 5, 2006 9:16:42 PM
38 * Last Modification Date: $Date: 2006-10-26 01:26:45 -0300 (Thu, 26 Oct 2006) $
39 *
40 * @author jvlio (jvlio@users.sourceforge.net)
41 * @version $Revision: 34 $
42 */
43 public class BaseManagerImpl implements Manager {
44 public static final String RCS_ID = "$Id: BaseManagerImpl.java 34 2006-10-26 04:26:45Z maldito_orco $";
45 private static Log log = LogFactory.getLog(BaseManagerImpl.class);
46
47 /** Manager ID (in spring Bean id) */
48 private String id = null;
49
50 /** ResourceManager for this Manager */
51 private ResourceManager resourceManager = null;
52
53 /** Manager Strategy (singleton, irrestricted or pooled) */
54 private ManagerStrategy strategy = null;
55
56 /** Configuration properties */
57 private Properties properties = new Properties();
58
59 /**
60 * Default Constructor
61 */
62 public BaseManagerImpl() {
63 }
64
65 public String getId() {
66 return id;
67 }
68
69 public void setId(String id) {
70 this.id = id;
71 }
72
73 /**
74 * Get for the ResourceManager linked to this Manager
75 * @return the ResourceManager for this Manager
76 */
77 public ResourceManager getResourceManager() {
78 return resourceManager;
79 }
80
81 /**
82 * Set for the ResourceManager for this Manager
83 * @param resourceManager the ResourceManager for this Manager
84 * @throws TuboException
85 */
86 public void setResourceManager(ResourceManager resourceManager) throws TuboException {
87 this.resourceManager = resourceManager;
88 }
89
90 public ManagerStrategy getStrategy() {
91 return strategy;
92 }
93
94 public void setStrategy(ManagerStrategy strategy) {
95 this.strategy = strategy;
96 }
97
98 /**
99 * <p>
100 * Resource Get.<br>
101 * This method is delegated to strategy.
102 * </p>
103 * @return a Resource
104 * @throws TuboResourceException
105 */
106 public Resource get() throws TuboResourceException {
107 return strategy.get();
108 }
109
110 /**
111 * <p>
112 * Restore resource.<br>
113 * This method is delegated to strategy.
114 * </p>
115 * @param resource Resource to be restored by strategy.
116 * @throws TuboResourceException
117 */
118 public void restore(Resource resource) throws TuboResourceException {
119 strategy.restore(resource);
120 }
121
122 public Properties getProperties() { return properties; }
123 public void setProperties(Properties properties) {
124 this.properties = properties;
125 }
126
127 public String getProperty(String name) {
128 return properties.getProperty(name);
129 }
130
131 public void setProperty(String name, String value) {
132 properties.setProperty(name,value);
133 }
134 }