Fix for Bug354541 - TraceLibPath handling + JUnits
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.jni / src / org / eclipse / linuxtools / lttng / jni_v2_5 / JniTrace_v2_5.java
1 package org.eclipse.linuxtools.lttng.jni_v2_5;
2 /*******************************************************************************
3 * Copyright (c) 2009, 2011 Ericsson, MontaVista Software
4 *
5 * All rights reserved. This program and the accompanying materials are
6 * made available under the terms of the Eclipse Public License v1.0 which
7 * accompanies this distribution, and is available at
8 * http://www.eclipse.org/legal/epl-v10.html
9 *
10 * Contributors:
11 * William Bourque (wbourque@gmail.com) - Initial API and implementation
12 * Yufen Kuo (ykuo@mvista.com) - add support to allow user specify trace library path
13 *******************************************************************************/
14
15 import org.eclipse.core.runtime.IPath;
16 import org.eclipse.core.runtime.Path;
17 import org.eclipse.linuxtools.lttng.jni.JniTrace;
18 import org.eclipse.linuxtools.lttng.jni.JniTracefile;
19 import org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer_And_Library_Id;
20 import org.eclipse.linuxtools.lttng.jni.exception.JniException;
21
22 /**
23 * <b><u>JniTrace_v2_5</u></b>
24 * <p>
25 * JniTrace version to support Lttng traceformat of version 2.5.<br>
26 * This class extend abstract class JniTrace with (possibly) version specific implementation (none yet).<br>
27 *
28 * It also make sure the correct library is loaded by liblttvlibraryloader.so
29 * <p>
30 */
31 public class JniTrace_v2_5 extends JniTrace {
32
33 // This is the dynamic library name that is passed to the library loader (liblttvlibraryloader.so) to load.
34 // It needs to be a complete name, like "libXYZ.so", unlike java that would take "XYZ". It could also take a complete path.
35 // The library need to be accessible, i.e. LD_LIBRARY_PATH need to be set correctly.
36 private static final String LIBRARY_NAME = "liblttvtraceread-2.5.so"; //$NON-NLS-1$
37
38 /*
39 * Forbid access to the default constructor
40 */
41 protected JniTrace_v2_5() {
42 super();
43 }
44
45
46 public JniTrace_v2_5(String newpath) throws JniException {
47 super(newpath);
48 }
49
50 public JniTrace_v2_5(String newpath, boolean newPrintDebug) throws JniException {
51 super(newpath, newPrintDebug);
52 }
53
54
55 public JniTrace_v2_5(JniTrace_v2_5 oldTrace) {
56 super(oldTrace);
57 }
58
59 public JniTrace_v2_5(Jni_C_Pointer_And_Library_Id newPtr, boolean newPrintDebug) throws JniException {
60 super(newPtr, newPrintDebug);
61 }
62
63
64 /**
65 * Initialize the C library.<p>
66 *
67 * Call the library loader with the .so we wish to load.
68 *
69 * @return True if the load went successful, false otherwise.
70 */
71 @Override
72 public int initializeLibrary() {
73 if (getTraceLibPath() == null)
74 return ltt_initializeHandle(LIBRARY_NAME);
75 else{
76 IPath path = new Path(getTraceLibPath());
77 IPath traceLib = path.append(LIBRARY_NAME);
78 return ltt_initializeHandle(traceLib.toOSString());
79 }
80 }
81
82 /**
83 * Allocate (call constructor for) a new JniTracefile.<p>
84 *
85 * This method is made to bypass limitation related to abstract class, see comment in JniTrace
86 *
87 * @return JniTracefile a newly allocated JniTracefile
88 *
89 * @see org.eclipse.linuxtools.lttng.jni.JniTrace
90 */
91 @Override
92 public JniTracefile allocateNewJniTracefile(Jni_C_Pointer_And_Library_Id newPtr, JniTrace newParentTrace) throws JniException {
93 return new JniTracefile_v2_5(newPtr, newParentTrace);
94 }
95
96
97
98 }
This page took 0.031916 seconds and 5 git commands to generate.