1 19 package org.openharmonise.vfs.servers; 20 21 import java.lang.reflect.*; 22 import java.net.*; 23 24 import org.openharmonise.vfs.*; 25 import org.openharmonise.vfs.authentication.*; 26 27 28 39 public class Server { 40 41 44 private URI m_uri = null; 45 46 49 private AbstractVirtualFileSystem m_vfs = null; 50 51 57 public Server(URI uri, String sVFSClassName) { 58 super(); 59 this.m_uri = uri; 60 this.m_vfs = this.createVFS(uri, sVFSClassName, null, null); 61 } 62 63 70 public Server(URI uri, String sVFSClassName, AuthInfo authInfo) { 71 super(); 72 this.m_uri = uri; 73 this.m_vfs = this.createVFS(uri, sVFSClassName, authInfo, null); 74 } 75 76 83 public Server(URI uri, String sVFSClassName, AbstractAuthenticationStore authStore) { 84 super(); 85 this.m_uri = uri; 86 this.m_vfs = this.createVFS(uri, sVFSClassName, null, authStore); 87 } 88 89 99 private AbstractVirtualFileSystem createVFS(URI uri, String sVFSClassName, AuthInfo authInfo, AbstractAuthenticationStore authStore) { 100 AbstractVirtualFileSystem vfsRetn = null; 101 Class [] params = null; 102 Object [] vals = null; 103 if( authInfo==null && authStore==null ) { 104 params = new Class []{URI.class}; 105 vals = new Object []{uri}; 106 } else if( authInfo!=null ) { 107 params = new Class []{URI.class, AuthInfo.class}; 108 vals = new Object []{uri, authInfo}; 109 } else if( authStore!=null ) { 110 params = new Class []{URI.class, AbstractAuthenticationStore.class}; 111 vals = new Object []{uri, authStore}; 112 } 113 114 try { 115 vfsRetn = (AbstractVirtualFileSystem) Class.forName(sVFSClassName).getConstructor(params).newInstance( vals ); 116 } catch (IllegalArgumentException e) { 117 e.printStackTrace(); 118 } catch (SecurityException e) { 119 e.printStackTrace(); 120 } catch (InstantiationException e) { 121 e.printStackTrace(); 122 } catch (IllegalAccessException e) { 123 e.printStackTrace(); 124 } catch (InvocationTargetException e) { 125 e.printStackTrace(); 126 } catch (NoSuchMethodException e) { 127 e.printStackTrace(); 128 } catch (ClassNotFoundException e) { 129 e.printStackTrace(); 130 } 131 132 return vfsRetn; 133 } 134 135 140 public AbstractVirtualFileSystem getVFS() { 141 return this.m_vfs; 142 } 143 144 149 public URI getURI() { 150 return this.m_uri; 151 } 152 153 } 154
| Popular Tags
|