Example usage for java.io File toURI

List of usage examples for java.io File toURI

Introduction

In this page you can find the example usage for java.io File toURI.

Prototype

public URI toURI() 

Source Link

Document

Constructs a file: URI that represents this abstract pathname.

Usage

From source file:eu.udig.catalog.jgrass.utils.JGrassCatalogUtilities.java

/**
 * Add a mapset to a Location in the catalog.
 *
 * <p>Note: this doesn't add the file. The file adding has to be done separately</p>
 *      //from w w  w  .  ja va2  s . co  m
 * @param locationPath path to the location to which the mapset has to be added.
 * @param mapsetName the name of the mapset to add
 * @return the added {@linkplain JGrassMapsetGeoResource mapset}
 */
public synchronized static JGrassMapsetGeoResource addMapsetToCatalog(String locationPath, String mapsetName) {
    // URL locationId = JGrassService.createId(locationPath);
    File locationFile = new File(locationPath);
    try {
        ID locationId = new ID(locationFile.toURI().toURL());
        JGrassService location = CatalogPlugin.getDefault().getLocalCatalog().getById(JGrassService.class,
                locationId, ProgressManager.instance().get());
        return location.addMapset(mapsetName);
    } catch (MalformedURLException e) {
        e.printStackTrace();
        String message = "An error occurred while adding the mapset to the catalog";
        ExceptionDetailsDialog.openError(null, message, IStatus.ERROR, JGrassPlugin.PLUGIN_ID, e);
        return null;
    }
}

From source file:com.tibco.tgdb.test.lib.TGAdmin.java

/**
 * Display connections synchronously. // w w w .ja v  a 2 s .com
 * Operation blocks until it is completed.
 * 
 * @param tgServer TG server to show connection from
 * @param tgNetListenerName Name of the net listener for TG Admin to connect to - if null connect to 1st one
 * @param logFile TG admin log file location - Generated by admin
 * @param logLevel Specify the log level: info/user1/user2/user3/debug/debugmemory/debugwire
 * @param timeout Number of milliseconds allowed to complete the stop server operation - If lower than 0 wait forever
 * @return Output console 
 * @throws TGAdminException Admin execution fails or timeout occurs 
 */
public static String showConnections(TGServer tgServer, String tgNetListenerName, String logFile,
        String logLevel, long timeout) throws TGAdminException {

    if (tgServer == null)
        throw new TGAdminException("TGAdmin - tgServer cannot be null");

    String showCmd = "show connections\ndisconnect\nexit";
    File cmdFile;
    try {
        cmdFile = new File(tgServer.getHome().getAbsolutePath() + "/showConnectionsAdminScript.txt");
        Files.write(Paths.get(cmdFile.toURI()), showCmd.getBytes(StandardCharsets.UTF_8));
    } catch (IOException ioe) {
        throw new TGAdminException("TGAdmin - " + ioe.getMessage());
    }

    TGServer.NetListener netListener = tgServer.getNetListeners()[0]; // default get the 1st one
    if (tgNetListenerName != null) {
        for (TGServer.NetListener net : tgServer.getNetListeners()) {
            if (net.getName().equals(tgNetListenerName)) {
                netListener = net;
            }
        }
    }

    String host = netListener.getHost();
    int port = netListener.getPort();
    String user = tgServer.getSystemUser();
    String pwd = tgServer.getSystemPwd();
    String url;
    try {
        url = "tcp://" + ((netListener.isIPv6()) ? ("[" + host + ":" + port + "]") : (host + ":" + port));
    } catch (TGGeneralException e) {
        throw new TGAdminException("TGAdmin - " + e.getMessage());
    }

    TGAdmin.showOperationBanner = false;
    String output = TGAdmin.invoke(tgServer.getHome().getAbsolutePath(), url, user, pwd, logFile, logLevel,
            cmdFile.getAbsolutePath(), -1, timeout);
    long endProcTime = System.currentTimeMillis();
    long totalProcTime = endProcTime - TGAdmin.startProcTime;
    System.out.println("TGAdmin - Show connections completed"
            + (totalProcTime > 0 ? " in " + totalProcTime + " msec" : ""));

    return output;
}

From source file:eu.udig.catalog.jgrass.utils.JGrassCatalogUtilities.java

/**
 * Adds a map to the catalog into the right Mapset.
 * /* ww w . j av  a 2 s. c  o m*/
 * <p>Note: this doesn't add the file. The file adding has to be done separately</p>
 *
 * @param locationPath the path to the Location folder.
 * @param mapsetName the name of the Mapset into which to put the map.
 * @param mapName the name of the map to add.
 * @param mapType the format of the map to add.
 * @return the resource that has been added.
 */
public synchronized static JGrassMapGeoResource addMapToCatalog(String locationPath, String mapsetName,
        String mapName, String mapType) {
    // URL mapsetId = JGrassMapsetGeoResource.createId(locationPath, mapsetName);

    JGrassMapsetGeoResource mapset = null;
    try {
        File locationFile = new File(locationPath);

        ID locationId = new ID(locationFile.toURI().toURL());
        URL mapsetUrl = JGrassMapsetGeoResource.createId(locationFile.getAbsolutePath(), mapsetName);
        ID mapsetId = new ID(mapsetUrl);
        ICatalog localCatalog = CatalogPlugin.getDefault().getLocalCatalog();
        mapset = localCatalog.getById(JGrassMapsetGeoResource.class, mapsetId,
                ProgressManager.instance().get());
        if (mapset == null) {
            // try with the service
            // URL locationId = JGrassService.createId(locationPath);
            JGrassService locationService = localCatalog.getById(JGrassService.class, locationId,
                    ProgressManager.instance().get());
            mapset = locationService.getMapsetGeoresourceByName(mapsetName);
        }
    } catch (MalformedURLException e) {
        e.printStackTrace();
        String message = "An error occurred while adding the map to the catalog";
        ExceptionDetailsDialog.openError(null, message, IStatus.ERROR, JGrassPlugin.PLUGIN_ID, e);
    }
    if (mapset == null)
        return null;
    return mapset.addMap(mapName, mapType);
}

From source file:com.tibco.tgdb.test.lib.TGAdmin.java

/**
 * Create a user. // ww w . j  a v  a2 s . c  om
 * Operation blocks until it is completed.
 * 
 * @param tgServer TG server to create user from 
 * @param tgNetListenerName Name of the net listener for TG Admin to connect to - if null connect to 1st one
 * @param user username to be created
 * @param pwd user password
 * @param logFile TG admin log file location - Generated by admin
 * @param logLevel Specify the log level: info/user1/user2/user3/debug/debugmemory/debugwire
 * @param timeout Number of milliseconds allowed to complete the stop server operation - If lower than 0 wait forever
 *
 * @return true if user creation succeeded 
 * @throws TGAdminException Admin execution fails or timeout occurs 
 */
public static boolean createUser(TGServer tgServer, String tgNetListenerName, String user, String pwd,
        String logFile, String logLevel, long timeout) throws TGAdminException {

    if (tgServer == null)
        throw new TGAdminException("TGAdmin - tgServer cannot be null");

    if (user == null || pwd == null)
        throw new TGAdminException("TGAdmin - user or pwd cannot be null");

    final String userCreationSuccessMsg = "Successfully created user on server.";
    String showCmd = "create user " + user + " passwd=" + pwd + "\ndisconnect\nexit";
    File cmdFile;
    try {
        cmdFile = new File(tgServer.getHome().getAbsolutePath() + "/createUserAdminScript.txt");
        Files.write(Paths.get(cmdFile.toURI()), showCmd.getBytes(StandardCharsets.UTF_8));
    } catch (IOException ioe) {
        throw new TGAdminException("TGAdmin - " + ioe.getMessage());
    }

    TGServer.NetListener netListener = tgServer.getNetListeners()[0]; // default get the 1st one
    if (tgNetListenerName != null) {
        for (TGServer.NetListener net : tgServer.getNetListeners()) {
            if (net.getName().equals(tgNetListenerName)) {
                netListener = net;
            }
        }
    }

    String host = netListener.getHost();
    int port = netListener.getPort();
    String sysUser = tgServer.getSystemUser();
    String sysPwd = tgServer.getSystemPwd();
    String url;
    try {
        url = "tcp://" + ((netListener.isIPv6()) ? ("[" + host + ":" + port + "]") : (host + ":" + port));
    } catch (TGGeneralException e) {
        throw new TGAdminException("TGAdmin - " + e.getMessage());
    }

    TGAdmin.showOperationBanner = false;
    String output = TGAdmin.invoke(tgServer.getHome().getAbsolutePath(), url, sysUser, sysPwd, logFile,
            logLevel, cmdFile.getAbsolutePath(), -1, timeout);
    long endProcTime = System.currentTimeMillis();
    long totalProcTime = endProcTime - TGAdmin.startProcTime;

    if (output.contains(userCreationSuccessMsg)) {
        System.out.println("TGAdmin - User creation succeeded"
                + (totalProcTime > 0 ? " in " + totalProcTime + " msec" : ""));
        return true;
    } else {
        System.out.println(
                "TGAdmin - User creation failed" + (totalProcTime > 0 ? " in " + totalProcTime + " msec" : ""));
        return false;
    }
}

From source file:com.athena.peacock.engine.util.SshExecUtil.java

/**
 * <pre>//w  ww .  j a  v a2  s . com
 * 
 * </pre>
 * @param targetHost
 * @param command
 * @return
 * @throws IOException 
 */
public static String executeCommand(TargetHost targetHost, String command) throws IOException {
    Assert.notNull(targetHost, "targetHost cannot be null.");
    Assert.notNull(command, "command cannot be null.");

    System.out.println(SshExecUtil.class.getClassLoader());
    System.out.println(SshExecUtil.class.getClassLoader().getResource("."));
    File result = new File(SshExecUtil.class.getClassLoader().getResource(".").getFile(), "result.log");

    logger.debug("[ssh exec] " + command);

    Project project = new Project();

    SSHExec exec = new SSHExec();
    exec.setProject(project);
    exec.setHost(targetHost.getHost());
    exec.setPort(targetHost.getPort());
    exec.setUsername(targetHost.getUsername());
    exec.setPassword(targetHost.getPassword());

    if (targetHost.getKeyfile() != null) {
        exec.setKeyfile(targetHost.getKeyfile());
    }

    exec.setTrust(targetHost.isTrust());
    exec.setVerbose(true);
    exec.setCommand(command);

    // command   ? ? 
    exec.setOutput(result);
    exec.setAppend(false);

    exec.execute();

    return IOUtils.toString(result.toURI());
}

From source file:net.sf.mcf2pdf.mcfelements.util.ImageUtil.java

/**
 * Loads the given CLP or SVG file and creates a BufferedImage with the given dimensions. As CLP files contain Vector images,
 * they can be scaled to every size needed. The contents are scaled to the given width and height, <b>not</b> preserving any
 * ratio of the image./*from w  w w. ja  va2 s .co m*/
 *
 * @param clpFile CLP or SVG file.
 * @param widthPixel The width, in pixels, the resulting image shall have.
 * @param heightPixel The height, in pixels, the resulting image shall have.
 *
 * @return An image displaying the contents of the loaded CLP file.
 *
 * @throws IOException If any I/O related problem occurs reading the file.
 */
public static BufferedImage loadClpFile(File clpFile, int widthPixel, int heightPixel) throws IOException {
    FileInputStream fis = new FileInputStream(clpFile);
    ClpInputStream cis = null;
    InputStream in = clpFile.getName().toLowerCase().endsWith(".clp") ? (cis = new ClpInputStream(fis)) : fis;

    UserAgentAdapter userAgentAdapter = new UserAgentAdapter();
    BridgeContext bridgeContext = new BridgeContext(userAgentAdapter);

    SVGDocument svgDocument;
    GraphicsNode rootSvgNode;
    try {
        String parser = XMLResourceDescriptor.getXMLParserClassName();
        SAXSVGDocumentFactory factory = new SAXSVGDocumentFactory(parser);
        svgDocument = (SVGDocument) factory.createDocument(clpFile.toURI().toString(),
                new InputStreamReader(in, "ISO-8859-1"));
        rootSvgNode = getRootNode(svgDocument, bridgeContext);
    } finally {
        IOUtils.closeQuietly(cis);
        IOUtils.closeQuietly(fis);
    }

    float[] vb = ViewBox.parseViewBoxAttribute(svgDocument.getRootElement(),
            svgDocument.getRootElement().getAttribute("viewBox"), bridgeContext);

    AffineTransform usr2dev = ViewBox.getPreserveAspectRatioTransform(vb,
            SVGPreserveAspectRatio.SVG_PRESERVEASPECTRATIO_NONE, true, widthPixel, heightPixel);

    BufferedImage img = new BufferedImage(widthPixel, heightPixel, BufferedImage.TYPE_INT_ARGB);
    Graphics2D g2d = img.createGraphics();

    g2d.setColor(new Color(0.0f, 0.0f, 0.0f, 0.0f));
    g2d.fillRect(0, 0, widthPixel, heightPixel);
    g2d.transform(usr2dev);

    // fixes "Graphics2D from BufferedImage lacks BUFFERED_IMAGE hint" - part 1
    final Object oldBufferedImage = g2d.getRenderingHint(RenderingHintsKeyExt.KEY_BUFFERED_IMAGE);
    g2d.setRenderingHint(RenderingHintsKeyExt.KEY_BUFFERED_IMAGE, new WeakReference<BufferedImage>(img));
    rootSvgNode.paint(g2d);
    // fixes "Graphics2D from BufferedImage lacks BUFFERED_IMAGE hint" - part 2
    if (oldBufferedImage != null)
        g2d.setRenderingHint(RenderingHintsKeyExt.KEY_BUFFERED_IMAGE, oldBufferedImage);
    else
        g2d.getRenderingHints().remove(RenderingHintsKeyExt.KEY_BUFFERED_IMAGE);

    g2d.dispose();
    return img;
}

From source file:com.simiacryptus.util.Util.java

/**
 * Report./*w  ww .j  av  a  2  s  .co m*/
 *
 * @param fragments the fragments
 * @throws IOException the io exception
 */
public static void report(@javax.annotation.Nonnull final Stream<String> fragments) throws IOException {
    @javax.annotation.Nonnull
    final File outDir = new File("reports");
    outDir.mkdirs();
    final StackTraceElement caller = com.simiacryptus.util.Util
            .getLast(Arrays.stream(Thread.currentThread().getStackTrace())//
                    .filter(x -> x.getClassName().contains("simiacryptus")));
    @javax.annotation.Nonnull
    final File report = new File(outDir, caller.getClassName() + "_" + caller.getLineNumber() + ".html");
    @javax.annotation.Nonnull
    final PrintStream out = new PrintStream(new FileOutputStream(report));
    out.println("<html><head></head><body>");
    fragments.forEach(out::println);
    out.println("</body></html>");
    out.close();
    Desktop.getDesktop().browse(report.toURI());
}

From source file:org.eclipse.virgo.kernel.osgi.provisioning.tools.DependencyLocator10.java

private static String[] readSearchPathsFromConfig(String configPath) {
    if (configPath != null) {
        File configFile = new File(configPath);
        if (configFile.exists()) {
            JSONParser parser = new AntlrJSONParser();
            try {
                Node root = parser.parse(configFile.toURI().toURL());
                return readStringsFromListNode(root, SEARCH_PATHS_PATH, DEFAULT_SEARCH_PATHS);
            } catch (Exception e) {
                throw new RuntimeException("Config file '" + configPath + "' could not be parsed.", e);
            }/*  w  w w  .  j a v a 2 s. co m*/
        } else {
            throw new IllegalArgumentException("Config file '" + configPath + "' does not exist.");
        }
    }
    return new String[0];
}

From source file:eu.udig.catalog.jgrass.utils.JGrassCatalogUtilities.java

/**
 * Reload the service, to which the location refers to. This is ment to be used when new maps
 * are added inside a mapset and the catalog doesn't care to see them. So the tree has to be
 * reloaded./*from  w  w w  .  jav a 2  s  . c  o m*/
 * 
 * @param locationPath the path to the affected location
 * @param monitor the progress monitor
 */
public static void refreshJGrassService(String locationPath, final IProgressMonitor monitor) {

    System.out.println("Lock on locationPath = " + Thread.holdsLock(locationPath));
    synchronized (locationPath) {

        /*
         * if the catalog is active, refresh the location in the catalog window
         */
        ID id = null;
        if (JGrassPlugin.getDefault() != null) {
            File locationFile = new File(locationPath);
            try {
                id = new ID(locationFile.toURI().toURL());
            } catch (MalformedURLException e) {
                e.printStackTrace();
                return;
            }
        } else {
            return;
        }
        /*
         * test code to make the catalog understand that the map should be added
         */
        final ICatalog catalog = CatalogPlugin.getDefault().getLocalCatalog();
        final JGrassService originalJGrassService = catalog.getById(JGrassService.class, id, monitor);

        /*
         * create the same service
         */
        if (originalJGrassService == null)
            return;
        final URL ID = originalJGrassService.getIdentifier();
        Map<String, Serializable> connectionParams = originalJGrassService.getConnectionParams();
        IServiceFactory locator = CatalogPlugin.getDefault().getServiceFactory();
        final List<IService> rereadService = locator.acquire(ID, connectionParams);

        /*
         * replace the service
         */
        if (rereadService.size() > 0) {
            Runnable refreshCatalogRunner = new Runnable() {
                public void run() {
                    final IService newJGrassService = rereadService.get(0);
                    catalog.remove(originalJGrassService);
                    catalog.add(newJGrassService);
                }
            };

            new Thread(refreshCatalogRunner).start();
        }
    }
}

From source file:com.serotonin.m2m2.Main.java

private static ClassLoader loadModules() throws Exception {
    Common.documentationManifest.parseManifestFile("web/WEB-INF/dox");

    File modulesPath = new File(new StringBuilder().append(Common.MA_HOME).append("/web/modules").toString());
    File[] modules = modulesPath.listFiles();
    if (modules == null) {
        modules = new File[0];
    }/*from w w w. j a v  a  2 s  . c o  m*/
    List classLoaderUrls = new ArrayList();
    Map<Module, List<String>> moduleClasses = new HashMap<Module, List<String>>();

    VersionData coreVersion = Common.getVersion();

    List<ModuleWrapper> moduleWrappers = new ArrayList();
    for (File moduleDir : modules) {
        if (!moduleDir.isDirectory()) {
            continue;
        }
        if (new File(moduleDir, "DELETE").exists()) {
            deleteDir(moduleDir);

            LOG.info(new StringBuilder().append("Deleted module directory ").append(moduleDir).toString());
        } else {
            Properties props = null;
            try {
                props = getProperties(moduleDir);
            } catch (ModulePropertiesException e) {
                LOG.warn(new StringBuilder().append("Error loading properties for module ")
                        .append(moduleDir.getPath()).toString(), e.getCause());
            }
            if (props == null) {
                continue;
            }
            String moduleName = props.getProperty("name");
            if (moduleName == null) {
                throw new RuntimeException(new StringBuilder().append("Module ").append(moduleDir.getPath())
                        .append(": ").append("name").append(" not defined in module properties").toString());
            }
            if (!ModuleUtils.validateName(moduleName)) {
                throw new RuntimeException(
                        new StringBuilder().append("Module ").append(moduleDir.getPath()).append(": ")
                                .append("name").append(" has an invalid name: ").append(moduleName).toString());
            }

            String version = props.getProperty("version");
            if (version == null) {
                throw new RuntimeException(new StringBuilder().append("Module ").append(moduleName).append(": ")
                        .append("version").append(" not defined in module properties").toString());
            }

            String moduleCoreVersion = props.getProperty("coreVersion");
            if (moduleCoreVersion == null) {
                throw new RuntimeException(new StringBuilder().append("Module ").append(moduleName).append(": ")
                        .append("coreVersion").append(" not defined in module properties").toString());
            }

            DependencyData moduleCoreDependency = new DependencyData(moduleCoreVersion);
            if (!moduleCoreDependency.matches(coreVersion)) {
                LOG.warn(new StringBuilder().append("Module ").append(moduleName)
                        .append(": this module requires a core version of ").append(moduleCoreVersion)
                        .append(", which does not match the current core version of ")
                        .append(coreVersion.getFullString()).append(". Module not loaded.").toString());
            } else {
                String descriptionKey = props.getProperty("descriptionKey");
                TranslatableMessage description = null;
                if (org.apache.commons.lang3.StringUtils.isBlank(descriptionKey)) {
                    String desc = props.getProperty("description");
                    if (!org.apache.commons.lang3.StringUtils.isBlank(desc))
                        description = new TranslatableMessage("common.default", new Object[] { desc });
                } else {
                    description = new TranslatableMessage(descriptionKey);
                }
                String vendor = props.getProperty("vendor");
                String vendorUrl = props.getProperty("vendorUrl");
                String dependencies = props.getProperty("dependencies");
                String loadOrderStr = props.getProperty("loadOrder");

                int loadOrder = 50;
                if (!org.apache.commons.lang3.StringUtils.isBlank(loadOrderStr)) {
                    try {
                        loadOrder = Integer.parseInt(loadOrderStr);
                    } catch (Exception e) {
                        loadOrder = -1;
                    }

                    if ((loadOrder < 1) || (loadOrder > 100)) {
                        LOG.warn(new StringBuilder().append("Module ").append(moduleName)
                                .append(": bad loadOrder value '").append(loadOrderStr)
                                .append("', must be a number between 1 and 100. Defaulting to 50").toString());

                        loadOrder = 50;
                    }
                }

                Module module = new Module(moduleName, version, description, vendor, vendorUrl, dependencies,
                        loadOrder);
                moduleWrappers.add(new ModuleWrapper(module, props, moduleDir));
            }
        }
    }
    Collections.sort(moduleWrappers, new Comparator<ModuleWrapper>() {
        public int compare(ModuleWrapper m1, ModuleWrapper m2) {
            return m1.module.getLoadOrder() - m2.module.getLoadOrder();
        }
    });
    for (ModuleWrapper moduleWrapper : moduleWrappers) {
        Module module = moduleWrapper.module;
        String moduleName = moduleWrapper.module.getName();
        String version = moduleWrapper.module.getVersion();
        String vendor = moduleWrapper.module.getVendor();
        Properties props = moduleWrapper.props;
        File moduleDir = moduleWrapper.moduleDir;

        ModuleRegistry.addModule(module);

        LOG.info(
                new StringBuilder().append("Loading module '").append(moduleName).append("', v").append(version)
                        .append(" by ").append(vendor == null ? "(unknown vendor)" : vendor).toString());

        String classes = props.getProperty("classes");
        if (!org.apache.commons.lang3.StringUtils.isBlank(classes)) {
            String[] parts = classes.split(",");
            for (String className : parts) {
                if (!org.apache.commons.lang3.StringUtils.isBlank(className)) {
                    className = className.trim();
                    List classNames = (List) moduleClasses.get(module);
                    if (classNames == null) {
                        classNames = new ArrayList();
                        moduleClasses.put(module, classNames);
                    }
                    classNames.add(className);
                }
            }

        }

        File classesDir = new File(moduleDir, "classes");
        if (classesDir.exists()) {
            classLoaderUrls.add(classesDir.toURI().toURL());
        }

        loadLib(moduleDir, classLoaderUrls);

        String logo = props.getProperty("logo");
        if (!org.apache.commons.lang3.StringUtils.isBlank(logo)) {
            Common.applicationLogo = new StringBuilder().append("/modules/").append(moduleName).append("/")
                    .append(logo).toString();
        }

        String favicon = props.getProperty("favicon");
        if (!org.apache.commons.lang3.StringUtils.isBlank(favicon)) {
            Common.applicationFavicon = new StringBuilder().append("/modules/").append(moduleName).append("/")
                    .append(favicon).toString();
        }

        String styles = props.getProperty("styles");
        if (!org.apache.commons.lang3.StringUtils.isBlank(styles)) {
            for (String style : styles.split(",")) {
                style = com.serotonin.util.StringUtils.trimWhitespace(style);
                if (!org.apache.commons.lang3.StringUtils.isBlank(style)) {
                    Common.moduleStyles.add(new StringBuilder().append("modules/").append(moduleName)
                            .append("/").append(style).toString());
                }
            }
        }

        String scripts = props.getProperty("scripts");
        if (!org.apache.commons.lang3.StringUtils.isBlank(scripts)) {
            for (String script : scripts.split(",")) {
                script = com.serotonin.util.StringUtils.trimWhitespace(script);
                if (!org.apache.commons.lang3.StringUtils.isBlank(script)) {
                    Common.moduleScripts.add(new StringBuilder().append("modules/").append(moduleName)
                            .append("/").append(script).toString());
                }
            }
        }

        String jspfs = props.getProperty("jspfs");
        if (!org.apache.commons.lang3.StringUtils.isBlank(jspfs)) {
            for (String jspf : jspfs.split(",")) {
                jspf = com.serotonin.util.StringUtils.trimWhitespace(jspf);
                if (!org.apache.commons.lang3.StringUtils.isBlank(jspf)) {
                    Common.moduleJspfs.add(new StringBuilder().append("/modules/").append(moduleName)
                            .append("/").append(jspf).toString());
                }
            }
        }

        String dox = props.getProperty("documentation");
        if (!org.apache.commons.lang3.StringUtils.isBlank(dox)) {
            Common.documentationManifest.parseManifestFile(new StringBuilder().append("web/modules/")
                    .append(moduleName).append("/").append(dox).toString());
        }

        String locales = props.getProperty("locales");
        if (!org.apache.commons.lang3.StringUtils.isBlank(locales)) {
            String[] s = locales.split(",");
            for (String locale : s) {
                module.addLocaleDefinition(locale.trim());
            }
        }

        String tagdir = props.getProperty("tagdir");
        if (!org.apache.commons.lang3.StringUtils.isBlank(tagdir)) {
            File from = new File(moduleDir, tagdir);
            File to = new File(new StringBuilder().append(Common.MA_HOME).append("/web/WEB-INF/tags/")
                    .append(moduleName).toString());
            deleteDir(to);

            if (from.exists()) {
                FileUtils.copyDirectory(from, to);
            }

        }

        String graphics = props.getProperty("graphics");
        if (!org.apache.commons.lang3.StringUtils.isBlank(graphics)) {
            graphics = com.serotonin.util.StringUtils.trimWhitespace(graphics);
            if (!org.apache.commons.lang3.StringUtils.isBlank(graphics)) {
                module.setGraphicsDir(graphics);
            }
        }

        String emailTemplates = props.getProperty("emailTemplates");
        if (!org.apache.commons.lang3.StringUtils.isBlank(emailTemplates)) {
            emailTemplates = com.serotonin.util.StringUtils.trimWhitespace(emailTemplates);
            if (!org.apache.commons.lang3.StringUtils.isBlank(emailTemplates)) {
                module.setEmailTemplatesDir(emailTemplates);
            }
        }
    }

    for (Module module : ModuleRegistry.getModules()) {
        String dependenciesStr = module.getDependencies();
        if (!org.apache.commons.lang3.StringUtils.isBlank(dependenciesStr)) {
            String[] parts = dependenciesStr.split(",");

            for (String dependencyStr : parts) {
                DependencyData depVer = null;

                dependencyStr = dependencyStr.trim();
                int pos = dependencyStr.lastIndexOf(45);
                String depName;
                if (pos == -1) {
                    depName = dependencyStr;
                } else {
                    depName = dependencyStr.substring(0, pos);

                    String ver = dependenciesStr.substring(pos + 1);
                    try {
                        depVer = new DependencyData(ver);
                    } catch (Exception e) {
                        throw new RuntimeException(new StringBuilder().append("Invalid dependency version in '")
                                .append(dependencyStr).append("'").toString(), e);
                    }

                }

                Module depModule = ModuleRegistry.getModule(depName);
                if (depModule == null) {
                    throw new RuntimeException(new StringBuilder().append("Module '").append(depName)
                            .append("' not found, but required by '").append(module.getName()).append("'")
                            .toString());
                }

                if ((depVer != null) && (!depVer.matches(new VersionData(depModule.getVersion())))) {
                    throw new RuntimeException(new StringBuilder().append("Module '").append(depName)
                            .append("' has version '").append(depModule.getVersion()).append("' but module '")
                            .append(module.getName()).append("' requires version '")
                            .append(depVer.getFullString()).append("'").toString());
                }
            }
        }

    }

    URL[] arr = (URL[]) classLoaderUrls.toArray(new URL[0]);
    URLClassLoader cl = new URLClassLoader(arr, Main.class.getClassLoader());
    Thread.currentThread().setContextClassLoader(cl);

    for (Map.Entry mod : moduleClasses.entrySet()) {
        try {
            for (String className : (List<String>) mod.getValue()) {
                Class clazz = cl.loadClass(className);
                boolean used = false;

                if (ModuleElementDefinition.class.isAssignableFrom(clazz)) {
                    ModuleElementDefinition def = (ModuleElementDefinition) clazz.newInstance();
                    ((Module) mod.getKey()).addDefinition(def);
                    used = true;
                }

                if (!used)
                    LOG.warn(new StringBuilder().append("Unused classes entry: ").append(className).toString());
            }
        } catch (Exception e) {
            throw new Exception(new StringBuilder().append("Exception loading classes in module ")
                    .append(((Module) mod.getKey()).getName()).toString(), e);
        }
    }

    return cl;
}