Added better comments and slight changes in the mecanisms that get the version number...
authorWilliam Bourque <william.bourque@polymtl.ca>
Tue, 16 Mar 2010 16:53:51 +0000 (16:53 +0000)
committerWilliam Bourque <william.bourque@polymtl.ca>
Tue, 16 Mar 2010 16:53:51 +0000 (16:53 +0000)
12 files changed:
org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/JniEvent.java
org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/JniMarker.java
org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/JniMarkerField.java
org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/JniParser.java
org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/JniTrace.java
org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/JniTracefile.java
org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/Jni_C_Common.java
org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/common/JniTime.java
org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/common/Jni_C_Constant.java
org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/common/Jni_C_Pointer.java
org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/factory/JniTraceFactory.java
org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/factory/JniTraceVersion.java

index d4ccc981a736c17e031be737e29e020ca0178179..5a84e4f52f372718ecd1076affe272e57b0b8ddf 100644 (file)
@@ -114,9 +114,9 @@ public abstract class JniEvent extends Jni_C_Common implements Comparable<JniEve
      *            
      * @exception JniException
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.common.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniMarker
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTracefile
+     * @see org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer
+     * @see org.eclipse.linuxtools.lttng.jni.JniMarker
+     * @see org.eclipse.linuxtools.lttng.jni.JniTracefile
      */
     public JniEvent(Jni_C_Pointer newEventPtr, HashMap<Integer, JniMarker> newMarkersMap, JniTracefile newParentTracefile) throws JniException {
 
@@ -153,9 +153,9 @@ public abstract class JniEvent extends Jni_C_Common implements Comparable<JniEve
      * 
      * If the move fails, the event will not get populated and the last event data will still be available.
      * 
-     * @return LTT read status, as defined in Jni_C_Common.
+     * @return LTT read status, as defined in Jni_C_Constant.
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.common.eclipse.linuxtools.lttng.jni.Jni_C_Common
+     * @see org.eclipse.linuxtools.lttng.jni.common.Jni_C_Constant
      */
      public int readNextEvent() {
         // Ask Ltt to read the next event for this particular tracefile
@@ -178,9 +178,9 @@ public abstract class JniEvent extends Jni_C_Common implements Comparable<JniEve
      * 
      * If the seek fails, the event will not get populated and the last event data will still be available.<p>
      * 
-     * @return LTT read status, as defined in Jni_C_Common
+     * @return LTT read status, as defined in Jni_C_Constant
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.common.eclipse.linuxtools.lttng.jni.Jni_C_Common
+     * @see org.eclipse.linuxtools.lttng.jni.common.Jni_C_Constant
      */
     public int seekToTime(JniTime seekTime) {
         // Ask Ltt to read the next event for this particular tracefile
@@ -201,9 +201,9 @@ public abstract class JniEvent extends Jni_C_Common implements Comparable<JniEve
      * 
      * If the seek fails, we will seek back to the previous position, so the event will stay in a consistent state.<p> 
      * 
-     * @return LTT read status, as defined in Jni_C_Common
+     * @return LTT read status, as defined in Jni_C_Constant
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.common.eclipse.linuxtools.lttng.jni.Jni_C_Common
+     * @see org.eclipse.linuxtools.lttng.jni.common.Jni_C_Constant
      */
     public int seekOrFallBack(JniTime seekTime) {
         // Save the old time
@@ -231,9 +231,9 @@ public abstract class JniEvent extends Jni_C_Common implements Comparable<JniEve
      * 
      * A status different of EOK probably means there is no event associated to this tracefile.
      * 
-     * @return LTT read status, as defined in Jni_C_Common
+     * @return LTT read status, as defined in Jni_C_Constant
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.common.eclipse.linuxtools.lttng.jni.Jni_C_Common
+     * @see org.eclipse.linuxtools.lttng.jni.common.Jni_C_Constant
      */
     public int positionToFirstEvent() {
         eventState = ltt_positionToFirstEvent(tracefilePtr.getPointer());
@@ -246,7 +246,7 @@ public abstract class JniEvent extends Jni_C_Common implements Comparable<JniEve
      * 
      * @return Reference to the marker for this tracefile's event or null if none.
      *  
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniMarker
+     * @see org.eclipse.linuxtools.lttng.jni.JniMarker
      */
     public JniMarker requestEventMarker() {
         return markersMap.get(getEventMarkerId());
@@ -275,7 +275,7 @@ public abstract class JniEvent extends Jni_C_Common implements Comparable<JniEve
      * 
      * @return  Reference to the JniMarker object for this event or null if none. 
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniMarker
+     * @see org.eclipse.linuxtools.lttng.jni.JniMarker
      */
     public String requestEventSource() {
         // *** TODO ***
@@ -295,7 +295,7 @@ public abstract class JniEvent extends Jni_C_Common implements Comparable<JniEve
      * 
      * @return Object that contain the parsed payload
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniParser
+     * @see org.eclipse.linuxtools.lttng.jni.JniParser
      */
     public Object parseFieldById(int fieldId) {
         return JniParser.parseField(this, fieldId);
@@ -310,7 +310,7 @@ public abstract class JniEvent extends Jni_C_Common implements Comparable<JniEve
      * 
      * @return Object that contain the parsed payload
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniParser
+     * @see org.eclipse.linuxtools.lttng.jni.JniParser
      */
     public Object parseFieldByName(String fieldName) {
         return JniParser.parseField(this, fieldName);
@@ -321,7 +321,7 @@ public abstract class JniEvent extends Jni_C_Common implements Comparable<JniEve
      * 
      * @return HashMap<String, Object> which is the parsedContent objects and their name as key.
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniParser 
+     * @see org.eclipse.linuxtools.lttng.jni.JniParser 
      */
     public HashMap<String, Object> parseAllFields() {
         return JniParser.parseAllFields(this);
@@ -364,7 +364,7 @@ public abstract class JniEvent extends Jni_C_Common implements Comparable<JniEve
      * 
      * @return The actual (long converted) pointer or NULL.
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.common.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
+     * @see org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer
      */
     public Jni_C_Pointer getTracefilePtr() {
         return new Jni_C_Pointer( ltt_getTracefilePtr(thisEventPtr.getPointer()) );
@@ -378,7 +378,7 @@ public abstract class JniEvent extends Jni_C_Common implements Comparable<JniEve
      * 
      * @return The actual (long converted) pointer or NULL.
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.common.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
+     * @see org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer
      */
     public Jni_C_Pointer getEventPtr() {
         return thisEventPtr;
@@ -393,7 +393,7 @@ public abstract class JniEvent extends Jni_C_Common implements Comparable<JniEve
      *
      * @return  The parent tracefile 
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTracefile
+     * @see org.eclipse.linuxtools.lttng.jni.JniTracefile
      */
     public JniTracefile getParentTracefile() {
         return parentTracefile;
@@ -467,4 +467,5 @@ public abstract class JniEvent extends Jni_C_Common implements Comparable<JniEve
 
         return returnData;
     }
+    
 }
index a1b180a9c177d48b9f3fbfc367e0b8005196d424..6999deb6f0893a9b6d80af41fa5956e3a194091c 100644 (file)
@@ -165,7 +165,7 @@ public abstract class JniMarker extends Jni_C_Common
      * 
      * @return The actual (long converted) pointer or NULL
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.common.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
+     * @see org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer
      */
     public Jni_C_Pointer getMarkerPtr() {
         return thisMarkerPtr;
@@ -224,6 +224,28 @@ public abstract class JniMarker extends Jni_C_Common
     }
     
     
+    // ****************************
+    // **** ABSTRACT FUNCTIONS ****
+    // You MUST override those in your version specific implementation
+       
+       
+       /**
+     * Function place holder to allocate a new JniMarkerField.<p>
+     * <br>
+     * JniMarkerField constructor is non overridable so we need another overridable function to return the correct version of JniMarkerField.<br>
+     * Effect of this function should be the same (allocate a fresh new JniMarkerField).<br>
+     * <br>
+     * <b>!! Override this with you version specific implementation.</b><br>
+     * 
+     * @param newMarkerFieldPtr                The pointer of an already opened marker_field C Structure
+     * 
+     * @return                                         The newly allocated JniMarkerField of the correct version
+     * 
+     * @throws JniException                    The construction (allocation) failed.
+     * 
+     * @see org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer
+     * @see org.eclipse.linuxtools.lttng.jni.JniMarkerField
+     */
     public abstract JniMarkerField allocateNewJniMarkerField(Jni_C_Pointer newMarkerFieldPtr) throws JniException;
     
 }
index d5458d5d7df41f6aca53bfd02961fa7d461bdd81..3af403f90e5284925fc9e1ffce0ef29822cffa40 100644 (file)
@@ -61,6 +61,8 @@ public abstract class JniMarkerField extends Jni_C_Common
      * @param newMarkerFieldPtr  Pointer to a C marker_field structure
      * 
      * @exception JniException
+     * 
+     * @see org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer
      */
     public JniMarkerField(Jni_C_Pointer newMarkerFieldPtr) throws JniException {
         thisMarkerFieldPtr = newMarkerFieldPtr;
@@ -99,7 +101,7 @@ public abstract class JniMarkerField extends Jni_C_Common
      * 
      * @return The actual (long converted) pointer or NULL
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.common.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
+     * @see org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer
      */
     public Jni_C_Pointer getMarkerFieldPtr() {
         return thisMarkerFieldPtr;
@@ -137,4 +139,5 @@ public abstract class JniMarkerField extends Jni_C_Common
         
         return returnData;
     }
+    
 }
index 0a32f2133222b9d86aac08e954483bd4e858b95a..cc3bb22f9558f9986bcb7e3a72d4b05463969f1c 100644 (file)
@@ -52,7 +52,7 @@ public abstract class JniParser extends Jni_C_Common
      * 
      * @return                  An Object that contain the JniEvent payload parsed by the C, or null, if if was impossible to parse (i.e., wrong position)
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent
+     * @see org.eclipse.linuxtools.lttng.jni.JniEvent
      */
     static public Object parseField(JniEvent eventToParse, int fieldPosition) {
         
@@ -80,7 +80,7 @@ public abstract class JniParser extends Jni_C_Common
      * 
      * @return                  An Object that contain the JniEvent payload parsed by the C, or null, if if was impossible to parse (i.e., wrong position)
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent
+     * @see org.eclipse.linuxtools.lttng.jni.JniEvent
      */
     static public Object parseField(JniEvent eventToParse, String fieldName) {
         
@@ -106,7 +106,7 @@ public abstract class JniParser extends Jni_C_Common
      * @param   eventToParse    The jni event we want to parse.  
      * @return                  An HashMap of Object that contain the is the JniEvent's payload parsed by the C
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent
+     * @see org.eclipse.linuxtools.lttng.jni.JniEvent
      */
     static public HashMap<String, Object> parseAllFields(JniEvent eventToParse) {
         HashMap<String,JniMarkerField> markerFieldData = eventToParse.requestEventMarker().getMarkerFieldsHashMap();
@@ -283,6 +283,7 @@ public abstract class JniParser extends Jni_C_Common
     
 }
 
+
 /**
  * <b><u>ParsedObjectContent</u></b><p>
  * 
@@ -299,4 +300,4 @@ class ParsedObjectContent {
     public void setData(Object newData) {
         parsedData = newData;
     }
-}
\ No newline at end of file
+}
index 8ecbe09e6bcc030fda3290653c0548574f7b7b37..43918e5bbdd1bc1d840df08664d2604ff7b628ee 100644 (file)
@@ -11,7 +11,6 @@ package org.eclipse.linuxtools.lttng.jni;
  *   William Bourque (wbourque@gmail.com) - Initial API and implementation
  *******************************************************************************/
 
-
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.PriorityQueue;
@@ -46,7 +45,7 @@ public abstract class JniTrace extends Jni_C_Common {
     // Note that all type have been scaled up as there is no "unsigned" in java
     // This might be a problem about "unsigned long" as there is no equivalent
     // in java
-
+    
     private String tracepath = ""; // Path of the trace. Should be a directory (like : /tmp/traceX)
     private int    cpuNumber = 0;
     private long   archType = 0;
@@ -190,7 +189,7 @@ public abstract class JniTrace extends Jni_C_Common {
      *            
      * @exception JniException
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.common.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
+     * @see org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer
      */
     public JniTrace(Jni_C_Pointer newPtr, boolean newPrintDebug) throws JniException {
         thisTracePtr = newPtr;
@@ -425,7 +424,7 @@ public abstract class JniTrace extends Jni_C_Common {
      * 
      * @return The top event in the stack or null if no event is available.
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent
+     * @see org.eclipse.linuxtools.lttng.jni.JniEvent
      */
     public JniEvent findNextEvent() {
         return eventsHeap.peek();
@@ -436,7 +435,7 @@ public abstract class JniTrace extends Jni_C_Common {
      * 
      * @return The next event in the trace or null if no event is available.
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent
+     * @see org.eclipse.linuxtools.lttng.jni.JniEvent
      */
     public JniEvent readNextEvent() {
         // Get the "next" event on the top of the heap but DO NOT remove it
@@ -485,8 +484,8 @@ public abstract class JniTrace extends Jni_C_Common {
      * 
      * @return The next event in the tracefile or null if no event is available.
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTracefile
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent
+     * @see org.eclipse.linuxtools.lttng.jni.JniTracefile
+     * @see org.eclipse.linuxtools.lttng.jni.JniEvent
      */
     public JniEvent readNextEvent(JniTracefile targetTracefile) {
         JniEvent returnedEvent = null;
@@ -527,7 +526,7 @@ public abstract class JniTrace extends Jni_C_Common {
     * 
     * @param seekTime     The time where we want to seek to
     * 
-    * @see org.eclipse.linuxtools.lttng.jni.common.eclipse.linuxtools.lttng.jni.JniTime
+    * @see org.eclipse.linuxtools.lttng.jni.common.JniTime
     */
     public void seekToTime(JniTime seekTime) {
         
@@ -554,8 +553,8 @@ public abstract class JniTrace extends Jni_C_Common {
     * @param targetTracefile   The tracefile object to read from
     * @param seekTime                  The time where we want to seek to
     * 
-    * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTracefile
-    * @see org.eclipse.linuxtools.lttng.jni.common.eclipse.linuxtools.lttng.jni.JniTime
+    * @see org.eclipse.linuxtools.lttng.jni.JniTracefile
+    * @see org.eclipse.linuxtools.lttng.jni.common.JniTime
     */
     public void seekToTime(JniTime seekTime, JniTracefile targetTracefile) {
         // Invalidate the current read event
@@ -582,8 +581,8 @@ public abstract class JniTrace extends Jni_C_Common {
     * 
     * @return The event just after the seeked time or null if none available.
     * 
-    * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent
-    * @see org.eclipse.linuxtools.lttng.jni.common.eclipse.linuxtools.lttng.jni.JniTime
+    * @see org.eclipse.linuxtools.lttng.jni.JniEvent
+    * @see org.eclipse.linuxtools.lttng.jni.common.JniTime
     */
     public JniEvent seekAndRead(JniTime seekTime) { 
          JniEvent returnedEvent = null;
@@ -602,14 +601,14 @@ public abstract class JniTrace extends Jni_C_Common {
     * 
     * Calling  readNextEvent() after this function will consider this tracefile moved and is then consistent.<br>
     * 
-    * @param tracefileName   The tracefile object to read from
+    * @param targetTracefile    The tracefile object to read from
     * @param seekTime           The time where we want to seek to
     * 
     * @return The event just after the seeked time or null if none available.
     * 
-    * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTracefile
-    * @see org.eclipse.linuxtools.lttng.jni.common.eclipse.linuxtools.lttng.jni.JniTime
-    * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent
+    * @see org.eclipse.linuxtools.lttng.jni.JniTracefile
+    * @see org.eclipse.linuxtools.lttng.jni.common.JniTime
+    * @see org.eclipse.linuxtools.lttng.jni.JniEvent
     */
     public JniEvent seekAndRead(JniTime seekTime, JniTracefile targetTracefile) { 
         seekToTime(seekTime, targetTracefile);
@@ -623,7 +622,7 @@ public abstract class JniTrace extends Jni_C_Common {
      * 
      * @return The tracefile found or null if none.
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTracefile
+     * @see org.eclipse.linuxtools.lttng.jni.JniTracefile
      */
     public JniTracefile requestTracefileByName(String tracefileName) {
         return tracefilesMap.get(tracefileName);
@@ -636,7 +635,7 @@ public abstract class JniTrace extends Jni_C_Common {
      * 
      * @return Event of the tracefile or null if none found.
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent
+     * @see org.eclipse.linuxtools.lttng.jni.JniEvent
      */
     public JniEvent requestEventByName(String tracefileName) {
         JniEvent returnValue = null;
@@ -724,7 +723,7 @@ public abstract class JniTrace extends Jni_C_Common {
      * 
      * @return Time of the last event read
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.common.eclipse.linuxtools.lttng.jni.JniTime
+     * @see org.eclipse.linuxtools.lttng.jni.common.JniTime
      */
     public JniTime getCurrentEventTimestamp() {
         JniTime returnedTime = null;
@@ -748,7 +747,7 @@ public abstract class JniTrace extends Jni_C_Common {
      * 
      * @return The actual (long converted) pointer or NULL.
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.common.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
+     * @see org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer
      */
     public Jni_C_Pointer getTracePtr() {
         return thisTracePtr;
@@ -772,7 +771,7 @@ public abstract class JniTrace extends Jni_C_Common {
      * This function will call Ltt to print, so information printed will be the
      * one from the C structure, not the one populated in java.
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTracefile
+     * @see org.eclipse.linuxtools.lttng.jni.JniTracefile
      */
     public void printAllTracefilesInformation() {
         JniTracefile tracefile = null;
@@ -839,8 +838,43 @@ public abstract class JniTrace extends Jni_C_Common {
         return returnData;
     }
     
+    
+    // ****************************
+    // **** ABSTRACT FUNCTIONS ****
+    // You MUST override those in your version specific implementation
+    
+    /**
+     * Function place holder to load the correct C library.<p>
+     * <br>
+     * Can be as simple as calling ltt_initializeHandle(LIBRARY_NAME) with the correct .so instead of LIBRARY_NAME.<br>
+     * You may also want to perform some check or some additionnal validations.<br>
+     * <br>
+     * <b>!! Override this with you version specific implementation.</b><br>
+     * 
+     * @return boolean saying if the initialization was successful. 
+     */
     public abstract boolean initializeLibrary();
     
+    
+    /**
+     * Function place holder to allocate a new JniTracefile.<p>
+     * 
+     * JniTracefile constructor is non overridable so we need another overridable function to return the correct version of JniTracefile.<br>
+     * Effect of this function should be the same (allocate a fresh new JniTracefile)<br>
+     * <br>
+     * <b>!! Override this with you version specific implementation.</b><br>
+     * 
+     * @param newPtr                   The pointer of an already opened LttTracefile C Structure
+     * @param newParentTrace   The JniTrace parent of this tracefile.
+     * 
+     * @return                                 The newly allocated JniTracefile of the correct version
+     * 
+     * @throws JniException            The construction (allocation) failed.
+     * 
+     * @see org.eclipse.linuxtools.lttng.jni.JniTracefile
+     * @see org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer
+     * @see org.eclipse.linuxtools.lttng.jni.JniTrace
+     */
     public abstract JniTracefile allocateNewJniTracefile(Jni_C_Pointer newPtr, JniTrace newParentTrace) throws JniException;
     
-}
\ No newline at end of file
+}
index 1262a32709f126704df2bcfd6fb95183627ded54..869d23414bbfe19fde67ce28bedb86894bbd4ae3 100644 (file)
@@ -159,12 +159,13 @@ public abstract class JniTracefile extends Jni_C_Common {
     /**
      * Constructor, using C pointer.<p>
      * 
-     * @param newPtr  The pointer of an already opened LttTracefile C Structure
+     * @param newPtr                   The pointer of an already opened LttTracefile C Structure
+     * @param newParentTrace   The JniTrace parent of this tracefile.
      * 
      * @exception JniException
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTrace
-     * @see org.eclipse.linuxtools.lttng.jni.common.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
+     * @see org.eclipse.linuxtools.lttng.jni.JniTrace
+     * @see org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer
      */
     public JniTracefile(Jni_C_Pointer newPtr, JniTrace newParentTrace) throws JniException {
         thisTracefilePtr = newPtr;
@@ -185,9 +186,9 @@ public abstract class JniTracefile extends Jni_C_Common {
      * 
      * Note : If the read succeed, the event will be populated.<p>
      *      
-     * @return LTT read status, as defined in Jni_C_Common
+     * @return LTT read status, as defined in Jni_C_Constant
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.common.eclipse.linuxtools.lttng.jni.Jni_C_Common
+     * @see org.eclipse.linuxtools.lttng.jni.common.Jni_C_Constant
      */
     public int readNextEvent() {
         return currentEvent.readNextEvent();
@@ -200,9 +201,9 @@ public abstract class JniTracefile extends Jni_C_Common {
      * 
      * @param seekTime      The timestamp where to seek.
      * 
-     * @return LTT read status, as defined in Jni_C_Common
+     * @return LTT read status, as defined in Jni_C_Constant
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.common.eclipse.linuxtools.lttng.jni.Jni_C_Common
+     * @see org.eclipse.linuxtools.lttng.jni.common.Jni_C_Constant
      */
     public int seekToTime(JniTime seekTime) {
         return currentEvent.seekToTime(seekTime);
@@ -384,7 +385,7 @@ public abstract class JniTracefile extends Jni_C_Common {
      *
      * @return The parent trace
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTrace
+     * @see org.eclipse.linuxtools.lttng.jni.JniTrace
      */
     public JniTrace getParentTrace() {
         return parentTrace;
@@ -398,7 +399,7 @@ public abstract class JniTracefile extends Jni_C_Common {
      * 
      * @return The actual (long converted) pointer or NULL.
      * 
-     * @see org.eclipse.linuxtools.lttng.jni.common.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
+     * @see org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer
      */
     public Jni_C_Pointer getTracefilePtr() {
         return thisTracefilePtr;
@@ -465,8 +466,52 @@ public abstract class JniTracefile extends Jni_C_Common {
     }
        
        
+       // ****************************
+    // **** ABSTRACT FUNCTIONS ****
+    // You MUST override those in your version specific implementation
+       
+       
+       /**
+     * Function place holder to allocate a new JniEvent.<p>
+     * <br>
+     * JniEvent constructor is non overridable so we need another overridable function to return the correct version of JniEvent.<br>
+     * Effect of this function should be the same (allocate a fresh new JniEvent).<br>
+     * <br>
+     * <b>!! Override this with you version specific implementation.</b><br>
+     * 
+     * @param newEventPtr                      The pointer of an already opened LttEvent C Structure
+     * @param newMarkersMap                    An already populated HashMap of JniMarker objects for this new event
+     * @param newParentTracefile       The JniTrace parent of this tracefile.
+     * 
+     * @return                                         The newly allocated JniEvent of the correct version
+     * 
+     * @throws JniException                    The construction (allocation) failed.
+     * 
+     * @see org.eclipse.linuxtools.lttng.jni.JniEvent
+     * @see org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer
+     * @see org.eclipse.linuxtools.lttng.jni.JniMarker
+     * @see org.eclipse.linuxtools.lttng.jni.JniTracefile
+     */
        public abstract JniEvent allocateNewJniEvent(Jni_C_Pointer newEventPtr, HashMap<Integer, JniMarker> newMarkersMap, JniTracefile newParentTracefile) throws JniException;
-    public abstract JniMarker allocateNewJniMarker(Jni_C_Pointer newMarkerPtr) throws JniException;
+    
+       
+       /**
+     * Function place holder to allocate a new JniMarker.<p>
+     * <br>
+     * JniMarker constructor is non overridable so we need another overridable function to return the correct version of JniMarker.<br>
+     * Effect of this function should be the same (allocate a fresh new JniMarker).<br>
+     * <br>
+     * <b>!! Override this with you version specific implementation.</b><br>
+     * 
+     * @param newMarkerPtr                     The pointer of an already opened marker_info C Structure
+     * 
+     * @return                                         The newly allocated JniMarker of the correct version
+     * 
+     * @throws JniException                    The construction (allocation) failed.
+     * 
+     * @see org.eclipse.linuxtools.lttng.jni.JniMarker
+     * @see org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer
+     */
+       public abstract JniMarker allocateNewJniMarker(Jni_C_Pointer newMarkerPtr) throws JniException;
        
 }
-
index 9531cbf1597db22174d3a0bc16d75269bc0f6997..eb4d38f5b04850604c08a7ab863b6e6413a76f71 100644 (file)
@@ -48,4 +48,5 @@ public abstract class Jni_C_Common extends Jni_C_Constant {
     public void printlnC(String msg) {
         printC(msg + "\n");
     }
-}
\ No newline at end of file
+    
+}
index 27960f4a2a0d4e0543f50e470a439fe2742a91e3..dc6d2827eb580fe98d160df60b51ba387fedeb88 100644 (file)
@@ -1,6 +1,15 @@
 package org.eclipse.linuxtools.lttng.jni.common;
-
-
+/*******************************************************************************
+ * Copyright (c) 2009 Ericsson
+ * 
+ * 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:
+ *   William Bourque (wbourque@gmail.com) - Initial API and implementation
+ *******************************************************************************/
 
 /**
  * <b><u>JniTime</u></b>
index 652f80f4c12d82b1a5066ea0ddb9a3b137b7c6fb..b6bc19540d6bbde0272d7cc2c408d82a9c3d8910 100644 (file)
@@ -11,7 +11,6 @@ package org.eclipse.linuxtools.lttng.jni.common;
  *   William Bourque (wbourque@gmail.com) - Initial API and implementation
  *******************************************************************************/
 
-
 /**
  * <b><u>Jni_C_Common</u></b>
  * <p>
@@ -30,6 +29,12 @@ public abstract class Jni_C_Constant {
     // Timestamps are in nanoseconds, this const ease up the math
     public static final long NANO = 1000000000;
     
+    /**
+     * Default constructor
+     */
+    public Jni_C_Constant() {
+    }
+    
     /**
      * "Alternate" .toString()<p>
      * 
index 0d2d91c9420aec58ffd4c18f4a1e10cc832ed4ab..0dca5ded523171d9d7acec515cee5dcaf090a7fb 100644 (file)
@@ -1,5 +1,15 @@
 package org.eclipse.linuxtools.lttng.jni.common;
-
+/*******************************************************************************
+ * Copyright (c) 2009 Ericsson
+ * 
+ * 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:
+ *   William Bourque (wbourque@gmail.com) - Initial API and implementation
+ *******************************************************************************/
 
 /**
  * <b><u>Jni_C_Pointer</u></b>
index 75dac8f9fbc937a7a6ad2b5431d86f3a2b8393e8..ac1562833115e6af983b995cd9661b476c7b7a0d 100644 (file)
@@ -1,4 +1,15 @@
 package org.eclipse.linuxtools.lttng.jni.factory;
+/*******************************************************************************
+ * Copyright (c) 2009 Ericsson
+ * 
+ * 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:
+ *   William Bourque (wbourque@gmail.com) - Initial API and implementation
+ *******************************************************************************/
 
 import org.eclipse.linuxtools.lttng.jni.JniTrace;
 import org.eclipse.linuxtools.lttng.jni.exception.JniException;
@@ -7,34 +18,63 @@ import org.eclipse.linuxtools.lttng.jni_v2_3.JniTrace_v2_3;
 import org.eclipse.linuxtools.lttng.jni_v2_5.JniTrace_v2_5;
 import org.eclipse.linuxtools.lttng.jni_v2_6.JniTrace_v2_6;
 
+/**
+ * <b><u>JniTraceFactory</u></b>
+ * <p>
+ * This class factory is responsible of returning the correct JniTrace implementation from a (valid) trace path.<p>
+ * 
+ * The different version supported are listed below and the same version string are expected to be returned by JniTraceVersion.<br>
+ * Each version need a different Lttv library so each need its liblttvtraceread-X.Y.so installed and available on the system.
+ * 
+ */
 public class JniTraceFactory {
        
+       // ***
+       // Version string of the supported library version
+       // These will be used in the switch below to find the correct version
+       // ***
        static final String TraceVersion_v2_3 = "2.3"; 
        static final String TraceVersion_v2_5 = "2.5";
        static final String TraceVersion_v2_6 = "2.6";
        
+       /*
+        * Default constructor is forbidden
+        */
        private JniTraceFactory(){
-               // Default constructor is forbidden
        }
        
+       /**
+        * Factory function : return the correct version of the JniTrace from a given path<p>
+        * NOTE : The correct Lttv library (liblttvtraceread-X.Y.so) need to be installed and accessible otherwise this
+        *                function will return an Exception. 
+        * 
+        * If the path is wrong or if the library is not supported (bad version or missing library) an Exception will be throwed. 
+        * 
+        * @param path                  Path of the trace we want to open
+        * @param show_debug    Should JniTrace print debug or not?
+        * 
+        * @return                              a newly allocated JniTrace of the correct version
+        * 
+        * @throws JniException
+        */
        static public JniTrace getJniTrace(String path, boolean show_debug) throws JniException {
                
                try {
                        JniTraceVersion traceVersion = new JniTraceVersion(path);
                        
-                       if ( traceVersion.toString().equals(TraceVersion_v2_6) ) {
-                               return new JniTrace_v2_6(path);
+                       if ( traceVersion.getVersionAsString().equals(TraceVersion_v2_6) ) {
+                               return new JniTrace_v2_6(path, show_debug);
                        }
-                       else if ( traceVersion.toString().equals(TraceVersion_v2_5) ) {
-                               return new JniTrace_v2_5(path);
+                       else if ( traceVersion.getVersionAsString().equals(TraceVersion_v2_5) ) {
+                               return new JniTrace_v2_5(path, show_debug);
                        }
-                       else if ( traceVersion.toString().equals(TraceVersion_v2_3) ) {
-                               return new JniTrace_v2_3(path);
+                       else if ( traceVersion.getVersionAsString().equals(TraceVersion_v2_3) ) {
+                               return new JniTrace_v2_3(path, show_debug);
                        }
                        else {
                                String errMsg = "\nERROR : Unrecognized/unsupported trace version." +
-                                                               "\nLibrary reported a trace version " + traceVersion.toString() + "." + 
-                                                               "\nMake sure you installed the Lttv library that support this version (look for liblttvtraceread-" + traceVersion.toString() + ".so).\n"; 
+                                                               "\nLibrary reported a trace version " + traceVersion.getVersionAsString() + "." + 
+                                                               "\nMake sure you installed the Lttv library that support this version (look for liblttvtraceread-" + traceVersion.getVersionAsString() + ".so).\n"; 
                                throw new JniException(errMsg);
                        }
                }
index 75a1a264291fd8b3316b216e806f4789e0965757..dbaf9889c5987bb77b47b6aef60621d4d6f19309 100644 (file)
 package org.eclipse.linuxtools.lttng.jni.factory;
+/*******************************************************************************
+ * Copyright (c) 2009 Ericsson
+ * 
+ * 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:
+ *   William Bourque (wbourque@gmail.com) - Initial API and implementation
+ *******************************************************************************/
 
+import org.eclipse.linuxtools.lttng.jni.exception.JniException;
 import org.eclipse.linuxtools.lttng.jni.exception.JniTraceVersionException;
 
+/**
+ * <b><u>JniTraceVersion</u></b>
+ * <p>
+ * This class is responsible of returning the correct version number of a trace at a certain given path.<p>
+ * 
+ * The class will call the C library to get the correct version number from the trace.<p>
+ * 
+ * Lttv library loader (liblttvtraceread_loader.so) and the default Lttv library (liblttvtraceread.so) must be installed on system and available to java.
+ * 
+ */
 public class JniTraceVersion {
        
+       // Native access functions
        protected native void ltt_getTraceVersion(String tracepath);
        protected native void ltt_setLibraryPath(String ldLibraryPath);
        
+       // Variables to store version number
        private int majorNumber = 0;
        private int minorNumber = 0;
        
+       // To store the given tracepath
        private String tracepath = "";
-
+       
+       // Was the trace read already?
+       private boolean wasTraceRead = false;
+       
+       /**
+        * Default constructor.<p>
+        * 
+        * Do nothing, readVersionFromTrace(path) will need to be called by the user
+        */
        public JniTraceVersion() {
                // Nothing to do 
        }
        
+       /**
+     * Constructor that takes a tracepath parameter.<p>
+     * 
+     * This constructor read the version number from the trace, so it might throw.
+     * 
+     * @param newTracepath             The <b>directory</b> of the trace to read.
+     * 
+     * @exception JniException If the library can not be loaded,if the path is wrong or if something go wrong during the read.
+     */
        public JniTraceVersion(String newTracepath) throws JniTraceVersionException {
                // Read the version number from the trace 
-               readVersionNumber(newTracepath);
+               readVersionFromTrace(newTracepath);
        }
        
+       /**
+     * Copy constructor.
+     * 
+     * @param oldVersion  A reference to the JniTraceVersion to copy.           
+     */
        public JniTraceVersion(JniTraceVersion oldVersion) {
                majorNumber = oldVersion.majorNumber;
                minorNumber = oldVersion.minorNumber;
        }
        
+       /*
+        * Read the version from the (already set) tracepath.<p>
+        * 
+        * This version is used internally and will silently dismiss any exceptions.
+        * 
+        */
+       private void readVersionNumberNofail() {
+               try {
+                       readVersionFromTrace(tracepath);
+               }
+               catch(JniTraceVersionException e) { }
+       }
+       
+       /**
+        * Read the version from the (already set) tracepath.<p>
+        * 
+        * This function throw if the library can not be loaded, if the path is wrong or if something go wrong during the read.
+        * 
+        */
        public void readVersionNumber() throws JniTraceVersionException {
-               readVersionNumber(tracepath);
+               readVersionFromTrace(tracepath);
        }
        
-       public void readVersionNumber(String tracepath) throws JniTraceVersionException {
+       /**
+        * Read the version from a given tracepath.<p>
+        * MajorVersion and MinorVersion should be set after a successful execution of this function.<br>
+        * 
+        * This function throw if the library can not be loaded,if the path is wrong or if something go wrong during the read.
+        * 
+        */
+       public void readVersionFromTrace(String newTracepath) throws JniTraceVersionException {
                
                // Verify that the tracepath isn't obliviously wrong (null or empty)
-               if ( (tracepath == null) || (tracepath.equals("") ) ) {
+               if ( (newTracepath == null) || (newTracepath.equals("") ) ) {
                        throw new JniTraceVersionException("ERROR : Tracepath is null or empty! (readVersionNumber)");
                }
+               else {
+                       // Otherwise set the path in case it was changed
+                       tracepath = newTracepath;
+               }
                
                try {
                        // Load the C library here. 
@@ -44,47 +121,116 @@ public class JniTraceVersion {
                        
                        // Assuming the C library loaded correctly, call the JNI here.
                        ltt_getTraceVersion(tracepath);
+                       
+                       // We can now assume that the trace was read
+                       wasTraceRead = true;
                }
+               // The library was unable to load -> Lttv not installed or bad version of it? 
                catch (java.lang.UnsatisfiedLinkError e) {
-                       throw new JniTraceVersionException("ERROR : Could not get trace version. Is the library missing?\n" +
-                                                                                          "        Make sure you setted either \"java.library.path\" or \"LD_LIBRARY_PATH\" (readVersionNumber)");
+                       throw new JniTraceVersionException("\nERROR : Could not get trace version. Is the library missing?" +
+                                                                                          "\nMake sure you setted either \"java.library.path\" or \"LD_LIBRARY_PATH\" (readVersionNumber)\n");
                }
+               // Something else failed -> Possibly a bad tracepath was given 
                catch (Exception e) {
-                       throw new JniTraceVersionException("ERROR : Call to ltt_getTraceVersion failed. (readVersionNumber)");
+                       throw new JniTraceVersionException("\nERROR : Call to ltt_getTraceVersion failed. (readVersionNumber)\n");
                }
        }
        
-       
+       /**
+        * Get major version number of the trace.<p>
+        * Note : readVersionFromTrace() will be called if it wasn't done but exception will be silently ignored.
+        * 
+        * @return major version
+        */
        public int getMajor() {
+               if ( wasTraceRead == false ) {
+                       readVersionNumberNofail();
+               }
+               
                return majorNumber;
        }
        
+       /**
+        * Get minor version number of the trace.<p>
+        * Note : readVersionFromTrace() will be called if it wasn't done but exception will be silently ignored.
+        * 
+        * @return minor version
+        */
        public int getMinor() {
+               if ( wasTraceRead == false ) {
+                       readVersionNumberNofail();
+               }
+               
                return minorNumber;
        }
        
+       /**
+        * Get full version number of the trace.<p>
+        * Note : readVersionFromTrace() will be called if it wasn't done but exception will be silently ignored.
+        * 
+        * @return Full Version as float
+        */
        public float getVersionAsFloat()  {
+               if ( wasTraceRead == false ) {
+                       readVersionNumberNofail();
+               }
+               
                return ((float)majorNumber + ((float)minorNumber)/10);
        }
        
+       /**
+        * Get full version number of the trace.<p>
+        * Note : readVersionFromTrace() will be called if it wasn't done but exception will be silently ignored.
+        * 
+        * @return Full Version as string
+        */
+       public String getVersionAsString()  {
+               if ( wasTraceRead == false ) {
+                       readVersionNumberNofail();
+               }
+               
+               return majorNumber + "." + minorNumber;
+       }
+       
+       /**
+        * Get for the current tracepath
+        * 
+        * @return The tracepath was are currently using.
+        */
        public String getTracepath() {
                return tracepath;
        }
        
+       /**
+        * Set for the tracepath.<p>
+        * NOTE  : Changing this will reset the version number currently loaded.
+        * NOTE2 : readVersionFromTrace() will be called but exception will be silently ignored.
+        * 
+        * @param newtracepath The net tracepath
+        */
        public void setTracepath(String newtracepath) {
+               majorNumber = 0;
+               minorNumber = 0;
+               wasTraceRead = false;
                tracepath = newtracepath;
+               
+               // Call the read function. This will fill up all the number if it goes well.
+               readVersionNumberNofail();
        }
        
-       
+       /*
+        * This function is be called from the C side to assign the version number the Java variable.
+        */
     @SuppressWarnings("unused")
        private void setTraceVersionFromC(int newMajor, int newMinor) {
                majorNumber = newMajor;
                minorNumber = newMinor;
     }
        
+    
        @Override
        public String toString() {
-               return majorNumber + "." + minorNumber;
+               return "JniTraceVersion [" + majorNumber + "." + minorNumber + "]";
        }
        
 }
This page took 0.040989 seconds and 5 git commands to generate.