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

com.viaoa.sync.remote.RemoteClientImpl Maven / Gradle / Ivy

There is a newer version: 3.7.10
Show newest version
/*  Copyright 1999 Vince Via [email protected]
    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.viaoa.sync.remote;

import java.util.concurrent.atomic.AtomicInteger;
import java.util.logging.Logger;
import com.viaoa.ds.OADataSource;
import com.viaoa.hub.Hub;
import com.viaoa.object.OAObject;
import com.viaoa.object.OAObjectCacheDelegate;
import com.viaoa.object.OAObjectDelegate;
import com.viaoa.object.OAObjectKey;
import com.viaoa.object.OAObjectPropertyDelegate;
import com.viaoa.object.OAObjectReflectDelegate;
import com.viaoa.sync.OASyncDelegate;

public abstract class RemoteClientImpl implements RemoteClientInterface {
    private static Logger LOG = Logger.getLogger(RemoteClientImpl.class.getName());
    // protected ConcurrentHashMap hashCache = new ConcurrentHashMap();
    // protected ConcurrentHashMap hashLock = new ConcurrentHashMap();
    private ClientGetDetail clientGetDetail; 
    private volatile RemoteDataSource remoteDataSource;
    private int sessionId;
    
    public RemoteClientImpl(int sessionId) {
        this.sessionId = sessionId;
        clientGetDetail = new ClientGetDetail(sessionId) {
            @Override
            protected void loadDataInBackground(OAObject obj, String property) {
                RemoteClientImpl.this.loadDataInBackground(obj, property);
            }
        };
    }
    
    /**
     * called when a other props or sibling data cant be loaded for current request, because of timeout.
     * This can be overwritten to have it done in a background thread.
     */
    protected void loadDataInBackground(OAObject obj, String property) {
    }
    
    
    // 20160101
    public void close() {
        clientGetDetail.close();
        clientGetDetail = null;
        remoteDataSource = null;
    }
    
    /**
     * this is called when objects are removed on the client,
     * so that the guid can be removed from the clientGetDetail cache of object.guids that have been sent to client. 
     */
    public void removeGuids(int[] guids) {
        if (guids == null) return;
        if (clientGetDetail == null) return;
        int x = guids.length;
        for (int i=0; i© 2015 - 2025 Weber Informatics LLC | Privacy Policy