All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.hazelcast.client.impl.client.ClientRequest Maven / Gradle / Ivy

/*
 * Copyright (c) 2008-2016, Hazelcast, Inc. All Rights Reserved.
 *
 * Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
 *
 * 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.
 */

package com.hazelcast.client.impl.client;

import com.hazelcast.client.ClientEndpoint;
import com.hazelcast.client.ClientEngine;
import com.hazelcast.client.impl.ClientEngineImpl;
import com.hazelcast.nio.serialization.PortableReader;
import com.hazelcast.nio.serialization.PortableWriter;
import com.hazelcast.internal.serialization.SerializationService;
import com.hazelcast.nio.serialization.VersionedPortable;
import com.hazelcast.spi.OperationService;

import java.io.IOException;

public abstract class ClientRequest implements SecureRequest, VersionedPortable {

    protected volatile long callId = -1;
    protected transient ClientEngineImpl clientEngine;
    protected transient OperationService operationService;
    protected transient SerializationService serializationService;
    protected transient Object service;
    protected transient ClientEndpoint endpoint;

    public void setOperationService(OperationService operationService) {
        this.operationService = operationService;
    }

    public void setSerializationService(SerializationService serializationService) {
        this.serializationService = serializationService;
    }

    public abstract void process() throws Exception;

    public ClientEngine getClientEngine() {
        return clientEngine;
    }

    public final void setClientEngine(ClientEngineImpl clientEngine) {
        this.clientEngine = clientEngine;
    }

    public  S getService() {
        return (S) service;
    }

    public final void setService(Object service) {
        this.service = service;
    }

    public ClientEndpoint getEndpoint() {
        return endpoint;
    }

    public final void setEndpoint(ClientEndpoint endpoint) {
        this.endpoint = endpoint;
    }

    public abstract String getServiceName();

    public long getCallId() {
        return callId;
    }

    public void setCallId(long callId) {
        this.callId = callId;
    }

    @Override
    public final void writePortable(PortableWriter writer) throws IOException {
        writer.writeLong("cId", callId);
        write(writer);
    }

    public void write(PortableWriter writer) throws IOException {
    }

    @Override
    public final void readPortable(PortableReader reader) throws IOException {
        callId = reader.readLong("cId");
        read(reader);
    }

    public void read(PortableReader reader) throws IOException {
    }

    /**
     * Version for internal requests.
     * This version can be configured per class by overriding this method.
     * 

*

* This should be updated/incremented when serialization of a request changes. *

*/ @Override public int getClassVersion() { return 1; } @Override public String getDistributedObjectType() { return getServiceName(); } @Override public String getDistributedObjectName() { return null; } @Override public String getMethodName() { return null; } @Override public Object[] getParameters() { return null; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy