dynamic factory with template lock