Skip to content

Instantly share code, notes, and snippets.

@nikitaeverywhere
Last active March 14, 2016 22:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nikitaeverywhere/e761473b7933a1beb204 to your computer and use it in GitHub Desktop.
Save nikitaeverywhere/e761473b7933a1beb204 to your computer and use it in GitHub Desktop.
Перед вами - пример веб-приложения Caché, которое устанавливает себя самостоятельно после импорта XML-файла. Сохраните архив, нажав вверху на "Download ZIP", разархивируйте и импортируйте его в Caché. Затем, откройте http://localhost:[port]/myWebApp/ (не забудьте добавить косую черту в конце!) и убедитесь, что приложение работает.
<?xml version="1.0" encoding="UTF-8"?>
<Export generator="Cache" version="25" zv="Cache for Windows (x86-64) 2016.2 (Build 590U)" ts="2016-03-15 00:40:16">
<Class name="MyPackage.Installer">
<CompileAfter>MyPackage.REST</CompileAfter>
<Super>%Projection.AbstractProjection</Super>
<TimeChanged>63992,1953.207424</TimeChanged>
<TimeCreated>63992,1916.587195</TimeCreated>
<Parameter name="WebAppName">
<Type>%String</Type>
<Default>/myWebApp</Default>
</Parameter>
<Parameter name="DispatchClass">
<Type>%String</Type>
<Default>MyPackage.REST</Default>
</Parameter>
<Projection name="Reference">
<Type>Installer</Type>
</Projection>
<Method name="CreateProjection">
<ClassMethod>1</ClassMethod>
<FormalSpec><![CDATA[cls:%String,&params]]></FormalSpec>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
set currentNamespace = $Namespace
write !, "Changing namespace to %SYS..."
znspace "%SYS" // необходимо изменить пространство имён на %SYS, так как класс Security.Applications существует только там
write !, "Configuring WEB application..."
set cspProperties("AutheEnabled") = $$$AutheUnauthenticated // общедоступное приложение
set cspProperties("NameSpace") = currentNamespace // приложение для области, куда производится импорт
set cspProperties("Description") = "A test WEB application." // описание приложения
set cspProperties("IsNameSpaceDefault") = $$$NO // это приложение не является основным для области
set cspProperties("DispatchClass") = ..#DispatchClass // ранее написанный класс-обработчик
return ##class(Security.Applications).Create(..#WebAppName, .cspProperties)
]]></Implementation>
</Method>
<Method name="RemoveProjection">
<ClassMethod>1</ClassMethod>
<FormalSpec><![CDATA[cls:%String,&params,recompile:%Boolean]]></FormalSpec>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
write !, "Changing namespace to %SYS..."
znspace "%SYS"
write !, "Deleting WEB application..."
return ##class(Security.Applications).Delete(..#WebAppName)
]]></Implementation>
</Method>
</Class>
<Class name="MyPackage.REST">
<Super>%CSP.REST</Super>
<TimeChanged>63992,1906.100316</TimeChanged>
<TimeCreated>63992,1906.100316</TimeCreated>
<XData name="UrlMap">
<Data><![CDATA[
<Routes>
<Route Url="/" Method="GET" Call="Index"/>
</Routes>
]]></Data>
</XData>
<Method name="Index">
<ClassMethod>1</ClassMethod>
<ReturnType>%Status</ReturnType>
<Implementation><![CDATA[
write "I am installed!"
return $$$OK
]]></Implementation>
</Method>
</Class>
</Export>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment