01: /*
02: * Copyright 1990-2006 Sun Microsystems, Inc. All Rights Reserved.
03: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
04: *
05: * This program is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU General Public License version
07: * 2 only, as published by the Free Software Foundation.
08: *
09: * This program is distributed in the hope that it will be useful, but
10: * WITHOUT ANY WARRANTY; without even the implied warranty of
11: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12: * General Public License version 2 for more details (a copy is
13: * included at /legal/license.txt).
14: *
15: * You should have received a copy of the GNU General Public License
16: * version 2 along with this work; if not, write to the Free Software
17: * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
18: * 02110-1301 USA
19: *
20: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
21: * Clara, CA 95054 or visit www.sun.com if you need additional
22: * information or have any questions.
23: */
24:
25: package com.sun.jumpimpl.module.download;
26:
27: import com.sun.jump.module.download.JUMPDownloadModule;
28: import com.sun.jump.module.download.JUMPDownloadModuleFactory;
29: import java.util.Map;
30:
31: public class DownloadModuleFactoryImpl extends
32: JUMPDownloadModuleFactory {
33:
34: private JUMPDownloadModule midpDownloadModule;
35: private JUMPDownloadModule otaDownloadModule;
36: private Map initdata;
37:
38: public static boolean verbose = ("true").equalsIgnoreCase(System
39: .getProperty("download.verbose"));
40:
41: public void load(Map map) {
42: this .initdata = map;
43: }
44:
45: public void unload() {
46: synchronized (this ) {
47: if (midpDownloadModule != null) {
48: midpDownloadModule.unload();
49: midpDownloadModule = null;
50: }
51: if (otaDownloadModule != null) {
52: otaDownloadModule.unload();
53: otaDownloadModule = null;
54: }
55: }
56: }
57:
58: private synchronized JUMPDownloadModule getMidpOtaDownloadModule() {
59: if (midpDownloadModule == null) {
60: midpDownloadModule = new MIDPOTADownloadModule();
61: midpDownloadModule.load(initdata);
62: }
63: return midpDownloadModule;
64: }
65:
66: private synchronized JUMPDownloadModule getOmaOtaDownloadModule() {
67: if (otaDownloadModule == null) {
68: otaDownloadModule = new OMAOTADownloadModule();
69: otaDownloadModule.load(initdata);
70: }
71: return otaDownloadModule;
72: }
73:
74: public JUMPDownloadModule getModule(String storeType) {
75: if (storeType
76: .equals(JUMPDownloadModuleFactory.PROTOCOL_MIDP_OTA))
77: return getMidpOtaDownloadModule();
78:
79: if (storeType
80: .equals(JUMPDownloadModuleFactory.PROTOCOL_OMA_OTA))
81: return getOmaOtaDownloadModule();
82:
83: return null;
84: }
85: }
|