當前位置: 首頁>>代碼示例>>Java>>正文


Java DispatcherType類代碼示例

本文整理匯總了Java中javax.servlet.DispatcherType的典型用法代碼示例。如果您正苦於以下問題:Java DispatcherType類的具體用法?Java DispatcherType怎麽用?Java DispatcherType使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


DispatcherType類屬於javax.servlet包,在下文中一共展示了DispatcherType類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: addApplication

import javax.servlet.DispatcherType; //導入依賴的package包/類
private void addApplication(final ServletContextHandler context, final MinijaxApplication application)
        throws IllegalAccessException, InvocationTargetException, NoSuchMethodException {

    // (0) Sort the resource methods by literal length
    application.sortResourceMethods();

    // (1) Add Minijax filter (must come before websocket!)
    context.addFilter(new FilterHolder(new MinijaxFilter(application)), "/*", EnumSet.of(DispatcherType.REQUEST));

    // (2) WebSocket endpoints
    if (OptionalClasses.WEB_SOCKET_UTILS != null) {
        OptionalClasses.WEB_SOCKET_UTILS
                .getMethod("init", ServletContextHandler.class, MinijaxApplication.class)
                .invoke(null, context, application);
    }

    // (3) Dynamic JAX-RS content
    final MinijaxServlet servlet = new MinijaxServlet(application);
    final ServletHolder servletHolder = new ServletHolder(servlet);
    servletHolder.getRegistration().setMultipartConfig(new MultipartConfigElement(""));
    context.addServlet(servletHolder, "/*");
}
 
開發者ID:minijax,項目名稱:minijax,代碼行數:23,代碼來源:Minijax.java

示例2: putHeaders

import javax.servlet.DispatcherType; //導入依賴的package包/類
@Override
protected void putHeaders(HttpServletResponse response, HttpContent content, long contentLength) {
	super.putHeaders(response, content, contentLength);
	HttpFields fields = ((Response) response).getHttpFields();
	if (requestHolder.get().getDispatcherType() == DispatcherType.ERROR) {
		/*
		 * Do not cache error page and also makes sure that error page is not eligible for 
		 * modification check. That is, error page will be always retrieved.
		 */
           fields.put(HttpHeader.CACHE_CONTROL, "must-revalidate,no-cache,no-store");
	} else if (requestHolder.get().getRequestURI().equals("/favicon.ico")) {
		/*
		 * Make sure favicon request is cached. Otherwise, it will be requested for every 
		 * page request.
		 */
		fields.put(HttpHeader.CACHE_CONTROL, "max-age=86400,public");
	}
}
 
開發者ID:jmfgdev,項目名稱:gitplex-mit,代碼行數:19,代碼來源:AssetServlet.java

示例3: handleRequest

import javax.servlet.DispatcherType; //導入依賴的package包/類
@Override
public void handleRequest(final HttpServerExchange exchange) throws Exception {
    final ServletRequestContext servletRequestContext = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY);
    ServletRequest request = servletRequestContext.getServletRequest();
    if (request.getDispatcherType() == DispatcherType.REQUEST) {
        List<SingleConstraintMatch> constraints = servletRequestContext.getRequiredConstrains();
        SecurityContext sc = exchange.getSecurityContext();
        if (!authorizationManager.canAccessResource(constraints, sc.getAuthenticatedAccount(), servletRequestContext.getCurrentServlet().getManagedServlet().getServletInfo(), servletRequestContext.getOriginalRequest(), servletRequestContext.getDeployment())) {

            HttpServletResponse response = (HttpServletResponse) servletRequestContext.getServletResponse();
            response.sendError(StatusCodes.FORBIDDEN);
            return;
        }
    }
    next.handleRequest(exchange);
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:17,代碼來源:ServletSecurityRoleHandler.java

示例4: run

import javax.servlet.DispatcherType; //導入依賴的package包/類
@Override
public void run(@Nonnull final GraphiakConfiguration configuration,
        @Nonnull final Environment environment) throws Exception {

    // Enable CORS
    final FilterRegistration.Dynamic cors = environment.servlets()
            .addFilter("cors", CrossOriginFilter.class);
    cors.addMappingForUrlPatterns(EnumSet.allOf(DispatcherType.class), true,
            "/*");

    // get Riak client
    final RiakClient client = configuration.getRiak().build();

    final MetricStore store = new MetricStore(client);
    environment.lifecycle().manage(new MetricStoreManager(store));

    // Configure the Netty TCP server
    configuration.getNetty().build(environment, store);

    // Resources
    environment.jersey().register(new DashboardResource());
    environment.jersey().register(new MetricsResource(store));
    environment.jersey().register(new EventsResource());
    environment.jersey().register(new PingResource());
    environment.jersey().register(new VersionResource());
}
 
開發者ID:smoketurner,項目名稱:graphiak,代碼行數:27,代碼來源:GraphiakApplication.java

示例5: setRequest

import javax.servlet.DispatcherType; //導入依賴的package包/類
/**
 * Set the request that we are wrapping.
 *
 * @param request
 *            The new wrapped request
 */
void setRequest(HttpServletRequest request) {

	super.setRequest(request);

	// Initialize the attributes for this request
	dispatcherType = (DispatcherType) request.getAttribute(Globals.DISPATCHER_TYPE_ATTR);
	requestDispatcherPath = request.getAttribute(Globals.DISPATCHER_REQUEST_PATH_ATTR);

	// Initialize the path elements for this request
	contextPath = request.getContextPath();
	pathInfo = request.getPathInfo();
	queryString = request.getQueryString();
	requestURI = request.getRequestURI();
	servletPath = request.getServletPath();

}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:23,代碼來源:ApplicationHttpRequest.java

示例6: getDispatcherNames

import javax.servlet.DispatcherType; //導入依賴的package包/類
public String[] getDispatcherNames() {
    ArrayList<String> result = new ArrayList<String>();
    if ((dispatcherMapping & FORWARD) > 0) {
        result.add(DispatcherType.FORWARD.name());
    }
    if ((dispatcherMapping & INCLUDE) > 0) {
        result.add(DispatcherType.INCLUDE.name());
    }
    if ((dispatcherMapping & REQUEST) > 0) {
        result.add(DispatcherType.REQUEST.name());
    }
    if ((dispatcherMapping & ERROR) > 0) {
        result.add(DispatcherType.ERROR.name());
    }
    if ((dispatcherMapping & ASYNC) > 0) {
        result.add(DispatcherType.ASYNC.name());
    }
    return result.toArray(new String[result.size()]);
}
 
開發者ID:sunmingshuai,項目名稱:apache-tomcat-7.0.73-with-comment,代碼行數:20,代碼來源:FilterMap.java

示例7: factory

import javax.servlet.DispatcherType; //導入依賴的package包/類
@Bean(name = "VIFilterRegistrationBeanNew")
public org.springframework.boot.web.servlet.FilterRegistrationBean factory() {

    if(environment != null) {
        String port = environment.getProperty("server.port");
        if(port !=null) {
            System.setProperty(SysKeys.SPRINGBOOTPORTKEY, port);
        }
    }
    org.springframework.boot.web.servlet.FilterRegistrationBean filter =
            new org.springframework.boot.web.servlet.FilterRegistrationBean();
    filter.setFilter(new VIFilter());
    filter.setName("vi-filter");
    filter.addUrlPatterns(URLPATTERNS);
    filter.setDispatcherTypes(DispatcherType.REQUEST, DispatcherType.FORWARD);
    filter.setAsyncSupported(true);
    filter.setOrder(Ordered.HIGHEST_PRECEDENCE);
    return filter;
}
 
開發者ID:ctripcorp,項目名稱:cornerstone,代碼行數:20,代碼來源:AutoConfiguration.java

示例8: setDispatcher

import javax.servlet.DispatcherType; //導入依賴的package包/類
/**
 *
 * This method will be used to set the current state of the FilterMap
 * representing the state of when filters should be applied.
 */
public void setDispatcher(String dispatcherString) {
    String dispatcher = dispatcherString.toUpperCase(Locale.ENGLISH);
    
    if (dispatcher.equals(DispatcherType.FORWARD.name())) {
        // apply FORWARD to the global dispatcherMapping.
        dispatcherMapping |= FORWARD;
    } else if (dispatcher.equals(DispatcherType.INCLUDE.name())) {
        // apply INCLUDE to the global dispatcherMapping.
        dispatcherMapping |= INCLUDE;
    } else if (dispatcher.equals(DispatcherType.REQUEST.name())) {
        // apply REQUEST to the global dispatcherMapping.
        dispatcherMapping |= REQUEST;
    }  else if (dispatcher.equals(DispatcherType.ERROR.name())) {
        // apply ERROR to the global dispatcherMapping.
        dispatcherMapping |= ERROR;
    }  else if (dispatcher.equals(DispatcherType.ASYNC.name())) {
        // apply ERROR to the global dispatcherMapping.
        dispatcherMapping |= ASYNC;
    }
}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:26,代碼來源:FilterMap.java

示例9: setAttribute

import javax.servlet.DispatcherType; //導入依賴的package包/類
/**
 * Override the <code>setAttribute()</code> method of the wrapped request.
 *
 * @param name
 *            Name of the attribute to set
 * @param value
 *            Value of the attribute to set
 */
@Override
public void setAttribute(String name, Object value) {

	if (name.equals(Globals.DISPATCHER_TYPE_ATTR)) {
		dispatcherType = (DispatcherType) value;
		return;
	} else if (name.equals(Globals.DISPATCHER_REQUEST_PATH_ATTR)) {
		requestDispatcherPath = value;
		return;
	}

	if (!setSpecial(name, value)) {
		getRequest().setAttribute(name, value);
	}

}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:25,代碼來源:ApplicationHttpRequest.java

示例10: getDispatcherNames

import javax.servlet.DispatcherType; //導入依賴的package包/類
public String[] getDispatcherNames() {
	ArrayList<String> result = new ArrayList<String>();
	if ((dispatcherMapping & FORWARD) > 0) {
		result.add(DispatcherType.FORWARD.name());
	}
	if ((dispatcherMapping & INCLUDE) > 0) {
		result.add(DispatcherType.INCLUDE.name());
	}
	if ((dispatcherMapping & REQUEST) > 0) {
		result.add(DispatcherType.REQUEST.name());
	}
	if ((dispatcherMapping & ERROR) > 0) {
		result.add(DispatcherType.ERROR.name());
	}
	if ((dispatcherMapping & ASYNC) > 0) {
		result.add(DispatcherType.ASYNC.name());
	}
	return result.toArray(new String[result.size()]);
}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:20,代碼來源:FilterMap.java

示例11: setDispatcher

import javax.servlet.DispatcherType; //導入依賴的package包/類
/**
 *
 * This method will be used to set the current state of the FilterMap
 * representing the state of when filters should be applied.
 */
public void setDispatcher(String dispatcherString) {
	String dispatcher = dispatcherString.toUpperCase(Locale.ENGLISH);

	if (dispatcher.equals(DispatcherType.FORWARD.name())) {
		// apply FORWARD to the global dispatcherMapping.
		dispatcherMapping |= FORWARD;
	} else if (dispatcher.equals(DispatcherType.INCLUDE.name())) {
		// apply INCLUDE to the global dispatcherMapping.
		dispatcherMapping |= INCLUDE;
	} else if (dispatcher.equals(DispatcherType.REQUEST.name())) {
		// apply REQUEST to the global dispatcherMapping.
		dispatcherMapping |= REQUEST;
	} else if (dispatcher.equals(DispatcherType.ERROR.name())) {
		// apply ERROR to the global dispatcherMapping.
		dispatcherMapping |= ERROR;
	} else if (dispatcher.equals(DispatcherType.ASYNC.name())) {
		// apply ERROR to the global dispatcherMapping.
		dispatcherMapping |= ASYNC;
	}
}
 
開發者ID:how2j,項目名稱:lazycat,代碼行數:26,代碼來源:FilterMap.java

示例12: flush

import javax.servlet.DispatcherType; //導入依賴的package包/類
/**
 * {@inheritDoc}
 */
public void flush() throws IOException {
    //according to the servlet spec we ignore a flush from within an include
    if (servletRequestContext.getOriginalRequest().getDispatcherType() == DispatcherType.INCLUDE ||
            servletRequestContext.getOriginalResponse().isTreatAsCommitted()) {
        return;
    }
    if (servletRequestContext.getDeployment().getDeploymentInfo().isIgnoreFlush() &&
            servletRequestContext.getExchange().isRequestComplete() &&
            servletRequestContext.getOriginalResponse().getHeader(Headers.TRANSFER_ENCODING_STRING) == null) {
        //we mark the stream as flushed, but don't actually flush
        //because in most cases flush just kills performance
        //we only do this if the request is fully read, so that http tunneling scenarios still work
        servletRequestContext.getOriginalResponse().setIgnoredFlushPerformed(true);
        return;
    }
    flushInternal();
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:21,代碼來源:ServletOutputStreamImpl.java

示例13: handleRequest

import javax.servlet.DispatcherType; //導入依賴的package包/類
@Override
public void handleRequest(final HttpServerExchange exchange) throws Exception {
    final ServletRequestContext servletRequestContext = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY);
    ServletRequest request = servletRequestContext.getServletRequest();
    ServletResponse response = servletRequestContext.getServletResponse();
    DispatcherType dispatcher = servletRequestContext.getDispatcherType();
    Boolean supported = asyncSupported.get(dispatcher);
    if(supported != null && ! supported) {
        exchange.putAttachment(AsyncContextImpl.ASYNC_SUPPORTED, false    );
    }

    final List<ManagedFilter> filters = this.filters.get(dispatcher);
    if(filters == null) {
        next.handleRequest(exchange);
    } else {
        final FilterChainImpl filterChain = new FilterChainImpl(exchange, filters, next, allowNonStandardWrappers);
        filterChain.doFilter(request, response);
    }
}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:20,代碼來源:FilterHandler.java

示例14: buildRequest

import javax.servlet.DispatcherType; //導入依賴的package包/類
@Override
public MockHttpServletRequest buildRequest(ServletContext servletContext) {
	MockHttpServletRequest request = this.result.getRequest();
	request.setDispatcherType(DispatcherType.ERROR);
	request.setRequestURI(this.path);
	return request;
}
 
開發者ID:spring-cloud,項目名稱:spring-cloud-skipper,代碼行數:8,代碼來源:ReleaseControllerTests.java

示例15: csrfFilterRegistrationBean

import javax.servlet.DispatcherType; //導入依賴的package包/類
/**
 * @return CSRF protection filter bean
 */
@Bean
public FilterRegistrationBean csrfFilterRegistrationBean() {
	String path = "/*";
	logger.debug("Initializing CSRF filter [{}]...", path);
	FilterRegistrationBean frb = new FilterRegistrationBean(new CsrfFilter());
	frb.setDispatcherTypes(EnumSet.of(DispatcherType.REQUEST));
	frb.setName("csrfFilter");
	frb.setAsyncSupported(true);
	frb.addUrlPatterns(path);
	frb.setMatchAfter(false);
	frb.setEnabled(true);
	frb.setOrder(2);
	return frb;
}
 
開發者ID:Erudika,項目名稱:scoold,代碼行數:18,代碼來源:ScooldServer.java


注:本文中的javax.servlet.DispatcherType類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。