Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8376917
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T15:32:31+00:00 2026-06-09T15:32:31+00:00

We have implemented a typical DAO/Abstract Factory pattern. The design is like this: DAOFactory

  • 0

We have implemented a typical DAO/Abstract Factory pattern. The design is like this:

DAOFactory – that returns either an instance of MySQLFactory / SQLiteFactory

  • MySQLFactory – returns DAOs that talks to MySQL DB
  • SQLiteFactory – returns DAOs that talks to SQLite DB

Things are fine. However, we need to create two executables: The one that is provided to customers uses the SQLiteFactory instance and relevant DAOs. In that executable, we don’t want to include any class related to MySQLFactory. If I delete those classes then we see a ClassNotFoundException at run time when DAOFactory class is being loaded by class loader.

How can we implement our DAOFactory so that MySQLFactory is not required at runtime ? The same problem also exists for certain other classes i.e. certain classes are required only for in-house version of the app. What is a good way of implementation so that we can exclude classes from the software that is shipped to customers ?

Thanks
Deep

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T15:32:32+00:00Added an answer on June 9, 2026 at 3:32 pm

    You can use Class.forName to load classes at runtime. For example:

    public class DAOFactoryLoader {
      public static DAOFactory loadMySQLFactory() {
        return (DAOFactory) Class.forName("your.package.MySQLFactory").newInstance();
      }
    
      public static DAOFactory loadSQLiteFactory() {
        return (DAOFactory) Class.forName("your.package.SQLiteFactory").newInstance();
      }
    }
    

    Then you can call the right method for the specific version of your software, i.e. loadMySQLFactory when you bundle the MySQL implementation and loadSQLiteFactory when you bundle the SQLite implementation.

    You can even pass the class name as a JVM property, for eg. -DdaoFactory=your.package.MySQLFactory and then use this to load the right class:

    return (DAOFactory) Class.forName(System.getProperty("daoFactory")).newInstance();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a C++ state machine implemented using the State design pattern. Each state
I have implemented correctly bump's api, and added this code: - (void) configureBump {
I have implemented Facebook into my app but now I find that whenever I
I have implemented a UISearchDisplayController that allows users to search a table. Currently the
I have implemented a simple entity ejb with a @version annotation. I expect that
The problem again is that though i have succesfully implemented a SAX parser in
I have a Grails-service implemented in Groovy, which I'd like to inject into a
This code compiles but looks very strange. I have a typical and simple parent/child
I have an existing Django application with a pretty typical model implementation that's backed
current situation: I have a service with several typical service methods like create(), remove(),

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.