001: /*
002: * $Header: /export/home/cvsroot/MyPersonalizerRepository/MyPersonalizer/Subsystems/Kernel/Sources/es/udc/mypersonalizer/kernel/model/repository/sql/plain/PlainRepositoryAccessorFactory.java,v 1.1.1.1 2004/03/25 12:08:36 fbellas Exp $
003: * $Revision: 1.1.1.1 $
004: * $Date: 2004/03/25 12:08:36 $
005: *
006: * =============================================================================
007: *
008: * Copyright (c) 2003, The MyPersonalizer Development Group
009: * (http://www.tic.udc.es/~fbellas/mypersonalizer/index.html) at
010: * University Of A Coruna
011: * All rights reserved.
012: *
013: * Redistribution and use in source and binary forms, with or without
014: * modification, are permitted provided that the following conditions are met:
015: *
016: * - Redistributions of source code must retain the above copyright notice,
017: * this list of conditions and the following disclaimer.
018: *
019: * - Redistributions in binary form must reproduce the above copyright notice,
020: * this list of conditions and the following disclaimer in the documentation
021: * and/or other materials provided with the distribution.
022: *
023: * - Neither the name of the University Of A Coruna nor the names of its
024: * contributors may be used to endorse or promote products derived from
025: * this software without specific prior written permission.
026: *
027: * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
028: * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
029: * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
030: * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
031: * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
032: * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
033: * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
034: * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
035: * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
036: * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
037: * POSSIBILITY OF SUCH DAMAGE.
038: *
039: */
040:
041: package es.udc.mypersonalizer.kernel.model.repository.sql.plain;
042:
043: import es.udc.mypersonalizer.kernel.model.repository.interfaces.MetaServiceAccessor;
044: import es.udc.mypersonalizer.kernel.model.repository.interfaces.RepositoryAccessorFactory;
045: import es.udc.mypersonalizer.kernel.model.repository.interfaces.ServicePropertyAccessor;
046: import es.udc.mypersonalizer.kernel.model.repository.interfaces.CachedServiceReplyAccessor;
047: import es.udc.mypersonalizer.kernel.model.repository.interfaces.ServiceButtonsStateAccessor;
048: import es.udc.mypersonalizer.kernel.model.repository.interfaces.UserRegistrationInformationAccessor;
049: import es.udc.mypersonalizer.kernel.model.repository.interfaces.UserGroupAccessor;
050: import es.udc.mypersonalizer.kernel.model.repository.interfaces.ServicePrototypeAccessor;
051: import es.udc.mypersonalizer.kernel.model.repository.interfaces.ServicePermissionsAccessor;
052: import es.udc.mypersonalizer.kernel.model.repository.interfaces.WorkspaceDefinitionAccessor;
053: import es.udc.mypersonalizer.kernel.model.repository.interfaces.ServiceConfigurationAccessor;
054: import es.udc.mypersonalizer.kernel.model.repository.interfaces.DesktopLayoutAccessor;
055: import es.udc.mypersonalizer.kernel.model.repository.interfaces.WorkspaceLayoutAccessor;
056: import es.udc.mypersonalizer.kernel.util.exceptions.InternalErrorException;
057:
058: /**
059: * An Plain-based implementation of the abstract factory
060: * {@link RepositoryAccessorFactory}.
061: *
062: * @author Fernando Bellas
063: * @since 1.0
064: */
065: public class PlainRepositoryAccessorFactory extends
066: RepositoryAccessorFactory {
067: /*
068: * The implementation only creates one instance of each type of
069: * accessor, since they do not mantain state specific to the caller.
070: *
071: * IMPORTANT. Accessors can not be created in the constructor, since
072: * some of them (e.g. PlainServiceButtonsStateAccessor) use a storer
073: * (e.g. ServiceButtonsStateStorer) that makes use of
074: * MetaServiceRegistrySingleton in its constructor.
075: * MetaServiceRegistrySingleton in turn uses
076: * RepositoryAccessorFactory.getInstance(). So, if accessors were
077: * created in the constructor, some of them would cause
078: * a call to RepositoryAccessorFactory.getInstance while the instance
079: * is still being created.
080: */
081:
082: private PlainServicePropertyAccessor servicePropertyAccessor;
083: private PlainCachedServiceReplyAccessor cachedServiceReplyAccessor;
084: private PlainServiceButtonsStateAccessor serviceButtonsStateAccessor;
085: private PlainUserRegistrationInformationAccessor userRegistrationInformationAccessor;
086: private PlainUserGroupAccessor userGroupAccessor;
087: private PlainServicePrototypeAccessor servicePrototypeAccessor;
088: private PlainServicePermissionsAccessor servicePermissionsAccessor;
089: private PlainWorkspaceDefinitionAccessor workspaceDefinitionAccessor;
090: private PlainServiceConfigurationAccessor serviceConfigurationAccessor;
091: private PlainDesktopLayoutAccessor desktopLayoutAccessor;
092: private PlainWorkspaceLayoutAccessor workspaceLayoutAccessor;
093: private PlainMetaServiceAccessor metaServiceAccessor;
094:
095: /**
096: * Constructs an instance of this class.
097: */
098: public PlainRepositoryAccessorFactory()
099: throws InternalErrorException {
100: }
101:
102: public ServicePropertyAccessor createServicePropertyAccessor()
103: throws InternalErrorException {
104:
105: if (servicePropertyAccessor == null) {
106: servicePropertyAccessor = new PlainServicePropertyAccessor();
107: }
108:
109: return servicePropertyAccessor;
110:
111: }
112:
113: public CachedServiceReplyAccessor createCachedServiceReplyAccessor()
114: throws InternalErrorException {
115:
116: if (cachedServiceReplyAccessor == null) {
117: cachedServiceReplyAccessor = new PlainCachedServiceReplyAccessor();
118: }
119:
120: return cachedServiceReplyAccessor;
121:
122: }
123:
124: public ServiceButtonsStateAccessor createServiceButtonsStateAccessor()
125: throws InternalErrorException {
126:
127: if (serviceButtonsStateAccessor == null) {
128: serviceButtonsStateAccessor = new PlainServiceButtonsStateAccessor();
129: }
130:
131: return serviceButtonsStateAccessor;
132:
133: }
134:
135: public UserRegistrationInformationAccessor createUserRegistrationInformationAccessor()
136: throws InternalErrorException {
137:
138: if (userRegistrationInformationAccessor == null) {
139: userRegistrationInformationAccessor = new PlainUserRegistrationInformationAccessor();
140: }
141:
142: return userRegistrationInformationAccessor;
143:
144: }
145:
146: public UserGroupAccessor createUserGroupAccessor()
147: throws InternalErrorException {
148:
149: if (userGroupAccessor == null) {
150: userGroupAccessor = new PlainUserGroupAccessor();
151: }
152:
153: return userGroupAccessor;
154: }
155:
156: public ServicePrototypeAccessor createServicePrototypeAccessor()
157: throws InternalErrorException {
158:
159: if (servicePrototypeAccessor == null) {
160: servicePrototypeAccessor = new PlainServicePrototypeAccessor();
161: }
162:
163: return servicePrototypeAccessor;
164: }
165:
166: public ServicePermissionsAccessor createServicePermissionsAccessor()
167: throws InternalErrorException {
168:
169: if (servicePermissionsAccessor == null) {
170: servicePermissionsAccessor = new PlainServicePermissionsAccessor();
171: }
172:
173: return servicePermissionsAccessor;
174: }
175:
176: public WorkspaceDefinitionAccessor createWorkspaceDefinitionAccessor()
177: throws InternalErrorException {
178:
179: if (workspaceDefinitionAccessor == null) {
180: workspaceDefinitionAccessor = new PlainWorkspaceDefinitionAccessor();
181: }
182:
183: return workspaceDefinitionAccessor;
184: }
185:
186: public ServiceConfigurationAccessor createServiceConfigurationAccessor()
187: throws InternalErrorException {
188:
189: if (serviceConfigurationAccessor == null) {
190: serviceConfigurationAccessor = new PlainServiceConfigurationAccessor();
191: }
192:
193: return serviceConfigurationAccessor;
194: }
195:
196: public DesktopLayoutAccessor createDesktopLayoutAccessor()
197: throws InternalErrorException {
198:
199: if (desktopLayoutAccessor == null) {
200: desktopLayoutAccessor = new PlainDesktopLayoutAccessor();
201: }
202:
203: return desktopLayoutAccessor;
204: }
205:
206: public WorkspaceLayoutAccessor createWorkspaceLayoutAccessor()
207: throws InternalErrorException {
208:
209: if (workspaceLayoutAccessor == null) {
210: workspaceLayoutAccessor = new PlainWorkspaceLayoutAccessor();
211: }
212:
213: return workspaceLayoutAccessor;
214: }
215:
216: public MetaServiceAccessor createMetaServiceAccessor()
217: throws InternalErrorException {
218:
219: if (metaServiceAccessor == null) {
220: metaServiceAccessor = new PlainMetaServiceAccessor();
221: }
222:
223: return metaServiceAccessor;
224:
225: }
226:
227: }
|