Search in sources :

Example 1 with ApplicationSettings

use of org.osmorc.settings.ApplicationSettings in project intellij-plugins by JetBrains.

the class OsgiRunConfiguration method readExternal.

@Override
public void readExternal(final Element element) throws InvalidDataException {
    workingDir = element.getAttributeValue(WORKING_DIR_ATTRIBUTE);
    vmParameters = element.getAttributeValue(VM_PARAMETERS_ATTRIBUTE);
    programParameters = element.getAttributeValue(PROGRAM_PARAMETERS_ATTRIBUTE);
    includeAllBundlesInClassPath = Boolean.valueOf(element.getAttributeValue(INCLUDE_ALL_BUNDLES_IN_CLASS_PATH_ATTRIBUTE, "false"));
    useAlternativeJre = Boolean.valueOf(element.getAttributeValue(USE_ALTERNATIVE_JRE_ATTRIBUTE, "false"));
    alternativeJrePath = element.getAttributeValue(ALTERNATIVE_JRE_PATH, "");
    generateWorkingDir = Boolean.valueOf(element.getAttributeValue(GENERATE_WORKING_DIR_ATTRIBUTE));
    try {
        frameworkStartLevel = Integer.parseInt(element.getAttributeValue(FRAMEWORK_START_LEVEL, "1"));
    } catch (NumberFormatException e) {
        frameworkStartLevel = 1;
    }
    try {
        defaultStartLevel = Integer.parseInt(element.getAttributeValue(DEFAULT_START_LEVEL, "5"));
    } catch (NumberFormatException e) {
        defaultStartLevel = 5;
    }
    List<Element> children = element.getChildren(BUNDLE_ELEMENT);
    bundlesToDeploy.clear();
    for (Element child : children) {
        String name = child.getAttributeValue(NAME_ATTRIBUTE);
        String url = child.getAttributeValue(URL_ATTRIBUTE);
        String startLevel = child.getAttributeValue(START_LEVEL_ATTRIBUTE);
        String typeName = child.getAttributeValue(TYPE_ATTRIBUTE);
        SelectedBundle.BundleType type;
        try {
            type = SelectedBundle.BundleType.valueOf(typeName);
        } catch (IllegalArgumentException e) {
            LOG.error("unexpected bundle type '" + typeName + "'");
            type = SelectedBundle.BundleType.Module;
        }
        String path = url != null ? VfsUtilCore.urlToPath(url) : null;
        SelectedBundle selectedBundle = new SelectedBundle(type, name, path);
        if (startLevel != null) {
            try {
                selectedBundle.setStartLevel(Integer.parseInt(startLevel));
            } catch (NumberFormatException ignored) {
            }
        }
        String startAfterInstallationString = child.getAttributeValue(START_AFTER_INSTALLATION_ATTRIBUTE);
        if (startAfterInstallationString != null) {
            selectedBundle.setStartAfterInstallation(Boolean.parseBoolean(startAfterInstallationString));
        }
        bundlesToDeploy.add(selectedBundle);
    }
    // try to load the framework instance
    Element framework = element.getChild(FRAMEWORK_ELEMENT);
    if (framework != null) {
        String name = framework.getAttributeValue(INSTANCE_ATTRIBUTE);
        if (name != null) {
            ApplicationSettings settings = ServiceManager.getService(ApplicationSettings.class);
            instanceToUse = settings.getFrameworkInstance(name);
        }
    }
    Element additionalProperties = element.getChild(ADDITIONAL_PROPERTIES_ELEMENT);
    if (additionalProperties == null) {
        //noinspection SpellCheckingInspection
        additionalProperties = element.getChild("additinalProperties");
    }
    if (additionalProperties != null) {
        List<Attribute> attributes = additionalProperties.getAttributes();
        for (Attribute attribute : attributes) {
            this.additionalProperties.put(attribute.getName(), attribute.getValue());
        }
    }
    super.readExternal(element);
}
Also used : ApplicationSettings(org.osmorc.settings.ApplicationSettings) SelectedBundle(org.osmorc.run.ui.SelectedBundle) Attribute(org.jdom.Attribute) Element(org.jdom.Element)

Aggregations

Attribute (org.jdom.Attribute)1 Element (org.jdom.Element)1 SelectedBundle (org.osmorc.run.ui.SelectedBundle)1 ApplicationSettings (org.osmorc.settings.ApplicationSettings)1