Austin Kottke's Code Site

Thoughts about Architecture – Java, C/C++, JS, Objective-C, Swift, Groovy, Grails, (RIP Flash)
Archive for the ‘java’ Category

I for one think it’s absolutely hilarious how google devs despise js as an enterprise development tool. But can’t stand to develop in it. I remember when angular1 came out. And thought to my self “Wow google actually made a library in pure js?” and recommends you to develop in js – impressive. Some years back I worked in a project called GWT – you may have heard of it. It compiles Java down into JS and provides a somewhat awesome way to dev apps – outside of compile times and crappy looking widgets. Anyway – So when angular1 came out I was like “Whoa awesome – pure js”. Used it for a project to build a fully functional phone with WebRTC and flash. Worked great – I really enjoyed the thoroughness that google put into it. But I couldnt get over the fact – having done a prior project in GWT/GXT that google was just laying it all out and doing a pure js library. I mean “I thought google despised js as a pure dev language.” Now, years later – Google releases angular 2 through 5 – “AHHHHH Im right – they ditched js in favor of TypeScript” haha. Now we’re using TypeScript. So I guess I was right. Google cant stand js. So now – I see flutter and Im like – wow, that’s pretty cool – FINALLY a competitor to react-native. But wait there’s more! https://flutter.io/. Google revamped the dart language and basically said screw js – lets use Dart! Honestly Im kind…

I combined Stripes and Velocity into a J2EE filter that came out to be extremely useful, so I could have Stripes/JSPs and have Velocity rendering with every request. I love the toolbox.xml concept of velocity so I couldnt live without it, but wanted to use stripes for its amazing action controller functionality. Here is a filter which modifies the stripes response and then parses the response through the Velocity Template Engine. package org.adk.java.viewfilter; import org.adk.java.locale.LocaleTool; import java.io.CharArrayWriter; import java.io.IOException; import java.io.PrintWriter; import java.util.Collection; import java.util.Iterator; import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.logging.Level; import java.util.logging.Logger; import javax.servlet.Filter; import javax.servlet.FilterChain; import javax.servlet.FilterConfig; import javax.servlet.ServletContext; import javax.servlet.ServletException; import javax.servlet.ServletRequest; import javax.servlet.ServletResponse; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpSession; import org.adk.java.store.StoreWebApplication; import org.adk.java.store.WebSessionBean; import org.adk.java.log.KLogger; import org.adk.java.secure.SecureRedirectorActionBean; import org.adk.java.stripes.ActionBeanUrlManager; import org.adk.java.viewfilter.tools.BaseTool; import org.adk.java.viewfilter.tools.BreadCrumbTool; import org.adk.java.viewfilter.tools.PropertyTool; import org.adk.java.viewfilter.tools.RequestTool; import org.apache.velocity.VelocityContext; import org.apache.velocity.app.Velocity; import org.apache.velocity.tools.view.XMLToolboxManager; /******************************************************************************************** * * Our basic filter, all it does is take our WebSessionBean which is a wrapper around * the current session and passes it in the request, so that all jsps and other objects * can access the data, such as the current users shopping cart, his user info, and * other pertinent details to the session for this user. * * In addition to basic session addition, we also take the content and * add in the velocity template engine so the session can be accessed from * velocity, and all content, after stripes is done with it is modified * with velocity. * * We perform the following steps: * ——————————- * *…

For the last few years I’ve been developing in flex. One of the very nice features is RSLs to save on file space, but no matter how much optimization work you end up with a huge SWF right? Which is why developers end up using flash for web development. How many times have you wanted to use the RPC components but ended up scrapping them because they bloat your SWFs? I’ve had to resort to custom AS3 soap libraries, or even have had to hack an existing AS3 web service implementation because it wasn’t compatible with ALL SOAP specs, as in each server has little nuances which can potentially break an AS3 implementation. The joys =) Ive been doing a lot of flash dev recently, and one option which I think a lot of flash developers miss over is the fact that they compile assets within assets that are shared across multiple SWF files. E.g. you have the Pure MVC framework or cairngorm classes compiled into 5 swfs, when really, all you need to load in a single shell SWF and all future SWF files can reference the classes normally WITHOUT compiling in the entire framework. So how do you do this? How do you make your other SWFs not compile the entire framework such as ui components and buttons and flash? Well, instead of doing all the runtime instantiation and non strong typing – you know like var myClass:* – which is prone to errors, use mxmlc -load-externs. So the steps are as follows:…

I found an awesome video that came out last month from one of the Spring Source engineers on building an entire application in Grails. I think if anything this video shows the true simplicity of grails. It outlines security, ajax, authentication, jdbc, validation and how fast it is to develop with grails. You see how robust and quick to develop a data-base driven twitter clone.

I tell you it’s been a while since I last posted, but one thing that I have been spending a lot of time is looking at web frameworks. I looked at wicket, web macro, jsp, velocity, and I have to say that the most awesome framework I can see is stripes. I was first reading a book on hibernate – harnessing hibernate and in the end of the chapter it mentions about Stripes. One of the things I can’t stand is the auto-wiring of Java bean objects and a web form. It’s not a big deal with flex because you have amf, but in a web site it’s a pain. So take stripes, I just take an entity bean and I can specify the bean on the page and stripes will auto-validate, and send errors if a field is not required. It’s pretty nice. See below: */ @ValidateNestedProperties({ @Validate(field=”firstName”, required=true, minlength=3, maxlength=50), @Validate(field=”lastName”, required=true, minlength=5, maxlength=50), @Validate(field=”email”, required=true, minlength=5, converter=EmailTypeConverter.class ), @Validate(field=”userName”, required=true, minlength=5 ), @Validate(field=”password”, required=true, minlength=8 ) }) @Validate(encrypted=true) public UserVO getUser() { return this.beanContext.getUser(); } Using annotations the validation occurs and its just a simple matter of inserting a field and binding directly: Doing this will automatically validate the field in java. Cool huh? Well that’s one of the major things I like about it. Besides flex, it’s pretty smoothe. I like wicket, but for some reason I just cant get over writing all my UI logic in java…. I feel like im doing swing again! Anyway, check out stripes – its…

If someone were interested in developing for the android or a sidekick, what is the best way to learn. I know the iphone is objective-c, but does anyone have any advice for this? Im trying to get perspectives from different developers as the best way to learn this field, coming from an as2 – as3 – heavy oop background with some java apps built but not proficient in J2ME. Obviously each unit requires different skills, but what is the best recommended learning environment for this? This is a very general question i realize this, but it would be good to know from pro developers any feedback on this.