01: /**
02: * $Id: XFileFactory.java,v 1.7 2005/11/30 11:26:36 ss150821 Exp $
03: * Copyright 2003 Sun Microsystems, Inc. All
04: * rights reserved. Use of this product is subject
05: * to license terms. Federal Acquisitions:
06: * Commercial Software -- Government Users
07: * Subject to Standard License Terms and
08: * Conditions.
09: *
10: * Sun, Sun Microsystems, the Sun logo, and Sun ONE
11: * are trademarks or registered trademarks of Sun Microsystems,
12: * Inc. in the United States and other countries.
13: */package com.sun.portal.netfile.servlet.java1;
14:
15: import java.lang.reflect.Constructor;
16: import com.sun.portal.log.common.PortalLogger;
17: import java.lang.reflect.InvocationTargetException;
18:
19: import com.sun.portal.netfile.servlet.java1.NetFileException;
20: import com.sun.portal.netfile.servlet.java1.XFileInterface;
21: import com.iplanet.sso.SSOToken;
22:
23: public class XFileFactory {
24:
25: private static XFileFactory factory = new XFileFactory();
26:
27: private XFileFactory() {
28: }
29:
30: public static XFileFactory newInstance() {
31: return new XFileFactory();
32: }
33:
34: public static XFileFactory getInstance() {
35: return factory;
36: }
37:
38: public XFileInterface newXFileInstance(NetFileLogManager logMgr,
39: String encoding, SSOToken token) throws NetFileException {
40:
41: try {
42: Class winFile = Class
43: .forName("com.sun.portal.netfile.servlet.java1.WinFile");
44: Class[] paramTypes = { NetFileLogManager.class,
45: String.class, SSOToken.class };
46: Constructor constructor = winFile
47: .getConstructor(paramTypes);
48: Object[] initArgs = { logMgr, encoding, token };
49: return (XFileInterface) constructor.newInstance(initArgs);
50: } catch (NoClassDefFoundError err) {
51: throw new NetFileException(
52: NetFileException.NETFILE_CLASSNOTFOUND,
53: "Win interface software not found.");
54: } catch (ClassNotFoundException cnfe) {
55: throw new NetFileException(
56: NetFileException.NETFILE_CLASSNOTFOUND,
57: "Win interface software not found.");
58: } catch (NoSuchMethodException cnfe) {
59: throw new NetFileException(
60: NetFileException.NETFILE_CREATEERROR,
61: "Unable to launch the interface software");
62: } catch (InstantiationException e) {
63: throw new NetFileException(
64: NetFileException.NETFILE_CREATEERROR,
65: "Unable to launch the interface software");
66: } catch (IllegalAccessException e) {
67: throw new NetFileException(
68: NetFileException.NETFILE_CREATEERROR,
69: "Unable to launch the interface software");
70: } catch (InvocationTargetException e) {
71: e.printStackTrace();
72: throw new NetFileException(
73: NetFileException.NETFILE_CREATEERROR,
74: "Unable to launch the interface software");
75: }
76: }
77:
78: }
|