本文整理汇总了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();
}
};
}
示例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);
}
}
示例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;
}
示例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;
}
示例5: getCurrentApplicationContext
import org.restlet.Application; //导入方法依赖的package包/类
public static Context getCurrentApplicationContext() {
Application application = Application.getCurrent();
if (application == null) {
return null;
}
return application.getContext();
}
示例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;
}
示例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);
}
示例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 );
}