postconstruct

Spring cache using @Cacheable during @PostConstruct does not work

一个人想着一个人 提交于 2019-11-30 09:49:29
related to the commit in spring framework https://github.com/spring-projects/spring-framework/commit/5aefcc802ef05abc51bbfbeb4a78b3032ff9eee3 the initialisation is set to a later stage from afterPropertiesSet() to afterSingletonsInstantiated() In short : This prevents the caching to work when using it in a @PostConstruct use case. Longer version : This prevents the use case where you would create serviceB with @Cacheable on a methodB create serviceA with @PostConstruct calling serviceB.methodB @Component public class ServiceA{ @Autowired private ServiceB serviceB; @PostConstruct public void

Spring cache using @Cacheable during @PostConstruct does not work

落花浮王杯 提交于 2019-11-29 14:55:21
问题 related to the commit in spring framework https://github.com/spring-projects/spring-framework/commit/5aefcc802ef05abc51bbfbeb4a78b3032ff9eee3 the initialisation is set to a later stage from afterPropertiesSet() to afterSingletonsInstantiated() In short : This prevents the caching to work when using it in a @PostConstruct use case. Longer version : This prevents the use case where you would create serviceB with @Cacheable on a methodB create serviceA with @PostConstruct calling serviceB

@PostConstruct didn't get called by JSF if ManagedBean is inside jar library

假装没事ソ 提交于 2019-11-29 04:42:00
I'm running with the following problem. I have a few Managed Beans that are shared between, at this moment, two JSF applications. As I don't want to copy and paste the code in the two (more in the coming future) I've put this shared managed beans inside a JAR library. I've followed this blog: http://jsflive.wordpress.com/2011/03/24/custom-component-library/ Well, even if I put the faces-config.xml inside JAR/META-INF/ the @ManagedBean and @ViewScoped didn't work. I couldn't realise why, but if I register the beans in faces-config.xml (JAR ones, not WAR ones) this problem goes away. I could

JSF bean: call @PostConstruct function after ViewParam is set

匆匆过客 提交于 2019-11-29 01:56:41
I have a product.xhtml and a ProductBean. I use /product/{id} to access the products so I have a viewParam in product.xhtml with value=ProductBean.id. The problem is that inside the bean I use an init function with a PostConstruct annotation in order to fill the details of the product. To do this I need the id to call an external function. I guess though that init is called before viewParam sets the id of the bean and therefore inside init I cannot call the external function because id is not set yet. What am I doing wrong and how do I fix this? UPDATE I found what was wrong. I think the

@PostConstruct & Checked exceptions

风流意气都作罢 提交于 2019-11-29 01:01:00
In the @PostConstruct doc it says about the annotated methods: "The method MUST NOT throw a checked exception." How would one deal with e.g. an IOException which can be thrown in such a method? Just wrap it in a RuntimeException and let the user worry about the faulty initial state of the object? Or is @PostConstruct the wrong place to validate and initialize objects which got their dependencies injected? Yes, wrap it in a runtime exception. Preferebly something more concrete like IllegalStateException . Note that if the init method fails, normally the application won't start. Generally, if

@PostConstruct method is called even if the ManagedBean has already been instantiated (e.g. on AJAX-calls) [duplicate]

孤人 提交于 2019-11-28 23:43:56
This question already has an answer here: @ViewScoped calls @PostConstruct on every postback request 1 answer I have a @ViewScope ManagedBean and a @PostConstruct initialisation method. This method is called when a new instance is created, but also on every ajax call. Why is this so? On an AJAX-call the init-Method is called and executed, but no changes are visible. For example if I change a property in the init-Method, this is only visible on instatiation and not for AJAX-calls. For AJAX-calls the value change is not persistent in the @ViewScoped Bean. Can anyone tell why this is so? How can

ViewScoped bean getting constructed on every request… part 99 [duplicate]

丶灬走出姿态 提交于 2019-11-28 05:09:11
问题 This question already has an answer here : @ViewScoped calls @PostConstruct on every postback request (1 answer) Closed 3 years ago . ARGH... This seems to have a hundred answers and I haven't found one that works for me, so I guess I will actually ask it again. Here is my scenario: My site technically has a single page whose contents get swapped out rather than having multiple pages that you navigate to. The starting point is this chunk: <?xml version="1.0" encoding="UTF-8"?> <f:view xmlns:f

JSF bean: call @PostConstruct function after ViewParam is set

烂漫一生 提交于 2019-11-27 21:45:43
问题 I have a product.xhtml and a ProductBean. I use /product/{id} to access the products so I have a viewParam in product.xhtml with value=ProductBean.id. The problem is that inside the bean I use an init function with a PostConstruct annotation in order to fill the details of the product. To do this I need the id to call an external function. I guess though that init is called before viewParam sets the id of the bean and therefore inside init I cannot call the external function because id is not

@PostConstruct & Checked exceptions

前提是你 提交于 2019-11-27 21:31:19
问题 In the @PostConstruct doc it says about the annotated methods: "The method MUST NOT throw a checked exception." How would one deal with e.g. an IOException which can be thrown in such a method? Just wrap it in a RuntimeException and let the user worry about the faulty initial state of the object? Or is @PostConstruct the wrong place to validate and initialize objects which got their dependencies injected? 回答1: Yes, wrap it in a runtime exception. Preferebly something more concrete like

@PostConstruct method called twice for the same request

梦想与她 提交于 2019-11-27 19:49:28
I'm using JSF 2.0 with GlassFish 3.0. I have the following Managed Bean: @ManagedBean @RequestScoped public class OverviewController{ private List<Event> eventList; @PostConstruct public void init(){ System.out.println("=> OverviewController - init() - enter"); System.out.println("=< OverviewController - init() - exit"); } } From the the overview.xhtml file I'm calling different attributes or methods from my OverviewController. <ui:repeat var="event" value="#{overviewController.eventList}"> ... </ui:repeat> Everything works just fine but the problem is on the Log File: INFO: Enter : RESTORE