Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Java
Class.forName().newInstance() vs new
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Robert Klemme, post: 4219443"] If Class.forName() is the bottleneck then a static factory method does not help in this particular case. You would have to configure the method name or a class name anyway and use reflection to get at the instance or method. Abu, to answer your question (pseudo code): interface com.your.company.db.DbManager { // methods } interface com.your.company.db.DbManagerFactory { DbManager create(/* args if needed */) throws WhateverException } class com.your.company.db.ora.OraDbManager implements DbManager { // ... } class com.your.company.db.ora.OracleDbManagerFactory implements DbManagerFactory { public DbManager create() { return new OraDbManager(); } } Kind regards robert [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Java
Class.forName().newInstance() vs new
Top