Hyperic 4.5 Released |
|

After many months of development, I am proud to announce the release of Hyperic 4.5. In this release, we migrated Hyperic from an EJB application running on JBoss to a Spring web application running on Tomcat. The detailed migration steps are covered in my Case Study on Migrating Hyperic from EJB to Spring, originally presented at the recent SpringOne 2GX. In this post, I would like to highlight a few of my favorite things about the conversion.
Improved testability
Switching to Spring allowed us to convert our existing Stateless Session EJBs to POJOs with autowired dependencies. This eliminated quite a bit of static JNDI lookup code that made unit testing so difficult. Spring also made integration testing significantly easier. Before the conversion, we had a handful of integration tests that each took several minutes to bootstrap an approximation of an EJB container. This process was cumbersome and error prone. Additionally, the tests often left the database in an inconsistent state, making it necessary to add database setup or tear down code, adding additional overhead to test execution time and occasionally causing inconsistent test results.
After the conversion, we were able to take advantage of Spring's integration testing support to test our new service layer of converted EJBs as well as their underlying DAOs. By simply adding a few annotations, we were able to bootstrap our entire application context in less than 30 seconds and run each test method in a dedicated transaction that was automatically rolled back at the end of the test. This support proved very valuable in allowing us to quickly increase our test coverage by 18% and 12% in our open source and enterprise codebases respectively.
@Transactional
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = "classpath*:META-INF/spring/*-context.xml")
public class AppdefManagerTest {
@Autowired
private AppdefManager appdefManager;
@Before
public void setUp() throws Exception {
createPlatformType("TestPlatform", "test");
}
@Test
public void testGetControllablePlatformTypes() throws Exception {
Map<String, AppdefEntityID> platformTypes = appdefManager
.getControllablePlatformTypes(subject);
assertEquals(1, platformTypes.size());
assertEquals("TestPlatform", platformTypes.keySet().iterator().next());
}
}
Reduced code complexity
Simply introducing Spring for dependency injection greatly simplified the code in many areas by eliminating verbose dependency lookup. However, there are many other places where introduction of Spring significantly improved the clarity of code, reducing the clutter of infrastructure and allowing us to focus on the true business logic. Two of my favorite examples of this in Hyperic are the usage of JmsTemplate for publishing JMS messages and JdbcTemplate for data access.
Message Publishing Before
public void publishMessage(String name, Serializable sObj) {
TopicConnection conn = null;
TopicSession session = null;
if (_ic == null)
_ic = new InitialContext();
if (_factory == null)
_factory = _ic.lookup(CONN_FACTORY_JNDI);
TopicConnectionFactory tFactory = (TopicConnectionFactory) _factory;
Topic topic = getTopic(name);
if (topic != null) {
// Now create a connection to send a message
if (_tConn != null)
conn = _tConn;
else
conn = tFactory.createTopicConnection();
if (conn == null)
_log.error("TopicConnection cannot be created");
if (_tSession != null)
session = _tSession;
else
session = conn.createTopicSession(false,
Session.AUTO_ACKNOWLEDGE);
// Create a publisher and publish the message
TopicPublisher publisher = session.createPublisher(topic);
ObjectMessage msg = session.createObjectMessage();
msg.setObject(sObj);
publisher.publish(msg);
...
}
Message Publishing After
public void publishMessage(String name, Serializable sObj) {
eventsJmsTemplate.convertAndSend(name, sObj);
}
Data Access Before
public int getServicesCount(AuthzSubject subject) {
Statement stmt = null;
ResultSet rs = null;
Integer subjectId = subject.getId();
try {
Connection conn = getDBConn();
String sql = "SELECT COUNT(SVC.ID) FROM TBL_SERVICE";
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
if (rs.next()) {
return rs.getInt(1);
}
} catch (SQLException e) {
log.error("Caught SQL Exception finding Services by type: " + e, e);
throw new SystemException(e);
} finally {
DBUtil.closeJDBCObjects(LOG_CTX, null, stmt, rs);
}
return 0;
}
Data Access After
public int getServicesCount(AuthzSubject subject) {
return jdbcTemplate.queryForInt("SELECT COUNT(SVC.ID) FROM TBL_SERVICE");
}
That's quite a weight loss plan! Simply by converting to Spring and not changing any functionality, we reduced both the open source and enterprise codebases by approximately 7%.
Improved developer productivity
As mentioned above, the Spring support for integration testing allows us to bootstrap our entire application context in less than 30 seconds for end-to-end integration testing. This has been a huge time-saver when testing new features or debugging problems. When we do need to bring up the entire web application, the switch to Tomcat has improved our productivity by significantly decreasing startup time. A single developer coding and debugging an application now saves approximately 5 minutes of waiting each time he/she starts up the application. Considering that developer may restart the application 12 times a day, that frees up an entire hour per day to develop new features! Additionally, the cleaner code and improved unit testability has made it faster and easier to find and fix problems, and the flexible architecture makes it easier to add new features and enhancements.
These are just a few of the benefits provided by switching to Spring and Tomcat in this release. There are really just too many to list in a single blog post!
This release also contains monitoring and management for three of the VMware vFabric platform services, including vFabric GemFire 6.5 distributed caching system, RabbitMQ enterprise messaging system, and the new vFabric tc Server 2.1 Java runtime server also released this week. Support for vFabric tc Server existed in previous releases of Hyperic; however, in 4.5 the plugin is now bundled with the Hyperic distributions, and is no longer a separate download. Look for more information on monitoring GemFire and RabbitMQ in a future blog post.
While migrating, we also took the opportunity to move our code repository from subversion to git. To download the source from the git code repository go to http://git.springsource.org/hq. We also switched our build system from ant to maven. All of the Hyperic modules needed for development of custom plugins or features can now be downloaded from our maven repository at http://maven.hyperic.org/release.
Conclusion
I encourage you to download Hyperic 4.5 and/or check out the code. As always, community feedback through the forums is very much appreciated. We are looking forward to building on this easily extensible architecture that our conversion to Spring has provided. Stay tuned for more exciting enhancements!
Similar Posts
- Spring 2.0's JMS Improvements
- Spring Web Services 2.0 Released
- Spring Integration 2.0 Milestone 3 Released
- Spring Integration: a new addition to the Spring portfolio
- Grails 1.2 Released









Claus Hausberger says:
Added on November 11th, 2010 at 9:47 amIntegration testing is also very easy with Arquillian. It is a JBoss product but not tied to the JBoss AS
http://jboss.org/arquillian
tiger says:
Added on November 12th, 2010 at 1:46 amas mentioned in the wikipedia, "the intergration testing is the phase in software testing in which individual software modules are combined and tested as a group. It occurs after unit testing and before system testing."
"the Spring support for integration testing allows us to bootstrap our entire application context in less than 30 seconds for end-to-end integration testing. "
Can you tell me the old application's bootstrap time? How offten do you reboot/redeploy your application system in the IT phase? once a day? once a hour? I donot think that the Spring can help you to improve your IT phase.
Behrang says:
Added on November 12th, 2010 at 7:20 amInteresting results. By the way, have you also accounted for XML files in your LOC comparison?
Somehow unrelated, but what's the point of passing AuthzSubject to that method if you never call it? Especially in the EJB example, where you also call getId() on it but then you never use subjectId.
Jennifer Hickey (blog author) says:
Added on November 12th, 2010 at 11:45 am@Behrang, no the LOC doesn't account for XML. However, we are using component scanning and autowiring, so our total lines of XML are pretty small. Plus, since we ship the product with Tomcat (and thus consider both the container and webapp to be part of our overall offering), we've definitely reduced the amount of XML configuration overall by switching from JBoss to Tomcat.
Using Spring Security to handle authorization and eliminating the AuthzSubject from method signatures is on the list of upcoming enhancements. But you are correct that it was not relevant for that particular example.
Behrang says:
Added on November 12th, 2010 at 11:38 pm@Jennifer: Thanks for the clarifications. LOC aside, thanks to Spring templates, the Springified version is much more concise and cleaner, and in the big picture, with much less code duplication.
ugg soldes says:
Added on November 17th, 2010 at 10:25 pmFrom your comments I can see most people like your post, thanks for taking time to write these. It makes our feel something different. ¬Hope you have a great day.
Sharron Clemons says:
Added on December 21st, 2010 at 3:25 pm[...] virtualized application stack. Jennifer Hickey recently described the internal details about the Hyperic 4.5 release, but also added were two important new monitoring [...]