Examples of ConnectionFactoryFactory


Examples of org.apache.ojb.broker.accesslayer.ConnectionFactoryFactory

    }

    private void checkFactory(Class factory) throws Exception
    {
        Class oldFac = null;
        ConnectionFactoryFactory fac = null;
        try
        {
            fac = ConnectionFactoryFactory.getInstance();
            oldFac = fac.getClassToServe();
            fac.setClassToServe(factory);
            ConnectionFactory conFac = (ConnectionFactory) fac.createNewInstance();

            MetadataManager mm = MetadataManager.getInstance();
            JdbcConnectionDescriptor jcd = (JdbcConnectionDescriptor) SerializationUtils.clone(
                    broker.serviceConnectionManager().getConnectionDescriptor());
            jcd.setJcdAlias(factory.getName() + "_test_checkFactory_a");
            jcd.setUseAutoCommit(2);
            // use this attribute to allow OJB changing initial state of connections
            jcd.addAttribute("initializationCheck", "true");

            mm.connectionRepository().addDescriptor(jcd);
            Connection con = conFac.lookupConnection(jcd);
            Connection con2 = conFac.lookupConnection(jcd);
            Connection con3 = conFac.lookupConnection(jcd);
            assertFalse("Expect autocommit state false", con.getAutoCommit());
            con.close();
            con2.close();
            con3.close();


            conFac = (ConnectionFactory) fac.createNewInstance();

            jcd = (JdbcConnectionDescriptor) SerializationUtils.clone(
                    broker.serviceConnectionManager().getConnectionDescriptor());
            jcd.setJcdAlias(factory.getName() + "_test_checkFactory_b");
            jcd.setUseAutoCommit(1);

            mm.connectionRepository().addDescriptor(jcd);
            con = conFac.lookupConnection(jcd);
            assertTrue("Expect autocommit state true", con.getAutoCommit());
        }
        finally
        {
            if (oldFac != null) fac.setClassToServe(oldFac);
        }
    }
View Full Code Here

Examples of org.apache.ojb.broker.accesslayer.ConnectionFactoryFactory

    }

    private void checkFactoryPoolExhausted(Class factory) throws Exception
    {
        Class oldFac = null;
        ConnectionFactoryFactory fac = null;
        try
        {
            fac = ConnectionFactoryFactory.getInstance();
            oldFac = fac.getClassToServe();
            fac.setClassToServe(factory);
            ConnectionFactory conFac = (ConnectionFactory) fac.createNewInstance();

            MetadataManager mm = MetadataManager.getInstance();
            JdbcConnectionDescriptor jcd = (JdbcConnectionDescriptor) SerializationUtils.clone(
                    broker.serviceConnectionManager().getConnectionDescriptor());
            jcd.setJcdAlias(factory.getName() + "_test_checkFactoryPoolExhausted_1");
            jcd.setUseAutoCommit(1);
            jcd.getConnectionPoolDescriptor().setMaxActive(2);
            jcd.getConnectionPoolDescriptor().setConnectionFactory(factory);
            mm.connectionRepository().addDescriptor(jcd);

            Connection con = null;
            Connection con2 = null;
            Connection con3 = null;
            try
            {
                con = conFac.lookupConnection(jcd);
                con2 = conFac.lookupConnection(jcd);
                try
                {
                    con3 = conFac.lookupConnection(jcd);
                    fail("We expect an exception indicating that the pool is exhausted");
                }
                catch (LookupException e)
                {
                    // we expected that
                    assertTrue(true);
                }
            }
            finally
            {
                try
                {
                    con.close();
                    con2.close();
                }
                catch (Exception e)
                {
                }
            }
        }
        finally
        {
            if (oldFac != null) fac.setClassToServe(oldFac);
        }
    }
View Full Code Here

Examples of org.hornetq.jms.bridge.ConnectionFactoryFactory

      JMSBridgeImpl bridge = null;

      Thread t = null;

      ConnectionFactoryFactory factInUse0 = cff0;
      ConnectionFactoryFactory factInUse1 = cff1;
      if (qosMode.equals(QualityOfServiceMode.ONCE_AND_ONLY_ONCE))
      {
         factInUse0 = cff0xa;
         factInUse1 = cff1xa;
      }
View Full Code Here

Examples of org.hornetq.jms.bridge.ConnectionFactoryFactory

      JMSBridgeImpl bridge = null;

      Thread t = null;

      ConnectionFactoryFactory factInUse0 = cff0;
      ConnectionFactoryFactory factInUse1 = cff1;
      if (qosMode.equals(QualityOfServiceMode.ONCE_AND_ONLY_ONCE))
      {
         factInUse0 = cff0xa;
         factInUse1 = cff1xa;
      }
View Full Code Here

Examples of org.hornetq.jms.bridge.ConnectionFactoryFactory

      JMSBridgeImpl bridge = null;

      Thread t = null;

      ConnectionFactoryFactory factInUse0 = cff0;
      if (qosMode.equals(QualityOfServiceMode.ONCE_AND_ONLY_ONCE))
      {
         factInUse0 = cff0xa;
      }
View Full Code Here

Examples of org.hornetq.jms.bridge.ConnectionFactoryFactory

   private void testNoMaxBatchTime(final QualityOfServiceMode qosMode, final boolean persistent) throws Exception
   {
      JMSBridgeImpl bridge = null;

      ConnectionFactoryFactory factInUse0 = cff0;
      ConnectionFactoryFactory factInUse1 = cff1;
      if (qosMode.equals(QualityOfServiceMode.ONCE_AND_ONLY_ONCE))
      {
         factInUse0 = cff0xa;
         factInUse1 = cff1xa;
      }
View Full Code Here

Examples of org.hornetq.jms.bridge.ConnectionFactoryFactory

   private void testNoMaxBatchTimeSameServer(final QualityOfServiceMode qosMode, final boolean persistent) throws Exception
   {
      JMSBridgeImpl bridge = null;

      ConnectionFactoryFactory factInUse0 = cff0;
      if (qosMode.equals(QualityOfServiceMode.ONCE_AND_ONLY_ONCE))
      {
         factInUse0 = cff0xa;
      }
View Full Code Here

Examples of org.hornetq.jms.bridge.ConnectionFactoryFactory

   private void testMaxBatchTime(final QualityOfServiceMode qosMode, final boolean persistent) throws Exception
   {
      JMSBridgeImpl bridge = null;

      ConnectionFactoryFactory factInUse0 = cff0;
      ConnectionFactoryFactory factInUse1 = cff1;
      if (qosMode.equals(QualityOfServiceMode.ONCE_AND_ONLY_ONCE))
      {
         factInUse0 = cff0xa;
         factInUse1 = cff1xa;
      }
View Full Code Here

Examples of org.hornetq.jms.bridge.ConnectionFactoryFactory

   private void testMaxBatchTimeSameServer(final QualityOfServiceMode qosMode, final boolean persistent) throws Exception
   {
      JMSBridgeImpl bridge = null;

      ConnectionFactoryFactory factInUse0 = cff0;
      if (qosMode.equals(QualityOfServiceMode.ONCE_AND_ONLY_ONCE))
      {
         factInUse0 = cff0xa;
      }
View Full Code Here

Examples of org.hornetq.jms.bridge.ConnectionFactoryFactory

    }

    private JMSBridge createJMSBridge(OperationContext context, ModelNode model) throws OperationFailedException {
        final Properties sourceContextProperties = resolveContextProperties(JMSBridgeDefinition.SOURCE_CONTEXT, context, model);
        final String sourceConnectionFactoryName = JMSBridgeDefinition.SOURCE_CONNECTION_FACTORY.resolveModelAttribute(context, model).asString();
        final ConnectionFactoryFactory sourceCff = new JNDIConnectionFactoryFactory(sourceContextProperties , sourceConnectionFactoryName);
        final String sourceDestinationName = JMSBridgeDefinition.SOURCE_DESTINATION.resolveModelAttribute(context, model).asString();
        final DestinationFactory sourceDestinationFactory = new JNDIDestinationFactory(sourceContextProperties, sourceDestinationName);

        final Properties targetContextProperties = resolveContextProperties(JMSBridgeDefinition.TARGET_CONTEXT, context, model);
        final String targetConnectionFactoryName = JMSBridgeDefinition.TARGET_CONNECTION_FACTORY.resolveModelAttribute(context, model).asString();
        final ConnectionFactoryFactory targetCff = new JNDIConnectionFactoryFactory(targetContextProperties, targetConnectionFactoryName);
        final String targetDestinationName = JMSBridgeDefinition.TARGET_DESTINATION.resolveModelAttribute(context, model).asString();
        final DestinationFactory targetDestinationFactory = new JNDIDestinationFactory(targetContextProperties, targetDestinationName);

        final String sourceUsername = resolveAttribute(JMSBridgeDefinition.SOURCE_USER, context, model);
        final String sourcePassword = resolveAttribute(JMSBridgeDefinition.SOURCE_PASSWORD, context, model);
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.