/*----------------------------------------------------------------------------- The contents of this file are subject to the Mozilla Public License Version 1.1 (the "License"); you may not use this file except in compliance with the License.You may obtain a copy of the License at http://www.mozilla.org/MPL/MPL-1.1.html Software distributed under the License is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License for the specific language governing rights and limitations under the License. The Original Code is Fever Framework code. The Initial Developer of the Original Code is Romain Ecarnot. Portions created by Initial Developer are Copyright (C) 2006 the Initial Developer. All Rights Reserved. Contributor(s): Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. -----------------------------------------------------------------------------*/ import com.bourre.remoting.RemotingConnection; import com.bourre.remoting.ServiceProxyLocator; import fever.log.FeverDebug; import fever.utils.Stringifier; /** * Default Remote Service locator for current application. * *

Use it as a global reference for your remoting gateway definition and * service declaration. * *

The gateway url can be defined throw the Fever Configuration * System * {@code * http://www.mydomain.com/amf/gateway.php * } * * @author Romain Ecarnot */ class fever.remoting.FeverServiceLocator extends ServiceProxyLocator { //------------------------------------------------------------------------- // Private properties //------------------------------------------------------------------------- private static var _instance : FeverServiceLocator; //------------------------------------------------------------------------- // Public API //------------------------------------------------------------------------- /** * Returns {@link FeverServiceLocator} instance. */ public static function getInstance() : FeverServiceLocator { if (!_instance) _instance = new FeverServiceLocator(); return _instance; } /** * Inits remoting system with passing gateway URL. * *

If {@link fever.Fever#isOn} is {@code true}, starts the * remoting connection debug mode. */ public function init( remotingURL : String ) : Void { if( remotingURL && ( remotingURL != gatewayURL ) ) { if( gatewayURL ) { RemotingConnection.getRemotingConnection( gatewayURL ).close(); } gatewayURL = remotingURL; _checkDebugMode(); } } /** * Returns string representation. */ public function toString() : String { return Stringifier.parse( this, gatewayURL ); } //------------------------------------------------------------------------- // Private implementation //------------------------------------------------------------------------- /** * Constructor. */ private function FeverServiceLocator() { super(); } private function _checkDebugMode() : Void { if( FeverDebug.isOn ) RemotingConnection.getRemotingConnection( gatewayURL ).runDebug(); else RemotingConnection.getRemotingConnection( gatewayURL ).stopDebug(); } }