php4Executive.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. <?php
  2. /**
  3. * THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESSED OR IMPLIED WARRANTIES, INCLUDING,
  4. * BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
  5. * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE
  6. * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  7. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  8. * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  9. * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
  10. * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  11. *
  12. * @license http://opensource.org/licenses/gpl-license.php GNU Public License
  13. * @copyright (c) 2003 amfphp.org
  14. * @package flashservices
  15. * @subpackage app
  16. */
  17. /**
  18. * The Executive class is responsible for executing the remote service method and returning it's value.
  19. *
  20. * Currently the executive class is a complicated chain of filtering events testing for various cases and
  21. * handling them. Future versions of this class will probably be broken up into many helper classes which will
  22. * use a delegation or chaining pattern to make adding new exceptions or handlers more modular. This will
  23. * become even more important if developers need to make their own custom header handlers.
  24. *
  25. * @package flashservices
  26. * @subpackage app
  27. * @author Musicman original design
  28. * @author Justin Watkins Gateway architecture, class structure, datatype io additions
  29. * @author John Cowen Datatype io additions, class structure
  30. * @author Klaasjan Tukker Modifications, check routines
  31. * @version $Id: Executive.php,v 1.32 2005/07/05 07:40:49 pmineault Exp $
  32. */
  33. class Executive {
  34. /**
  35. * The built instance of the service class
  36. *
  37. * @access private
  38. * @var object
  39. */
  40. var $_classConstruct;
  41. /**
  42. * The method name to execute
  43. *
  44. * @access private
  45. * @var string
  46. */
  47. var $_methodname;
  48. /**
  49. * The arguments to pass to the executed method
  50. *
  51. * @access private
  52. * @var mixed
  53. */
  54. var $_arguments;
  55. function Executive() {
  56. }
  57. /**
  58. * The main method of the executive class.
  59. *
  60. * @param array $a Arguments to pass to the method
  61. * @return mixed The results from the method operation
  62. */
  63. function doMethodCall(&$bodyObj, &$object, $method, $args) {
  64. /*
  65. ::TODO::
  66. Add the ability to use an object with named parameters as the first and only argument. This will REQUIRE
  67. that the arguments are defined in the method table, but that is just the sacrifice that will have to be made.
  68. Maybe the arguments should be it's own action or bundled with another action...
  69. */
  70. //Unfortunately there is no way to catch (as of PHP 4) an error that occurs in a user function
  71. //You will receive a bad version error if that is the case
  72. //You will have to rely on server logs for this purpose
  73. return call_user_func_array (array(&$object, $method), $args);
  74. }
  75. /**
  76. * Builds a class using a class name
  77. * If there is a failure, catch the error and return to caller
  78. */
  79. function buildClass(&$bodyObj, $className)
  80. {
  81. global $amfphp;
  82. if(isset($amfphp['classInstances'][$className]))
  83. {
  84. return $amfphp['classInstances'][$className];
  85. }
  86. else
  87. {
  88. $construct = new $className($className);
  89. $amfphp['classInstances'][$className] = & $construct;
  90. return $construct;
  91. }
  92. }
  93. /**
  94. * Include a class
  95. * If there is an error, catch and return to caller
  96. */
  97. function includeClass(&$bodyObj, $location)
  98. {
  99. $included = include_once($location);
  100. return $included !== FALSE;
  101. }
  102. }
  103. ?>