Simple middleware in java