forked from cer/event-sourcing-examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'observable' of https://github.com/rstoyanchev/event-sou…
…rcing-examples into rstoyanchev-observable
- Loading branch information
Showing
8 changed files
with
119 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 23 additions & 1 deletion
24
...re/javaexamples/banking/web/commandside/accounts/CommandSideWebAccountsConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,35 @@ | ||
package net.chrisrichardson.eventstore.javaexamples.banking.web.commandside.accounts; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import javax.annotation.PostConstruct; | ||
|
||
import net.chrisrichardson.eventstore.javaexamples.banking.backend.commandside.accounts.AccountConfiguration; | ||
import net.chrisrichardson.eventstore.javaexamples.banking.web.util.ObservableReturnValueHandler; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.context.annotation.ComponentScan; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Import; | ||
import org.springframework.web.method.support.HandlerMethodReturnValueHandler; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; | ||
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter; | ||
|
||
@Configuration | ||
@Import({AccountConfiguration.class}) | ||
@ComponentScan | ||
public class CommandSideWebAccountsConfiguration { | ||
public class CommandSideWebAccountsConfiguration extends WebMvcConfigurerAdapter { | ||
|
||
@Autowired | ||
private RequestMappingHandlerAdapter adapter; | ||
|
||
@PostConstruct | ||
public void init() { | ||
// https://jira.spring.io/browse/SPR-13083 | ||
List<HandlerMethodReturnValueHandler> handlers = new ArrayList<HandlerMethodReturnValueHandler>(adapter.getReturnValueHandlers()); | ||
handlers.add(0, new ObservableReturnValueHandler()); | ||
adapter.setReturnValueHandlers(handlers); | ||
} | ||
|
||
} |
25 changes: 24 additions & 1 deletion
25
...isrichardson/eventstore/javaexamples/banking/web/queryside/QuerySideWebConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,35 @@ | ||
package net.chrisrichardson.eventstore.javaexamples.banking.web.queryside; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import javax.annotation.PostConstruct; | ||
|
||
import net.chrisrichardson.eventstore.javaexamples.banking.backend.queryside.accounts.QuerySideAccountConfiguration; | ||
import net.chrisrichardson.eventstore.javaexamples.banking.web.util.ObservableReturnValueHandler; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.context.annotation.ComponentScan; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Import; | ||
import org.springframework.web.method.support.HandlerMethodReturnValueHandler; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; | ||
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter; | ||
|
||
@Configuration | ||
@Import({QuerySideAccountConfiguration.class}) | ||
@ComponentScan | ||
public class QuerySideWebConfiguration { | ||
public class QuerySideWebConfiguration extends WebMvcConfigurerAdapter { | ||
|
||
@Autowired | ||
private RequestMappingHandlerAdapter adapter; | ||
|
||
@PostConstruct | ||
public void init() { | ||
// https://jira.spring.io/browse/SPR-13083 | ||
List<HandlerMethodReturnValueHandler> handlers = new ArrayList<HandlerMethodReturnValueHandler>(adapter.getReturnValueHandlers()); | ||
handlers.add(0, new ObservableReturnValueHandler()); | ||
adapter.setReturnValueHandlers(handlers); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
...hrisrichardson/eventstore/javaexamples/banking/web/util/ObservableReturnValueHandler.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
package net.chrisrichardson.eventstore.javaexamples.banking.web.util; | ||
|
||
import rx.Observable; | ||
|
||
import org.springframework.core.MethodParameter; | ||
import org.springframework.web.context.request.NativeWebRequest; | ||
import org.springframework.web.context.request.async.DeferredResult; | ||
import org.springframework.web.context.request.async.WebAsyncUtils; | ||
import org.springframework.web.method.support.HandlerMethodReturnValueHandler; | ||
import org.springframework.web.method.support.ModelAndViewContainer; | ||
|
||
|
||
public class ObservableReturnValueHandler implements HandlerMethodReturnValueHandler { | ||
|
||
@Override | ||
public boolean supportsReturnType(MethodParameter returnType) { | ||
return Observable.class.equals(returnType.getParameterType()); | ||
} | ||
|
||
@Override | ||
public void handleReturnValue(Object returnValue, MethodParameter returnType, ModelAndViewContainer mavContainer, | ||
NativeWebRequest webRequest) throws Exception { | ||
|
||
if (returnValue == null) { | ||
return; | ||
} | ||
DeferredResult<?> d = DeferredUtils.toDeferredResult((Observable<?>) returnValue); | ||
WebAsyncUtils.getAsyncManager(webRequest).startDeferredResultProcessing(d, mavContainer); | ||
} | ||
|
||
} |
24 changes: 23 additions & 1 deletion
24
...xamples/banking/web/commandside/transactions/CommandSideWebTransactionsConfiguration.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,35 @@ | ||
package net.chrisrichardson.eventstore.javaexamples.banking.web.commandside.transactions; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import javax.annotation.PostConstruct; | ||
|
||
import net.chrisrichardson.eventstore.javaexamples.banking.backend.commandside.transactions.MoneyTransferConfiguration; | ||
import net.chrisrichardson.eventstore.javaexamples.banking.web.util.ObservableReturnValueHandler; | ||
|
||
import org.springframework.beans.factory.annotation.Autowired; | ||
import org.springframework.context.annotation.ComponentScan; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.context.annotation.Import; | ||
import org.springframework.web.method.support.HandlerMethodReturnValueHandler; | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; | ||
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter; | ||
|
||
@Configuration | ||
@Import({MoneyTransferConfiguration.class}) | ||
@ComponentScan | ||
public class CommandSideWebTransactionsConfiguration { | ||
public class CommandSideWebTransactionsConfiguration extends WebMvcConfigurerAdapter { | ||
|
||
@Autowired | ||
private RequestMappingHandlerAdapter adapter; | ||
|
||
@PostConstruct | ||
public void init() { | ||
// https://jira.spring.io/browse/SPR-13083 | ||
List<HandlerMethodReturnValueHandler> handlers = new ArrayList<HandlerMethodReturnValueHandler>(adapter.getReturnValueHandlers()); | ||
handlers.add(0, new ObservableReturnValueHandler()); | ||
adapter.setReturnValueHandlers(handlers); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters