I finally I found the solution. I can calculate my expression very fast using this technique:
(a * b) % p = ((a % p) * (b % p)) % p
So my example will look like this:
(a^x * b^y) % z = ( ((a^x) % z) * ((b^y) % z) ) % z;
or, using BigInteger in Java:
BigInteger result = a.modPow(x, z).multiply( b.modPow(y, z) ).mod(z);