org.springframework.web.context.WebApplicationContext.getEnvironment()方法的使用及代码示例

x33g5p2x  于2022-02-02 转载在 其他  
字(12.1k)|赞(0)|评价(0)|浏览(131)

本文整理了Java中org.springframework.web.context.WebApplicationContext.getEnvironment()方法的一些代码示例,展示了WebApplicationContext.getEnvironment()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。WebApplicationContext.getEnvironment()方法的具体详情如下:
包路径:org.springframework.web.context.WebApplicationContext
类名称:WebApplicationContext
方法名:getEnvironment

WebApplicationContext.getEnvironment介绍

暂无

代码示例

代码示例来源:origin: spring-projects/spring-framework

/**
 * Create a new {@code DelegatingFilterProxy} that will retrieve the named target
 * bean from the given Spring {@code WebApplicationContext}.
 * <p>For use in Servlet 3.0+ environments where instance-based registration of
 * filters is supported.
 * <p>The target bean must implement the standard Servlet Filter interface.
 * <p>The given {@code WebApplicationContext} may or may not be refreshed when passed
 * in. If it has not, and if the context implements {@link ConfigurableApplicationContext},
 * a {@link ConfigurableApplicationContext#refresh() refresh()} will be attempted before
 * retrieving the named target bean.
 * <p>This proxy's {@code Environment} will be inherited from the given
 * {@code WebApplicationContext}.
 * @param targetBeanName name of the target filter bean in the Spring application
 * context (must not be {@code null}).
 * @param wac the application context from which the target filter will be retrieved;
 * if {@code null}, an application context will be looked up from {@code ServletContext}
 * as a fallback.
 * @see #findWebApplicationContext()
 * @see #setEnvironment(org.springframework.core.env.Environment)
 */
public DelegatingFilterProxy(String targetBeanName, @Nullable WebApplicationContext wac) {
  Assert.hasText(targetBeanName, "Target Filter bean name must not be null or empty");
  this.setTargetBeanName(targetBeanName);
  this.webApplicationContext = wac;
  if (wac != null) {
    this.setEnvironment(wac.getEnvironment());
  }
}

代码示例来源:origin: spring-projects/spring-framework

private void assertHasStandardServletEnvironment(WebApplicationContext ctx) {
  // ensure a default servlet environment exists
  Environment defaultEnv = ctx.getEnvironment();
  assertThat(defaultEnv, notNullValue());
  assertThat(defaultEnv, instanceOf(StandardServletEnvironment.class));
}

代码示例来源:origin: org.springframework/spring-web

/**
 * Create a new {@code DelegatingFilterProxy} that will retrieve the named target
 * bean from the given Spring {@code WebApplicationContext}.
 * <p>For use in Servlet 3.0+ environments where instance-based registration of
 * filters is supported.
 * <p>The target bean must implement the standard Servlet Filter interface.
 * <p>The given {@code WebApplicationContext} may or may not be refreshed when passed
 * in. If it has not, and if the context implements {@link ConfigurableApplicationContext},
 * a {@link ConfigurableApplicationContext#refresh() refresh()} will be attempted before
 * retrieving the named target bean.
 * <p>This proxy's {@code Environment} will be inherited from the given
 * {@code WebApplicationContext}.
 * @param targetBeanName name of the target filter bean in the Spring application
 * context (must not be {@code null}).
 * @param wac the application context from which the target filter will be retrieved;
 * if {@code null}, an application context will be looked up from {@code ServletContext}
 * as a fallback.
 * @see #findWebApplicationContext()
 * @see #setEnvironment(org.springframework.core.env.Environment)
 */
public DelegatingFilterProxy(String targetBeanName, @Nullable WebApplicationContext wac) {
  Assert.hasText(targetBeanName, "Target Filter bean name must not be null or empty");
  this.setTargetBeanName(targetBeanName);
  this.webApplicationContext = wac;
  if (wac != null) {
    this.setEnvironment(wac.getEnvironment());
  }
}

代码示例来源:origin: cloudfoundry/uaa

@BeforeEach
void setup() {
  webApplicationContext.getEnvironment();
  allowQueryString = webApplicationContext.getBean(UaaTokenEndpoint.class).isAllowQueryString();
  IdentityZoneHolder.setProvisioning(webApplicationContext.getBean(IdentityZoneProvisioning.class));
}

代码示例来源:origin: cloudfoundry/uaa

private void setProperty(String name, String value) {
  StandardServletEnvironment env = (StandardServletEnvironment) webApplicationContext.getEnvironment();
  MockPropertySource mockPropertySource = new MockPropertySource();
  mockPropertySource.setProperty(name, value);
  env.getPropertySources().addLast(mockPropertySource);
  assertEquals(value, webApplicationContext.getEnvironment().getProperty(name));
}

代码示例来源:origin: cloudfoundry/uaa

@BeforeEach
void setUp() throws Exception {
  FilterChainProxy springSecurityFilterChain = webApplicationContext.getBean("springSecurityFilterChain", FilterChainProxy.class);
  mockMvc = MockMvcBuilders.webAppContextSetup(webApplicationContext)
      .addFilter(springSecurityFilterChain)
      .build();
  testClient = new TestClient(mockMvc);
  String adminToken = testClient.getClientCredentialsOAuthAccessToken("admin", "adminsecret",
      "clients.read clients.write clients.secret clients.admin uaa.admin");
  String clientId = generator.generate().toLowerCase();
  String clientSecret = generator.generate().toLowerCase();
  String authorities = "scim.read,scim.write,password.write,oauth.approvals,scim.create,uaa.admin";
  clientDetails = MockMvcUtils.createClient(mockMvc, adminToken, clientId, clientSecret, Collections.singleton("oauth"), Arrays.asList("openid", "foo", "bar"), Arrays.asList("client_credentials", "password"), authorities);
  scimReadWriteToken = testClient.getClientCredentialsOAuthAccessToken(clientId, clientSecret, "scim.read scim.write password.write");
  scimCreateToken = testClient.getClientCredentialsOAuthAccessToken(clientId, clientSecret, "scim.create");
  usersRepository = webApplicationContext.getBean(ScimUserProvisioning.class);
  identityProviderProvisioning = webApplicationContext.getBean(JdbcIdentityProviderProvisioning.class);
  codeStore = webApplicationContext.getBean(ExpiringCodeStore.class);
  mfaCredentialsProvisioning = webApplicationContext.getBean(JdbcUserGoogleMfaCredentialsProvisioning.class);
  mfaProviderProvisioning = webApplicationContext.getBean(JdbcMfaProviderProvisioning.class);
  uaaAdminToken = testClient.getClientCredentialsOAuthAccessToken(clientId, clientSecret, "uaa.admin");
  usersMaxCount = Integer.parseInt(webApplicationContext.getEnvironment().getProperty("userMaxCount"));
}

代码示例来源:origin: stackoverflow.com

ServletContext sc = request.getSession().getServletContext();
WebApplicationContext applicationContext = WebApplicationContextUtils.getWebApplicationContext(sc);
String[] profiles = applicationContext.getEnvironment().getActiveProfiles();

代码示例来源:origin: com.almis.awe/awe-model

/**
 * Autowired constructor
 * @param streamSerializer Serializer
 * @param context Context
 * @param logger Logger
 */
@Autowired
public AweElements(XStreamSerializer streamSerializer, WebApplicationContext context, LogUtil logger) {
 this.serializer = streamSerializer;
 this.context = context;
 this.logger = logger;
 this.environment = context.getEnvironment();
}

代码示例来源:origin: seleniumkit/selenograph

@Override
public void contextInitialized(ServletContextEvent sce) {
  LOGGER.info("Servlet context initialized");
  int tpSize = Integer.valueOf(getWebApplicationContext(sce.getServletContext()).getEnvironment()
      .getProperty("grid.config.jetty.executor.threads.count", "500"));
  sce.getServletContext().setAttribute("org.eclipse.jetty.server.Executor", newFixedThreadPool(tpSize));
}

代码示例来源:origin: wu191287278/spring-boot-starter-dubbo

private static Environment getEnvironment() {
  return getApplicationContext().getEnvironment();
}

代码示例来源:origin: com.almis.awe/awe-model

@PostConstruct
public void onInitialize() {
 this.elements = getBean(AweElements.class);
 this.environment = context.getEnvironment();
 this.logger = getBean(LogUtil.class);
}

代码示例来源:origin: org.jmockring/jmockring-core

/**
 * @param context
 *
 * @return
 */
public static BaseContextConfiguration getContextConfigurationFromContext(WebApplicationContext context) {
  Map configMap = (Map) ((StandardServletEnvironment) context.getEnvironment()).getPropertySources()
      .get(ConfigurationConstants.EXECUTION_ENVIRONMENT_KEY).getSource();
  return (BaseContextConfiguration) configMap.get(ConfigurationConstants.CONTEXT_CONFIGURATION_KEY);
}

代码示例来源:origin: org.jmockring/jmockring-core

/**
 * @param context
 *
 * @return
 */
public static ServerConfiguration getConfigurationFromContext(WebApplicationContext context) {
  Map configMap = (Map) ((StandardServletEnvironment) context.getEnvironment()).getPropertySources()
      .get(ConfigurationConstants.EXECUTION_ENVIRONMENT_KEY).getSource();
  return (ServerConfiguration) configMap.get(ConfigurationConstants.SERVER_CONFIGURATION_KEY);
}

代码示例来源:origin: org.jmockring/jmockring-core

/**
 * @param context
 *
 * @return
 */
public static Class<? extends WebServer> getBootstrapClassFromContext(WebApplicationContext context) {
  Map configMap = (Map) ((StandardServletEnvironment) context.getEnvironment()).getPropertySources()
      .get(ConfigurationConstants.EXECUTION_ENVIRONMENT_KEY).getSource();
  return (Class<? extends WebServer>) configMap.get(ConfigurationConstants.EXECUTION_PROPERTIES_BOOTSTRAP);
}

代码示例来源:origin: org.apache.servicemix.bundles/org.apache.servicemix.bundles.spring-web

/**
 * Create a new {@code DelegatingFilterProxy} that will retrieve the named target
 * bean from the given Spring {@code WebApplicationContext}.
 * <p>For use in Servlet 3.0+ environments where instance-based registration of
 * filters is supported.
 * <p>The target bean must implement the standard Servlet Filter interface.
 * <p>The given {@code WebApplicationContext} may or may not be refreshed when passed
 * in. If it has not, and if the context implements {@link ConfigurableApplicationContext},
 * a {@link ConfigurableApplicationContext#refresh() refresh()} will be attempted before
 * retrieving the named target bean.
 * <p>This proxy's {@code Environment} will be inherited from the given
 * {@code WebApplicationContext}.
 * @param targetBeanName name of the target filter bean in the Spring application
 * context (must not be {@code null}).
 * @param wac the application context from which the target filter will be retrieved;
 * if {@code null}, an application context will be looked up from {@code ServletContext}
 * as a fallback.
 * @see #findWebApplicationContext()
 * @see #setEnvironment(org.springframework.core.env.Environment)
 */
public DelegatingFilterProxy(String targetBeanName, @Nullable WebApplicationContext wac) {
  Assert.hasText(targetBeanName, "Target Filter bean name must not be null or empty");
  this.setTargetBeanName(targetBeanName);
  this.webApplicationContext = wac;
  if (wac != null) {
    this.setEnvironment(wac.getEnvironment());
  }
}

代码示例来源:origin: apache/servicemix-bundles

/**
 * Create a new {@code DelegatingFilterProxy} that will retrieve the named target
 * bean from the given Spring {@code WebApplicationContext}.
 * <p>For use in Servlet 3.0+ environments where instance-based registration of
 * filters is supported.
 * <p>The target bean must implement the standard Servlet Filter interface.
 * <p>The given {@code WebApplicationContext} may or may not be refreshed when passed
 * in. If it has not, and if the context implements {@link ConfigurableApplicationContext},
 * a {@link ConfigurableApplicationContext#refresh() refresh()} will be attempted before
 * retrieving the named target bean.
 * <p>This proxy's {@code Environment} will be inherited from the given
 * {@code WebApplicationContext}.
 * @param targetBeanName name of the target filter bean in the Spring application
 * context (must not be {@code null}).
 * @param wac the application context from which the target filter will be retrieved;
 * if {@code null}, an application context will be looked up from {@code ServletContext}
 * as a fallback.
 * @see #findWebApplicationContext()
 * @see #setEnvironment(org.springframework.core.env.Environment)
 */
public DelegatingFilterProxy(String targetBeanName, @Nullable WebApplicationContext wac) {
  Assert.hasText(targetBeanName, "Target Filter bean name must not be null or empty");
  this.setTargetBeanName(targetBeanName);
  this.webApplicationContext = wac;
  if (wac != null) {
    this.setEnvironment(wac.getEnvironment());
  }
}

代码示例来源:origin: 1and1/cosmo

if (productId == null) {
  Environment environment = WebApplicationContextUtils
      .findWebApplicationContext(req.getServletContext()).getEnvironment();
  productId = environment.getProperty(PRODUCT_ID_KEY);

代码示例来源:origin: net.oneandone.cosmo/cosmo-core

if (productId == null) {
  Environment environment = WebApplicationContextUtils
      .findWebApplicationContext(req.getServletContext()).getEnvironment();
  productId = environment.getProperty(PRODUCT_ID_KEY);

代码示例来源:origin: spring-cloud/spring-cloud-dataflow

mockMvc = MockMvcBuilders.webAppContextSetup(configurableApplicationContext)
    .addFilters(filters.toArray(new Filter[filters.size()])).build();
dataflowPort = configurableApplicationContext.getEnvironment().resolvePlaceholders("${server.port}");

相关文章