javabeans

30 sec periodic task to poll external web service and cache data

五迷三道 提交于 2020-01-05 01:49:19
问题 I'm after some advice on polling an external web service every 30 secs from a Domino server side action. A quick bit of background... We track the location of cars thru the TomTom api. We now have a requirement to show this in our web app, overlayed onto a map (google, bing, etc.) and mashed up with other lat long data from our application. Think of it as dispatching calls to taxis and we want to assign those calls to the taxis (...it's not taxis\ calls, but it is similar process). We refresh

OpenCSV: Mapping a Nested Bean to a CSV file

流过昼夜 提交于 2020-01-05 01:41:09
问题 I am trying to map a bean to a CSV file but the problem that my bean has other nested beans as attributes. What happens is that OpenCSV goes through the attributes finds a bean then goes into it and maps all the data inside of that bean and if it finds another bean it goes on and on. How can I deal withe nested beans using OpenCSV? How can I ensure that it maps the correct attributes from the nested beans? 回答1: In OpenCSV 5.0, we can map nested bean by @CsvRecurse annotation without using

Spring Boot - Load bean only if it is enabled by a property

元气小坏坏 提交于 2020-01-04 14:35:14
问题 I have a Spring Boot application with different submodules which also contains spring components. And in the main web modules I use 70% of the beans from the submodules. It depends on the application.yml properties, if the property group (which points to a bean) is enabled or not. First I wanted to create Aspect-s, so when a method of a bean (which is not enabled by it's property) is called, then throw an exception. This solution could work, but then I would need to create Aspect classes,

Might EnumMap be considered a reasonable alternative to Java beans?

懵懂的女人 提交于 2020-01-04 06:00:37
问题 Curious if anybody has considered using EnumMap in place of Java beans, particularly "value objects" (with no behavior)? To me it seems that one advantage would be that the name of a "property" would be directly accessible from the backing Enum, with no need for reflection, and therefore I'd assume it would be faster. 回答1: It may be a little faster then using reflection (I didn't measure it, didn't find any metrics in Google either); however there are big disadvantages to this approach: You

“required a single bean, but 2 were found” - Spring

为君一笑 提交于 2020-01-03 17:09:48
问题 Here is my class: import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.support.MessageSourceAccessor; import org.springframework.http.HttpHeaders; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.util.Assert; import org.springframework.web.bind.annotation.ControllerAdvice; import org.springframework.web.bind.annotation.ExceptionHandler; import org.springframework.web.context

How can I go through a Set in JSP? (Hibernate Associations)

寵の児 提交于 2020-01-03 10:40:56
问题 So I am pretty new to JSP. I have tried this a few ways. Ways that would make sense in PHP or automagicy frameworks... I am probably thinking too much in fact... I have a hibernate one to many association. That is class x has many of class y. In class x's view.jsp. I would like to grab all of class y, where the foreign key of y matches the primary key of x and display them. It seems that hibernate properly puts this stuff into a set. Now, the question is how can I iterate through this set and

Assert that two java beans are equivalent

别说谁变了你拦得住时间么 提交于 2020-01-03 07:27:12
问题 This question is close, but still not what I want. I'd like to assert in a generic way that two bean objects are equivalent. In case they are not, I'd like a detailed error message explaining the difference instead of a boolean "equal" or "not equal". 回答1: I recommend you use unitils library: http://www.unitils.org/tutorial-reflectionassert.html public class User { private long id; private String first; private String last; public User(long id, String first, String last) { this.id = id; this

@BeanProperty with PropertyChangeListener support?

人盡茶涼 提交于 2020-01-02 05:07:22
问题 @BeanProperty generates simple get / set methods. Is there a way to automatically generate such methods with support for firing property change events (e.g. I want to use it with JFace Databinding?) 回答1: I've had the same question, and have been keeping a close eye out for possible answers. I think I've just stumbled across one (although I haven't tried it yet). Scala 2.9 has a feature for handling dynamic calls (meant for integration with dynamic languages, I suspect). Essentially, calls to

@BeanProperty with PropertyChangeListener support?

筅森魡賤 提交于 2020-01-02 05:05:09
问题 @BeanProperty generates simple get / set methods. Is there a way to automatically generate such methods with support for firing property change events (e.g. I want to use it with JFace Databinding?) 回答1: I've had the same question, and have been keeping a close eye out for possible answers. I think I've just stumbled across one (although I haven't tried it yet). Scala 2.9 has a feature for handling dynamic calls (meant for integration with dynamic languages, I suspect). Essentially, calls to

spring ioc injecting concrete implementation of interface to test

风格不统一 提交于 2020-01-01 19:40:54
问题 I have the following setup: @Component public class ImplOne implements IFace{ } @Component public class ImplTwo implements IFace{ } public interface IFace{ } I am trying to get a reference of ImplOne by type: @RunWith(SpringJUnit4ClassRunner.class) public class ImplOneTest { @Autowired private ImplOne impl; @Test public void test(){ Assert.assertNotNull(impl); } } Though with this I get the following exception: org.springframework.beans.factory.NoSuchBeanDefinitionException: No matching bean