javabeans

spring ioc injecting concrete implementation of interface to test

南楼画角 提交于 2019-12-04 19:27:11
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 of type [some.package.TestBean] found for dependency: expected at least 1 bean which qualifies as

What is the best way to implement notification about property change?

不羁岁月 提交于 2019-12-04 17:33:41
A have a bean (POJO-like) and want to make model for GUI component of it. So I need to notify about each property change in order GUI component can reflect. How to do this? Should I put notification and listener storage code just inside my bean? But this will make it "dirty". May be write some wrapper? But this will duplicate getters and setters. Are there any libraries and/or helper objects for this in Commons or somewhere else? UPDATE Also suppose I have AbstractList<E> implementation. How to "propertize" it quickly, i.e. make it to notify listeners about changes? For example, by firing

java beans: difference between persistent field and persistent property?

余生颓废 提交于 2019-12-04 17:17:14
I got the impression that if we use persistent fields, there is no need for getter methods since the entity manager references the instance variables directly. However, when I removed the getter and setter methods from an entity to have persistent fields, the values for the corresponding instance variable was not retrieved from the database! Does that mean we must have getter and setter methods even though we have persistent fields? If the entity class uses persistence, fields Persistence accesses the entity class instance variables directly at runtime. While on persistence property, there is

How to merge multiple maps into one in Spring

依然范特西╮ 提交于 2019-12-04 16:44:35
I have several maps defined in my context file. Is there a way to combine those maps into one map that contains all of their entries, without writing Java code (and without using nested maps)? I'm looking for the equivalent of Map m = new HashMap(); m.putAll(carMap); m.putAll(bikeMap); Seems like there should be a way to do this in Spring context file, but the Spring 3.0 reference doc section on util:map doesn't cover this use case. <!-- I want to create a map with id "vehicles" that contains all entries of the other maps --> <util:map id="cars"> <entry key="groceryGetter" value-ref="impreza"/

Gwt editor with not only getter/setter bean class

て烟熏妆下的殇ゞ 提交于 2019-12-04 15:54:53
Lets say I have form build in GWT, an UI-Binder, which implements Editor interface (com.google.gwt.editor.client.Editor) with two date fields (date from and to). Bean class is expected to have members: Date fromDate; // with getter and setter Date toDate; // with getter and setter And okay, while having bean class defined as written, there is no problem, but just after I add something like this: public boolean hasFromDate() { return fromDate != null; } I got compilation error (for example for fromDate): [ERROR] Line 17: The method hasFromDate() is undefined for the type Date [ERROR] Line 20:

Spring boot preloading data from database in bean

吃可爱长大的小学妹 提交于 2019-12-04 15:21:04
I'm asking for elements that have a recursive relationship in one table: child id | parent id 1 | null 2 | 1 3 | 1 4 | 2 And so on...To ask for this whole datastructure it takes about 10 secondsAt the moment I can't redesign this table because it cost too much time (for more information: Spring Repository performance issues with recursive ORM Class ) Now, I am thinking about preloading all data during spring startup in a bean, so that the client "communicates" with the bean and I update the data in bean and database. I think it doesn't matter how long this startup takes, but it matters how

Apache camel getbody as custom class

回眸只為那壹抹淺笑 提交于 2019-12-04 15:18:35
The question is rather simple, perhaps because I'm a little confused in the process. What I'm trying to do is shown in the code example: cc.addRoutes(new RouteBuilder() { @Override public void configure() throws Exception { from("file://files?noop=true") .split() .tokenize("\n") .split() .method(SplitToken.class, "hashTokens") and: class SplitToken { @SuppressWarnings("unchecked") public static List<HashMap<String, Integer>> hashTokens(final Exchange exchange) { List<String> oldstr = exchange.getIn().getBody(List<String>); //Create a key value hashmap from accumulated string list } } but

Servlets with JavaBeans

℡╲_俬逩灬. 提交于 2019-12-04 12:35:09
I have a set of three servlets, each one of them has a form with radio buttons that passes its values to the next servlet. What I am trying to do is to make a JavaBean class to use with the servlets and keep the state of them and the choices of the radio buttons while going from one servlet to another. Could anyone suggest some sample code for the JavaBean please? Here is some of the first servlet code: (The other two servlets have same code for other questions) protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

How can share bean from external library to GWT client?

北慕城南 提交于 2019-12-04 12:07:57
I have a question about share the java bean in library to gwt client I know bean share between GWT client and server usually put into package domain.shared. However, how can I make use of existing bean from external jar library on GWT client? Because I always got this message. No source code is available for type xxxx.xxxx.bean did you forget to inherit a required module? Given that your beans are in the package xxx.xxx.bean , and they are in an imported my_beans.jar library. Create a folder in your Application src tree (or src/main/java if you are using maven) with the name xxx/xxx Create a

jsf/primefaces load indicator during init of the bean

岁酱吖の 提交于 2019-12-04 12:05:38
In my JSF/Primefaces project, I have a lot of data loading in the init (postconstruct) method of my beans. That's why I would like to show an gif indicator during the bean load. I tried with primefaces and the Ajax status (programmatic version of the showcase) http://www.primefaces.org/showcase/ui/ajaxStatusScript.jsf So I added this to the template of my project <p:dialog modal="true" widgetVar="loadWidget" header="Status" draggable="false" closable="false"> <p:graphicImage value="../images/ajaxload.gif" /> </p:dialog> I would like to be able to call loadWidget.show(); at the beginning of the