本文整理汇总了PHP中RPC::getDefaultSerializationPolicy方法的典型用法代码示例。如果您正苦于以下问题:PHP RPC::getDefaultSerializationPolicy方法的具体用法?PHP RPC::getDefaultSerializationPolicy怎么用?PHP RPC::getDefaultSerializationPolicy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RPC
的用法示例。
在下文中一共展示了RPC::getDefaultSerializationPolicy方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
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');
}
示例2: getSerializationPolicy
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;
}
示例3: encodeResponseForFailure
/**
* 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);
}
示例4: __construct
public function __construct(SerializationPolicyProvider $serializationPolicyProvider)
{
//parent::__construct();
$this->serializationPolicy = RPC::getDefaultSerializationPolicy();
$this->settersByClass = new HashMap();
$this->serializationPolicyProvider = $serializationPolicyProvider;
}