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


Java Application.getCurrent方法代码示例

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


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

示例1: newApplicationProvider

import org.restlet.Application; //导入方法依赖的package包/类
/**
 * Creates a {@link Provider}r for the current {@link Application}.
 * Override to use a custom Application provider.
 * 
 * @return A {@link Provider} for the current {@link Application}.
 */
protected Provider<Application> newApplicationProvider() {
    return new Provider<Application>() {
        public Application get() {
            return Application.getCurrent();
        }
    };
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:14,代码来源:RestletGuice.java

示例2: handle

import org.restlet.Application; //导入方法依赖的package包/类
/**
 * In addition to the default behavior, it saves the current application
 * instance into the current thread.
 * 
 * @param request
 *            The request to handle.
 * @param response
 *            The response to update.
 */
@Override
public void handle(Request request, Response response) {
    Application current = Application.getCurrent();
    // Save the current application
    Application.setCurrent(getHelped());

    // Actually handle call
    try {
        super.handle(request, response);
    } finally {
        // restaure the current application
        Application.setCurrent(current);
    }
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:24,代码来源:ApplicationHelper.java

示例3: getMapResolverConstructor

import org.restlet.Application; //导入方法依赖的package包/类
/**
 * The constructor for the map resolver for the current application.
 * <p>
 * The constructor accepts a {@link Map} argument.
 * 
 * @return The constructor for the map resolver
 */
public static Constructor<Resolver<?>> getMapResolverConstructor()
{
	Application application = Application.getCurrent();
	if( application != null )
		return getMapResolverConstructor( application );
	else
		return null;
}
 
开发者ID:tliron,项目名称:prudence,代码行数:16,代码来源:ResolvingTemplate.java

示例4: getCallResolverConstructor

import org.restlet.Application; //导入方法依赖的package包/类
/**
 * The constructor for the call resolver for the current application.
 * <p>
 * The constructor accepts {@link Request} and {@link Response} arguments.
 * 
 * @return The constructor for the call resolver
 */
public static Constructor<Resolver<?>> getCallResolverConstructor()
{
	Application application = Application.getCurrent();
	if( application != null )
		return getCallResolverConstructor( application );
	else
		return null;
}
 
开发者ID:tliron,项目名称:prudence,代码行数:16,代码来源:ResolvingTemplate.java

示例5: getCurrentApplicationContext

import org.restlet.Application; //导入方法依赖的package包/类
public static Context getCurrentApplicationContext() {
	Application application = Application.getCurrent();
	if (application == null) {
		return null;
	}
	return application.getContext();
}
 
开发者ID:ontopia,项目名称:ontopia,代码行数:8,代码来源:ContextUtils.java

示例6: toRepresentation

import org.restlet.Application; //导入方法依赖的package包/类
/**
 * Returns a representation for the given status. In order to customize the
 * default representation, this method can be overridden. It returns a
 * {@link org.restlet.message.Status} representation by default or a
 * {@link java.lang.Throwable} representation if the throwable is annotated
 * with {@link org.restlet.resource.Status}.
 * 
 * @param status
 *            The status to represent.
 * @param request
 *            The request handled.
 * @param response
 *            The response updated.
 * @return The representation of the given status.
 */
public Representation toRepresentation(Status status, Request request,
        Response response) {
    Representation result = null;

    // Do content negotiation for status
    if (converterService != null && connegService != null
            && metadataService != null) {
        Object representationObject = null;

        // Serialize exception if any and if {@link
        // org.restlet.resource.Status} annotation asks for it
        Throwable cause = status.getThrowable();

        if (cause != null) {
            org.restlet.engine.resource.ThrowableAnnotationInfo tai = org.restlet.engine.resource.AnnotationUtils
                    .getInstance().getThrowableAnnotationInfo(
                            cause.getClass());

            if (tai != null && tai.isSerializable()) {
                if (Application.getCurrent() != null
                        && !Application.getCurrent().isDebugging()) {
                    // We clear the stack trace to prevent technical
                    // information leak
                    cause.setStackTrace(new StackTraceElement[] {});

                    if (cause.getCause() != null) {
                        Context.getCurrentLogger()
                                .warn("The cause of the exception should be null except in debug mode");
                    }
                }

                representationObject = cause;
            }
        }

        try {
            // Default representation match with the status properties
            if (representationObject == null) {
                representationObject = new StatusInfo(status,
                        getContactEmail(), getHomeRef().toString());
            }

            List<org.restlet.engine.resource.VariantInfo> variants = org.restlet.engine.converter.ConverterUtils
                    .getVariants(representationObject.getClass(), null);
            if (variants == null) {
                variants = new ArrayList<>();
            }

            Variant variant = connegService.getPreferredVariant(variants,
                    request, metadataService);
            result = converterService.toRepresentation(
                    representationObject, variant);
        } catch (Exception e) {
            Context.getCurrentLogger().warn(
                    "Could not serialize throwable class "
                            + ((cause == null) ? null : cause.getClass()),
                    e);
        }
    }
    return result;
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:77,代码来源:StatusService.java

示例7: Role

import org.restlet.Application; //导入方法依赖的package包/类
/**
 * Default constructor. Note that the parent application is retrieved using
 * the {@link Application#getCurrent()} method if available or is null.
 */
public Role() {
    this(Application.getCurrent(), null, null);
}
 
开发者ID:restlet,项目名称:restlet-framework,代码行数:8,代码来源:Role.java

示例8: ApplicationTask

import org.restlet.Application; //导入方法依赖的package包/类
/**
 * Constructor using current Restlet application.
 * 
 * @param documentName
 *        The document name
 * @param entryPointName
 *        The entry point name or null
 * @param context
 *        The context made available to the task
 * @see Application#getCurrent()
 */
public ApplicationTask( String documentName, String entryPointName, Object context )
{
	this( Application.getCurrent(), documentName, entryPointName, context );
}
 
开发者ID:tliron,项目名称:prudence,代码行数:16,代码来源:ApplicationTask.java


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