当前位置: 首页>>代码示例>>Java>>正文


Java ApplicationService.getState方法代码示例

本文整理汇总了Java中org.onosproject.app.ApplicationService.getState方法的典型用法代码示例。如果您正苦于以下问题:Java ApplicationService.getState方法的具体用法?Java ApplicationService.getState怎么用?Java ApplicationService.getState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.onosproject.app.ApplicationService的用法示例。


在下文中一共展示了ApplicationService.getState方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: populateRow

import org.onosproject.app.ApplicationService; //导入方法依赖的package包/类
private void populateRow(TableModel.Row row, Application app,
                         ApplicationService as) {
    ApplicationId id = app.id();
    ApplicationState state = as.getState(id);
    String iconId = state == ACTIVE ? ICON_ID_ACTIVE : ICON_ID_INACTIVE;

    row.cell(STATE, state)
            .cell(STATE_IID, iconId)
            .cell(ID, id.name())
            .cell(ICON, id.name())
            .cell(VERSION, app.version())
            .cell(CATEGORY, app.category())
            .cell(ORIGIN, app.origin())
            .cell(TITLE, app.title())
            .cell(DESC, app.description())
            .cell(URL, app.url());
}
 
开发者ID:shlee89,项目名称:athena,代码行数:18,代码来源:ApplicationViewMessageHandler.java

示例2: complete

import org.onosproject.app.ApplicationService; //导入方法依赖的package包/类
@Override
    public int complete(String buffer, int cursor, List<String> candidates) {
        // Delegate string completer
        StringsCompleter delegate = new StringsCompleter();

        ApplicationService service = get(ApplicationService.class);
        Iterator<Application> it = service.getApplications().iterator();
        SortedSet<String> strings = delegate.getStrings();
        while (it.hasNext()) {
            Application app = it.next();
            ApplicationState state = service.getState(app.id());
//            if (previousApps.contains(app.id().name())) {
//                continue;
//            }
            if (state == INSTALLED) {
                strings.add(app.id().name());
            }
        }

        // Now let the completer do the work for figuring out what to offer.
        return delegate.complete(buffer, cursor, candidates);
    }
 
开发者ID:shlee89,项目名称:athena,代码行数:23,代码来源:ReviewApplicationNameCompleter.java

示例3: execute

import org.onosproject.app.ApplicationService; //导入方法依赖的package包/类
@Override
protected void execute() {
    ApplicationService service = get(ApplicationService.class);
    List<Application> apps = newArrayList(service.getApplications());
    Collections.sort(apps, Comparators.APP_COMPARATOR);

    if (outputJson()) {
        print("%s", json(service, apps));
    } else {
        for (Application app : apps) {
            boolean isActive = service.getState(app.id()) == ACTIVE;
            if (activeOnly && isActive || !activeOnly) {
                if (shortOnly) {
                    String shortDescription = app.title().equals(app.id().name()) ?
                            app.description().replaceAll("[\\r\\n]", " ").replaceAll(" +", " ") :
                            app.title();
                    print(SHORT_FMT, isActive ? "*" : " ",
                          app.id().id(), app.id().name(), app.version(), shortDescription);
                } else {
                    print(FMT, isActive ? "*" : " ",
                          app.id().id(), app.id().name(), app.version(), app.origin(),
                          app.category(), app.description(), app.features(),
                          app.featuresRepo().map(URI::toString).orElse(""),
                          app.requiredApps(), app.permissions(), app.url());
                }
            }
        }
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:30,代码来源:ApplicationsListCommand.java

示例4: json

import org.onosproject.app.ApplicationService; //导入方法依赖的package包/类
private JsonNode json(ApplicationService service, List<Application> apps) {
    ObjectMapper mapper = new ObjectMapper();
    ArrayNode result = mapper.createArrayNode();
    for (Application app : apps) {
        boolean isActive = service.getState(app.id()) == ACTIVE;
        if (activeOnly && isActive || !activeOnly) {
            result.add(jsonForEntity(app, Application.class));
        }
    }
    return result;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:12,代码来源:ApplicationsListCommand.java

示例5: complete

import org.onosproject.app.ApplicationService; //导入方法依赖的package包/类
@Override
    public int complete(String buffer, int cursor, List<String> candidates) {
        // Delegate string completer
        StringsCompleter delegate = new StringsCompleter();

        // Command name is the second argument.
        ArgumentCompleter.ArgumentList list = getArgumentList();
        String cmd = list.getArguments()[1];

        // Grab apps already on the command (to prevent tab-completed duplicates)
        // FIXME: This does not work.
//        final Set previousApps;
//        if (list.getArguments().length > 2) {
//            previousApps = Sets.newHashSet(
//                    Arrays.copyOfRange(list.getArguments(), 2, list.getArguments().length));
//        } else {
//            previousApps = Collections.emptySet();
//        }

        // Fetch our service and feed it's offerings to the string completer
        ApplicationService service = get(ApplicationService.class);
        Iterator<Application> it = service.getApplications().iterator();
        SortedSet<String> strings = delegate.getStrings();
        while (it.hasNext()) {
            Application app = it.next();
            ApplicationState state = service.getState(app.id());
//            if (previousApps.contains(app.id().name())) {
//                continue;
//            }
            if (cmd.equals("uninstall") ||
                    (cmd.equals("activate") && state == INSTALLED) ||
                    (cmd.equals("deactivate") && state == ACTIVE)) {
                strings.add(app.id().name());
            }
        }

        // Now let the completer do the work for figuring out what to offer.
        return delegate.complete(buffer, cursor, candidates);
    }
 
开发者ID:shlee89,项目名称:athena,代码行数:40,代码来源:ApplicationNameCompleter.java

示例6: ApplicationTableRow

import org.onosproject.app.ApplicationService; //导入方法依赖的package包/类
public ApplicationTableRow(ApplicationService service, Application app) {
    ApplicationState state = service.getState(app.id());
    String iconId = state == ACTIVE ? ICON_ID_ACTIVE : ICON_ID_INACTIVE;

    add(STATE, state.toString());
    add(STATE_IID, iconId);
    add(ID, app.id().name());
    add(VERSION, app.version().toString());
    add(ORIGIN, app.origin());
    add(DESC, app.description());
}
 
开发者ID:ravikumaran2015,项目名称:ravikumaran201504,代码行数:12,代码来源:ApplicationViewMessageHandler.java

示例7: execute

import org.onosproject.app.ApplicationService; //导入方法依赖的package包/类
@Override
protected void execute() {
    ApplicationService service = get(ApplicationService.class);
    List<Application> apps = newArrayList(service.getApplications());
    Collections.sort(apps, Comparators.APP_COMPARATOR);

    if (outputJson()) {
        print("%s", json(service, apps));
    } else {
        for (Application app : apps) {
            boolean isActive = service.getState(app.id()) == ACTIVE;
            if (activeOnly && isActive || !activeOnly) {
                if (shortOnly) {
                    print(SHORT_FMT, isActive ? "*" : " ",
                          app.id().id(), app.id().name(), app.version(),
                          app.origin(), app.description());
                } else {
                    print(FMT, isActive ? "*" : " ",
                          app.id().id(), app.id().name(), app.version(), app.origin(),
                          app.description(), app.features(),
                          app.featuresRepo().isPresent() ? app.featuresRepo().get().toString() : "",
                          app.permissions());
                }
            }
        }
    }
}
 
开发者ID:ravikumaran2015,项目名称:ravikumaran201504,代码行数:28,代码来源:ApplicationsListCommand.java

示例8: json

import org.onosproject.app.ApplicationService; //导入方法依赖的package包/类
private JsonNode json(ApplicationService service, List<Application> apps) {
    ObjectMapper mapper = new ObjectMapper();
    ArrayNode result = mapper.createArrayNode();
    for (Application app : apps) {
        boolean isActive = service.getState(app.id()) == ACTIVE;
        if (activeOnly && isActive || !activeOnly) {
            result.add(json(service, mapper, app));
        }
    }
    return result;
}
 
开发者ID:ravikumaran2015,项目名称:ravikumaran201504,代码行数:12,代码来源:ApplicationsListCommand.java

示例9: process

import org.onosproject.app.ApplicationService; //导入方法依赖的package包/类
@Override
public void process(long sid, ObjectNode payload) {
    String id = string(payload, ID);
    ApplicationService as = get(ApplicationService.class);

    // If the ID was not specified in the payload, use the name of the
    // most recently uploaded app.
    if (isNullOrEmpty(id)) {
        id = ApplicationResource.lastInstalledAppName;
    }

    ApplicationId appId = as.getId(id);
    ApplicationState state = as.getState(appId);
    Application app = as.getApplication(appId);
    ObjectNode data = objectNode();

    data.put(STATE, state.toString());
    data.put(ID, appId.name());
    data.put(VERSION, app.version().toString());
    data.put(ROLE, app.role().toString());
    data.put(CATEGORY, app.category());
    data.put(TITLE, app.title());
    data.put(ORIGIN, app.origin());
    data.put(README, app.readme());
    data.put(DESC, app.description());
    data.put(URL, app.url());

    // process required applications
    ArrayNode requiredApps = arrayNode();
    app.requiredApps().forEach(requiredApps::add);

    data.set(REQUIRED_APPS, requiredApps);

    // process features
    ArrayNode features = arrayNode();
    app.features().forEach(features::add);

    data.set(FEATURES, features);

    // process permissions
    ArrayNode permissions = arrayNode();
    app.permissions().forEach(p -> permissions.add(p.getName()));

    data.set(PERMISSIONS, permissions);

    ObjectNode rootNode = objectNode();
    rootNode.set(DETAILS, data);
    sendMessage(APP_DETAILS_RESP, 0, rootNode);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:50,代码来源:ApplicationViewMessageHandler.java

示例10: process

import org.onosproject.app.ApplicationService; //导入方法依赖的package包/类
@Override
public void process(ObjectNode payload) {
    String id = string(payload, ID);
    ApplicationService as = get(ApplicationService.class);

    // If the ID was not specified in the payload, use the name of the
    // most recently uploaded app.
    if (isNullOrEmpty(id)) {
        id = ApplicationResource.getLastInstalledAppName();
    }

    ApplicationId appId = as.getId(id);
    ApplicationState state = as.getState(appId);
    Application app = as.getApplication(appId);
    ObjectNode data = objectNode();

    data.put(STATE, state.toString());
    data.put(ID, appId.name());
    data.put(VERSION, app.version().toString());
    data.put(ROLE, app.role().toString());
    data.put(CATEGORY, app.category());
    data.put(TITLE, app.title());
    data.put(ORIGIN, app.origin());
    data.put(README, app.readme());
    data.put(DESC, app.description());
    data.put(URL, app.url());

    // process required applications
    ArrayNode requiredApps = arrayNode();
    app.requiredApps().forEach(requiredApps::add);

    data.set(REQUIRED_APPS, requiredApps);

    // process features
    ArrayNode features = arrayNode();
    app.features().forEach(features::add);

    data.set(FEATURES, features);

    // process permissions
    ArrayNode permissions = arrayNode();
    app.permissions().forEach(p -> permissions.add(p.getName()));

    data.set(PERMISSIONS, permissions);

    ObjectNode rootNode = objectNode();
    rootNode.set(DETAILS, data);
    sendMessage(APP_DETAILS_RESP, rootNode);
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:50,代码来源:ApplicationViewMessageHandler.java

示例11: complete

import org.onosproject.app.ApplicationService; //导入方法依赖的package包/类
@Override
    public int complete(String buffer, int cursor, List<String> candidates) {
        // Delegate string completer
        StringsCompleter delegate = new StringsCompleter();

        // Command name is the second argument.
        ArgumentCompleter.ArgumentList list = getArgumentList();
        String cmd = list.getArguments()[1];

        // Grab apps already on the command (to prevent tab-completed duplicates)
        // FIXME: This does not work.
//        final Set previousApps;
//        if (list.getArguments().length > 2) {
//            previousApps = Sets.newHashSet(
//                    Arrays.copyOfRange(list.getArguments(), 2, list.getArguments().length));
//        } else {
//            previousApps = Collections.emptySet();
//        }

        // Fetch our service and feed it's offerings to the string completer
        ApplicationService service = get(ApplicationService.class);
        Iterator<Application> it = service.getApplications().iterator();
        SortedSet<String> strings = delegate.getStrings();
        while (it.hasNext()) {
            Application app = it.next();
            ApplicationState state = service.getState(app.id());
//            if (previousApps.contains(app.id().name())) {
//                continue;
//            }
            if ("uninstall".equals(cmd) || "download".equals(cmd) ||
                    ("activate".equals(cmd) && state == INSTALLED) ||
                    ("deactivate".equals(cmd) && state == ACTIVE)) {
                strings.add(app.id().name());
            }
        }

        // add unique suffix to candidates, if user has something in buffer
        if (!Strings.isNullOrEmpty(buffer)) {
            List<String> suffixCandidates = strings.stream()
                    // remove onos common prefix
                    .map(full -> full.replaceFirst("org\\.onosproject\\.", ""))
                    // a.b.c -> [c, b.c, a.b.c]
                    .flatMap(appName -> {
                        List<String> suffixes = new ArrayList<>();
                        Deque<String> frags = new ArrayDeque<>();
                        // a.b.c -> [c, b, a] -> [c, b.c, a.b.c]
                        Lists.reverse(asList(appName.split("\\."))).forEach(frag -> {
                            frags.addFirst(frag);
                            suffixes.add(frags.stream().collect(Collectors.joining(".")));
                        });
                        return suffixes.stream();
                    })
                    // convert to occurrence map
                    .collect(Collectors.groupingBy(e -> e, Collectors.counting()))
                    .entrySet().stream()
                    // only accept unique suffix
                    .filter(e -> e.getValue() == 1L)
                    .map(Entry::getKey)
                    .collect(Collectors.toList());

            delegate.getStrings().addAll(suffixCandidates);
        }

        // Now let the completer do the work for figuring out what to offer.
        return delegate.complete(buffer, cursor, candidates);
    }
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:67,代码来源:ApplicationNameCompleter.java


注:本文中的org.onosproject.app.ApplicationService.getState方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。