2 * ================================================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ================================================================================
20 package org.openecomp.portalapp.conf;
22 import java.util.ArrayList;
23 import java.util.List;
25 import org.openecomp.portalapp.scheduler.RegistryAdapter;
26 import org.openecomp.portalapp.uebhandler.InitUebHandler;
27 import org.openecomp.portalapp.uebhandler.MainUebHandler;
28 import org.openecomp.portalapp.uebhandler.WidgetNotificationHandler;
29 import org.openecomp.portalsdk.core.conf.AppConfig;
30 import org.openecomp.portalsdk.core.conf.Configurable;
31 import org.openecomp.portalsdk.core.objectcache.AbstractCacheManager;
32 import org.openecomp.portalsdk.core.service.DataAccessService;
33 import org.openecomp.portalsdk.core.util.CacheManager;
34 import org.openecomp.portalsdk.core.util.SystemProperties;
35 import org.springframework.beans.factory.annotation.Autowired;
36 import org.springframework.context.annotation.Bean;
37 import org.springframework.context.annotation.ComponentScan;
38 import org.springframework.context.annotation.Configuration;
39 import org.springframework.context.annotation.Import;
40 import org.springframework.context.annotation.Profile;
41 import org.springframework.context.annotation.PropertySource;
42 import org.springframework.scheduling.annotation.EnableAsync;
43 import org.springframework.scheduling.annotation.EnableScheduling;
44 import org.springframework.scheduling.quartz.SchedulerFactoryBean;
45 import org.springframework.web.servlet.ViewResolver;
46 import org.springframework.web.servlet.config.annotation.EnableWebMvc;
47 import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
48 import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
51 * Configures Spring features in the ECOMP Portal SDK sample application.
52 * Subclasses the ECOMP Portal SDK core AppConfig class to reuse interceptors,
53 * view resolvers and other features defined there.
57 @ComponentScan(basePackages = "org.openecomp")
58 @PropertySource(value = { "${container.classpath:}/WEB-INF/conf/app/test.properties" }, ignoreResourceNotFound = true)
62 public class ExternalAppConfig extends AppConfig implements Configurable {
64 private RegistryAdapter schedulerRegistryAdapter;
67 @Import(SystemProperties.class)
68 static class InnerConfiguration {
72 * @see org.openecomp.portalsdk.core.conf.AppConfig#viewResolver()
74 public ViewResolver viewResolver() {
75 return super.viewResolver();
79 * @see org.openecomp.portalsdk.core.conf.AppConfig#addResourceHandlers(ResourceHandlerRegistry)
83 public void addResourceHandlers(ResourceHandlerRegistry registry) {
84 super.addResourceHandlers(registry);
88 * @see org.openecomp.portalsdk.core.conf.AppConfig#dataAccessService()
90 public DataAccessService dataAccessService() {
91 return super.dataAccessService();
95 * Creates a new list with a single entry that is the external app
96 * definitions.xml path.
98 * @return List of String, size 1
100 public List<String> addTileDefinitions() {
101 List<String> definitions = new ArrayList<String>();
102 definitions.add("/WEB-INF/defs/definitions.xml");
107 * Adds request interceptors to the specified registry by calling
108 * {@link AppConfig#addInterceptors(InterceptorRegistry)}, but excludes
109 * certain paths from the session timeout interceptor.
112 public void addInterceptors(InterceptorRegistry registry) {
113 super.setExcludeUrlPathsForSessionTimeout("/login_external", "*/login_external.htm", "login", "/login.htm",
114 "/api*","/single_signon.htm","/single_signon");
115 super.addInterceptors(registry);
119 * Creates and returns a new instance of a {@link CacheManager} class.
121 * @return New instance of {@link CacheManager}
124 public AbstractCacheManager cacheManager() {
125 return new CacheManager();
129 * Creates and returns a new instance of a {@link MainUebHandler}.
131 * @return New instance of {@link MainUebHandler}.
134 public MainUebHandler mainUebHandler() {
136 return new MainUebHandler();
140 * Creates and returns a new instance of a {@link InitUebHandler}.
142 * @return New instance of {@link InitUebHandler}.
145 public InitUebHandler initUebHandler() {
147 return new InitUebHandler();
151 * Creates and returns a new instance of a {@link WidgetNotificationHandler}
154 * @return New instance of {@link WidgetNotificationHandler}.
157 public WidgetNotificationHandler widgetNotificationHandler() {
158 return new WidgetNotificationHandler();
162 * Creates and returns a new instance of a {@link SchedulerFactoryBean} and
163 * populates it with triggers.
165 * @return New instance of {@link SchedulerFactoryBean}
168 // @Bean // ANNOTATION COMMENTED OUT
169 // APPLICATIONS REQUIRING QUARTZ SHOULD RESTORE ANNOTATION
170 public SchedulerFactoryBean schedulerFactoryBean() throws Exception {
171 SchedulerFactoryBean scheduler = new SchedulerFactoryBean();
172 scheduler.setTriggers(schedulerRegistryAdapter.getTriggers());
173 scheduler.setConfigLocation(appApplicationContext.getResource("WEB-INF/conf/quartz.properties"));
174 scheduler.setDataSource(dataSource());
180 * Sets the scheduler registry adapter.
182 * @param schedulerRegistryAdapter
185 public void setSchedulerRegistryAdapter(final RegistryAdapter schedulerRegistryAdapter) {
186 this.schedulerRegistryAdapter = schedulerRegistryAdapter;