Self routing all-optical switch for WDM applications