How to Inject Object in Custom Route Service

Discussions relating to breakout scripting, .NET and COM programming with Jiwa objects.

How to Inject Object in Custom Route Service

Postby symimake » Sun Jul 31, 2022 6:49 am

Consider the Jiwa Example custom route plugin example.

Code: Select all
public class RESTAPIPlugin : System.MarshalByRefObject, JiwaFinancials.Jiwa.JiwaApplication.IJiwaRESTAPIPlugin
   {
      public void Configure(JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin Plugin, ServiceStack.ServiceStackHost  AppHost, Funq.Container Container, JiwaApplication.Manager JiwaApplicationManager)
      {
                // How can I Inject the Manager Object in this CustomService?
           AppHost.RegisterService<CustomServices>();       
           AppHost.Routes.Add(typeof(MyDebtorContactGetRequest), "/Debtors/{DebtorID}/MyContacts", "GET", "Retrieves a list of contacts for a debtor.", "");
         AppHost.Routes.Add(typeof(MySearchRequest), "/Search/{SearchTerm}", "GET", "Performs a system wide search for a search term using a Jiwa stored procedure", "");
         AppHost.Routes.Add(typeof(MyCustomSearchRequest), "/SearchCustom/{SearchTerm}", "GET", "Performs a system wide search for a search term using a stored procedure", "");         
      }
   }


I want to inject the Manager Object in CustomService. How to do that?
symimake
Occasional Contributor
Occasional Contributor
 
Posts: 16
Joined: Thu Jul 28, 2022 3:38 pm

Re: How to Inject Object in Custom Route Service

Postby Mike.Sheen » Mon Aug 01, 2022 11:22 am

You've posted this in the version 6 forum. Version 6 does not have a REST API. You want to post in the version 7 forum, specifically the REST API subforum.

To answer you question, inside any service class, you can use the extension method GetManager() to retrieve the Jiwa Manager object associated with the session:

Code: Select all
JiwaFinancials.Jiwa.JiwaApplication.Manager manager = this.GetManager();


You can see many examples of this in the REST API plugin.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2444
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 756


Return to Technical / Programming

Who is online

Users browsing this forum: No registered users and 1 guest