Wednesday, July 25, 2007
WAS 6.1 in RSA 7.0
In WAS 6.1, RMI ORB bootstrap port is defined 2810. Modify it to 7810.
Start WAS 6.1, still complain on port 2810. Restart RAS 7.0.
Profile name "AppSrv01", server name "server1".
From its log, it started. but in the RSA console, it still says starting. Also the publish failed and complained not started.
Even after 30 minutes, it still says starting. So I stopped it.
Restarted the workstation. Found port 2810 gone. Modify WAS 6.1 port back to 2810. Restart RSA.
Start WAS 6.1 and started.
Sunday, June 10, 2007
Fodero Core 5 Package Updater
I then opened a terminal window and run "yum update". It reported the error at Macromedia update. After some research, I was suggested replacing the /etc/yum.repos.d/macromedia-mplug.repo with the following content.
[macromedia]
name=Macromedia for i386 Linux
#baseurl=http://macromedia.rediris.es/rpm/
baseurl=http://sluglug.ucsc.edu/macromedia/rpm/
enabled=1
gpgcheck=1
#gpgkey=http://macromedia.mplug.org/FEDORA-GPG-KEY
gpgkey=http://sluglug.ucsc.edu/macromedia/FEDORA-GPG-KEY
After that, the Package Update came back to normal.
Thursday, May 31, 2007
Unique ID Generation
- Unique to the System.currentTimeMillis()
- Unique to the IP address
- Unique to the object instance System.identityHashCode(this)
- Unique within a millisecond, SecureRandom
A open source named Java UUID Generator is available at http://jug.safehaus.org/.
Business Delegate and Session Facade
ONE to ONE. Often, the business delegate will have the same API as the session facade.
There is a close relationship between the BD and the SF. The client layer interacts with a BD. The BD would in turn, employ the Service Locator pattern to locate the SF. It is common to see a one-to-one mapping between the BD and the SF.
Monday, May 28, 2007
Testing Glossary
- Black-box testing - testing that verifies that given input A the component or system being tested gives you expected results B.
- Boundary-value testing - testing of unusual or extreme situations that your code should be able to handle.
- Function testing - a part of system testing in which development staff confirm that their application meets the specified user requirements.
- Integration testing - testing that verifies that several portions of software work together.
- Regression testing - testing that ensures previously tested behaviors still work as expected after changes have been made to an application.
- Stress testing - testing that ensures the system performs as expected under a high volume of transactions, high number of users, and so on. Also referred to as load testing.
- White-box testing - testing that verifies specific line of code work as defined. Also referred to as clear-box testing.
- Alpha testing - a testing period in which pre-release versions of software products are released to users who need access to the product before it it officially deployed. In return, these users will report any defects to the software developers. Alpha testing is typically followed by beta testing.
- Beta testing - a similar process to alpha testing, except the software product should be less buggy.
- Code inspection - a form of technical review in which the deliverable being reviewed is source code.
- Peer view - a style of technical review in which a project artifact, or portion thereof, is inspected by a small group of experts.
- Use-case scenario testing - a testing process in which users work through use cases with the aid of a facilitator to verify that a user interface prototype fulfills the needs of its users and that the identified classes for a system fulfill the requirements described in the use cases.
- User testing - testing processes in which the user community, as opposed to developers, performs the tests.
- User-interface testing - the testing of the user interface to ensure that it follows accepted standards and meets its requirements. User-interface testing is often referred to as graphical user interface (GUI) testing.
Friday, May 25, 2007
Session Data in Multiframed JSPs
JSPs will, be default, create an HttpSession if it does not already exist. A developer can use <% @page session="false" %> to turn off the automatic session creation from the JSP files that will not access the session. Then if the page needs access to the session information, the developer can use <% HttpSession session = HttpServletRequest.getSession(false); %> to get the already existing session that was created by the original session creating JSP file. This action helps prevent breaking session affinity on the initial loading of the frame pages.
Web Application Session Data
- When developing new objects to be stored in the HTTP session, they should implement Serializable to ensure that they can be persisted into a database or send via the message server if clustered sessions are enabled by the system administrator.
- Maximize use of session affinity and avoid breaking affinity. Session affinity is enabled by default in WebSphere Application Server. It ensures that, except for hardware or software fail-over, requests are handled by the container which initialized that session. Session clustering may be used in addition to affinity to handle fail-over.
- Release HttpSessions when done, call HttpSession.invalidate(). Otherwise the session objects remain in memory until the session timeout expires.
- It does not make sense to protect access to session state only part of the time.
- Distributed HttpSession support does not guarantee transactional integrity of an attribute in a failover scenario or when session affinity is broken.
Tuesday, May 22, 2007
Syntactic and Semantic
- Syntactic -- this involves checking for the format of a field, e.g. number of characters, alpha or numeric, membership in a list, and so forth. This needs to be repeated on the server because of the issues with JavaScript being turned off, loss of synchronization between the two languages in a project.
- Semantic -- this requires domain (business) logic to perform, e.g. comparing postal code with city, and so forth.
Monday, April 30, 2007
Combine Intercepting Filter and Template Method
At the mean time, template method can be also integrated into the base filter. As shown in this diagram.
Intercepting Filter Pattern
This pattern creates pluggable filters to process common services in a standard manner without requiring changes to core request processing code. The filters intercept incoming requests and outgoing responses, allowing preprocessing and post-processing. We are able to add and remove these filters unobtrusively, without requiring changes to our existing code.
We are able, in effect, to decorate our main processing with a variety of common services, such as security, logging, debugging, and so forth. These filters are components that are independent of the main application code, and they may be added or removed declaratively. For example, a deployment configuration file may be modified to set up a chain of filters. The same configuration file might include a mapping of specific URLs to this filter chain. When a client requests a resource that matches this configured URL mapping, the filters in the chain are each processed in order before the requested target resource is invoked.

Possible types of filters include:
- Authentication filters
- Logging and auditing filters
- Image conversion filters
- Data compression filters
- Encryption filters
- Tokenizing filters
- Filters that trigger resource-access events
- XSL/T filters that transform XML content
- MIME-type chain filters
- Filters that cache URLs and other information
Note: As for J2EE, filters are a new feature of the version 2.3 Java Servlet specification.
Tuesday, April 03, 2007
1999/00: With the off-season acquisition of Antonio Davis for a high draft pick, the Raptors not only got older, they got a whole lot better. As Davis along with Charles Oakley who was acquired a year earlier provided veteran stability to a young talented team. The veteran presence helped make Vince Carter into an All-Star as he received the second most amount of all star votes ever while stealing the show in the Slam Dunk Contest which he won easily. Carter would go on to average a team high 25.7 ppg while his cousin Tracy McGrady finished second with 15.4 ppg, as the Raptors fulfilled Vince Carter's guarantee with a 45-37 record. However, in the playoffs the inexperienced Raptors would be schooled by the playoff tested New York Knicks losing in 3 straight games. Following the season, the Raptors would be jilted by Tracy McGrady, who decided to seek his own fame, out of his cousin's shadow by signing with the Orlando Magic.
2000/01: After their first playoff appearance the Raptors decided to go after a Hall of Fame coach, to lead the team to the next step as the hired al-time winingest Coach Lenny Wilkins. Vince Carter continued to establish himself as the next big star in the NBA by leading the Raptors with an impressive 27.6 pp, after exhibiting show-stopping dunks in the Olympics with Team USA. With the continued improvement of Vince Carter the Raptors would finish in 2nd place with a solid record of 47-35. In the playoffs the Raptors were matched up against the New York Knicks for the second year in a row. After splitting the first 2 games in New York the Raptors appeared to be heading for a disappointing exit again after they lost Game 3 at the ACC 97-89. However, the Raptors would send the series back to New York by winning Game 4 100-93. In the decisive 5th game in New York the Raptors would stun the Knicks 93-89 to advance to the 2nd round. In the 2nd round the Raptors were matched up against the top seed Philadelphia 76ers. However the Raptors would give the 7ers all they could handle as the battled tooth and nailed all the way to a 7th game where Vince Carter missed a buzzer beater with the Raptors down 88-87, which would have sent the Raptors on the Eastern Conference Finals.
2001/02: After experience success in the playoffs the Raptors were able to sign Vince Carter to a long-term multimillion-dollar deal to ensure their marquee stars for years to come. In addition the Raptors would add even more star power by acquiring future Hall of Famer Hakeem Olajuwon from the Houston Rockets. The Raptors appeared to be heading for another strong season as they held a record of 29-21 entering the all-star break. However, in the final game before the break Vince Carter suffered a knee injury that would hamper their star for the rest of the season. In the second half the Raptors lost 18 of 19 games including, 13 straight games following the break. With all hopes of the playoff seemingly lost Vince Carter decided to undergo knee surgery. However, the Raptors would suddenly turn thing around as they won 8 straight without Vince Carter to get back into the playoff picture. The Raptors would do on to slip into the playoff as the 7th seed with a record of 42-40. In the playoffs the Raptors would get off to a shaky start as they dropped the first 2 games on the road to the Detroit Pistons. However, coming home the Raptors would rebound nicely winning 2 games at ACC to force a decisive 5th game. In Game 5 at Detroit the Raptors gave the Pistons all they could handle before losing 85-82.
2002/03: Things looked bleak for the Raptors early in the season as Hakeem Olajuwon announced his retirement following a disappointing first season in Toronto. In addition Vince Carter continued to feel the lingering effect of his knee injury as he missed most of the first half. However, some former teammates and NBA observes began to question Carter's heart and desire and he didn't seem to be a hurry to get back in the lineup. This view was even given further ammo when Carter was dancing on stage with Nelly as the Raptors, were getting blown out by the Hawks in Atlanta. The Raptors would have all hopes for the playoff buried in January as they held a record of 8-28, which included a 12-game losing streak. Vince Carter would return and play most of the second half, averaging 20.6 ppg, but the Raptors struggles continues as Coach Lenny Wilkins who already held the record for most career wins set the record for most career losses as a coach, while the Raptors finished in 7th place with a disappointing record of 24-58. Following the final game GM Glenn Grunwald apologized to the fans at ACC announcing changes would be made. He would get started right away by firing Coach Lenny Wilkins.
2003/04: With new Coach Kevin O'Neill the Raptors started the season on a high note beating the 2-time Eastern Conference Champion New Jersey Nets 90-87. However a few days later they would set an embarrassing post shot clock record by scoring just 56 points in a loss to the Minnesota Timberwolves. That kind of inconsistency would become the hallmark of the Raptors all season, at times they looked like genuine playoff contenders, while others they looked like a last place team. At 8-8 the Raptors pulled off a blockbuster deal with the Chicago Bulls on December 1st acquiring Jalen Rose, Donyell Marshall, and Lonny Baxter in exchange for Antonio Davis, Jerome Williams, and Chris Jefferies. The Raptors would win their first 3 games after the deal but won just 1 of 7 following the initially strong start as the Raptors continued through out the entire first half as they sat at 25-25 at the All Star Break. However after the all star break injuries would become a problem as the Raptors won just 8 games the rest of the way finishing with a 33-49 record. Following the season the Raptors would fire Coach O'Neill choosing to go with Sam Mitchell.
2004/05: The Sam Mitchell era got off to a good start as the Raptors won 4 of their first 5 games. However the joy was short lived as the Raptors came back to earth fast, as a disgruntled Vince Carter continued to sulk, which hit rock bottom in a November 12th loss in Seattle as he told the Supersonics what play the team was going to run in the waning moments of an 88-87 loss. Through December the Raptors struggled badly winning just 3 of 15 games, as they finally gave up on Vince Carter as he was traded to the New Jersey Nets for Eric Williams, Aaron Williams, Alonzo Mourning, and two first-round draft picks. Mourning a future Hall of Famer refused to play for the Raptors and forced a buyout as he returned to the Miami Heat where he had his best years. Meanwhile the Raptors would go to finish tied for last place in the Atlantic Division with a 33-49 record, while Chris Bosh started to emerge as the new star of the Toronto with a solid 16.8 ppg and 8.9 rpg in just his second year.
2005/06: Under new Coach Sam Mitchell not much was expected from the Raptors who were clearly in a rebuilding mindset as they were still feeling the effects of the Vince Carter deal, in which they got nothing substantial in return, while many questioned their decision to draft Charlie Villanueva. When the season start the Raptors were struggling to match even their low expectations as they lost 15 of their first 16 games. In December the Raptors would show some improvement as they split 14 games as Chris Bosh put together an All-Star season leading the Raptors with 22.5 ppg. The Raptors would continue to play .500 ball in an up and down January that saw them set a franchise record for points in a game while a week later they were torched by Kobe Bryant for 81 points. January would also see changes in Management as GM Mike Babcock was fired and eventually replaced by Bryan Colangelo. The Raptors would close the season much as they begun losing 12 of their last 13, with Chris Bosh injured as they finished in 4th Place with a 27-55 record. The Raptors poor record would have one beneficial side effect as they won the top pick in the draft lottery which they used on Italian prodigy Andrea Bargnani, making him the first European drafted number one overall. While they would trade Charlie Villanueva, who would prove critics wrong by finishing second in Rookie of the Year Voting to the Milwaukee Bucks for play making Point Guard T.J. Ford.
猛龙队史 - 97/98
坎比等等五员大将相继倒下,被伤病浸透的猛龙无奈迎来十七连败。以色亚辞职,达蒙声言必不留营。
猛龙无奈,只好交换达蒙,虽然也换来了昌西-比卢普斯,但当时的昌西尚是菜鸟,远非今日的BIG SHOOT。
猛龙一蹶不振,16-66,全联盟垫底。
猛龙队史 - 96/97
依然是小鬼当家,猛龙虽然战胜了诸如公牛、爵士和火箭这样的决赛圈队伍,却也输给波士顿三场。公牛是当年的总冠军,爵士和火箭则是西区的冠亚军,而波士顿一季不过才胜了15场。
第二年,30-52猛龙依然中区殿底。
猛龙队史 - 95/96
为了纪念那位加拿大人--篮球之父奈施密斯教授,第一场比赛被特意安排在多伦多开球。可惜天公不做美,多伦多HUSKIES队以66比68败给了来访的纽约尼克斯队。此后,BAA脱胎成了NBA,尼克斯也成了NBA的基石,而HUSKIES却以15-45的惨淡战绩仅生存了一个赛季便黯然收场。
光阴似箭,时光荏苒,这一去就是五十年。
九五年,正是朱罗纪公园大红大紫的那一年,顺着这股狂热,猛龙从天而降。11月3日,也是多伦多的主场,猛龙迎战蓝网,94比78猛龙破网而出。
好彩头却依然是烂成绩,赛季结束的时候,猛龙仅仅胜了21场而排在中区最末。
虽然如此,那一季的猛龙却也是可歌可泣。一是3月24日,猛龙主场以109-108击败公牛,而那正是公牛以72-10的战绩横扫联盟的那个赛季。二是达蒙-司徒麦尔以场均19.0分和9.3助攻当选年度最佳新秀。
Monday, March 05, 2007
ThreadLocal – A Wrapper Class for Thread Safe
Basically the template thread-safe is fulfilled by using a wrapper class "ThreadLocal". The following code provides a simple example that shows how the ThreadLocal class work.
private static ThreadLocal pi = new ThreadLocal();
public Double pi() {
if (pi.get() == null) {
pi.set(new Double(22 / 7));
}
return (Double)pi.get();
}
ThreadLocal class wraps any object and binds it to the current thread thus making objects local to the thread. When a thread executes the pi() method for the first time there will be no object bound to the thread by ThreadLocal instance pi so the get() method will return null.The set() method will bind an object to the thread that is not shared by other threads. If the method pi() is called often per thread this approach may still offer a considerable performance gain while guaranteeing thread-safety.
Thursday, February 22, 2007
Is RMI Thread Safe?
According to the specification defined with Java 1.4.2, RMI section 3.2,
A method dispatched by the RMI runtime to a remote object implementation may or may not execute in a separate thread. The RMI runtime makes no guarantees with respect to mapping remote object invocations to threads. Since remote method invocation on the same remote object may execute concurrently, a remote object implementation needs to make sure its implementation is thread-safe.No matter how confusing this specification is, it at least tells us two things,
- RMI does not take care of the thread safety, it leaves the thread safety as it is.
- RMI does not give you one server thread for one client thread, actually, it guarantees nothing on the thread scheduling.
As long as both the client objects and the server objects are thread-safe, the application is thread-safe.
Wednesday, February 21, 2007
Please! Don't Thread Safe Everything!
- Unnecessary synchronized method invocations (and synchronized blocks) can cause unnecessary blocking and unblocking of threads, which can hurt performance.
- Immutable objects tend to be instantiated more often, leading to greater numbers of often short-lived objects that can increase the work of the garbage collector.
- Synchronization gives rise to the possibility of deadlock, a severe performance problem in which your program appears to hang.
Way to Thread Safety - Wrapper
This approach makes the most sense when you want to give clients a choice between a version of a class that is thread-safe and one that isn't. It also makes sense when you're a client of someone else's class that isn't thread-safe, but you need to use the class in a multithreaded environment. Once you define your own thread-safe wrapper for the class, you can safely use the class in a multithreaded environment by going through your wrapper.
A good example of this approach from the Java API comes from the 1.2 collections library. The 1.2 collections library defines a hierarchy that includes classes that represent many kinds of collections -- none of which are thread-safe. But class Collection includes several class methods that will enclose a regular collection object in a thread-safe wrapper, so you can safely use the object in a multithreaded context. This design gives users of the collections library a choice of using a collections object that is thread-safe and one that isn't.
Note that a common attribute of wrapper classes like those you would use to add thread safety to the enclosed object is that the wrapper accepts the same messages as the enclosed object. In other words, often a wrapper class will descend from a common superclass or superinterface with the enclosed class. (For those of you familiar with the Design Patterns book by Gamma, et. al., this is the "decorator" pattern.) This decorator design approach to wrappers, which is exhibited by the thread-safe wrappers of the 1.2 collections library, allows the thread safety to be dynamically added or removed from an object.
Way to Thread Safety - Immutable
In this approach to making an object thread-safe, you don't mark critical sections as synchronized. Instead, you separate out the critical sections that read instance variables from those that write to instance variables. The critical sections that read are left as-is. The critical sections that write must be changed so that, instead of altering the current object's instance variables, they create a new object that embodies the new state and returns a reference to that object.
String and the primitive type wrappers such as Integer, Long, Float, Boolean, Character, and so on.It also lets you pass references to them to methods without worrying that the method will change the object's state. In addition, if the overhead of immutability (excessive creation of short-lived objects) may at times be too inefficient, you can also define a mutable companion class that can be used when the immutable version isn't appropriate. An example of this design approach in the Java API is the StringBuffer class, which serves as a mutable companion to the immutable String class. Note that the StringBuffer class is also thread-safe, but it uses the "normal" approach: its instance variables are private and its critical sections are synchronized.
Way to Thread Safety - Synchronization
An object's critical sections are those methods or blocks of code within methods that must be executed by only one thread at a time. Put another way, a critical section is a method or block of code that must be executed atomically, as a single, indivisible operation. By using Java's
synchronized keyword, you can guarantee that only one thread at a time will ever execute the object's critical sections.This approach takes two steps, to make all relevant fields private, and to identify and synchronize all the critical sections.
Any field that you need to coordinate multithreaded access to must be private, otherwise it may be possible for other classes and objects to ignore your critical sections and access the fields directly. Not every field must be private - only those that will be involved in any temporarily invalid states created by the object's or class's critical sections. For example, constants (static final variables) can't be corrupted by multiple threads, so they needn't be private.
A critical section is a bit of code that must be executed atomically, that is, as a single, indivisible operation.
Note that reads and writes of primitive types and object references are atomic by definition, except for longs and doubles. This means that if you have an int, for example, that is independent of any other fields in an object, you needn't synchronize code that accesses that field. If two threads were to attempt to write two different values to the int concurrently, the resulting value would be one or the other. The int would never end up with a corrupted value made up of some bits written by one thread and other bits written by the other thread.
The same is not necessarily true, however, for longs and doubles. If two different threads were to attempt to write two different values to a long concurrently, you might just end up with a corrupted value consisting of some bits written by one thread and other bits written by the other thread. Multithreaded access to longs and doubles, therefore, should always be synchronized.
For example, a Price class has two instances variables, double priceValue and Date effectiveDate. And the class has a updatePrice method,
public void updatePrice(doubel priceValue, effectiveDate) {this.priceValue = priceValue;
this.effectiveDate = effectiveDate;
}
The way to make Price thread safe is to make the priceValue and the effectiveDate private first,
then synchronize the updatePrice method.
public synchronized void updatePrice(double priceValue, effectiveDate) {
...
}
or
public void ... {
synchronized (this) {
this.priceValue = priceValue;
this.effectiveDate = effectiveDate;
}
}