Examples of BAMConfigurationDSClient


Examples of org.wso2.carbon.bam.common.clients.BAMConfigurationDSClient


    public void addService(ServiceDO service) throws BAMException {
        // we should not add the server if it is not in the config tables.
        // unlike in the case with services when operations are added.
        BAMConfigurationDSClient client = null;
        try {
            client = BAMUtil.getBAMConfigurationDSClient();
            client.addService(service);
        } finally {
            if (client != null) {
                client.cleanup();
            }
        }
    }
View Full Code Here

Examples of org.wso2.carbon.bam.common.clients.BAMConfigurationDSClient

        }
    }

    public ServiceDO getService(int serviceID) throws BAMException {
        ServiceDO service = BAMConfigurationCache.getService(serviceID);
        BAMConfigurationDSClient client = null;
        try {
            if (service == null) {
                client = BAMUtil.getBAMConfigurationDSClient();
                return client.getService(serviceID);
            }
            if (service != null) {
                BAMConfigurationCache.addService(service);
            }

            return service;
        } finally {
            if (client != null) {
                client.cleanup();
            }
        }
    }
View Full Code Here

Examples of org.wso2.carbon.bam.common.clients.BAMConfigurationDSClient

    }

    public ServiceDO getService(int serverID, String serviceName) throws BAMException {
        ServiceDO cashService = BAMConfigurationCache.getService(serverID, serviceName);
        ServiceDO service = null;
        BAMConfigurationDSClient configurationDSClient = null;

        try {
            if (cashService == null) {
                configurationDSClient = BAMUtil.getBAMConfigurationDSClient();
                // load service from DB
                service = configurationDSClient.getService(serverID, serviceName);
                if (service == null) {
                    // service not there in the DB, hence we need to add it
                    service = new ServiceDO();
                    service.setName(serviceName);
                    service.setServerID(serverID);
                    // This is to guard against occasional race condition of service
                    // being added while operation is also being added.
                    boolean raceCondition = false;
                    try {
                        configurationDSClient.addService(service);
                        BAMConfigurationCache.addService(service);
                    } catch (Exception ignore) {
                        // In this case the service should have already been added
                        // to the DB, thus the following getService
                        // now would definitely retrieve it the service.
                        log.error("Race condition - trying to add the same service from two events." +
                                " Attempting to recover...");
                        raceCondition = true;
                    }
                    service = configurationDSClient.getService(serverID, serviceName);
                    if (raceCondition && service != null) {
                        log.info("Recovered from race condition. " + serviceName + " successfully added!");
                    } else if (raceCondition && service == null) {
                        log.error("Failed to recover from race condition, in adding service " + serviceName);
                    }
                }
            }
            return service;
        } catch (BAMException e) {
            throw e;
        } finally {
            if (configurationDSClient != null) {
                configurationDSClient.cleanup();
            }
        }
    }
View Full Code Here

Examples of org.wso2.carbon.bam.common.clients.BAMConfigurationDSClient

    public List<ServiceDO> getAllServices(int serverID) throws BAMException {

        List<ServiceDO> services = BAMConfigurationCache.getAllServices(serverID);

        BAMConfigurationDSClient client = null;
        try {
            if (services == null || services.size() <= 0) {
                client = BAMUtil.getBAMConfigurationDSClient();
                ServiceDO[] servicesArray = client.getAllServices(serverID);
                services = new ArrayList<ServiceDO>(servicesArray.length);
                services.addAll(Arrays.asList(servicesArray));
            }

            for (ServiceDO svc : services) {
                BAMConfigurationCache.addService(svc);
            }

            return services;
        } finally {
            if (client != null) {
                client.cleanup();
            }
        }
    }
View Full Code Here

Examples of org.wso2.carbon.bam.common.clients.BAMConfigurationDSClient

    }

    public List<OperationDO> getAllOperations(int serviceID) throws BAMException {
        List<OperationDO> operations = BAMConfigurationCache.getAllOperations(serviceID);

        BAMConfigurationDSClient client = null;
        try {
            if (operations == null || operations.size() <= 0) {
                client = BAMUtil.getBAMConfigurationDSClient();
                OperationDO[] operationsArray = client.getAllOperations(serviceID);

                operations = new ArrayList<OperationDO>();
                operations.addAll(Arrays.asList(operationsArray));
            }
            return operations;
        } finally {
            if (client != null) {
                client.cleanup();
            }
        }
    }
View Full Code Here

Examples of org.wso2.carbon.bam.common.clients.BAMConfigurationDSClient

            addService(service);
        }
    }

    public void addOperation(OperationDO operation) throws BAMException {
        BAMConfigurationDSClient client = null;
        try {
            client = BAMUtil.getBAMConfigurationDSClient();
            client.addOperation(operation);
        } finally {
            if (client != null) {
                client.cleanup();
            }
        }
    }
View Full Code Here

Examples of org.wso2.carbon.bam.common.clients.BAMConfigurationDSClient

        }
    }

    public OperationDO getOperation(int serviceID, String operationName) throws BAMException {

        BAMConfigurationDSClient client = null;
        try {
            client = BAMUtil.getBAMConfigurationDSClient();
            OperationDO operation = client.getOperation(serviceID, operationName);

            if (operation == null) {
                operation = new OperationDO();
                operation.setName(operationName);
                operation.setServiceID(serviceID);

                client.addOperation(operation);
                operation = client.getOperation(serviceID, operationName);
            }

            if (operation != null) {
                BAMConfigurationCache.addOperation(operation);
            }

            return operation;
        } finally {
            if (client != null) {
                client.cleanup();
            }
        }

    }
View Full Code Here

Examples of org.wso2.carbon.bam.common.clients.BAMConfigurationDSClient

    }

    public OperationDO getOperation(int operationID) throws BAMException {
        OperationDO operation = BAMConfigurationCache.getOperation(operationID);
        BAMConfigurationDSClient client = null;
        try {
            if (operation == null) {
                client = BAMUtil.getBAMConfigurationDSClient();
                operation = client.getOperation(operationID);
            }
            BAMConfigurationCache.addOperation(operation);
            return operation;
        } finally {
            if (client != null) {
                client.cleanup();
            }
        }
    }
View Full Code Here

Examples of org.wso2.carbon.bam.common.clients.BAMConfigurationDSClient

            }
        }
    }

    public List<MediationDataDO> getEndpoints(int serverId) throws BAMException {
        BAMConfigurationDSClient client = null;
        try {
            client = BAMUtil.getBAMConfigurationDSClient();
            MediationDataDO[] endpoints = client.getEndpoints(serverId);
            List<MediationDataDO> endpointList = new ArrayList<MediationDataDO>(endpoints.length);
            endpointList.addAll(Arrays.asList(endpoints));
            return endpointList;
        } finally {
            if (client != null) {
                client.cleanup();
            }
        }
    }
View Full Code Here

Examples of org.wso2.carbon.bam.common.clients.BAMConfigurationDSClient

            }
        }
    }

    public List<MediationDataDO> getSequences(int serverId) throws BAMException {
        BAMConfigurationDSClient client = null;
        try {
            client = BAMUtil.getBAMConfigurationDSClient();
            MediationDataDO[] sequences = client.getSequences(serverId);
            List<MediationDataDO> sequenceList = new ArrayList<MediationDataDO>(sequences.length);
            sequenceList.addAll(Arrays.asList(sequences));
            return sequenceList;
        } finally {
            if (client != null) {
                client.cleanup();
            }
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.