Package org.wso2.carbon.bam.common.clients

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


        return new ArrayList<ServerDO>();
    }


    public ServerDO getMonitoredServer(int serverID) throws BAMException {
        BAMConfigurationDSClient client = null;
        ServerDO server = null;
        try {
            client = BAMUtil.getBAMConfigurationDSClient();
            server = client.getServer(serverID);
            if (server != null && server.getPassword() != null) {
                server.setPassword(decryptPassword(server.getPassword()));
            }

        } catch (CryptoException e) {
            throw new BAMException("Cannot decrypt password for server " + server.getServerURL(), e);
        } finally {
            if (client != null) {
                client.cleanup();
            }
        }
        return server;
    }
View Full Code Here


        }
        return server;
    }

    public ServerDO getMonitoredServer(String serverURL) throws BAMException {
        BAMConfigurationDSClient client = null;
        ServerDO server = null;
        try {
            client = BAMUtil.getBAMConfigurationDSClient();
            server = client.getServer(serverURL);
            if (server != null && server.getPassword() != null) {
                server.setPassword(decryptPassword(server.getPassword()));
            }

        } catch (CryptoException e) {
            throw new BAMException("Cannot decrypt password for server " + server.getServerURL(), e);
        } finally {
            if (client != null) {
                client.cleanup();
            }
        }
        return server;
    }
View Full Code Here

    public Registry getRegistry() {
        return registry;
    }

    public void deactivateServer(int serverID) throws BAMException {
        BAMConfigurationDSClient client = null;

        try {
            client = BAMUtil.getBAMConfigurationDSClient();
            client.deactivateServer(serverID);
            BAMUtil.getServersListCache().removeServer(serverID);
        } finally {
            if (client != null) {
                client.cleanup();
            }
        }
    }
View Full Code Here

            }
        }
    }

    public void activateServer(int serverID, String subscriptionID) throws BAMException {
        BAMConfigurationDSClient client = null;

        try {
            client = BAMUtil.getBAMConfigurationDSClient();
            client.activateServer(serverID, subscriptionID);
        } catch (BAMException e) {
            throw e;
        } finally {
            if (client != null) {
                client.cleanup();
            }
        }
    }
View Full Code Here


    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

        }
    }

    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

    }

    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

    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

    }

    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

            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

TOP

Related Classes of org.wso2.carbon.bam.common.clients.BAMConfigurationDSClient

Copyright © 2018 www.massapicom. 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.