473,395 Members | 1,676 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Abstract Factory using String paramater as Conctrete Class

Hello,

I need to use a Factory pattern to create services class.

i have an interface --> MyService
i can have an abstract class --> MyAbstractService
i have several concrete class for this service --> MyServiceVersion1_1
MyServiceVersion1_2.

I would like to create a factory which could instantiate object using
String (from XML file) as Class identifier. (maybe using a abstract
creator).

So that i'll be able to add some implementation class without rewritte
any lines on my code, only add concrete class to jar file and configure
XML file to use this.

example of a XML configuration file :

<IPNX>
<IPADDR>127.0.0.1</IPADDR>

<COMPSERVICE>
<VERSION>1.1</VERSION>
<IMPL-SERVICE-CLASS>
ict.wtl.ipnx.service.MyServiceVersion1_1
</IMPL-SERVICE-CLASS>
</COMPSERVICE>
</IPNX>

Thank's
--

-------------------
Sebastien Degardin
Intercall-Telecom
Java - J2EE (beginner)
sd*******@powerdevNOSPAM.be
Jul 18 '05 #1
2 3837
Sebastien Degardin wrote:
Hello,

I need to use a Factory pattern to create services class.

i have an interface --> MyService
i can have an abstract class --> MyAbstractService
i have several concrete class for this service --> MyServiceVersion1_1
MyServiceVersion1_2.

I would like to create a factory which could instantiate object using
String (from XML file) as Class identifier. (maybe using a abstract
creator).

So that i'll be able to add some implementation class without rewritte
any lines on my code, only add concrete class to jar file and configure
XML file to use this.

example of a XML configuration file :

<IPNX>
<IPADDR>127.0.0.1</IPADDR>

<COMPSERVICE>
<VERSION>1.1</VERSION>
<IMPL-SERVICE-CLASS>
ict.wtl.ipnx.service.MyServiceVersion1_1
</IMPL-SERVICE-CLASS>
</COMPSERVICE>
</IPNX>

Was there a question in there?

Using my psychic powers, I'll guess that you need a pointer to look at
java.lang.Class.forName() and java.lang.Class.newInstance().

If you are interested in a pattern that does this that has been very
successful (integrates great with third party implementations), take a
look at java.sql.DriverManager.

Ray

--
XML is the programmer's duct tape.
Jul 18 '05 #2
Raymond DeCampo wrote:
Sebastien Degardin wrote:
Hello,

I need to use a Factory pattern to create services class.

i have an interface --> MyService
i can have an abstract class --> MyAbstractService
i have several concrete class for this service --> MyServiceVersion1_1
MyServiceVersion1_2.

I would like to create a factory which could instantiate object using
String (from XML file) as Class identifier. (maybe using a abstract
creator).

So that i'll be able to add some implementation class without rewritte
any lines on my code, only add concrete class to jar file and
configure XML file to use this.

example of a XML configuration file :

<IPNX>
<IPADDR>127.0.0.1</IPADDR>

<COMPSERVICE>
<VERSION>1.1</VERSION>
<IMPL-SERVICE-CLASS>
ict.wtl.ipnx.service.MyServiceVersion1_1
</IMPL-SERVICE-CLASS>
</COMPSERVICE>
</IPNX>

Was there a question in there?

Using my psychic powers, I'll guess that you need a pointer to look at
java.lang.Class.forName() and java.lang.Class.newInstance().

If you are interested in a pattern that does this that has been very
successful (integrates great with third party implementations), take a
look at java.sql.DriverManager.

Ray


Yes, of course, i would like to get the concrete class from a XML file
dynamicaly at runtime.

To be able to add some implementation class easily in the future.

I'm gonna take a look at these class.

Thank's

--

-------------------
Sebastien Degardin
Intercall-Telecom
Java - J2EE (beginner)
sd*******@powerdevNOSPAM.be
Jul 18 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
by: Medi Montaseri | last post by:
Hi, Given a collection of similar but not exact entities (or products) Toyota, Ford, Buick, etc; I am contemplating using the Abstraction pattern to provide a common interface to these products....
1
by: f00sion | last post by:
I found a good tutorial of how to supply the objects without having the implementation files on the client. This was working great until I realized that I couldnt use any constructors with server...
33
by: Chris Capel | last post by:
What is the rationale behind the decision not to allow abstract static class members? It doesn't seem like it's a logically contradictory concept, or that the implementation would be difficult or...
3
by: Christer | last post by:
Hi all! We're creating an administration for a web application. This includes severeal aspx pages. Our key entity in the web application is "Profile", which can have a certain type. Based on...
2
by: max | last post by:
Hello, I analyze this design pattern for a long time but I do not understand how this pattern work and what the purpose is? (I looked a this site...
0
by: Craig Buchanan | last post by:
i am trying to build an application that uses plugins to extend the business functionality of an application. i've decided to use inheritance of abstract classes as the mechanism to do this. ...
0
by: mailforpr | last post by:
Hi. Let me introduce an iterator to you, the so-called "Abstract Iterator" I developed the other day. I actually have no idea if there's another "Abstract Iterator" out there, as I have never...
6
by: Nindi | last post by:
5 Files Singleton.h The Singleton Factory.h The factory creating new objects. The Base class of the hierachy stores a typelist identifying the signature of the constructors to be called...
0
by: Saeed Amrollahi | last post by:
Hi All I am working on a Stock Exchange related program. Because I want, my program be independent from specific market convention, I designed a class hierarchy for market and a class hierarchy...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.