本文整理汇总了Java中org.restlet.Application.getContext方法的典型用法代码示例。如果您正苦于以下问题:Java Application.getContext方法的具体用法?Java Application.getContext怎么用?Java Application.getContext使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.restlet.Application
的用法示例。
在下文中一共展示了Application.getContext方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getCurrentApplicationContext
import org.restlet.Application; //导入方法依赖的package包/类
public static Context getCurrentApplicationContext() {
Application application = Application.getCurrent();
if (application == null) {
return null;
}
return application.getContext();
}
示例2: createApplication
import org.restlet.Application; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
@Override
protected Application createApplication(Context parentContext) {
Application application = super.createApplication(parentContext);
try {
registerComponent(application, RESTLET_APPLICATION_BEAN_NAME + "." + getServletConfig().getServletName());
} catch (Exception e) {
logger.error("Error while creating Restlet Application", e);
throw new RuntimeException(e);
};
application.setName(getServletConfig().getServletName());
application.setContext(parentContext.createChildContext());
// setting logger explicitly, to override the stupid logger put there by
// ServletContextAdapter
application.getContext()
.setLogger(application.getClass()
.getName());
final Context applicationContext = application.getContext();
String initParam;
// Copy all the Servlet component initialization parameters
final javax.servlet.ServletConfig servletConfig = getServletConfig();
for (final Enumeration<String> enum1 = servletConfig.getInitParameterNames(); enum1.hasMoreElements();) {
initParam = enum1.nextElement();
applicationContext.getParameters()
.add(initParam, servletConfig.getInitParameter(initParam));
}
// Copy all the Servlet application initialization parameters
for (final Enumeration<String> enum1 = getServletContext().getInitParameterNames(); enum1.hasMoreElements();) {
initParam = enum1.nextElement();
applicationContext.getParameters()
.add(initParam, getServletContext().getInitParameter(initParam));
}
this.serverAdapter = new ServletAdapter(this.getServletContext(), application);
if (application instanceof RestletSpringApplication) {
RestletSpringApplication bridge = (RestletSpringApplication) application;
bridge.doAfterCreateApplication();
}
return application;
}
示例3: forDocumentSource
import org.restlet.Application; //导入方法依赖的package包/类
/**
* Creates a preheat task for each document descriptor in a document source.
* URIs are assumed to simply be the document names.
*
* @param documentSource
* The document source
* @param applicationInternalName
* The internal application name
* @param application
* The application
* @param applicationLoggerName
* The application logger name
* @return An array of tasks
*/
public static PreheatTask[] forDocumentSource( DocumentSource<Executable> documentSource, String applicationInternalName, Application application, String applicationLoggerName )
{
Collection<DocumentDescriptor<Executable>> documentDescriptors = documentSource.getDocuments();
PreheatTask[] preheatTasks = new PreheatTask[documentDescriptors.size()];
int i = 0;
Context context = application.getContext();
Logger logger = getLogger( applicationLoggerName );
for( DocumentDescriptor<Executable> documentDescriptor : documentDescriptors )
preheatTasks[i++] = new PreheatTask( applicationInternalName, documentDescriptor.getDefaultName(), context, logger );
return preheatTasks;
}
示例4: make
import org.restlet.Application; //导入方法依赖的package包/类
private void make(){
application = new Application(new Context());
Router router = new Router(application.getContext());
application.getContext().getAttributes().put(TokenManager.class.getName(), tokenManager);
application.getContext().getAttributes().put(ClientManager.class.getName(), clientManager);
application.getContext().getAttributes().put(ResourceOwnerManager.class.getName(), ownerManager);
application.getContext().getAttributes().put(OAuthServerResource.PARAMETER_DEFAULT_SCOPE, OAUTHDEFAULTSCOPE);
// Setup Authorize Endpoint - used by the client to obtain authorization from the resource owner via user-agent redirection
router.attach(AUTHORIZEENDPOINTURI, AuthorizationServerResource.class);
// Setup Token Endpoint - used by the client to exchange an authorization grant for an access token, typically with client authentication
ChallengeAuthenticator clientAuthenticator = new ChallengeAuthenticator(application.getContext(), ChallengeScheme.HTTP_BASIC, ObixServiceImpl.REALM);
BugFixClientVerifier clientVerifier = new BugFixClientVerifier(application.getContext());
clientVerifier.setAcceptBodyMethod(true);
clientAuthenticator.setVerifier(clientVerifier);
clientAuthenticator.setNext(AccessTokenServerResource.class);
router.attach(CLIENTTOKENENDPOINTURI, clientAuthenticator);
// Setup Token Auth for Resources Server
router.attach(TOKENAUTHENTICATORURI, TokenAuthServerResource.class);
application.setInboundRoot(router);
}
示例5: PreheatTask
import org.restlet.Application; //导入方法依赖的package包/类
/**
* Constructor.
*
* @param applicationInternalName
* The internal application name
* @param resourceUri
* The internal URI
* @param application
* The application
* @param applicationLoggerName
* The application logger name
*/
public PreheatTask( String applicationInternalName, String resourceUri, Application application, String applicationLoggerName )
{
this( applicationInternalName, resourceUri, application.getContext(), getLogger( applicationLoggerName ) );
}
示例6: CustomEncoder
import org.restlet.Application; //导入方法依赖的package包/类
/**
* Constructor.
*
* @param application
* The application
* @param encodingRequest
* Indicates if the request entities should be encoded
* @param encodingResponse
* Indicates if the response entities should be encoded
*/
public CustomEncoder( Application application, boolean encodingRequest, boolean encodingResponse )
{
this( application.getContext(), encodingRequest, encodingResponse, new CustomEncoderService() );
}