1 5 package ve.luz.ica.remoteio ; 6 7 import java.io.BufferedInputStream ; 8 import java.io.File ; 9 import java.io.FileInputStream ; 10 import java.io.FileNotFoundException ; 11 import java.io.InputStream ; 12 13 import org.omg.PortableServer.POA ; 14 import org.omg.PortableServer.POAPackage.ServantNotActive ; 15 import org.omg.PortableServer.POAPackage.WrongPolicy ; 16 17 21 public class RemoteFileImpl extends RemoteFilePOA 22 { 23 private POA poa = null; 24 private File file = null; 25 26 31 public RemoteFileImpl(String path, POA thePoa) 32 { 33 this.file = new File (path); 34 this.poa = thePoa; 35 } 36 37 40 public RemoteInputStream getInputStream() throws RemoteIOException 41 { 42 InputStream in; 43 try 44 { 45 in = new BufferedInputStream (new FileInputStream (this.file)); 46 RemoteInputStreamImpl risImpl = new RemoteInputStreamImpl(in); 47 org.omg.CORBA.Object obj = poa.servant_to_reference(risImpl); 48 RemoteInputStream ris = RemoteInputStreamHelper.narrow(obj); 49 return ris; 50 } 51 catch (FileNotFoundException e) 52 { 53 e.printStackTrace(); 54 throw new RemoteIOException(e.getMessage()); 55 } 56 catch (ServantNotActive e) 57 { 58 e.printStackTrace(); 59 throw new RemoteIOException(e.getMessage()); 60 } 61 catch (WrongPolicy e) 62 { 63 e.printStackTrace(); 64 throw new RemoteIOException(e.getMessage()); 65 } 66 } 67 68 71 public String getName() 72 { 73 return file.getName(); 74 } 75 76 79 public String getPath() 80 { 81 return file.getPath(); 82 } 83 } 84 | Popular Tags |