java - Using EJB interface for helper class -
my colleague told me ejb shoudln't contain method implemetation, must delegate method calls "helper" classes, i.e. ejb methods should this:
public string bsuinessmethod1() { return helper.bsuinessmethod1() } public void bsuinessmethod2() { helper.bsuinessmethod2() } and reason delegate methods above, have less coupled code (for example when want reuse methods of "helper" class not in ejb context). told business methods shouldn't know java ee.
(correct me if above statement wrong, , please note don't use jpa transactions, use framework dealing data persistence)
so if above statement correct, "helper" classes should have same methods ejb. can reuse ejb interface helper class (i.e. make helper class implement same interface ejb)? not bad architectural point of view?
i dont think
delegate method calls "helper" classes
, means keep ejb method 1 liner calls helper class(es). intent of delegating implementation helper class use core computation different kinds of service exposers (ejb, pojo, web service etc). helps port service ejb non ejb.
having computation in helper classes expose services in multiple ways if required. of them can use these helper classes core computation.
say, need service retrieve average temperature of day given city. pardon if example not hope expresses idea. service needs
- retrieve list of temperatures db given city day. (in db stored 40 f, 5 c etc).
- parse temperatures identify unit of measurement , convert fahrenheit.
- filter invalid temperatues (zeroes , values containing invalid characters etc).
- calculate average.
in scenario items 2, 3 , 4 makes sense moved helper class. item 1 not recommended part of helper class.
now helper class can used a) pojo service. b) ejb. c) web service or others.
Comments
Post a Comment