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


Java Application.getContext方法代码示例

本文整理汇总了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();
}
 
开发者ID:ontopia,项目名称:ontopia,代码行数:8,代码来源:ContextUtils.java

示例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;
}
 
开发者ID:devacfr,项目名称:spring-restlet,代码行数:51,代码来源:RestletSpringApplicationContextServlet.java

示例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;
}
 
开发者ID:tliron,项目名称:prudence,代码行数:27,代码来源:PreheatTask.java

示例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);
       
}
 
开发者ID:lathil,项目名称:Ptoceti,代码行数:31,代码来源:Oauth2ApplicationFactory.java

示例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 ) );
}
 
开发者ID:tliron,项目名称:prudence,代码行数:17,代码来源:PreheatTask.java

示例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() );
}
 
开发者ID:tliron,项目名称:prudence,代码行数:15,代码来源:CustomEncoder.java


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