Home | History | Annotate | Download | only in examples
      1  1449  tomee /*
      2  1449  tomee  * CDDL HEADER START
      3  1449  tomee  *
      4  1449  tomee  * The contents of this file are subject to the terms of the
      5  1449  tomee  * Common Development and Distribution License (the "License").
      6  1449  tomee  * You may not use this file except in compliance with the License.
      7  1449  tomee  *
      8  1449  tomee  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
      9  1449  tomee  * or http://www.opensolaris.org/os/licensing.
     10  1449  tomee  * See the License for the specific language governing permissions
     11  1449  tomee  * and limitations under the License.
     12  1449  tomee  *
     13  1449  tomee  * When distributing Covered Code, include this CDDL HEADER in each
     14  1449  tomee  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
     15  1449  tomee  * If applicable, add the following below this CDDL HEADER, with the
     16  1449  tomee  * fields enclosed by brackets "[]" replaced with your own identifying
     17  1449  tomee  * information: Portions Copyright [yyyy] [name of copyright owner]
     18  1449  tomee  *
     19  1449  tomee  * CDDL HEADER END
     20  1449  tomee  */
     21  1449  tomee 
     22  1449  tomee /*
     23  1449  tomee  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
     24  1449  tomee  * Use is subject to license terms.
     25  1449  tomee  *
     26  1449  tomee  * ident	"%Z%%M%	%I%	%E% SMI"
     27  1449  tomee  */
     28  1449  tomee 
     29  1449  tomee import org.opensolaris.os.dtrace.*;
     30  1449  tomee import java.io.File;
     31  1449  tomee 
     32  1449  tomee public class TestAPI {
     33  1449  tomee     public static void
     34  1449  tomee     main(String[] args)
     35  1449  tomee     {
     36  1449  tomee 	if (args.length < 1) {
     37  1449  tomee 	    System.err.println("Usage: java TestAPI <script> [ macroargs... ]");
     38  1449  tomee 	    System.exit(2);
     39  1449  tomee 	}
     40  1449  tomee 
     41  1449  tomee 	File file = new File(args[0]);
     42  1449  tomee 	String[] macroArgs = new String[args.length - 1];
     43  1449  tomee 	System.arraycopy(args, 1, macroArgs, 0, (args.length - 1));
     44  1449  tomee 
     45  1449  tomee 	Consumer consumer = new LocalConsumer();
     46  1449  tomee 	consumer.addConsumerListener(new ConsumerAdapter() {
     47  1449  tomee 	    public void dataReceived(DataEvent e) {
     48  1449  tomee 		System.out.println(e.getProbeData());
     49  1449  tomee 	    }
     50  1449  tomee 	});
     51  1449  tomee 
     52  1449  tomee 	try {
     53  1449  tomee 	    consumer.open();
     54  1449  tomee 	    consumer.compile(file, macroArgs);
     55  1449  tomee 	    consumer.enable();
     56  1449  tomee 	    consumer.go();
     57  1449  tomee 	} catch (Exception e) {
     58  1449  tomee 	    e.printStackTrace();
     59  1449  tomee 	    System.exit(1);
     60  1449  tomee 	}
     61  1449  tomee     }
     62  1449  tomee }
     63