public void postConstruct() { commandName = myself.getName(); String parentTypeName = getOne(GenerateServiceFromMethod.PARENT_CONFIGURED, myself.getMetadata()); if (logger.isLoggable(level)) { logger.log(level,"Generic method parent targeted type is " + parentTypeName); parentType = loadClass(parentTypeName); String methodName = getOne(GenerateServiceFromMethod.METHOD_NAME, myself.getMetadata()); targetMethod=null; methodlookup: String targetTypeName = getOne(GenerateServiceFromMethod.METHOD_ACTUAL, myself.getMetadata()); try { targetType = loadClass(targetTypeName);
void prepareInjection(final AdminCommandContext ctx) { // inject resolver with command parameters... manager = new InjectionManager(); resolver = habitat.getService(resolverType); paramResolver = getInjectionResolver(); manager.inject(resolver, paramResolver); }
@Override public boolean preAuthorization(final AdminCommandContext adminCommandContext) { if ( ! super.preAuthorization(adminCommandContext)) { return false; } prepareInjection(adminCommandContext); return true; }
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. model = new GenericCommandModel(targetType, false, null, listing.i18n(), new LocalStringManagerImpl(targetType), habitat.getComponent(DomDocument.class), commandName, listing.resolver(), null); if (logger.isLoggable(level)) { for (String paramName : model.getParametersNames()) { CommandModel.ParamModel param = model.getModelFor(paramName); logger.fine("I take " + param.getName() + " parameters"); } } } catch(Exception e) { String msg = localStrings.getLocalString(GenericCrudCommand.class, "GenericCreateCommand.command_model_exception", "Exception while creating the command model for the generic command {0} : {1}", commandName, e.getMessage()); logger.severe(msg); throw new ComponentException(msg, e); } }
@Override public Object run(Domain writeableDomain) throws PropertyVetoException, TransactionFailure { ConfigBeanProxy child = writeableDomain.createChild(type); Dom domDomain = Dom.unwrap(writeableDomain); final String elementName; try { elementName = GenericCrudCommand.elementName(domDomain.document, Domain.class, type); } catch (ClassNotFoundException e) { throw new TransactionFailure(e.toString()); } if (elementName==null) { String msg = localStrings.getLocalString(TypeResolver.class, "TypeResolver.no_element_of_that_type", "The Domain configuration does not have a sub-element of the type {0}", type.getSimpleName()); throw new TransactionFailure(msg); } domDomain.setNodeElements(elementName, Dom.unwrap(child)); // add to the habitat habitat.addIndex(new ExistingSingletonInhabitant<ConfigBeanProxy>(child), type.getName(), null); return child; } }, domain));
final Config destCopy = (Config) config.deepCopy(configs); if (systemproperties != null) { final Properties properties = GenericCrudCommand.convertStringToProperties(systemproperties,':');
parentType = (Class<ConfigBeanProxy>) loadClass(parentTypeName); } catch(ClassNotFoundException e) { String msg = localStrings.getLocalString(GenericCrudCommand.class,
@Override public boolean preAuthorization(AdminCommandContext adminCommandContext) { prepareInjection(adminCommandContext); return true; }
public CommandRunnerProgressHelper(AdminCommand command, String name, Job job, ProgressStatus clientProgressStatus) { if (command instanceof GenericCrudCommand) { GenericCrudCommand gcc = (GenericCrudCommand) command; Class decorator = gcc.getDecoratorClass(); if (decorator != null) { progressAnnotation = (Progress) decorator.getAnnotation(Progress.class); } } else if (command instanceof ProgressProvider) { progressAnnotation = ((ProgressProvider) command).getProgress(); } else { progressAnnotation = command.getClass().getAnnotation(Progress.class); } this.commandProgress = (CommandProgressImpl) job.getCommandProgress(); //Possible from checkpoint if (progressAnnotation != null) { if (commandProgress == null) { if (progressAnnotation.name() == null || progressAnnotation.name().isEmpty()) { commandProgress = new CommandProgressImpl(name, createIdForCommandProgress(job)); } else { commandProgress = new CommandProgressImpl(progressAnnotation.name(), createIdForCommandProgress(job)); } } connectWithClientProgressStatus(job, clientProgressStatus); job.setCommandProgress(commandProgress); } }
@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 = localStrings.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); } }
@Override public Object run(Domain writeableDomain) throws PropertyVetoException, TransactionFailure { ConfigBeanProxy child = writeableDomain.createChild(type); Dom domDomain = Dom.unwrap(writeableDomain); final String elementName; try { elementName = GenericCrudCommand.elementName(domDomain.document, Domain.class, type); } catch (ClassNotFoundException e) { throw new TransactionFailure(e.toString()); } if (elementName==null) { String msg = localStrings.getLocalString(TypeResolver.class, "TypeResolver.no_element_of_that_type", "The Domain configuration does not have a sub-element of the type {0}", type.getSimpleName()); throw new TransactionFailure(msg); } domDomain.setNodeElements(elementName, Dom.unwrap(child)); // add to the habitat ServiceLocatorUtilities.addOneConstant(habitat, child, null, type); return child; } }, domain));
Properties props = convertStringToProperties(value.toString(), ':'); if (logger.isLoggable(level)) { for (Map.Entry<Object, Object> entry : props.entrySet()) {
c.setInjectionResolver(injector);
@Override void prepareInjection(final AdminCommandContext ctx) { super.prepareInjection(ctx); parentBean = resolver.resolve(ctx, parentType); }
@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.getComponent(DomDocument.class), commandName, delete.resolver(), delete.decorator()); if (logger.isLoggable(level)) { for (String paramName : model.getParametersNames()) { CommandModel.ParamModel param = model.getModelFor(paramName); logger.fine("I take " + param.getName() + " parameters"); } } } catch(Exception e) { String msg = localStrings.getLocalString(GenericCrudCommand.class, "GenericCreateCommand.command_model_exception", "Exception while creating the command model for the generic command {0} : {1}", commandName, e.getMessage()); logger.severe(msg); throw new ComponentException(msg, e); } }
String elementName = GenericCrudCommand.elementName(parentDom.document, targetType, type); if (elementName==null) { return null;
Properties props = convertStringToProperties(value.toString(), ':'); if (logger.isLoggable(level)) { for (Map.Entry<Object, Object> entry : props.entrySet()) {
@Override void prepareInjection(final AdminCommandContext ctx) { super.prepareInjection(ctx); parentBean = resolver.resolve(ctx, parentType); }
@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 = localStrings.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); } }