Hello again,
I have reorganized my project and I think I have figured out, at least one of, my problems. I am unsure of a "manager" type class that will make calls to all of the other objects. For example.
There are a few different paths in my app
//in all of the paths
now I also need to log the xml file as .xml and/or parse it into a database
I also need to log/write the start and end time
I need to know if I timed out during the call and log that as well
my app is a servlet and I have the config parameters in my web.xml so I also need to pass some info, like where the url is to post to, to the class that is to handle it along with the path to put the log file in as well as a very dynamic naming scheme
//path 1
client calls me with a Map
map has to get translated into xml
the xml has to get posted via HttpUrlConnection
an xml doc is returned to me
the xml needs to get translated back to a map
there are images in this xml that I have to put together then write to disk
I also have to put in the map the address to the images I just wrote
the map needs to get passed back to the client
//path 2
client call me with xml
I have to response immediatly with xml
then I have to parse the xml
execute business logic on the data
create an xml file
the xml has to get posted via HttpUrlConnection
and this can happen n number of calls depending on the business logic
write to the database
//path 3
client calls me
I build an xml file
the xml has to get posted via HttpUrlConnection
get back an xml file
parse and check the values back
write to a db
start a timeout checker
etc...
there is like one more scenario but it is similar
my problem is this, I have the following classes but don' tknow where to put some of the responsibility
MainServlet
----------
reads in the map if appropriate
reads in xml if appropriate (don't like that my servlet is in the xml business but can't get around it)
grabs config info and puts it into an Info class
calls a Handler class with a specific function like
XmlBuilder
---------
buildsXml (returns it as a string)
HttpTask
--------
makes the call
also has to check if timed out to try again up to the limit of trying again
returns result as string
Communicator
-----------
starts a loop and calls HttpTask
checks if timed out or other exception
grabs the result and returns it or throws exception
XmlParser
--------
parsesXml into a map
BUT HOW DO I GET THE IMAGES WRITTEN, this is the only place I have access to the raw data to write it but don't know if I call and ImageWriter from here if that even makes sense. DAMN
Handler
-------
calls buildXml on a memeber variable of XmlBuilder
calls Communicator.call(xmlString,url, times2Try, timeLimit)
calls parseXml (which writes the images, DAMN)
writes out the map
you know what, this is already getting long. Don't want to get over zealous. And all this and now I don't even know how to do the damn Logger
Now main question is; Is it ok to have a Handler make all the calls? Almost seems procedural or modular to have that. And to get all the config info down deep into the classes seems wrong but I have to store it in my web.xml and that is only accessable from a Servlet class.
Thanx
Spend like you don't need the money,
love like you've never been hurt and dance like no one's watching!
I have reorganized my project and I think I have figured out, at least one of, my problems. I am unsure of a "manager" type class that will make calls to all of the other objects. For example.
There are a few different paths in my app
//in all of the paths
now I also need to log the xml file as .xml and/or parse it into a database
I also need to log/write the start and end time
I need to know if I timed out during the call and log that as well
my app is a servlet and I have the config parameters in my web.xml so I also need to pass some info, like where the url is to post to, to the class that is to handle it along with the path to put the log file in as well as a very dynamic naming scheme
//path 1
client calls me with a Map
map has to get translated into xml
the xml has to get posted via HttpUrlConnection
an xml doc is returned to me
the xml needs to get translated back to a map
there are images in this xml that I have to put together then write to disk
I also have to put in the map the address to the images I just wrote
the map needs to get passed back to the client
//path 2
client call me with xml
I have to response immediatly with xml
then I have to parse the xml
execute business logic on the data
create an xml file
the xml has to get posted via HttpUrlConnection
and this can happen n number of calls depending on the business logic
write to the database
//path 3
client calls me
I build an xml file
the xml has to get posted via HttpUrlConnection
get back an xml file
parse and check the values back
write to a db
start a timeout checker
etc...
there is like one more scenario but it is similar
my problem is this, I have the following classes but don' tknow where to put some of the responsibility
MainServlet
----------
reads in the map if appropriate
reads in xml if appropriate (don't like that my servlet is in the xml business but can't get around it)
grabs config info and puts it into an Info class
calls a Handler class with a specific function like
XmlBuilder
---------
buildsXml (returns it as a string)
HttpTask
--------
makes the call
also has to check if timed out to try again up to the limit of trying again
returns result as string
Communicator
-----------
starts a loop and calls HttpTask
checks if timed out or other exception
grabs the result and returns it or throws exception
XmlParser
--------
parsesXml into a map
BUT HOW DO I GET THE IMAGES WRITTEN, this is the only place I have access to the raw data to write it but don't know if I call and ImageWriter from here if that even makes sense. DAMN
Handler
-------
calls buildXml on a memeber variable of XmlBuilder
calls Communicator.call(xmlString,url, times2Try, timeLimit)
calls parseXml (which writes the images, DAMN)
writes out the map
you know what, this is already getting long. Don't want to get over zealous. And all this and now I don't even know how to do the damn Logger
Now main question is; Is it ok to have a Handler make all the calls? Almost seems procedural or modular to have that. And to get all the config info down deep into the classes seems wrong but I have to store it in my web.xml and that is only accessable from a Servlet class.
Thanx
Spend like you don't need the money,
love like you've never been hurt and dance like no one's watching!