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