Any pattern can be applied?

Discussions

General J2EE: Any pattern can be applied?

  1. Any pattern can be applied? (2 messages)

    I have a specific problem and want to apply a suitable pattern to it. Thanks for any help.


    Have two environments. Unix File System and TSO (Main Frame) File System.

    - Need to have a single Java application which reads the files on both the file systems.
    - Files can be taken from a directory. Or few specified files.
    -API to read and write from files is different for different environment.


    Presently I have code something like this. This is very plainly coded.

    // Depending onthe choice, from where to take the files://////// 3 choices
               if(ScifConstants.SOURCE_CHOICE == ScifConstants.FROM_DIRECTORY)
               {
    // Use Unix API and return File list
    }
               }else if(ScifConstants.SOURCE_CHOICE == ScifConstants.FROM_FILES)
               {
    // Use Unix API and return File list
                  }

               }
               else if(ScifConstants.SOURCE_CHOICE == ScifConstants.FROM_TSO_FILES)
               {
    // Use TSO API and return RecordFile list
                  }

                }
    //---------------------------------------------------------------------------------------------------------
    // Reading the files (TSO file or Unix File)
    ArrayList readFromFile(RecordFile file)
    {
    // reading the lines in to array list using TSO File I/O
    }

    ArrayList readFromFile(File file)
    {
    // reading the lines in to array list using Unix File I/O
    }

    -----------------------------------------------------------------------------------------------------------

    Threaded Messages (2)

  2. Any pattern can be applied?[ Go to top ]

    Hi,
        You can use jndi to access files in a directory. This will standardize the access to files in your application.
    More information can be reached at
    http://java.sun.com/products/jndi/

    Leo
  3. Any pattern can be applied?[ Go to top ]

    The strategy or the state design patterns can hide away the repetitive SOURCE_CHOICE decisions.