/* * Account.java * * Created on: 08-Feb-2010 * */ package netukar.piggybank.soap; import javax.annotation.security.RolesAllowed; import javax.jws.WebMethod; import javax.jws.WebParam; import javax.jws.WebResult; import javax.jws.WebService; import javax.jws.soap.SOAPBinding; import javax.jws.soap.SOAPBinding.Style; import netukar.piggybank.WithdrawException; /** * * @author radovan */ @WebService(targetNamespace="piggybank") @SOAPBinding(style=Style.RPC) //@RolesAllowed("piggybank_customer") Pro rozsireni prikladu o autorizaci public class Account { private double balance; /** * Creates a new instance of Account. */ public Account() { } @WebMethod @WebResult(name="balance") public double getBalance() { return balance; } @WebMethod @WebResult(name="balance") public double withdraw(@WebParam(name="amount") double amount) throws WithdrawException { if (amount > balance) { throw new WithdrawException("Unable to withdraw more than account leftover."); } balance -= amount; return balance; } @WebMethod @WebResult(name="balance") public double deposit(@WebParam(name="amount") double amount) { balance += amount; return balance; } }