Project

General

Profile

« Previous | Next » 

Revision 4442

Added by daigle about 16 years ago

Change the ServiceInterface into a base class called BaseService. All services extend BaseService.

View differences:

src/edu/ucsb/nceas/metacat/service/ServiceInterface.java
1
/**
2
 *  '$RCSfile$'
3
 *    Purpose: A Class that implements utility methods like:
4
 *             1/ Reding all doctypes from db connection
5
 *             2/ Reading DTD or Schema file from Metacat catalog system
6
 *             3/ Reading Lore type Data Guide from db connection
7
 *  Copyright: 2000 Regents of the University of California and the
8
 *             National Center for Ecological Analysis and Synthesis
9
 *    Authors: Jivka Bojilova
10
 * 
11
 *   '$Author$'
12
 *     '$Date$'
13
 * '$Revision$'
14
 *
15
 * This program is free software; you can redistribute it and/or modify
16
 * it under the terms of the GNU General Public License as published by
17
 * the Free Software Foundation; either version 2 of the License, or
18
 * (at your option) any later version.
19
 *
20
 * This program is distributed in the hope that it will be useful,
21
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
 * GNU General Public License for more details.
24
 *
25
 * You should have received a copy of the GNU General Public License
26
 * along with this program; if not, write to the Free Software
27
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
28
 */
29

  
30
package edu.ucsb.nceas.metacat.service;
31

  
32
/**
33
 * A suite of utility classes for querying DB
34
 * 
35
 */
36
public interface ServiceInterface {
37

  
38
	public boolean isRestartable = false;
39
	
40
	/**
41
	 * TODO MCD define register(), restartable() and restart() abstract methods
42
	 */
43

  
44
}
45 0

  
src/edu/ucsb/nceas/metacat/service/ServiceService.java
1
/**
2
 *  '$RCSfile$'
3
 *    Purpose: A Class that implements session utility methods 
4
 *  Copyright: 2008 Regents of the University of California and the
5
 *             National Center for Ecological Analysis and Synthesis
6
 *    Authors: Michael Daigle
7
 * 
8
 *   '$Author: daigle $'
9
 *     '$Date: 2008-10-09 09:53:18 -0700 (Thu, 09 Oct 2008) $'
10
 * '$Revision: 4429 $'
11
 *
12
 * This program is free software; you can redistribute it and/or modify
13
 * it under the terms of the GNU General Public License as published by
14
 * the Free Software Foundation; either version 2 of the License, or
15
 * (at your option) any later version.
16
 *
17
 * This program is distributed in the hope that it will be useful,
18
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
 * GNU General Public License for more details.
21
 *
22
 * You should have received a copy of the GNU General Public License
23
 * along with this program; if not, write to the Free Software
24
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
25
 */
26

  
27
package edu.ucsb.nceas.metacat.service;
28

  
29
import java.util.Hashtable;
30
import java.util.Vector;
31

  
32
import org.apache.log4j.Logger;
33

  
34
import edu.ucsb.nceas.metacat.util.SessionData;
35

  
36
public class ServiceService extends BaseService {
37
	
38
	private static ServiceService serviceService = null;
39
	
40
	private static Logger logMetacat = Logger.getLogger(ServiceService.class);
41
	private static Hashtable<String, Class> ServiceList = null;
42

  
43
	/**
44
	 * private constructor since this is a singleton
45
	 */
46
	private ServiceService() {
47
		
48
	}
49
	
50
	/**
51
	 * Get the single instance of ServiceService.
52
	 * 
53
	 * @return the single instance of ServiceService
54
	 */
55
	public static ServiceService getInstance() {
56
		if (serviceService == null) {
57
			serviceService = new ServiceService();
58
		}
59
		return serviceService;
60
	}
61
	
62
	public boolean refreshable() {
63
		return false;
64
	}
65
	
66
	protected void doRefresh() {
67
		return;
68
	}
69
	
70

  
71
}
0 72

  
src/edu/ucsb/nceas/metacat/service/XMLSchemaService.java
45 45
import edu.ucsb.nceas.utilities.PropertyNotFoundException;
46 46
import edu.ucsb.nceas.utilities.StringUtil;
47 47

  
48
public class XMLSchemaService implements ServiceInterface {
48
public class XMLSchemaService extends BaseService {
49 49
	
50 50
	public static final String NAMESPACEKEYWORD = "xmlns";
51 51
	
......
98 98
		return xmlSchemaService;
99 99
	}
100 100
	
101
	public boolean refreshable() {
102
		return true;
103
	}
104
	
101 105
	/**
102 106
	 * refresh the persistant values in this service.
103 107
	 */
104
	public static void refresh() {
108
	protected void doRefresh() {
105 109
		try {
106 110
			populateRegisteredSchemaList();
107 111
			setUseFullSchemaValidation();
......
229 233
	 */
230 234
	private static void createRegisteredNameSpaceAndLocationString() {
231 235
		boolean firstRow = true;
236
		nameSpaceAndLocationString = "";
237
		
232 238
		for (XMLSchema xmlSchema : registeredSchemaList) {
233 239
			if (!firstRow) {
234 240
				nameSpaceAndLocationString += " ";
......
243 249
	 * create a lsit of all namespaces in the registered schema list.
244 250
	 */
245 251
	private static void createRegisteredNameSpaceList() {
252
		nameSpaceList = new Vector<String>();
246 253
		for (XMLSchema xmlSchema : registeredSchemaList) {
247 254
			nameSpaceList.add(xmlSchema.getFileNamespace());
248 255
		}
src/edu/ucsb/nceas/metacat/service/SessionService.java
28 28

  
29 29
import java.util.Hashtable;
30 30

  
31
import javax.servlet.http.Cookie;
32
import javax.servlet.http.HttpServletRequest;
33

  
34 31
import org.apache.log4j.Logger;
35 32

  
36 33
import edu.ucsb.nceas.metacat.util.SessionData;
37 34

  
38
public class SessionService implements ServiceInterface {
35
public class SessionService extends BaseService {
39 36
	
40 37
	private static SessionService sessionService = null;
41 38
	
......
64 61
		return sessionService;
65 62
	}
66 63
	
64
	public boolean refreshable() {
65
		return false;
66
	}
67
	
68
	protected void doRefresh() {
69
		return;
70
	}
71
	
67 72
	/**
68 73
	 * Register a session in the session hash table.  This uses
69 74
	 * the parameters passed in to create a SessionData object.
src/edu/ucsb/nceas/metacat/service/DatabaseService.java
30 30

  
31 31
import edu.ucsb.nceas.dbadapter.AbstractDatabase;
32 32

  
33
public class DatabaseService implements ServiceInterface {
33
public class DatabaseService extends BaseService {
34 34
	
35 35
	private static DatabaseService databaseService = null;
36 36
	private static AbstractDatabase dbAdapter;	
......
61 61
		return databaseService;
62 62
	}
63 63
	
64
	public boolean refreshable() {
65
		return false;
66
	}
67
	
68
	protected void doRefresh() {
69
		return;
70
	}
71
	
64 72
    /**
65 73
	 * Instantiate a class using the name of the class at runtime
66 74
	 *
src/edu/ucsb/nceas/metacat/service/PropertyService.java
29 29
import java.io.IOException;
30 30
import java.util.Map;
31 31
import java.util.Set;
32
import java.util.SortedMap;
33 32
import java.util.Vector;
34 33

  
35 34
import javax.servlet.ServletContext;
......
42 41
import edu.ucsb.nceas.metacat.util.UtilException;
43 42
import edu.ucsb.nceas.utilities.FileUtil;
44 43
import edu.ucsb.nceas.utilities.GeneralPropertyException;
45
import edu.ucsb.nceas.utilities.MetaDataGroup;
46
import edu.ucsb.nceas.utilities.MetaDataProperty;
47 44
import edu.ucsb.nceas.utilities.PropertiesMetaData;
48 45
import edu.ucsb.nceas.utilities.PropertyNotFoundException;
49 46
import edu.ucsb.nceas.utilities.SortedProperties;
......
51 48
/**
52 49
 * A suite of utility classes for the metadata configuration utility
53 50
 */
54
public class PropertyService implements ServiceInterface {
51
public class PropertyService extends BaseService {
55 52
	
56 53
	private static PropertyService propertyService = null;
57 54
	
......
121 118
		return propertyService;
122 119
	}
123 120
	
121
	public boolean refreshable() {
122
		return false;
123
	}
124
	
125
	protected void doRefresh() {
126
		return;
127
	}
128
	
124 129
	/**
125 130
	 * Initialize the singleton.
126 131
	 * 
src/edu/ucsb/nceas/metacat/service/SkinPropertyService.java
49 49
/**
50 50
 * A suite of utility classes for the skin configuration utility
51 51
 */
52
public class SkinPropertyService implements ServiceInterface {
52
public class SkinPropertyService extends BaseService {
53 53
	
54 54
	private static SkinPropertyService skinService = null;
55 55
	
......
97 97
		return skinService;
98 98
	}
99 99
	
100
	public boolean refreshable() {
101
		return false;
102
	}
103
	
104
	protected void doRefresh() {
105
		return;
106
	}
107
	
100 108
	/**
101 109
	 * Initialize the singleton.
102 110
	 * 
src/edu/ucsb/nceas/metacat/service/BaseService.java
1
/**
2
 *  '$RCSfile$'
3
 *    Purpose: A Class that implements utility methods like:
4
 *             1/ Reding all doctypes from db connection
5
 *             2/ Reading DTD or Schema file from Metacat catalog system
6
 *             3/ Reading Lore type Data Guide from db connection
7
 *  Copyright: 2000 Regents of the University of California and the
8
 *             National Center for Ecological Analysis and Synthesis
9
 *    Authors: Jivka Bojilova
10
 * 
11
 *   '$Author$'
12
 *     '$Date$'
13
 * '$Revision$'
14
 *
15
 * This program is free software; you can redistribute it and/or modify
16
 * it under the terms of the GNU General Public License as published by
17
 * the Free Software Foundation; either version 2 of the License, or
18
 * (at your option) any later version.
19
 *
20
 * This program is distributed in the hope that it will be useful,
21
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
23
 * GNU General Public License for more details.
24
 *
25
 * You should have received a copy of the GNU General Public License
26
 * along with this program; if not, write to the Free Software
27
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
28
 */
29

  
30
package edu.ucsb.nceas.metacat.service;
31

  
32
/**
33
 * A suite of utility classes for querying DB
34
 * 
35
 */
36
public abstract class BaseService {
37

  
38
	public abstract boolean refreshable();
39
	
40
	protected abstract void doRefresh();
41
	
42
	public void refresh() {
43
		if (refreshable()) {
44
			doRefresh();
45
		}
46
	}
47

  
48
}
0 49

  

Also available in: Unified diff