public Manager getManagerImplWithName(String name, Class<? extends Manager> subType) { Set<?> managers = managersRef.getSubTypesOf(subType); for (Object clazz : managers) { Service serviceAnno = ((Class<?>) clazz).getAnnotation(Service.class); if (serviceAnno != null && !StringUtils.isEmpty(serviceAnno.name()) && serviceAnno.name().equals(name)) return (Manager) ((Class<?>) clazz).newInstance(); } return null; }
private String getModuleName(Class<? extends Module> module) { Service service = module.getAnnotation(Service.class); if (service!=null) { return service.name(); } return null; } }
private String getModuleName(Class<? extends Module> module) { Service service = module.getAnnotation(Service.class); if (service!=null) { return service.name(); } return null; } }
/** * Constructor used by subclasses when instantiated by HK2. * ProgramOptions and Environment are injected. name is set here. */ protected CLICommand() { Service service = this.getClass().getAnnotation(Service.class); if (service == null) name = "unknown-command"; // should never happen else name = service.name(); }
CLICommand(AdminCommand adminCommand) { this.adminCommand = adminCommand; Service service = adminCommand.getClass().getAnnotation(Service.class); name = (service != null) ? service.name() : ""; }
private static String getCommandName(final AdminCommand c) { final Service serviceAnno = c.getClass().getAnnotation(Service.class); if (serviceAnno == null) { return "no-name"; } return serviceAnno.name(); }
/** * Constructor used by subclasses when instantiated by HK2. * ProgramOptions and Environment are injected. name is set here. */ protected CLICommand() { Service service = this.getClass().getAnnotation(Service.class); if (service == null) name = "unknown-command"; // should never happen else name = service.name(); }
@Override public int compare(AdminCommand c1, AdminCommand c2) { Service service1 = c1.getClass().getAnnotation(Service.class); Service service2 = c2.getClass().getAnnotation(Service.class); String name1 = (service1 != null) ? service1.name() : ""; String name2 = (service2 != null) ? service2.name() : ""; return name1.compareTo(name2); } }
public CommandModelImpl(Class<?> commandType) { Service service = commandType.getAnnotation(Service.class); commandName = service != null ? service.name() : null; commandClass = commandType; i18n = commandType.getAnnotation(I18n.class); execOn = commandType.getAnnotation(ExecuteOn.class); localStrings = new LocalStringManagerImpl(commandType); params = init(commandType, i18n, localStrings); Class currentClazz = commandType; boolean found = false; while (currentClazz != null) { if (currentClazz.isAnnotationPresent(UnknownOptionsAreOperands.class)) found = true; currentClazz = currentClazz.getSuperclass(); } dashOk = found; }
final String commandName = serviceAnnotation.name(); if(commandName == null) { throw new IllegalArgumentException(
public CommandModelImpl(Class<?> commandType) { Service service = commandType.getAnnotation(Service.class); commandName = service != null ? service.name() : null; commandClass = commandType; i18n = commandType.getAnnotation(I18n.class); execOn = commandType.getAnnotation(ExecuteOn.class); localStrings = new LocalStringManagerImpl(commandType); managedJob = AnnotationUtil.presentTransitive(ManagedJob.class, commandType); params = init(commandType, i18n, localStrings); Class currentClazz = commandType; boolean found = false; while (currentClazz != null) { if (currentClazz.isAnnotationPresent(UnknownOptionsAreOperands.class)) { found = true; } currentClazz = currentClazz.getSuperclass(); } dashOk = found; }
public CommandModelImpl(Class<?> commandType) { Service service = commandType.getAnnotation(Service.class); commandName = service != null ? service.name() : null; commandClass = commandType; i18n = commandType.getAnnotation(I18n.class); execOn = commandType.getAnnotation(ExecuteOn.class); localStrings = new LocalStringManagerImpl(commandType); managedJob = AnnotationUtil.presentTransitive(ManagedJob.class, commandType); params = init(commandType, i18n, localStrings); Class currentClazz = commandType; boolean found = false; while (currentClazz != null) { if (currentClazz.isAnnotationPresent(UnknownOptionsAreOperands.class)) { found = true; } currentClazz = currentClazz.getSuperclass(); } dashOk = found; }
public static List<URL> getModuleLibraryJars(DeploymentContext context) throws Exception { ReadableArchive archive = context.getSource(); List<URL> moduleLibraryURLs = new ArrayList<URL>(); ArchiveHandler handler = context.getArchiveHandler(); if (handler.getClass() == null || handler.getClass().getAnnotation(Service.class) == null) { return moduleLibraryURLs; } String handlerName = handler.getClass().getAnnotation(Service.class).name(); File archiveFile = new File(archive.getURI()); if (handlerName.equals("war")) { // we should add all the WEB-INF/lib jars for web module File webInf = new File(archiveFile, "WEB-INF"); File webInfLib = new File(webInf, "lib"); if (webInfLib.exists()) { moduleLibraryURLs = getLibDirectoryJars(webInfLib); } } else if (handlerName.equals("connector")) { // we should add the top level jars for connector module moduleLibraryURLs = getLibDirectoryJars(archiveFile); } return moduleLibraryURLs; }
/** * Executes the command. * * @param context information */ public void execute(AdminCommandContext context) { final ActionReport report = context.getActionReport(); ActionReport.MessagePart msgPart = report.getTopMessagePart(); msgPart.setChildrenType("WARNING"); ActionReport.MessagePart childPart = msgPart.addChild(); String commandName = getClass().getAnnotation(Service.class).name(); childPart.setMessage(localStrings.getLocalString("deploydir.command.deprecated", "{0} command deprecated. Please use {1} command instead.", commandName, "deploy")); super.execute(context); } }