object EMPLOYEE: TSQLDataSet CommandText = 'EMPLOYEE' CommandType = ctTable SQLConnection = IBCONNECTION end object DataSetProviderEmployee: TDataSetProvider

DataSet = EMPLOYEE end

This server module is built in a very similar way to how it would have been in the past. What is new is the need to include in the program three new components that provide configuration and connectivity in place of the COM support (which is totally gone). The three components are:

  • DSServer, the main server configuration component, which is needed to wire all the other DataSnap 2009 components together.
  • DSServerClass, a component needed for each class you want to expose. This component is not the class you make available, but acts as a class factory to create objects of the class you want to call from a remote client. In other words, the DSServerClass component will refer to the class that has the public interface.
  • DSTCPServerTransport, a component that defines the transport protocol to be used (this is the only protocol directly available in Delphi 2009) and its configuration, such as which TCP/IP port to use.

In the demo these components are in the main form of the server, configured as follows:

object DSServer1: TDSServer AutoStart = True HideDSAdmin = False OnConnect = DSServer1Connect OnDisconnect = DSServer1Disconnect end object DSTCPServerTransport1: TDSTCPServerTransport PoolSize = 0 Server = DSServer1 BufferKBSize = 32 end object DSServerClass1: TDSServerClass OnGetClass = DSServerClass1GetClass Server = DSServer1 LifeCycle = 'Session' end

We'll get to some of the details of these properties later on. The reason you don't see the value of the TCP/IP port in the listing above is that I've not modified the default value of 211.

The only Delphi code you need to write is the "class factory" code that is needed to connect the DSServerClass1 component to the server module exposing the providers:

procedure TFormFirst3Tier2009Server.

DSServerClass1GetClass(DSServerClass: TDSServerClass; var PersistentClass: TPersistentClass); begi n

PersistentClass := TDSFirst3TierServerModule; end;

This is all you need for the server. In the actual example I've added a logging statement to the method above, as well as to the event handlers of the OnConnect and OnDisconnect events of the DSServer component.

Again, there is no need to register it in any way. Simply run it, maybe using the Run | Run Without Debugging command of the Delphi IDE, so you can build the client and connect it to the server even at design time.

Was this article helpful?

0 0
Project Management Made Easy

Project Management Made Easy

What you need to know about… Project Management Made Easy! Project management consists of more than just a large building project and can encompass small projects as well. No matter what the size of your project, you need to have some sort of project management. How you manage your project has everything to do with its outcome.

Get My Free Ebook

Post a comment