01: /*
02: * Copyright 2001 Sun Microsystems, Inc. All rights reserved.
03: * PROPRIETARY/CONFIDENTIAL. Use of this product is subject to license terms.
04: */
05:
06: package com.sun.portal.subscriptions.admin.util;
07:
08: import java.util.*;
09:
10: public class ScheduleFactory {
11:
12: static Class taskClass = null;
13:
14: public static final String[] osNames = { "SunOS", "Windows",
15: "Linux", "HP-UX" };
16: public static final String[] classNames = {
17: "com.sun.portal.subscriptions.admin.util.SunOSTask",
18: "com.sun.portal.subscriptions.admin.util.WinOSTask",
19: "com.sun.portal.subscriptions.admin.util.SunOSTask",
20: "com.sun.portal.subscriptions.admin.util.SunOSTask" };
21:
22: static Map cmdMap = new HashMap();
23:
24: public ScheduleFactory() {
25: }
26:
27: public static void main(String[] args) throws Exception {
28: Class c = getTaskClass();
29: System.out.println("Found default TaskClass " + c.getName());
30: }
31:
32: static Class getTaskClass() throws Exception {
33: if (ScheduleFactory.taskClass == null) {
34: String os = System.getProperty("os.name");
35: for (int i = 0; i < ScheduleFactory.osNames.length; i++) {
36: if (os.equals(ScheduleFactory.osNames[i])
37: || os.startsWith(ScheduleFactory.osNames[i])) {
38: ScheduleFactory.taskClass = Class
39: .forName(ScheduleFactory.classNames[i]);
40: return ScheduleFactory.taskClass;
41: }
42: }
43: }
44: return ScheduleFactory.taskClass;
45: }
46:
47: public static Task getNewTask() throws Exception {
48: return (Task) getTaskClass().newInstance();
49: }
50:
51: public static void registerCmd(String name, String cmd) {
52: cmdMap.put(name, cmd);
53: }
54:
55: public static String getCmd(String name) {
56: return (String) cmdMap.get(name);
57: }
58: }
|