Browse Source

Register classes as Spring services, deprecate instance attribute

autowiring
Signed-off-by: Pekka Helenius <fincer89@hotmail.com>
v0.0.3-alpha
Pekka Helenius 4 years ago
parent
commit
a9f35eb743
5 changed files with 13 additions and 28 deletions
  1. +2
    -2
      bookstore/src/main/java/com/fjordtek/bookstore/service/BookAuthorHelper.java
  2. +2
    -0
      bookstore/src/main/java/com/fjordtek/bookstore/service/HttpServerLogger.java
  3. +4
    -13
      bookstore/src/main/java/com/fjordtek/bookstore/web/BookBasePathAwareController.java
  4. +3
    -12
      bookstore/src/main/java/com/fjordtek/bookstore/web/BookController.java
  5. +2
    -1
      bookstore/src/main/java/com/fjordtek/bookstore/web/BookRestController.java

+ 2
- 2
bookstore/src/main/java/com/fjordtek/bookstore/service/BookAuthorHelper.java View File

@ -3,7 +3,7 @@
package com.fjordtek.bookstore.service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;
import com.fjordtek.bookstore.model.book.Author;
import com.fjordtek.bookstore.model.book.AuthorRepository;
@ -21,7 +21,7 @@ import com.fjordtek.bookstore.model.book.Book;
* @author Pekka Helenius
*/
@Component
@Service
public class BookAuthorHelper {
@Autowired


+ 2
- 0
bookstore/src/main/java/com/fjordtek/bookstore/service/HttpServerLogger.java View File

@ -11,6 +11,7 @@ import javax.servlet.http.HttpServletResponse;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;
/**
*
@ -19,6 +20,7 @@ import org.slf4j.LoggerFactory;
* @author Pekka Helenius
*/
@Service
public class HttpServerLogger {
private static final Logger serverLogger = LoggerFactory.getLogger(HttpServerLogger.class);


+ 4
- 13
bookstore/src/main/java/com/fjordtek/bookstore/web/BookBasePathAwareController.java View File

@ -47,23 +47,14 @@ public class BookBasePathAwareController {
@Autowired
private CategoryRepository categoryRepository;
@Autowired
private BookAuthorHelper bookAuthorHelper;
private BookEventHandler bookEventHandler;
private HttpServerLogger httpServerLogger = new HttpServerLogger();
@Autowired
private BookEventHandler bookEventHandler;
/*
* This method MUST exist with Autowired annotation. Handles autowiring of external classes.
* If this method is not defined, they are not found by this controller class (are null).
*/
@Autowired
private void instanceAttributeController(
BookAuthorHelper bookAuthorHelper,
BookEventHandler bookEventHandler
) {
this.bookAuthorHelper = bookAuthorHelper;
this.bookEventHandler = bookEventHandler;
}
private HttpServerLogger httpServerLogger;
//////////////////////////////
private void bookGetAndSetNestedJSON(Book book, JsonNode bookNode) {


+ 3
- 12
bookstore/src/main/java/com/fjordtek/bookstore/web/BookController.java View File

@ -75,20 +75,11 @@ public class BookController {
@Autowired
private BookHashRepository bookHashRepository;
private BookAuthorHelper bookAuthorHelper;
/*
* This method MUST exist with Autowired annotation. Handles autowiring of external classes.
* If this method is not defined, they are not found by this controller class (are null).
*/
@Autowired
private void instanceAttributeController(
BookAuthorHelper bookAuthorHelper
) {
this.bookAuthorHelper = bookAuthorHelper;
}
private HttpServerLogger httpServerLogger;
private HttpServerLogger httpServerLogger = new HttpServerLogger();
@Autowired
private BookAuthorHelper bookAuthorHelper;
/*
private Map<String,String> globalModelMap = new HashMap<String,String>() {


+ 2
- 1
bookstore/src/main/java/com/fjordtek/bookstore/web/BookRestController.java View File

@ -49,7 +49,8 @@ public class BookRestController {
private CategoryRepository categoryRepository;
*/
private HttpServerLogger httpServerLogger = new HttpServerLogger();
@Autowired
private HttpServerLogger httpServerLogger;
@RequestMapping(
value = "${page.url.json.list}",


Loading…
Cancel
Save