src/jdk.jfr/share/classes/jdk/jfr/internal/consumer/JdkJfrConsumer.java
changeset 58863 c16ac7a2eba4
parent 52850 f527b24990d7
equal deleted inserted replaced
58861:2c3cc4b01880 58863:c16ac7a2eba4
       
     1 /*
       
     2  * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
       
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
       
     4  *
       
     5  * This code is free software; you can redistribute it and/or modify it
       
     6  * under the terms of the GNU General Public License version 2 only, as
       
     7  * published by the Free Software Foundation.  Oracle designates this
       
     8  * particular file as subject to the "Classpath" exception as provided
       
     9  * by Oracle in the LICENSE file that accompanied this code.
       
    10  *
       
    11  * This code is distributed in the hope that it will be useful, but WITHOUT
       
    12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
       
    13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
       
    14  * version 2 for more details (a copy is included in the LICENSE file that
       
    15  * accompanied this code).
       
    16  *
       
    17  * You should have received a copy of the GNU General Public License version
       
    18  * 2 along with this work; if not, write to the Free Software Foundation,
       
    19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
       
    20  *
       
    21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
       
    22  * or visit www.oracle.com if you need additional information or have any
       
    23  * questions.
       
    24  */
       
    25 
       
    26 package jdk.jfr.internal.consumer;
       
    27 
       
    28 import java.io.IOException;
       
    29 import java.util.Comparator;
       
    30 import java.util.List;
       
    31 
       
    32 import jdk.jfr.consumer.RecordedClass;
       
    33 import jdk.jfr.consumer.RecordedClassLoader;
       
    34 import jdk.jfr.consumer.RecordedEvent;
       
    35 import jdk.jfr.consumer.RecordedFrame;
       
    36 import jdk.jfr.consumer.RecordedMethod;
       
    37 import jdk.jfr.consumer.RecordedObject;
       
    38 import jdk.jfr.consumer.RecordedStackTrace;
       
    39 import jdk.jfr.consumer.RecordedThread;
       
    40 import jdk.jfr.consumer.RecordedThreadGroup;
       
    41 import jdk.jfr.consumer.RecordingFile;
       
    42 import jdk.jfr.internal.Type;
       
    43 /*
       
    44  * Purpose of this class is to give package private access to
       
    45  * the jdk.jfr.consumer package
       
    46  */
       
    47 public abstract class JdkJfrConsumer {
       
    48 
       
    49     private static JdkJfrConsumer instance;
       
    50 
       
    51     // Initialization will trigger setAccess being called
       
    52     private static void forceInitializetion() {
       
    53         try {
       
    54             Class<?> c = RecordedObject.class;
       
    55             Class.forName(c.getName(), true, c.getClassLoader());
       
    56         } catch (ClassNotFoundException e) {
       
    57             throw new InternalError("Should not happen");
       
    58         }
       
    59     }
       
    60 
       
    61     public static void setAccess(JdkJfrConsumer access) {
       
    62         instance = access;
       
    63     }
       
    64 
       
    65     public static JdkJfrConsumer instance() {
       
    66         if (instance == null) {
       
    67             forceInitializetion();
       
    68         }
       
    69         return instance;
       
    70     }
       
    71 
       
    72     public abstract List<Type> readTypes(RecordingFile file) throws IOException;
       
    73 
       
    74     public abstract boolean isLastEventInChunk(RecordingFile file);
       
    75 
       
    76     public abstract Object getOffsetDataTime(RecordedObject event, String name);
       
    77 
       
    78     public abstract RecordedClass newRecordedClass(ObjectContext objectContext, long id, Object[] values);
       
    79 
       
    80     public abstract RecordedClassLoader newRecordedClassLoader(ObjectContext objectContext, long id, Object[] values);
       
    81 
       
    82     public abstract RecordedStackTrace newRecordedStackTrace(ObjectContext objectContext, Object[] values);
       
    83 
       
    84     public abstract RecordedThreadGroup newRecordedThreadGroup(ObjectContext objectContext, Object[] values);
       
    85 
       
    86     public abstract RecordedFrame newRecordedFrame(ObjectContext objectContext, Object[] values);
       
    87 
       
    88     public abstract RecordedThread newRecordedThread(ObjectContext objectContext, long id, Object[] values);
       
    89 
       
    90     public abstract RecordedMethod newRecordedMethod(ObjectContext objectContext, Object[] values);
       
    91 
       
    92     public abstract RecordedEvent newRecordedEvent(ObjectContext objectContext, Object[] objects, long l, long m);
       
    93 
       
    94     public abstract Comparator<? super RecordedEvent> eventComparator();
       
    95 
       
    96     public abstract void setStartTicks(RecordedEvent event, long startTicks);
       
    97 
       
    98     public abstract void setEndTicks(RecordedEvent event, long endTicks);
       
    99 
       
   100     public abstract Object[] eventValues(RecordedEvent event);
       
   101 }