All Downloads are FREE. Search and download functionalities are using the official Maven repository.

at.spardat.xma.pipes.XMAPipe Maven / Gradle / Ivy

There is a newer version: 6.0.2
Show newest version
/*******************************************************************************
 * Copyright (c) 2003, 2007 s IT Solutions AT Spardat GmbH .
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     s IT Solutions AT Spardat GmbH - initial API and implementation
 *******************************************************************************/

/*
 * @(#) $Id: XMAPipe.java 2089 2007-11-28 13:56:13Z s3460 $
 *
 * 
 * 
 * 
 *
 */
package at.spardat.xma.pipes;

import java.io.IOException;

/**
 * @author s3460  
 * @since version_number
 */
public abstract class XMAPipe {
    
    private String pipeName;
    
    protected XMAPipe(String pipeName) throws IOException {
        this.pipeName = pipeName;         
    }
    
    /**
     * Creates the pipe (as Object and on the OS). 
     * The actual implementation is OS depend, therfore a factory is used.
     * @param pipeName
     * @return a new created XMAPipe
     * @since version_number
     * @author s3460
     */
    public static XMAPipe getInstance(String pipeName) throws IOException {
        return new WindowsPipe(pipeName);
    }      
    
    /**
     * Closes the Pipe itself, which the can then not be used further.
     * Should always be called after pipe is not further used.
     * @since version_number
     * @author s3460
     */
    public abstract void destroyPipe() throws IOException;
    
    /**
     * Waits for a client to connect and connects to it.
     * 
     * @since version_number
     * @author s3460
     */
    public abstract void open() throws IOException;
    
    /**
     * Closes and flushes the connection to a client.
     * 
     * @since version_number
     * @author s3460
     */
    public abstract void close() throws IOException;
    
    /**
     * Writes out to pipe (client).
     * Do not try to write more than 4096 bytes ! (Actual Win32 Impl).
     * @param out - the byte[] must not be longer than 4096.
     * @since version_number
     * @author s3460
     */
    public abstract void write(byte[] out) throws IOException;
    
    /**
     * Reads from pipe (client).
     * @return the bytes read from the pipe
     * @since version_number
     * @author s3460
     */
    public abstract byte[] read() throws IOException;         
    
    /**
     * @return Returns the pipeName.
     */
    public String getPipeName() {
        return pipeName;
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy