mirror of
https://bitbucket.org/wisemapping/wisemapping-open-source.git
synced 2024-11-21 05:37:57 +01:00
Refactor beens loading.
This commit is contained in:
parent
a739bb3e0b
commit
479eb6db2c
@ -2,11 +2,11 @@ package com.wisemapping.config;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
import org.springframework.context.annotation.ImportResource;
|
||||
import org.springframework.transaction.TransactionManager;
|
||||
import org.springframework.transaction.annotation.EnableTransactionManagement;
|
||||
import org.springframework.transaction.interceptor.TransactionAttributeSource;
|
||||
import org.springframework.transaction.interceptor.TransactionInterceptor;
|
||||
import org.springframework.web.servlet.HandlerExceptionResolver;
|
||||
import org.springframework.web.servlet.ViewResolver;
|
||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||
@ -17,7 +17,9 @@ import org.springframework.web.servlet.view.JstlView;
|
||||
@EnableWebMvc
|
||||
@Configuration
|
||||
@EnableTransactionManagement
|
||||
public class AppConfig {
|
||||
@ComponentScan
|
||||
@ImportResource("classpath:spring/wisemapping-common.xml")
|
||||
public class Application {
|
||||
|
||||
@Autowired
|
||||
TransactionManager txManager;
|
@ -1,68 +0,0 @@
|
||||
/*
|
||||
* Copyright [2022] [wisemapping]
|
||||
*
|
||||
* Licensed under WiseMapping Public License, Version 1.0 (the "License").
|
||||
* It is basically the Apache License, Version 2.0 (the "License") plus the
|
||||
* "powered by wisemapping" text requirement on every single page;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the license at
|
||||
*
|
||||
* http://www.wisemapping.org/license
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package com.wisemapping.rest;
|
||||
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.http.HttpInputMessage;
|
||||
import org.springframework.http.converter.HttpMessageNotReadableException;
|
||||
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
|
||||
|
||||
public class DebugMappingJacksonHttpMessageConverter extends MappingJackson2HttpMessageConverter {
|
||||
|
||||
@Override
|
||||
protected Object readInternal(Class<?> clazz, HttpInputMessage inputMessage) throws JsonHttpMessageNotReadableException {
|
||||
try {
|
||||
final byte[] bytes = IOUtils.toByteArray(inputMessage.getBody());
|
||||
final ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
|
||||
final WrapHttpInputMessage wrap = new WrapHttpInputMessage(bais, inputMessage.getHeaders());
|
||||
|
||||
return super.readInternal(clazz, wrap);
|
||||
|
||||
} catch (HttpMessageNotReadableException | IOException e) {
|
||||
throw new JsonHttpMessageNotReadableException("Request Body could not be read", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class WrapHttpInputMessage implements HttpInputMessage {
|
||||
private final InputStream body;
|
||||
private final HttpHeaders headers;
|
||||
|
||||
WrapHttpInputMessage(InputStream is, HttpHeaders headers) {
|
||||
this.body = is;
|
||||
this.headers = headers;
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getBody() {
|
||||
return body;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HttpHeaders getHeaders() {
|
||||
return headers;
|
||||
}
|
||||
}
|
@ -23,13 +23,16 @@ import com.wisemapping.model.User;
|
||||
import com.wisemapping.service.UserService;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.security.core.userdetails.UsernameNotFoundException;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
|
||||
@Service
|
||||
public class UserDetailsService
|
||||
implements org.springframework.security.core.userdetails.UserDetailsService {
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
private String adminUser;
|
||||
|
||||
|
20
wise-webapp/src/main/resources/spring/wisemapping-common.xml
Normal file
20
wise-webapp/src/main/resources/spring/wisemapping-common.xml
Normal file
@ -0,0 +1,20 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||||
http://www.springframework.org/schema/beans/spring-beans.xsd">
|
||||
|
||||
<!-- <bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">-->
|
||||
<!-- <property name="defaultEncoding" value="UTF-8"/>-->
|
||||
<!-- <property name="basenames">-->
|
||||
<!-- <list>-->
|
||||
<!-- <value>messages</value>-->
|
||||
<!-- </list>-->
|
||||
<!-- </property>-->
|
||||
<!-- </bean>-->
|
||||
|
||||
<import resource="wisemapping-datasource.xml"/>
|
||||
<import resource="wisemapping-dao.xml"/>
|
||||
<import resource="wisemapping-service.xml"/>
|
||||
<import resource="wisemapping-servlet.xml"/>
|
||||
</beans>
|
@ -13,11 +13,10 @@
|
||||
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
|
||||
|
||||
<context:component-scan base-package="com.wisemapping.rest"/>
|
||||
<context:annotation-config/>
|
||||
|
||||
<mvc:annotation-driven>
|
||||
<mvc:message-converters>
|
||||
<bean class="com.wisemapping.rest.DebugMappingJacksonHttpMessageConverter"/>
|
||||
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter"/>
|
||||
<bean class="org.springframework.http.converter.xml.Jaxb2RootElementHttpMessageConverter"/>
|
||||
</mvc:message-converters>
|
||||
</mvc:annotation-driven>
|
@ -33,5 +33,5 @@
|
||||
</property>
|
||||
</bean>
|
||||
|
||||
<import resource="wisemapping-security-${security.type}.xml"/>
|
||||
<import resource="wisemapping-security-${security.type:db}.xml"/>
|
||||
</beans>
|
@ -12,8 +12,6 @@
|
||||
http://www.springframework.org/schema/mvc/spring-mvc.xsd">
|
||||
|
||||
<context:component-scan base-package="com.wisemapping"/>
|
||||
<context:annotation-config/>
|
||||
<mvc:annotation-driven/>
|
||||
<context:property-placeholder location="/WEB-INF/app.properties" ignore-unresolvable="true"/>
|
||||
|
||||
<!-- Interceptors Registration -->
|
@ -24,10 +24,7 @@
|
||||
<context-param>
|
||||
<param-name>contextConfigLocation</param-name>
|
||||
<param-value>
|
||||
/WEB-INF/wisemapping-datasource.xml
|
||||
/WEB-INF/wisemapping-dao.xml
|
||||
/WEB-INF/wisemapping-service.xml
|
||||
/WEB-INF/wisemapping-servlet.xml
|
||||
classpath:spring/wisemapping-common.xml
|
||||
</param-value>
|
||||
</context-param>
|
||||
|
||||
@ -35,8 +32,7 @@
|
||||
<param-name>contextInitializerClasses</param-name>
|
||||
<param-value>com.wisemapping.webmvc.ApplicationContextInitializer</param-value>
|
||||
</context-param>
|
||||
|
||||
|
||||
|
||||
<!--
|
||||
- Loads the root application context of this web app at startup.
|
||||
- The application context is then available via
|
||||
@ -91,7 +87,7 @@
|
||||
<init-param>
|
||||
<param-name>contextConfigLocation</param-name>
|
||||
<param-value>
|
||||
/WEB-INF/wisemapping-servlet.xml
|
||||
classpath:spring/wisemapping-servlet.xml
|
||||
</param-value>
|
||||
</init-param>
|
||||
<load-on-startup>1</load-on-startup>
|
||||
@ -103,7 +99,7 @@
|
||||
<init-param>
|
||||
<param-name>contextConfigLocation</param-name>
|
||||
<param-value>
|
||||
/WEB-INF/wisemapping-rest.xml
|
||||
classpath:spring/wisemapping-rest.xml
|
||||
</param-value>
|
||||
</init-param>
|
||||
<load-on-startup>1</load-on-startup>
|
||||
|
Loading…
Reference in New Issue
Block a user