Generic code for autodiscovering plugin