// Path: example/src/main/java/org/async/example/resultset/FileResultSetInterface.java
// public interface FileResultSetInterface extends Remote {
//     String SER_FILE_NAME = "file.resultset.server.ser";
//     ResultSet<Byte> retrieve(File file, int bufferSize) throws RemoteException;
// }
// 
// Path: asyncrmi/src/main/java/org/async/rmi/Util.java
// public class Util {
//     @SuppressWarnings("UnusedDeclaration")
//     private static final Logger logger = LoggerFactory.getLogger(Util.class);
// 
//     public static <T> T writeAndRead(T object) throws IOException, ClassNotFoundException {
//         byte[] bytes;
//         try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); MarshalOutputStream out = new MarshalOutputStream(byteArrayOutputStream)) {
//             out.writeObject(object);
//             bytes = byteArrayOutputStream.toByteArray();
//         }
//         try (InputStream is = new ByteArrayInputStream(bytes); MarshalInputStream ois = new MarshalInputStream(is)) {
//             //noinspection unchecked
//             return (T) ois.readObject();
//         }
//     }
// 
//     public static byte[] asByteArray(InputStream in) throws IOException {
//         try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
//             int nRead;
//             byte[] data = new byte[16384];
// 
//             while ((nRead = in.read(data, 0, data.length)) != -1) {
//                 out.write(data, 0, nRead);
//             }
// 
//             out.flush();
//             return out.toByteArray();
//         }
//     }
// 
//     public static void writeToFile(Object object, File file) throws IOException {
//         try (FileOutputStream fileOutputStream = new FileOutputStream(file); MarshalOutputStream out = new MarshalOutputStream(fileOutputStream)) {
//             out.writeObject(object);
//         }
//     }
// 
//     public static Object readFromFile(File file) throws IOException, ClassNotFoundException {
//         try (FileInputStream fileInputStream = new FileInputStream(file); MarshalInputStream in = new MarshalInputStream(fileInputStream)) {
//             return in.readObject();
//         }
//     }
// 
//     public static <T> T readYmlFile(File file, T instance) throws IOException, IllegalAccessException, IntrospectionException, InvocationTargetException, InstantiationException {
//         try (InputStream is = new FileInputStream(file)) {
//             return readYmlFile(is, instance);
//         }
//     }
// 
// 
//     public static <T> T readYmlContent(String content, T instance) throws IOException, IllegalAccessException, IntrospectionException, InvocationTargetException, InstantiationException {
//         try (InputStream is = new ByteArrayInputStream(content.getBytes())) {
//             return readYmlFile(is, instance);
//         }
//     }
// 
//     public static <T> T readYmlFile(InputStream is, T instance) throws MalformedURLException, IntrospectionException, IllegalAccessException, InvocationTargetException, InstantiationException {
//         Yaml yaml = new Yaml();
//         @SuppressWarnings("rawtypes") Map map = (Map) yaml.load(is);
//         return read(map, instance);
//     }
// 
// 
//     private static <T> Stream<T> toStream(Collection<T> collection) {
//         if (collection == null) {
//             return Stream.empty();
//         } else {
//             return collection.stream();
//         }
//     }
// 
//     public static <T> T read(Map properties, T instance) throws IntrospectionException, InvocationTargetException, IllegalAccessException, MalformedURLException, InstantiationException {
//         return PropertiesReader.read(properties, instance);
//     }
// 
//     public static Configuration readConfiguration(File ymlFile) throws InvocationTargetException, IntrospectionException, InstantiationException, IllegalAccessException, IOException {
//         return readYmlFile(ymlFile, new Configuration());
//     }
//     public static Configuration readConfiguration(String configuration) throws InvocationTargetException, IntrospectionException, InstantiationException, IllegalAccessException, IOException {
//         return readYmlContent(configuration, new Configuration());
//     }
// }


import org.async.example.resultset.FileResultSetInterface;
import org.async.rmi.ResultSet;
import org.async.rmi.Util;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;
package org.async.example.resultset.client;



/**
 * Created by Barak Bar Orion.
 */
public class ClientImpl {
    @SuppressWarnings("UnusedDeclaration")
    private static final Logger logger = LoggerFactory.getLogger(ClientImpl.class);

    public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
        if(args.length == 0){
            logger.warn("Missing text file param");
            return;
        }
// Path: example/src/main/java/org/async/example/resultset/FileResultSetInterface.java
// public interface FileResultSetInterface extends Remote {
//     String SER_FILE_NAME = "file.resultset.server.ser";
//     ResultSet<Byte> retrieve(File file, int bufferSize) throws RemoteException;
// }
// 
// Path: asyncrmi/src/main/java/org/async/rmi/Util.java
// public class Util {
//     @SuppressWarnings("UnusedDeclaration")
//     private static final Logger logger = LoggerFactory.getLogger(Util.class);
// 
//     public static <T> T writeAndRead(T object) throws IOException, ClassNotFoundException {
//         byte[] bytes;
//         try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); MarshalOutputStream out = new MarshalOutputStream(byteArrayOutputStream)) {
//             out.writeObject(object);
//             bytes = byteArrayOutputStream.toByteArray();
//         }
//         try (InputStream is = new ByteArrayInputStream(bytes); MarshalInputStream ois = new MarshalInputStream(is)) {
//             //noinspection unchecked
//             return (T) ois.readObject();
//         }
//     }
// 
//     public static byte[] asByteArray(InputStream in) throws IOException {
//         try (ByteArrayOutputStream out = new ByteArrayOutputStream()) {
//             int nRead;
//             byte[] data = new byte[16384];
// 
//             while ((nRead = in.read(data, 0, data.length)) != -1) {
//                 out.write(data, 0, nRead);
//             }
// 
//             out.flush();
//             return out.toByteArray();
//         }
//     }
// 
//     public static void writeToFile(Object object, File file) throws IOException {
//         try (FileOutputStream fileOutputStream = new FileOutputStream(file); MarshalOutputStream out = new MarshalOutputStream(fileOutputStream)) {
//             out.writeObject(object);
//         }
//     }
// 
//     public static Object readFromFile(File file) throws IOException, ClassNotFoundException {
//         try (FileInputStream fileInputStream = new FileInputStream(file); MarshalInputStream in = new MarshalInputStream(fileInputStream)) {
//             return in.readObject();
//         }
//     }
// 
//     public static <T> T readYmlFile(File file, T instance) throws IOException, IllegalAccessException, IntrospectionException, InvocationTargetException, InstantiationException {
//         try (InputStream is = new FileInputStream(file)) {
//             return readYmlFile(is, instance);
//         }
//     }
// 
// 
//     public static <T> T readYmlContent(String content, T instance) throws IOException, IllegalAccessException, IntrospectionException, InvocationTargetException, InstantiationException {
//         try (InputStream is = new ByteArrayInputStream(content.getBytes())) {
//             return readYmlFile(is, instance);
//         }
//     }
// 
//     public static <T> T readYmlFile(InputStream is, T instance) throws MalformedURLException, IntrospectionException, IllegalAccessException, InvocationTargetException, InstantiationException {
//         Yaml yaml = new Yaml();
//         @SuppressWarnings("rawtypes") Map map = (Map) yaml.load(is);
//         return read(map, instance);
//     }
// 
// 
//     private static <T> Stream<T> toStream(Collection<T> collection) {
//         if (collection == null) {
//             return Stream.empty();
//         } else {
//             return collection.stream();
//         }
//     }
// 
//     public static <T> T read(Map properties, T instance) throws IntrospectionException, InvocationTargetException, IllegalAccessException, MalformedURLException, InstantiationException {
//         return PropertiesReader.read(properties, instance);
//     }
// 
//     public static Configuration readConfiguration(File ymlFile) throws InvocationTargetException, IntrospectionException, InstantiationException, IllegalAccessException, IOException {
//         return readYmlFile(ymlFile, new Configuration());
//     }
//     public static Configuration readConfiguration(String configuration) throws InvocationTargetException, IntrospectionException, InstantiationException, IllegalAccessException, IOException {
//         return readYmlContent(configuration, new Configuration());
//     }
// }


// Path: example/src/main/java/org/async/example/resultset/client/ClientImpl.java
import org.async.example.resultset.FileResultSetInterface;
import org.async.rmi.ResultSet;
import org.async.rmi.Util;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.IOException;

package org.async.example.resultset.client;



/**
 * Created by Barak Bar Orion.
 */
public class ClientImpl {
    @SuppressWarnings("UnusedDeclaration")
    private static final Logger logger = LoggerFactory.getLogger(ClientImpl.class);

    public static void main(String[] args) throws IOException, ClassNotFoundException, InterruptedException {
        if(args.length == 0){
            logger.warn("Missing text file param");
            return;
        }
        FileResultSetInterface server = (FileResultSetInterface) Util.readFromFile(new File(new File(".."), FileResultSetInterface.SER_FILE_NAME));