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

org.jgroups.tests.ParseMessages Maven / Gradle / Ivy

Go to download

This artifact provides a single jar that contains all classes required to use remote Jakarta Enterprise Beans and Jakarta Messaging, including all dependencies. It is intended for use by those not using maven, maven users should just import the Jakarta Enterprise Beans and Jakarta Messaging BOM's instead (shaded JAR's cause lots of problems with maven, as it is very easy to inadvertently end up with different versions on classes on the class path).

There is a newer version: 35.0.1.Final
Show newest version
package org.jgroups.tests;

import org.jgroups.Message;
import org.jgroups.util.Util;

import java.io.ByteArrayInputStream;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.util.List;

/**
 * Parses messages out of a captured file and writes them to stdout
 * @author Bela Ban
 */
public class ParseMessages {

    public static List parse(byte[] buf, int offset, int length) {
        return Util.parse(new ByteArrayInputStream(buf, offset, length));
    }

    public static List parse(String filename) throws FileNotFoundException {
        return Util.parse(new FileInputStream(filename));
    }


    public static void main(String[] args) throws FileNotFoundException {
        String file=null;

        for(int i=0; i < args.length; i++) {
            if(args[i].equals("-file")) {
                file=args[++i];
                continue;
            }
            help();
            return;
        }

        List msgs=parse(file);
        int cnt=1;
        for(Message msg: msgs)
            System.out.println(cnt++ + ": " + msg + ", hdrs: " + msg.printHeaders());
    }

    static private void help() {
        System.out.println("ParseMessages [-file ]");
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy