Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please help with my object migration strategy 1

Status
Not open for further replies.

MagicFrisbee

Programmer
Feb 22, 2006
74
US
Fellow programmers, I have a design issue that I need your help with. I have this project I've been working on for the past few months. It's done. One of the units in that project is full of objects that handle all of the business logic. The objects don't connect to ANY forms, but they do connect to a DataModule by instance name. The forms, however, DO know about the objects and make appropriate calls to those objects as users perform their work inside the program.

So, I'm thinking that since I have my objects nicely organized in their own, quasi-independent unit, I should be able to easily use another Delphi technology to harness those same objects and display them on the web. But I've read MANY pages of help text and can't figure out which technology to go with. The help files are too generic and don't help. Do I compile the objects into a WebSnap application somehow? Or IntraWeb project? Do I make them into SOAP objects somehow? I'm lost. Oh, and some operations can't be performed if the user doesn't have sufficient rights. I grab the current username at run-time, but that won't be the same operation on-line.

Any suggestions you guys have? I did all this work to encapsulize my business logic into one unit with all these objects, properties, and methods, and now I can't seem to use them outside the executable.

GIS Programmer
City of Orem, UT
 
Hi

The TIdHTTPServer compunent is the best way to go. Implement your html code in the method/event:

DoCommandGet(AContext: TIdContext;
ARequestInfo: TIdHTTPRequestInfo; AResponseInfo: TIdHTTPResponseInfo);

The requested web pages is found in ARequestInfo.Document and you return the HTML code to the AResponseInfo.ContentText variable.

For your security issue I would recoment "Basic authentication". This is also handled by the Indy components.
 
make a COM interface that only exposes public functions/procedures. COM can be called from a wide array of technologies (all MS languages and even Java).

I use this method for all my ASP.NET projects (codebehind with C# or VB)

/Daddy

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
@glennof - Thank you. However, this reminds me of ISAPI Web Broker programming, and I was hoping to not go that route. Something that would allow me to visually design my web pages. I don't like using Delphi's PageProducer components anymore because they rely on those "pound-tags" that aren't pretty when designing the web page with a WYSIWYG editor. For instance, pound tags inside a table often show up outside and above the table in HTML.

@whosrdaddy - I loved the idea of COM when I first heard and read about it. But actual programming with COM in Delphi in any version has been a big pain. One non-Delphi-related issue that I have with COM is the reference counting/garbage collection mechanism. In this model I made, I have several child classes that have pointers to their parent class, which in turn point back to them. When I have COM objects do that, nothing frees anything because of reference counting. But in strict Delphi code, *I* control the lifetime of the children by having the parents free them when they themselves are freed. Delphi as an IDE has also messed up my Type Library more than once. If you have a work-around for the child-parent issue, drop me a note as I'd like to see what expert programmers do to overcome that issue in COM.

Also, whosrdaddy, do your COM objects communicate with a TDataModule by instance name or not? How do you deal with multi-threaded applications calling your COM library and possibly loading/saving objects at the same time? Like, how to avoid the scenario where once object has opened Table1 with a certain parameter, then another object opens Table1 with a different parameter, and both objects start reading the same rows of Table1, and the first object gets all the wrong values?

GIS Programmer
City of Orem, UT
 
Also, whosrdaddy, do your COM objects communicate with a TDataModule by instance name or not? How do you deal with multi-threaded applications calling your COM library and possibly loading/saving objects at the same time? Like, how to avoid the scenario where once object has opened Table1 with a certain parameter, then another object opens Table1 with a different parameter, and both objects start reading the same rows of Table1, and the first object gets all the wrong values?

short answer:
make a middleware that serialize the requests to the database.

the problem with this solution however, is that you need to develop your own communication protocol.
it works with this principle:

a) web site makes request for data
b) web page COM object function is called
c) COM dll makes TCP connection to middleware service
d) COM dll sends data request to middleware service
e) middleware service serializes the request and retrieves data from database
f) middleware service sends data via TCP to COM dll
g) COM function has now the returned data and is processed by the web page

this setup allows me to mix win32 apps with web pages that rely on the same bussiness logic.

there are tools available that do this work for you, like kbmw, remobjects, datasnap

look for a discussion here:

I like kbmw very much but it's not free and I like to keep control over the technologies I use...

/Daddy


-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
What you're talking about then is middleware. And I believe Delphi Enterprise or Architect has the ability to let programmers create middleware using something called DataSnap. I haven't read much about it. But the serialization thing really confuses me. But, yes, I love that idea of my executables and web pages using the same business logic, calling the same properties by name, and the same methods which underneath it all do exactly the same thing because it's the same code, not just a copy of the code. It seems difficult, however, to replace such middleware when you've invented a new version and want to publish it out to a host of in-house users AND a web server.

Well, thank you all for your reponses. I'm gonna have to keep hunting for the right solution. I'm in e-mails right now with people at Embarcadero so hopefully something turns up that won't require much reengineering on my part. But any tool that helps me do this object persistence better is, well, better.

GIS Programmer
City of Orem, UT
 
with serialization I mean that when you have 2 concurrent queries, the middleware will execute one query at a time

/Daddy

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
I know what you mean by serialization, but can't imagine how you'd code it up. That's what I meant to express. I'm thinking either you used Mutex classes or something you coded by hand. Anyway, I think I'll close this thread and thank you for your responses with a star.

GIS Programmer
City of Orem, UT
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top