當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。