Package org.apache.geronimo.connector.deployment.jsr88

Examples of org.apache.geronimo.connector.deployment.jsr88.Connector15DCBTest


                        setting.setValue(value == null ? "" : value);
                    }
                }
                ConnectionManager manager = instance.getConnectionManager();
                manager.setTransactionLocal(true);
                SinglePool pool = new SinglePool();
                manager.setPoolSingle(pool);
                pool.setMatchOne(true);
                // Max Size needs to be set before the minimum.  This is because
                // the connection manager will constrain the minimum based on the
                // current maximum value in the pool.  We might consider adding a 
                // setPoolConstraints method to allow specifying both at the same time.
                if(data.maxSize != null && !data.maxSize.equals("")) {
                    pool.setMaxSize(new Integer(data.maxSize));
                }
                if(data.minSize != null && !data.minSize.equals("")) {
                    pool.setMinSize(new Integer(data.minSize));
                }
                if(data.blockingTimeout != null && !data.blockingTimeout.equals("")) {
                    pool.setBlockingTimeoutMillis(new Integer(data.blockingTimeout));
                }
                if(data.idleTimeout != null && !data.idleTimeout.equals("")) {
                    pool.setIdleTimeoutMinutes(new Integer(data.idleTimeout));
                }
               
                if(planOnly) {
                    ByteArrayOutputStream out = new ByteArrayOutputStream();
                    config.save(out);
                    out.close();
                    return new String(out.toByteArray(), "US-ASCII");
                } else {
                    File tempFile = File.createTempFile("console-deployment",".xml");
                    tempFile.deleteOnExit();
                    log.debug("Writing database pool deployment plan to "+tempFile.getAbsolutePath());
                    BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(tempFile));
                    config.save(out);
                    out.flush();
                    out.close();
                    Target[] targets = mgr.getTargets();
                    ProgressObject po = mgr.distribute(targets, rarFile, tempFile);
                    waitForProgress(po);
                    if(po.getDeploymentStatus().isCompleted()) {
                        TargetModuleID[] ids = po.getResultTargetModuleIDs();
                        po = mgr.start(ids);
                        waitForProgress(po);
                        if(po.getDeploymentStatus().isCompleted()) {
                            ids = po.getResultTargetModuleIDs();
                            if(status != null) {
                                status.getCurrentPool().setName(data.getName());
                                status.getCurrentPool().setConfigurationName(ids[0].getModuleID());
                                status.getCurrentPool().setFinished(true);
                                response.setRenderParameter(MODE_KEY, IMPORT_STATUS_MODE);
                            }
                           
                            log.info("Deployment completed successfully!");
                        }
                    } else if(po.getDeploymentStatus().isFailed()) {
                        data.deployError = "Unable to deploy: " + data.name;
                        response.setRenderParameter(MODE_KEY, EDIT_MODE);
                        log.info("Deployment Failed!");
                    }
                }
            } catch (Exception e) {
                log.error("Unable to save connection pool", e);
            } finally {
                if(mgr != null) mgr.release();
            }
        } else { // We're saving updates to an existing pool
            if(planOnly) {
                throw new UnsupportedOperationException("Can't update a plan for an existing deployment");
            }
            try {
                JCAManagedConnectionFactory factory = (JCAManagedConnectionFactory) PortletManager.getManagedBean(request, new AbstractName(URI.create(data.getAbstractName())));
                if(data.isGeneric()) {
                    factory.setConfigProperty("ConnectionURL", data.getUrl());
                    factory.setConfigProperty("UserName", data.getUser());
                    factory.setConfigProperty("Password", data.getPassword());
                } else {
                    for (Iterator it = data.getProperties().entrySet().iterator(); it.hasNext();) {
                        Map.Entry entry = (Map.Entry) it.next();
                        factory.setConfigProperty(((String) entry.getKey()).substring("property-".length()), entry.getValue());
                    }
                }
                //todo: push the lookup into ManagementHelper
                PoolingAttributes pool = (PoolingAttributes) factory.getConnectionManager();
                pool.setPartitionMinSize(data.minSize == null || data.minSize.equals("") ? 0 : Integer.parseInt(data.minSize));
                pool.setPartitionMaxSize(data.maxSize == null || data.maxSize.equals("") ? 10 : Integer.parseInt(data.maxSize));
                pool.setBlockingTimeoutMilliseconds(data.blockingTimeout == null || data.blockingTimeout.equals("") ? 5000 : Integer.parseInt(data.blockingTimeout));
                pool.setIdleTimeoutMinutes(data.idleTimeout == null || data.idleTimeout.equals("") ? 15 : Integer.parseInt(data.idleTimeout));
            } catch (Exception e) {
                log.error("Unable to save connection pool", e);
            }
        }
        return null;
View Full Code Here


                    manager.setTransactionNone(true);
                } else {
                    manager.setTransactionLocal(true);
                }

                SinglePool pool = new SinglePool();
                manager.setPoolSingle(pool);
                pool.setMatchOne(true);
                // Max Size needs to be set before the minimum.  This is because
                // the connection manager will constrain the minimum based on the
                // current maximum value in the pool.  We might consider adding a 
                // setPoolConstraints method to allow specifying both at the same time.
                if (data.maxSize != null && !data.maxSize.equals("")) {
                    pool.setMaxSize(new Integer(data.maxSize));
                }
                if (data.minSize != null && !data.minSize.equals("")) {
                    pool.setMinSize(new Integer(data.minSize));
                }
                if (data.blockingTimeout != null && !data.blockingTimeout.equals("")) {
                    pool.setBlockingTimeoutMillis(new Integer(data.blockingTimeout));
                }
                if (data.idleTimeout != null && !data.idleTimeout.equals("")) {
                    pool.setIdleTimeoutMinutes(new Integer(data.idleTimeout));
                }

                if (planOnly) {
                    ByteArrayOutputStream out = new ByteArrayOutputStream();
                    config.save(out);
                    out.close();
                    return new String(out.toByteArray(), "US-ASCII");
                } else {
                    File tempFile = File.createTempFile("console-deployment", ".xml");
                    tempFile.deleteOnExit();
                    log.debug("Writing database pool deployment plan to " + tempFile.getAbsolutePath());
                    BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(tempFile));
                    config.save(out);
                    out.flush();
                    out.close();
                    Target[] targets = mgr.getTargets();
                    if (null == targets) {
                        throw new IllegalStateException("No target to distribute to");
                    }
                    targets = new Target[] {targets[0]};
                   
                    ProgressObject po = mgr.distribute(targets, rarFile, tempFile);
                    waitForProgress(po);
                    if (po.getDeploymentStatus().isCompleted()) {
                        TargetModuleID[] ids = po.getResultTargetModuleIDs();
                        po = mgr.start(ids);
                        waitForProgress(po);
                        if (po.getDeploymentStatus().isCompleted()) {
                            ids = po.getResultTargetModuleIDs();
                            if (status != null) {
                                status.getCurrentPool().setName(data.getName());
                                status.getCurrentPool().setConfigurationName(ids[0].getModuleID());
                                status.getCurrentPool().setFinished(true);
                                response.setRenderParameter(MODE_KEY, IMPORT_STATUS_MODE);
                            }

                            log.info("Deployment completed successfully!");
                        }
                    } else if (po.getDeploymentStatus().isFailed()) {
                        data.deployError = "Unable to deploy: " + data.name;
                        response.setRenderParameter(MODE_KEY, EDIT_MODE);
                        log.info("Deployment Failed!");
                    }
                }
            } catch (Exception e) {
                log.error("Unable to save connection pool", e);
            } finally {
                if (mgr != null) mgr.release();
            }
        } else { // We're saving updates to an existing pool
            if (planOnly) {
                throw new UnsupportedOperationException("Can't update a plan for an existing deployment");
            }
            try {
                JCAManagedConnectionFactory factory = (JCAManagedConnectionFactory) PortletManager.getManagedBean(
                        request, new AbstractName(URI.create(data.getAbstractName())));
                if (data.isGeneric()) {
                    factory.setConfigProperty("ConnectionURL", data.getUrl());
                    factory.setConfigProperty("UserName", data.getUser());
                    factory.setConfigProperty("Password", data.getPassword());
                } else {
                    for (Map.Entry<String, String> entry : data.getProperties().entrySet()) {
                        factory.setConfigProperty(entry.getKey().substring("property-".length()),
                                entry.getValue());
                    }
                }
                //todo: push the lookup into ManagementHelper
                PoolingAttributes pool = (PoolingAttributes) factory.getConnectionManagerContainer();
                pool.setPartitionMinSize(
                        data.minSize == null || data.minSize.equals("") ? 0 : Integer.parseInt(data.minSize));
                pool.setPartitionMaxSize(
                        data.maxSize == null || data.maxSize.equals("") ? 10 : Integer.parseInt(data.maxSize));
                pool.setBlockingTimeoutMilliseconds(
                        data.blockingTimeout == null || data.blockingTimeout.equals("") ? 5000 : Integer.parseInt(
                                data.blockingTimeout));
                pool.setIdleTimeoutMinutes(
                        data.idleTimeout == null || data.idleTimeout.equals("") ? 15 : Integer.parseInt(
                                data.idleTimeout));
            } catch (Exception e) {
                log.error("Unable to save connection pool", e);
            }
View Full Code Here

                        def.setConnectionInstance(new ConnectionDefinitionInstance[]{instance});
                        if(providerData.getConnectionFactoryInterface().equals("javax.jms.ConnectionFactory")) {
                            instance.setImplementedInterface(new String[]{"javax.jms.QueueConnectionFactory","javax.jms.TopicConnectionFactory"});
                        }
                        instance.setName(factoryData.getInstanceName());
                        SinglePool pool = new SinglePool();
                        instance.getConnectionManager().setPoolSingle(pool);
                        pool.setMatchOne(true);
                        pool.setMaxSize(factoryData.getPoolMaxSize());
                        pool.setMinSize(factoryData.getPoolMinSize());
                        pool.setBlockingTimeoutMillis(factoryData.getPoolBlockingTimeout());
                        pool.setIdleTimeoutMinutes(factoryData.getPoolIdleTimeout());
                        if(factoryData.getTransaction().equals("none")) {
                            instance.getConnectionManager().setTransactionNone(true);
                        } else if(factoryData.getTransaction().equals("local")) {
                            instance.getConnectionManager().setTransactionLocal(true);
                        } else if(factoryData.getTransaction().equals("xa")) {
View Full Code Here

                        setting.setValue(value == null ? "" : value);
                    }
                }
                ConnectionManager manager = instance.getConnectionManager();
                manager.setTransactionLocal(true);
                SinglePool pool = new SinglePool();
                manager.setPoolSingle(pool);
                pool.setMatchOne(true);
                // Max Size needs to be set before the minimum.  This is because
                // the connection manager will constrain the minimum based on the
                // current maximum value in the pool.  We might consider adding a 
                // setPoolConstraints method to allow specifying both at the same time.
                if(data.maxSize != null && !data.maxSize.equals("")) {
                    pool.setMaxSize(new Integer(data.maxSize));
                }
                if(data.minSize != null && !data.minSize.equals("")) {
                    pool.setMinSize(new Integer(data.minSize));
                }
                if(data.blockingTimeout != null && !data.blockingTimeout.equals("")) {
                    pool.setBlockingTimeoutMillis(new Integer(data.blockingTimeout));
                }
                if(data.idleTimeout != null && !data.idleTimeout.equals("")) {
                    pool.setIdleTimeoutMinutes(new Integer(data.idleTimeout));
                }
               
                if(planOnly) {
                    ByteArrayOutputStream out = new ByteArrayOutputStream();
                    config.save(out);
                    out.close();
                    return new String(out.toByteArray(), "US-ASCII");
                } else {
                    File tempFile = File.createTempFile("console-deployment",".xml");
                    tempFile.deleteOnExit();
                    log.debug("Writing database pool deployment plan to "+tempFile.getAbsolutePath());
                    BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(tempFile));
                    config.save(out);
                    out.flush();
                    out.close();
                    Target[] targets = mgr.getTargets();
                    ProgressObject po = mgr.distribute(targets, rarFile, tempFile);
                    waitForProgress(po);
                    if(po.getDeploymentStatus().isCompleted()) {
                        TargetModuleID[] ids = po.getResultTargetModuleIDs();
                        po = mgr.start(ids);
                        waitForProgress(po);
                        if(po.getDeploymentStatus().isCompleted()) {
                            ids = po.getResultTargetModuleIDs();
                            if(status != null) {
                                status.getCurrentPool().setName(data.getName());
                                status.getCurrentPool().setConfigurationName(ids[0].getModuleID());
                                status.getCurrentPool().setFinished(true);
                                response.setRenderParameter(MODE_KEY, IMPORT_STATUS_MODE);
                            }
                            System.out.println("Deployment completed successfully!");
                        }
                    }
                }
            } catch (Exception e) {
                log.error("Unable to save connection pool", e);
            } finally {
                if(mgr != null) mgr.release();
            }
        } else { // We're saving updates to an existing pool
            if(planOnly) {
                throw new UnsupportedOperationException("Can't update a plan for an existing deployment");
            }
            try {
                JCAManagedConnectionFactory factory = (JCAManagedConnectionFactory) PortletManager.getManagedBean(request, new AbstractName(URI.create(data.getAbstractName())));
                if(data.isGeneric()) {
                    factory.setConfigProperty("ConnectionURL", data.getUrl());
                    factory.setConfigProperty("UserName", data.getUser());
                    factory.setConfigProperty("Password", data.getPassword());
                } else {
                    for (Iterator it = data.getProperties().entrySet().iterator(); it.hasNext();) {
                        Map.Entry entry = (Map.Entry) it.next();
                        factory.setConfigProperty(((String) entry.getKey()).substring("property-".length()), entry.getValue());
                    }
                }
                //todo: push the lookup into ManagementHelper
                PoolingAttributes pool = (PoolingAttributes) factory.getConnectionManager();
                pool.setPartitionMinSize(data.minSize == null || data.minSize.equals("") ? 0 : Integer.parseInt(data.minSize));
                pool.setPartitionMaxSize(data.maxSize == null || data.maxSize.equals("") ? 10 : Integer.parseInt(data.maxSize));
                pool.setBlockingTimeoutMilliseconds(data.blockingTimeout == null || data.blockingTimeout.equals("") ? 5000 : Integer.parseInt(data.blockingTimeout));
                pool.setIdleTimeoutMinutes(data.idleTimeout == null || data.idleTimeout.equals("") ? 15 : Integer.parseInt(data.idleTimeout));
            } catch (Exception e) {
                log.error("Unable to save connection pool", e);
            }
        }
        return null;
View Full Code Here

                        def.setConnectionInstance(new ConnectionDefinitionInstance[]{instance});
                        if(providerData.getConnectionFactoryInterface().equals("javax.jms.ConnectionFactory")) {
                            instance.setImplementedInterface(new String[]{"javax.jms.QueueConnectionFactory","javax.jms.TopicConnectionFactory"});
                        }
                        instance.setName(factoryData.getInstanceName());
                        SinglePool pool = new SinglePool();
                        instance.getConnectionManager().setPoolSingle(pool);
                        pool.setMatchOne(true);
                        pool.setMaxSize(factoryData.getPoolMaxSize());
                        pool.setMinSize(factoryData.getPoolMinSize());
                        pool.setBlockingTimeoutMillis(factoryData.getPoolBlockingTimeout());
                        pool.setIdleTimeoutMinutes(factoryData.getPoolIdleTimeout());
                        if(factoryData.getTransaction().equals("none")) {
                            instance.getConnectionManager().setTransactionNone(true);
                        } else if(factoryData.getTransaction().equals("local")) {
                            instance.getConnectionManager().setTransactionLocal(true);
                        } else if(factoryData.getTransaction().equals("xa")) {
View Full Code Here

                    manager.setTransactionNone(true);
                } else {
                    manager.setTransactionLocal(true);
                }

                SinglePool pool = new SinglePool();
                manager.setPoolSingle(pool);
                pool.setMatchOne(true);
                // Max Size needs to be set before the minimum.  This is because
                // the connection manager will constrain the minimum based on the
                // current maximum value in the pool.  We might consider adding a 
                // setPoolConstraints method to allow specifying both at the same time.
                if (data.maxSize != null && !data.maxSize.equals("")) {
                    pool.setMaxSize(new Integer(data.maxSize));
                }
                if (data.minSize != null && !data.minSize.equals("")) {
                    pool.setMinSize(new Integer(data.minSize));
                }
                if (data.blockingTimeout != null && !data.blockingTimeout.equals("")) {
                    pool.setBlockingTimeoutMillis(new Integer(data.blockingTimeout));
                }
                if (data.idleTimeout != null && !data.idleTimeout.equals("")) {
                    pool.setIdleTimeoutMinutes(new Integer(data.idleTimeout));
                }

                if (planOnly) {
                    ByteArrayOutputStream out = new ByteArrayOutputStream();
                    config.save(out);
                    out.close();
                    return new String(out.toByteArray(), "US-ASCII");
                } else {
                    File tempFile = File.createTempFile("console-deployment", ".xml");
                    tempFile.deleteOnExit();
                    log.debug("Writing database pool deployment plan to " + tempFile.getAbsolutePath());
                    BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(tempFile));
                    config.save(out);
                    out.flush();
                    out.close();
                    Target[] targets = mgr.getTargets();
                    if (null == targets) {
                        throw new IllegalStateException("No target to distribute to");
                    }
                    targets = new Target[] {targets[0]};
                   
                    ProgressObject po = mgr.distribute(targets, rarFile, tempFile);
                    waitForProgress(po);
                    if (po.getDeploymentStatus().isCompleted()) {
                        TargetModuleID[] ids = po.getResultTargetModuleIDs();
                        po = mgr.start(ids);
                        waitForProgress(po);
                        if (po.getDeploymentStatus().isCompleted()) {
                            ids = po.getResultTargetModuleIDs();
                            if (status != null) {
                                status.getCurrentPool().setName(data.getName());
                                status.getCurrentPool().setConfigurationName(ids[0].getModuleID());
                                status.getCurrentPool().setFinished(true);
                                response.setRenderParameter(MODE_KEY, IMPORT_STATUS_MODE);
                            }

                            log.info("Deployment completed successfully!");
                        }
                    } else if (po.getDeploymentStatus().isFailed()) {
                        data.deployError = "Unable to deploy: " + data.name;
                        response.setRenderParameter(MODE_KEY, EDIT_MODE);
                        log.info("Deployment Failed!");
                    }
                }
            } catch (Exception e) {
                log.error("Unable to save connection pool", e);
            } finally {
                if (mgr != null) mgr.release();
            }
        } else { // We're saving updates to an existing pool
            if (planOnly) {
                throw new UnsupportedOperationException("Can't update a plan for an existing deployment");
            }
            try {
                JCAManagedConnectionFactory factory = (JCAManagedConnectionFactory) PortletManager.getManagedBean(
                        request, new AbstractName(URI.create(data.getAbstractName())));
                if (data.isGeneric()) {
                    factory.setConfigProperty("ConnectionURL", data.getUrl());
                    factory.setConfigProperty("UserName", data.getUser());
                    factory.setConfigProperty("Password", data.getPassword());
                } else {
                    for (Map.Entry<String, String> entry : data.getProperties().entrySet()) {
                        factory.setConfigProperty(entry.getKey().substring("property-".length()),
                                entry.getValue());
                    }
                }
                //todo: push the lookup into ManagementHelper
                PoolingAttributes pool = (PoolingAttributes) factory.getConnectionManagerContainer();
                pool.setPartitionMinSize(
                        data.minSize == null || data.minSize.equals("") ? 0 : Integer.parseInt(data.minSize));
                pool.setPartitionMaxSize(
                        data.maxSize == null || data.maxSize.equals("") ? 10 : Integer.parseInt(data.maxSize));
                pool.setBlockingTimeoutMilliseconds(
                        data.blockingTimeout == null || data.blockingTimeout.equals("") ? 5000 : Integer.parseInt(
                                data.blockingTimeout));
                pool.setIdleTimeoutMinutes(
                        data.idleTimeout == null || data.idleTimeout.equals("") ? 15 : Integer.parseInt(
                                data.idleTimeout));
            } catch (Exception e) {
                log.error("Unable to save connection pool", e);
            }
View Full Code Here

                        def.setConnectionInstance(new ConnectionDefinitionInstance[]{instance});
                        if(providerData.getConnectionFactoryInterface().equals("javax.jms.ConnectionFactory")) {
                            instance.setImplementedInterface(new String[]{"javax.jms.QueueConnectionFactory","javax.jms.TopicConnectionFactory"});
                        }
                        instance.setName(factoryData.getInstanceName());
                        SinglePool pool = new SinglePool();
                        instance.getConnectionManager().setPoolSingle(pool);
                        pool.setMatchOne(true);
                        pool.setMaxSize(factoryData.getPoolMaxSize());
                        pool.setMinSize(factoryData.getPoolMinSize());
                        pool.setBlockingTimeoutMillis(factoryData.getPoolBlockingTimeout());
                        pool.setIdleTimeoutMinutes(factoryData.getPoolIdleTimeout());
                        if(factoryData.getTransaction().equals("none")) {
                            instance.getConnectionManager().setTransactionNone(true);
                        } else if(factoryData.getTransaction().equals("local")) {
                            instance.getConnectionManager().setTransactionLocal(true);
                        } else if(factoryData.getTransaction().equals("xa")) {
View Full Code Here

                    manager.setTransactionNone(true);
                } else {
                    manager.setTransactionLocal(true);
                }

                SinglePool pool = new SinglePool();
                manager.setPoolSingle(pool);
                pool.setMatchOne(true);
                // Max Size needs to be set before the minimum.  This is because
                // the connection manager will constrain the minimum based on the
                // current maximum value in the pool.  We might consider adding a 
                // setPoolConstraints method to allow specifying both at the same time.
                if (data.maxSize != null && !data.maxSize.equals("")) {
                    pool.setMaxSize(new Integer(data.maxSize));
                }
                if (data.minSize != null && !data.minSize.equals("")) {
                    pool.setMinSize(new Integer(data.minSize));
                }
                if (data.blockingTimeout != null && !data.blockingTimeout.equals("")) {
                    pool.setBlockingTimeoutMillis(new Integer(data.blockingTimeout));
                }
                if (data.idleTimeout != null && !data.idleTimeout.equals("")) {
                    pool.setIdleTimeoutMinutes(new Integer(data.idleTimeout));
                }

                if (planOnly) {
                    ByteArrayOutputStream out = new ByteArrayOutputStream();
                    config.save(out);
                    out.close();
                    return new String(out.toByteArray(), "US-ASCII");
                } else {
                    File tempFile = File.createTempFile("console-deployment", ".xml");
                    tempFile.deleteOnExit();
                    log.debug("Writing database pool deployment plan to " + tempFile.getAbsolutePath());
                    BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(tempFile));
                    config.save(out);
                    out.flush();
                    out.close();
                    Target[] targets = mgr.getTargets();
                    if (null == targets) {
                        throw new IllegalStateException("No target to distribute to");
                    }
                    targets = new Target[] {targets[0]};
                   
                    ProgressObject po = mgr.distribute(targets, rarFile, tempFile);
                    waitForProgress(po);
                    if (po.getDeploymentStatus().isCompleted()) {
                        TargetModuleID[] ids = po.getResultTargetModuleIDs();
                        po = mgr.start(ids);
                        waitForProgress(po);
                        if (po.getDeploymentStatus().isCompleted()) {
                            ids = po.getResultTargetModuleIDs();
                            if (status != null) {
                                status.getCurrentPool().setName(data.getName());
                                status.getCurrentPool().setConfigurationName(ids[0].getModuleID());
                                status.getCurrentPool().setFinished(true);
                                response.setRenderParameter(MODE_KEY, IMPORT_STATUS_MODE);
                            }

                            log.info("Deployment completed successfully!");
                        }
                    } else if (po.getDeploymentStatus().isFailed()) {
                        data.deployError = "Unable to deploy: " + data.name;
                        response.setRenderParameter(MODE_KEY, EDIT_MODE);
                        log.info("Deployment Failed!");
                    }
                }
            } catch (Exception e) {
                log.error("Unable to save connection pool", e);
            } finally {
                if (mgr != null) mgr.release();
            }
        } else { // We're saving updates to an existing pool
            if (planOnly) {
                throw new UnsupportedOperationException("Can't update a plan for an existing deployment");
            }
            try {
                JCAManagedConnectionFactory factory = (JCAManagedConnectionFactory) PortletManager.getManagedBean(
                        request, new AbstractName(URI.create(data.getAbstractName())));
                if (data.isGeneric()) {
                    factory.setConfigProperty("ConnectionURL", data.getUrl());
                    factory.setConfigProperty("UserName", data.getUser());
                    factory.setConfigProperty("Password", data.getPassword());
                } else {
                    for (Map.Entry<String, String> entry : data.getProperties().entrySet()) {
                        factory.setConfigProperty(entry.getKey().substring("property-".length()),
                                entry.getValue());
                    }
                }
                //todo: push the lookup into ManagementHelper
                PoolingAttributes pool = (PoolingAttributes) factory.getConnectionManagerContainer();
                pool.setPartitionMinSize(
                        data.minSize == null || data.minSize.equals("") ? 0 : Integer.parseInt(data.minSize));
                pool.setPartitionMaxSize(
                        data.maxSize == null || data.maxSize.equals("") ? 10 : Integer.parseInt(data.maxSize));
                pool.setBlockingTimeoutMilliseconds(
                        data.blockingTimeout == null || data.blockingTimeout.equals("") ? 5000 : Integer.parseInt(
                                data.blockingTimeout));
                pool.setIdleTimeoutMinutes(
                        data.idleTimeout == null || data.idleTimeout.equals("") ? 15 : Integer.parseInt(
                                data.idleTimeout));
            } catch (Exception e) {
                log.error("Unable to save connection pool", e);
            }
View Full Code Here

                    manager.setTransactionNone(true);
                } else {
                    manager.setTransactionLocal(true);
                }

                SinglePool pool = new SinglePool();
                manager.setPoolSingle(pool);
                pool.setMatchOne(true);
                // Max Size needs to be set before the minimum.  This is because
                // the connection manager will constrain the minimum based on the
                // current maximum value in the pool.  We might consider adding a 
                // setPoolConstraints method to allow specifying both at the same time.
                if (data.maxSize != null && !data.maxSize.equals("")) {
                    pool.setMaxSize(new Integer(data.maxSize));
                }
                if (data.minSize != null && !data.minSize.equals("")) {
                    pool.setMinSize(new Integer(data.minSize));
                }
                if (data.blockingTimeout != null && !data.blockingTimeout.equals("")) {
                    pool.setBlockingTimeoutMillis(new Integer(data.blockingTimeout));
                }
                if (data.idleTimeout != null && !data.idleTimeout.equals("")) {
                    pool.setIdleTimeoutMinutes(new Integer(data.idleTimeout));
                }

                if (planOnly) {
                    ByteArrayOutputStream out = new ByteArrayOutputStream();
                    config.save(out);
                    out.close();
                    return new String(out.toByteArray(), "US-ASCII");
                } else {
                    File tempFile = File.createTempFile("console-deployment", ".xml");
                    tempFile.deleteOnExit();
                    log.debug("Writing database pool deployment plan to " + tempFile.getAbsolutePath());
                    BufferedOutputStream out = new BufferedOutputStream(new FileOutputStream(tempFile));
                    config.save(out);
                    out.flush();
                    out.close();
                    Target[] targets = mgr.getTargets();
                    if (null == targets) {
                        throw new IllegalStateException("No target to distribute to");
                    }
                    targets = new Target[] {targets[0]};
                   
                    ProgressObject po = mgr.distribute(targets, rarFile, tempFile);
                    waitForProgress(po);
                    if (po.getDeploymentStatus().isCompleted()) {
                        TargetModuleID[] ids = po.getResultTargetModuleIDs();
                        po = mgr.start(ids);
                        waitForProgress(po);
                        if (po.getDeploymentStatus().isCompleted()) {
                            ids = po.getResultTargetModuleIDs();
                            if (status != null) {
                                status.getCurrentPool().setName(data.getName());
                                status.getCurrentPool().setConfigurationName(ids[0].getModuleID());
                                status.getCurrentPool().setFinished(true);
                                response.setRenderParameter(MODE_KEY, IMPORT_STATUS_MODE);
                            }

                            log.info("Deployment completed successfully!");
                        }
                    } else if (po.getDeploymentStatus().isFailed()) {
                        data.deployError = "Unable to deploy: " + data.name;
                        response.setRenderParameter(MODE_KEY, EDIT_MODE);
                        log.info("Deployment Failed!");
                    }
                }
            } catch (Exception e) {
                log.error("Unable to save connection pool", e);
            } finally {
                if (mgr != null) mgr.release();
            }
        } else { // We're saving updates to an existing pool
            if (planOnly) {
                throw new UnsupportedOperationException("Can't update a plan for an existing deployment");
            }
            try {
                JCAManagedConnectionFactory factory = (JCAManagedConnectionFactory) PortletManager.getManagedBean(
                        request, new AbstractName(URI.create(data.getAbstractName())));
                if (data.isGeneric()) {
                    factory.setConfigProperty("ConnectionURL", data.getUrl());
                    factory.setConfigProperty("UserName", data.getUser());
                    factory.setConfigProperty("Password", data.getPassword());
                } else {
                    for (Map.Entry<String, String> entry : data.getProperties().entrySet()) {
                        factory.setConfigProperty(entry.getKey().substring("property-".length()),
                                entry.getValue());
                    }
                }
                //todo: push the lookup into ManagementHelper
                PoolingAttributes pool = (PoolingAttributes) factory.getConnectionManagerContainer();
                pool.setPartitionMinSize(
                        data.minSize == null || data.minSize.equals("") ? 0 : Integer.parseInt(data.minSize));
                pool.setPartitionMaxSize(
                        data.maxSize == null || data.maxSize.equals("") ? 10 : Integer.parseInt(data.maxSize));
                pool.setBlockingTimeoutMilliseconds(
                        data.blockingTimeout == null || data.blockingTimeout.equals("") ? 5000 : Integer.parseInt(
                                data.blockingTimeout));
                pool.setIdleTimeoutMinutes(
                        data.idleTimeout == null || data.idleTimeout.equals("") ? 15 : Integer.parseInt(
                                data.idleTimeout));
            } catch (Exception e) {
                log.error("Unable to save connection pool", e);
            }
View Full Code Here

                        def.setConnectionInstance(new ConnectionDefinitionInstance[]{instance});
                        if(providerData.getConnectionFactoryInterface().equals("javax.jms.ConnectionFactory")) {
                            instance.setImplementedInterface(new String[]{"javax.jms.QueueConnectionFactory","javax.jms.TopicConnectionFactory"});
                        }
                        instance.setName(factoryData.getInstanceName());
                        SinglePool pool = new SinglePool();
                        instance.getConnectionManager().setPoolSingle(pool);
                        pool.setMatchOne(true);
                        pool.setMaxSize(factoryData.getPoolMaxSize());
                        pool.setMinSize(factoryData.getPoolMinSize());
                        pool.setBlockingTimeoutMillis(factoryData.getPoolBlockingTimeout());
                        pool.setIdleTimeoutMinutes(factoryData.getPoolIdleTimeout());
                        if(factoryData.getTransaction().equals("none")) {
                            instance.getConnectionManager().setTransactionNone(true);
                        } else if(factoryData.getTransaction().equals("local")) {
                            instance.getConnectionManager().setTransactionLocal(true);
                        } else if(factoryData.getTransaction().equals("xa")) {
View Full Code Here

TOP

Related Classes of org.apache.geronimo.connector.deployment.jsr88.Connector15DCBTest

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.