Consider the following class where I am overwriting the OutputStream
public class MyOutputStream extends java.io.OutputStream {
public String clientId = null;
public String fileId = null;
public String filelocation = null;
public DBClient clientobj = null;
public OuputStream out = null;
public MyOuputStream(String clientid, String fileid, String filelocation) {
this.clientid = clientid;
this.fileid = fileid;
this.filelocation = filelocation;
}
public void write(byte[] bytes) throws IOException {
out.write(bytes);
}
private DBClient getInstance(String clientid, String fileid) throws DBClientException {
return this.clientobj = DBClient.getInstance(clientid, fileid);
}
private OutputStream getOuputStream(DFSClient clientobj) throws Exception {
return this.out = clientobj.getOutputStream();
}
}
In the above code to write using
MyOuputStreamthe DBClient object and OuputStream has to be initialized before write operation
Someone, please suggest me an appropriate design pattern to solve this.
Aucun commentaire:
Enregistrer un commentaire