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

com.hazelcast.osgi.impl.HazelcastOSGiInstanceImpl Maven / Gradle / Ivy

There is a newer version: 5.4.0
Show newest version
/*
 * 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.osgi.impl;

import com.hazelcast.config.Config;
import com.hazelcast.config.GroupConfig;
import com.hazelcast.core.ClientService;
import com.hazelcast.core.Cluster;
import com.hazelcast.core.DistributedObject;
import com.hazelcast.core.DistributedObjectListener;
import com.hazelcast.core.Endpoint;
import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.IAtomicLong;
import com.hazelcast.core.IAtomicReference;
import com.hazelcast.core.ICountDownLatch;
import com.hazelcast.core.IExecutorService;
import com.hazelcast.core.IList;
import com.hazelcast.core.ILock;
import com.hazelcast.core.IMap;
import com.hazelcast.core.IQueue;
import com.hazelcast.core.ISemaphore;
import com.hazelcast.core.ISet;
import com.hazelcast.core.ITopic;
import com.hazelcast.core.IdGenerator;
import com.hazelcast.core.LifecycleService;
import com.hazelcast.core.MultiMap;
import com.hazelcast.core.PartitionService;
import com.hazelcast.core.ReplicatedMap;
import com.hazelcast.osgi.HazelcastOSGiInstance;
import com.hazelcast.osgi.HazelcastOSGiService;
import com.hazelcast.logging.LoggingService;
import com.hazelcast.mapreduce.JobTracker;
import com.hazelcast.quorum.QuorumService;
import com.hazelcast.ringbuffer.Ringbuffer;
import com.hazelcast.transaction.HazelcastXAResource;
import com.hazelcast.transaction.TransactionContext;
import com.hazelcast.transaction.TransactionException;
import com.hazelcast.transaction.TransactionOptions;
import com.hazelcast.transaction.TransactionalTask;
import com.hazelcast.util.StringUtil;

import java.util.Collection;
import java.util.concurrent.ConcurrentMap;

/**
 * {@link com.hazelcast.osgi.HazelcastOSGiInstance} implementation
 * as proxy of delegated {@link com.hazelcast.core.HazelcastInstance} for getting from OSGi service.
 */
class HazelcastOSGiInstanceImpl
        implements HazelcastOSGiInstance {

    private final HazelcastInstance delegatedInstance;
    private final HazelcastOSGiService ownerService;

    public HazelcastOSGiInstanceImpl(HazelcastInstance delegatedInstance,
                                     HazelcastOSGiService ownerService) {
        this.delegatedInstance = delegatedInstance;
        this.ownerService = ownerService;
    }

    @Override
    public String getName() {
        return delegatedInstance.getName();
    }

    @Override
    public  IQueue getQueue(String name) {
        return delegatedInstance.getQueue(name);
    }

    @Override
    public  ITopic getTopic(String name) {
        return delegatedInstance.getTopic(name);
    }

    @Override
    public  ISet getSet(String name) {
        return delegatedInstance.getSet(name);
    }

    @Override
    public  IList getList(String name) {
        return delegatedInstance.getList(name);
    }

    @Override
    public  IMap getMap(String name) {
        return delegatedInstance.getMap(name);
    }

    @Override
    public  ReplicatedMap getReplicatedMap(String name) {
        return delegatedInstance.getReplicatedMap(name);
    }

    @Override
    public JobTracker getJobTracker(String name) {
        return delegatedInstance.getJobTracker(name);
    }

    @Override
    public  MultiMap getMultiMap(String name) {
        return delegatedInstance.getMultiMap(name);
    }

    @Override
    public ILock getLock(String key) {
        return delegatedInstance.getLock(key);
    }

    @Override
    public  Ringbuffer getRingbuffer(String name) {
        return delegatedInstance.getRingbuffer(name);
    }

    @Override
    public  ITopic getReliableTopic(String name) {
        return delegatedInstance.getReliableTopic(name);
    }

    @Override
    public Cluster getCluster() {
        return delegatedInstance.getCluster();
    }

    @Override
    public Endpoint getLocalEndpoint() {
        return delegatedInstance.getLocalEndpoint();
    }

    @Override
    public IExecutorService getExecutorService(String name) {
        return delegatedInstance.getExecutorService(name);
    }

    @Override
    public  T executeTransaction(TransactionalTask task) throws TransactionException {
        return delegatedInstance.executeTransaction(task);
    }

    @Override
    public  T executeTransaction(TransactionOptions options, TransactionalTask task) throws TransactionException {
        return delegatedInstance.executeTransaction(options, task);
    }

    @Override
    public TransactionContext newTransactionContext() {
        return delegatedInstance.newTransactionContext();
    }

    @Override
    public TransactionContext newTransactionContext(TransactionOptions options) {
        return delegatedInstance.newTransactionContext(options);
    }

    @Override
    public IdGenerator getIdGenerator(String name) {
        return delegatedInstance.getIdGenerator(name);
    }

    @Override
    public IAtomicLong getAtomicLong(String name) {
        return delegatedInstance.getAtomicLong(name);
    }

    @Override
    public  IAtomicReference getAtomicReference(String name) {
        return delegatedInstance.getAtomicReference(name);
    }

    @Override
    public ICountDownLatch getCountDownLatch(String name) {
        return delegatedInstance.getCountDownLatch(name);
    }

    @Override
    public ISemaphore getSemaphore(String name) {
        return delegatedInstance.getSemaphore(name);
    }

    @Override
    public Collection getDistributedObjects() {
        return delegatedInstance.getDistributedObjects();
    }

    @Override
    public String addDistributedObjectListener(DistributedObjectListener distributedObjectListener) {
        return delegatedInstance.addDistributedObjectListener(distributedObjectListener);
    }

    @Override
    public boolean removeDistributedObjectListener(String registrationId) {
        return delegatedInstance.removeDistributedObjectListener(registrationId);
    }

    @Override
    public Config getConfig() {
        return delegatedInstance.getConfig();
    }

    @Override
    public PartitionService getPartitionService() {
        return delegatedInstance.getPartitionService();
    }

    @Override
    public QuorumService getQuorumService() {
        return delegatedInstance.getQuorumService();
    }

    @Override
    public ClientService getClientService() {
        return delegatedInstance.getClientService();
    }

    @Override
    public LoggingService getLoggingService() {
        return delegatedInstance.getLoggingService();
    }

    @Override
    public LifecycleService getLifecycleService() {
        return delegatedInstance.getLifecycleService();
    }

    @Override
    public  T getDistributedObject(String serviceName, String name) {
        return delegatedInstance.getDistributedObject(serviceName, name);
    }

    @Override
    public ConcurrentMap getUserContext() {
        return delegatedInstance.getUserContext();
    }

    @Override
    public HazelcastXAResource getXAResource() {
        return delegatedInstance.getXAResource();
    }

    @Override
    public void shutdown() {
        delegatedInstance.shutdown();
    }

    @Override
    public HazelcastInstance getDelegatedInstance() {
        return delegatedInstance;
    }

    @Override
    public HazelcastOSGiService getOwnerService() {
        return ownerService;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }

        HazelcastOSGiInstanceImpl that = (HazelcastOSGiInstanceImpl) o;

        if (!delegatedInstance.equals(that.delegatedInstance)) {
            return false;
        }
        if (!ownerService.equals(that.ownerService)) {
            return false;
        }

        return true;
    }

    @Override
    public int hashCode() {
        int result = ownerService.hashCode();
        result = 31 * result + delegatedInstance.hashCode();
        return result;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder();
        sb.append("HazelcastOSGiInstanceImpl");
        sb.append("{delegatedInstance='").append(delegatedInstance).append('\'');
        Config config = getConfig();
        GroupConfig groupConfig = config.getGroupConfig();
        if (groupConfig != null && !StringUtil.isNullOrEmpty(groupConfig.getName())) {
            sb.append(", groupName=").append(groupConfig.getName());
        }
        sb.append(", ownerServiceId=").append(ownerService.getId());
        sb.append('}');
        return sb.toString();
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy