tag:blogger.com,1999:blog-15405911642746611062024-03-18T20:13:28.363-07:00James worldJames Liu is a technical professional who has a lot of passion on software development, both technology and process.James Liuhttp://www.blogger.com/profile/12065644925126284329noreply@blogger.comBlogger93125tag:blogger.com,1999:blog-1540591164274661106.post-5463282182642872672012-11-29T08:42:00.003-08:002012-11-29T08:42:20.302-08:00Spring bean threadsafetyRecently working on multi-thread safety issues, and read a interesting article regarding spring bean and thread safe.
http://tarunsapra.wordpress.com/2011/08/21/spring-singleton-request-session-beans-and-thread-safety/
Please be aware one more thing, spring singleton is not a true singleton, is one instance per application context. So it is possible there are multiple instances inside JVM.James Liuhttp://www.blogger.com/profile/12065644925126284329noreply@blogger.com2tag:blogger.com,1999:blog-1540591164274661106.post-2282671346642274782012-11-20T11:27:00.001-08:002012-11-29T08:38:51.202-08:00Four questions for every solution1. What is the problem
2. What is the solution
3. Solution Matrix for Advantage and disadvantage.
4. What is the best solution
http://www.dzone.com/links/r/is_programming_the_art_of_making_the_right_decisi.htmlJames Liuhttp://www.blogger.com/profile/12065644925126284329noreply@blogger.com0tag:blogger.com,1999:blog-1540591164274661106.post-2131312883921877512012-11-19T13:25:00.000-08:002012-11-19T13:25:20.902-08:00Java deadLock Below it is the link of a blog regarding java dead Lock, it is very useful.
http://www.captaindebug.com/p/blogs-on-investigating-deadlocks.htmlJames Liuhttp://www.blogger.com/profile/12065644925126284329noreply@blogger.com0tag:blogger.com,1999:blog-1540591164274661106.post-30859382534899127882012-10-09T06:25:00.000-07:002012-10-09T06:25:21.560-07:00Java Interview questions LinkToday I read one article regarding interview questions, it is basic but useful. I might use for future interview for Java developers.
link is below.
http://javarevisited.blogspot.com/2011/04/top-20-core-java-interview-questions.html
James Liuhttp://www.blogger.com/profile/12065644925126284329noreply@blogger.com1tag:blogger.com,1999:blog-1540591164274661106.post-53360456404175372342012-06-26T10:28:00.005-07:002012-06-26T10:29:30.097-07:00Manager vs LeaderToday I read a article and below statement is very interesting.
<i>Managers do things right, and leaders do the right thing.
Then a manager who has a leadership will do the right things right.
</i>
It reminds me a concept which a Chinese guy "Sun Tzu" said 2000 years ago in "The Art of War": a Strategist is making sure they are doing the right thing, and a Tactician is making sure the army is doing the thing right.James Liuhttp://www.blogger.com/profile/12065644925126284329noreply@blogger.com0tag:blogger.com,1999:blog-1540591164274661106.post-37948162549870593162012-05-08T10:21:00.001-07:002012-05-08T10:21:34.144-07:00Pagination SolutionIn the last couple of days, I had some discussions with some developers regarding how to implement Pagination, below are the notes.
1. Client side solution, good for small result (10-500), static data. Initial load is slow, but switch is fast.
2. Application server solution, good for medium result set (500- 1000), and relative static data. Initial load is slow. and switch is little slow.
3. Database solution, good for Large result set ( > 10000) and dynamic data. Initial load is faster than the other two, but switch pages are much slower depends on QUERY.
If the query is complicated and expensive, then solution 3 will have big overhead.
By the way, from scalability point of view, database solution is much more expensive as it will need query db multiple times and resources are also expensive (hard to scale).James Liuhttp://www.blogger.com/profile/12065644925126284329noreply@blogger.com0tag:blogger.com,1999:blog-1540591164274661106.post-20316419662521325292012-03-05T05:45:00.000-08:002012-03-05T05:45:58.974-08:00JSF ajax exception handler solutionRecently I had some issues with JSF ajax exception handling, Primefaces 3.2 will fix it, so I am still waiting.<br />
<br />
Below are the resources might helpful:<br />
<br />
http://www.dzone.com/links/r/full_ajax_exception_handler_for_jsf_2.html<br />
http://ovaraksin.blogspot.com/2010/10/global-handling-of-all-unchecked.html<br />
http://stackoverflow.com/questions/464193/intercepting-exceptions-with-custom-jsf-event-handlersJames Liuhttp://www.blogger.com/profile/12065644925126284329noreply@blogger.com0tag:blogger.com,1999:blog-1540591164274661106.post-76904135846426758192012-02-24T08:53:00.000-08:002012-02-24T08:53:28.920-08:00Best Pratctices for Successfully ProjectSome thoughts regarding running IT project successfully.<br />
1. Major stakeholder involvement, and communication with development team. If the development team, especially primary designers(BA and Architect) can communicate with the major stakeholder regularly, then it will the DEv team to align the direction. In a project while ago, Dev team had been working on development for about 6 months based on the requirements BA collected and signed by users about 9 months ago, there is no communication between major stakeholder and development team during that time period, later that project was shut down as requirements are out of date. This is also a big issue for Waterfall. <br />
2. IT project and business requirement design are professional jobs, need specific skills and technical knowledge. Many times we see in a project,James Liuhttp://www.blogger.com/profile/12065644925126284329noreply@blogger.com2tag:blogger.com,1999:blog-1540591164274661106.post-84927989057515749962012-02-24T08:52:00.000-08:002012-02-24T08:52:24.075-08:00JSF Validation1. Customize error message.<br />
<h:inputText id="email" value="#{managePasswordBean.forgotPasswordEmail}"
validatorMessage="#{msg['searchscreen.validator.controlnumber']}"
requiredMessage="#{msg['searchscreen.required.controlnumber']}"
required="true"><br />
<f:validateRegex pattern="^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,6})$" /><br />
</h:inputText><br />
<br />
You can only have one validatorMessage. So if you have multiple validators, please use custom validators.<br />
<br />
2. For default validator, if you want customrize message, you can do this too.<br />
<br />
<h:inputText id="name" value="#{sampleBean.userName}" ><br />
<f:validateLength minimum="5" maximum="20" /><br />
</h:inputText><br />
<br />
put this into resources bundle.<br />
javax.faces.validator.LongRangeValidator.MAXIMUM={1}: Value is greater than allowable maximum of ''{0}''<br />
<br />
3. How to specify field name in validator.<br />
<br />
<rich:calendar value="#{fieldValue}" id="dateField" datePattern="yyyy/MM/dd"><br />
<f:validator validatorId="dateNotInThePast"/><br />
<f:attribute name="fieldLabel" value="Date field 2" /><br />
</rich:calendar><br />
<br />
<br />
private void checkDate(Date date, UIComponent uiComponent, Locale locale) {<br />
if(isDateInRange(date) == false) {<br />
ResourceBundle rb = ResourceBundle.getBundle("messages", locale);<br />
String messageText = getFieldLabel(uiComponent) +" " + rb.getString(getErrorKey());<br />
<br />
throw new ValidatorException(new FacesMessage(FacesMessage.SEVERITY_ERROR,<br />
messageText, messageText));<br />
}<br />
}<br />
<br />
protected String getFieldLabel(UIComponent uiComponent) {<br />
String fieldLabel = (String) uiComponent.getAttributes().get("fieldLabel");<br />
<br />
if(fieldLabel == null) {<br />
fieldLabel = "Date" ;<br />
}<br />
<br />
return fieldLabel;<br />
}<br />
<br />
<a href="http://tomaszdziurko.pl/2011/10/parametrizing-custom-validator-jsf-2/">Check this link for details.</a>James Liuhttp://www.blogger.com/profile/12065644925126284329noreply@blogger.com0tag:blogger.com,1999:blog-1540591164274661106.post-59982304340816238422012-02-21T11:06:00.000-08:002012-02-21T11:06:41.912-08:00James Liuhttp://www.blogger.com/profile/12065644925126284329noreply@blogger.com0tag:blogger.com,1999:blog-1540591164274661106.post-6135709736435790032012-02-16T07:24:00.001-08:002012-02-16T07:24:55.535-08:00HTML5 videohttp://www.dzone.com/links/r/video_series_html5_web_camp_silicon_valley.htmlJames Liuhttp://www.blogger.com/profile/12065644925126284329noreply@blogger.com0tag:blogger.com,1999:blog-1540591164274661106.post-91027220769206023172012-02-09T13:44:00.000-08:002012-02-09T13:44:20.576-08:00What are required for LeadershipGood leader requires two things.<br />
1. Version<br />
2. Smart Followers<br />
<br />
A good leader is a person who has a version and also group of skilled and smart people which follow him, and help him to achieve his versions.<br />
<br />
A leader without a version is just a manager. A good manager does not need a version, but people skills, and can be a good follower.<br />
<br />
A expert or specialist can help leaders to achieve something, but not necessary need either version or people skills. <br />
<br />
In some cases, a good leader may not have people skills, and still having many followers, also still can be attractive to smart experts and specialists, like Steven Jobs. But he need a clear version.<br />
<br />
In my opinion, Version is the most important factor to be a good leader. As clear and good version will attractive more smart people to follow.James Liuhttp://www.blogger.com/profile/12065644925126284329noreply@blogger.com0tag:blogger.com,1999:blog-1540591164274661106.post-31730537396370347962012-02-09T13:23:00.000-08:002012-02-09T13:23:45.930-08:00JSF Managed BeanToday I made some changes JSF managed beans using annotation instead of XML. Below it is the example.<br />
<br />
<br />
@ManagedBean(name="themeSwitcherBean") -- Declare it as managed bean<br />
@RequestScoped<br />
public class MyThemeSwitcherBean {<br />
<br />
@ManagedProperty(value = "#{userAccountService}") -- How to reference spring bean or other managed bean.<br />
UserAccountService userAccountService;James Liuhttp://www.blogger.com/profile/12065644925126284329noreply@blogger.com0tag:blogger.com,1999:blog-1540591164274661106.post-74878756993512733802012-01-10T08:08:00.000-08:002012-01-10T08:08:04.535-08:00Eclipse errors and solutions1. javax.el.PropertyNotFoundException: /index.xhtml @12,39 value="#{user.name}": Target Unreachable, identifier 'user' resolved to null <br />
<br />
reason: it could not load jsf bean.<br />
<br />
Solution: a. check project-->properties --> build --> source code, if it is checked.<br />
b. removed the tomcat server.<br />
c. mvn eclipse:eclipse<br />
d. add resourcesJames Liuhttp://www.blogger.com/profile/12065644925126284329noreply@blogger.com0tag:blogger.com,1999:blog-1540591164274661106.post-26513325844794054482012-01-09T05:57:00.000-08:002012-01-09T05:57:13.728-08:00How to create two doamins in one Tomcat instance<a href="http://tomcat.apache.org/tomcat-7.0-doc/virtual-hosting-howto.html">Virtual Hosting and Tomcat</a>James Liuhttp://www.blogger.com/profile/12065644925126284329noreply@blogger.com0tag:blogger.com,1999:blog-1540591164274661106.post-37829089200908213882012-01-06T13:06:00.000-08:002012-01-06T13:06:25.067-08:00How to deal with Warning: This page calls for XML namespace primefaces.org/ui declared with prefix p but no taglibrary exists for that namespace.Yesterday I did a example using PRISMFACE, JSF2, and I got below error:<br />
<br />
Warning: This page calls for XML namespace primefaces.org/ui declared with prefix p but no taglibrary exists for that namespace.<br />
<br />
After I copied primeface jar into lib directory, everything is working. So wired.<br />
<br />
I think this might be a Maven issue.James Liuhttp://www.blogger.com/profile/12065644925126284329noreply@blogger.com0tag:blogger.com,1999:blog-1540591164274661106.post-33081731441922016232011-11-16T11:34:00.001-08:002011-11-16T11:34:53.283-08:00Where to put named queries in JPA?Please check below <a href="http://jdevelopment.nl/put-named-queries-jpa/">link</a>James Liuhttp://www.blogger.com/profile/12065644925126284329noreply@blogger.com0tag:blogger.com,1999:blog-1540591164274661106.post-31684749617749672262011-11-14T08:27:00.000-08:002011-11-14T10:28:58.228-08:00How to configure multiThread MDB in websphereThe maximum sessions property determines how many messages an MDB can process simultaneously. The default value for this property is 1, which means that an MDB must finish processing the first message on the queue before it can process the second, and so on (for you programmers, this essentially means that an MDB is single-threaded).<br />
<br />
If the application server is not under a heavy load, you might want to increase the throughput of messages. In this situation, you can increase the value of the maximum sessions property to enable an MDB to process more than one message at once (this makes the MDB multi-threaded). It is worth noting, though, that increasing the value of maximum sessions will increase the load on your system, since you will now have multiple instances of the MDB running at the same time!<br />
<br />
Details please check below <a href="http://www.ibm.com/developerworks/websphere/library/techarticles/0602_kesavan/0602_kesavan.html">link</a>James Liuhttp://www.blogger.com/profile/12065644925126284329noreply@blogger.com0tag:blogger.com,1999:blog-1540591164274661106.post-20005680618576812662011-11-11T06:04:00.001-08:002011-11-11T06:04:16.897-08:00Spring reference cardhttp://refcardz.dzone.com/refcardz/spring-configuration?oid=sb001James Liuhttp://www.blogger.com/profile/12065644925126284329noreply@blogger.com0tag:blogger.com,1999:blog-1540591164274661106.post-88516310851848014462011-11-11T05:54:00.001-08:002011-11-11T05:54:37.725-08:00Design Pattern for Java resourceshttp://www.dzone.com/links/r/design_patterns_object_oriented_design_repository.htmlJames Liuhttp://www.blogger.com/profile/12065644925126284329noreply@blogger.com0tag:blogger.com,1999:blog-1540591164274661106.post-12176406248527317172011-10-27T06:46:00.000-07:002011-10-27T06:46:24.608-07:00Why project failedBelow it is a very interesting <a href="http://www.dzone.com/links/r/project_managers_is_yellow_the_new_green.html">article</a> <br />
<br />
1. Reduce co-location makes communication difficult.<br />
2. Loss of key players will take months to recovery.<br />
3. new technology learning curve.<br />
4. New team need to time to build.James Liuhttp://www.blogger.com/profile/12065644925126284329noreply@blogger.com0tag:blogger.com,1999:blog-1540591164274661106.post-37486966875886269422011-10-08T17:57:00.000-07:002011-10-08T20:06:03.237-07:00HTML 5 MagicToday I did some research regaridng HTML5, it is really impressive. I have the feeling HTML 5 will be the next wave on web. Below are some features:<br /><br />1. SVG<br />2. VIDEO<br />3. GEOLOCATION<br />4. Cache and Database<br />5. Web wrokerJameshttp://www.blogger.com/profile/11175701368737156200noreply@blogger.com0tag:blogger.com,1999:blog-1540591164274661106.post-10503309703010853552011-10-03T08:46:00.001-07:002011-10-03T08:46:35.627-07:00Why Software Is Eating The WorldToday I read a article which is very useful to inspire the developers.<br />
<br />
Please check the <a href="http://online.wsj.com/article/SB10001424053111903480904576512250915629460.html">link.</a>James Liuhttp://www.blogger.com/profile/12065644925126284329noreply@blogger.com0tag:blogger.com,1999:blog-1540591164274661106.post-10172706147948354832011-09-30T12:54:00.000-07:002011-09-30T12:55:43.562-07:00Best way to use ConstractorI had been working as consultant for about two months already. One interesting thing I found in those days regarding how to use consultant effectively.<br />
<br />
1. Hire technical expert as technical leader, so other team members can learn from him. This way is better than hiring a trainer. This works very well if this company run into a new technical area.<br />
2. Hire Junior consultants doing heavy load and lower technical tasks. Also those works are perfect for outsourcing.<br />
3. Team members should include both full-time and contractors. A team contains only contractors will face long term maintainability issues in the long run. Some one in the team should audit the quality.<br />
<br />
"Knowledge can be conveyed, but wisdom is only earned by experience of trying"James Liuhttp://www.blogger.com/profile/12065644925126284329noreply@blogger.com0tag:blogger.com,1999:blog-1540591164274661106.post-49785739626192770952011-09-23T05:59:00.001-07:002011-09-23T05:59:32.664-07:00Check List for new project before codingI recently read a article talking about check list before coding, it is very interesting, please check the <a href="http://www.javacodegeeks.com/2011/09/this-comes-before-your-business-logic.html">link </a>James Liuhttp://www.blogger.com/profile/12065644925126284329noreply@blogger.com0