Search in sources :

Example 31 with TYPE

use of org.jvnet.hk2.config.Changed.TYPE in project Payara by payara.

the class ExternalJndiResourceDeployer method toExternalJndiJavaEEResource.

/**
 * Returns a new instance of j2ee external jndi resource from the given
 * config bean.
 * <p/>
 * This method gets called from the external resource
 * deployer to convert external-jndi-resource config bean into
 * external-jndi  j2ee resource.
 *
 * @param rbean external-jndi-resource config bean
 * @param resourceInfo
 * @return a new instance of j2ee external jndi resource
 */
public static org.glassfish.resources.api.JavaEEResource toExternalJndiJavaEEResource(ExternalJndiResource rbean, ResourceInfo resourceInfo) {
    org.glassfish.resources.beans.ExternalJndiResource jr = new org.glassfish.resources.beans.ExternalJndiResource(resourceInfo);
    // jr.setDescription( rbean.getDescription() ); // FIXME: getting error
    // sets the enable flag
    jr.setEnabled(Boolean.valueOf(rbean.getEnabled()));
    // sets the jndi look up name
    jr.setJndiLookupName(rbean.getJndiLookupName());
    // sets the resource type
    jr.setResType(rbean.getResType());
    // sets the factory class name
    jr.setFactoryClass(rbean.getFactoryClass());
    // sets the properties
    List<Property> properties = rbean.getProperty();
    if (properties != null) {
        for (Property property : properties) {
            ResourceProperty rp = new ResourcePropertyImpl(property.getName(), property.getValue());
            jr.addProperty(rp);
        }
    }
    return jr;
}
Also used : ResourceProperty(com.sun.enterprise.repository.ResourceProperty) ExternalJndiResource(org.glassfish.resources.config.ExternalJndiResource) ResourceProperty(com.sun.enterprise.repository.ResourceProperty) Property(org.jvnet.hk2.config.types.Property)

Example 32 with TYPE

use of org.jvnet.hk2.config.Changed.TYPE in project Payara by payara.

the class CustomResourceDeployer method toCustomJavaEEResource.

/**
 * Returns a new instance of j2ee custom resource from the given
 * config bean.
 * <p/>
 * This method gets called from the custom resource deployer
 * to convert custom-resource config bean into custom j2ee resource.
 *
 * @param rbean custom-resource config bean
 * @param resourceInfo the definition of the resources to create
 * @return new instance of j2ee custom resource
 */
public static JavaEEResource toCustomJavaEEResource(CustomResource rbean, ResourceInfo resourceInfo) {
    org.glassfish.resources.beans.CustomResource jr = new org.glassfish.resources.beans.CustomResource(resourceInfo);
    // jr.setDescription(rbean.getDescription()); // FIXME: getting error
    // sets the enable flag
    jr.setEnabled(Boolean.valueOf(rbean.getEnabled()));
    // sets the resource type
    jr.setResType(rbean.getResType());
    // sets the factory class name
    jr.setFactoryClass(rbean.getFactoryClass());
    // sets the properties
    List<Property> properties = rbean.getProperty();
    if (properties != null) {
        for (Property property : properties) {
            ResourceProperty rp = new ResourcePropertyImpl(property.getName(), property.getValue());
            jr.addProperty(rp);
        }
    }
    return jr;
}
Also used : ResourceProperty(com.sun.enterprise.repository.ResourceProperty) CustomResource(org.glassfish.resources.config.CustomResource) ResourceProperty(com.sun.enterprise.repository.ResourceProperty) Property(org.jvnet.hk2.config.types.Property)

Example 33 with TYPE

use of org.jvnet.hk2.config.Changed.TYPE in project Payara by payara.

the class SetHealthCheckServiceConfiguration method execute.

@Override
public void execute(AdminCommandContext context) {
    report = context.getActionReport();
    if (report.getExtraProperties() == null) {
        report.setExtraProperties(new Properties());
    }
    targetConfig = targetUtil.getConfig(target);
    serviceType = parseServiceType(serviceName);
    if (serviceType == null) {
        String values = Arrays.asList(CheckerType.values()).stream().map(type -> type.name().toLowerCase().replace('_', '-')).collect(Collectors.joining(", "));
        report.setMessage("No such service: " + serviceName + ".\nChoose one of: " + values + ".\nThe name can also be given in short form consisting only of the first letters of each word.");
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    // update the service to unify the way it is printed later on
    serviceName = serviceType.name().toLowerCase().replace('_', '-');
    BaseHealthCheck<?, ?> service = getService();
    if (service == null) {
        report.appendMessage(strings.getLocalString("healthcheck.service.configure.status.error", "Service with name {0} could not be found.", serviceName));
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    updateServiceConfiguration(service);
}
Also used : Arrays(java.util.Arrays) HoggingThreadsChecker(fish.payara.nucleus.healthcheck.configuration.HoggingThreadsChecker) BaseThresholdHealthCheck(fish.payara.nucleus.healthcheck.preliminary.BaseThresholdHealthCheck) RestEndpoint(org.glassfish.api.admin.RestEndpoint) PropertyVetoException(java.beans.PropertyVetoException) TransactionFailure(org.jvnet.hk2.config.TransactionFailure) ServerEnvironment(org.glassfish.api.admin.ServerEnvironment) HealthCheckService(fish.payara.nucleus.healthcheck.HealthCheckService) Max(javax.validation.constraints.Max) Property(org.jvnet.hk2.config.types.Property) CheckerConfigurationType(fish.payara.nucleus.healthcheck.configuration.CheckerConfigurationType) Min(javax.validation.constraints.Min) Logger(java.util.logging.Logger) Collectors(java.util.stream.Collectors) Target(org.glassfish.internal.api.Target) ThresholdDiagnosticsChecker(fish.payara.nucleus.healthcheck.configuration.ThresholdDiagnosticsChecker) List(java.util.List) Service(org.jvnet.hk2.annotations.Service) CommandTarget(org.glassfish.config.support.CommandTarget) Domain(com.sun.enterprise.config.serverbeans.Domain) SystemPropertyConstants(com.sun.enterprise.util.SystemPropertyConstants) HealthCheckConstants(fish.payara.nucleus.healthcheck.HealthCheckConstants) ServiceLocator(org.glassfish.hk2.api.ServiceLocator) HealthCheckServiceConfiguration(fish.payara.nucleus.healthcheck.configuration.HealthCheckServiceConfiguration) CheckerType(fish.payara.nucleus.healthcheck.configuration.CheckerType) Param(org.glassfish.api.Param) MonitoredMetric(fish.payara.nucleus.healthcheck.configuration.MonitoredMetric) CommandLock(org.glassfish.api.admin.CommandLock) HealthCheckExecutionOptions(fish.payara.nucleus.healthcheck.HealthCheckExecutionOptions) Level(java.util.logging.Level) I18n(org.glassfish.api.I18n) PerLookup(org.glassfish.hk2.api.PerLookup) Inject(javax.inject.Inject) ActionReport(org.glassfish.api.ActionReport) ExecuteOn(org.glassfish.api.admin.ExecuteOn) RuntimeType(org.glassfish.api.admin.RuntimeType) LocalStringManagerImpl(com.sun.enterprise.util.LocalStringManagerImpl) BiConsumer(java.util.function.BiConsumer) RestEndpoints(org.glassfish.api.admin.RestEndpoints) AdminCommand(org.glassfish.api.admin.AdminCommand) Properties(java.util.Properties) StuckThreadsChecker(fish.payara.nucleus.healthcheck.configuration.StuckThreadsChecker) MicroProfileMetricsChecker(fish.payara.nucleus.healthcheck.configuration.MicroProfileMetricsChecker) TargetType(org.glassfish.config.support.TargetType) Checker(fish.payara.nucleus.healthcheck.configuration.Checker) ConfigSupport(org.jvnet.hk2.config.ConfigSupport) BaseHealthCheck(fish.payara.nucleus.healthcheck.preliminary.BaseHealthCheck) AdminCommandContext(org.glassfish.api.admin.AdminCommandContext) Config(com.sun.enterprise.config.serverbeans.Config) Properties(java.util.Properties)

Example 34 with TYPE

use of org.jvnet.hk2.config.Changed.TYPE in project Payara by payara.

the class CreateSecurityService method execute.

/**
 * Execute the create-security-service admin command.
 */
@Override
public void execute(AdminCommandContext context) {
    final ActionReport report = context.getActionReport();
    // Setup the service type and configuration handler
    if (AUTHENTICATION.equalsIgnoreCase(serviceType)) {
        clazzServiceType = AuthenticationService.class;
        serviceConfigHandler = new AuthenticationConfigHandler();
    } else {
        report.setMessage("Invalid security service type specified: " + serviceType);
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        return;
    }
    // Add service configuration to the security configurations
    // TODO - Add validation logic required for base service configuration
    SecurityConfiguration config = null;
    try {
        config = (SecurityConfiguration) ConfigSupport.apply(new SingleConfigCode<SecurityConfigurations>() {

            @Override
            public Object run(SecurityConfigurations param) throws PropertyVetoException, TransactionFailure {
                SecurityConfiguration svcConfig = param.createChild(clazzServiceType);
                svcConfig.setName(serviceName);
                svcConfig.setDefault(enableDefault.toString());
                param.getSecurityServices().add(svcConfig);
                return svcConfig;
            }
        }, secConfigs);
    } catch (TransactionFailure transactionFailure) {
        report.setMessage("Unable to create security service: " + transactionFailure.getMessage());
        report.setActionExitCode(ActionReport.ExitCode.FAILURE);
        report.setFailureCause(transactionFailure);
        return;
    }
    // TODO - Add validation logic required for specific service configuration
    if ((config != null) && (configuration != null) && (!configuration.isEmpty())) {
        serviceConfigHandler.setupConfiguration(report, config);
    }
}
Also used : PropertyVetoException(java.beans.PropertyVetoException) TransactionFailure(org.jvnet.hk2.config.TransactionFailure) SecurityConfigurations(org.glassfish.security.services.config.SecurityConfigurations) SecurityConfiguration(org.glassfish.security.services.config.SecurityConfiguration) ActionReport(org.glassfish.api.ActionReport)

Example 35 with TYPE

use of org.jvnet.hk2.config.Changed.TYPE in project Payara by payara.

the class TemplateRestResource method buildPath.

/**
 * This method will build the path string as needed by ConfigModularityUtils.getOwningObject().
 * There is a mismatch between what the method expects and the way the REST URIs are constructed.
 * For example, for the transaction-service element, the REST URI, stripped of the HTTP and
 * server context information, looks like this:
 * /domain/configs/config/server-config/transaction-service.  The format expected by the
 * getOwningObject(), however, looks like this:
 * domain/configs/server-config/transaction-service. In the REST URIs, if there is a collection of
 * Named items, the type of the collection is inserted into the URI ("config" here) followed by
 * the name of the particular instance ("server-config").  In building the path, we must identify
 * Named instances and insert the name of the instance rather than the type.  We apply this logic
 * as we recurse up to the top of the Dom tree to finish building the path desired.
 * @param node
 * @return
 */
private String buildPath(Dom node) {
    final Dom parentNode = node.parent();
    String part = node.model.getTagName();
    String name = node.attribute("name");
    if (name != null) {
        part = name;
    }
    return (parentNode != null) ? (buildPath(parentNode) + "/" + part) : part;
}
Also used : Dom(org.jvnet.hk2.config.Dom)

Aggregations

TransactionFailure (org.jvnet.hk2.config.TransactionFailure)15 Property (org.jvnet.hk2.config.types.Property)15 IOException (java.io.IOException)13 ActionReport (org.glassfish.api.ActionReport)13 PropertyVetoException (java.beans.PropertyVetoException)12 List (java.util.List)10 ConfigBeanProxy (org.jvnet.hk2.config.ConfigBeanProxy)10 Method (java.lang.reflect.Method)9 HashMap (java.util.HashMap)9 Map (java.util.Map)7 Logger (java.util.logging.Logger)7 Service (org.jvnet.hk2.annotations.Service)7 ArrayList (java.util.ArrayList)6 Inject (javax.inject.Inject)6 MultiException (org.glassfish.hk2.api.MultiException)6 ConfigBean (org.jvnet.hk2.config.ConfigBean)6 NetworkListener (org.glassfish.grizzly.config.dom.NetworkListener)5 SystemProperty (com.sun.enterprise.config.serverbeans.SystemProperty)4 Collection (java.util.Collection)4 DeploymentException (org.glassfish.deployment.common.DeploymentException)4