01: /*
02: * IzPack - Copyright 2001-2008 Julien Ponge, All Rights Reserved.
03: *
04: * http://izpack.org/
05: * http://izpack.codehaus.org/
06: *
07: * Copyright 2005 Klaus Bartz
08: *
09: * Licensed under the Apache License, Version 2.0 (the "License");
10: * you may not use this file except in compliance with the License.
11: * You may obtain a copy of the License at
12: *
13: * http://www.apache.org/licenses/LICENSE-2.0
14: *
15: * Unless required by applicable law or agreed to in writing, software
16: * distributed under the License is distributed on an "AS IS" BASIS,
17: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
18: * See the License for the specific language governing permissions and
19: * limitations under the License.
20: */
21:
22: package com.izforge.izpack.util;
23:
24: import com.izforge.izpack.installer.AutomatedInstallData;
25:
26: /*---------------------------------------------------------------------------*/
27: /**
28: * This class is the system independent base class for helpers which are system dependent in its
29: * subclasses.
30: *
31: * @author Klaus Bartz
32: */
33: /*---------------------------------------------------------------------------*/
34: public class OSClassHelper {
35:
36: protected AutomatedInstallData installdata;
37:
38: protected Class workerClass = null;
39:
40: protected Object worker = null;
41:
42: /**
43: * Default constructor
44: */
45: public OSClassHelper() {
46: super ();
47: }
48:
49: /**
50: * Creates an object which contains as worker an object of the given class name if possible. If
51: * not possible, only the stack trace will be printed, no exception will be raised. To determine
52: * the state, there is the method good.
53: *
54: * @param className full qualified class name of the needed worker
55: */
56: public OSClassHelper(String className) {
57: super ();
58:
59: try {
60: workerClass = Class.forName(className);
61: worker = workerClass.newInstance();
62: } catch (InstantiationException e) {
63: e.printStackTrace();
64: } catch (IllegalAccessException e) {
65: e.printStackTrace();
66: } catch (ClassNotFoundException e) {
67: e.printStackTrace();
68: // Do nothing, class not bound.
69: } catch (Exception e4) { // If the native lib is not found an unqualified Exception will be raised.
70: Debug.trace("Ctor OSClassHelper for " + className
71: + ": worker not available (" + e4.getMessage()
72: + ").");
73: return;
74: }
75: Debug.trace("Ctor OSClassHelper for " + className
76: + " is good: " + good());
77:
78: }
79:
80: /**
81: * Return whether the helper can do the work or not.
82: * @return whether the helper can do the work or not
83: */
84: public boolean good() {
85: return (worker != null);
86: }
87:
88: /**
89: * Verifies the helper.
90: * @param idata current install data
91: * @return whether the helper is good or not
92: * @throws Exception
93: */
94: public boolean verify(AutomatedInstallData idata) throws Exception {
95: installdata = idata;
96: return (false);
97: }
98:
99: }
|