public function __construct(MappedClassLoader $mappedClassLoader, SerializationPolicyProvider $serializationPolicyProvider)
 {
     $this->mappedClassLoader = $mappedClassLoader;
     $this->serializationPolicyProvider = $serializationPolicyProvider;
     $this->serializationPolicy = RPC::getDefaultSerializationPolicy();
     $this->logger = LoggerManager::getLogger('gwtphp.rpc.impl.ServerSerializationStreamReader');
 }
 public function getSerializationPolicy($moduleBaseURL, $strongName)
 {
     $serializationPolicy = $this->getCachedSerializationPolicy($moduleBaseURL, $strongName);
     if (!is_null($serializationPolicy)) {
         return $serializationPolicy;
     }
     $serializationPolicy = $this->doGetSerializationPolicy($moduleBaseURL, $strongName);
     if (is_null($serializationPolicy)) {
         // Failed to get the requested serialization policy; use the default
         /*log(
                  	"WARNING: Failed to get the SerializationPolicy '"
                      + strongName
                      + "' for module '"
                      + moduleBaseURL
                      + "'; a legacy, 1.3.3 compatible, serialization policy will be used.  You may experience SerializationExceptions as a result.");
         		*/
         $serializationPolicy = RPC::getDefaultSerializationPolicy();
     }
     // This could cache null or an actual instance. Either way we will not
     // attempt to lookup the policy again.
     $this->putCachedSerializationPolicy($moduleBaseURL, $strongName, $serializationPolicy);
     return $serializationPolicy;
 }
Exemple #3
0
 /**
  * Returns a string that encodes an exception. If method is not
  * <code>null</code>, it is an error if the exception is not in the
  * method's list of checked exceptions.
  *
  * <p>
  * If the serializationPolicy parameter is not <code>null</code>, it is
  * used to determine what types can be encoded as part of this response. If
  * this parameter is <code>null</code>, then only subtypes of
  * {@link com.google.gwt.user.client.rpc.IsSerializable IsSerializable} or
  * types which have custom field serializers may be encoded.
  * </p>
  *
  * @param MappedMethod serviceMethod the method that threw the exception, may be
  *          <code>null</code>
  * @param Exception cause the {@link Throwable} that was thrown
  * @param SerializationPolicy serializationPolicy determines the serialization policy to be used
  * @return a string that encodes the exception
  *
  * @throws NullPointerException if the the cause or the serializationPolicy
  *           are <code>null</code>
  * @throws SerializationException if the result cannot be serialized
  * @throws UnexpectedException if the result was an unexpected exception (a
  *           checked exception not declared in the serviceMethod's signature)
  */
 public static function encodeResponseForFailure(MappedMethod $serviceMethod = null, Exception $cause, SerializationPolicy $serializationPolicy = null, MappedClassLoader $mappedClassLoader)
 {
     if ($cause === null) {
         throw new NullPointerException("cause cannot be null");
     }
     if ($serializationPolicy === null) {
         $serializationPolicy = RPC::getDefaultSerializationPolicy();
         //throw new NullPointerException("serializationPolicy");
     }
     if ($serviceMethod != null && !RPC::isExpectedException($serviceMethod, $cause)) {
         class_exists('UnexpectedException') || (require GWTPHP_DIR . '/exceptions/UnexpectedException.class.php');
         throw new UnexpectedException("Service method '" . RPC::getSourceRepresentation($serviceMethod) . "' threw an unexpected exception: " . $cause->__toString(), $cause);
     }
     //class_exists('UnimplementedOperationException') || require(GWTPHP_DIR.'/exceptions/UnimplementedOperationException.class.php');
     //throw new UnimplementedOperationException("Exception serialization not implemented yet! " . print_r($cause,true));
     //ArrayMappedClassLoader::loadMappedClass('pl.rmalinowski.gwtphp.client.dto.SimpleException');
     $couseClass = $mappedClassLoader->findMappedClassByReflectionClass(new ReflectionObject($cause));
     return RPC::encodeResponse($couseClass, $cause, true, $serializationPolicy);
     // return RPC::encodeResponse($cause.getClass(), $cause, true, $serializationPolicy);
 }
 public function __construct(SerializationPolicyProvider $serializationPolicyProvider)
 {
     //parent::__construct();
     $this->serializationPolicy = RPC::getDefaultSerializationPolicy();
     $this->settersByClass = new HashMap();
     $this->serializationPolicyProvider = $serializationPolicyProvider;
 }