KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > ve > luz > ica > remoteio > RemoteFileImpl


1 /*
2  * Copyright (c) 2003 by The Jackass Team
3  * Licensed under the Open Software License version 2.0
4  */

5 package ve.luz.ica.remoteio JavaDoc;
6
7 import java.io.BufferedInputStream JavaDoc;
8 import java.io.File JavaDoc;
9 import java.io.FileInputStream JavaDoc;
10 import java.io.FileNotFoundException JavaDoc;
11 import java.io.InputStream JavaDoc;
12
13 import org.omg.PortableServer.POA JavaDoc;
14 import org.omg.PortableServer.POAPackage.ServantNotActive JavaDoc;
15 import org.omg.PortableServer.POAPackage.WrongPolicy JavaDoc;
16
17 /**
18  *
19  * @author Carlos Arévalo
20  */

21 public class RemoteFileImpl extends RemoteFilePOA
22 {
23     private POA JavaDoc poa = null;
24     private File JavaDoc file = null;
25
26     /**
27      * Class constructor
28      * @param path the path to the file that will be accesed remotely
29      * @param thePoa the poa where the RemoteFile was created
30      */

31     public RemoteFileImpl(String JavaDoc path, POA JavaDoc thePoa)
32     {
33         this.file = new File JavaDoc(path);
34         this.poa = thePoa;
35     }
36
37     /**
38      * @see ve.luz.ica.remoteio.RemoteFileOperations#getInputStream()
39      */

40     public RemoteInputStream getInputStream() throws RemoteIOException
41     {
42         InputStream JavaDoc in;
43         try
44         {
45             in = new BufferedInputStream JavaDoc(new FileInputStream JavaDoc(this.file));
46             RemoteInputStreamImpl risImpl = new RemoteInputStreamImpl(in);
47             org.omg.CORBA.Object JavaDoc obj = poa.servant_to_reference(risImpl);
48             RemoteInputStream ris = RemoteInputStreamHelper.narrow(obj);
49             return ris;
50         }
51         catch (FileNotFoundException JavaDoc e)
52         {
53             e.printStackTrace();
54             throw new RemoteIOException(e.getMessage());
55         }
56         catch (ServantNotActive JavaDoc e)
57         {
58             e.printStackTrace();
59             throw new RemoteIOException(e.getMessage());
60         }
61         catch (WrongPolicy JavaDoc e)
62         {
63             e.printStackTrace();
64             throw new RemoteIOException(e.getMessage());
65         }
66     }
67
68     /**
69      * @see ve.luz.ica.remoteio.RemoteFileOperations#getName()
70      */

71     public String JavaDoc getName()
72     {
73         return file.getName();
74     }
75
76     /**
77      * @see ve.luz.ica.remoteio.RemoteFileOperations#getPath()
78      */

79     public String JavaDoc getPath()
80     {
81         return file.getPath();
82     }
83 }
84
Popular Tags