1 5 package calculator; 6 7 import org.apache.commons.logging.Log; 8 import org.apache.commons.logging.LogFactory; 9 10 import ve.luz.ica.jackass.component.ApplicationContext; 11 import ve.luz.ica.jackass.component.StatelessContext; 12 import ve.luz.ica.jackass.component.StatelessHook; 13 14 22 public class RealCalculatorImpl extends RealCalculatorPOA implements StatelessHook 23 { 24 private static final Log LOG = LogFactory.getLog(RealCalculatorImpl.class); 25 26 private ApplicationContext appContext = null; 27 private StatelessContext compContext = null; 28 29 37 public double add(double op1, double op2) 38 { 39 if (LOG.isDebugEnabled()) 40 { 41 LOG.debug("Parameters: " + op1 + "," + op2 + 42 ". Result:" + (op1 + op2)); 43 } 44 return op1 + op2; 45 } 46 47 56 public double div(double op1, double op2) throws DivByZero 57 { 58 if (LOG.isDebugEnabled()) LOG.debug("Parameters: " + op1 + "," + op2); 59 60 if (op2 == 0) 61 { 62 if (LOG.isWarnEnabled()) LOG.warn("DivByZero will be throw."); 63 throw new DivByZero(); 64 } 65 66 if (LOG.isDebugEnabled()) LOG.debug("Result:" + (op1 / op2)); 67 return op1 / op2; 68 } 69 70 73 public void jackassSetContexts(ApplicationContext appCtx, StatelessContext compCtx) 74 { 75 this.appContext = appCtx; 76 this.compContext = compCtx; 77 } 78 79 82 public void jackassCreate() 83 { 84 } 86 87 90 public void jackassRemove() 91 { 92 } 94 } 95 | Popular Tags |