Search in sources :

Example 16 with CustomResource

use of org.glassfish.resources.config.CustomResource in project Payara by payara.

the class JNDIConfigSource method deleteValue.

public void deleteValue(final String propertyName, String target) throws TransactionFailure {
    // remove the resource reference
    ResourceUtil resourceUtil = Globals.getDefaultHabitat().getService(ResourceUtil.class);
    resourceUtil.deleteResourceRef(propertyName, target);
    ConfigSupport.apply(new SingleConfigCode<Resources>() {

        public Object run(Resources param) throws PropertyVetoException, TransactionFailure {
            CustomResource resource = (CustomResource) domainConfiguration.getResources().getResourceByName(CustomResource.class, propertyName);
            if (resource != null && resource.getJndiName().equals(propertyName)) {
                return param.getResources().remove(resource);
            }
            return null;
        }
    }, domainConfiguration.getResources());
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) TransactionFailure(org.jvnet.hk2.config.TransactionFailure) ResourceUtil(org.glassfish.resourcebase.resources.admin.cli.ResourceUtil) CustomResource(org.glassfish.resources.config.CustomResource) Resources(com.sun.enterprise.config.serverbeans.Resources)

Aggregations

CustomResource (org.glassfish.resources.config.CustomResource)16 Resource (com.sun.enterprise.config.serverbeans.Resource)5 ResourceInfo (org.glassfish.resourcebase.resources.api.ResourceInfo)4 ConfigApiTest (org.glassfish.tests.utils.ConfigApiTest)4 Test (org.junit.Test)4 PropertyVetoException (java.beans.PropertyVetoException)3 TransactionFailure (org.jvnet.hk2.config.TransactionFailure)3 ResourceRef (com.sun.enterprise.config.serverbeans.ResourceRef)2 Resources (com.sun.enterprise.config.serverbeans.Resources)2 ActionReport (org.glassfish.api.ActionReport)2 ParameterMap (org.glassfish.api.admin.ParameterMap)2 Property (org.jvnet.hk2.config.types.Property)2 ResourceProperty (com.sun.enterprise.repository.ResourceProperty)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 ResourceUtil (org.glassfish.resourcebase.resources.admin.cli.ResourceUtil)1 After (org.junit.After)1