DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Refcards
Trend Reports

Events

View Events Video Library

Zones

Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Curious about the future of data-driven systems? Join our Data Engineering roundtable and learn how to build scalable data platforms.

Data Engineering: The industry has come a long way from organizing unstructured data to adopting today's modern data pipelines. See how.

Threat Detection: Learn core practices for managing security risks and vulnerabilities in your organization — don't regret those threats!

Managing API integrations: Assess your use case and needs — plus learn patterns for the design, build, and maintenance of your integrations.

Avatar

Andy Gibson

Programmer at ccdcfs

Strongsville, US

Joined Mar 2008

About

I've been developing software for over 15 years working in Delphi and now Java. This site is a home for my open source projects, writings, articles and tutorials mainly focusing on Java and Java EE.

Stats

Reputation: 156
Pageviews: 468.1K
Articles: 4
Comments: 83
  • Articles
  • Comments

Articles

article thumbnail
Java Patterns for Concurrency
Want to learn more about Java patterns for concurrency? Check out this post to learn more about how to solve concurrency issues with multiple threads.
November 1, 2018
· 38,113 Views · 21 Likes
article thumbnail
Comparing Constants Safely
When comparing two objects, the equals method is used to return true if they are identical. Typically, this leads to the following code : if (name.equals("Jim")) { } The problem here is that whether intended or not, it is quite possible that the name value is null, in which case a null pointer exception would be thrown. A better practice is to execute the equals method of the string constant “Jim” instead : if ("Jim".equals(name)) { } Since the constant is never null, a null exception will not be thrown, and if the other value is null, the equals comparison will fail. If you are using Java 7 or above, the new Objects class has an equals static method to compare two objects while taking null values into account. if (Objects.equals(name,"Jim")) { } Alternatively if you are using a java version prior to Java 7, but using the guava library you can use the Objects class which has a static equal() method that takes two objects and handles null cases for you. It should also be noted that there are probably a number of other implementations in various libraries (i.e. Apache Commons)
December 8, 2014
· 6,501 Views
article thumbnail
Generate Test Data with DataFactory
DataFactory is a project I just released which allows you to easily generate test data. It was primarily written for populating database for dev or test environments by providing values for names, addresses, email addresses, phone numbers, text, and dates. To add DataFactory to your maven project, just add it as a dependency in your pom.xml file. org.fluttercode.datafactory datafactory 0.8 jar Generating Test Data Now you can create instances of the DataFactory class and create data : public class Main { public static void main(String[] args) { DataFactory df = new DataFactory(); for (int i = 0; i < 100; i++) { String name = df.getFirstName() + " "+ df.getLastName(); System.out.println(name); } } } The produced output is : Lindsey Craft Erica Larsen Ryan Levine Erika Smith Brooklyn Sloan Karen Mayer Eddie O'neill Nancy Stevens The DataFactory class can generate different types of values, from addresses to random text to random dates, to dates within a fixed time period. Addresses and business names can be created using the following code : DataFactory df = new DataFactory(); for (int i = 0; i < 100; i++) { String address = df.getAddress()+","+df.getCity()+","+df.getNumberText(5); String business = df.getBusinessName(); System.out.println(business + " located at " + address); } to produce Uvalda Signs located at 1383 Beam Way,Lyons,19316 Alma Accounting located at 1386 Countiss St,Nashville,14967 Fort Stewart Engineering located at 1753 Bethesda Rd,Springfield,26306 Sugar Hill Textiles located at 1141 Loudon Circle,Cordele,83937 Albany Engineering located at 1185 Grieves Avenue,Sugar Hill,36753 Poulan Insurance located at 816 Cohen Blvd,Lake City,74839 Crescent Services located at 1085 Cloveridge Boulevard,Bemiss,08769 Dates There are a number of features to create dates, the first being creating a random date which is usually in a given sensible date range. DataFactory df = new DataFactory(); Date minDate = df.getDate(2000, 1, 1); Date maxDate = new Date(); for (int i = 0; i < 10; i++) { Date start = df.getDateBetween(minDate, maxDate); System.out.println("Date = "+start); } This produces a list of random dates between 1/1/2000 and the current date. Typically, a random date might be constrained by some other date, for example you can’t have an end date that occurs before the start date. In this case, you would plug the start date in as the minimum date value : DataFactory df = new DataFactory(); Date minDate = df.getDate(2000, 1, 1); Date maxDate = new Date(); for (int i = 0; i < 10; i++) { Date start = df.getDateBetween(minDate, maxDate); Date end = df.getDateBetween(start, maxDate); System.out.println("Date range = " + dateToString(start) + " to " + dateToString(end)); } The result is a list of dates where the second date is always later than the first : Date range = 04/29/2005 to 07/16/2006 Date range = 08/07/2009 to 01/19/2010 Date range = 09/22/2000 to 12/15/2003 Date range = 07/31/2004 to 03/24/2009 Date range = 06/27/2003 to 01/10/2007 Date range = 07/10/2003 to 04/02/2008 Date range = 01/04/2003 to 01/12/2005 In many cases, you might want your end date to be only within a few days of the start date. For example, helpdesk support tickets or hotel stays don’t last for years. To do this, you can specify the number of days from the base date you want to generate a result. In this case, we make the end date within 10 days of the begin date : for (int i = 0; i < 10; i++) { Date start = df.getDateBetween(minDate, maxDate); Date end = df.getDate(start, 0, 10); //set end to within 10 days of the start System.out.println("Date range = " + dateToString(start) + " to " + dateToString(end)); } And the result : Date range = 04/29/2005 to 04/30/2005 Date range = 12/29/2003 to 12/30/2003 Date range = 06/25/2003 to 07/03/2003 Date range = 10/19/2009 to 10/19/2009 You can also specify a negative minimum days value that could return a date prior to the base date or a positive minimum date value to get a later date. Here’s a more complex example that uses different date rules to come up with some complex test data. for (int i = 0; i < 10; i++) { //generate an order date Date orderDate = df.getDateBetween(minDate, maxDate); //estimate delivery 4-10 days after ordering Date estimatedDeliveryDate = df.getDate(orderDate, 4, 10); //deliver between 2 days prior and 3 days after delivery estimate Date actualDeliveryDate = df.getDate(estimatedDeliveryDate, -2, 3); String msg = "Ordered on "+dateToString(orderDate) + " deliver by = "+dateToString(estimatedDeliveryDate)+ " delivered on " + dateToString(actualDeliveryDate); if (estimatedDeliveryDate.before(actualDeliveryDate)) { msg = msg + " - LATE"; } if (estimatedDeliveryDate.after(actualDeliveryDate)) { msg = msg + " - EARLY"; } System.out.println(msg); } Here we calculate an order date, and create a delivery date that is at least 4 days out but no more than 10, and then we created an actual delivery date that is between 2 days prior and 3 days after the expected delivery date. Notice how we cherry picked the dates, the estimated delivery date is at least 4 days out from the order date, and the actual delivery date will only be at most 2 days prior to the estimated date. This means the actual delivery date is always at least 2 days out from the order date and we won’t get a delivery date value that is before the item was ordered. This code produces the following values: Ordered on 04/29/2005 deliver by = 05/06/2005 delivered on 05/06/2005 Ordered on 08/07/2009 deliver by = 08/13/2009 delivered on 08/13/2009 Ordered on 09/22/2000 deliver by = 09/27/2000 delivered on 09/25/2000 - EARLY Ordered on 07/31/2004 deliver by = 08/07/2004 delivered on 08/09/2004 - LATE Ordered on 06/27/2003 deliver by = 07/04/2003 delivered on 07/04/2003 Ordered on 07/10/2003 deliver by = 07/19/2003 delivered on 07/18/2003 - EARLY Ordered on 01/04/2003 deliver by = 01/08/2003 delivered on 01/08/2003 Custom Random Values If there is a set of values that is very specific to your application that you might want to generate data from, you can use methods on the DataFactory class to return values with the option for it to be randomly be a default value. public static void main(String[] args) { DataFactory df = new DataFactory(); //favorite animal String[] values = {"Cat","Dog","Goat","Horse","Sheep"}; for (int i = 0; i < 100; i++) { System.out.println(df.getItem(values,80,"None")); } } This example uses the array of animals and returns a value with a 20% chance of being the default value of “None” to produce the following : Sheep None Dog Horse Textual Data Random text data comes in two forms, absolutely random data and text data made up of words. You can generate either using the following methods : DataFactory df = new DataFactory(); System.out.println(df.getRandomText(20, 25)); System.out.println(df.getRandomChars(20)); System.out.println(df.getRandomWord(4, 10)) which produces badly numbers good hot I ywyypgqorighfawpftjq demanded All three of these methods can be passed a single length which returns a fixed length string, or a min/max length which produces a random string with a length somewhere between the min/max. For the single word method, if there are no words in the dictionary of suitable length, then a word is generated using random characters. Changing the test data values produced The data used to generate the values come from classes that can be replaced with other versions. For example, the name values can be changed by providing the DataFactory instance with an object that implements the NameDataValues interface. Here is a simple class that does that to return Scandinavian first names and delegates to the the default implementation to return all the other values. public class ScandinavianNames implements NameDataValues { //first name values to use String[] firstNames = {"Anders","Freydís","Gerlach","Sigdis"}; //delegate to the default implementation for the other values NameDataValues defaults = new DefaultNameDataValues(); public String[] getFirstNames() { //return our custom list of names return firstNames; } //for the other values, just use the defaults public String[] getLastNames() { return defaults.getLastNames(); } public String[] getPrefixes() { return defaults.getPrefixes(); } public String[] getSuffixes() { return defaults.getSuffixes(); } } Obviously, to use all your own names you would add and return values for last name and the suffix/prefix values. To use this new implementation, just create an instance of the data provider and pass it to the instance of the data factory. public static void main(String[] args) { DataFactory df = new DataFactory(); df.setNameDataValues(new ScandinavianNames()); for (int i = 0; i < 10; i++) { System.out.println(df.getName()); } } Our results are Sigdis Craft Gerlach Larsen Sigdis Levine Sigdis Smith Freydís Sloan Gerlach Mayer You can always start working with the default implementation and use a more locale specific implementation if you need it later. The different pieces that can be replaced are as follows : NameDataValues – Generates names and suffix/prefixes ContentDataValues.java – Generates words, business types, email domain names and top level domain values AddressDataValues – Generates city names, street names and address suffixes Note that if you intend on replacing the component that generates words, you should have a good collection of words of various lengths from 2 up to say 8 or more characters. Hopefully this will give you a head start in generating data in development and test environments for new projects. Now I have DataFactory in the Central Maven Repository I plan on using this in the Knappsack archetypes rather than hard coding the data which was in fact generated from an earlier DataFactory implementation. From http://www.andygibson.net/blog/article/generate-test-data-with-datafactory/
February 10, 2011
· 58,693 Views · 2 Likes
article thumbnail
Deterring “ToMany” Relationships in JPA models
This article considers the issues of one to many relationships from the JPA model, and looks at an alternative strategy to provide more efficient and fine grained data access, to build more robust and lightweight applications and web services. A fairly typical use is to have one entity ‘owned’ by the other in such a way that one entity is said to ‘have’ many instances of the other one. A typical example would be customer and orders : class Customer { @OneToMany(mappedBy="customer") private Set orders; } class Order { @ManyToOne private Customer customer; } In this trivial example, the order belongs to a customer, and the customer has a set of orders. We don’t have a problem with the ManyToOne relationship, especially as it is required in order to map the order back to the customer. When we load an order we will at most get a single reference to a customer. No, our problem is with the value we get from customer.getOrders() as this set of order entities doesn’t really serve any useful purpose and can cause more problems than it solves for the following reasons : Dumb Relationship – It will contain every order for this particular customer when you usually only want a subset of the orders that match a set of criteria. You either have to read them all and filter the ones you don’t want manually (which is what SQL is for) or you end up having to make a call to a method to get the specific entities you are interested in. Unbounded dataset – How many orders a customer has could vary and you could end up with a customer with thousands of orders. Combined with accidental eager fetching and loading a simple list of 10 people could mean loading thousands of entities. Unsecured Access – Sometimes we may want to restrict the items visible to the user based on their security rights. By making it available as a property controlled by JPA we lose that ability or have to implement it further down in the application stack. No Pagination – Similar to the unbounded dataset, you end up throwing the whole list into the pagination components and letting them sort out what to display. In most cases, you need to treat each dataset like it will eventually contain more than 30 records so you really need to consider pagination early. Overgrown object graph – When you request an entity, how much of the object graph do you need? How do you know which pieces to initialize so you can avoid LIEs? This is often the case with JPA, but is also more relevant when you take account of the needs to serialize object graphs to XML or JSON. Sometimes you might need the relationships and sometimes you do not depending on the context you will be using the data in. Rife with pitfalls – Who saves and cascades what and how do you bind one to the other? You create an order, and assign the customer, do you need to then add it to the customers list of orders or not. What happens if you forget to add it to the customer and you save the customer? Whatever strategy you pick for dealing with this will no doubt end up being implemented inconsistently. (Ok, the first four are really different facets of the same problem, that you can’t control the data you are getting back.) So what use are they? Well, they make it really tempting just to use customer.orders in the view which is suitable for some sets of data. They also allow the relationship to be used in ejbql statements, although the inverse of the relationship can also be used in most cases. Specifying this relationship can also allow you to cascade updates/deletes from the customer to the order, but then so can your database. Going Granular The best alternative I’ve found is to provide additional methods to obtain the relational information separate from the model. This more granular approach gives you plenty of ways of obtaining data from the database without the dangers and temptations of bad practices. For example, the Order object still has the Customer reference on it, which we use to obtain lists of orders from the data access layer which can be constrained by customer, time frame, or other criteria depending on where it is being used. Also, it allows data to be fetched when needed without having to define a single initialization strategy using annotations or mapping files. The code that knows what pieces of data it needs will have access to facilities to fetch the specific data it needs. Alternatively, the methods to fetch the data can either be exposed as web services directly or DTO objects can be used to build a data payload to be returned from a single web service that consolidates the calls. Regardless, you don’t need to worry about setting the JPA fetch or XML/JSON serialization policy permanently in the model. Some examples might be to fetch orders for a customer in different ways. public List getOrders(Long customerId) {...} public List getOrders(Long customerId,Date startDate,Date endDate) {...} public List getOrders(SearchCriteria searchCriteria,int firstResult,int pageSize) {...} What about @ManyToMany Good question. In most cases I find that what starts as a many to many relationship can usually be modeled as a separate entity because when you create a many to many relationship, there is usually additional information stored with that relationship. For example, a Users and Groups ManyToMany relationship has many users belonging to many groups and vice versa. The membership however also probably has start and end dates and also maybe a role within that group. This also exhibits one of the earlier problems in that user.getGroupMemberships() would return all group memberships past and present whereas you probably only want the active ones. Modeling it as a separate entity means it becomes an entity with two OneToMany relationships. While there are cases where the many to many relationship is literally just a pair of ids (think blog post tags, many tags to many posts), you could benefit at a later date by using an entity if you decide to add additional information into the relationship. In summary, moving relational fetches out of the data model and into the data layer means you remove some of the temptations of bad practices and create a library of reusable functions for fetching the data that can be used from different code points. From http://www.andygibson.net/blog/article/deterring-tomany-relationships-in-jpa-models/
January 18, 2011
· 22,548 Views · 1 Like

Comments

Displaying Meaningful Error Messages when Auto Loading Classes in PHP 5

Feb 11, 2012 · Mr B Loid

Its a PITA to install on Ubuntu and there really isn't that much new stuff to get all excited about.

Cheers,

Andy

Refactor! For Visual C++ 2005

Mar 29, 2011 · Tony Thomas

Josh the benefits of qualifiers, or qualifiers with Enums is that you get type safety when defining injection points and items to be injected. You could just use named but thats just attaching an untype safe name to the bean.

I see what you are saying about having to drag external qualifiers in there, and I have two answers for that.

First the qualifier could be regarded as part of your object semantics, the SoapTransport class really is a @Transport and marking it with that qualifier is along the lines of implementing the Transport interface. Think about it, you don't need to implement the Transport interface, you do it to make it type safe and to take advantage of polymorphism. Likewise you add a qualifier to make it type safe and to take advantage of looking up beans of similar types but with different qualifiers (i.e. semantic polymorphism or something!)

We don't get rid of an interface to keep our objects pure when we only use one implementation of the interface (there are times we should but we don't always). Same way we don't throw out qualifiers just because we aren't always accessing the beans using the qualifier.

Second option is to can create your pure SoapTransport class with no CDI annotations and have a CDI aware transport factory with a method to create a SoapTransport that is annotated with @Produces @Transport(TransportType.SOAP) . You would have to build the instance (or get it from the CDI container) and return it.

However, you run into problems because if the SoapTransport class needs an xyz bean injecting into then its not going to happen automatically because you didn't define the injection point with @Inject because your bean knows nothing about CDI. At which point, you have to handle your own injection like you would if you had to define it in xml.

In this case CDI makes you do your manual injections in type safe code rather than in untype safe xml, usually with no code assist either.

Thanks for your thoughts, I think this is a good idea for a blog post.

CDI Dependency Injection - An Introductory Java EE Tutorial Part 1

Mar 29, 2011 · Rick Hightower

Josh the benefits of qualifiers, or qualifiers with Enums is that you get type safety when defining injection points and items to be injected. You could just use named but thats just attaching an untype safe name to the bean.

I see what you are saying about having to drag external qualifiers in there, and I have two answers for that.

First the qualifier could be regarded as part of your object semantics, the SoapTransport class really is a @Transport and marking it with that qualifier is along the lines of implementing the Transport interface. Think about it, you don't need to implement the Transport interface, you do it to make it type safe and to take advantage of polymorphism. Likewise you add a qualifier to make it type safe and to take advantage of looking up beans of similar types but with different qualifiers (i.e. semantic polymorphism or something!)

We don't get rid of an interface to keep our objects pure when we only use one implementation of the interface (there are times we should but we don't always). Same way we don't throw out qualifiers just because we aren't always accessing the beans using the qualifier.

Second option is to can create your pure SoapTransport class with no CDI annotations and have a CDI aware transport factory with a method to create a SoapTransport that is annotated with @Produces @Transport(TransportType.SOAP) . You would have to build the instance (or get it from the CDI container) and return it.

However, you run into problems because if the SoapTransport class needs an xyz bean injecting into then its not going to happen automatically because you didn't define the injection point with @Inject because your bean knows nothing about CDI. At which point, you have to handle your own injection like you would if you had to define it in xml.

In this case CDI makes you do your manual injections in type safe code rather than in untype safe xml, usually with no code assist either.

Thanks for your thoughts, I think this is a good idea for a blog post.

Beginning Windows Communication Foundation development, Part 3

Mar 20, 2011 · Tony Thomas

Hey Hank,

That would work except ViewScope isn't natively supported with CDI, plus it forces you to pass state around unnecessarily while my solution is stateless. The tradeoff being that every postback needs to re-generate the data in some form. You could determine on a case by case basis as to whether you want to store state in the view (i.e. you have lots of postbacks that don't change the data state) versus a page where every postback changes the state so it would need to be regenerated anyway.

Cheers,

Andy Gibson

Reporting bugs - a how-to guide

Mar 16, 2011 · Gerd Storm

Hey Rob,

Its not Java EE 6 that's problem, it's the archetype you're using. Just use my archetypes for Java EE 6, they work out of the box with JBoss and also with Glassfish if you change the JNDI name of the DB Connection in persistence.xml (there are instructions in there). They can also be deployed through Eclipse (I also use JBoss Tools).

There are also archetypes for using Jsf/Jpa/CDI in servlet containers such as Jetty and Tomcat which you can run using jetty:run or tomcat:run maven targets from the command line. I never tried them on those containers through the IDE to be honest.

The archetypes are in the central repository or you can use the latest version from github (https://github.com/andygibson/knappsack) in which I've also added a couple of Spring JSF/JPA archetypes. This version is going to get released to central in the next week.

Project page - http://www.andygibson.net/blog/projects/knappsack/

Cheers,

Andy

Simple RESTful web services with Glassfish

Feb 06, 2011 · mitchp

Hey Alexis, I do make the bean a stateless session bean as mentioned in item 1 just before the last piece of code. I also just added that last example at the end there to come up with something more useful than just returning a constant string based on the input parameters. Part 2 expands on all this a little more and uses other beans to handle the persistence.

Cheers,

Andy

50 Best Java Interview Questions

Jan 19, 2011 · Sandeep Bhandari

Not criticizing your response, just the original question, but how many jobs involve knowing the internal implementation of the HashTable? Isn't the whole point to black box this stuff so you don't need to know it? Bucketing is also applied to the Renderman implementation of the REYES algorithm or a bucket sort, both of which can be implemented in Java.
Visual C++ Futures

Jan 19, 2011 · Tony Thomas

This was already posted last July, and the Javalobby folks reposted it, not me ( I wish they would indicate when they auto-posted stuff, it would make me look a (little) less foolish).

Siva, I think programmers tend towards places like sourcefource and project kenai (ok, maybe not there) to search projects they are interested in. I think thats about the best fit for what you are seeking.

Forget Captcha images, try MathGuard 3.0 anti-spam

Jan 17, 2011 · Matej Koval

>You just admitted to having a short-sighted, high risk view on software.

Not at all since by the same measure, I also admitted to having a long-term low risk view on software with the next statement. It's a device often used in writing to show two different extremes before finding a happy mid-point .

> Ugh, I hate this statement

Universally, from the perspective of the customer (either buying or internal) sooner and ugly is better since they don't care about architecture. Try telling your boss that the project is complete and working but you want to take a couple of months to pretty up the internals with no benefit to the users, but it will make maintenance easier for you. Agile methodologies and Alpha/Beta tests talk about releasing early and often and getting things in front of users and I'm going to guess these aren't pristine versions.

The nice thing about the 90% maintenance is that you don't need to do it if your product bombs upon release to the public. Products are a short term high risk unless it is a foolproof idea with a 100% guaranteed chance of success.

For in-house projects where there is nothing but long term, you don't need to take a waterfall type approach to architecture where you need months or years to map out for every single potential change. The point of the article is that as long as you build it with a basic simple architecture, follow some good programming guidelines, you can get the code out faster with a good design that lends itself well to improvements making that 90% maintenance easier.

BangPypers + Bangalore RUG meeting on 11th Aug

Jan 13, 2011 · Sidu Ponnappa C, K,

>Definitely no.

More like definitely maybe, there is still plenty of things that can be done in the call backs such as auditing or triggering CDI events or JMS messages. Anything meatier than that really needs to be insome kind of business logic layer rather than tying it in with model callbacks.

Cheers,

Andy

Are the JPA callback methods useful?

Jan 13, 2011 · Javier Paniza

>Definitely no.

More like definitely maybe, there is still plenty of things that can be done in the call backs such as auditing or triggering CDI events or JMS messages. Anything meatier than that really needs to be insome kind of business logic layer rather than tying it in with model callbacks.

Cheers,

Andy

Go With Grails and NetBeans

Dec 22, 2010 · Mr B Loid

"and Spring/Hibernate/JSF on the server side"

Fixed it for you.

JRuby on Rails -- Performance

Oct 28, 2010 · Gerd Storm

Hey Oleg,

Yes, you can use the built in SelectManyCheckbox, but like the SelectOneRadio, it's limited in functionality and very limited in formatting since the components just get rendered one after the other. By rolling your own, you can apply all kinds of styling, putting them in columns, indenting certain ones, enabling/disabling items (which you could also do with SelectItem instances).

We've had a number of situations where the built-ins don't cut it, and the point is to show you how simple it is to reproduce this when you consider all the hacks you need to do to get the same effect in action frameworks.

Iterating over the keyset doesn't work, in your example, the value of #{entry} is the toString() of the map {Open=false, Closed=false, .....etc...etc...}.

I should have also noted that this technique is usable for the Radio buttons too.

Cheers,

Andy Gibson

Is Java Losing Appeal?

Oct 20, 2010 · Joseph Randolph

There's a shortage of Java Developers? ,
About Massachusetts...

Oct 19, 2010 · Stacy Doss

Some good points, although I think you are coming from the opposite point of view I usually come from. I tend to look at web frameworks for the purpose of thicker web-application type projects, not (high traffic) stateless restful web sites which you have been working on. For that reason, it's fairly easy to see why you would beturned off by state, conversations and JSF.

Aren't GWT, Wicket, and even JQuery frameworks among others a way to abstract Javascript from the developer? Should those developers not be allowed to write GUIs either? It's rather like saying people who use Delphi don't know how to use the Windows API and shouldn't be writing GUI's. Both statements are rather silly, I use JSF (and Delphi) to get GUI's up and running fast without having to fiddle with the internals of it. We don't all work on simple web sites where we can take the time to craft the few pages in excrutiating detail, we often have dozens or hundreds of forms that can be quickly produced working at a higher abstract.

Most of Spring's latest innovations haven't been in the core framework, they've done some good stuff recently in Spring MVC, but beyond that, Spring is still about attaching objects by name or simplistic type autowiring. Spring's latest works have been in providing the platform for it to run on which again, is good stuff. I wouldn't put too much literal weight in the "Age of Frameworks is over" statement, I think that it's indicative that Java EE 6 makes some big leaps to the point that it is very capable (although not perfect)

Andy

F# Web Toolkit: "Ajax" applications made simple

Oct 14, 2010 · Mr B Loid

>Having multiple implementations of Java EE and ME specs has been a Good Thing, why is SE different?

In theory it's a good thing, but then people turn around and whine that Java EE servers are not 100% compatible. For a server implementation it's one thing to have to tweak some configuration code to get it working, it's a whole other thing to have to modify your core source code because of JVM incompatabilities.

The further down the stack you go, the more solid, stable and dependable you want it. Having different JVM versions with their own quirks is not a world most people would want to develop in (See CSS incompatabilities for more details)

Cheers,

Andy

F# Web Toolkit: "Ajax" applications made simple

Oct 14, 2010 · Mr B Loid

>Having multiple implementations of Java EE and ME specs has been a Good Thing, why is SE different?

In theory it's a good thing, but then people turn around and whine that Java EE servers are not 100% compatible. For a server implementation it's one thing to have to tweak some configuration code to get it working, it's a whole other thing to have to modify your core source code because of JVM incompatabilities.

The further down the stack you go, the more solid, stable and dependable you want it. Having different JVM versions with their own quirks is not a world most people would want to develop in (See CSS incompatabilities for more details)

Cheers,

Andy

F# Web Toolkit: "Ajax" applications made simple

Oct 14, 2010 · Mr B Loid

>Having multiple implementations of Java EE and ME specs has been a Good Thing, why is SE different?

In theory it's a good thing, but then people turn around and whine that Java EE servers are not 100% compatible. For a server implementation it's one thing to have to tweak some configuration code to get it working, it's a whole other thing to have to modify your core source code because of JVM incompatabilities.

The further down the stack you go, the more solid, stable and dependable you want it. Having different JVM versions with their own quirks is not a world most people would want to develop in (See CSS incompatabilities for more details)

Cheers,

Andy

F# Web Toolkit: "Ajax" applications made simple

Oct 14, 2010 · Mr B Loid

>Having multiple implementations of Java EE and ME specs has been a Good Thing, why is SE different?

In theory it's a good thing, but then people turn around and whine that Java EE servers are not 100% compatible. For a server implementation it's one thing to have to tweak some configuration code to get it working, it's a whole other thing to have to modify your core source code because of JVM incompatabilities.

The further down the stack you go, the more solid, stable and dependable you want it. Having different JVM versions with their own quirks is not a world most people would want to develop in (See CSS incompatabilities for more details)

Cheers,

Andy

It's time to set Java free.

Oct 02, 2010 · Joseph Ottinger

And how long was he at Sun during which time they also didn't make Java free? I didn't see any T-Shirts with Johnathan Schwartz on, by him or anyone else until he found his conscience as part of his severance from Oracle. The last people who should be directing what Oracle does with Java would be the people that drove the company to the point of needing a buyout. ,
5 Problems of the Semantic Web

Sep 22, 2010 · James Simmons

Hey Rob,

Weld doesn't implement Persistence Context injection, that is a feature of the container. There is support for persistence contexts if you are testing in the container, especially if you are testing using full blown EJBs which have their PCs injected by the container. I have no idea why the reference documentation shows that there is no persistence context injection in any container, and can only think that they haven't kept that part of the documenation up to date (Arquillian is still under development).

Weld isn't responsible for managing and injecting persistence contexts, either the container is or you are if you are testing in a servlet container or on an SE environment.In the demos I wrote (that I know you have seen) I produce the persistence context manually and inject it using a regular @Inject point.

Cheers,

Andy

Groovy is Seamed

Sep 05, 2010 · Mr B Loid

Apart from legacy apps already using this, there should be no need for the Woodstock stuff, or even the Visual Web Pack. It's just not how you need to write JSF web applications.

Django Hosting

Sep 05, 2010 · Christopher Penkin

Sweet Golly Rockets that looks awesome. I really wish I had some reason to get into the Netbeans platform.

Fun projects are on the back burner for a while

Cheers,

Andy Gibson

Is Scala the new Groovy?

Aug 24, 2010 · Mr B Loid

Jacek, it is possible to set the converter for a specific type (ie. some BaseEntity class) so you don't need to specify it. This requires just the converter above and a line of configuration code to achieve exactly what you are referring to.

Should such functionality be included from the get-go? It raises questions about how does the converter know which database connection it should be using to fetch the entity, or whether it should be using a pre-fetched cached list of entities for the lookup instead, or even a non-persisted list of objects. There is also the problem of making JSF dependent on a persistence library. Converters with injection also makes it dependent on the CDI API. When you end up with JSF that depends on JPA and CDI, you aren't far from someone complaining that its wrong to have such dependencies and will start calling it heavyweight.

I agree that JSF 2.0 still doesn't hit the mark with regards to having smarter converters (or validators) with resources injected into them. Converters with Injection for me is the sweet spot that lets me easily define what I want to do without defining it for me and making me go around the default when I don't need it.

Cheers,

Andy Gibson

Is Scala the new Groovy?

Aug 24, 2010 · Mr B Loid

Jacek, it is possible to set the converter for a specific type (ie. some BaseEntity class) so you don't need to specify it. This requires just the converter above and a line of configuration code to achieve exactly what you are referring to.

Should such functionality be included from the get-go? It raises questions about how does the converter know which database connection it should be using to fetch the entity, or whether it should be using a pre-fetched cached list of entities for the lookup instead, or even a non-persisted list of objects. There is also the problem of making JSF dependent on a persistence library. Converters with injection also makes it dependent on the CDI API. When you end up with JSF that depends on JPA and CDI, you aren't far from someone complaining that its wrong to have such dependencies and will start calling it heavyweight.

I agree that JSF 2.0 still doesn't hit the mark with regards to having smarter converters (or validators) with resources injected into them. Converters with Injection for me is the sweet spot that lets me easily define what I want to do without defining it for me and making me go around the default when I don't need it.

Cheers,

Andy Gibson

Is Scala the new Groovy?

Aug 24, 2010 · Mr B Loid

Jacek, it is possible to set the converter for a specific type (ie. some BaseEntity class) so you don't need to specify it. This requires just the converter above and a line of configuration code to achieve exactly what you are referring to.

Should such functionality be included from the get-go? It raises questions about how does the converter know which database connection it should be using to fetch the entity, or whether it should be using a pre-fetched cached list of entities for the lookup instead, or even a non-persisted list of objects. There is also the problem of making JSF dependent on a persistence library. Converters with injection also makes it dependent on the CDI API. When you end up with JSF that depends on JPA and CDI, you aren't far from someone complaining that its wrong to have such dependencies and will start calling it heavyweight.

I agree that JSF 2.0 still doesn't hit the mark with regards to having smarter converters (or validators) with resources injected into them. Converters with Injection for me is the sweet spot that lets me easily define what I want to do without defining it for me and making me go around the default when I don't need it.

Cheers,

Andy Gibson

Is Scala the new Groovy?

Aug 24, 2010 · Mr B Loid

Jacek, it is possible to set the converter for a specific type (ie. some BaseEntity class) so you don't need to specify it. This requires just the converter above and a line of configuration code to achieve exactly what you are referring to.

Should such functionality be included from the get-go? It raises questions about how does the converter know which database connection it should be using to fetch the entity, or whether it should be using a pre-fetched cached list of entities for the lookup instead, or even a non-persisted list of objects. There is also the problem of making JSF dependent on a persistence library. Converters with injection also makes it dependent on the CDI API. When you end up with JSF that depends on JPA and CDI, you aren't far from someone complaining that its wrong to have such dependencies and will start calling it heavyweight.

I agree that JSF 2.0 still doesn't hit the mark with regards to having smarter converters (or validators) with resources injected into them. Converters with Injection for me is the sweet spot that lets me easily define what I want to do without defining it for me and making me go around the default when I don't need it.

Cheers,

Andy Gibson

Is Scala the new Groovy?

Aug 24, 2010 · Mr B Loid

My apologies, I should have written that a little better,yes, it is all just JSF 2 code.

Seam 2 has a tag for converting entities, with Seam Faces in Seam 3 you can write your own in a few lines of code. In Seam 2 and Java EE 5, there was no easy way to inject dependencies into converters so it was a bigger deal.

Cheers,

Andy Gibson

plainTemplate & phpQuery

Jul 31, 2010 · Mr B Loid

You mean as part of a query? It is handled the same way Hibernate or JPA or JDBC woudl handle it :

addRestriction("endDate is null"); 

The restrictions can consist of any old query restriction that the underlying data provider (hibernate, JPA, JDBC) can understand. DataValve itself doesn't do anything with the query, it just passes it on to JDBC or the JPA framework. DataValve just (optionally) takes out pieces of the query for you when the parameter is null.

Cheers,

Andy Gibson

"NetBeans is a Vastly Superior IDE"

Jun 07, 2010 · mitchp

I find Eclipse in general to be faster and stall less, however, it can have problems with plugins, but if you go with a fixed stack, I generally don't have any problems. I've been using JBoss Developer Tools plugins on a clean Eclipse install for Java EE 6 CDI, JSF, JPA development and am loving it.
Rules of Thumb: Don't Use the Session

Feb 17, 2010 · James Sugrue

The arguments for stateless design delivers a great message, it just doesn't apply in a lot of cases and practical alternatives are needed. The database just moves your bottleneck to the least scalable tier and people try and introduce caches which are little more than a custom version of the session that still need some kind of replication and management. Using hidden fields and parameters means you have to (or should) re-validate everything you get back from the client and leads to ugly urls or postback only forms.

Conversations in Seam and now CDI are a great way to introduce temporal sessions. Ideally, we'd be able to have state held in a bean that somehow moved itself out of memory and into a more permanent storage if it hadn't been used for a while and/or the server needed the memory for something else and automatic replication might be nice too. Hey maybe we can use those new fangled Stateful EJBs people have been talking about and everyone keeps wondering why they are still around?

Php-Stats SQL Injections and PHP Code Execution

Jan 10, 2010 · Lebon Bon Lebon

Weld, the CDI implementation used in Glassfish, doesn't quite work right with asynchronous timer services. When the method is called by the timer service the required contexts aren't active and it causes an error. The JIRA issue is here.

How to Create a Scheduler Module in a Java EE 6 Application with TimerService

Jan 10, 2010 · Geertjan Wielenga

Weld, the CDI implementation used in Glassfish, doesn't quite work right with asynchronous timer services. When the method is called by the timer service the required contexts aren't active and it causes an error. The JIRA issue is here.

HTML Mastery (Book review)

Dec 16, 2009 · Mr B Loid

BTW, as a side note, is it me or does that link to the Eclipse Modelling Project send you to pages filled with techno babble? Most people looking for modelling stuff just want to go install the visual modelling editor and model entities. Instead, they are subject to statements like :

"The Eclipse Modeling Project focuses on (...) model-based development technologies (...) by providing a unified set of modeling frameworks, tooling, and standards implementations."

Where is the screenshot like the one in the original post showing fancy diagrams and a big link saying "Download Now".

I had no idea that the modelling piece was called ECore until I re-read the original post. Instead, when I go to the download page for the "Eclipse Modelling Tools" it is described as

"This modeling package contains a collection of (..) components, including EMF, GMF, MDT XSD/OCL/UML2, M2M, M2T, and EMFT elements"

Umm, still no mention of the magic words, visual model editor. Granted, EMT is probably a bigger library than just the editor, but Netbeans has a whole big visual library that you can use (maven dependencies and uml diagramming are two uses that come to mind) but I can still go into netbeans, go to Tools->Plugins, click the available plugins tab, select UML Modelling and install it (well, I could do but not under 6.8!)

HTML Mastery (Book review)

Dec 16, 2009 · Mr B Loid

I find that there is no easy winner when comparing Netbeans and Eclipse. I still find Netbeans to be slow and inaccurate in things like auto completion (especially for HTML/ XML), but at least I can edit those documents in Netbeans unlike Eclipse which doesn't provide any help for editing XHTML (it's only been a defacto and now current standard for JSF for a few years) without renaming files. Netbeans is up to date for the Enterprise with Java EE 6 support (including EE maven support) and Netbeans has good maven and groovy support. It also has 2 way UML plugins for MDA development, online updating and module installation which is better I find than the fine grained Eclipse version. Eclipse is fairly useless until you start adding plugins and you need to add them for everything like subversion, maven, or issue tracking software integration. Netbeans does come with a fairly large set of features by default (I know, some people dislike that and would call it useless bloat).

However, I find Eclipse has much better performance as I use it, auto completes come up quicker and are more useful. I can't get custom DTDs to pop up for things like docbook documents even if I add them to Netbeans. I find the Netbeans keyboard shortcuts to be horrible such as not using the standard ctrl+space to bring auto-completion, or pressing Alt+F and then C closes the project instead of the currently active document. Plus, JBoss Tools for eclipse is a great JSF editor and Seam IDE in Eclipse.

I think Netbeans probably wins on the bigger features (I don't know about Mylyn), partially because it is all much easier to install and get working together without having to worry about missing plugins. Eclipse wins on performance and getting the basics more correct but not perfect.

Like many choices in Java, it's a matter choosing the least offensive.

Has open source lost its halo?

Nov 03, 2009 · Mr B Loid

Glassfish will preserve session state across redeployments, here is a link showing it in action in a similar situation you are talking about.

Has open source lost its halo?

Nov 03, 2009 · Mr B Loid

Glassfish will preserve session state across redeployments, here is a link showing it in action in a similar situation you are talking about.

Has open source lost its halo?

Nov 03, 2009 · Mr B Loid

Glassfish will preserve session state across redeployments, here is a link showing it in action in a similar situation you are talking about.

Has open source lost its halo?

Nov 03, 2009 · Mr B Loid

Glassfish will preserve session state across redeployments, here is a link showing it in action in a similar situation you are talking about.

Has open source lost its halo?

Nov 03, 2009 · Mr B Loid

Glassfish will preserve session state across redeployments, here is a link showing it in action in a similar situation you are talking about.

Has open source lost its halo?

Nov 03, 2009 · Mr B Loid

Glassfish will preserve session state across redeployments, here is a link showing it in action in a similar situation you are talking about.

Has open source lost its halo?

Nov 03, 2009 · Mr B Loid

Glassfish will preserve session state across redeployments, here is a link showing it in action in a similar situation you are talking about.

Has open source lost its halo?

Nov 03, 2009 · Mr B Loid

Glassfish will preserve session state across redeployments, here is a link showing it in action in a similar situation you are talking about.

Has open source lost its halo?

Nov 03, 2009 · Mr B Loid

Glassfish will preserve session state across redeployments, here is a link showing it in action in a similar situation you are talking about.

Has open source lost its halo?

Nov 03, 2009 · Mr B Loid

Glassfish will preserve session state across redeployments, here is a link showing it in action in a similar situation you are talking about.

Has open source lost its halo?

Nov 03, 2009 · Mr B Loid

Glassfish will preserve session state across redeployments, here is a link showing it in action in a similar situation you are talking about.

Has open source lost its halo?

Nov 03, 2009 · Mr B Loid

Glassfish will preserve session state across redeployments, here is a link showing it in action in a similar situation you are talking about.

Has open source lost its halo?

Nov 03, 2009 · Mr B Loid

Glassfish will preserve session state across redeployments, here is a link showing it in action in a similar situation you are talking about.

Has open source lost its halo?

Nov 03, 2009 · Mr B Loid

Glassfish will preserve session state across redeployments, here is a link showing it in action in a similar situation you are talking about.

Has open source lost its halo?

Nov 03, 2009 · Mr B Loid

+1 for Glassfish v3 - I was blown away by the way it redeploys modified code (EJB and Pojos) in both Eclipse and Netbeans just by using it the same way you would use any server in those IDEs. Amazing Stuff.

JavaMail Client on the NetBeans Platform (Step 1)

Aug 25, 2009 · Mr B Loid

Another in a good set of articles, although I'm afraid my answer on this one is not to use BiDirectional associations except for the rare limited cases. Typically, if I want to display the orderLines in an order, since there could be hundreds, I probably want to order and paginate them. For this reason, I mostly use separate queries to fetch items rather than rely on the JPA implementation to fetch them in a lazy/non lazy/partially lazy fashion and then figure out how to order them. This way I can also add on filters to show only order Items that were unfulfilled or whatever without having to load the whole set and then start filtering from there.

Cheers,

Andy

Upcoming CSS3 support in Opera - Slightly ajar - by David Storey

Aug 06, 2009 · Schalk Neethling

Just out of interest, in terms of general development infrastructure, what about backup of at least the Subversion repositories? Personally, I've been using online subversion repos more and more as it lets me access work from anywhere, and someone else is (I hope) taking care of backups (hourly in my case).

Cheers,

Andy Gibson

PHPsimple : Export MySQL to Excel

Jun 17, 2009 · Lebon Bon Lebon

This rather seems like responding to a complaint that a car doesn't go very fast by lecturing that nobody should be driving over 60mph. While that is usually true, it doesn't excuse a car not being able to go 80mph because of a faulty design or implementation. There are valid times in the real world when you want to deploy a project containing broken code, after all, nobody said it had to be deployed into production.

If this is the way Tapestry must work, then fine, if not, how about a configuration setting to allow broken deployments. Either way, lets not sidestep the issue by questioning the professionalism or integrity in those that dare not like it, and dressing it up as a an advantage to 'keep you legal' .

Scrum in a Nutshell or 5 minutes to learn scrum

Mar 18, 2009 · Mark Levison

This is like bizarro world. Since when did bonuses to execs become such an offence. The AIG scandal is due to the fact that the bonuses are being paid out on the back of AIG receiving billions in tax payers money as part of a misguided bailout package/ lobbyist pay off without transparency, oversight or consideration of how the money is spent. Chris Dodd (D- Conneticut) even added bonus protections to the bill that passed and the rest of them signed off on it. Not surprisingly, Obama and Dodd were the largest recipients of camipaign donations from AIG at over $100,000 each (at least AIG got their money's worth).

While everyone is getting upset over the 167 Million (with an M) paid out in bonuses, nobody is saying a word about the 93 Billion (with a B) that AIG sent out to foreign banks in Britain, France and Germany among others.

Back to the case in point, whether or not Sun gives execs bonuses is up to them since they aren't backed by tax payer money, and it would be of concern to the board of directors and shareholders. Even then, since people willingly bought stock, and held on to it, at least nobody is twisting their arm unlike AIG's money which was taken from taxpayers at gunpoint.

Similarly, I suppose that since over half the country voted in Obama, they have no reason to complain how he runs the country either.

Before you Learn Rails

Jan 15, 2009 · Mr B Loid

Let's look at this from a two angles though, there's a cool place to work where it's all ping pong tables, afghan rugs, 24 hour snack service delivery, free crack, and as much gaming as you can handle compared to drab offices, cubes, flourescent lights, and daily TPS reports. Then there is the wow factor of working somewhere where simply being an employee of a company was somewhat of a status symbol.

Taking over from IBM, Microsoft started the new wave of developer coolness in both terms along with many others in silicon valley, but now I think the mantle has passed on to Google. Does saying you work for Microsoft have the same coolness factor as it had around 2000? Google appears to be where the smart heads are as one ex-Microsoft, then Google employee noted in 2005-ish, "Google uses Bayesian filtering the way Microsoft uses the if statement". When you consider the lawsuits over the years, the open source phenomenon that Microsoft has been against, still charging $200 for a new OS with $10 of new features, the embarassments of Steve Ballmer, the problems of Vista, Microsoft has hardly endeared themselves to their customers, or developers. This is also why I'm a Java developer using Ubuntu (since MSFT were "unable" to port .net 3.0 back to Win2K). So from a status position, I think Microsoft has come down the ladder a few rungs.

Nevertheless, I'm sure Microsoft still has all the cool gee whiz physical elements in the work place that IBM doesn't have, and google does have,even if they weren't that visible in the offices you saw. However, I'm sure that Redmond still has all the fun stuff that they probably can't put in all their remote offices.

IT's all good

Dec 19, 2008 · Mr B Loid

Yes, thanks, that's what I was referring to. I'm mostly using Seam with JBoss Tools right now, and there is a great deal of difference between the JBoss Tools JSF stuff and the Netbeans JSF editor. I don't really see why there needs to be any kind of tie-in as it would seem to be more work to create a highly integrated jsf editor than one that could be used with any framework (Seam/Spring/pojo backing beans). I supposed they were going for the asp.net type feel with page events and automatically binding the components to the component references in the backing bean.

The JBoss Tools are a great example of how decoupled a JSF editor should be from a framework. Sure, it is tied to Seam, but not tightly. I would imagine that the only missing piece to get it working with Spring would be a design time variable resolver to offer suggestions for spring bean names and validators to check for errors.

I personally don't care too much about the WYSIWYG aspect, I use it as a rough guide to see if things are in place, but apart from that I'm more interested in writing by hand and using good code-completion to help with typing bean names and properies (helps reduce typos).

How are you finding JBoss Tools with Spring Web Flow? It's been a while since I used to two together, but I'm looking at starting a new project with it, so I'm curious if there are any good advances in Spring + Web Flow + JSF tools?

Cheers,

Andy Gibson

IT's all good

Dec 18, 2008 · Mr B Loid

My understanding of things, which may be quite out of date regarding JSF + Netbeans, is that the real problem is how Netbeans has approached the whole issue editing JSF pages. Despite JSF being a standard, the visual editor required the application, in particular the backing beans, to take a particular structure in order to work with the editor. If they had taken a more generic approach, i.e. one that followed the standards only, then developers could install any kind of jsf component framework and use the editor without any problems.

The only requirement the Netbeans JSF editor should impose is needing a plugin for the editor to be made aware of backing beans from different frameworks (i.e. Spring, Seam, Spring Web Flow) for code completion of El Expressions (like some kind of design time variable resolver). Beyond that the editor should be able to use any jsf components installed on pages that hookup to arbitrary backing beans that don't require specific hierarchy. The editor itself should be nothing more than a JSF editor that uses the plugins to determine El expressions for code completion.

I may be wrong, and that may be where netbeans is, I would be delighted to be wrong and find that Netbeans supports plain jsf editing with El auto completion for spring beans etc..However, I would prefer a more generic JSF editor which might not have so many complex functions built against one framework than one with deep integration that is very restrictive on what and how I can develop.

It seems this news means that the netbeans team have bound themselves (and their developers) to Icefaces this time instead of Woodstock.

How to: Execute (another's class) private methods

Oct 31, 2008 · admin

I'd actually disagree with point number 4. I realize that this is from 7 years ago and times have changed, but..

You are looking at problems of web development from a client/front end scenario with tabs and tables. Coming from thick client/ Delphi software development background, my problem was relating to the statelessness of the web. For example, to create a widget editing wizard, I would expect a solution to be able to provide (at least the illusion of) state without having to reload data each trip to the server and remember the values I had entered 2 wizard pages ago. There are all sorts of problems that crop up for state in a full blown web application such as handling multiple browser windows editing the same entity type without having same named values in the session overwritten or ending up with huge user sessions.

While it is possible to come up with some lightweight fixes for some of this stuff, I think needing a sturdy and scalable backend makes web development all the more difficult. Only now with Seam and Spring Web Flow are we seeing solid framework based solutions to these problems.

Comparatively, with Swing or a thick client alternative, I think it is easier to come up with a 'back end' given that a thick client can handle it's own business layer locally, or use a remote one, even using frameworks like Spring on the desktop to make it easier. State is held locally, I can just grab an entity, fiddle with it, edit it, and save it.It gives developers more time to focus on the user experience and putting the rich (even filthy rich) into the client.

In general, I find web application development feels like some big Rube Goldberg machine with all these distributed pieces where you can't really see the whole, and if just one small thing isn't in place the whole thing fails, usually with some giant stack trace but no comprehensive error message.

FoxTrot Programming (cartoon)

Aug 28, 2008 · admin

John, when do you really need to use Spring? It doesn't really offer you anything you can't do yourself. The only difference with EJB really is that the the whole package is bundled together unlike spring where you can modularize the pieces (i.e. not include transaction management).

I've included more thoughts on the EJB vs Spring fan base in this blog post.

Overall, there is really very little difference in this day and age, it all just depends on what you consider important.

EJB 3.0 and Spring 2.5

Aug 28, 2008 · Meera Subbarao

John, when do you really need to use Spring? It doesn't really offer you anything you can't do yourself. The only difference with EJB really is that the the whole package is bundled together unlike spring where you can modularize the pieces (i.e. not include transaction management).

I've included more thoughts on the EJB vs Spring fan base in this blog post.

Overall, there is really very little difference in this day and age, it all just depends on what you consider important.

Ease of Use Shouldn't Neuter Products

Jul 16, 2008 · Pete Moore

Slava, I agree with just about everything you wrote except for " I feel for book publishers. ", at least as far as O'Reilly is concerned.

The problems you describe are just as applicable to the Open Source developers O'Reilly wishes we all were and more so. Once we give our products away, and start the consulting services to pay the pays, we suddenly need to know far more than just the problem domain our project involved. The Hibernate or the Wicket team can't just focus on persistence or the view layers that their projects involve, suddenly, they need to be fully knowledgeable in all the other technologies to provide those services.

O'Reilly has hammered on for years advocating open source and the notion that commercial licenses don't work, while at the same time keeping his own books closed source. More open source applications, libraries and tools means a wider adoption and a bigger customer base for O'Reilly.

Back to the original point, Web 2.0 was obviously not the first time O'Reilly advocated ideas and concepts to sell books.

Mongrel 0.3.13.4 for UNIX released

Jun 18, 2008 · Dieter Komendera

I was going from my Seam experiences and reading on the forums posts from users who were trying to use the embedded JBoss container in Tomcat to run EJB Seam applications. It seemed rather complex at the time and people were running into problems.

You could be right in that it just takes adding OpenEJB to the project to test the EJBs, I haven't really looked at it closely to be honest, but that is good news.

Cheers,

Andy Gibson

Mongrel 0.3.13.4 for UNIX released

Jun 17, 2008 · Dieter Komendera

[quote=fabriziogiudici]

I agree on that too. But, for instance, I have seen people to whom I've presented both technologies and were much more attracted by EJBs (in spite of my light/medium Spring bias) where "things just work" and you don't have to set up a handful of beans for the TX manager etc... Which is not an argument to me, I mean the thing is apparently more complex, but once you learn it you make it work forever, but everybody has his own perspective on this.

[/quote]

You know that is a good point. I remember looking at the Spring MVC step by step tutorial. The first few installments were all XML and setting up the environment! It can be somewhat daunting at first but step by step you can get there. I guess developers like quick results, but many developers should, after time, start to wonder how things work under the hood, and with Spring, things are a little more obvious and don't include a huge 'black box' container. Even the spring container is simple to comprehend and it seems quite obvious how the Bean factory might work based on the XML you write.

Also, as an unrelated point, the other thing I don't like about EJB is that it isn't at all simple to use your EJBs in desktop apps unlike Spring Beans.

Mongrel 0.3.13.4 for UNIX released

Jun 17, 2008 · Dieter Komendera

[quote=fabriziogiudici]

I agree on that too. But, for instance, I have seen people to whom I've presented both technologies and were much more attracted by EJBs (in spite of my light/medium Spring bias) where "things just work" and you don't have to set up a handful of beans for the TX manager etc... Which is not an argument to me, I mean the thing is apparently more complex, but once you learn it you make it work forever, but everybody has his own perspective on this.

[/quote]

You know that is a good point. I remember looking at the Spring MVC step by step tutorial. The first few installments were all XML and setting up the environment! It can be somewhat daunting at first but step by step you can get there. I guess developers like quick results, but many developers should, after time, start to wonder how things work under the hood, and with Spring, things are a little more obvious and don't include a huge 'black box' container. Even the spring container is simple to comprehend and it seems quite obvious how the Bean factory might work based on the XML you write.

Also, as an unrelated point, the other thing I don't like about EJB is that it isn't at all simple to use your EJBs in desktop apps unlike Spring Beans.

Mongrel 0.3.13.4 for UNIX released

Jun 17, 2008 · Dieter Komendera

[quote=fabriziogiudici]

I agree on that too. But, for instance, I have seen people to whom I've presented both technologies and were much more attracted by EJBs (in spite of my light/medium Spring bias) where "things just work" and you don't have to set up a handful of beans for the TX manager etc... Which is not an argument to me, I mean the thing is apparently more complex, but once you learn it you make it work forever, but everybody has his own perspective on this.

[/quote]

You know that is a good point. I remember looking at the Spring MVC step by step tutorial. The first few installments were all XML and setting up the environment! It can be somewhat daunting at first but step by step you can get there. I guess developers like quick results, but many developers should, after time, start to wonder how things work under the hood, and with Spring, things are a little more obvious and don't include a huge 'black box' container. Even the spring container is simple to comprehend and it seems quite obvious how the Bean factory might work based on the XML you write.

Also, as an unrelated point, the other thing I don't like about EJB is that it isn't at all simple to use your EJBs in desktop apps unlike Spring Beans.

Mongrel 0.3.13.4 for UNIX released

Jun 17, 2008 · Dieter Komendera

The fact that they are written as POJO's doesn't invalidate the fact that on the server, they are still EJBs. They exhibit the same characteristics and can be used in the same way that EJBs have always been used.

One could just as easily ask why they are called Spring Beans when they are POJOs.

Mongrel 0.3.13.4 for UNIX released

Jun 17, 2008 · Dieter Komendera

The fact that they are written as POJO's doesn't invalidate the fact that on the server, they are still EJBs. They exhibit the same characteristics and can be used in the same way that EJBs have always been used.

One could just as easily ask why they are called Spring Beans when they are POJOs.

Mongrel 0.3.13.4 for UNIX released

Jun 17, 2008 · Dieter Komendera

The fact that they are written as POJO's doesn't invalidate the fact that on the server, they are still EJBs. They exhibit the same characteristics and can be used in the same way that EJBs have always been used.

One could just as easily ask why they are called Spring Beans when they are POJOs.

Mongrel 0.3.13.4 for UNIX released

Jun 17, 2008 · Dieter Komendera

The fact that they are written as POJO's doesn't invalidate the fact that on the server, they are still EJBs. They exhibit the same characteristics and can be used in the same way that EJBs have always been used.

One could just as easily ask why they are called Spring Beans when they are POJOs.

Mongrel 0.3.13.4 for UNIX released

Jun 17, 2008 · Dieter Komendera

The fact that they are written as POJO's doesn't invalidate the fact that on the server, they are still EJBs. They exhibit the same characteristics and can be used in the same way that EJBs have always been used.

One could just as easily ask why they are called Spring Beans when they are POJOs.

Mongrel 0.3.13.4 for UNIX released

Jun 17, 2008 · Dieter Komendera

The fact that they are written as POJO's doesn't invalidate the fact that on the server, they are still EJBs. They exhibit the same characteristics and can be used in the same way that EJBs have always been used.

One could just as easily ask why they are called Spring Beans when they are POJOs.

Mongrel 0.3.13.4 for UNIX released

Jun 17, 2008 · Dieter Komendera

The fact that they are written as POJO's doesn't invalidate the fact that on the server, they are still EJBs. They exhibit the same characteristics and can be used in the same way that EJBs have always been used.

One could just as easily ask why they are called Spring Beans when they are POJOs.

Mongrel 0.3.13.4 for UNIX released

Jun 17, 2008 · Dieter Komendera

The fact that they are written as POJO's doesn't invalidate the fact that on the server, they are still EJBs. They exhibit the same characteristics and can be used in the same way that EJBs have always been used.

One could just as easily ask why they are called Spring Beans when they are POJOs.

Mongrel 0.3.13.4 for UNIX released

Jun 17, 2008 · Dieter Komendera

As someone has already stated, Spring is a container, a proprietary one at that, and you still have to lug it around and initialize it in all your applications whether on the server, desktop, or in testing. Now initializing the Spring container is relatively simple, but there are embedded EJB implementations (albeit probably more complex) that you can use for testing.

Also, the one thing not really mentioned here is that EJB lets you have state on the server side. Yes, there is the Session, but that is fraught with dangers when you take replication, the lack of dirty checking and the issue of immutable versus mutable objects. There is the option of writing to the DB, but can soon become a bottleneck. Yes, you can throw a cache in there, but then you end up with having state on the server which is the same thing that was objected to with EJBs.

Spring pushed for a stateless architecture for years, and then ajax came along and the need for stateful bean management and they are introducing the concept of state with Spring Web Flow. If you are writing an online store and can put everything in a session scoped shopping cart and user account, then great, but most applications run a little more complex than that.

I've seen plenty of hacks and bad solutions to the state management problem, and people seem to shun a real solution to the problem because of 'overhead' which they fear like they have to give a pint of blood for every extra few meg of 'overhead' that is sitting there doing nothing.

Fabrizio is right though, the two are merging so close it is almost a pointless debate. The EJB servers are becoming more modular and giving you the option to only include services that you need. Furthermore, if it becomes a Web Beans world, then it will no longer be a question of whether you use Spring or EJB. It will be a question of whether you use an EJB or Spring (or other) implementation of Web Beans. Which raises the question of what that means for Spring long term in a Web Beans world when developers no longer use the proprietary Spring syntax and opt for the standard Web Beans syntax.

As an aside, the one thing I do like about Spring is the transparency of the setup. I deploy to an EJB container and "somehow" my calls are wrapped in transactions. With Spring I set up a transaction manager and apply transactions to calls using AOP. Spring does give you a feeling of being more in control at the expense of having to set everything up yourself. Might be nice to have an EJB server which is as transparent in terms of the implementation of its services (I'm no expert, so there may well already be one!)

PathsBuildProvider

Apr 08, 2008 · Michal Talaga

One could also note that Spring (and .net) has not really detracted from EJB's numbers either. One possible conclusion is that many jobs are including both items in job descriptions. Either that or Java demand is going through the roof to support the number of jobs for EJB & the jobs for Spring vs. the jobs for Spring & EJB.

I think Spring is also seeing some use outside of J2EE, I've used it for a couple of little command line apps, one of which I used to demonstrate the benefits of IoC. I haven't seen any other IoC containers work quite so well (or at all) in Java SE. It appears Web Beans is going to be J2EE only also which is a shame.

Ajax/Javascript Library - DHTMLGoodies

Apr 07, 2008 · Bernhard Kappe

www.itjobswatch.co.uk might be a good source for UK jobs.

It shows a current decline of Java over .net, not sure about longer term declines (and since I'm at work, I'm not going to look right now either ;-)

I'm more concerned about the lack of Seam & JSF jobs. Having come from a career in Delphi, I've spent most of my time using superior technology for which there was no jobs market. I don't wish to make the same mistake as I move over to Java.

However, the intent of the linked original post was really quite misleading as I'm sure they knew as they were careful enough not to come out with a deceptive statement and hoped that the charts with downard lines for Java and upward lines for Ruby would carry their deception for them.

Regardless, I still see .net adoption picking up, and the jobs numbers following. Consider the chart included above. Java had twice as many jobs as .net 18 months ago and now the lead has narrowed to 50%.

From itjobswatch.co.uk, .net has a slight edge over Java.

Setting Up Transactional Replication with SQL Server 2005

Apr 01, 2008 · Lebon Bon Lebon

Rod is probably partly right, but for the wrong reasons. Consider the lineage of standard J2EE persistence. We had EJB CMP which was a mess, then Hibernate came along, then iBatis et al, and now we have a new standard with JPA which serves to encapsulate the ideas and concepts that came before it. Now JPA 2.0 should fill in the holes with things like criteria queries.

Now look at EJB itself, we had EJB 2.1 which was a mess, then Spring came along, then Guice, Seam, even web frameworks started implementing dependency injection. For EJB, the first step back on the right path was EJB 3.0, and now we have a new standard coming up with web beans that will again encapsulate a lot of the ideas that came before it.

I see web servers evolving the same way. We have Tomcat and full blown J2EE app servers which will then evolve into modular servers where you can use either the lightweight web beans container, or switch to the more heavyweight EJB driven web beans implementation.

While Spring in itself may be simple, it does nothing to reduce the complexity of the Java platform itself. Rather than have one fixed framework as a standard (a la Ruby on Rails, PHP, asp.net) , java chooses to have a set of multiple frameworks and while each one may be simple in nature, their existence introduces complexity into the Java ecosystem.

Ruby on Rails Model Based Validators

Mar 16, 2008 · Xelipe Zone

"70% of H1-Bs are going to indian companies based in the US"


Sorry, that should be 1/3 of H1-Bs are going to Indian companies in the US. 70% of H1B recipients are from India.

Ruby on Rails Model Based Validators

Mar 16, 2008 · Xelipe Zone

"70% of H1-Bs are going to indian companies based in the US"


Sorry, that should be 1/3 of H1-Bs are going to Indian companies in the US. 70% of H1B recipients are from India.

Ruby on Rails Model Based Validators

Mar 16, 2008 · Xelipe Zone

"70% of H1-Bs are going to indian companies based in the US"


Sorry, that should be 1/3 of H1-Bs are going to Indian companies in the US. 70% of H1B recipients are from India.

Ruby on Rails Model Based Validators

Mar 16, 2008 · Xelipe Zone

"70% of H1-Bs are going to indian companies based in the US"


Sorry, that should be 1/3 of H1-Bs are going to Indian companies in the US. 70% of H1B recipients are from India.

Ruby on Rails Model Based Validators

Mar 16, 2008 · Xelipe Zone

The answer to the H1B problem is simple, make sure any h1B worker is paid $200,000 or more, and you can bet that home-grown labour will magically appear, and US based business will be falling over themselves to hire, train, and retain perfectly good candiates.

boss would like to ship your job overseas and lay you off. If that can't be done, she'd like to bring in somebody on an H1-B who will work more cheaply than you.

Indian shops are now setting up in the US, placing fake job ads and then bringing in Indians on H1Bs, keeping them shacked up in houses with 3 to a room, and ferrying them to and from the office for 12 hour work stretches. There is no longer any need to outsource since we have brought the cheap labour in-country. 70% of H1-Bs are going to indian companies based in the US so they can bring cheap labour here instead of sending the work over there.

The 'tight' job market is a sham, fueled by fake job adverts, and unsrcupulus practices.

H1-B increase could decrease discourage IT graduates

You Tube Link

Lawyers giving seminar on how to give the impression there are no skilled workers in the US

You Tube Link

Seriously, would you want your kid to go into a shrinking industry where Washington and big business are intent on destroying your career and making sure get paid as little as possible.

Ruby on Rails Model Based Validators

Mar 14, 2008 · Xelipe Zone

Most people from my generation started on home computers..Z80, Spectrum, C4, Amiga. We also usually started with basic and then Assembly language (talk about polar opposites!).

While there are a number of free development tools available today online, it isn't as much a part of owning a computer nowadays. When you got a computer when you were 10, you either played games or wrote code. Coding was so new it was almost cool. Then came the geeky sub culture where coding is always cool. It's much harder to slip into that realm nowadays. You fire up the computer, play a game, check your email, surf the web, buy a book, read the news, chat online etc... There's too much other stuff going on to give people time to get interested in programming.

Also the fact that it is becoming less profitable to be a programmer, more jobs are being shipped overseas makes it a dying industry. There were no shortage of people looking to get into IT in 1998-2000 when the Y2k crisis and the dot com boom took off and companies were paying silly prices for anyone who could write HTML or add up two numbers. I don't believe open source helps that either. As an outsider looking in, why would you go into an industry where you compete with people giving their products away, existing in a community where it is advocated that you help projects for free, only to have the owners of projects sell your hard work for their profit when they get bought out by Oracle/Sun/Microsoft/Whoever

There are two kinds of programmers in this world, those that love it and those that do it for the money. The former will always do it, while the latter will move on to some other career (until that gets shipped off). The problem with the former is that since programming is less accessible, they are becoming fewer are farther between with only the most curious and most intrigued actually taking that final step to investigate and see how programs and the internet works.

Perhaps the real question is whether you would advocate a career in software to your kids when they are considering career opportunities. Will there really be much of a software industry in 6-10 years time when they leave college, or will it be a fraction of its former self just as manufacturing has become a shadow of itself?

User has been successfully modified

Failed to modify user

ABOUT US

  • About DZone
  • Support and feedback
  • Community research
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Core Program
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: