Apache module extension to be a dll/so hosting env

git-svn-id: https://svn.code.sf.net/p/lazarus-ccr/svn@278 8e941d3f-bd1b-0410-a28a-d453659cc2b4
This commit is contained in:
inoussa 2007-10-22 12:44:00 +00:00
parent 343b11db66
commit 952fa6ce12
11 changed files with 1125 additions and 272 deletions

View File

@ -14,7 +14,7 @@
unit library_base_intf;
interface
uses base_service_intf;
uses SysUtils, Classes, base_service_intf;
{$INCLUDE wst.inc}
{$INCLUDE wst_delphi.inc}
@ -51,6 +51,30 @@ type
function SetPosition(const ANewPos : LongWord):LongInt;
end;
{ TwstStream }
TwstStream = class(TInterfacedObject,IwstStream)
private
FStream : TStream;
protected
function Read(
ABuffer : Pointer;
const ALenToRead : LongWord;
out AReadedLen : LongWord
):LongInt;
function Write(
ABuffer : Pointer;
const ALenToWrite : LongWord;
out AWrittenLen : LongWord
):LongInt;
function GetSize(out ASize : LongWord):LongInt;
function SetSize(const ANewSize : LongWord):LongInt;
function GetPosition(out APos : LongWord):LongWord;
function SetPosition(const ANewPos : LongWord):LongInt;
public
constructor Create(AStream : TStream);
end;
TwstLibraryHandlerFunction =
function(
ARequestBuffer : IwstStream;
@ -85,5 +109,65 @@ begin
end;
end;
{ TwstStream }
function TwstStream.Read(
ABuffer : Pointer;
const ALenToRead : LongWord;
out AReadedLen : LongWord
): LongInt;
begin
try
AReadedLen := FStream.Read(ABuffer^,ALenToRead);
Result := RET_OK;
except
Result := RET_FALSE;
end;
end;
function TwstStream.Write(
ABuffer : Pointer;
const ALenToWrite : LongWord;
out AWrittenLen : LongWord
): LongInt;
begin
try
AWrittenLen := FStream.Write(ABuffer^,ALenToWrite);
Result := RET_OK;
except
Result := RET_FALSE;
end;
end;
function TwstStream.GetSize(out ASize: LongWord): LongInt;
begin
ASize := FStream.Size;
Result := RET_OK;
end;
function TwstStream.SetSize(const ANewSize: LongWord): LongInt;
begin
FStream.Size := ANewSize;
Result := RET_OK;
end;
function TwstStream.GetPosition(out APos: LongWord): LongWord;
begin
APos := FStream.Position;
Result := RET_OK;
end;
function TwstStream.SetPosition(const ANewPos: LongWord): LongInt;
begin
FStream.Position := ANewPos;
Result := RET_OK;
end;
constructor TwstStream.Create(AStream: TStream);
begin
Assert(Assigned(AStream));
FStream := AStream;
end;
end.

View File

@ -16,13 +16,28 @@ unit library_imp_utils;
interface
uses
Classes, SysUtils;
Classes, SysUtils
{$IFDEF FPC}
, DynLibs
{$ELSE}
, Windows
{$ENDIF}
;
{$INCLUDE wst.inc}
{$INCLUDE wst_delphi.inc}
{$IFNDEF FPC}
const
NilHandle = 0;
{$ENDIF}
type
{$IFNDEF FPC}
TLibHandle = Longint;
{$ENDIF}
IwstModule = interface
['{A62A9A71-727E-47AD-9B84-0F7CA0AE51D5}']
function GetFileName():string;
@ -33,61 +48,57 @@ type
['{0A49D315-FF3E-40CD-BCA0-F958BCD5C57F}']
function Get(const AFileName : string):IwstModule;
procedure Clear();
function GetCount() : PtrInt;
function GetItem(const AIndex : PtrInt) : IwstModule;
end;
var
LibraryManager : IwstModuleManager = nil;
implementation
{$IFDEF FPC}
uses DynLibs;
{$ELSE}
uses Windows;
type TLibHandle = THandle;
const NilHandle = 0;
{$ENDIF}
type
{ TwstModule }
TwstModule = class(TInterfacedObject,IwstModule)
private
FFileName : string;
FHandle : TLibHandle;
private
procedure Load(const ADoLoad : Boolean);
protected
function GetFileName():string;
function GetProc(const AProcName : string):Pointer;
procedure Load(const ADoLoad : Boolean);virtual;
public
constructor Create(const AFileName : string);
constructor Create(const AFileName : string);virtual;
destructor Destroy();override;
end;
TwstModuleClass = class of TwstModule;
{ TwstModuleManager }
TwstModuleManager = class(TInterfacedObject,IwstModuleManager)
private
FList : IInterfaceList;
FItemClass : TwstModuleClass;
private
function Load(const AFileName : string):IwstModule;
function GetItem(const AIndex : Integer):IwstModule;
function IndexOf(const AFileName : string):Integer;
protected
function Get(const AFileName : string):IwstModule;
procedure Clear();
function GetCount() : PtrInt;
function GetItem(const AIndex : PtrInt) : IwstModule;
public
constructor Create();
constructor Create(AItemClass : TwstModuleClass);
destructor Destroy();override;
end;
var
LibraryManager : IwstModuleManager = nil;
implementation
procedure TwstModule.Load(const ADoLoad : Boolean);
begin
if ADoLoad then begin
if ( FHandle = NilHandle ) then begin
if not FileExists(FFileName) then
raise Exception.CreateFmt('File not found : "%s".',[FFileName]);
{$IFDEF FPC}
FHandle := LoadLibrary(FFileName);
{$ELSE}
@ -122,8 +133,6 @@ end;
constructor TwstModule.Create(const AFileName: string);
begin
if not FileExists(AFileName) then
raise Exception.CreateFmt('File not found : "%s".',[AFileName]);
FHandle := NilHandle;
FFileName := AFileName;
Load(True);
@ -142,10 +151,22 @@ var
i : Integer;
begin
i := IndexOf(AFileName);
if ( i < 0 ) then
Result := Load(AFileName)
else
if ( i < 0 ) then begin
FList.Lock();
try
i := IndexOf(AFileName);
if ( i < 0 ) then begin
Result := Load(AFileName);
FList.Add(Result);
end else begin
Result := GetItem(i);;
end;
finally
FList.Unlock();
end;
end else begin
Result := GetItem(i);
end;
end;
procedure TwstModuleManager.Clear();
@ -153,16 +174,21 @@ begin
FList.Clear();
end;
function TwstModuleManager.Load(const AFileName: string): IwstModule;
function TwstModuleManager.GetCount(): PtrInt;
begin
Result := TwstModule.Create(AFileName);
Result := FList.Count;
end;
function TwstModuleManager.GetItem(const AIndex: Integer): IwstModule;
function TwstModuleManager.GetItem(const AIndex: PtrInt): IwstModule;
begin
Result := FList[AIndex] as IwstModule;
end;
function TwstModuleManager.Load(const AFileName: string): IwstModule;
begin
Result := FItemClass.Create(AFileName);
end;
function TwstModuleManager.IndexOf(const AFileName: string): Integer;
begin
for Result := 0 to Pred(FList.Count) do begin
@ -172,9 +198,11 @@ begin
Result := -1;
end;
constructor TwstModuleManager.Create();
constructor TwstModuleManager.Create(AItemClass : TwstModuleClass);
begin
inherited;
Assert(Assigned(AItemClass));
inherited Create();
FItemClass := AItemClass;
FList := TInterfaceList.Create();
end;
@ -186,7 +214,7 @@ end;
procedure InitLibraryManager();
begin
LibraryManager := TwstModuleManager.Create();
LibraryManager := TwstModuleManager.Create(TwstModule);
end;
initialization

View File

@ -60,92 +60,6 @@ Type
implementation
uses binary_streamer;
type
{ TwstStream }
TwstStream = class(TInterfacedObject,IwstStream)
private
FStream : TStream;
protected
function Read(
ABuffer : Pointer;
const ALenToRead : LongWord;
out AReadedLen : LongWord
):LongInt;
function Write(
ABuffer : Pointer;
const ALenToWrite : LongWord;
out AWrittenLen : LongWord
):LongInt;
function GetSize(out ASize : LongWord):LongInt;
function SetSize(const ANewSize : LongWord):LongInt;
function GetPosition(out APos : LongWord):LongWord;
function SetPosition(const ANewPos : LongWord):LongInt;
public
constructor Create(AStream : TStream);
end;
{ TwstStream }
function TwstStream.Read(
ABuffer : Pointer;
const ALenToRead : LongWord;
out AReadedLen : LongWord
): LongInt;
begin
try
AReadedLen := FStream.Read(ABuffer^,ALenToRead);
Result := RET_OK;
except
Result := RET_FALSE;
end;
end;
function TwstStream.Write(
ABuffer : Pointer;
const ALenToWrite : LongWord;
out AWrittenLen : LongWord
): LongInt;
begin
try
AWrittenLen := FStream.Write(ABuffer^,ALenToWrite);
Result := RET_OK;
except
Result := RET_FALSE;
end;
end;
function TwstStream.GetSize(out ASize: LongWord): LongInt;
begin
ASize := FStream.Size;
Result := RET_OK;
end;
function TwstStream.SetSize(const ANewSize: LongWord): LongInt;
begin
FStream.Size := ANewSize;
Result := RET_OK;
end;
function TwstStream.GetPosition(out APos: LongWord): LongWord;
begin
APos := FStream.Position;
Result := RET_OK;
end;
function TwstStream.SetPosition(const ANewPos: LongWord): LongInt;
begin
FStream.Position := ANewPos;
Result := RET_OK;
end;
constructor TwstStream.Create(AStream: TStream);
begin
Assert(Assigned(AStream));
FStream := AStream;
end;
{ TLIBTransport }
procedure TLIBTransport.SetFileName(const AValue: string);

View File

@ -7,7 +7,7 @@
<MainUnit Value="0"/>
<IconPath Value="./"/>
<TargetFileExt Value=".exe"/>
<ActiveEditorIndexAtStart Value="0"/>
<ActiveEditorIndexAtStart Value="3"/>
</General>
<VersionInfo>
<ProjectVersion Value=""/>
@ -24,121 +24,482 @@
<LaunchingApplication PathPlusParams="/usr/X11R6/bin/xterm -T 'Lazarus Run Output' -e $(LazarusDir)/tools/runwait.sh $(TargetCmdLine)"/>
</local>
</RunParams>
<Units Count="14">
<Units Count="56">
<Unit0>
<Filename Value="mod_wst.lpr"/>
<IsPartOfProject Value="True"/>
<UnitName Value="mod_wst"/>
<CursorPos X="3" Y="11"/>
<CursorPos X="38" Y="11"/>
<TopLine Value="1"/>
<EditorIndex Value="0"/>
<UsageCount Value="36"/>
<UsageCount Value="68"/>
<Loaded Value="True"/>
</Unit0>
<Unit1>
<Filename Value="wst_apache_binding.pas"/>
<UnitName Value="wst_apache_binding"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="249"/>
<EditorIndex Value="4"/>
<UsageCount Value="18"/>
<CursorPos X="19" Y="74"/>
<TopLine Value="70"/>
<EditorIndex Value="1"/>
<UsageCount Value="33"/>
<Loaded Value="True"/>
</Unit1>
<Unit2>
<Filename Value="..\..\metadata_wsdl.pas"/>
<UnitName Value="metadata_wsdl"/>
<CursorPos X="70" Y="30"/>
<TopLine Value="16"/>
<EditorIndex Value="8"/>
<UsageCount Value="18"/>
<Loaded Value="True"/>
<CursorPos X="5" Y="82"/>
<TopLine Value="67"/>
<UsageCount Value="33"/>
</Unit2>
<Unit3>
<Filename Value="..\user_service_intf_imp.pas"/>
<UnitName Value="user_service_intf_imp"/>
<CursorPos X="71" Y="20"/>
<TopLine Value="1"/>
<EditorIndex Value="9"/>
<UsageCount Value="18"/>
<Loaded Value="True"/>
<CursorPos X="8" Y="225"/>
<TopLine Value="191"/>
<UsageCount Value="21"/>
</Unit3>
<Unit4>
<Filename Value="..\..\..\..\..\lazarus23_213\fpc\2.1.3\source\packages\base\httpd\httpd-1.3\httpd.pas"/>
<UnitName Value="httpd"/>
<CursorPos X="5" Y="26"/>
<TopLine Value="25"/>
<UsageCount Value="9"/>
<UsageCount Value="6"/>
</Unit4>
<Unit5>
<Filename Value="..\..\..\..\..\lazarus23_213\fpc\2.1.3\source\packages\base\httpd\httpd-1.3\httpd.inc"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="75"/>
<UsageCount Value="9"/>
<UsageCount Value="6"/>
</Unit5>
<Unit6>
<Filename Value="..\..\..\..\..\lazarus23_213\fpc\2.1.3\source\packages\base\httpd\httpd-2.2\httpd.pas"/>
<UnitName Value="httpd"/>
<CursorPos X="35" Y="44"/>
<TopLine Value="61"/>
<UsageCount Value="9"/>
<UsageCount Value="6"/>
</Unit6>
<Unit7>
<Filename Value="..\..\..\..\..\..\lazarus23_213\fpc\2.1.3\source\packages\base\httpd\httpd-2.2\http_protocol.inc"/>
<CursorPos X="47" Y="799"/>
<TopLine Value="777"/>
<EditorIndex Value="7"/>
<UsageCount Value="12"/>
<Loaded Value="True"/>
<UsageCount Value="9"/>
</Unit7>
<Unit8>
<Filename Value="..\..\..\..\..\..\lazarus23_213\fpc\2.1.3\source\packages\base\httpd\httpd-2.2\httpd.inc"/>
<CursorPos X="5" Y="794"/>
<TopLine Value="777"/>
<EditorIndex Value="6"/>
<UsageCount Value="11"/>
<Loaded Value="True"/>
<UsageCount Value="8"/>
</Unit8>
<Unit9>
<Filename Value="..\..\..\..\..\..\lazarus23_213\fpc\2.1.3\source\packages\base\httpd\httpd-2.0\apr\apr_tables.inc"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="16"/>
<EditorIndex Value="5"/>
<UsageCount Value="11"/>
<Loaded Value="True"/>
<UsageCount Value="8"/>
</Unit9>
<Unit10>
<Filename Value="..\..\..\..\..\..\lazarus23_213\fpc\2.1.3\source\packages\base\httpd\httpd-2.2\http_config.inc"/>
<CursorPos X="71" Y="66"/>
<TopLine Value="32"/>
<EditorIndex Value="1"/>
<UsageCount Value="11"/>
<Loaded Value="True"/>
<UsageCount Value="8"/>
</Unit10>
<Unit11>
<Filename Value="..\..\..\..\..\..\lazarus23_213\fpc\2.1.3\source\packages\base\httpd\httpd-2.2\httpd.pas"/>
<UnitName Value="httpd"/>
<CursorPos X="41" Y="134"/>
<TopLine Value="117"/>
<EditorIndex Value="2"/>
<UsageCount Value="11"/>
<Loaded Value="True"/>
<UsageCount Value="8"/>
</Unit11>
<Unit12>
<Filename Value="..\..\..\..\..\..\lazarus23_213\fpc\2.1.3\source\packages\base\httpd\httpd-2.2\ap_mmn.inc"/>
<CursorPos X="3" Y="111"/>
<TopLine Value="96"/>
<EditorIndex Value="3"/>
<UsageCount Value="11"/>
<Loaded Value="True"/>
<UsageCount Value="8"/>
</Unit12>
<Unit13>
<Filename Value="..\..\..\..\..\..\lazarus23_213\fpc\2.1.3\source\packages\base\httpd\httpd-2.0\apr\apr_pools.inc"/>
<CursorPos X="3" Y="48"/>
<TopLine Value="678"/>
<UsageCount Value="10"/>
<UsageCount Value="7"/>
</Unit13>
<Unit14>
<Filename Value="..\..\wst_rtti_filter\cursor_intf.pas"/>
<UnitName Value="cursor_intf"/>
<CursorPos X="16" Y="18"/>
<TopLine Value="1"/>
<UsageCount Value="9"/>
</Unit14>
<Unit15>
<Filename Value="..\user_service_intf_binder.pas"/>
<UnitName Value="user_service_intf_binder"/>
<CursorPos X="3" Y="252"/>
<TopLine Value="250"/>
<UsageCount Value="13"/>
</Unit15>
<Unit16>
<Filename Value="..\imp_helper.pas"/>
<UnitName Value="imp_helper"/>
<CursorPos X="1" Y="76"/>
<TopLine Value="33"/>
<UsageCount Value="20"/>
</Unit16>
<Unit17>
<Filename Value="..\..\metadata_service_binder.pas"/>
<UnitName Value="metadata_service_binder"/>
<CursorPos X="29" Y="43"/>
<TopLine Value="1"/>
<UsageCount Value="25"/>
</Unit17>
<Unit18>
<Filename Value="..\..\metadata_service.pas"/>
<UnitName Value="metadata_service"/>
<CursorPos X="71" Y="76"/>
<TopLine Value="1"/>
<UsageCount Value="25"/>
</Unit18>
<Unit19>
<Filename Value="..\..\metadata_service_imp.pas"/>
<UnitName Value="metadata_service_imp"/>
<CursorPos X="61" Y="21"/>
<TopLine Value="13"/>
<UsageCount Value="24"/>
</Unit19>
<Unit20>
<Filename Value="..\..\library_imp_utils.pas"/>
<UnitName Value="library_imp_utils"/>
<CursorPos X="42" Y="35"/>
<TopLine Value="73"/>
<EditorIndex Value="7"/>
<UsageCount Value="24"/>
<Loaded Value="True"/>
</Unit20>
<Unit21>
<Filename Value="..\..\..\..\..\..\lazarus_23_2.2.1\fpc\2.2.1\source\packages\base\httpd\httpd-2.0\apr\apr.pas"/>
<UnitName Value="apr"/>
<CursorPos X="18" Y="182"/>
<TopLine Value="173"/>
<UsageCount Value="10"/>
</Unit21>
<Unit22>
<Filename Value="..\..\..\..\..\..\lazarus_23_2.2.1\fpc\2.2.1\source\packages\base\httpd\httpd-2.0\apr\apr_file_info.inc"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="151"/>
<UsageCount Value="7"/>
</Unit22>
<Unit23>
<Filename Value="..\..\..\..\..\..\lazarus_23_2.2.1\fpc\2.2.1\source\packages\base\httpd\httpd-2.0\apr\apr_file_io.inc"/>
<CursorPos X="124" Y="665"/>
<TopLine Value="778"/>
<UsageCount Value="7"/>
</Unit23>
<Unit24>
<Filename Value="..\..\..\..\..\..\lazarus_23_2.2.1\fpc\2.2.1\source\packages\base\httpd\httpd-2.0\apr\apr_dso.inc"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="66"/>
<UsageCount Value="7"/>
</Unit24>
<Unit25>
<Filename Value="..\..\..\..\..\..\lazarus_23_2.2.1\fpc\2.2.1\source\packages\base\httpd\httpd-2.0\apr\apr_lib.inc"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="192"/>
<UsageCount Value="7"/>
</Unit25>
<Unit26>
<Filename Value="..\..\..\..\..\..\lazarus_23_2.2.1\fpc\2.2.1\source\packages\base\httpd\httpd-2.0\apr\apr_general.inc"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="199"/>
<UsageCount Value="7"/>
</Unit26>
<Unit27>
<Filename Value="..\..\..\..\..\..\lazarus_23_2.2.1\fpc\2.2.1\source\packages\base\httpd\httpd-2.0\apr\apr_strings.inc"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="329"/>
<UsageCount Value="7"/>
</Unit27>
<Unit28>
<Filename Value="..\..\..\..\..\..\lazarus_23_2.2.1\fpc\2.2.1\source\packages\base\httpd\httpd-1.3\httpd.inc"/>
<CursorPos X="21" Y="23"/>
<TopLine Value="10"/>
<UsageCount Value="12"/>
</Unit28>
<Unit29>
<Filename Value="..\..\library_base_intf.pas"/>
<UnitName Value="library_base_intf"/>
<CursorPos X="29" Y="17"/>
<TopLine Value="73"/>
<EditorIndex Value="5"/>
<UsageCount Value="23"/>
<Loaded Value="True"/>
</Unit29>
<Unit30>
<Filename Value="..\..\..\..\..\..\lazarus_23_2.2.1\fpc\2.2.1\source\packages\base\httpd\httpd-1.3\ap_alloc.inc"/>
<CursorPos X="3" Y="45"/>
<TopLine Value="30"/>
<UsageCount Value="11"/>
</Unit30>
<Unit31>
<Filename Value="..\..\..\..\..\..\lazarus_23_2.2.1\fpc\2.2.1\source\packages\base\httpd\httpd-2.0\apr\apr_pools.inc"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="678"/>
<UsageCount Value="7"/>
</Unit31>
<Unit32>
<Filename Value="..\..\..\..\..\..\lazarus_23_2.2.1\fpc\2.2.1\source\packages\base\httpd\httpd-1.3\httpd.pas"/>
<UnitName Value="httpd"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="82"/>
<UsageCount Value="10"/>
</Unit32>
<Unit33>
<Filename Value="..\..\..\..\..\..\lazarus_23_2.2.1\fpc\2.2.1\source\packages\base\httpd\httpd-1.3\http_log.inc"/>
<CursorPos X="11" Y="75"/>
<TopLine Value="60"/>
<UsageCount Value="10"/>
</Unit33>
<Unit34>
<Filename Value="..\..\server_service_xmlrpc.pas"/>
<UnitName Value="server_service_xmlrpc"/>
<CursorPos X="17" Y="57"/>
<TopLine Value="42"/>
<UsageCount Value="13"/>
</Unit34>
<Unit35>
<Filename Value="..\..\base_xmlrpc_formatter.pas"/>
<UnitName Value="base_xmlrpc_formatter"/>
<CursorPos X="3" Y="29"/>
<TopLine Value="14"/>
<UsageCount Value="13"/>
</Unit35>
<Unit36>
<Filename Value="..\..\server_service_intf.pas"/>
<UnitName Value="server_service_intf"/>
<CursorPos X="5" Y="18"/>
<TopLine Value="3"/>
<UsageCount Value="21"/>
</Unit36>
<Unit37>
<Filename Value="..\..\..\..\..\..\lazarus_23_2.2.1\fpc\2.2.1\source\rtl\win32\classes.pp"/>
<UnitName Value="Classes"/>
<CursorPos X="8" Y="46"/>
<TopLine Value="21"/>
<UsageCount Value="8"/>
</Unit37>
<Unit38>
<Filename Value="..\..\..\..\..\..\lazarus_23_2.2.1\fpc\2.2.1\source\rtl\objpas\classes\classes.inc"/>
<CursorPos X="11" Y="1674"/>
<TopLine Value="1665"/>
<UsageCount Value="8"/>
</Unit38>
<Unit39>
<Filename Value="..\..\..\..\..\..\lazarus_23_2.2.1\fpc\2.2.1\source\packages\base\httpd\httpd-1.3\http_config.inc"/>
<CursorPos X="24" Y="165"/>
<TopLine Value="150"/>
<UsageCount Value="8"/>
</Unit39>
<Unit40>
<Filename Value="..\..\..\..\..\..\lazarus_23_2.2.1\fpc\2.2.1\source\packages\base\httpd\httpd-2.2\apr\apr_pools.inc"/>
<CursorPos X="3" Y="48"/>
<TopLine Value="33"/>
<UsageCount Value="8"/>
</Unit40>
<Unit41>
<Filename Value="..\..\..\..\..\..\lazarus_23_2.2.1\fpc\2.2.1\source\packages\base\httpd\httpd-2.2\http_config.inc"/>
<CursorPos X="25" Y="154"/>
<TopLine Value="117"/>
<UsageCount Value="17"/>
</Unit41>
<Unit42>
<Filename Value="..\..\..\..\..\..\lazarus_23_2.2.1\fpc\2.2.1\source\packages\base\httpd\httpd-2.2\httpd.pas"/>
<UnitName Value="httpd"/>
<CursorPos X="3" Y="70"/>
<TopLine Value="55"/>
<UsageCount Value="15"/>
</Unit42>
<Unit43>
<Filename Value="..\..\..\..\..\..\lazarus_23_2.2.1\fpc\2.2.1\source\packages\base\httpd\httpd-2.2\httpd.inc"/>
<CursorPos X="5" Y="1029"/>
<TopLine Value="1014"/>
<UsageCount Value="11"/>
</Unit43>
<Unit44>
<Filename Value="..\..\..\..\..\..\lazarus_23_2.2.1\fpc\2.2.1\source\packages\base\httpd\httpd-2.2\http_log.inc"/>
<CursorPos X="15" Y="34"/>
<TopLine Value="17"/>
<UsageCount Value="11"/>
</Unit44>
<Unit45>
<Filename Value="..\..\..\..\..\..\lazarus_23_2.2.1\fpc\2.2.1\source\packages\base\httpd\httpd-2.0\http_config.inc"/>
<CursorPos X="1" Y="136"/>
<TopLine Value="113"/>
<UsageCount Value="13"/>
</Unit45>
<Unit46>
<Filename Value="..\..\wst.inc"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="1"/>
<UsageCount Value="9"/>
</Unit46>
<Unit47>
<Filename Value="..\..\base_service_intf.pas"/>
<UnitName Value="base_service_intf"/>
<CursorPos X="25" Y="1252"/>
<TopLine Value="1237"/>
<EditorIndex Value="6"/>
<UsageCount Value="13"/>
<Loaded Value="True"/>
</Unit47>
<Unit48>
<Filename Value="..\..\imp_utils.pas"/>
<UnitName Value="imp_utils"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="38"/>
<UsageCount Value="10"/>
</Unit48>
<Unit49>
<Filename Value="..\..\wst_resources_imp.pas"/>
<UnitName Value="wst_resources_imp"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="13"/>
<UsageCount Value="10"/>
</Unit49>
<Unit50>
<Filename Value="..\..\record_rtti.pas"/>
<UnitName Value="record_rtti"/>
<CursorPos X="5" Y="66"/>
<TopLine Value="51"/>
<UsageCount Value="10"/>
</Unit50>
<Unit51>
<Filename Value="..\..\server_service_imputils.pas"/>
<UnitName Value="server_service_imputils"/>
<CursorPos X="5" Y="18"/>
<TopLine Value="3"/>
<UsageCount Value="10"/>
</Unit51>
<Unit52>
<Filename Value="..\..\server_service_soap.pas"/>
<UnitName Value="server_service_soap"/>
<CursorPos X="15" Y="22"/>
<TopLine Value="1"/>
<EditorIndex Value="2"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit52>
<Unit53>
<Filename Value="..\..\base_soap_formatter.pas"/>
<UnitName Value="base_soap_formatter"/>
<CursorPos X="5" Y="356"/>
<TopLine Value="342"/>
<EditorIndex Value="3"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit53>
<Unit54>
<Filename Value="..\..\server_binary_formatter.pas"/>
<UnitName Value="server_binary_formatter"/>
<CursorPos X="5" Y="18"/>
<TopLine Value="3"/>
<UsageCount Value="10"/>
</Unit54>
<Unit55>
<Filename Value="..\..\metadata_repository.pas"/>
<UnitName Value="metadata_repository"/>
<CursorPos X="5" Y="117"/>
<TopLine Value="102"/>
<EditorIndex Value="4"/>
<UsageCount Value="10"/>
<Loaded Value="True"/>
</Unit55>
</Units>
<JumpHistory Count="0" HistoryIndex="-1"/>
<JumpHistory Count="22" HistoryIndex="21">
<Position1>
<Filename Value="wst_apache_binding.pas"/>
<Caret Line="72" Column="16" TopLine="70"/>
</Position1>
<Position2>
<Filename Value="..\..\base_service_intf.pas"/>
<Caret Line="1" Column="1" TopLine="1"/>
</Position2>
<Position3>
<Filename Value="..\..\base_service_intf.pas"/>
<Caret Line="20" Column="5" TopLine="5"/>
</Position3>
<Position4>
<Filename Value="..\..\base_service_intf.pas"/>
<Caret Line="1252" Column="25" TopLine="1237"/>
</Position4>
<Position5>
<Filename Value="wst_apache_binding.pas"/>
<Caret Line="73" Column="19" TopLine="70"/>
</Position5>
<Position6>
<Filename Value="wst_apache_binding.pas"/>
<Caret Line="73" Column="34" TopLine="70"/>
</Position6>
<Position7>
<Filename Value="wst_apache_binding.pas"/>
<Caret Line="74" Column="22" TopLine="70"/>
</Position7>
<Position8>
<Filename Value="..\..\server_service_soap.pas"/>
<Caret Line="1" Column="1" TopLine="1"/>
</Position8>
<Position9>
<Filename Value="..\..\server_service_soap.pas"/>
<Caret Line="22" Column="18" TopLine="3"/>
</Position9>
<Position10>
<Filename Value="..\..\base_soap_formatter.pas"/>
<Caret Line="1" Column="1" TopLine="1"/>
</Position10>
<Position11>
<Filename Value="..\..\base_soap_formatter.pas"/>
<Caret Line="18" Column="5" TopLine="3"/>
</Position11>
<Position12>
<Filename Value="wst_apache_binding.pas"/>
<Caret Line="74" Column="41" TopLine="70"/>
</Position12>
<Position13>
<Filename Value="wst_apache_binding.pas"/>
<Caret Line="74" Column="56" TopLine="70"/>
</Position13>
<Position14>
<Filename Value="wst_apache_binding.pas"/>
<Caret Line="75" Column="22" TopLine="70"/>
</Position14>
<Position15>
<Filename Value="..\..\metadata_repository.pas"/>
<Caret Line="1" Column="1" TopLine="1"/>
</Position15>
<Position16>
<Filename Value="..\..\metadata_repository.pas"/>
<Caret Line="18" Column="5" TopLine="3"/>
</Position16>
<Position17>
<Filename Value="wst_apache_binding.pas"/>
<Caret Line="75" Column="36" TopLine="70"/>
</Position17>
<Position18>
<Filename Value="wst_apache_binding.pas"/>
<Caret Line="76" Column="12" TopLine="70"/>
</Position18>
<Position19>
<Filename Value="wst_apache_binding.pas"/>
<Caret Line="74" Column="19" TopLine="70"/>
</Position19>
<Position20>
<Filename Value="..\..\server_service_soap.pas"/>
<Caret Line="22" Column="15" TopLine="1"/>
</Position20>
<Position21>
<Filename Value="..\..\base_soap_formatter.pas"/>
<Caret Line="1" Column="1" TopLine="7"/>
</Position21>
<Position22>
<Filename Value="..\..\base_soap_formatter.pas"/>
<Caret Line="18" Column="58" TopLine="3"/>
</Position22>
</JumpHistory>
</ProjectOptions>
<CompilerOptions>
<Version Value="5"/>
@ -147,9 +508,10 @@
<Filename Value="mod_wst.so"/>
</Target>
<SearchPaths>
<OtherUnitFiles Value="..\;..\..\;..\..\wst_rtti_filter\;$(LazarusDir)\fpc\2.1.3\source\packages\base\httpd\httpd-2.2\;$(LazarusDir)\fpc\2.1.3\source\packages\base\httpd\httpd-2.2\apr\;$(LazarusDir)\fpc\2.1.3\source\packages\base\httpd\httpd-2.2\apriconv\;$(LazarusDir)\fpc\2.1.3\source\packages\base\httpd\httpd-2.2\aprutil\"/>
<IncludeFiles Value="..\..\"/>
<OtherUnitFiles Value="..\;..\..\;..\..\wst_rtti_filter\;$(FPCSrcDir)\packages\base\httpd\httpd-2.0\;$(FPCSrcDir)\packages\base\httpd\httpd-2.0\apr\;$(FPCSrcDir)\packages\base\httpd\httpd-2.0\apriconv\;$(FPCSrcDir)\packages\base\httpd\httpd-2.0\aprutil\"/>
<UnitOutputDirectory Value="obj"/>
<SrcPath Value="$(LazarusDir)\fpc\2.1.3\source\packages\base\httpd\httpd-2.2\;$(LazarusDir)\fpc\2.1.3\source\packages\base\httpd\httpd-2.2\apr\;$(LazarusDir)\fpc\2.1.3\source\packages\base\httpd\httpd-2.2\apriconv\;$(LazarusDir)\fpc\2.1.3\source\packages\base\httpd\httpd-2.2\aprutil\"/>
<SrcPath Value="$(FPCSrcDir)\packages\base\httpd\httpd-2.0\;$(FPCSrcDir)\packages\base\httpd\httpd-2.0\apr\;$(FPCSrcDir)\packages\base\httpd\httpd-2.0\apriconv\;$(FPCSrcDir)\packages\base\httpd\httpd-2.0\aprutil\"/>
</SearchPaths>
<CodeGeneration>
<Generate Value="Faster"/>

View File

@ -41,6 +41,7 @@ end;
begin
default_module_ptr := @wst_module;
wst_apache_binding.wst_module_ptr := default_module_ptr;
FillChar(default_module_ptr^, SizeOf(default_module_ptr^), 0);
STANDARD20_MODULE_STUFF(default_module_ptr^);
with wst_module do
@ -48,5 +49,9 @@ begin
name := MODULE_NAME;
magic := MODULE_MAGIC_COOKIE;
register_hooks := @RegisterHooks;
create_dir_config := @wst_create_dir_config;
cmds := WstCommandStructArray;
end;
WstCommandStructArray[0].cmd_data := @WstConfigData^.BasePath;
FillChar(WstCommandStructArray[1],SizeOf(command_rec),#0);
end.

View File

@ -1,4 +1,27 @@
{$DEFINE WST_DBG}
{$UNDEF WST_DBG}
(*WST_BROKER enable the service brokering :
if enabled, this module just forwards the request to the
implementation libraries contained in the WstRootPath path.
WST load these libraries in the local file system folder
configured by the value of WstRootPath.
WstRootPath is a configuration directive which must be
in the wst "Location" scope.
Example :
<Location /wst>
SetHandler wst-handler
WstRootPath "C:/Programmes/lazarus/wst/trunk/samples/library_server/"
</Location>
Services can then be invoked through the following addressing schema
http://127.0.0.1:8080/wst/services/lib_server/UserService
lib_server : the library name ( without extension )
UserService : the target service
wst/services : constant.
*)
{$DEFINE WST_BROKER}
unit wst_apache_binding;
@ -17,25 +40,82 @@ const
sWSDL = 'WSDL';
sHTTP_BINARY_CONTENT_TYPE = 'application/octet-stream';
sCONTENT_TYPE = 'Content-Type';
sWstRootPath = 'WstRootPath'; // The WST local file system path configure in apache
sWST_LIBRARY_EXTENSION = '.wml';
type
PWstConfigData = ^TWstConfigData;
TWstConfigData = record
Dir : PChar;
BasePath : PChar;
end;
var
wst_module_ptr : Pmodule = nil;
WstConfigData : PWstConfigData = nil;
WstCommandStructArray : array[0..1] of command_rec = (
( name : sWstRootPath;
func : ( func_take1 : @ap_set_string_slot );
cmd_data : ( nil {@WstConfigData^.BasePath} );
req_override : OR_ALL;
args_how : TAKE1;
errmsg : 'usage : WstRootPath <path>' + LineEnding + ' path is the path to the WST root path.';
),
()
);
function wst_RequestHandler(r: Prequest_rec): Integer;
function wst_create_dir_config(p: Papr_pool_t; dir: PChar) : Pointer;cdecl;
implementation
uses base_service_intf,
server_service_intf, server_service_imputils,
server_service_soap, server_binary_formatter,
metadata_repository, metadata_wsdl, DOM, XMLWrite,
user_service_intf, user_service_intf_binder, user_service_intf_imp,
server_service_soap, server_binary_formatter, server_service_xmlrpc,
metadata_repository, metadata_wsdl,
imp_utils, binary_streamer, library_base_intf, library_imp_utils,
DOM, XMLWrite,
metadata_service, metadata_service_binder, metadata_service_imp;
procedure wst_initialize();
begin
RegisterStdTypes();
Server_service_RegisterBinaryFormat();
Server_service_RegisterSoapFormat();
//Server_service_RegisterXmlRpcFormat();
RegisterWSTMetadataServiceImplementationFactory();
Server_service_RegisterWSTMetadataServiceService();
end;
function wst_create_dir_config(p: Papr_pool_t; dir: PChar) : Pointer; cdecl;
begin
WstConfigData := PWstConfigData(apr_palloc(p,SizeOf(TWstConfigData)));
FillChar(WstConfigData^,SizeOf(TWstConfigData),#0);
WstConfigData^.Dir := apr_pstrdup(p,dir);
Result := WstConfigData;
end;
function GetWstPath(): PChar;inline;
begin
Result := WstConfigData^.BasePath;
end;
type
PRequestArgument = ^TRequestArgument;
TRequestArgument = record
Name : shortstring;
Value : shortstring;
Next : PRequestArgument;
end;
TRequestInfo = record
Root : string;
URI : string;
ContentType : string;
Buffer : string;
Argument : string;
InnerRequest : Pointer;
Root : string;
URI : string;
ContentType : string;
Buffer : string;
Arguments : string;
ArgList : PRequestArgument;
end;
TResponseInfo = record
@ -43,6 +123,52 @@ type
ContentType : string;
end;
function ParseArgs(
const APool : Papr_pool_t;
const AArgs : string;
const ASeparator : Char = '&'
) : PRequestArgument;
var
locBuffer, locArg : string;
locPrev, locTmpArg : PRequestArgument;
begin
Result := nil;
locBuffer := Trim(AArgs);
if not IsStrEmpty(locBuffer) then begin
locTmpArg := nil;
locPrev := nil;
while True do begin
locArg := GetToken(locBuffer,ASeparator);
if IsStrEmpty(locArg) then
Break;
locPrev := locTmpArg;
locTmpArg := PRequestArgument(apr_palloc(APool,SizeOf(TRequestArgument)));
FillChar(locTmpArg^,SizeOf(TRequestArgument),#0);
if ( Result = nil ) then begin
Result := locTmpArg;
end else begin
locPrev^.Next := locTmpArg;
end;
locTmpArg^.Name := GetToken(locArg,'=');
locTmpArg^.Value := locArg;
end;
end;
end;
function FindArg(const AArgs : PRequestArgument; const AName : string) : PRequestArgument;
var
p : PRequestArgument;
begin
Result := nil;
p := AArgs;
while Assigned(p) do begin
if AnsiSameText(AName,AArgs^.Name) then begin
Result := p;
Break;
end;
p := p^.Next;
end;
end;
procedure SaveStringToFile(const AStr,AFile:string;const AKeepExisting : Boolean);
begin
@ -154,7 +280,7 @@ begin
Result := '<html>' +
'<head>'+
'<title>'+
'The Web Service Toolkit generated Metadata table'+
'The Web Service Toolkit generated Metadata table XXXXX'+
'</title>'+
'<body>' +
'<p BGCOLOR="#DDEEFF"><FONT FACE="Arial" COLOR="#0000A0" SIZE="+2">The following repositories has available. Click on the link to view the corresponding WSDL.</FONT></p>'+
@ -233,7 +359,7 @@ begin
AResponseInfo.ContentType := sHTTP_BINARY_CONTENT_TYPE
else
AResponseInfo.ContentType := ctntyp;
rqst := TRequestBuffer.Create(trgt,ctntyp,inStream,outStream,'');
rqst := TRequestBuffer.Create(trgt,ctntyp,inStream,outStream,ARequestInfo.ContentType);
HandleServiceRequest(rqst);
i := outStream.Size;
if ( i > 0 ) then begin
@ -244,7 +370,7 @@ begin
outStream.Free();
inStream.Free();
{$IFDEF WST_DBG}
SaveStringToFile('RequestInfo.ContentType=' + ARequestInfo.Argument + LineEnding,'c:\log.log',False);
SaveStringToFile('RequestInfo.ContentType=' + ARequestInfo.Arguments + LineEnding,'c:\log.log',False);
{SaveStringToFile('RequestInfo.Buffer=' + ARequestInfo.Buffer + LineEnding,'E:\Inoussa\Sources\lazarus\wst\v0.3\tests\apache_module\log.log',True);
SaveStringToFile('RequestInfo.URI=' + ARequestInfo.URI + LineEnding,'E:\Inoussa\Sources\lazarus\wst\v0.3\tests\apache_module\log.log',True);
SaveStringToFile('ResponseInfo.ContentType=' + AResponseInfo.ContentType + LineEnding,'E:\Inoussa\Sources\lazarus\wst\v0.3\tests\apache_module\log.log',True);
@ -254,14 +380,94 @@ begin
end;
end;
const MAX_ERR_LEN = 500;
function ProcessServiceRequestLibrary(
const ARequestInfo : TRequestInfo;
out AResponseInfo : TResponseInfo
) : Boolean;
var
loc_path, ctntyp : string;
targetModuleName, targetFormat, targetService : string;
wrtr : IDataStore;
buffStream : TMemoryStream;
strBuff : string;
intfBuffer : IwstStream;
bl : LongInt;
targetModule : IwstModule;
handlerProc : TwstLibraryHandlerFunction;
pArg : PRequestArgument;
i : Integer;
begin
try
FillChar(AResponseInfo,SizeOf(TResponseInfo),#0);
loc_path := ARequestInfo.URI;
targetModuleName := ExtractNextPathElement(loc_path);
Result := False;
targetModule := LibraryManager.Get(GetWstPath() + targetModuleName + sWST_LIBRARY_EXTENSION);
handlerProc := TwstLibraryHandlerFunction(targetModule.GetProc(WST_LIB_HANDLER));
if not Assigned(handlerProc) then
Exit;
targetService := ExtractNextPathElement(loc_path);
if AnsiSameText(sWSDL,targetService) then
Exit;
pArg := FindArg(ARequestInfo.ArgList,'format');
if Assigned(pArg) then
targetFormat := pArg^.Value;
if IsStrEmpty(targetFormat) then
targetFormat := ARequestInfo.ContentType;
buffStream := TMemoryStream.Create();
try
wrtr := CreateBinaryWriter(buffStream);
wrtr.WriteInt32S(0);
wrtr.WriteStr(targetService);
wrtr.WriteStr(ARequestInfo.ContentType);
wrtr.WriteStr(targetFormat);
wrtr.WriteStr(ARequestInfo.Buffer);
buffStream.Position := 0;
wrtr.WriteInt32S(buffStream.Size-4);
buffStream.Position := 0;
intfBuffer := TwstStream.Create(buffStream);
bl := MAX_ERR_LEN;
strBuff := StringOfChar(#0,bl);
i := handlerProc(intfBuffer,Pointer(strBuff),bl);
if ( i <> RET_OK ) then
raise Exception.CreateFmt('Library server error :'#13'Code : %d'#13'Message : %s',[i,strBuff]);
if AnsiSameText(sBINARY_CONTENT_TYPE,ARequestInfo.ContentType) then
AResponseInfo.ContentType := sHTTP_BINARY_CONTENT_TYPE
else
AResponseInfo.ContentType := ARequestInfo.ContentType;
buffStream.Position := 0;
if ( buffStream.Size > 0 ) then begin
SetLength(AResponseInfo.ContentText,buffStream.Size);
buffStream.Read(AResponseInfo.ContentText[1],Length(AResponseInfo.ContentText));
end else begin
AResponseInfo.ContentText := '';
end;
finally
buffStream.Free();
end;
Result := True;
except
on e : Exception do begin
Result := False;
ap_log_rerror(PCHAR('wst_apache_binding'),392,APLOG_ERR,0,Prequest_rec(ARequestInfo.InnerRequest),PCHAR(e.Message),[]);
end;
end;
end;
function wst_RequestHandler(r: Prequest_rec): Integer;
function FillRequestInfo(var ARequestInfo : TRequestInfo):Integer;
begin
ARequestInfo.InnerRequest := r;
ARequestInfo.ContentType := apr_table_get(r^.headers_in,sCONTENT_TYPE);
ARequestInfo.Root := ap_get_server_name(r) + sSEPARATOR + sWST_ROOT + sSEPARATOR;
ARequestInfo.URI := r^.uri;
ARequestInfo.Argument := r^.args;
ARequestInfo.Arguments := r^.args;
ARequestInfo.ArgList := ParseArgs(r^.pool,ARequestInfo.Arguments);
Result := ReadBuffer(r,ARequestInfo.Buffer);
end;
@ -279,8 +485,14 @@ begin
try
if AnsiSameText(sSERVICES_PREFIXE,ExtractNextPathElement(loc_RequestInfo.URI)) then begin
{$IFDEF WST_BROKER}
if not ProcessServiceRequestLibrary(loc_RequestInfo,loc_ResponseInfo) then
ProcessWSDLRequest(loc_RequestInfo,loc_ResponseInfo);
{$ELSE}
if not ProcessServiceRequest(loc_RequestInfo,loc_ResponseInfo) then
ProcessWSDLRequest(loc_RequestInfo,loc_ResponseInfo);
{$ENDIF}
end else begin
ProcessWSDLRequest(loc_RequestInfo,loc_ResponseInfo);
end;
@ -294,7 +506,6 @@ begin
ap_rputs(PCHAR(loc_ResponseInfo.ContentText), r);
end;
Result := OK;
Exit;
except
on e : Exception do begin
ap_set_content_type(r, 'text/html');
@ -307,14 +518,6 @@ begin
end;
initialization
RegisterStdTypes();
Server_service_RegisterBinaryFormat();
Server_service_RegisterSoapFormat();
RegisterUserServiceImplementationFactory();
Server_service_RegisterUserServiceService();
RegisterWSTMetadataServiceImplementationFactory();
Server_service_RegisterWSTMetadataServiceService();
wst_initialize();
end.

View File

@ -30,15 +30,15 @@
<LaunchingApplication PathPlusParams="\usr\X11R6\bin\xterm -T 'Lazarus Run Output' -e $(LazarusDir)\tools\runwait.sh $(TargetCmdLine)"/>
</local>
</RunParams>
<Units Count="43">
<Units Count="45">
<Unit0>
<Filename Value="user_client_console.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="user_client_console"/>
<CursorPos X="1" Y="12"/>
<TopLine Value="1"/>
<CursorPos X="44" Y="147"/>
<TopLine Value="136"/>
<EditorIndex Value="0"/>
<UsageCount Value="76"/>
<UsageCount Value="82"/>
<Loaded Value="True"/>
</Unit0>
<Unit1>
@ -46,8 +46,8 @@
<UnitName Value="user_service_intf_proxy"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="1"/>
<EditorIndex Value="4"/>
<UsageCount Value="30"/>
<EditorIndex Value="7"/>
<UsageCount Value="33"/>
<Loaded Value="True"/>
</Unit1>
<Unit2>
@ -55,8 +55,8 @@
<UnitName Value="synapse_tcp_protocol"/>
<CursorPos X="1" Y="23"/>
<TopLine Value="1"/>
<EditorIndex Value="12"/>
<UsageCount Value="37"/>
<EditorIndex Value="15"/>
<UsageCount Value="40"/>
<Loaded Value="True"/>
</Unit2>
<Unit3>
@ -64,8 +64,8 @@
<UnitName Value="service_intf"/>
<CursorPos X="51" Y="34"/>
<TopLine Value="21"/>
<EditorIndex Value="10"/>
<UsageCount Value="33"/>
<EditorIndex Value="13"/>
<UsageCount Value="36"/>
<Loaded Value="True"/>
</Unit3>
<Unit4>
@ -73,8 +73,8 @@
<UnitName Value="user_service_intf"/>
<CursorPos X="53" Y="11"/>
<TopLine Value="1"/>
<EditorIndex Value="5"/>
<UsageCount Value="29"/>
<EditorIndex Value="8"/>
<UsageCount Value="32"/>
<Loaded Value="True"/>
</Unit4>
<Unit5>
@ -94,10 +94,10 @@
<Unit7>
<Filename Value="..\..\library_protocol.pas"/>
<UnitName Value="library_protocol"/>
<CursorPos X="1" Y="24"/>
<TopLine Value="1"/>
<CursorPos X="1" Y="137"/>
<TopLine Value="19"/>
<EditorIndex Value="2"/>
<UsageCount Value="25"/>
<UsageCount Value="28"/>
<Loaded Value="True"/>
</Unit7>
<Unit8>
@ -142,8 +142,8 @@
<UnitName Value="synapse_http_protocol"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="13"/>
<EditorIndex Value="9"/>
<UsageCount Value="19"/>
<EditorIndex Value="12"/>
<UsageCount Value="22"/>
<Loaded Value="True"/>
</Unit14>
<Unit15>
@ -162,9 +162,11 @@
<Unit17>
<Filename Value="..\..\library_imp_utils.pas"/>
<UnitName Value="library_imp_utils"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="1"/>
<UsageCount Value="8"/>
<CursorPos X="1" Y="187"/>
<TopLine Value="170"/>
<EditorIndex Value="3"/>
<UsageCount Value="13"/>
<Loaded Value="True"/>
</Unit17>
<Unit18>
<Filename Value="..\..\..\..\..\lazarus23_213\fpc\2.1.3\source\rtl\win\dynlibs.inc"/>
@ -177,8 +179,8 @@
<UnitName Value="semaphore"/>
<CursorPos X="1" Y="140"/>
<TopLine Value="110"/>
<EditorIndex Value="3"/>
<UsageCount Value="10"/>
<EditorIndex Value="6"/>
<UsageCount Value="13"/>
<Loaded Value="True"/>
</Unit19>
<Unit20>
@ -194,15 +196,15 @@
<UnitName Value="xmlrpc_formatter"/>
<CursorPos X="54" Y="21"/>
<TopLine Value="1"/>
<UsageCount Value="62"/>
<UsageCount Value="68"/>
</Unit21>
<Unit22>
<Filename Value="..\..\binary_formatter.pas"/>
<UnitName Value="binary_formatter"/>
<CursorPos X="20" Y="21"/>
<TopLine Value="12"/>
<EditorIndex Value="11"/>
<UsageCount Value="30"/>
<EditorIndex Value="14"/>
<UsageCount Value="33"/>
<Loaded Value="True"/>
</Unit22>
<Unit23>
@ -306,8 +308,8 @@
<UnitName Value="indy_http_protocol"/>
<CursorPos X="1" Y="16"/>
<TopLine Value="109"/>
<EditorIndex Value="8"/>
<UsageCount Value="15"/>
<EditorIndex Value="11"/>
<UsageCount Value="18"/>
<Loaded Value="True"/>
</Unit37>
<Unit38>
@ -320,10 +322,10 @@
<Unit39>
<Filename Value="..\..\ics_tcp_protocol.pas"/>
<UnitName Value="ics_tcp_protocol"/>
<CursorPos X="1" Y="22"/>
<TopLine Value="1"/>
<CursorPos X="5" Y="41"/>
<TopLine Value="26"/>
<EditorIndex Value="1"/>
<UsageCount Value="14"/>
<UsageCount Value="17"/>
<Loaded Value="True"/>
</Unit39>
<Unit40>
@ -331,8 +333,8 @@
<UnitName Value="ics_http_protocol"/>
<CursorPos X="1" Y="25"/>
<TopLine Value="1"/>
<EditorIndex Value="7"/>
<UsageCount Value="14"/>
<EditorIndex Value="10"/>
<UsageCount Value="17"/>
<Loaded Value="True"/>
</Unit40>
<Unit41>
@ -340,8 +342,8 @@
<UnitName Value="same_process_protocol"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="13"/>
<EditorIndex Value="6"/>
<UsageCount Value="14"/>
<EditorIndex Value="9"/>
<UsageCount Value="17"/>
<Loaded Value="True"/>
</Unit41>
<Unit42>
@ -354,17 +356,26 @@
<TopLine Value="1"/>
<UsageCount Value="10"/>
</Unit42>
<Unit43>
<Filename Value="..\..\binary_streamer.pas"/>
<UnitName Value="binary_streamer"/>
<CursorPos X="21" Y="15"/>
<TopLine Value="1"/>
<EditorIndex Value="5"/>
<UsageCount Value="13"/>
<Loaded Value="True"/>
</Unit43>
<Unit44>
<Filename Value="..\..\library_base_intf.pas"/>
<UnitName Value="library_base_intf"/>
<CursorPos X="25" Y="17"/>
<TopLine Value="5"/>
<EditorIndex Value="4"/>
<UsageCount Value="13"/>
<Loaded Value="True"/>
</Unit44>
</Units>
<JumpHistory Count="2" HistoryIndex="1">
<Position1>
<Filename Value="user_client_console.pas"/>
<Caret Line="8" Column="111" TopLine="1"/>
</Position1>
<Position2>
<Filename Value="user_client_console.pas"/>
<Caret Line="13" Column="1" TopLine="1"/>
</Position2>
</JumpHistory>
<JumpHistory Count="0" HistoryIndex="-1"/>
</ProjectOptions>
<CompilerOptions>
<Version Value="5"/>

View File

@ -144,8 +144,8 @@ const ADDRESS_MAP : array[TTransportType] of string = (
'LIB:FileName=..\library_server\lib_server.dll;target=UserService',
//'TCP:Address=172.16.82.31;Port=1234;target=UserService',
'TCP:Address=127.0.0.1;Port=1234;target=UserService',
//'http:Address=http://127.0.0.1:8080/wst/services/UserService/?format=soap'
'http:Address=http://127.0.0.1:8000/services/UserService'
'http:Address=http://127.0.0.1:8888/wst/services/lib_server/UserService'
//'http:Address=http://127.0.0.1:8000/services/UserService'
);
FORMAT_MAP : array[TFormatType] of string =( 'binary', 'soap', 'xmlrpc' );
var

View File

@ -220,9 +220,9 @@ end;
initialization
FUserList := TObjectList.Create(True);
FUserCursor := TObjectListCursor.Create(FUserList);
if FileExists(sDATA_FILE_NAME) then
{if FileExists(sDATA_FILE_NAME) then
FillDataFromFile(sDATA_FILE_NAME)
else
else}
FillSampleData();
finalization

View File

@ -22,7 +22,8 @@ uses
TestFrameWork,
{$ENDIF}
TypInfo,
base_service_intf, server_service_intf;
base_service_intf, server_service_intf,
library_imp_utils;
type
@ -102,7 +103,24 @@ type
published
procedure POOLED_Discard();
end;
{ TwstModuleNotLoad }
TwstModuleNotLoad = class(TwstModule,IInterface,IwstModule)
protected
procedure Load(const ADoLoad : Boolean);override;
end;
{ TTest_TwstModuleManager }
TTest_TwstModuleManager = class(TTestCase)
published
function Get(const AFileName : string):IwstModule;
procedure Clear();
function GetCount() : PtrInt;
function GetItem(const AIndex : PtrInt) : IwstModule;
end;
implementation
{ TTestClass }
@ -585,19 +603,140 @@ begin
CheckEquals(TSimpleFactoryItem_B,b.GetItemClass());
end;
{ TwstModuleNotLoad }
procedure TwstModuleNotLoad.Load(const ADoLoad: Boolean);
begin
//;
end;
{ TTest_TwstModuleManager }
function TTest_TwstModuleManager.Get(const AFileName: string): IwstModule;
const C = 10;
var
locObj : IwstModuleManager;
locModule : IwstModule;
i, j, k: Integer;
ok : Boolean;
locName : string;
begin
locObj := TwstModuleManager.Create(TwstModuleNotLoad);
for i := 0 to Pred(C) do begin
locObj.Get(Format('lib_%d',[i]));
end;
for i := 0 to Pred(C) do begin
ok := False;
locName := Format('lib_%d',[i]);
for j := 0 to Pred(locObj.GetCount()) do begin
locModule := locObj.GetItem(j);
if AnsiSameText(locName, locModule.GetFileName()) then begin
ok := True;
k := j + 1;
Break;
end;
end;
Check(ok);
for j := k to Pred(locObj.GetCount()) do begin
locModule := locObj.GetItem(j);
if AnsiSameText(locName, locModule.GetFileName()) then begin
Check(False,'Duplicated items : ' + locName);
end;
end;
end;
end;
procedure TTest_TwstModuleManager.Clear();
const C = 12;
var
locObj : IwstModuleManager;
i : Integer;
begin
locObj := TwstModuleManager.Create(TwstModuleNotLoad);
locObj.Clear();
CheckEquals(0,locObj.GetCount());
for i := 0 to Pred(C) do begin
locObj.Get(Format('lib_%d',[i]));
end;
CheckEquals(C,locObj.GetCount());
locObj.Clear();
CheckEquals(0,locObj.GetCount());
end;
function TTest_TwstModuleManager.GetCount(): PtrInt;
const C = 10;
var
locObj : IwstModuleManager;
i : Integer;
begin
locObj := TwstModuleManager.Create(TwstModuleNotLoad);
CheckEquals(0,locObj.GetCount());
CheckEquals(0,locObj.GetCount());
for i := 0 to Pred(C) do begin
CheckEquals(i,locObj.GetCount(),'before Add');
locObj.Get(Format('lib_%d',[i]));
CheckEquals(i + 1,locObj.GetCount(),'after Add');
end;
CheckEquals(C,locObj.GetCount());
end;
function TTest_TwstModuleManager.GetItem(const AIndex: PtrInt): IwstModule;
const C = 10;
var
locObj : IwstModuleManager;
locModule : IwstModule;
i : Integer;
ok : Boolean;
begin
locObj := TwstModuleManager.Create(TwstModuleNotLoad);
ok := False;
try
locObj.GetItem(0);
except
on e : Exception do begin
ok := True;
end;
end;
Check(ok);
ok := False;
try
locObj.GetItem(1);
except
on e : Exception do begin
ok := True;
end;
end;
Check(ok);
for i := 0 to Pred(C) do begin
locObj.Get(Format('lib_%d',[i]));
end;
for i := 0 to Pred(C) do begin
locModule := locObj.GetItem(i);
CheckEquals(Format('lib_%d',[i]), locModule.GetFileName());
end;
ok := False;
try
locObj.GetItem(C + 1);
except
on e : Exception do begin
ok := True;
end;
end;
Check(ok);
end;
initialization
{$IFDEF FPC}
RegisterTest(TTest_TIntfPool);
RegisterTest(TTest_TSimpleItemFactoryEx);
RegisterTest(TTest_TImplementationFactory);
RegisterTest(TTest_TIntfPoolItem);
RegisterTest(TTest_TImplementationFactory);
{$ELSE}
RegisterTest(TTest_TIntfPool.Suite);
RegisterTest(TTest_TSimpleItemFactoryEx.Suite);
RegisterTest(TTest_TImplementationFactory.Suite);
RegisterTest(TTest_TIntfPoolItem.Suite);
RegisterTest(TTest_TImplementationFactory.Suite);
{$ENDIF}
RegisterTest('Utilities',TTest_TIntfPool.Suite);
RegisterTest('Utilities',TTest_TSimpleItemFactoryEx.Suite);
RegisterTest('Utilities',TTest_TImplementationFactory.Suite);
RegisterTest('Utilities',TTest_TIntfPoolItem.Suite);
RegisterTest('Utilities',TTest_TImplementationFactory.Suite);
RegisterTest('Utilities',TTest_TwstModuleManager.Suite);
end.

View File

@ -7,7 +7,7 @@
<MainUnit Value="0"/>
<IconPath Value="./"/>
<TargetFileExt Value=".exe"/>
<ActiveEditorIndexAtStart Value="1"/>
<ActiveEditorIndexAtStart Value="16"/>
</General>
<PublishOptions>
<Version Value="2"/>
@ -27,7 +27,7 @@
<PackageName Value="FPCUnitTestRunner"/>
</Item1>
</RequiredPackages>
<Units Count="72">
<Units Count="74">
<Unit0>
<Filename Value="wst_test_suite.lpr"/>
<IsPartOfProject Value="True"/>
@ -251,7 +251,7 @@
<CursorPos X="3" Y="174"/>
<TopLine Value="165"/>
<EditorIndex Value="9"/>
<UsageCount Value="45"/>
<UsageCount Value="46"/>
<Loaded Value="True"/>
</Unit25>
<Unit26>
@ -318,10 +318,10 @@
<Filename Value="test_utilities.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="test_utilities"/>
<CursorPos X="40" Y="64"/>
<TopLine Value="58"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="49"/>
<EditorIndex Value="15"/>
<UsageCount Value="193"/>
<UsageCount Value="195"/>
<Loaded Value="True"/>
</Unit35>
<Unit36>
@ -414,7 +414,7 @@
<UnitName Value="server_service_xmlrpc"/>
<CursorPos X="38" Y="33"/>
<TopLine Value="27"/>
<UsageCount Value="147"/>
<UsageCount Value="149"/>
</Unit46>
<Unit47>
<Filename Value="..\..\..\..\..\..\lazarus_23_215XX\fpc\source\packages\fcl-xml\src\xmlread.pp"/>
@ -450,7 +450,7 @@
<CursorPos X="50" Y="24"/>
<TopLine Value="1"/>
<EditorIndex Value="4"/>
<UsageCount Value="125"/>
<UsageCount Value="127"/>
<Loaded Value="True"/>
</Unit51>
<Unit52>
@ -459,7 +459,7 @@
<CursorPos X="17" Y="190"/>
<TopLine Value="188"/>
<EditorIndex Value="6"/>
<UsageCount Value="29"/>
<UsageCount Value="30"/>
<Loaded Value="True"/>
</Unit52>
<Unit53>
@ -468,7 +468,7 @@
<CursorPos X="98" Y="94"/>
<TopLine Value="71"/>
<EditorIndex Value="8"/>
<UsageCount Value="21"/>
<UsageCount Value="22"/>
<Loaded Value="True"/>
</Unit53>
<Unit54>
@ -504,7 +504,7 @@
<CursorPos X="14" Y="91"/>
<TopLine Value="77"/>
<EditorIndex Value="7"/>
<UsageCount Value="28"/>
<UsageCount Value="29"/>
<Loaded Value="True"/>
</Unit58>
<Unit59>
@ -519,7 +519,7 @@
<UnitName Value="wsdl_generator"/>
<CursorPos X="27" Y="146"/>
<TopLine Value="124"/>
<UsageCount Value="105"/>
<UsageCount Value="107"/>
</Unit60>
<Unit61>
<Filename Value="..\..\..\..\..\..\lazarus_23_2.2.1\fpc\2.2.1\source\packages\fcl-xml\src\xmlread.pp"/>
@ -548,7 +548,7 @@
<CursorPos X="3" Y="81"/>
<TopLine Value="261"/>
<EditorIndex Value="2"/>
<UsageCount Value="88"/>
<UsageCount Value="90"/>
<Loaded Value="True"/>
</Unit64>
<Unit65>
@ -557,7 +557,7 @@
<UnitName Value="xsd_consts"/>
<CursorPos X="8" Y="78"/>
<TopLine Value="51"/>
<UsageCount Value="87"/>
<UsageCount Value="89"/>
</Unit65>
<Unit66>
<Filename Value="..\..\ws_helper\wsdl_parser.pas"/>
@ -566,7 +566,7 @@
<CursorPos X="28" Y="845"/>
<TopLine Value="835"/>
<EditorIndex Value="5"/>
<UsageCount Value="20"/>
<UsageCount Value="22"/>
<Loaded Value="True"/>
</Unit66>
<Unit67>
@ -576,7 +576,7 @@
<CursorPos X="58" Y="112"/>
<TopLine Value="99"/>
<EditorIndex Value="11"/>
<UsageCount Value="73"/>
<UsageCount Value="75"/>
<Loaded Value="True"/>
</Unit67>
<Unit68>
@ -585,7 +585,7 @@
<CursorPos X="3" Y="265"/>
<TopLine Value="296"/>
<EditorIndex Value="12"/>
<UsageCount Value="37"/>
<UsageCount Value="38"/>
<Loaded Value="True"/>
</Unit68>
<Unit69>
@ -608,16 +608,123 @@
<TopLine Value="586"/>
<UsageCount Value="16"/>
</Unit71>
<Unit72>
<Filename Value="..\..\library_imp_utils.pas"/>
<UnitName Value="library_imp_utils"/>
<CursorPos X="2" Y="31"/>
<TopLine Value="19"/>
<EditorIndex Value="16"/>
<UsageCount Value="11"/>
<Loaded Value="True"/>
</Unit72>
<Unit73>
<Filename Value="..\..\..\..\..\..\lazarus_23_2.2.1\fpc\2.2.1\source\rtl\win\dynlibs.inc"/>
<CursorPos X="1" Y="26"/>
<TopLine Value="9"/>
<UsageCount Value="10"/>
</Unit73>
</Units>
<JumpHistory Count="2" HistoryIndex="1">
<JumpHistory Count="25" HistoryIndex="24">
<Position1>
<Filename Value="..\..\base_soap_formatter.pas"/>
<Caret Line="1481" Column="23" TopLine="1470"/>
<Filename Value="test_utilities.pas"/>
<Caret Line="26" Column="19" TopLine="1"/>
</Position1>
<Position2>
<Filename Value="..\..\base_soap_formatter.pas"/>
<Caret Line="127" Column="61" TopLine="115"/>
<Filename Value="..\..\library_imp_utils.pas"/>
<Caret Line="72" Column="52" TopLine="48"/>
</Position2>
<Position3>
<Filename Value="..\..\library_imp_utils.pas"/>
<Caret Line="184" Column="38" TopLine="179"/>
</Position3>
<Position4>
<Filename Value="..\..\library_imp_utils.pas"/>
<Caret Line="72" Column="24" TopLine="72"/>
</Position4>
<Position5>
<Filename Value="..\..\library_imp_utils.pas"/>
<Caret Line="172" Column="23" TopLine="170"/>
</Position5>
<Position6>
<Filename Value="..\..\library_imp_utils.pas"/>
<Caret Line="84" Column="1" TopLine="63"/>
</Position6>
<Position7>
<Filename Value="..\..\library_imp_utils.pas"/>
<Caret Line="28" Column="1" TopLine="12"/>
</Position7>
<Position8>
<Filename Value="..\..\library_imp_utils.pas"/>
<Caret Line="50" Column="25" TopLine="35"/>
</Position8>
<Position9>
<Filename Value="..\..\library_imp_utils.pas"/>
<Caret Line="84" Column="15" TopLine="64"/>
</Position9>
<Position10>
<Filename Value="..\..\library_imp_utils.pas"/>
<Caret Line="11" Column="5" TopLine="10"/>
</Position10>
<Position11>
<Filename Value="..\..\library_imp_utils.pas"/>
<Caret Line="185" Column="21" TopLine="170"/>
</Position11>
<Position12>
<Filename Value="..\..\library_imp_utils.pas"/>
<Caret Line="198" Column="56" TopLine="179"/>
</Position12>
<Position13>
<Filename Value="..\..\library_imp_utils.pas"/>
<Caret Line="90" Column="25" TopLine="62"/>
</Position13>
<Position14>
<Filename Value="test_utilities.pas"/>
<Caret Line="107" Column="35" TopLine="93"/>
</Position14>
<Position15>
<Filename Value="test_utilities.pas"/>
<Caret Line="109" Column="3" TopLine="107"/>
</Position15>
<Position16>
<Filename Value="test_utilities.pas"/>
<Caret Line="116" Column="3" TopLine="114"/>
</Position16>
<Position17>
<Filename Value="test_utilities.pas"/>
<Caret Line="638" Column="1" TopLine="610"/>
</Position17>
<Position18>
<Filename Value="test_utilities.pas"/>
<Caret Line="633" Column="26" TopLine="610"/>
</Position18>
<Position19>
<Filename Value="..\..\library_imp_utils.pas"/>
<Caret Line="94" Column="62" TopLine="87"/>
</Position19>
<Position20>
<Filename Value="test_utilities.pas"/>
<Caret Line="619" Column="1" TopLine="585"/>
</Position20>
<Position21>
<Filename Value="test_utilities.pas"/>
<Caret Line="652" Column="5" TopLine="618"/>
</Position21>
<Position22>
<Filename Value="..\..\library_imp_utils.pas"/>
<Caret Line="151" Column="4" TopLine="140"/>
</Position22>
<Position23>
<Filename Value="test_utilities.pas"/>
<Caret Line="619" Column="1" TopLine="585"/>
</Position23>
<Position24>
<Filename Value="test_utilities.pas"/>
<Caret Line="647" Column="9" TopLine="623"/>
</Position24>
<Position25>
<Filename Value="..\..\library_imp_utils.pas"/>
<Caret Line="51" Column="18" TopLine="40"/>
</Position25>
</JumpHistory>
</ProjectOptions>
<CompilerOptions>