Skip to content

Commit

Permalink
make feathersui-rpc-services optional
Browse files Browse the repository at this point in the history
  • Loading branch information
joshtynjala committed Aug 28, 2024
1 parent 3622f75 commit 6eb7924
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/com/adobe/cairngorm/business/HTTPServices.hx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

package com.adobe.cairngorm.business;

#if feathersui_rpc_services
import feathers.rpc.http.HTTPService;
import com.adobe.cairngorm.CairngormMessageCodes;

Expand Down Expand Up @@ -123,3 +124,4 @@ class HTTPServices extends AbstractServices {
}
}
}
#end
4 changes: 4 additions & 0 deletions src/com/adobe/cairngorm/business/IServiceLocator.hx
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,17 @@

package com.adobe.cairngorm.business;

#if feathersui_rpc_services
import feathers.rpc.remoting.RemoteObject;
import feathers.rpc.http.HTTPService;
#end

/**
IServiceLocator defines an interface for service locator. Its intention is
to support unit testing.
**/
interface IServiceLocator {
#if feathersui_rpc_services
/**
Return the HTTPService for the given service id.
@param serviceId the service id.
Expand All @@ -60,6 +63,7 @@ interface IServiceLocator {
// @return the RemoteObject.
// **/
// function getWebService(destinationId:String):WebService;
#end

/**
Set the credentials for all registered services. Note that services
Expand Down
2 changes: 2 additions & 0 deletions src/com/adobe/cairngorm/business/RemoteObjects.hx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

package com.adobe.cairngorm.business;

#if feathersui_rpc_services
import feathers.rpc.remoting.RemoteObject;

/**
Expand Down Expand Up @@ -122,3 +123,4 @@ class RemoteObjects extends AbstractServices {
}
}
}
#end
15 changes: 15 additions & 0 deletions src/com/adobe/cairngorm/business/ServiceLocator.hx
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,12 @@

package com.adobe.cairngorm.business;

#if feathersui_rpc_services
import feathers.rpc.remoting.RemoteObject;
import feathers.rpc.AbstractInvoker;
import feathers.rpc.AbstractService;
import feathers.rpc.http.HTTPService;
#end

/**
The ServiceLocator allows service to be located and security
Expand All @@ -51,9 +53,12 @@ import feathers.rpc.http.HTTPService;
class ServiceLocator implements IServiceLocator {
private static var _instance:ServiceLocator;

#if feathersui_rpc_services
private var _httpServices:HTTPServices;
private var _remoteObjects:RemoteObjects;

// private var _webServices:WebServices;
#end
private var _timeout:Int = 0;

public static var instance(get, never):ServiceLocator;
Expand Down Expand Up @@ -96,6 +101,7 @@ class ServiceLocator implements IServiceLocator {
_instance = this;
}

#if feathersui_rpc_services
/**
Deprecated.
Expand Down Expand Up @@ -156,6 +162,7 @@ class ServiceLocator implements IServiceLocator {
// public function getWebService(name:String):WebService {
// return cast(webServices.getService(name), WebService);
// }
#end

/**
Set the credentials for all registered services.
Expand All @@ -164,9 +171,11 @@ class ServiceLocator implements IServiceLocator {
@param password the password to set.
**/
public function setCredentials(username:String, password:String):Void {
#if feathersui_rpc_services
httpServices.setCredentials(username, password);
// remoteObjects.setCredentials(username, password);
// webServices.setCredentials(username, password);
#end
}

/**
Expand All @@ -175,15 +184,18 @@ class ServiceLocator implements IServiceLocator {
@param password the password to set.
**/
public function setRemoteCredentials(username:String, password:String):Void {
#if feathersui_rpc_services
httpServices.setRemoteCredentials(username, password);
// remoteObjects.setRemoteCredentials(username, password);
// webServices.setRemoteCredentials(username, password);
#end
}

/**
Logs the user out of all registered services.
**/
public function logout():Void {
#if feathersui_rpc_services
// First release the resources held by the service. We release the
// resources first as the logout logs the user out at a channel level.
httpServices.release();
Expand All @@ -194,6 +206,7 @@ class ServiceLocator implements IServiceLocator {
httpServices.logout();
// remoteObjects.logout();
// webServices.logout();
#end
}

public var timeout(get, set):Int;
Expand All @@ -207,6 +220,7 @@ class ServiceLocator implements IServiceLocator {
return _timeout;
}

#if feathersui_rpc_services
private var httpServices(get, never):HTTPServices;

private function get_httpServices():HTTPServices {
Expand Down Expand Up @@ -238,6 +252,7 @@ class ServiceLocator implements IServiceLocator {
// }
// return _webServices;
// }
#end

/**
Return the service with the given id.
Expand Down

0 comments on commit 6eb7924

Please sign in to comment.