Package org.apache.synapse.commons

Examples of org.apache.synapse.commons.SynapseCommonsException


     * @param listener <code>DataSourceInformationRepositoryListener</code> instance
     */
    public void setRepositoryListener(DataSourceInformationRepositoryListener listener) {

        if (listener == null) {
            throw new SynapseCommonsException("Provided DataSourceInformationRepositoryListener " +
                    "instance is null", log);
        }

        if (this.listener != null) {
            throw new SynapseCommonsException("There is already a DataSourceInformationRepositoryListener " +
                    "associated with 'DataSourceInformationRepository", log);
        }

        this.listener = listener;
    }
View Full Code Here


     *
     * @param msg The error message
     */
    private static void handleException(String msg) {
        log.error(msg);
        throw new SynapseCommonsException(msg);
    }
View Full Code Here

    private void assertInitialized() {
        if (!initialized) {
            String msg = "Task helper has not been initialized, it requires to be initialized";
            log.error(msg);
            throw new SynapseCommonsException(msg);
        }
    }
View Full Code Here

        return null;
    }

    private static void handleException(String msg) {
        log.error(msg);
        throw new SynapseCommonsException(msg);
    }
View Full Code Here

        throw new SynapseCommonsException(msg);
    }

    private static void handleException(String msg, Throwable throwable) {
        log.error(msg, throwable);
        throw new SynapseCommonsException(msg, throwable);
    }
View Full Code Here

        }
    }

    private static void handleException(String msg) {
        log.error(msg);
        throw new SynapseCommonsException(msg);
    }
View Full Code Here

                context.rebind(dataSourceName, ref);
            } catch (NamingException e) {
                String msg = " Error binding name ' " + dataSourceName + " ' to " +
                        "the DataSource(BasicDataSource) reference";
                throw new SynapseCommonsException(msg, e, log);
            }

        } else if (DataSourceInformation.PER_USER_POOL_DATA_SOURCE.equals(dsType)) {

            // Construct DriverAdapterCPDS reference
            String className = (String) information.getParameter(
                    DataSourceConstants.PROP_CPDS_ADAPTER +
                            DataSourceConstants.DOT_STRING +
                            DataSourceConstants.PROP_CPDS_CLASS_NAME);
            String factory = (String) information.getParameter(
                    DataSourceConstants.PROP_CPDS_ADAPTER +
                            DataSourceConstants.DOT_STRING +
                            DataSourceConstants.PROP_CPDS_FACTORY);
            String name = (String) information.getParameter(
                    DataSourceConstants.PROP_CPDS_ADAPTER +
                            DataSourceConstants.DOT_STRING +
                            DataSourceConstants.PROP_CPDS_NAME);

            Reference cpdsRef =
                    new Reference(className, factory, null);

            cpdsRef.add(new StringRefAddr(DataSourceConstants.PROP_DRIVER, driver));
            cpdsRef.add(new StringRefAddr(DataSourceConstants.PROP_URL, url));
            cpdsRef.add(new StringRefAddr(DataSourceConstants.PROP_USER, user));
            cpdsRef.add(new StringRefAddr(SecurityConstants.PROP_PASSWORD,
                    password));

            try {
                context.rebind(name, cpdsRef);
            } catch (NamingException e) {
                String msg = "Error binding name '" + name + "' to " +
                        "the DriverAdapterCPDS reference";
                throw new SynapseCommonsException(msg, e, log);
            }

            // Construct PerUserPoolDataSource reference
            Reference ref =
                    new Reference("org.apache.commons.dbcp.datasources.PerUserPoolDataSource",
                            "org.apache.commons.dbcp.datasources.PerUserPoolDataSourceFactory",
                            null);

            ref.add(new BinaryRefAddr(
                    DataSourceConstants.PROP_JNDI_ENV,
                    MiscellaneousUtil.serialize(jndiEvn)));
            ref.add(new StringRefAddr(
                    DataSourceConstants.PROP_DATA_SOURCE_NAME, name));
            ref.add(new StringRefAddr(
                    DataSourceConstants.PROP_DEFAULT_MAX_ACTIVE, maxActive));
            ref.add(new StringRefAddr(
                    DataSourceConstants.PROP_DEFAULT_MAX_IDLE, maxIdle));
            ref.add(new StringRefAddr(
                    DataSourceConstants.PROP_DEFAULT_MAX_WAIT, maxWait));

            //set default jndiProperties for reference
            setCommonParameters(ref, information);

            try {

                if (log.isDebugEnabled()) {
                    log.debug("Registering a DataSource with name : " +
                            dataSourceName + " in the JNDI tree with jndiProperties : " + jndiEvn);
                }

                context.rebind(dataSourceName, ref);
            } catch (NamingException e) {
                String msg = "Error binding name ' " + dataSourceName + " ' to " +
                        "the PerUserPoolDataSource reference";
                throw new SynapseCommonsException(msg, e, log);
            }

        } else {
            throw new SynapseCommonsException("Unsupported data source type : " + dsType, log);
        }
        cachedNameList.add(dataSourceName);
    }
View Full Code Here

        InitialContext context = getCachedInitialContext(name);
        try {
            context.unbind(name);
        } catch (NamingException e) {
            throw new SynapseCommonsException("Error removing a Datasource with name : " +
                    name + " from the JNDI context : " + initialContext, e);
        }
        cachedNameList.remove(name);
    }
View Full Code Here

                try {
                    assert context != null;
                    context = context.createSubcontext(path1);
                    if (context == null) {
                        throw new SynapseCommonsException("sub context " + path1 + " could not" +
                                " be created", log);
                    }

                } catch (NamingException e) {
                    throw new SynapseCommonsException("Unable to create sub context : " + path1,
                            e, log);
                }
            }
        }
    }
View Full Code Here

        return initialized;
    }

    private void validateInitialized() {
        if (!isInitialized()) {
            throw new SynapseCommonsException("Datasource repository has not been initialized " +
                    "yet", log);
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.synapse.commons.SynapseCommonsException

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.