Source Beat is Live!
Just noticed Source Beat is live. And yes that is my ugly mug on the front page :-)
Random Musings On Java Stuff I'm doing
Just noticed Source Beat is live. And yes that is my ugly mug on the front page :-)
Well I finally got attached to Tomcat (the tomcat from jwsdp1.3)
./catalina.sh start -debug
The trick is to find the port #. I looked far and wide and could not find out which port it was actually using. I found a blog that was old that suggested it defaulted to 8000. That did not work. Finally I found launcher.xml that the commons-launcher uses. In this file the port is defaulted to 9876 under the property jpda.address. I don't see a straightforward way to set that property off hand.
In Eclipse (on a mac and other unixs) set the connection type to Standard (Socket Attach) and the Host to localhost and the port to 9876 then hit the Debug button. Assuming that catalina is up and running you should attach and be able to stop at your breakpoints. On Windows you would probably have to use shared memory instead (I don't have my windows box handy or I'd get the exact wording). The shared memory name is jdbconn.
Any ideas how to set my own value of jpda.address? Catalina uses the commons-launcher which basically uses ant files. Does it also allow a property to be set only once? If so then I could presumably put a -Djpda.address=my port # into the command line (the catalina.sh script does not appear to allow this though). 9876 is fine for now but it seems weird that there is not a way to change it (I'm sure I'm missing something...)
Your thoughts greatly appreciated.
Not since the glory days of Obj-C in gdb have I been so productive with a debugger :-)
Current Three Favorite Features;
Conditional Breakpoints are activated via the Breakpoints view. Right click on the breakpoint of interest, select Properties... and then activate the Enable Condition checkbox. You can type in a code snipit that will be executed to determine if the breakpoint should be hit or not.
Logical Structure hides some of the detail about the internal structure of a variable. For example a Map can be implemented in many different ways but often all we want to see is the key/value pairs. The Logical Structure feature does just that. To activate it; in the Variables view select the Show Logical Structure button in the title bar. It looks like a browser on OSX and is the second button from the left.
New Detail Formatter... with this little gem you can code the way your variable looks in the Detail panel of the Variables view. To activate, right click on a variable in the Variables view and select New Detail Formatter... menu item. Then in the code box type in method calls against the type (entrySet() for example on a java.util.Map). The Detail panel will now show the output of the code you typed in. Groovy!
There is of course more to love but I really need to finish chapter 3!
I usually don't talk about politics or religion here but...
I hate this kind of thing. Either God is God and is capable of doing things like creating the world, parting the sea or healing a blind man or He is not. So next are we going to calculate that just enough spit and just enough clay is enough to make a blind man see? Or just enough balm, linen and the right temperate was enough to bring Christ back from the dead? God does not need our permission or understanding to part the Red sea. That is great that there is a reef and that a wind could expose it etc. But come on, if He really is God then he could lift the whole sea out of it's bed and then drop it again, or make it all evaporate. Or do just as the text says, make the waters into a wall on the right and the left. There is no way to explain God with physics, sure He set up the laws and mostly lets then run on their own. But if we reduce Him to a follower of the rules of physics the important stuff (like the virgin birth, the resurrection) becomes impossible and makes God irrelevant. Either He is God or He's not.
Chris Mathews started a great discussion on JavaRanch about when you should use EJB's.
I posted my thoughts there instead of cross posting I'll let you read them there...
What are your thoughts?
Just delivered the second chapter of the Eclipse book to Source Beat. I like the way its coming together.
We (that is Source Beat and I) will be at Eclipse Con. They are giving away really cool bits of stuff for doing an early buy of the book. I don't think I can say yet what the stuff will be yet but I sure wish I could get one :-)
Hope to see you there!
Lego finally responded to all the info that's been floating around about the end of Mindstorms
If you read the original release (Jan 8th) closely it does not mention specifically that they will be dropping electronic products. The Yahoo story that started it all must have come from conversation instead of the release.
Can't wait to play with this stuff! Its not like I'm bored and looking for something to do, I have way to much to do to be playing with new software toys but I really want to produce Anna's 5th birthday video with iMovie 4.0!
In other book related news... Jonathan and I made the java developer book shelf.
I'm honored!
They even put a couple of the pitfalls/antipatterns up for download. I'd love to get your feed back!
Well I've finally finished getting the contract signed and I'm on board with SourceBeat. I love the model, in essence I get to write a book and then rewrite it based on feed back, add stuff that I wanted to but did not have time to for the first release, etc. Also the publishing cycle is much compressed. Instead of delivering my last written word and waiting 4 months for the book to show up on Amazon then 2 more weeks for it to make the warehouse its like 15 minutes from me hitting send till it shows up (well not really they do make sure that its not full of holes and stuff but you get the idea).
I'm totally psyched!
What are your thoughts about the model?
Well after years of exhaustive research I've finally discovered the perfect ski sock... I have been using Kirkland brand (Costco for those that don't know) dress socks for the last few times I've gone skiing and they work like a champ. I've tried the $25/pair silk socks, normal white athletic socks etc and nothing works as well as these dress socks. Yes I know its weird but give it a shot. Of course your mileage might vary :-)
Well this is the first of hopefully many installments on how to convert to the new JSF 1.0 Beta from the EA4 release.
In the old EA4 you would implement an adapter between what JSF expected (i.e. the javax.faces.application.Action interface) and the business method on your java bean. So the code looked something like this...
private transient Action loginAction = new Action() {
public String invoke() {
return login();
}
};
...
public String login() {
// defautls to valid
String outcome = VALID_LOGIN_OUTCOME;
FacesContext ctx = FacesContext.getCurrentInstance();
try {
LoginCommand delegate = LoginCommandLocal.getCommand();
Customer customer =
delegate.validateLogin(getUserName(), getPassword());
if (customer != null) {
Map sessionMap = ctx.getExternalContext().getSessionMap();
sessionMap.put(CUSTOMER_KEY, customer);
} else {
// The customer was null so the login must have failed.
// Set the outcome to invalid and add an error message
// to the faces context.
outcome = INVALID_LOGIN_OUTCOME;
addLoginNotFoundMessage(ctx);
}
} catch (HibernateException e) {
// something is wrong with the database
outcome = INVALID_LOGIN_OUTCOME;
addInternalErrorMessage(ctx);
// log the exception so someone can fix it
logger.throwing(getClass().getName(), "login", e);
} finally {
// for security purposes set the password to null
setPassword(null);
}
return outcome;
}
The JSP would contain an 'actionRef' attribute that specified a EL like expression that JSF used to bind the button push (or other User Gesture) to the adapter.
<h:command_button id="submit" type="SUBMIT"
label="Login"
commandName="login"
actionRef="loginPage.loginAction"/>
In the brave new world of 1.0 Beta things are simpler. Instead of having an adapter between your 'business logic' and the JSF component you simply refer to the method you want called via a Method Binding Expression (Section 5.2 of the JSF 1.0 Beta spec). This frees you from having to have one of these little anonymous implementations for each 'action' that happens on a page. As expected this among other things will cause a reworking of part of the presentation but I think that the general idea is still quite valid (basically don't mix your business logic with your view logic). Which I know to many folks this seems to be basic fundamental programming 101, but you would be surprised how often the view and model are mixed...
Enough rambling on to the code...
<h:command_button action="#{loginPage.login}"
value="#{bundle.login}" />
The LoginPage code is then altered to remove the loginAction field as well as the get/set method pair. Since UICommand implements ActionSource it will find the MethodBinding specified in the 'action' attribute and then invoke that method binding. (Which for the astute observer might look surprisingly like an adapter, and that is what it is, but its provided by the framework and transparent to us as JSF developers now). The method must take no parameters and return a String. The String that is returned is used as the 'logical outcome' for input into the NavigationHandler.
Overall I really like this, I think it is much more elegant than the EA4 mechanism.
The command_button in this example also has its value set via a properties bundle which is the new and improved localization stuff in the JSF 1.0 Beta but that is a topic for another post.
Sorry not to have linked UICommand, ActionSource and MethodBinding to their JavaDocs but I could not find them publicly @ sun. They are in the javadoc that comes with the 1.0 Beta JSF download though.
I'll post more bits and pieces as I work through the code for the book.