Example usage for java.lang UnsatisfiedLinkError getMessage

List of usage examples for java.lang UnsatisfiedLinkError getMessage

Introduction

In this page you can find the example usage for java.lang UnsatisfiedLinkError getMessage.

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:net.sf.jabref.openoffice.OpenOfficePanel.java

private void connect(boolean auto) {
    String ooBaseDirectory;/* w  ww.  j  a  v a  2  s  . c  om*/
    if (auto) {
        AutoDetectPaths adp = new AutoDetectPaths(diag);
        if (adp.runAutodetection()) {
            autoDetected = true;
            dialogOkPressed = true;
            diag.dispose();
        } else if (!adp.cancelled()) {
            JOptionPane.showMessageDialog(diag, Localization.lang("Autodetection failed"),
                    Localization.lang("Autodetection failed"), JOptionPane.ERROR_MESSAGE);
        }
        if (!autoDetected) {
            return;
        }

        ooBaseDirectory = Globals.prefs.get(JabRefPreferences.OO_JARS_PATH);
        sOffice = Globals.prefs.get(JabRefPreferences.OO_EXECUTABLE_PATH);
    } else { // Manual connect

        showConnectDialog();
        if (!dialogOkPressed) {
            return;
        }

        String ooPath = Globals.prefs.get(JabRefPreferences.OO_PATH);
        String ooJars = Globals.prefs.get(JabRefPreferences.OO_JARS_PATH);
        sOffice = Globals.prefs.get(JabRefPreferences.OO_EXECUTABLE_PATH);

        if (OS.WINDOWS) {
            ooBaseDirectory = ooPath + "\\program\\classes";
            sOffice = ooPath + "\\program\\soffice.exe";
        } else if (OS.OS_X) {
            sOffice = ooPath + "/Contents/MacOS/soffice.bin";
            ooBaseDirectory = ooPath + "/Contents/Resources/java";
        } else {
            // Linux:
            ooBaseDirectory = ooJars + "/program/classes";
        }
    }

    // Add OO jars to the classpath:
    try {
        List<File> jarFiles = Arrays.asList(new File(ooBaseDirectory, "unoil.jar"),
                new File(ooBaseDirectory, "jurt.jar"), new File(ooBaseDirectory, "juh.jar"),
                new File(ooBaseDirectory, "ridl.jar"));
        List<URL> jarList = new ArrayList<>(jarFiles.size());
        for (File jarFile : jarFiles) {
            if (!jarFile.exists()) {
                throw new IOException("File not found: " + jarFile.getPath());
            }
            jarList.add(jarFile.toURI().toURL());
        }
        addURL(jarList);

        // Show progress dialog:
        final JDialog progDiag = new AutoDetectPaths(diag).showProgressDialog(diag,
                Localization.lang("Connecting"), Localization.lang("Please wait..."), false);
        getWorker().run(); // Do the actual connection, using Spin to get off the EDT.
        progDiag.dispose();
        diag.dispose();
        if (ooBase == null) {
            throw connectException;
        }

        if (ooBase.isConnectedToDocument()) {
            frame.output(Localization.lang("Connected to document") + ": "
                    + ooBase.getCurrentDocumentTitle().orElse(""));
        }

        // Enable actions that depend on Connect:
        selectDocument.setEnabled(true);
        pushEntries.setEnabled(true);
        pushEntriesInt.setEnabled(true);
        pushEntriesEmpty.setEnabled(true);
        pushEntriesAdvanced.setEnabled(true);
        update.setEnabled(true);
        merge.setEnabled(true);
        manageCitations.setEnabled(true);

    } catch (UnsatisfiedLinkError e) {
        LOGGER.warn("Could not connect to running OpenOffice/LibreOffice", e);
        JOptionPane.showMessageDialog(frame,
                Localization.lang("Unable to connect. One possible reason is that JabRef "
                        + "and OpenOffice/LibreOffice are not both running in either 32 bit mode or 64 bit mode."));
    } catch (IOException e) {
        LOGGER.warn("Could not connect to running OpenOffice/LibreOffice", e);
        JOptionPane.showMessageDialog(frame,
                Localization.lang("Could not connect to running OpenOffice.") + "\n"
                        + Localization.lang("Make sure you have installed OpenOffice with Java support.") + "\n"
                        + Localization.lang("If connecting manually, please verify program and library paths.")
                        + "\n" + "\n" + Localization.lang("Error message:") + " " + e.getMessage());
    }
}

From source file:net.sf.jabref.gui.openoffice.OpenOfficePanel.java

private void connect(boolean auto) {
    String ooJarsDirectory;//from w  ww . j  a  va  2  s .c  o  m
    if (auto) {
        AutoDetectPaths adp = new AutoDetectPaths(diag, preferences);
        if (adp.runAutodetection()) {
            autoDetected = true;
            dialogOkPressed = true;
            diag.dispose();
        } else if (!adp.canceled()) {
            JOptionPane.showMessageDialog(diag, Localization.lang("Autodetection failed"),
                    Localization.lang("Autodetection failed"), JOptionPane.ERROR_MESSAGE);
        } else {
            frame.setStatus(Localization.lang("Operation canceled."));
        }
        if (!autoDetected) {
            return;
        }

        ooJarsDirectory = preferences.getJarsPath();
        sOffice = preferences.getExecutablePath();
    } else { // Manual connect

        showConnectDialog();
        if (!dialogOkPressed) {
            return;
        }

        String ooPath = preferences.getOOPath();
        String ooJars = preferences.getJarsPath();
        sOffice = preferences.getExecutablePath();

        if (OS.WINDOWS) {
            ooJarsDirectory = ooPath + OpenOfficePreferences.WINDOWS_JARS_SUBPATH;
            sOffice = ooPath + OpenOfficePreferences.WINDOWS_EXECUTABLE_SUBPATH
                    + OpenOfficePreferences.WINDOWS_EXECUTABLE;
        } else if (OS.OS_X) {
            sOffice = ooPath + OpenOfficePreferences.OSX_EXECUTABLE_SUBPATH
                    + OpenOfficePreferences.OSX_EXECUTABLE;
            ooJarsDirectory = ooPath + OpenOfficePreferences.OSX_JARS_SUBPATH;
        } else {
            // Linux:
            ooJarsDirectory = ooJars + "/program/classes";
        }
    }

    // Add OO jars to the classpath:
    try {
        List<File> jarFiles = Arrays.asList(new File(ooJarsDirectory, "unoil.jar"),
                new File(ooJarsDirectory, "jurt.jar"), new File(ooJarsDirectory, "juh.jar"),
                new File(ooJarsDirectory, "ridl.jar"));
        List<URL> jarList = new ArrayList<>(jarFiles.size());
        for (File jarFile : jarFiles) {
            if (!jarFile.exists()) {
                throw new IOException("File not found: " + jarFile.getPath());
            }
            jarList.add(jarFile.toURI().toURL());
        }
        addURL(jarList);

        // Show progress dialog:
        final JDialog progDiag = new AutoDetectPaths(diag, preferences).showProgressDialog(diag,
                Localization.lang("Connecting"), Localization.lang("Please wait..."), false);
        getWorker().run(); // Do the actual connection, using Spin to get off the EDT.
        progDiag.dispose();
        diag.dispose();
        if (ooBase == null) {
            throw connectException;
        }

        if (ooBase.isConnectedToDocument()) {
            frame.output(Localization.lang("Connected to document") + ": "
                    + ooBase.getCurrentDocumentTitle().orElse(""));
        }

        // Enable actions that depend on Connect:
        selectDocument.setEnabled(true);
        pushEntries.setEnabled(true);
        pushEntriesInt.setEnabled(true);
        pushEntriesEmpty.setEnabled(true);
        pushEntriesAdvanced.setEnabled(true);
        update.setEnabled(true);
        merge.setEnabled(true);
        manageCitations.setEnabled(true);

    } catch (UnsatisfiedLinkError e) {
        LOGGER.warn("Could not connect to running OpenOffice/LibreOffice", e);
        JOptionPane.showMessageDialog(frame,
                Localization.lang("Unable to connect. One possible reason is that JabRef "
                        + "and OpenOffice/LibreOffice are not both running in either 32 bit mode or 64 bit mode."));
    } catch (IOException e) {
        LOGGER.warn("Could not connect to running OpenOffice/LibreOffice", e);
        JOptionPane.showMessageDialog(frame,
                Localization.lang("Could not connect to running OpenOffice/LibreOffice.") + "\n"
                        + Localization.lang(
                                "Make sure you have installed OpenOffice/LibreOffice with Java support.")
                        + "\n"
                        + Localization.lang("If connecting manually, please verify program and library paths.")
                        + "\n" + "\n" + Localization.lang("Error message:") + " " + e.getMessage());
    }
}

From source file:com.lfv.lanzius.application.Controller.java

public synchronized void init(int id) {

    clear();//  w ww  .java2 s  . c o  m
    state = CLIENT_STATE_DISCONNECTED;
    reconnectPrintCount = 5;

    // Load terminal properties
    try {
        properties = new TerminalProperties(id);
    } catch (Exception ex) {
        log.error("Invalid or no terminal properties file (data/properties/terminalproperties.xml). Exiting!",
                ex);
        System.exit(0);
    }

    // Overwrite if specified externally on the command line
    if (id > 0)
        properties.setTerminalId(id);

    log.info("Starting terminal " + properties.getTerminalId());

    // Setup codec values
    AudioDecoder.setJitterBufferSize(properties.getJitterBufferSize());
    AudioDecoder.setOutputBufferSize(properties.getOutputBufferSize());
    AudioEncoder.setInputBufferSize(properties.getInputBufferSize());

    // Initialize the timing system
    Time.init();

    // Setup a socket address to the server
    try {
        serverSocketAddr = new SocketAddress(properties.getServerAddress(), properties.getServerUdpPort());
    } catch (UnknownHostException ex) {
        log.error("Invalid server address. Exiting!", ex);
        System.exit(0);
    }

    // Create a bundle
    bundle = new ClientBundle();

    // Create the network manager
    try {
        networkManager = new ClientNetworkManager(properties.getTerminalId(), bundle, serverSocketAddr,
                new SocketAddress(properties.getLocalBindAddress(), properties.getLocalBindPort()),
                new SocketAddress(properties.getMulticastAddress(), properties.getMulticastPort()),
                properties.getMulticastTTL(), properties);
        packetReceiver = networkManager.getReceiver();
    } catch (IOException ex) {
        log.error(
                "The network manager could not be created, possibly due to an invalid multicast socket setting. Exiting!",
                ex);
        System.exit(0);
    }

    // Create push to talk interfaces
    if (properties.getEventDeviceName().length() > 0) {
        eventSwitch = new EventSwitchController(this, properties.getEventDeviceName());
    }
    if (properties.getFootSwitchInterface().length() > 0) {
        try {
            footSwitch = new FootSwitchController(this, properties.getFootSwitchInterface(),
                    properties.getFootSwitchPollTimeMillis(), properties.isFootSwitchInverted());
        } catch (UnsatisfiedLinkError err) {
            log.error("UnsatisfiedLinkError: " + err.getMessage());
            log.warn("Missing ftsw library (ftsw.dll or libftsw.so)");
            if (!properties.getFootSwitchInterface().equalsIgnoreCase("ftdi"))
                log.warn("Missing rxtxSerial library (rxtxSerial.dll or librxtxSerial.so)");
            log.warn("The footswitch has been disabled!");
            footSwitch = null;
        } catch (NoClassDefFoundError err) {
            log.warn("Missing ftsw library (ftsw.dll or libftsw.so)");
            if (!properties.getFootSwitchInterface().equalsIgnoreCase("ftdi"))
                log.warn("Missing rxtxSerial library (rxtxSerial.dll or librxtxSerial.so)");
            log.warn("The footswitch has been disabled!");
            footSwitch = null;
        }
    }

    // Get the selected audio devices
    Mixer.Info[] mixerinfo = AudioSystem.getMixerInfo();

    if ((properties.getSoundOutputDevice() >= mixerinfo.length)
            || (properties.getSoundInputDevice() >= mixerinfo.length)) {
        log.error("Invalid sound device. Exiting!");
        //System.exit(0);
    }

    outputMixer = AudioSystem.getMixer(mixerinfo[properties.getSoundOutputDevice()]);
    inputMixer = AudioSystem.getMixer(mixerinfo[properties.getSoundInputDevice()]);

    if (log.isDebugEnabled()) {
        log.debug("Using output device " + properties.getSoundOutputDevice() + " ("
                + mixerinfo[properties.getSoundOutputDevice()] + ")");
        log.debug("Using input device " + properties.getSoundInputDevice() + " ("
                + mixerinfo[properties.getSoundInputDevice()] + ")");
    }

    // Creating sound clips
    clipRingTone = new SoundClip(outputMixer, "data/resources/sounds/phone_ringtone_mono.wav",
            "data/resources/sounds/phone_ringtone_stereo.wav", 1100, properties.getSignalVolumeAdjustment());
    volumeClipList.add(clipRingTone);
    clipRingBack = new SoundClip(outputMixer, "data/resources/sounds/phone_ringback_mono.wav",
            "data/resources/sounds/phone_ringback_stereo.wav", 2100, properties.getSignalVolumeAdjustment());
    volumeClipList.add(clipRingBack);
    clipRingBusy = new SoundClip(outputMixer, "data/resources/sounds/phone_busy_mono.wav",
            "data/resources/sounds/phone_busy_stereo.wav", 400, properties.getSignalVolumeAdjustment());
    volumeClipList.add(clipRingBusy);
    clipWarning = new SoundClip(outputMixer, "data/resources/sounds/radio_error_mono.wav",
            "data/resources/sounds/radio_error_stereo.wav", 1000, properties.getSignalVolumeAdjustment());
    volumeClipList.add(clipWarning);
    clipNotify = new SoundClip(outputMixer, "data/resources/sounds/ding_mono.wav",
            "data/resources/sounds/ding_stereo.wav", 1000, properties.getSignalVolumeAdjustment());
    volumeClipList.add(clipNotify);

    // Create peripheral link
    peripheralLink = null;
    int peripheralLinkPort = properties.getPeripheralLinkPort();
    if (peripheralLinkPort > 0) {
        try {
            peripheralLink = new PeripheralLink(properties.getTerminalId(), peripheralLinkPort);
            peripheralLink.startModule();
        } catch (IOException ex) {
            log.warn("Unable to create peripheral link, disabling!");
            peripheralLink = null;
        }
    }

    // Add shutdown hook
    if (hookThread != null)
        Runtime.getRuntime().removeShutdownHook(hookThread);
    hookThread = new Thread(new Runnable() {
        public void run() {
            stop(true, true);
            shutdown(true);
            sleep(25);
            dbgListThreads();
            log.info("Bye!");
        }
    }, "Thook");
    Runtime.getRuntime().addShutdownHook(hookThread);

    if (Config.CLIENT_SERVERLESS) {
        state = CLIENT_STATE_CONNECTED;
        sessionStart();
    } else {
        // Setup handler for incoming requests and timeouts
        networkManager.setNetworkHandler(this);

        // Try to connect to server
        log.info("Connecting to server on " + properties.getServerAddress() + "...");
        networkManager.serverConnect();
    }

    if (autoTesterEnabled) {
        autoTester = new AutoTester(this);
    }
}

From source file:org.apache.hadoop.hbase.util.TestCompressionTest.java

/**
 * Verify CompressionTest.testCompression() on a native codec.
 *///from  w ww . ja v a 2 s  .  c o m
private void nativeCodecTest(String codecName, String libName, String codecClassName) {
    if (isCompressionAvailable(codecClassName)) {
        try {
            if (libName != null) {
                System.loadLibrary(libName);
            }

            try {
                Configuration conf = new Configuration();
                CompressionCodec codec = (CompressionCodec) ReflectionUtils
                        .newInstance(conf.getClassByName(codecClassName), conf);

                DataOutputBuffer compressedDataBuffer = new DataOutputBuffer();
                CompressionOutputStream deflateFilter = codec.createOutputStream(compressedDataBuffer);

                byte[] data = new byte[1024];
                DataOutputStream deflateOut = new DataOutputStream(new BufferedOutputStream(deflateFilter));
                deflateOut.write(data, 0, data.length);
                deflateOut.flush();
                deflateFilter.finish();

                // Codec class, codec nativelib and Hadoop nativelib with codec JNIs are present
                assertTrue(CompressionTest.testCompression(codecName));
            } catch (UnsatisfiedLinkError e) {
                // Hadoop nativelib does not have codec JNIs.
                // cannot assert the codec here because the current logic of
                // CompressionTest checks only classloading, not the codec
                // usage.
                LOG.debug("No JNI for codec '" + codecName + "' " + e.getMessage());
            } catch (Exception e) {
                LOG.error(codecName, e);
            }
        } catch (UnsatisfiedLinkError e) {
            // nativelib is not available
            LOG.debug("Native lib not available: " + codecName);
            assertFalse(CompressionTest.testCompression(codecName));
        }
    } else {
        // Compression Codec class is not available
        LOG.debug("Codec class not available: " + codecName);
        assertFalse(CompressionTest.testCompression(codecName));
    }
}

From source file:org.apache.sysml.utils.NativeHelper.java

/**
 * Attempts to load native BLAS/*  w ww  .  j  a v a2  s.c o  m*/
 * 
 * @param customLibPath can be null (if we want to only want to use LD_LIBRARY_PATH), else the 
 * @param blas can be gomp, openblas or mkl_rt
 * @param optionalMsg message for debugging
 * @return true if successfully loaded BLAS
 */
private static boolean loadBLAS(String customLibPath, String blas, String optionalMsg) {
    // First attempt to load from custom library path
    if (customLibPath != null) {
        String libPath = customLibPath + File.separator + System.mapLibraryName(blas);
        try {
            System.load(libPath);
            // Print to stdout as this feature is intended for cloud environment
            System.out.println("Loaded the library:" + libPath);
            return true;
        } catch (UnsatisfiedLinkError e1) {
            // Print to stdout as this feature is intended for cloud environment
            System.out.println("Unable to load " + libPath + ":" + e1.getMessage());
        }
    }

    // Then try loading using loadLibrary
    try {
        System.loadLibrary(blas);
        return true;
    } catch (UnsatisfiedLinkError e) {
        if (optionalMsg != null)
            LOG.debug("Unable to load " + blas + "(" + optionalMsg + "):" + e.getMessage());
        else
            LOG.debug("Unable to load " + blas + ":" + e.getMessage());
        return false;
    }
}

From source file:org.codice.opendx.NITFInputTransformer.java

public void initializeJoms() {
    log.info("Initializing JOMS");
    try {/*from  w ww . jav a 2  s. c om*/
        Init.instance().initialize();
    } catch (UnsatisfiedLinkError e) {
        log.error("Error initializing joms " + e.getMessage(), e);
    }
}

From source file:org.energy_home.jemma.internal.device.zgd.StreamGobbler.java

/**
 * We try to load a dll that causes an UnsatisfiedLinkError exception. This
 * exception contains in the error message the location of the native
 * storage area. We exctract the path and return back to the caller. FIXME:
 * probably this trick is valid only on the Sun's jdk.
 * //from  w  w w  . j  a v a  2s  . com
 * @param filename
 * @return
 */

private String getNativeStorageLocation(String filename) {
    String path = "";

    if (logDebug && (log != null))
        log.debug("getNativeStorageLocation = " + filename);

    try {
        System.loadLibrary(filename);
    } catch (UnsatisfiedLinkError e) {
        int index_start = 0;
        int index_end = 0;

        if (e.getMessage().indexOf("cannot dynamically load executable") > 0) {
            index_end = e.getMessage().indexOf("(", index_start + 2);
            if (index_end == -1) {
                // try with :
                index_end = e.getMessage().indexOf(":", index_start + 2);
            }
        } else {
            index_end = e.getMessage().indexOf(":", index_start + 2) + 1;
        }

        path = e.getMessage().substring(index_start, index_end - filename.length() - 1);
    } catch (Exception e) {
        log.error(e);
        return path;
    }
    return path + File.separator;
}

From source file:org.hyperic.hq.plugin.db2.DB2RuntimeAutoDiscoveryPlugin.java

public RuntimeResourceReport discoverResources(int serverId, AIPlatformValue aiplatform, ConfigResponse config)
        throws PluginException {
    try {/*from   w  w w. j av a 2s  .co  m*/
        DB2Monitor.load();
    } catch (UnsatisfiedLinkError le) {
        throw new PluginException(le.getMessage());
    } catch (DB2MonitorException e) {
        throw new PluginException(e.getMessage());
    }

    RuntimeResourceReport rrr = new RuntimeResourceReport(serverId);
    SqlmDbase[] dbase;
    AIServerExtValue server;
    ArrayList services, tables, tablespaces;

    if (this.db2Monitor == null) {
        String nodename = config.getValue(DB2ProductPlugin.PROP_NODENAME);
        String user = config.getValue(DB2ProductPlugin.PROP_USER, "");
        String password = config.getValue(DB2ProductPlugin.PROP_PASSWORD, "");

        try {
            if (nodename != null) {
                // Attach to the instance specified
                this.log.debug("Attaching to instance: " + nodename);
                this.db2Monitor = new DB2Monitor(nodename, user, password);
            } else {
                // Attach to the default local instance
                this.log.debug("Attaching to default local instance");
                this.db2Monitor = new DB2Monitor();
            }
        } catch (DB2MonitorException e) {
            this.log.error("Error attaching to DB2 instance: " + e.getMessage());
        }

        if (this.db2Monitor == null) {
            throw new PluginException("DB2 Monitor not loaded");
        }
    }

    // Check if we should enable the monitor switches
    // XXX: Maybe we should only do this once.. Sure would be nice
    //      if this could be done in MeasurmentPlugin's init(), but
    //      we have no config response there.
    String monEnable = config.getValue(DB2ProductPlugin.PROP_MON_ENABLE);
    if (monEnable != null) {
        try {
            this.log.debug("Enabling DB2 monitoring switches");
            this.db2Monitor.enableMonitorSwitches();
        } catch (DB2MonitorException e) {
            this.log.error("Unable to enable DB2 monitor switches: " + e.getMessage());
        }
    }

    try {
        dbase = this.db2Monitor.getSqlmDbase();
    } catch (DB2MonitorException e) {
        throw new PluginException(e.getMessage());
    }

    server = new AIServerExtValue();
    server.setId(new Integer(serverId));
    server.setPlaceholder(true);

    services = new ArrayList();

    for (int i = 0; i < dbase.length; i++) {
        AIServiceValue service = new AIServiceValue();
        ConfigResponse productResponse, metricResponse;
        String dbName = dbase[i].getName();

        if (this.version.equals(DB2ProductPlugin.VERSION_7)) {
            service.setServiceTypeName(DB2ProductPlugin.FULL_DATABASE_NAME_V7);
        } else if (this.version.equals(DB2ProductPlugin.VERSION_8)) {
            service.setServiceTypeName(DB2ProductPlugin.FULL_DATABASE_NAME_V8);
        } else {
            // Assume version 9.x
            service.setServiceTypeName(DB2ProductPlugin.FULL_DATABASE_NAME_V9);
        }

        service.setName("%serverName%" + " " + dbName + " " + DB2ProductPlugin.DATABASE);
        productResponse = new ConfigResponse();
        metricResponse = new ConfigResponse();

        try {
            metricResponse.setValue(DB2ProductPlugin.PROP_DATABASE, dbName);
            service.setProductConfig(productResponse.encode());
            service.setMeasurementConfig(metricResponse.encode());
        } catch (Exception exc) {
            throw new PluginException("Unable to generate config");
        }

        // For each database discover tables
        tables = discoverTables(dbName);
        services.addAll(tables);

        // For each database discover tablespaces
        tablespaces = discoverTablespaces(dbName);
        services.addAll(tablespaces);

        services.add(service);
    }

    server.setAIServiceValues((AIServiceValue[]) services.toArray(new AIServiceValue[0]));
    aiplatform.addAIServerValue(server);
    rrr.addAIPlatform(aiplatform);

    return rrr;
}

From source file:org.hyperic.hq.plugin.db2.DB2RuntimeAutoDiscoveryPlugin.java

private ArrayList discoverTables(String dbName) throws PluginException {
    ArrayList services = new ArrayList();
    SqlmTable[] tables;// w  w w .  ja  va  2  s  .co m

    try {
        tables = this.db2Monitor.getSqlmTable(dbName);
    } catch (UnsatisfiedLinkError e) {
        throw new PluginException(e.getMessage());
    } catch (DB2MonitorException e) {
        throw new PluginException(e.getMessage());
    }

    for (int i = 0; i < tables.length; i++) {

        AIServiceValue service = new AIServiceValue();
        ConfigResponse productResponse, metricResponse;
        String tableName = tables[i].getName();

        if (this.version.equals(DB2ProductPlugin.VERSION_7)) {
            service.setServiceTypeName(DB2ProductPlugin.FULL_TABLE_NAME_V7);
        } else if (this.version.equals(DB2ProductPlugin.VERSION_8)) {
            service.setServiceTypeName(DB2ProductPlugin.FULL_TABLE_NAME_V8);
        } else {
            service.setServiceTypeName(DB2ProductPlugin.FULL_TABLE_NAME_V9);
        }

        service.setName("%serverName%" + " " + dbName + " " + tableName + " " + DB2ProductPlugin.TABLE);
        productResponse = new ConfigResponse();
        metricResponse = new ConfigResponse();

        try {
            metricResponse.setValue(DB2ProductPlugin.PROP_DATABASE, dbName);
            metricResponse.setValue(DB2ProductPlugin.PROP_TABLE, tableName);
            service.setProductConfig(productResponse.encode());
            service.setMeasurementConfig(metricResponse.encode());
        } catch (Exception exc) {
            throw new PluginException("Unable to generate config");
        }

        services.add(service);
    }

    return services;
}

From source file:org.hyperic.hq.plugin.db2.DB2RuntimeAutoDiscoveryPlugin.java

private ArrayList discoverTablespaces(String dbName) throws PluginException {
    ArrayList services = new ArrayList();
    SqlmTablespace[] ts;//from   w  w w.  jav a2  s .  c om

    try {
        ts = this.db2Monitor.getSqlmTablespace(dbName);
    } catch (UnsatisfiedLinkError e) {
        throw new PluginException(e.getMessage());
    } catch (DB2MonitorException e) {
        throw new PluginException(e.getMessage());
    }

    for (int i = 0; i < ts.length; i++) {

        AIServiceValue service = new AIServiceValue();
        ConfigResponse productResponse, metricResponse;
        String tsName = ts[i].getName();

        if (this.version.equals(DB2ProductPlugin.VERSION_7)) {
            service.setServiceTypeName(DB2ProductPlugin.FULL_TABLESPACE_NAME_V7);
        } else if (this.version.equals(DB2ProductPlugin.VERSION_8)) {
            service.setServiceTypeName(DB2ProductPlugin.FULL_TABLESPACE_NAME_V8);
        } else {
            service.setServiceTypeName(DB2ProductPlugin.FULL_TABLESPACE_NAME_V9);
        }

        service.setName("%serverName%" + " " + dbName + " " + tsName + " " + DB2ProductPlugin.TABLESPACE);
        productResponse = new ConfigResponse();
        metricResponse = new ConfigResponse();

        try {
            metricResponse.setValue(DB2ProductPlugin.PROP_DATABASE, dbName);
            metricResponse.setValue(DB2ProductPlugin.PROP_TABLESPACE, tsName);
            service.setProductConfig(productResponse.encode());
            service.setMeasurementConfig(metricResponse.encode());
        } catch (Exception exc) {
            throw new PluginException("Unable to generate config");
        }

        services.add(service);
    }

    return services;
}