Search in sources :

Example 1 with Serialization

use of io.fabric8.kubernetes.client.utils.Serialization in project fabric8 by jboss-fuse.

the class ClientInvokerImpl method getMethodData.

private MethodData getMethodData(Method method) throws IOException {
    MethodData rc = null;
    synchronized (method_cache) {
        rc = method_cache.get(method);
    }
    if (rc == null) {
        StringBuilder sb = new StringBuilder();
        sb.append(method.getName());
        sb.append(",");
        Class<?>[] types = method.getParameterTypes();
        for (int i = 0; i < types.length; i++) {
            if (i != 0) {
                sb.append(",");
            }
            sb.append(encodeClassName(types[i]));
        }
        Buffer signature = new UTF8Buffer(sb.toString()).buffer();
        Serialization annotation = method.getAnnotation(Serialization.class);
        SerializationStrategy serializationStrategy;
        if (annotation != null) {
            serializationStrategy = serializationStrategies.get(annotation.value());
            if (serializationStrategy == null) {
                throw new RuntimeException("Could not find the serialization strategy named: " + annotation.value());
            }
        } else {
            serializationStrategy = ObjectSerializationStrategy.INSTANCE;
        }
        final InvocationStrategy strategy;
        if (AsyncInvocationStrategy.isAsyncMethod(method)) {
            strategy = AsyncInvocationStrategy.INSTANCE;
        } else {
            strategy = BlockingInvocationStrategy.INSTANCE;
        }
        rc = new MethodData(strategy, serializationStrategy, signature);
        synchronized (method_cache) {
            method_cache.put(method, rc);
        }
    }
    return rc;
}
Also used : Buffer(org.fusesource.hawtbuf.Buffer) UTF8Buffer(org.fusesource.hawtbuf.UTF8Buffer) Serialization(io.fabric8.dosgi.api.Serialization) UTF8Buffer(org.fusesource.hawtbuf.UTF8Buffer) SerializationStrategy(io.fabric8.dosgi.api.SerializationStrategy) ObjectSerializationStrategy(io.fabric8.dosgi.api.ObjectSerializationStrategy)

Aggregations

ObjectSerializationStrategy (io.fabric8.dosgi.api.ObjectSerializationStrategy)1 Serialization (io.fabric8.dosgi.api.Serialization)1 SerializationStrategy (io.fabric8.dosgi.api.SerializationStrategy)1 Buffer (org.fusesource.hawtbuf.Buffer)1 UTF8Buffer (org.fusesource.hawtbuf.UTF8Buffer)1