Search in sources :

Example 31 with Application

use of com.sun.enterprise.config.serverbeans.Application in project Payara by payara.

the class VersioningService method getVersionFromSameDir.

/**
 * Get the version directory-deployed from the given directory
 *
 * @param directory
 * @return the name of the version currently using the directory, else null
 * @throws VersioningSyntaxException     *
 */
public String getVersionFromSameDir(File dir) throws VersioningSyntaxException {
    try {
        Iterator it = domain.getApplications().getApplications().iterator();
        Application app = null;
        // check if directory deployment exist
        while (it.hasNext()) {
            app = (Application) it.next();
            /*
                 * A lifecycle module appears as an application but has a null location.
                 */
            if (dir.toURI().toString().equals(app.getLocation())) {
                if (!VersioningUtils.getUntaggedName(app.getName()).equals(app.getName())) {
                    return app.getName();
                }
            }
        }
    } catch (VersioningSyntaxException ex) {
    // return null if an exception is thrown
    }
    return null;
}
Also used : Iterator(java.util.Iterator) Application(com.sun.enterprise.config.serverbeans.Application)

Example 32 with Application

use of com.sun.enterprise.config.serverbeans.Application in project Payara by payara.

the class VersioningUtils method getVersions.

/**
 * Extract the set of version(s) of the given application from a set of
 * applications. This method is used by unit tests.
 *
 * @param untaggedName the application name as an untagged version : an
 * application name without version identifier
 * @param allApplications the set of applications
 * @return all the version(s) of the given application in the given set of
 * applications
 */
public static final List<String> getVersions(String untaggedName, List<Application> allApplications) {
    List<String> allVersions = new ArrayList<String>();
    Iterator<Application> it = allApplications.iterator();
    while (it.hasNext()) {
        Application app = it.next();
        // if a tagged version or untagged version of the app
        if (app.getName().startsWith(untaggedName + EXPRESSION_SEPARATOR) || app.getName().equals(untaggedName)) {
            allVersions.add(app.getName());
        }
    }
    return allVersions;
}
Also used : ArrayList(java.util.ArrayList) Application(com.sun.enterprise.config.serverbeans.Application)

Example 33 with Application

use of com.sun.enterprise.config.serverbeans.Application in project Payara by payara.

the class ApplicationConfigSource method deleteValue.

public boolean deleteValue(String propertyName) throws TransactionFailure {
    boolean result = false;
    Application app = domainConfiguration.getApplications().getApplication(configurationName);
    if (app != null) {
        for (Property object : app.getProperty()) {
            if ((PROPERTY_PREFIX + propertyName).equals(object.getName())) {
                ConfigSupport.deleteChild((ConfigBean) ConfigBean.unwrap(app), (ConfigBean) ConfigBean.unwrap(object));
                result = true;
            }
        }
    }
    return result;
}
Also used : Application(com.sun.enterprise.config.serverbeans.Application) Property(org.jvnet.hk2.config.types.Property)

Example 34 with Application

use of com.sun.enterprise.config.serverbeans.Application in project Payara by payara.

the class ApplicationConfigSource method setValue.

public boolean setValue(final String propertyName, final String propertyValue) throws TransactionFailure {
    boolean result = false;
    Application app = domainConfiguration.getApplications().getApplication(configurationName);
    if (app != null) {
        // does the property exist
        Property p = app.getProperty(PROPERTY_PREFIX + propertyName);
        if (p == null) {
            ConfigSupport.apply(new SingleConfigCode<Application>() {

                @Override
                public Object run(Application config) throws TransactionFailure, PropertyVetoException {
                    Property prop = config.createChild(Property.class);
                    prop.setName(PROPERTY_PREFIX + propertyName);
                    prop.setValue(propertyValue);
                    config.getProperty().add(prop);
                    return null;
                }
            }, app);
        } else {
            ConfigSupport.apply(new SingleConfigCode<Property>() {

                @Override
                public Object run(Property config) throws TransactionFailure, PropertyVetoException {
                    config.setValue(propertyValue);
                    return null;
                }
            }, p);
        }
        result = true;
    }
    return result;
}
Also used : TransactionFailure(org.jvnet.hk2.config.TransactionFailure) PropertyVetoException(java.beans.PropertyVetoException) Application(com.sun.enterprise.config.serverbeans.Application) Property(org.jvnet.hk2.config.types.Property)

Example 35 with Application

use of com.sun.enterprise.config.serverbeans.Application in project Payara by payara.

the class ApplicationConfigSource method getProperties.

@Override
public Map<String, String> getProperties() {
    Application config = domainConfiguration.getApplications().getApplication(configurationName);
    HashMap<String, String> result = new HashMap<>();
    if (config != null) {
        List<Property> properties = config.getProperty();
        for (Property property : properties) {
            if (property.getName().startsWith(PROPERTY_PREFIX)) {
                result.put(property.getName().substring(PROPERTY_PREFIX.length()), property.getValue());
            }
        }
    }
    return result;
}
Also used : HashMap(java.util.HashMap) Application(com.sun.enterprise.config.serverbeans.Application) Property(org.jvnet.hk2.config.types.Property)

Aggregations

Application (com.sun.enterprise.config.serverbeans.Application)44 Module (com.sun.enterprise.config.serverbeans.Module)10 ApplicationRef (com.sun.enterprise.config.serverbeans.ApplicationRef)9 ActionReport (org.glassfish.api.ActionReport)9 ArrayList (java.util.ArrayList)8 ApplicationInfo (org.glassfish.internal.data.ApplicationInfo)7 Property (org.jvnet.hk2.config.types.Property)7 Applications (com.sun.enterprise.config.serverbeans.Applications)6 PropertyVetoException (java.beans.PropertyVetoException)6 HashMap (java.util.HashMap)5 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)5 Test (org.junit.Test)4 Server (com.sun.enterprise.config.serverbeans.Server)3 SystemApplications (com.sun.enterprise.config.serverbeans.SystemApplications)3 HashSet (java.util.HashSet)3 Iterator (java.util.Iterator)3 List (java.util.List)3 Logger (java.util.logging.Logger)3 ExtendedDeploymentContext (org.glassfish.internal.deployment.ExtendedDeploymentContext)3 ConfigBeanProxy (org.jvnet.hk2.config.ConfigBeanProxy)3