How to Dynamically load DA Schema while server is running? (Delphi Win32)

(Delphi Win32) How do I reload the DA schema of a custom server while it is running? I’d like to throw a button on the main server form and pop up a load from file dialog to specify the new schema. But I don’t see a way to access the DA DataService once it is running…

Thanks
-scherb

Thanks, logged support request as bugs://47713
Posted by Bugs for Mac

You can move schema component from service implementation module to server data module and load schema from file or you can do this every time when service instance is created. Also you’ll need take care about already running service instances (specially when is used non-default class factory).

Humm… it seems like it might be best to destroy and then recreate the server data module. Then reload it from file on create. Would this clean out any running server instances? (I am using the default class factory.) Kill connections etc??

By default (http://wiki.remobjects.com/wiki/Standard_Class_Factory) new service instance is created for every client’s call. In this case I think need make sure that all requests were handled, turn off server, change schema and turn on server.

We also implementend this but we moved the schema component to the server datamodule. We check if the schema has changed on the disk and if so reload it. This takes place everytime the factory loads the service.

We also implementend this but we moved the schema component to the server datamodule. We check if the schema has changed on the disk and if so reload it. This takes place everytime the factory loads the service.

Thanks AJR65… I think I will run with your implementation.

Just to help anyone else wanting a similar solution here is the simple code I ended up using. There is a bit of extra code in there to throw some info to the console for my debugging purposes.

procedure TMyServerModule.ReloadSchema;
begin
if SchemaDate <> FileAge(MySchema_Location) then
begin
SchemaLoadNumber := SchemaLoadNumber + 1;
SchemaDate := FileAge(MySchema_Location);
LogServerActivity(‘Reloading Schema: ’ + FormatDateTime(‘yyyy-mm-dd hh:nn:ss’, FileDateToDateTime(SchemaDate)));
frmMainServerForm.StatusBar1.Panels[0].Text := ’ Schema Ver: ’ + FormatDateTime(‘yyyy-mm-dd hh:nn:ss’, FileDateToDateTime(SchemaDate)) + ’ (’ + IntToStr(SchemaLoadNumber) + ‘)’;
MySchema.LoadFromFile(MySchema_Location);
end;
end;