Advice on best approach to extend services

I thought I would get some advice as to the best way to do the following.

I have multiple file types that I use in my application. I have set up an @EventListener to process the files after they have been uploaded.

What would be the best way to process the different file types?

So far I have:

  1. extended the base FileDescriptor entity of Cuba and added a FileType enum.

  2. created an event listener for after insert of any new filedescriptor which creates a GlobalEvent.

  3. set up a component that listens for the different GlobalEvents. e.g.

        @EventListener(condition = "#fileEvent.fileDescriptorExt.fileType.getId().equals('MY_FILE')")
        public void processAmsHermFile(FileEvent fileEvent){
  "Processing new MY_FILE file: "+fileEvent.getFileDescriptorExt().getName());
            FileProcessingServiceBean myFileProcessor= new MyFileProcessor();
  "Processing of "+fileEvent.getFileDescriptorExt().getName()+" complete.");
            events.publish(new UiNotificationEvent(this, "MY_FILE Successfully uploaded "+fileEvent.getFileDescriptorExt().getName()));
  4. here is where I get stuck.

Ideally I want to create a file service that has a method like processFile(FileDescriptorExt fileDescriptor); with lots of sub-services that extend it for all the different file types. I can’t seem to be able to get this to work.

e.g. public class MyFileProcessor extends FileProcessingServiceBean()

Does anyone have any good ideas / best way to achieve this. i.e. process multiple different file types. Is there any examples/demo programs which do this?

I was trying to make a factory e.g.

public class FileProcessingFactory {
  public static FileProcessor getFileProcessor(Object object) {
switch (object.getClass().getSimpleName()) {
                case "FileDescriptorExt":
                    FileDescriptorExt fileDescriptorExt = (FileDescriptorExt) object;
                    switch (fileDescriptorExt.getFileType()) {
                        case MY_FILE:
                            return new MyFileProcessor();                      
                        default: // do some error handling
                case "SwitchRequest":
                    //return new SwitchRequestFileProcessor();
            return null;

Maybe I’m going about this wrong? Cant seem to figure out how to extend a service… Or should I even be trying to?