Package com.ibm.as400.access

Examples of com.ibm.as400.access.AS400


     *
     * @param timeout time to wait when reading from data queue. A value of -1
     *                indicates a blocking read.
     */
    public Exchange receive(long timeout) {
        BaseDataQueue queue = queueService.getDataQueue();
        try {
            if (endpoint.isKeyed()) {
                return receive((KeyedDataQueue) queue, timeout);
            } else {
                return receive((DataQueue) queue, timeout);
            }
        } catch (Exception e) {
            throw new RuntimeCamelException("Unable to read from data queue: " + queue.getName(), e);
        }
    }
View Full Code Here


    mAS400System = aS400System;
    mQSYSObject = qSYSObject;
    mOriginFile = originFile;
    try
    {
      mCharConverter = new CharConverter(encoding);
    }
    catch (UnsupportedEncodingException e)
    {
      throw new XException(Constants.LOCATION_EXTERN,
          Constants.LAYER_TECHNICAL,
View Full Code Here

    {
      // open original file for each resolution.
      mOriginFile.open(AS400File.READ_WRITE, 0,
          AS400File.COMMIT_LOCK_LEVEL_DEFAULT);

      CharConverter charConverter = new CharConverter(mEncoding);
      StringTokenizer tokenizer = new StringTokenizer(callData,
          Constants.LINE_SEPERATOR);

      while (tokenizer.hasMoreTokens())
      {
        String token = tokenizer.nextToken();
        // Characters written to it are translated into bytes array
        // according to a specified character encoding.
        dataByte = charConverter.stringToByteArray(token);
        // Save byteArray into Record based on the file format
        Record record = format.getNewRecord(dataByte);
        // write Record into file
        file.write(record);
      }
View Full Code Here

    AS400 as400 = as400Connection.getSystem();

    // Character converter
    try
    {
      mConverter = new CharConverter(as400.getCcsid());
    }
    catch (UnsupportedEncodingException e)
    {
      throw new XException(Constants.LOCATION_EXTERN,
          Constants.LAYER_TECHNICAL,
View Full Code Here

        // save record contents to the byte array
        inData = record.getContents();

        // convert this content to the String
        mConverter = new CharConverter(mEncoding);
        retBuffer.append(mConverter.byteArrayToString(inData));

        while ((record = mOriginFile.readNext()) != null)
        {
          // read records while they exist
View Full Code Here

    AS400 as400 = AS400Connection.getInstance(as400name).getSystem();
    String encoding = AS400FileBase.getEncoding(as400, system);

    try
    {
      conv = new CharConverter(encoding);
    }
    catch (UnsupportedEncodingException e)
    {
      throw new XException(Constants.LOCATION_EXTERN,
          Constants.LAYER_PROTOCOL,
View Full Code Here

     *
     * @param timeout time to wait when reading from data queue. A value of -1
     *            indicates a blocking read.
     */
    public Exchange receive(long timeout) {
        DataQueue queue = endpoint.getDataQueue();
        try {
            DataQueueEntry entry;
            if (timeout >= 0) {
                entry = queue.read((int)timeout);
            } else {
                entry = queue.read();
            }
            Exchange exchange = new DefaultExchange(endpoint.getCamelContext());
            if (entry != null) {
                if (endpoint.getFormat() == Format.binary) {
                    exchange.getIn().setBody(entry.getData());
View Full Code Here

     * data will be sent as a <code>byte[]</code>. If the endpoint's format is
     * set to {@link Format#text}, the data queue entry's data will be sent as a
     * <code>String</code>.
     */
    public void process(Exchange exchange) throws Exception {
        DataQueue queue = endpoint.getDataQueue();
        if (endpoint.getFormat() == Format.binary) {
            queue.write(exchange.getIn().getBody(byte[].class));
        } else {
            queue.write(exchange.getIn().getBody(String.class));
        }
    }
View Full Code Here

        return system;
    }

    protected DataQueue getDataQueue() {
        if (dataqueue == null) {
            dataqueue = new DataQueue(system, objectPath);
        }
        return dataqueue;
    }
View Full Code Here

     *
     * @param timeout time to wait when reading from data queue. A value of -1
     *            indicates a blocking read.
     */
    public Exchange receive(long timeout) {
        DataQueue queue = endpoint.getDataQueue();
        try {
            DataQueueEntry entry;
            if (timeout >= 0) {
                int seconds = (int)timeout / 1000;
                log.trace("Reading from data queue: {} with {} seconds timeout", queue.getName(), seconds);
                entry = queue.read(seconds);
            } else {
                log.trace("Reading from data queue: {} with no timeout", queue.getName());
                entry = queue.read(-1);
            }

            Exchange exchange = new DefaultExchange(endpoint.getCamelContext());
            if (entry != null) {
                if (endpoint.getFormat() == Format.binary) {
                    exchange.getIn().setBody(entry.getData());
                } else {
                    exchange.getIn().setBody(entry.getString());
                }
                return exchange;
            }
        } catch (AS400SecurityException e) {
            throw new RuntimeCamelException("Unable to read from data queue: " + queue.getName(), e);
        } catch (ErrorCompletingRequestException e) {
            throw new RuntimeCamelException("Unable to read from data queue: " + queue.getName(), e);
        } catch (IOException e) {
            throw new RuntimeCamelException("Unable to read from data queue: " + queue.getName(), e);
        } catch (IllegalObjectTypeException e) {
            throw new RuntimeCamelException("Unable to read from data queue: " + queue.getName(), e);
        } catch (InterruptedException e) {
            throw new RuntimeCamelException("Unable to read from data queue: " + queue.getName(), e);
        } catch (ObjectDoesNotExistException e) {
            throw new RuntimeCamelException("Unable to read from data queue: " + queue.getName(), e);
        }
        return null;
    }
View Full Code Here

TOP

Related Classes of com.ibm.as400.access.AS400

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.