001: /**********************************************************************************
002: * $URL: https://source.sakaiproject.org/svn/memory/tags/sakai_2-4-1/memory-api/api/src/java/org/sakaiproject/memory/cover/MemoryService.java $
003: * $Id: MemoryService.java 7220 2006-03-29 15:23:17Z ggolden@umich.edu $
004: ***********************************************************************************
005: *
006: * Copyright (c) 2003, 2004, 2005, 2006 The Sakai Foundation.
007: *
008: * Licensed under the Educational Community License, Version 1.0 (the "License");
009: * you may not use this file except in compliance with the License.
010: * You may obtain a copy of the License at
011: *
012: * http://www.opensource.org/licenses/ecl1.php
013: *
014: * Unless required by applicable law or agreed to in writing, software
015: * distributed under the License is distributed on an "AS IS" BASIS,
016: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
017: * See the License for the specific language governing permissions and
018: * limitations under the License.
019: *
020: **********************************************************************************/package org.sakaiproject.memory.cover;
021:
022: import org.sakaiproject.component.cover.ComponentManager;
023:
024: /**
025: * <p>
026: * MemoryService is a static Cover for the {@link org.sakaiproject.memory.api.MemoryService MemoryService}; see that interface for usage details.
027: * </p>
028: *
029: * @author University of Michigan, Sakai Software Development Team
030: * @version $Revision: 7220 $
031: */
032: public class MemoryService {
033: /**
034: * Access the component instance: special cover only method.
035: *
036: * @return the component instance.
037: */
038: public static org.sakaiproject.memory.api.MemoryService getInstance() {
039: if (ComponentManager.CACHE_COMPONENTS) {
040: if (m_instance == null)
041: m_instance = (org.sakaiproject.memory.api.MemoryService) ComponentManager
042: .get(org.sakaiproject.memory.api.MemoryService.class);
043: return m_instance;
044: } else {
045: return (org.sakaiproject.memory.api.MemoryService) ComponentManager
046: .get(org.sakaiproject.memory.api.MemoryService.class);
047: }
048: }
049:
050: private static org.sakaiproject.memory.api.MemoryService m_instance = null;
051:
052: public static long getAvailableMemory() {
053: org.sakaiproject.memory.api.MemoryService service = getInstance();
054: if (service == null)
055: return 0;
056:
057: return service.getAvailableMemory();
058: }
059:
060: public static void resetCachers()
061: throws org.sakaiproject.memory.api.MemoryPermissionException {
062: org.sakaiproject.memory.api.MemoryService service = getInstance();
063: if (service == null)
064: return;
065:
066: service.resetCachers();
067: }
068:
069: public static void registerCacher(
070: org.sakaiproject.memory.api.Cacher param0) {
071: org.sakaiproject.memory.api.MemoryService service = getInstance();
072: if (service == null)
073: return;
074:
075: service.registerCacher(param0);
076: }
077:
078: public static void unregisterCacher(
079: org.sakaiproject.memory.api.Cacher param0) {
080: org.sakaiproject.memory.api.MemoryService service = getInstance();
081: if (service == null)
082: return;
083:
084: service.unregisterCacher(param0);
085: }
086:
087: public static org.sakaiproject.memory.api.Cache newCache(
088: org.sakaiproject.memory.api.CacheRefresher param0,
089: java.lang.String param1) {
090: org.sakaiproject.memory.api.MemoryService service = getInstance();
091: if (service == null)
092: return null;
093:
094: return service.newCache(param0, param1);
095: }
096:
097: public static org.sakaiproject.memory.api.Cache newHardCache(
098: org.sakaiproject.memory.api.CacheRefresher param0,
099: java.lang.String param1) {
100: org.sakaiproject.memory.api.MemoryService service = getInstance();
101: if (service == null)
102: return null;
103:
104: return service.newHardCache(param0, param1);
105: }
106:
107: public static org.sakaiproject.memory.api.Cache newCache(
108: org.sakaiproject.memory.api.CacheRefresher param0,
109: long param1) {
110: org.sakaiproject.memory.api.MemoryService service = getInstance();
111: if (service == null)
112: return null;
113:
114: return service.newCache(param0, param1);
115: }
116:
117: public static org.sakaiproject.memory.api.Cache newHardCache(
118: org.sakaiproject.memory.api.CacheRefresher param0,
119: long param1) {
120: org.sakaiproject.memory.api.MemoryService service = getInstance();
121: if (service == null)
122: return null;
123:
124: return service.newHardCache(param0, param1);
125: }
126:
127: public static org.sakaiproject.memory.api.Cache newHardCache(
128: long param0, java.lang.String param1) {
129: org.sakaiproject.memory.api.MemoryService service = getInstance();
130: if (service == null)
131: return null;
132:
133: return service.newHardCache(param0, param1);
134: }
135:
136: public static org.sakaiproject.memory.api.Cache newCache() {
137: org.sakaiproject.memory.api.MemoryService service = getInstance();
138: if (service == null)
139: return null;
140:
141: return service.newCache();
142: }
143:
144: public static org.sakaiproject.memory.api.Cache newHardCache() {
145: org.sakaiproject.memory.api.MemoryService service = getInstance();
146: if (service == null)
147: return null;
148:
149: return service.newHardCache();
150: }
151:
152: public static org.sakaiproject.memory.api.MultiRefCache newMultiRefCache(
153: long param0) {
154: org.sakaiproject.memory.api.MemoryService service = getInstance();
155: if (service == null)
156: return null;
157:
158: return service.newMultiRefCache(param0);
159: }
160:
161: public static java.lang.String getStatus() {
162: org.sakaiproject.memory.api.MemoryService service = getInstance();
163: if (service == null)
164: return null;
165:
166: return service.getStatus();
167: }
168: }
|