Skip to content

Commit ad0cd72

Browse files
iaforekpedja4
authored andcommitted
BAEL-434 Spring Roo (eugenp#1589)
* Code for Dependency Injection Article. * Added Java based configuration. Downloaded formatter.xml and reformatted all changed files. Manually changed tab into 4 spaces in XML configuration files. * BAEL-434 - Spring Roo project files generated by Spring Roo. No formatting applied. Added POM, java and resources folders.
1 parent 2dfd789 commit ad0cd72

114 files changed

Lines changed: 15965 additions & 52 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

‎roo/pom.xml‎

Lines changed: 644 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.baeldung;
2+
3+
import org.springframework.boot.SpringApplication;
4+
import org.springframework.boot.autoconfigure.SpringBootApplication;
5+
6+
/**
7+
* = RooApplication
8+
*
9+
* TODO Auto-generated class documentation
10+
*
11+
*/
12+
@SpringBootApplication
13+
public class RooApplication {
14+
15+
/**
16+
* TODO Auto-generated method documentation
17+
*
18+
* @param args
19+
*/
20+
public static void main(String[] args) {
21+
SpringApplication.run(RooApplication.class, args);
22+
}
23+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.baeldung.config;
2+
import org.springframework.roo.addon.layers.repository.jpa.annotations.RooJpaRepositoryConfiguration;
3+
4+
/**
5+
* = SpringDataJpaDetachableRepositoryConfiguration
6+
TODO Auto-generated class documentation
7+
*
8+
*/
9+
@RooJpaRepositoryConfiguration
10+
public class SpringDataJpaDetachableRepositoryConfiguration {
11+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// WARNING: DO NOT EDIT THIS FILE. THIS FILE IS MANAGED BY SPRING ROO.
2+
// You may push code into the target .java compilation unit if you wish to edit any member(s).
3+
4+
package com.baeldung.config;
5+
6+
import com.baeldung.RooApplication;
7+
import com.baeldung.config.SpringDataJpaDetachableRepositoryConfiguration;
8+
import io.springlets.data.jpa.repository.support.DetachableJpaRepositoryImpl;
9+
import org.springframework.context.annotation.Configuration;
10+
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
11+
12+
privileged aspect SpringDataJpaDetachableRepositoryConfiguration_Roo_Jpa_Repository_Configuration {
13+
14+
declare @type: SpringDataJpaDetachableRepositoryConfiguration: @Configuration;
15+
16+
declare @type: SpringDataJpaDetachableRepositoryConfiguration: @EnableJpaRepositories(repositoryBaseClass = DetachableJpaRepositoryImpl.class, basePackageClasses = RooApplication.class);
17+
18+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.baeldung.config;
2+
import org.springframework.roo.addon.web.mvc.controller.annotations.config.RooWebMvcConfiguration;
3+
import org.springframework.roo.addon.web.mvc.thymeleaf.annotations.RooWebMvcThymeleafUIConfiguration;
4+
5+
/**
6+
* = WebMvcConfiguration
7+
TODO Auto-generated class documentation
8+
*
9+
*/
10+
@RooWebMvcConfiguration(defaultLanguage = "en")
11+
@RooWebMvcThymeleafUIConfiguration
12+
public class WebMvcConfiguration {
13+
}
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
// WARNING: DO NOT EDIT THIS FILE. THIS FILE IS MANAGED BY SPRING ROO.
2+
// You may push code into the target .java compilation unit if you wish to edit any member(s).
3+
4+
package com.baeldung.config;
5+
6+
import com.baeldung.config.WebMvcConfiguration;
7+
import org.springframework.beans.factory.annotation.Autowired;
8+
import org.springframework.boot.autoconfigure.thymeleaf.ThymeleafProperties;
9+
import org.springframework.context.ApplicationContext;
10+
import org.springframework.context.ApplicationContextAware;
11+
import org.springframework.context.annotation.Bean;
12+
import org.thymeleaf.TemplateEngine;
13+
import org.thymeleaf.spring4.templateresolver.SpringResourceTemplateResolver;
14+
import org.thymeleaf.spring4.view.ThymeleafViewResolver;
15+
import org.thymeleaf.templatemode.TemplateMode;
16+
17+
privileged aspect WebMvcConfiguration_Roo_ThymeleafUIConfiguration {
18+
19+
declare parents: WebMvcConfiguration implements ApplicationContextAware;
20+
21+
/**
22+
* TODO Auto-generated attribute documentation
23+
*
24+
*/
25+
@Autowired
26+
private ThymeleafProperties WebMvcConfiguration.thymeleafProperties;
27+
28+
/**
29+
* TODO Auto-generated attribute documentation
30+
*
31+
*/
32+
@Autowired
33+
private TemplateEngine WebMvcConfiguration.templateEngine;
34+
35+
/**
36+
* TODO Auto-generated attribute documentation
37+
*
38+
*/
39+
private ApplicationContext WebMvcConfiguration.applicationContext;
40+
41+
/**
42+
* TODO Auto-generated method documentation
43+
*
44+
* @return ThymeleafProperties
45+
*/
46+
public ThymeleafProperties WebMvcConfiguration.getThymeleafProperties() {
47+
return thymeleafProperties;
48+
}
49+
50+
/**
51+
* TODO Auto-generated method documentation
52+
*
53+
* @return TemplateEngine
54+
*/
55+
public TemplateEngine WebMvcConfiguration.getTemplateEngine() {
56+
return templateEngine;
57+
}
58+
59+
/**
60+
* TODO Auto-generated method documentation
61+
*
62+
* @return ApplicationContext
63+
*/
64+
public ApplicationContext WebMvcConfiguration.getApplicationContext() {
65+
return applicationContext;
66+
}
67+
68+
/**
69+
* TODO Auto-generated method documentation
70+
*
71+
* @param applicationContext
72+
*/
73+
public void WebMvcConfiguration.setApplicationContext(ApplicationContext applicationContext) {
74+
this.applicationContext = applicationContext;
75+
}
76+
77+
/**
78+
* TODO Auto-generated method documentation
79+
*
80+
* @return ThymeleafViewResolver
81+
*/
82+
@Bean
83+
public ThymeleafViewResolver WebMvcConfiguration.javascriptThymeleafViewResolver() {
84+
ThymeleafViewResolver resolver = new ThymeleafViewResolver();
85+
resolver.setTemplateEngine(getTemplateEngine());
86+
resolver.setCharacterEncoding("UTF-8");
87+
resolver.setContentType("application/javascript");
88+
resolver.setViewNames(new String[] {"*.js"});
89+
resolver.setCache(getThymeleafProperties().isCache());
90+
return resolver;
91+
}
92+
93+
/**
94+
* TODO Auto-generated method documentation
95+
*
96+
* @return SpringResourceTemplateResolver
97+
*/
98+
@Bean
99+
public SpringResourceTemplateResolver WebMvcConfiguration.javascriptTemplateResolver() {
100+
SpringResourceTemplateResolver resolver = new SpringResourceTemplateResolver();
101+
resolver.setApplicationContext(getApplicationContext());
102+
resolver.setPrefix("classpath:/templates/fragments/js/");
103+
resolver.setTemplateMode(TemplateMode.JAVASCRIPT);
104+
resolver.setCharacterEncoding("UTF-8");
105+
resolver.setCheckExistence(true);
106+
resolver.setCacheable(getThymeleafProperties().isCache());
107+
return resolver;
108+
}
109+
110+
}
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
// WARNING: DO NOT EDIT THIS FILE. THIS FILE IS MANAGED BY SPRING ROO.
2+
// You may push code into the target .java compilation unit if you wish to edit any member(s).
3+
4+
package com.baeldung.config;
5+
6+
import com.baeldung.config.WebMvcConfiguration;
7+
import io.tracee.binding.springmvc.TraceeInterceptor;
8+
import java.lang.Override;
9+
import java.util.Locale;
10+
import org.springframework.context.annotation.Bean;
11+
import org.springframework.context.annotation.Configuration;
12+
import org.springframework.context.annotation.Primary;
13+
import org.springframework.validation.beanvalidation.LocalValidatorFactoryBean;
14+
import org.springframework.web.servlet.LocaleResolver;
15+
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
16+
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter;
17+
import org.springframework.web.servlet.i18n.LocaleChangeInterceptor;
18+
import org.springframework.web.servlet.i18n.SessionLocaleResolver;
19+
20+
privileged aspect WebMvcConfiguration_Roo_WebMvcConfiguration {
21+
22+
declare parents: WebMvcConfiguration extends WebMvcConfigurerAdapter;
23+
24+
declare @type: WebMvcConfiguration: @Configuration;
25+
26+
/**
27+
* TODO Auto-generated method documentation
28+
*
29+
* @return LocalValidatorFactoryBean
30+
*/
31+
@Primary
32+
@Bean
33+
public LocalValidatorFactoryBean WebMvcConfiguration.validator() {
34+
return new LocalValidatorFactoryBean();
35+
}
36+
37+
/**
38+
* TODO Auto-generated method documentation
39+
*
40+
* @return LocaleResolver
41+
*/
42+
@Bean
43+
public LocaleResolver WebMvcConfiguration.localeResolver() {
44+
SessionLocaleResolver localeResolver = new SessionLocaleResolver();
45+
localeResolver.setDefaultLocale(new Locale("en"));
46+
return localeResolver;
47+
}
48+
49+
/**
50+
* TODO Auto-generated method documentation
51+
*
52+
* @return LocaleChangeInterceptor
53+
*/
54+
@Bean
55+
public LocaleChangeInterceptor WebMvcConfiguration.localeChangeInterceptor() {
56+
LocaleChangeInterceptor localeChangeInterceptor = new LocaleChangeInterceptor();
57+
localeChangeInterceptor.setParamName("lang");
58+
return localeChangeInterceptor;
59+
}
60+
61+
/**
62+
* TODO Auto-generated method documentation
63+
*
64+
* @param registry
65+
*/
66+
@Override
67+
public void WebMvcConfiguration.addInterceptors(InterceptorRegistry registry) {
68+
registry.addInterceptor(localeChangeInterceptor());
69+
registry.addInterceptor(new TraceeInterceptor());
70+
}
71+
72+
}
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
package com.baeldung.config.jackson;
2+
import org.springframework.roo.addon.web.mvc.controller.annotations.config.RooDomainModelModule;
3+
4+
/**
5+
* = DomainModelModule
6+
TODO Auto-generated class documentation
7+
*
8+
*/
9+
@RooDomainModelModule
10+
public class DomainModelModule {
11+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// WARNING: DO NOT EDIT THIS FILE. THIS FILE IS MANAGED BY SPRING ROO.
2+
// You may push code into the target .java compilation unit if you wish to edit any member(s).
3+
4+
package com.baeldung.config.jackson;
5+
6+
import com.baeldung.config.jackson.DomainModelModule;
7+
import com.baeldung.domain.Book;
8+
import com.baeldung.web.BookJsonMixin;
9+
import com.fasterxml.jackson.databind.module.SimpleModule;
10+
import org.springframework.boot.jackson.JsonComponent;
11+
12+
privileged aspect DomainModelModule_Roo_DomainModelModule {
13+
14+
declare parents: DomainModelModule extends SimpleModule;
15+
16+
declare @type: DomainModelModule: @JsonComponent;
17+
18+
/**
19+
* TODO Auto-generated constructor documentation
20+
*
21+
*/
22+
public DomainModelModule.new() {
23+
// Mixin registration
24+
25+
setMixInAnnotation(Book.class, BookJsonMixin.class);
26+
}
27+
28+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package com.baeldung.domain;
2+
import org.springframework.roo.addon.javabean.annotations.RooEquals;
3+
import org.springframework.roo.addon.javabean.annotations.RooJavaBean;
4+
import org.springframework.roo.addon.javabean.annotations.RooToString;
5+
import org.springframework.roo.addon.jpa.annotations.entity.RooJpaEntity;
6+
import javax.persistence.GeneratedValue;
7+
import javax.persistence.GenerationType;
8+
import javax.persistence.Id;
9+
import javax.persistence.Version;
10+
import javax.validation.constraints.NotNull;
11+
12+
/**
13+
* = Book
14+
TODO Auto-generated class documentation
15+
*
16+
*/
17+
@RooJavaBean
18+
@RooToString
19+
@RooJpaEntity
20+
@RooEquals(isJpaEntity = true)
21+
public class Book {
22+
23+
/**
24+
* TODO Auto-generated attribute documentation
25+
*
26+
*/
27+
@Id
28+
@GeneratedValue(strategy = GenerationType.AUTO)
29+
private Long id;
30+
31+
/**
32+
* TODO Auto-generated attribute documentation
33+
*
34+
*/
35+
@Version
36+
private Integer version;
37+
38+
/**
39+
* TODO Auto-generated attribute documentation
40+
*
41+
*/
42+
@NotNull
43+
private String title;
44+
45+
/**
46+
* TODO Auto-generated attribute documentation
47+
*
48+
*/
49+
@NotNull
50+
private String author;
51+
52+
/**
53+
* TODO Auto-generated attribute documentation
54+
*
55+
*/
56+
@NotNull
57+
private String isbn;
58+
}

0 commit comments

Comments
 (0)