Archive for 'Code'
Notification Service: The audit log in action
6 December 2008With the completion of the service layer for the audit log, it was now time to make a few changes to the Notifier implementation to log the details of notifications. While I was at it, I also upgraded to Velocity 1.6, since that became available this week, just in time for my little Notification Service [...]
Notification Service: Audit log data manager tests
5 December 2008Now that we have the NoticeAuditManager and NoticeAuditManagerImpl, we need to test them. First, the NoticeAuditManagerTest:
package org.restafarian.notify.manager;
import java.util.Date;
import org.restafarian.notify.beans.NoticeAudit;
import org.springframework.test.AbstractTransactionalDataSourceSpringContextTests;
public class NoticeAuditManagerTest extends AbstractTransactionalDataSourceSpringContextTests {
private NoticeAuditManager noticeAuditManager;
public void setNoticeAuditManager(NoticeAuditManager noticeAuditManager) {
this.noticeAuditManager = noticeAuditManager;
}
protected String[] getConfigLocations() {
setAutowireMode(AUTOWIRE_BY_NAME);
[...]
Notification Service: Audit log data manager
4 December 2008Meanwhile, back on the Notification Service project, it was time start putting together the service layer on top of the new data access layer for the NoticeAudit entity. Here is the basic manager interface:
package org.restafarian.notify.manager;
import java.util.List;
import org.restafarian.notify.beans.NoticeAudit;
/**
* <p>This is the NoticeAudit manager interface.</p>
*/
public interface NoticeAuditManager {
/**
* <p>Returns all [...]
DAO Refactoring: One final(?) version
4 December 2008For the last little touch to my version of the “The Best AbstractHibernateDao Ever“, I pulled the save and delete methods from here:
package org.restafarian.core.dao.hibernate;
import java.io.Serializable;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Example;
import org.hibernate.criterion.Restrictions;
import org.springframework.orm.ObjectRetrievalFailureException;
import org.springframework.util.Assert;
public abstract class AbstractHibernateDao<E> {
private final Class<E> entityClass;
private final SessionFactory sessionFactory;
/**
* <p>Constructs a [...]
DAO Refactoring: OK, that’s the end of that!
4 December 2008Once I did one, then it was just a matter of going back and doing the same thing to all of the other projects, and then going through the full build process from the top to get to here:
[INFO] ————————————————————————
[INFO] Reactor Summary:
[INFO] ————————————————————————
[INFO] example-parent …………………………………. SUCCESS [14.063s]
[INFO] core ………………………………………….. SUCCESS [50.671s]
[INFO] approval ………………………………………. SUCCESS [7.250s]
[INFO] [...]
DAO Refactoring: Finally!
2 December 2008Well, it took a little longer than I care to admit, but I finally got back to here:
[INFO] ————————————————————————
[INFO] BUILD SUCCESSFUL
[INFO] ————————————————————————
[INFO] Total time: 1 minute 41 seconds
[INFO] Finished at: Tue Dec 02 18:41:45 PST 2008
[INFO] Final Memory: 16M/39M
[INFO] ————————————————————————
My goal was to resolve all of the warning messages that had cropped up in the [...]
DAO Refactoring: Lookup Table DAOs
30 November 2008Since I decided to go with this version, I went ahead and went all the way back to the Look-up Table project and reworked these into this:
package org.restafarian.core.dao.hibernate;
import org.hibernate.SessionFactory;
import org.restafarian.core.beans.LookupTable;
import org.restafarian.core.dao.LookupTableDao;
/**
* <p>This is the LookupTable data access object.</p>
*/
public class LookupTableDaoHibernate extends AbstractHibernateDao<LookupTable>
implements LookupTableDao {
/**
[...]
DAO Refactoring: One more version
29 November 2008After playing around a little more, I decided to turn this in this (differences here):
package org.restafarian.core.dao.hibernate;
import java.io.Serializable;
import java.util.List;
import org.hibernate.Criteria;
import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Example;
import org.hibernate.criterion.Restrictions;
import org.springframework.orm.ObjectRetrievalFailureException;
import org.springframework.util.Assert;
public abstract class AbstractHibernateDao<E> {
private final Class<E> entityClass;
private final SessionFactory sessionFactory;
public AbstractHibernateDao(Class<E> entityClass, SessionFactory sessionFactory) {
Assert.notNull(entityClass, “entityClass must not be [...]
DAO Refactoring: NoticeAuditDaoHibernate
29 November 2008Since I just couldn’t put it off any longer, I went ahead and struggled through the creation of the new NoticeAuditDao implementation. Actually, it went relatively well — I had to do a little research on a couple of things, but all in all, I think it came out pretty good:
package org.restafarian.notify.dao.hibernate;
import java.util.List;
import org.hibernate.SessionFactory;
import org.hibernate.criterion.Example;
import [...]
DAO Refactoring: NoticeAuditDaoTest
29 November 2008Now that we have constructed the NoticeAuditDao interface, we can go ahead and put the tests together before we attempt to create the actual implementation. Again, this looks relatively similar to other DAO tests that we have put together in the past:
package org.restafarian.notify.dao;
import java.util.Date;
import java.util.List;
import org.restafarian.notify.beans.NoticeAudit;
import org.springframework.dao.DataAccessException;
public class NoticeAuditDaoTest extends BaseDaoTestCase {
private NoticeAudit [...]






