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


Java SubjectFactory类代码示例

本文整理汇总了Java中org.onosproject.net.config.SubjectFactory的典型用法代码示例。如果您正苦于以下问题:Java SubjectFactory类的具体用法?Java SubjectFactory怎么用?Java SubjectFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: download

import org.onosproject.net.config.SubjectFactory; //导入依赖的package包/类
/**
 * Gets all network configuration for a subjectKey.
 *
 * @param subjectClassKey subjectKey class key
 * @param subjectKey      subjectKey key
 * @return 200 OK with network configuration JSON
 */
@GET
@Path("{subjectClassKey}/{subjectKey}")
@Produces(MediaType.APPLICATION_JSON)
@SuppressWarnings("unchecked")
public Response download(@PathParam("subjectClassKey") String subjectClassKey,
                         @PathParam("subjectKey") String subjectKey) {
    NetworkConfigService service = get(NetworkConfigService.class);
    ObjectNode root = mapper().createObjectNode();
    SubjectFactory subjectFactory =
            nullIsNotFound(service.getSubjectFactory(subjectClassKey),
                           subjectClassNotFoundErrorString(subjectClassKey));
    produceSubjectJson(service, root, subjectFactory.createSubject(subjectKey),
                       true,
                       subjectNotFoundErrorString(subjectClassKey, subjectKey));
    return ok(root).build();
}
 
开发者ID:shlee89,项目名称:athena,代码行数:24,代码来源:NetworkConfigWebResource.java

示例2: execute

import org.onosproject.net.config.SubjectFactory; //导入依赖的package包/类
@Override
protected void execute() {
    service = get(NetworkConfigService.class);
    JsonNode root = mapper.createObjectNode();
    if (isNullOrEmpty(subjectClassKey)) {
        addAll((ObjectNode) root);
    } else {
        SubjectFactory subjectFactory = service.getSubjectFactory(subjectClassKey);
        if (isNullOrEmpty(subjectKey)) {
            addSubjectClass((ObjectNode) root, subjectFactory);
        } else {
            Object s = subjectFactory.createSubject(subjectKey);
            if (isNullOrEmpty(configKey)) {
                addSubject((ObjectNode) root, s);
            } else {
                root = getSubjectConfig(getConfig(s, subjectClassKey, configKey));
            }
        }
    }

    try {
        print("%s", mapper.writerWithDefaultPrettyPrinter().writeValueAsString(root));
    } catch (JsonProcessingException e) {
        throw new RuntimeException("Error writing JSON to string", e);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:27,代码来源:NetworkConfigCommand.java

示例3: choices

import org.onosproject.net.config.SubjectFactory; //导入依赖的package包/类
@Override
protected List<String> choices() {
    NetworkConfigRegistry service = AbstractShellCommand.get(NetworkConfigRegistry.class);
    ArgumentList args = getArgumentList();

    checkArgument(args.getCursorArgumentIndex() >= 2);
    String subjectClassKey = args.getArguments()[args.getCursorArgumentIndex() - 2];

    SubjectFactory<?> subjectFactory = service.getSubjectFactory(subjectClassKey);
    if (subjectFactory == null) {
        return ImmutableList.of();
    }

    String subjectKey = args.getArguments()[args.getCursorArgumentIndex() - 1];

    Object subject = subjectFactory.createSubject(subjectKey);
    Set<? extends Config<Object>> configs = service.getConfigs(subject);
    return configs.stream().map(Config::key).collect(Collectors.toList());
}
 
开发者ID:shlee89,项目名称:athena,代码行数:20,代码来源:ConfigKeyCompleter.java

示例4: upload

import org.onosproject.net.config.SubjectFactory; //导入依赖的package包/类
/**
 * Upload multiple network configurations for a subject class.
 *
 * @param subjectClassKey subject class key
 * @param request         network configuration JSON rooted at the top node
 * @return 200 OK
 * @throws IOException if unable to parse the request
 */
@POST
@Path("{subjectClassKey}")
@Consumes(MediaType.APPLICATION_JSON)
@SuppressWarnings("unchecked")
public Response upload(@PathParam("subjectClassKey") String subjectClassKey,
                       InputStream request) throws IOException {
    NetworkConfigService service = get(NetworkConfigService.class);
    ObjectNode root = (ObjectNode) mapper().readTree(request);
    SubjectFactory subjectFactory =
            nullIsNotFound(service.getSubjectFactory(subjectClassKey),
                    subjectClassNotValidErrorString(subjectClassKey));
    List<String> errorMsgs = consumeJson(service, root, subjectFactory);
    if (!errorMsgs.isEmpty()) {
        return Response.status(MULTI_STATUS_RESPONE).entity(produceErrorJson(errorMsgs)).build();
    }
    return Response.ok().build();
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:26,代码来源:NetworkConfigWebResource.java

示例5: registerConfigFactory

import org.onosproject.net.config.SubjectFactory; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public void registerConfigFactory(ConfigFactory configFactory) {
    checkNotNull(configFactory, NULL_FACTORY_MSG);
    if (factoryCounters.containsKey(key(configFactory))) {
        factoryCounters.replace(key(configFactory), (factoryCounters.get(key(configFactory)) + 1));
    } else {
        factories.put(key(configFactory), configFactory);
        factoryCounters.put(key(configFactory), 1);

        configClasses.put(identifier(configFactory), configFactory.configClass());

        SubjectFactory subjectFactory = configFactory.subjectFactory();
        subjectClasses.putIfAbsent(subjectFactory.subjectClassKey(), subjectFactory);
        subjectClassKeys.putIfAbsent(subjectFactory.subjectClass(), subjectFactory);

        store.addConfigFactory(configFactory);
    }
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:20,代码来源:NetworkConfigManager.java

示例6: consumeJson

import org.onosproject.net.config.SubjectFactory; //导入依赖的package包/类
private List<String> consumeJson(NetworkConfigService service, ObjectNode classNode,
                         SubjectFactory subjectFactory) {
    List<String> errorMsgs = new ArrayList<String>();
    classNode.fieldNames().forEachRemaining(s -> {
        List<String> error = consumeSubjectJson(service, (ObjectNode) classNode.path(s),
                                                subjectFactory.createSubject(s),
                                                subjectFactory.subjectClassKey());
        errorMsgs.addAll(error);
    });
    return errorMsgs;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:12,代码来源:NetworkConfigWebResource.java

示例7: getSubjectFactory

import org.onosproject.net.config.SubjectFactory; //导入依赖的package包/类
@Override
public SubjectFactory getSubjectFactory(Class subjectClass) {
    if (subjectClass == Device.class) {
        return mockDevicesSubjectFactory;
    } else if (subjectClass == Link.class) {
        return mockLinksSubjectFactory;
    }
    return null;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:10,代码来源:NetworkConfigWebResourceTest.java

示例8: choices

import org.onosproject.net.config.SubjectFactory; //导入依赖的package包/类
@Override
protected List<String> choices() {
    NetworkConfigRegistry service = AbstractShellCommand.get(NetworkConfigRegistry.class);
    ArgumentList args = getArgumentList();
    String subjectClassKey = args.getArguments()[args.getCursorArgumentIndex() - 1];

    SubjectFactory subjectFactory = service.getSubjectFactory(subjectClassKey);
    if (subjectFactory == null) {
        return Collections.emptyList();
    }
    // get all registered subject objects.
    Set<Object> subjects = service.getSubjects(subjectFactory.subjectClass());
    return subjects.stream().map(subjectFactory::subjectKey).collect(Collectors.toList());
}
 
开发者ID:shlee89,项目名称:athena,代码行数:15,代码来源:SubjectKeyCompleter.java

示例9: addAll

import org.onosproject.net.config.SubjectFactory; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void addAll(ObjectNode root) {
    service.getSubjectClasses()
            .forEach(sc -> {
                SubjectFactory sf = service.getSubjectFactory(sc);
                addSubjectClass(newObject(root, sf.subjectClassKey()), sf);
            });
}
 
开发者ID:shlee89,项目名称:athena,代码行数:9,代码来源:NetworkConfigCommand.java

示例10: choices

import org.onosproject.net.config.SubjectFactory; //导入依赖的package包/类
@Override
protected List<String> choices() {
    NetworkConfigRegistry service = AbstractShellCommand.get(NetworkConfigRegistry.class);
    return service.getSubjectClasses()
            .stream()
            .map(service::getSubjectFactory)
            .map(SubjectFactory::subjectClassKey)
            .collect(Collectors.toList());
}
 
开发者ID:shlee89,项目名称:athena,代码行数:10,代码来源:SubjectClassKeyCompleter.java

示例11: registerConfigFactory

import org.onosproject.net.config.SubjectFactory; //导入依赖的package包/类
@Override
@SuppressWarnings("unchecked")
public void registerConfigFactory(ConfigFactory configFactory) {
    checkNotNull(configFactory, NULL_FACTORY_MSG);
    factories.put(key(configFactory), configFactory);
    configClasses.put(identifier(configFactory), configFactory.configClass());

    SubjectFactory subjectFactory = configFactory.subjectFactory();
    subjectClasses.putIfAbsent(subjectFactory.subjectClassKey(), subjectFactory);
    subjectClassKeys.putIfAbsent(subjectFactory.subjectClass(), subjectFactory);

    store.addConfigFactory(configFactory);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:14,代码来源:NetworkConfigManager.java

示例12: delete

import org.onosproject.net.config.SubjectFactory; //导入依赖的package包/类
/**
 * Clear all network configurations for a subject class.
 *
 * @param subjectClassKey subject class key
 * @return 204 NO CONTENT
 */
@DELETE
@Path("{subjectClassKey}")
@SuppressWarnings("unchecked")
public Response delete(@PathParam("subjectClassKey") String subjectClassKey) {
    NetworkConfigService service = get(NetworkConfigService.class);
    SubjectFactory subjectFactory =
            nullIsNotFound(service.getSubjectFactory(subjectClassKey),
                    subjectClassNotValidErrorString(subjectClassKey));
    service.getSubjects(subjectFactory.subjectClass())
            .forEach(subject -> service.removeConfig(subject));
    return Response.noContent().build();
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:19,代码来源:NetworkConfigWebResource.java

示例13: execute

import org.onosproject.net.config.SubjectFactory; //导入依赖的package包/类
@Override
protected void execute() {
    service = get(NetworkConfigService.class);
    JsonNode root = mapper.createObjectNode();
    if (isNullOrEmpty(subjectClassKey)) {
        if (remove) {
            service.removeConfig();
        }
        addAll((ObjectNode) root);
    } else {
        SubjectFactory subjectFactory = nullIsIllegal(service.getSubjectFactory(subjectClassKey),
                            subjectClassKey + E_CLASSKEY_NOT_REGISTERED);
        if (isNullOrEmpty(subjectKey)) {
            addSubjectClass((ObjectNode) root, subjectFactory);
        } else {
            Object s = subjectFactory.createSubject(subjectKey);
            if (isNullOrEmpty(configKey)) {
                if (remove) {
                    service.removeConfig(s);
                }
                addSubject((ObjectNode) root, s);
            } else {
                if (remove) {
                    service.removeConfig(subjectClassKey, s, configKey);
                }
                root = getSubjectConfig(getConfig(s, subjectClassKey, configKey));
            }
        }
    }

    try {
        print("%s", mapper.writerWithDefaultPrettyPrinter().writeValueAsString(root));
    } catch (JsonProcessingException e) {
        throw new RuntimeException("Error writing JSON to string", e);
    }
}
 
开发者ID:opennetworkinglab,项目名称:onos,代码行数:37,代码来源:NetworkConfigCommand.java

示例14: produceJson

import org.onosproject.net.config.SubjectFactory; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void produceJson(NetworkConfigService service, ObjectNode node,
                         SubjectFactory subjectFactory, Class subjectClass) {
    service.getSubjects(subjectClass).forEach(s ->
        produceSubjectJson(service, newObject(node, subjectFactory.subjectKey(s)), s, false, ""));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:7,代码来源:NetworkConfigWebResource.java

示例15: addSubjectClass

import org.onosproject.net.config.SubjectFactory; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private void addSubjectClass(ObjectNode root, SubjectFactory sf) {
    service.getSubjects(sf.subjectClass())
            .forEach(s -> addSubject(newObject(root, sf.subjectKey(s)), s));
}
 
开发者ID:shlee89,项目名称:athena,代码行数:6,代码来源:NetworkConfigCommand.java


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