ServiceReference[] refs = null;
try {
filter = "(osgi.unit.name="+ unitName +")";
refs = ctx.getServiceReferences(EntityManagerFactoryBuilder.class.getName(), filter);
} catch (InvalidSyntaxException isEx) {
new PersistenceException("Implementation error - incorrect filter specified while looking up EMF", isEx);
}
if ((refs != null) && (refs.length != 0)) {
debug("Persistence class - lookupEMFBuilder, found service ", unitName, " in registry");
// Take the first one and create an EMF from it
EntityManagerFactoryBuilder builder = (EntityManagerFactoryBuilder)ctx.getService(refs[0]);