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