Package com.sun.appserv.connectors.internal.api

Examples of com.sun.appserv.connectors.internal.api.ConnectorRuntime


    private Connection getConnection(String jndiName) throws Exception {
        // TODO - pass Habitat or ConnectorRuntime as an argument.
        // TODO - remove duplication with DeploymentHelper

        ServiceLocator habitat = Globals.getDefaultHabitat();
        ConnectorRuntime connectorRuntime = habitat.getService(ConnectorRuntime.class);
        DataSource ds = PersistenceHelper.lookupNonTxResource(connectorRuntime, ctx, jndiName);
        return ds.getConnection();
    }
View Full Code Here


     * {@inheritDoc}
     */
    public void loadXAResourcesAndItsConnections(List xaresList, List connList) {

        //Done so as to initialize connectors-runtime before loading jdbc-resources. need a better way ?
        ConnectorRuntime crt = connectorRuntimeProvider.get();

        Collection<JdbcResource> jdbcResources = getAllJdbcResources();

        if (jdbcResources == null || jdbcResources.size() == 0) {
            if (_logger.isLoggable(Level.FINEST)) {
                _logger.finest("loadXAResourcesAndItsConnections : no resources" );
            }
            return;
        }

        List<JdbcConnectionPool> jdbcPools = new ArrayList<JdbcConnectionPool>();

        for (Resource resource : jdbcResources) {
            JdbcResource jdbcResource = (JdbcResource) resource;
            if(getResourcesUtil().isEnabled(jdbcResource)) {
                ResourceInfo resourceInfo = ConnectorsUtil.getResourceInfo(jdbcResource);
                JdbcConnectionPool pool = JdbcResourcesUtil.createInstance().getJdbcConnectionPoolOfResource(resourceInfo);
                if (pool != null && "javax.sql.XADataSource".equals(pool.getResType())) {
                    jdbcPools.add(pool);
                }
                if (_logger.isLoggable(Level.FINE)) {
                    _logger.fine("JdbcRecoveryResourceHandler:: loadXAResourcesAndItsConnections :: "
                            + "adding : " + (jdbcResource.getPoolName()));
                }
            }
        }

        loadAllJdbcResources();
        // Read from the transaction-service , if the replacement of
        // Vendor XAResource class with our version required.
        // If yes, put the mapping in the xaresourcewrappers properties.
        Properties XAResourceWrappers = new Properties();

        XAResourceWrappers.put(
                "oracle.jdbc.xa.client.OracleXADataSource",
                "com.sun.enterprise.transaction.jts.recovery.OracleXAResource");

        Config c = habitat.getService(Config.class, ServerEnvironment.DEFAULT_INSTANCE_NAME);
        txService =  c.getExtensionByType(TransactionService.class);

        List<Property> properties = txService.getProperty();

        if (properties != null) {
            for (Property property : properties) {
                String name = property.getName();
                String value = property.getValue();
                if (name.equals("oracle-xa-recovery-workaround")) {
                    if ("false".equals(value)) {
                        XAResourceWrappers.remove(
                                "oracle.jdbc.xa.client.OracleXADataSource");
                    }
                } else if (name.equals("sybase-xa-recovery-workaround")) {
                    if (value.equals("true")) {
                        XAResourceWrappers.put(
                                "com.sybase.jdbc2.jdbc.SybXADataSource",
                                "com.sun.enterprise.transaction.jts.recovery.SybaseXAResource");
                    }
                }
            }
        }

        for(JdbcConnectionPool jdbcConnectionPool : jdbcPools){
            if (jdbcConnectionPool.getResType() == null
                    || jdbcConnectionPool.getName() == null
                    || !jdbcConnectionPool.getResType().equals(
                    "javax.sql.XADataSource")) {
                if (_logger.isLoggable(Level.FINEST)) {
                    _logger.finest("skipping pool : " + jdbcConnectionPool.getName());
                }
                continue;
            }
            if (_logger.isLoggable(Level.FINEST)) {
                _logger.finest(" using pool : " + jdbcConnectionPool.getName());
            }

            PoolInfo poolInfo = ConnectorsUtil.getPoolInfo(jdbcConnectionPool);
            try {

                String[] dbUserPassword = getdbUserPasswordOfJdbcConnectionPool(jdbcConnectionPool);
                String dbUser = dbUserPassword[0];
                String dbPassword = dbUserPassword[1];
                if (dbPassword == null) {
                    dbPassword = "";
                    if (_logger.isLoggable(Level.FINEST)) {
                        _logger.log(Level.FINEST,
                                "datasource.xadatasource_nullpassword_error", poolInfo);
                    }
                }
                if (dbUser == null) {
                    dbUser = "";
                    if (_logger.isLoggable(Level.FINEST)) {
                        _logger.log(Level.FINEST,
                                "datasource.xadatasource_nulluser_error", poolInfo);
                    }
                }

                ManagedConnectionFactory fac =
                        crt.obtainManagedConnectionFactory(poolInfo);
                Subject subject = new Subject();
                PasswordCredential pc = new PasswordCredential(
                        dbUser, dbPassword.toCharArray());
                pc.setManagedConnectionFactory(fac);
                Principal prin = new ResourcePrincipal(dbUser, dbPassword);
                subject.getPrincipals().add(prin);
                subject.getPrivateCredentials().add(pc);
                ManagedConnection mc = fac.createManagedConnection(subject, null);
                connList.add(mc);
                try {
                    XAResource xares = mc.getXAResource();
                    if (xares != null) {

                        // See if a wrapper class for the vendor XADataSource is
                        // specified if yes, replace the XAResouce class of database
                        // vendor with our own version

                        String datasourceClassname =
                                jdbcConnectionPool.getDatasourceClassname();
                        String wrapperclass = (String) XAResourceWrappers.get(
                                datasourceClassname);
                        if (wrapperclass != null) {
                            //need to load wrapper class provided by "transactions" module.
                            //Using connector-class-loader so as to get access to "transaction" module.
                            XAResourceWrapper xaresWrapper = null;
                            xaresWrapper = (XAResourceWrapper) crt.getConnectorClassLoader().loadClass(wrapperclass).
                                    newInstance();
                            xaresWrapper.init(mc, subject);
                            if (_logger.isLoggable(Level.FINEST)) {
                                _logger.finest("adding resource " + poolInfo + " -- "+xaresWrapper);
                            }
View Full Code Here

    public boolean initializeService(){
         try {
             String module = ConnectorConstants.DEFAULT_JMS_ADAPTER;
             String loc = ConnectorsUtil.getSystemModuleLocation(module);
             ConnectorRuntime connectorRuntime = habitat.getComponent(ConnectorRuntime.class);
             connectorRuntime.createActiveResourceAdapter(loc, module, null);
             return true;
               } catch (ConnectorRuntimeException e) {
                   e.printStackTrace();
                   //_logger.log(Level.WARNING, "Failed to start JMS RA");
                   e.printStackTrace();
View Full Code Here

    public boolean initializeService(){
         try {
             String module = ConnectorConstants.DEFAULT_JMS_ADAPTER;
             String loc = ConnectorsUtil.getSystemModuleLocation(module);
             ConnectorRuntime connectorRuntime = connectorRuntimeProvider.get();
             connectorRuntime.createActiveResourceAdapter(loc, module, null);
             return true;
               } catch (ConnectorRuntimeException e) {
                   e.printStackTrace();
                   //_logger.log(Level.WARNING, "Failed to start JMS RA");
                   e.printStackTrace();
View Full Code Here

        bindConnectorDescriptors();
    }

    public void resourceManagerShutdown() {
        if (isConnectorRuntimeInitialized()) {
            ConnectorRuntime cr = getConnectorRuntime();
            if (cr != null) {
                // clean up will take care of any system RA resources, pools
                // (including pools via datasource-definition)
                cr.cleanUpResourcesAndShutdownAllActiveRAs();
            }
        } else {
            if(logger.isLoggable(Level.FINEST)) {
                logger.finest("ConnectorRuntime not initialized, hence skipping " +
                    "resource-adapters shutdown, resources, pools cleanup");
View Full Code Here

    ASyncClientShutdownTask task = new ASyncClientShutdownTask(appEJBName_,
        messageBeanClient_, loader, messageBeanPool_);
    long timeout = 0;
    try {
                    ConnectorRuntime cr = EjbContainerUtilImpl.getInstance().getDefaultHabitat()
                            .getByContract(ConnectorRuntime.class);
                    timeout = cr.getShutdownTimeout();
                } catch (Throwable th) {
                    _logger.log(Level.WARNING, "[MDBContainer] Got exception while trying " +
                 " to get shutdown timeout", th);
                }
    try {
View Full Code Here

    }
    public void initializeBroker () throws ConnectorRuntimeException
    {
            String module = ConnectorConstants.DEFAULT_JMS_ADAPTER;
            String loc = ConnectorsUtil.getSystemModuleLocation(module);
            ConnectorRuntime connectorRuntime = connectorRuntimeProvider.get();
            connectorRuntime.createActiveResourceAdapter(loc, module, null);
    }
View Full Code Here

    //methods from LazyServiceIntializer
    public boolean initializeService(){
         try {
             String module = ConnectorConstants.DEFAULT_JMS_ADAPTER;
             String loc = ConnectorsUtil.getSystemModuleLocation(module);
             ConnectorRuntime connectorRuntime = connectorRuntimeProvider.get();
             connectorRuntime.createActiveResourceAdapter(loc, module, null);
             return true;
               } catch (ConnectorRuntimeException e) {
                   e.printStackTrace();
                   //_logger.log(Level.WARNING, "Failed to start JMS RA");
                   e.printStackTrace();
View Full Code Here

        return failed;
    }

    private void lookupTimerResource() throws Exception {
        String resource_name = ejbContainerUtil.getTimerResource();
        ConnectorRuntime connectorRuntime = ejbContainerUtil.getDefaultHabitat().getByContract(ConnectorRuntime.class);
        timerDataSource = DataSource.class.cast(connectorRuntime.lookupNonTxResource(resource_name, false));
    }
View Full Code Here

            }
            return;
        }

        //TODO V3 done so as to initialize connectors-runtime before loading jdbc-resources. need a better way ?
        ConnectorRuntime crt = connectorRuntimeHabitat.getComponent(ConnectorRuntime.class);
       
        List<JdbcConnectionPool> jdbcPools = new ArrayList<JdbcConnectionPool>();

        for (Resource resource : jdbcResources) {
            JdbcResource jdbcResource = (JdbcResource) resource;
            if(getResourcesUtil().isEnabled(jdbcResource)) {
                ResourceInfo resourceInfo = ConnectorsUtil.getResourceInfo(jdbcResource);
                JdbcConnectionPool pool = ResourcesUtil.createInstance().getJdbcConnectionPoolOfResource(resourceInfo);
                if (pool != null && "javax.sql.XADataSource".equals(pool.getResType())) {
                    jdbcPools.add(pool);
                }
                if (_logger.isLoggable(Level.FINE)) {
                    _logger.fine("JdbcRecoveryResourceHandler:: loadXAResourcesAndItsConnections :: "
                            + "adding : " + (jdbcResource.getPoolName()));
                }
            }
        }

        loadAllJdbcResources();
        // Read from the transaction-service , if the replacement of
        // Vendor XAResource class with our version required.
        // If yes, put the mapping in the xaresourcewrappers properties.
        Properties XAResourceWrappers = new Properties();

        XAResourceWrappers.put(
                "oracle.jdbc.xa.client.OracleXADataSource",
                "com.sun.enterprise.transaction.jts.recovery.OracleXAResource");

        List<Property> properties = txService.getProperty();

        if (properties != null) {
            for (Property property : properties) {
                String name = property.getName();
                String value = property.getValue();
                if (name.equals("oracle-xa-recovery-workaround")) {
                    if ("false".equals(value)) {
                        XAResourceWrappers.remove(
                                "oracle.jdbc.xa.client.OracleXADataSource");
                    }
                } else if (name.equals("sybase-xa-recovery-workaround")) {
                    if (value.equals("true")) {
                        XAResourceWrappers.put(
                                "com.sybase.jdbc2.jdbc.SybXADataSource",
                                "com.sun.enterprise.transaction.jts.recovery.SybaseXAResource");
                    }
                }
            }
        }

        for(JdbcConnectionPool jdbcConnectionPool : jdbcPools){
            if (jdbcConnectionPool.getResType() == null
                    || jdbcConnectionPool.getName() == null
                    || !jdbcConnectionPool.getResType().equals(
                    "javax.sql.XADataSource")) {
                if (_logger.isLoggable(Level.FINEST)) {
                    _logger.finest("skipping pool : " + jdbcConnectionPool.getName());
                }
                continue;
            }
            if (_logger.isLoggable(Level.FINEST)) {
                _logger.finest(" using pool : " + jdbcConnectionPool.getName());
            }

            PoolInfo poolInfo = ConnectorsUtil.getPoolInfo(jdbcConnectionPool);
            try {

                String[] dbUserPassword = getdbUserPasswordOfJdbcConnectionPool(jdbcConnectionPool);
                String dbUser = dbUserPassword[0];
                String dbPassword = dbUserPassword[1];
                if (dbPassword == null) {
                    dbPassword = "";
                    if (_logger.isLoggable(Level.FINEST)) {
                        _logger.log(Level.FINEST,
                                "datasource.xadatasource_nullpassword_error", poolInfo);
                    }
                }
                if (dbUser == null) {
                    dbUser = "";
                    if (_logger.isLoggable(Level.FINEST)) {
                        _logger.log(Level.FINEST,
                                "datasource.xadatasource_nulluser_error", poolInfo);
                    }
                }

                ManagedConnectionFactory fac =
                        crt.obtainManagedConnectionFactory(poolInfo);
                Subject subject = new Subject();
                PasswordCredential pc = new PasswordCredential(
                        dbUser, dbPassword.toCharArray());
                pc.setManagedConnectionFactory(fac);
                Principal prin = new ResourcePrincipal(dbUser, dbPassword);
                subject.getPrincipals().add(prin);
                subject.getPrivateCredentials().add(pc);
                ManagedConnection mc = fac.createManagedConnection(subject, null);
                connList.add(mc);
                try {
                    XAResource xares = mc.getXAResource();
                    if (xares != null) {

                        // See if a wrapper class for the vendor XADataSource is
                        // specified if yes, replace the XAResouce class of database
                        // vendor with our own version

                        String datasourceClassname =
                                jdbcConnectionPool.getDatasourceClassname();
                        String wrapperclass = (String) XAResourceWrappers.get(
                                datasourceClassname);
                        if (wrapperclass != null) {
                            //need to load wrapper class provided by "transactions" module.
                            //Using connector-class-loader so as to get access to "transaction" module.
                            XAResourceWrapper xaresWrapper = null;
                            xaresWrapper = (XAResourceWrapper) crt.getConnectorClassLoader().loadClass(wrapperclass).
                                    newInstance();
                            xaresWrapper.init(mc, subject);
                            if (_logger.isLoggable(Level.FINEST)) {
                                _logger.finest("adding resource " + poolInfo + " -- "+xaresWrapper);
                            }
View Full Code Here

TOP

Related Classes of com.sun.appserv.connectors.internal.api.ConnectorRuntime

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.