Search in sources :

Example 1 with GenericCommandModel

use of org.glassfish.common.util.admin.GenericCommandModel in project Payara by payara.

the class GenericCreateCommand method postConstruct.

@Override
public void postConstruct() {
    super.postConstruct();
    create = getAnnotation(targetMethod, Create.class);
    resolverType = create.resolver();
    try {
        model = new GenericCommandModel(targetType, true, create.cluster(), create.i18n(), new LocalStringManagerImpl(targetType), habitat.<DomDocument>getService(DomDocument.class), commandName, AnnotationUtil.presentTransitive(ManagedJob.class, create.decorator()), create.resolver(), create.decorator());
        if (LOGGER.isLoggable(level)) {
            for (String paramName : model.getParametersNames()) {
                CommandModel.ParamModel param = model.getModelFor(paramName);
                LOGGER.log(Level.FINE, "I take {0} parameters", param.getName());
            }
        }
    } catch (Exception e) {
        String msg = LOCAL_STRINGS.getLocalString(GenericCrudCommand.class, "GenericCreateCommand.command_model_exception", "Exception while creating the command model for the generic command {0} : {1}", commandName, e.getMessage());
        LOGGER.log(Level.SEVERE, ConfigApiLoggerInfo.GENERIC_CREATE_CMD_FAILED, commandName);
        throw new RuntimeException(msg, e);
    }
}
Also used : LocalStringManagerImpl(com.sun.enterprise.util.LocalStringManagerImpl) GenericCommandModel(org.glassfish.common.util.admin.GenericCommandModel) GenericCommandModel(org.glassfish.common.util.admin.GenericCommandModel) PropertyVetoException(java.beans.PropertyVetoException)

Example 2 with GenericCommandModel

use of org.glassfish.common.util.admin.GenericCommandModel in project Payara by payara.

the class GenericDeleteCommand method postConstruct.

@Override
public void postConstruct() {
    super.postConstruct();
    delete = targetMethod.getAnnotation(Delete.class);
    resolverType = delete.resolver();
    try {
        // we pass false for "useAnnotations" as the @Param declarations on
        // the target type are not used for the Delete method parameters.
        model = new GenericCommandModel(targetType, false, delete.cluster(), delete.i18n(), new LocalStringManagerImpl(targetType), habitat.<DomDocument>getService(DomDocument.class), commandName, AnnotationUtil.presentTransitive(ManagedJob.class, delete.decorator()), delete.resolver(), delete.decorator());
        if (LOGGER.isLoggable(level)) {
            for (String paramName : model.getParametersNames()) {
                CommandModel.ParamModel param = model.getModelFor(paramName);
                LOGGER.log(Level.FINE, "I take {0} parameters", param.getName());
            }
        }
    } catch (Exception e) {
        String msg = LOCAL_STRINGS.getLocalString(GenericCrudCommand.class, "GenericCreateCommand.command_model_exception", "Exception while creating the command model for the generic command {0} : {1}", commandName, e.getMessage());
        LogHelper.log(LOGGER, Level.SEVERE, ConfigApiLoggerInfo.GENERIC_CREATE_CMD_FAILED, e, new Object[] { commandName });
        throw new RuntimeException(msg, e);
    }
}
Also used : LocalStringManagerImpl(com.sun.enterprise.util.LocalStringManagerImpl) GenericCommandModel(org.glassfish.common.util.admin.GenericCommandModel) GenericCommandModel(org.glassfish.common.util.admin.GenericCommandModel) PropertyVetoException(java.beans.PropertyVetoException)

Example 3 with GenericCommandModel

use of org.glassfish.common.util.admin.GenericCommandModel in project Payara by payara.

the class GenericListCommand method postConstruct.

@Override
public void postConstruct() {
    super.postConstruct();
    listing = targetMethod.getAnnotation(Listing.class);
    resolverType = listing.resolver();
    try {
        // we pass false for "useAnnotations" as the @Param declarations on
        // the target type are not used for the List method parameters.
        cmdModel = new GenericCommandModel(targetType, false, null, listing.i18n(), new LocalStringManagerImpl(targetType), habitat.<DomDocument>getService(DomDocument.class), commandName, false, listing.resolver(), GenericListCommand.class);
        targetModel = habitat.<DomDocument>getService(DomDocument.class).buildModel(targetType);
        if (LOGGER.isLoggable(level)) {
            for (String paramName : cmdModel.getParametersNames()) {
                CommandModel.ParamModel param = cmdModel.getModelFor(paramName);
                LOGGER.log(Level.FINE, "I take {0} parameters", param.getName());
            }
        }
    } catch (Exception e) {
        String msg = LOCAL_STRINGS.getLocalString(GenericCrudCommand.class, "GenericCreateCommand.command_model_exception", "Exception while creating the command model for the generic command {0} : {1}", commandName, e.getMessage());
        LogHelper.log(LOGGER, Level.SEVERE, ConfigApiLoggerInfo.GENERIC_CREATE_CMD_FAILED, e, commandName);
        throw new RuntimeException(msg, e);
    }
}
Also used : LocalStringManagerImpl(com.sun.enterprise.util.LocalStringManagerImpl) GenericCommandModel(org.glassfish.common.util.admin.GenericCommandModel) GenericCommandModel(org.glassfish.common.util.admin.GenericCommandModel) CommandModel(org.glassfish.api.admin.CommandModel) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Aggregations

LocalStringManagerImpl (com.sun.enterprise.util.LocalStringManagerImpl)3 GenericCommandModel (org.glassfish.common.util.admin.GenericCommandModel)3 PropertyVetoException (java.beans.PropertyVetoException)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 CommandModel (org.glassfish.api.admin.CommandModel)1