Search in sources :

Example 1 with PersistenceService

use of javax.jnlp.PersistenceService in project adempiere by adempiere.

the class Ini method saveWebStartProperties.

private static void saveWebStartProperties() {
    PersistenceService ps;
    try {
        ps = (PersistenceService) ServiceManager.lookup("javax.jnlp.PersistenceService");
    } catch (UnavailableServiceException e) {
        ps = null;
        log.log(Level.SEVERE, e.toString());
        return;
    }
    try {
        OutputStream os = ps.get(getCodeBase()).getOutputStream(true);
        s_prop.store(os, "Adempiere");
        os.flush();
        os.close();
    } catch (Throwable t) {
        log.log(Level.SEVERE, "Cannot save Properties to " + getCodeBase() + " - " + t.toString());
        return;
    }
}
Also used : PersistenceService(javax.jnlp.PersistenceService) OutputStream(java.io.OutputStream) FileOutputStream(java.io.FileOutputStream) UnavailableServiceException(javax.jnlp.UnavailableServiceException)

Example 2 with PersistenceService

use of javax.jnlp.PersistenceService in project adempiere by adempiere.

the class Ini method loadWebStartProperties.

//	loadProperties
private static boolean loadWebStartProperties() {
    boolean loadOK = true;
    boolean firstTime = false;
    s_prop = new Properties();
    PersistenceService ps;
    try {
        ps = (PersistenceService) ServiceManager.lookup("javax.jnlp.PersistenceService");
    } catch (UnavailableServiceException e) {
        ps = null;
        log.log(Level.SEVERE, e.toString());
        return false;
    }
    FileContents fc = null;
    try {
        fc = ps.get(getCodeBase());
    } catch (MalformedURLException e) {
        log.log(Level.SEVERE, e.toString());
        return false;
    } catch (FileNotFoundException e) {
        try {
            ps.create(getCodeBase(), 16 * 1024);
            ps.setTag(getCodeBase(), PersistenceService.DIRTY);
            fc = ps.get(getCodeBase());
        } catch (Exception e1) {
        }
    } catch (IOException e) {
        log.log(Level.SEVERE, e.toString());
        return false;
    }
    try {
        InputStream is = fc.getInputStream();
        s_prop.load(is);
        is.close();
    } catch (Throwable t) {
        log.log(Level.SEVERE, t.toString());
        loadOK = false;
    }
    if (!loadOK || s_prop.getProperty(P_TODAY, "").equals("")) {
        firstTime = true;
        if (isShowLicenseDialog())
            if (!IniDialog.accept())
                System.exit(-1);
        checkProperties();
    }
    //  Save if not exist or could not be read
    if (!loadOK || firstTime)
        saveWebStartProperties();
    s_loaded = true;
    s_propertyFileName = getCodeBase().toString();
    return firstTime;
}
Also used : PersistenceService(javax.jnlp.PersistenceService) MalformedURLException(java.net.MalformedURLException) FileContents(javax.jnlp.FileContents) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) FileNotFoundException(java.io.FileNotFoundException) IOException(java.io.IOException) Properties(java.util.Properties) UnavailableServiceException(javax.jnlp.UnavailableServiceException) NamingException(javax.naming.NamingException) MalformedURLException(java.net.MalformedURLException) UnavailableServiceException(javax.jnlp.UnavailableServiceException) IOException(java.io.IOException) FileNotFoundException(java.io.FileNotFoundException)

Aggregations

PersistenceService (javax.jnlp.PersistenceService)2 UnavailableServiceException (javax.jnlp.UnavailableServiceException)2 FileInputStream (java.io.FileInputStream)1 FileNotFoundException (java.io.FileNotFoundException)1 FileOutputStream (java.io.FileOutputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 OutputStream (java.io.OutputStream)1 MalformedURLException (java.net.MalformedURLException)1 Properties (java.util.Properties)1 FileContents (javax.jnlp.FileContents)1 NamingException (javax.naming.NamingException)1