@Bean public static CustomScopeConfigurer customScopeConfigurer(final ContainerRequestScope scope) { final CustomScopeConfigurer configurer = new CustomScopeConfigurer(); configurer.setScopes(Collections.singletonMap("request", scope)); return configurer; }
@Bean @Lazy public static CustomScopeConfigurer customScopeConfigurer( ScenarioScope scope ) { CustomScopeConfigurer configurer = new CustomScopeConfigurer(); configurer.addScope("scenario", scope); return configurer; }
@Override public BeanDefinition parse(Element element, ParserContext parserContext) { RootBeanDefinition beanDefinition = new RootBeanDefinition(); beanDefinition.setBeanClass(CustomScopeConfigurer.class); beanDefinition.setScope("singleton"); Map<String, Object> scopes = new HashMap<>(); scopes.put("thread", new SimpleThreadScope()); beanDefinition.getPropertyValues().add("scopes", scopes); parserContext.getRegistry().registerBeanDefinition("CustomScopeConfigurer", beanDefinition); return beanDefinition; }
@Bean public static CustomScopeConfigurer customScopeConfigurer(){ CustomScopeConfigurer configurer = new CustomScopeConfigurer(); Map<String, Object> scopes = new HashMap<String, Object>(); scopes.put("view", new ViewScope()); configurer.setScopes(scopes); return configurer; }
@Bean public CustomScopeConfigurer threadCustomScopeConfigurer(ThreadScopeManager threadScopeManager, ConfigurableEnvironment environment) { CustomScopeConfigurer customScopeConfigurer = new CustomScopeConfigurer(); // ConfigurationProperties not configured yet. Use ConfigurableEnvironment to get properties. String scopeName = environment.getProperty(SCOPE_NAME_PROPERTY, ThreadScopeProperties.DEFAULT_SCOPE_NAME); logger.info("Thread scope name set to {}", scopeName); customScopeConfigurer.addScope(scopeName, threadScopeManager); return customScopeConfigurer; }
@SuppressWarnings({ "rawtypes", "unchecked" }) @Bean public CustomScopeConfigurer viewScopeConfigurer() { CustomScopeConfigurer customScopeConfigurer = new CustomScopeConfigurer(); Map scopes = new HashMap(); scopes.put("view", new ViewScope()); customScopeConfigurer.setScopes(scopes); return customScopeConfigurer; }
@Bean(name = "customScopeConfigurer") public static CustomScopeConfigurer createClientScope(final ClientSession clientSession) { Assert.requireNonNull(clientSession, "clientSession"); CustomScopeConfigurer configurer = new CustomScopeConfigurer(); configurer.addScope(ClientScopeImpl.CLIENT_SCOPE, new TestClientScope(clientSession)); return configurer; }
/** * Declare the "tenant" scope. */ @Bean public static CustomScopeConfigurer customScopeConfigurer (TenantScope tenantScope) { CustomScopeConfigurer configurer = new CustomScopeConfigurer (); configurer.addScope("tenant", tenantScope); return configurer; }
@SuppressWarnings("serial") @Bean public org.springframework.beans.factory.config.CustomScopeConfigurer customScopeConfigurer(){ CustomScopeConfigurer csc = new CustomScopeConfigurer(); csc.setScopes(new HashMap<String, Object>() {{ put("view", new com.liferay.faces.demos.spring.ViewScope()); }}); return csc; }
@Bean public static CustomScopeConfigurer webSocketScopeConfigurer( ConfigurableListableBeanFactory beanFactory) { beanFactory.registerResolvableDependency(WebSocketSession.class, new WampSessionScope.WebSocketSessionObjectFactory()); beanFactory.registerResolvableDependency(WampSession.class, new WampSessionScope.WampSessionObjectFactory()); CustomScopeConfigurer configurer = new CustomScopeConfigurer(); configurer.addScope("wampsession", new WampSessionScope()); return configurer; }
@Bean public CustomScopeConfigurer configurer() { CustomScopeConfigurer toRet = new CustomScopeConfigurer(); Map<String, Object> map = new HashMap<String, Object>(); map.put(KarakuBaseConfiguration.SCOPE_CONVERSATION, new SimpleThreadScope()); map.put(KarakuBaseConfiguration.SCOPE_CONVERSATION_MANUAL, new SimpleThreadScope()); map.put(WebApplicationContext.SCOPE_SESSION, new SimpleThreadScope()); toRet.setScopes(map); return toRet; }
@Bean public static CustomScopeConfigurer registerScopes() { CustomScopeConfigurer customScopeConfigurer = new CustomScopeConfigurer(); Map<String, Object> scopes = new HashMap<>(); scopes.put("wideSession", new WideSessionScope()); customScopeConfigurer.setScopes(scopes); return customScopeConfigurer; }
@Bean // must be static // http://stackoverflow.com/questions/14942304/springs-javaconfig-and-customscopeconfigurer-issue public static CustomScopeConfigurer customScope() { CustomScopeConfigurer cus = new CustomScopeConfigurer(); cus.addScope("view", new ViewScope()); return cus; }
@Bean public CustomScopeConfigurer customScopeConfigurer() { final CustomScopeConfigurer configurer = new CustomScopeConfigurer(); configurer.addScope("session", new SimpleThreadScope()); return configurer; }
@Bean public static CustomScopeConfigurer customScopeConfigurer() { Map<String, Object> scopes = new HashMap<>(); scopes.put("view", new ViewScope()); CustomScopeConfigurer bean = new CustomScopeConfigurer(); bean.setScopes(scopes); return bean; }
@Bean static CustomScopeConfigurer customScopes() { final CustomScopeConfigurer configurer = new CustomScopeConfigurer(); final Map<String, Object> scopes = new HashMap<String, Object>(); scopes.put("foobarScope", new SimpleThreadScope()); configurer.setScopes(scopes); return configurer; }
@Override protected void onRefresh() { super.onRefresh(); Map beansOfType = getBeansOfType(CustomScopeConfigurer.class); if (!beansOfType.isEmpty()) { return; } addCustomScopeConfigurerBean(); }
private void addCustomScopeConfigurerBean() { AutowireCapableBeanFactory autowireCapableBeanFactory = getAutowireCapableBeanFactory(); CustomScopeConfigurer customScopeConfigurer = (CustomScopeConfigurer) autowireCapableBeanFactory.createBean(CustomScopeConfigurer.class); HashMap map = new HashMap(); map.put(RequestManager.SESSION, SessionScope.class); map.put(RequestManager.REQUEST, RequestScope.class); customScopeConfigurer.setScopes(map); autowireCapableBeanFactory.initializeBean(customScopeConfigurer, SCOPE_CONFIGURER); }
@Bean CustomScopeConfigurer getCustomScopeConfigurer() { CustomScopeConfigurer cf = new CustomScopeConfigurer(); cf.addScope("request", new org.springframework.web.context.request.RequestScope()); return cf; }
@Bean public static CustomScopeConfigurer webSocketScopeConfigurer() { CustomScopeConfigurer configurer = new CustomScopeConfigurer(); configurer.addScope("websocket", new SimpSessionScope()); return configurer; }
@Override public BeanDefinition parse(Element element, ParserContext context) { Object source = context.extractSource(element); CompositeComponentDefinition compDefinition = new CompositeComponentDefinition(element.getTagName(), source); context.pushContainingComponent(compDefinition); Element channelElem = DomUtils.getChildElementByTagName(element, "client-inbound-channel"); RuntimeBeanReference inChannel = getMessageChannel("clientInboundChannel", channelElem, context, source); channelElem = DomUtils.getChildElementByTagName(element, "client-outbound-channel"); RuntimeBeanReference outChannel = getMessageChannel("clientOutboundChannel", channelElem, context, source); channelElem = DomUtils.getChildElementByTagName(element, "broker-channel"); RuntimeBeanReference brokerChannel = getMessageChannel("brokerChannel", channelElem, context, source); RuntimeBeanReference userRegistry = registerUserRegistry(element, context, source); Object userDestHandler = registerUserDestHandler(element, userRegistry, inChannel, brokerChannel, context, source); RuntimeBeanReference converter = registerMessageConverter(element, context, source); RuntimeBeanReference template = registerMessagingTemplate(element, brokerChannel, converter, context, source); registerAnnotationMethodMessageHandler(element, inChannel, outChannel,converter, template, context, source); RootBeanDefinition broker = registerMessageBroker(element, inChannel, outChannel, brokerChannel, userDestHandler, template, userRegistry, context, source); // WebSocket and sub-protocol handling ManagedMap<String, Object> urlMap = registerHandlerMapping(element, context, source); RuntimeBeanReference stompHandler = registerStompHandler(element, inChannel, outChannel, context, source); for (Element endpointElem : DomUtils.getChildElementsByTagName(element, "stomp-endpoint")) { RuntimeBeanReference requestHandler = registerRequestHandler(endpointElem, stompHandler, context, source); String pathAttribute = endpointElem.getAttribute("path"); Assert.state(StringUtils.hasText(pathAttribute), "Invalid <stomp-endpoint> (no path mapping)"); List<String> paths = Arrays.asList(StringUtils.tokenizeToStringArray(pathAttribute, ",")); for (String path : paths) { path = path.trim(); Assert.state(StringUtils.hasText(path), "Invalid <stomp-endpoint> path attribute: " + pathAttribute); if (DomUtils.getChildElementByTagName(endpointElem, "sockjs") != null) { path = path.endsWith("/") ? path + "**" : path + "/**"; } urlMap.put(path, requestHandler); } } Map<String, Object> scopeMap = Collections.<String, Object>singletonMap("websocket", new SimpSessionScope()); RootBeanDefinition scopeConfigurer = new RootBeanDefinition(CustomScopeConfigurer.class); scopeConfigurer.getPropertyValues().add("scopes", scopeMap); registerBeanDefByName("webSocketScopeConfigurer", scopeConfigurer, context, source); registerWebSocketMessageBrokerStats(broker, inChannel, outChannel, context, source); context.popAndRegisterContainingComponent(); return null; }
@Bean public static CustomScopeConfigurer viewScopeConfigurer() { CustomScopeConfigurer customScopeConfigurer = new CustomScopeConfigurer(); customScopeConfigurer.addScope(ViewScope.SCOPE_VIEW, new ViewScope()); return customScopeConfigurer; }
@Bean public static CustomScopeConfigurer configureTenantScope() { CustomScopeConfigurer customScopeConfigurer = new CustomScopeConfigurer(); customScopeConfigurer.addScope(TenantScope.SCOPE_NAME, new TenantScope()); return customScopeConfigurer; }
@Bean(name = "customScopeConfigurer") public static CustomScopeConfigurer createClientScope() { final CustomScopeConfigurer configurer = new CustomScopeConfigurer(); configurer.addScope(ClientScopeImpl.CLIENT_SCOPE, new ClientScopeImpl()); return configurer; }
@Bean public static CustomScopeConfigurer scopeConfigurer() { return new SimpleThreadScopeConfigurer(); }