]> source.dussan.org Git - vaadin-framework.git/commit
Add fallback resolvers for CurrentInstance (#10974)
authorGilberto Torrezan <gilberto-torrezan@users.noreply.github.com>
Wed, 13 Jun 2018 07:08:04 +0000 (10:08 +0300)
committerIlia Motornyi <elmot@vaadin.com>
Wed, 13 Jun 2018 07:08:04 +0000 (10:08 +0300)
commit915df65bbb2d0ee6b744bae02e46ff9a73f6e1d0
treed60a478614d136f20793429e2374d7e7ab0958cd
parent539f9c0c77258b1dc4369648409749c058a6ff8d
Add fallback resolvers for CurrentInstance (#10974)

* Add fallback resolvers for CurrentInstance

This allow applications to inject custom default instances when the
current instances cannot be found by regular means.

For example, when VaadinServlet.getCurrent() would return null, a
fallback resolver could be invoked to properly create the servlet and
return it.

* Make the setting of CurrentInstanceFallbackResolvers protected

* Remove the default constructor. Improve test.

* Made setFallbackResolver public again

* Rename the method to defineFallbackResolver, and make it throw when a
type is used twice

* Make the method thread-safe

* Make the method thread-safe in a Java 6 way

* Thread safety with ConcurrentHashMap API instead of just Map

* Improve test with fake classes.

* Clear the test state after it has been run.
server/src/main/java/com/vaadin/util/CurrentInstance.java
server/src/main/java/com/vaadin/util/CurrentInstanceFallbackResolver.java [new file with mode: 0644]
server/src/test/java/com/vaadin/util/CurrentInstanceTest.java