當前位置: 首頁>>代碼示例>>Java>>正文


Java Context類代碼示例

本文整理匯總了Java中org.restlet.Context的典型用法代碼示例。如果您正苦於以下問題:Java Context類的具體用法?Java Context怎麽用?Java Context使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Context類屬於org.restlet包,在下文中一共展示了Context類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getJavaActualType

import org.restlet.Context; //導入依賴的package包/類
/**
 * Returns the actual type for a given generic type.
 * 
 * @param initialType
 *            The initial type, which may be generic.
 * @param genericType
 *            The generic type information if any.
 * @return The actual type.
 */
protected Class<?> getJavaActualType(Class<?> initialType, Type genericType) {
    Class<?> result = initialType;

    try {
        if (genericType instanceof TypeVariable<?>) {
            TypeVariable<?> genericTypeVariable = (TypeVariable<?>) genericType;
            String genericTypeName = genericTypeVariable.getName();
            result = getJavaActualType(getJavaClass(), genericTypeName);
        }
    } catch (Throwable t) {
        Context.getCurrentLogger().warn("Cannot get actual type of generic type: " + genericType, t);
    }

    return result;
}
 
開發者ID:restlet,項目名稱:restlet-framework,代碼行數:25,代碼來源:AnnotationInfo.java

示例2: addExtensionHeaders

import org.restlet.Context; //導入依賴的package包/類
/**
 * Adds extension headers if they are non-standard headers.
 * 
 * @param existingHeaders
 *            The headers to update.
 * @param additionalHeaders
 *            The headers to add.
 */
public static void addExtensionHeaders(Series<Header> existingHeaders,
        Series<Header> additionalHeaders) {
    if (additionalHeaders != null) {
        for (Header param : additionalHeaders) {
            if (STANDARD_HEADERS.contains(param.getName())) {
                // Standard headers that can't be overridden
                Context.getCurrentLogger()
                        .warn(
                                "Addition of the standard header \""
                                        + param.getName()
                                        + "\" is not allowed. Please use the equivalent property in the Restlet API.");
            } else if (UNSUPPORTED_STANDARD_HEADERS.contains(param
                    .getName())) {
                Context.getCurrentLogger()
                        .warn(
                                "Addition of the standard header \""
                                        + param.getName()
                                        + "\" is discouraged as a future version of the Restlet API will directly support it.");
                existingHeaders.add(param);
            } else {
                existingHeaders.add(param);
            }
        }
    }
}
 
開發者ID:restlet,項目名稱:restlet-framework,代碼行數:34,代碼來源:HeaderUtils.java

示例3: parse

import org.restlet.Context; //導入依賴的package包/類
/**
 * Parses a post into a given entries series.
 * 
 * @param entries
 *            The target entries series.
 * @param post
 *            The posted form.
 */
public static void parse(Series<FormData> entries, Representation post) {
    if (post != null) {
        if (post.isAvailable()) {
            FormReader fr = null;

            try {
                fr = new FormReader(post);
            } catch (IOException ioe) {
                Context.getCurrentLogger().warn("Unable to create a form reader. Parsing aborted.", ioe);
            }

            if (fr != null) {
                fr.addEntries(entries);
            }
        } else {
            throw new IllegalStateException(
                    "The Web form cannot be parsed as no fresh content is available. If this entity has been already read once, caching of the entity is required");
        }
    }
}
 
開發者ID:restlet,項目名稱:restlet-framework,代碼行數:29,代碼來源:FormUtils.java

示例4: getRestlet

import org.restlet.Context; //導入依賴的package包/類
@Override
public Restlet getRestlet(Context context) {
    Router router = new Router(context);
    router.attach("/module/all/json", ModuleLoaderResource.class);
    router.attach("/module/loaded/json", LoadedModuleLoaderResource.class);
    router.attach("/switch/{" + STR_SWITCH_ID + "}/role/json", SwitchRoleResource.class);
    router.attach("/switch/all/{" + STR_STAT_TYPE + "}/json", AllSwitchStatisticsResource.class);
    router.attach("/switch/{" + STR_SWITCH_ID + "}/{" + STR_STAT_TYPE + "}/json", SwitchStatisticsResource.class);
    router.attach("/controller/switches/json", ControllerSwitchesResource.class);
    router.attach("/counter/{" + STR_CTR_MODULE + "}/{" + STR_CTR_TITLE + "}/json", CounterResource.class);
    router.attach("/memory/json", ControllerMemoryResource.class);
    router.attach("/packettrace/json", PacketTraceResource.class);
    router.attach("/storage/tables/json", StorageSourceTablesResource.class);
    router.attach("/controller/summary/json", ControllerSummaryResource.class);
    router.attach("/role/json", ControllerRoleResource.class);
    router.attach("/health/json", HealthCheckResource.class);
    router.attach("/system/uptime/json", SystemUptimeResource.class);
    return router;
}
 
開發者ID:zhenshengcai,項目名稱:floodlight-hardware,代碼行數:20,代碼來源:CoreWebRoutable.java

示例5: registerHelper

import org.restlet.Context; //導入依賴的package包/類
/**
 * Registers a helper.
 *
 * @param classLoader      The classloader to use.
 * @param provider         Bynary name of the helper's class.
 * @param helpers          The list of helpers to update.
 * @param constructorClass The constructor parameter class to look for.
 */
@SuppressWarnings({"unchecked", "rawtypes"})
public void registerHelper(ClassLoader classLoader, String provider,
                           List helpers, Class constructorClass) {
    if ((provider != null) && (!provider.equals(""))) {
        // Instantiate the factory
        try {
            Class providerClass = classLoader.loadClass(provider);

            if (constructorClass == null) {
                helpers.add(providerClass.newInstance());
            } else {
                helpers.add(providerClass.getConstructor(constructorClass)
                        .newInstance(constructorClass.cast(null)));
            }
        } catch (Throwable t) {
            Context.getCurrentLogger().info("Unable to register the helper " + provider, t);
        }
    }
}
 
開發者ID:restlet,項目名稱:restlet-framework,代碼行數:28,代碼來源:Engine.java

示例6: parse

import org.restlet.Context; //導入依賴的package包/類
/**
 * Parses a tag formatted as defined by the HTTP standard.
 * 
 * @param httpTag
 *            The HTTP tag string; if it starts with 'W/' the tag will be
 *            marked as weak and the data following the 'W/' used as the
 *            tag; otherwise it should be surrounded with quotes (e.g.,
 *            "sometag").
 * @return A new tag instance.
 * @see <a href="http://www.w3.org/Protocols/rfc2616/rfc2616-sec3.html#sec3.11">HTTP Entity Tags</a>
 */
public static Tag parse(String httpTag) {
    Tag result = null;
    boolean weak = false;
    String httpTagCopy = httpTag;

    if (httpTagCopy.startsWith("W/")) {
        weak = true;
        httpTagCopy = httpTagCopy.substring(2);
    }

    if (httpTagCopy.startsWith("\"") && httpTagCopy.endsWith("\"")) {
        result = new Tag(
                httpTagCopy.substring(1, httpTagCopy.length() - 1), weak);
    } else if (httpTagCopy.equals("*")) {
        result = new Tag("*", weak);
    } else {
        Context.getCurrentLogger().warn("Invalid tag format detected: " + httpTagCopy);
    }

    return result;
}
 
開發者ID:restlet,項目名稱:restlet-framework,代碼行數:33,代碼來源:Tag.java

示例7: getRestlet

import org.restlet.Context; //導入依賴的package包/類
@Override
public Restlet getRestlet(Context context) {
    Router router = new Router(context);
    router.attach("/module/all/json", ModuleLoaderResource.class);
    router.attach("/module/loaded/json", LoadedModuleLoaderResource.class);
    router.attach("/switch/{switchId}/role/json", SwitchRoleResource.class);
    router.attach("/switch/all/{statType}/json", AllSwitchStatisticsResource.class);
    router.attach("/switch/{switchId}/{statType}/json", SwitchStatisticsResource.class);
    router.attach("/controller/switches/json", ControllerSwitchesResource.class);
    router.attach("/counter/{counterTitle}/json", CounterResource.class);
    router.attach("/counter/{switchId}/{counterName}/json", SwitchCounterResource.class);
    router.attach("/counter/categories/{switchId}/{counterName}/{layer}/json", SwitchCounterCategoriesResource.class);
    router.attach("/memory/json", ControllerMemoryResource.class);
    router.attach("/packettrace/json", PacketTraceResource.class);
    router.attach("/storage/tables/json", StorageSourceTablesResource.class);
    router.attach("/controller/summary/json", ControllerSummaryResource.class);
    router.attach("/role/json", ControllerRoleResource.class);
    router.attach("/health/json", HealthCheckResource.class);
    router.attach("/system/uptime/json", SystemUptimeResource.class);
    return router;
}
 
開發者ID:JianqingJiang,項目名稱:QoS-floodlight,代碼行數:22,代碼來源:CoreWebRoutable.java

示例8: createFinder

import org.restlet.Context; //導入依賴的package包/類
/**
 * Creates a new finder instance based on the "targetClass" property.
 * 
 * @param targetClass
 *            The target Resource class to attach.
 * @param finderClass
 *            The optional finder class to instantiate.
 * @param logger
 *            The logger.
 * @return The new finder instance.
 */
public static Finder createFinder(
        Class<? extends ServerResource> targetClass,
        Class<? extends Finder> finderClass, Context context, Logger logger) {
    Finder result = null;

    if (finderClass != null) {
        try {
            Constructor<? extends Finder> constructor = finderClass
                    .getConstructor(Context.class, Class.class);

            if (constructor != null) {
                result = constructor.newInstance(context, targetClass);
            }
        } catch (Exception e) {
            if (logger != null) {
                logger.warn("Exception while instantiating the finder.", e);
            }
        }
    } else {
        result = new Finder(context, targetClass);
    }

    return result;
}
 
開發者ID:restlet,項目名稱:restlet-framework,代碼行數:36,代碼來源:Finder.java

示例9: encode

import org.restlet.Context; //導入依賴的package包/類
/**
 * Encodes a given string using the standard URI encoding mechanism and the
 * UTF-8 character set. Useful to prevent the usage of '+' to encode spaces
 * (%20 instead). The '*' characters are encoded as %2A and %7E are replaced
 * by '~'.
 * 
 * @param toEncode
 *            The string to encode.
 * @param queryString
 *            True if the string to encode is part of a query string instead
 *            of a HTML form post.
 * @param characterSet
 *            The supported character encoding.
 * @return The encoded string.
 */
public static String encode(String toEncode, boolean queryString, CharacterSet characterSet) {
    String result = null;

    try {
        result = (characterSet == null) ? toEncode : java.net.URLEncoder.encode(toEncode, characterSet.getName());

        if (result != null && queryString) {
            result = result.replace("+", "%20").replace("*", "%2A").replace("%7E", "~");
        }
    } catch (UnsupportedEncodingException uee) {
        Context.getCurrentLogger()
                .warn("Unable to encode the string with the UTF-8 character set.", uee);
    }

    return result;
}
 
開發者ID:restlet,項目名稱:restlet-framework,代碼行數:32,代碼來源:Reference.java

示例10: write

import org.restlet.Context; //導入依賴的package包/類
/**
 * Writes the representation to a stream of characters.
 *
 * @param writer
 *            The writer to use when writing.
 *
 * @throws IOException
 *             If any error occurs attempting to write the stream.
 */
@Override
public void write(Writer writer) throws IOException {
    try {
        new Marshaller<T>(this, this.contextPath, getClassLoader())
                .marshal(getObject(), writer);
    } catch (JAXBException e) {
        Context.getCurrentLogger().warn("JAXB marshalling error caught.", e);

        // Maybe the tree represents a failure, try that.
        try {
            new Marshaller<T>(this, "failure", getClassLoader()).marshal(
                    getObject(), writer);
        } catch (JAXBException e2) {
            // We don't know what package this tree is from.
            throw new IOException(e.getMessage());
        }
    }
}
 
開發者ID:restlet,項目名稱:restlet-framework,代碼行數:28,代碼來源:JaxbRepresentation.java

示例11: init

import org.restlet.Context; //導入依賴的package包/類
@Override
public void init(final Context context, final Request request, final Response response) {
    super.init(context, request, response);
    this.ticketGrantingTicketId = (String) request.getAttributes().get("ticketGrantingTicketId");
    this.setNegotiated(false);
    this.getVariants().add(new Variant(MediaType.APPLICATION_WWW_FORM));
}
 
開發者ID:hsj-xiaokang,項目名稱:springboot-shiro-cas-mybatis,代碼行數:8,代碼來源:TicketGrantingTicketResource.java

示例12: getRestlet

import org.restlet.Context; //導入依賴的package包/類
@Override
public Restlet getRestlet(Context context) {
	Router router = new Router(context);
	router.attach("/controller/summary/json", ControllerSummaryResource.class);
	router.attach("/module/loaded/json", LoadedModuleLoaderResource.class);
	router.attach("/controller/switches/json", ControllerSwitchesResource.class);
	router.attach("/groups_info/json", GroupsInfoResource.class);
	router.attach("/group_info/json", GroupInfoResource.class);
	router.attach("/group_create/json", GroupCreateResource.class);
	return router;
}
 
開發者ID:hexec,項目名稱:floodlight-simple-multicast,代碼行數:12,代碼來源:MulticastWebRoutable.java

示例13: getRestlet

import org.restlet.Context; //導入依賴的package包/類
@Override
public Restlet getRestlet(Context context) {
    Router router = new Router(context);
    router.attach("/flow", FlowResource.class);
    router.attach("/flows/switch_id/{switch_id}", FlowsResource.class);
    router.attach("/meters/switch_id/{switch_id}", MetersResource.class);
    return router;
}
 
開發者ID:telstra,項目名稱:open-kilda,代碼行數:9,代碼來源:SwitchManagerWebRoutable.java

示例14: getRestlet

import org.restlet.Context; //導入依賴的package包/類
@Override
public Restlet getRestlet(Context context) {
    Router router = new Router(context);
    router.attach("/data/json", PerfMonDataResource.class);
    router.attach("/{perfmonstate}/json", PerfMonToggleResource.class); // enable, disable, or reset
    return router;
}
 
開發者ID:xuraylei,項目名稱:fresco_floodlight,代碼行數:8,代碼來源:PerfWebRoutable.java

示例15: getRestlet

import org.restlet.Context; //導入依賴的package包/類
@Override
public Restlet getRestlet(Context context) {
    Router router = new Router(context);
    router.attach("/all/json", DeviceResource.class);
    router.attach("/", DeviceResource.class);
    router.attach("/debug", DeviceEntityResource.class);
    return router;
}
 
開發者ID:xuraylei,項目名稱:fresco_floodlight,代碼行數:9,代碼來源:DeviceRoutable.java


注:本文中的org.restlet.Context類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。