• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Tim Cooke
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Frits Walraven
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • salvin francis
  • fred rosenberger

Different implementation of method within the same service

 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I've got class FileMaker. It contains several methods like open and close file, read text line from file etc. and also one method which reads Record.

class FileMaker{
Record readRecord(){
String line = readLineOfTextFromFile();
return new Record(line) // or return record.convertToRecord(line)
}
}

I would like to make FileMaker general class which could be used for different types of Records
For example it should be able to read the file which contains lines about Person (name;age;email) as well as file which contains lines about Car (brand;year)

How initiate FileMaker with different implementation of "convertToRecord" for specified services?

Here I would like to use FileMaker for PersonRecord
<bean name="personService" >
<property name="fileMaker" ref="fileMaker" />
</bean>


And here for CarRecord
<bean name="carService" >
<property name="fileMaker" ref="fileMaker" />
</bean>


Thanks for help in advance.









 
That new kid is a freak. Show him this tiny ad:
Devious Experiments for a Truly Passive Greenhouse!
https://www.kickstarter.com/projects/paulwheaton/greenhouse-1
    Bookmark Topic Watch Topic
  • New Topic