public class DAOFacadeExample extends DAOFacadeBase<CountryDAO> implements CountryDAO {
public DAOFacadeExample(CountryDAO legacyDAO, CountryDAO lightblueDAO) {
super(legacyDAO, lightblueDAO);
}
@Override
public Country createCountry(Country country) throws CountryException {
try {
return callDAOCreateSingleMethod(entityIdExtractor, Country.class, "createCountry", country);
} catch (CountryException ce) {
throw ce;
} catch (Throwable t) {
throw new RuntimeException(t);
}
}
( ... )
Dynamic proxy solution:
public class DAOFacadeExample implements CountryDAO {
CountryDAO facade;
public DAOFacadeExample(CountryDAO legacyDAO, CountryDAO lightblueDAO) {
facade = FacadeProxyFactory.createFacadeProxy(legacyDAO, lightblueDAO, );
}
@Override
public Country createCountry(Country country) throws CountryException {
return facade.createCountry(country);
}
( ... )
The facade knows which operation this is based on the ReadOperation, WriteOperation and UpdateOperation annotations which need to be added to CountryDAO apis. No annotation means the call will be sent to legacyDAO, no matter the togglz configuration.
This change is backwards compatible, you can still extend DAOFacadeBase if you prefer.
This is https://github.com/lightblue-platform/lightblue-migrator/issues/171 implementation. The benefit is less code to write and maintain. Example:
Current solution:
Dynamic proxy solution:
The facade knows which operation this is based on the ReadOperation, WriteOperation and UpdateOperation annotations which need to be added to CountryDAO apis. No annotation means the call will be sent to legacyDAO, no matter the togglz configuration.
This change is backwards compatible, you can still extend DAOFacadeBase if you prefer.