Package org.apache.derby.iapi.services.context

Examples of org.apache.derby.iapi.services.context.ContextManager


    //REMIND: someone is leaving an incorrect manager on when they
    // are exiting the system in the nested case.
    if (SanityManager.DEBUG)
    {
      if (tr.getCsf() != null) {
        ContextManager cm1 = tr.getCsf().getCurrentContextManager();
        ContextManager cm2 = tr.getContextManager();
        // If the system has been shut down, cm1 can be null.
        // Otherwise, cm1 and cm2 should be identical.
        Util.ASSERT(this, (cm1 == cm2 || cm1 == null),
          "Current Context Manager not the one was expected: " +
           cm1 + " " + cm2);
View Full Code Here


        ts = (TopService) services.elementAt(position);
      }

      // push a new context manager
      ContextManager cm = contextService.newContextManager();
      try {
        // pop the default shutdown context, we are shutting down
        cm.popContext();

        contextService.setCurrentContextManager(cm);


        shutdown(ts.getService());
View Full Code Here

    ProtocolKey serviceKey = ProtocolKey.create(factoryInterface, serviceName);
    if (SanityManager.DEBUG && reportOn) {
      report("Booting service " + serviceKey + " create = " + create);
    }

    ContextManager previousCM = contextService.getCurrentContextManager();
    ContextManager cm = previousCM;
    Object instance;
    TopService ts = null;
    Context sb = null;


    try {


      synchronized (this) {

        if (inShutdown) {
          throw StandardException.newException(SQLState.CLOUDSCAPE_SYSTEM_SHUTDOWN);
        }

        for (int i = 1; i < services.size(); i++) {
          TopService ts2 = (TopService) services.elementAt(i);
          if (ts2.isPotentialService(serviceKey)) {
            // if the service already exists then  just return null
            return null;
          }
        }


        Locale serviceLocale = null;
        if (create) {

         
          // always wrap the property set in an outer set.
          // this ensures that any random attributes from
          // a JDBC URL are not written into the service.properties
          // file (e.g. like user and password :-)
          properties = new Properties(properties);

          serviceLocale = setLocale(properties);

          properties.put(Property.SERVICE_PROTOCOL, factoryInterface);

          serviceName = provider.createServiceRoot(serviceName,
              Boolean.valueOf(properties.getProperty(Property.DELETE_ON_CREATE)).booleanValue());

          serviceKey = ProtocolKey.create(factoryInterface, serviceName);
        } else if (properties != null) {
          String serverLocaleDescription = properties.getProperty(Property.SERVICE_LOCALE);
          if ( serverLocaleDescription != null)
            serviceLocale = staticGetLocaleFromString(serverLocaleDescription);
        }

        ts = new TopService(this, serviceKey, provider, serviceLocale);
        services.addElement(ts);
      }

      if (SanityManager.DEBUG) {
        if (provider != null)
        {
          SanityManager.ASSERT(provider.getCanonicalServiceName(serviceName).equals(serviceName),
            "mismatched canonical names " + provider.getCanonicalServiceName(serviceName)
            + " != " + serviceName);
          SanityManager.ASSERT(serviceName.equals(serviceKey.getIdentifier()),
            "mismatched names " + serviceName + " != " + serviceKey.getIdentifier());
        }
      }


      if (properties != null) {

        // these properties must not be stored in the persistent properties,
        // otherwise moving databases from one directory to another
        // will not work. Thus they all have a fixed prefix

        // the root of the data
        properties.put(PersistentService.ROOT, serviceName);

        // the type of the service
        properties.put(PersistentService.TYPE, provider.getType());
      }

      if (SanityManager.DEBUG && reportOn) {
        dumpProperties("Service Properties: " + serviceKey.toString(), properties);
      }

      // push a new context manager
      if (previousCM == null) {
        cm = contextService.newContextManager();

        contextService.setCurrentContextManager(cm);
      }
      sb = new ServiceBootContext(cm);

      UpdateServiceProperties usProperties;
      Properties serviceProperties;


      //while doing restore from backup, we don't want service properties to be
      //updated until all the files are copied from backup.
      boolean inRestore = (properties !=null ?
                 properties.getProperty(Property.IN_RESTORE_FROM_BACKUP) != null:false);
     
      if ((provider != null) && (properties != null)) {
        // we need to track to see if the properties have
        // been updated or not. If the database is not created yet, we don't create the
        // services.properties file yet. We let the following if (create) statement do
        //that at the end of the database creation. After that, the changes in
        // services.properties file will be tracked by UpdateServiceProperties.
        usProperties = new UpdateServiceProperties(provider,
                               serviceName,
                               properties,
                               !(create || inRestore));
        serviceProperties = usProperties;
      } else {
        usProperties = null;
        serviceProperties = properties;
      }

      instance = ts.bootModule(create, null, serviceKey, serviceProperties);

      if (create || inRestore) {
        // remove all the in-memory properties
        provider.saveServiceProperties(serviceName, usProperties.getStorageFactory(),
            BaseMonitor.removeRuntimeProperties(properties), false);
        usProperties.setServiceBooted();
      }
           
            if (cm != previousCM)
                cm.cleanupOnError(StandardException.closeException());
           
    } catch (Throwable t) {

      StandardException se;
      // ensure that the severity will shutdown the service
      if ((t instanceof StandardException) && (((StandardException) t).getSeverity() == ExceptionSeverity.DATABASE_SEVERITY))
        se = (StandardException) t;
      else
        se = Monitor.exceptionStartingModule(t);

      if (cm != previousCM) {
        cm.cleanupOnError(se);
      }

      if (ts != null) {
        ts.shutdown();
        synchronized (this) {
View Full Code Here

        XAXactId xid_im = new XAXactId(xid);
        XATransactionState tranState = getTransactionState(xid_im);
       
        if (tranState == null) {
            XAResourceManager rm = ra.getXAResourceManager();
            ContextManager inDoubtCM = rm.find(xid);
            // RM also does not know about this xid.
            if (inDoubtCM == null)
                throw new XAException(XAException.XAER_NOTA);
            ContextService csf = ContextService.getFactory();
            csf.setCurrentContextManager(inDoubtCM);
            try {
                rm.commit(inDoubtCM, xid_im, onePhase);
               
                // close the connection/transaction since it can never
                // be used again.
                inDoubtCM.cleanupOnError(StandardException.closeException());
                return;
            } catch (StandardException se) {
                // The rm threw an exception, clean it up in the approprate
                // context.  There is no transactionResource to handle the
                // exception for us.
                inDoubtCM.cleanupOnError(se);
                throw wrapInXAException(se);
            } finally {
                csf.resetCurrentContextManager(inDoubtCM);
            }
           
View Full Code Here

        XATransactionState tranState = getTransactionState(xid_im);
       
        if (tranState == null) {
            XAResourceManager rm = ra.getXAResourceManager();
           
            ContextManager inDoubtCM = rm.find(xid);
           
            // RM also does not know about this xid.
            if (inDoubtCM == null)
                throw new XAException(XAException.XAER_NOTA);
           
View Full Code Here

       
        XATransactionState tranState = getTransactionState(xid_im);
        if (tranState == null) {
            XAResourceManager rm = ra.getXAResourceManager();
           
            ContextManager inDoubtCM = rm.find(xid);
           
            // RM also does not know about this xid.
            if (inDoubtCM == null)
                throw new XAException(XAException.XAER_NOTA);
           
            ContextService csf = ContextService.getFactory();
           
            csf.setCurrentContextManager(inDoubtCM);
            try {
                rm.forget(inDoubtCM, xid_im);
               
                // close the connection/transaction since it can never be used again.
                inDoubtCM.cleanupOnError(StandardException.closeException());
                return;
            } catch (StandardException se) {
                // The rm threw an exception, clean it up in the approprate
                // context.  There is no transactionResource to handle the
                // exception for us.
                inDoubtCM.cleanupOnError(se);
                throw wrapInXAException(se);
            } finally {
                csf.resetCurrentContextManager(inDoubtCM);
            }
           
View Full Code Here

        XATransactionState tranState = getTransactionState(xid_im);
       
        if (tranState == null) {
            XAResourceManager rm = ra.getXAResourceManager();
           
            ContextManager inDoubtCM = rm.find(xid);
           
            // RM also does not know about this xid.
            if (inDoubtCM == null)
                throw new XAException(XAException.XAER_NOTA);
           
            ContextService csf = ContextService.getFactory();
           
            csf.setCurrentContextManager(inDoubtCM);
            try {
                rm.rollback(inDoubtCM, xid_im);
               
                // close the connection/transaction since it can never be used again.
                inDoubtCM.cleanupOnError(StandardException.closeException());
                return;
            } catch (StandardException se) {
                // The rm threw an exception, clean it up in the approprate
                // context.  There is no transactionResource to handle the
                // exception for us.
                inDoubtCM.cleanupOnError(se);
                throw wrapInXAException(se);
            } finally {
                csf.resetCurrentContextManager(inDoubtCM);
            }
           
View Full Code Here

    REPORT("(unitTestMain) Testing " + testService);

    try {

            ContextManager cm =
                    ContextService.getFactory().getCurrentContextManager();

      tc = store.getAndNameTransaction(
                    cm, AccessFactoryGlobals.USER_TRANS_NAME);
View Full Code Here

      // expect fail
    }


    // get another transaction going
    ContextManager cm2 = ContextService.getFactory().newContextManager();

    ContextService.getFactory().setCurrentContextManager(cm2);

    TransactionController tc2 = null;
    ConglomerateController cc2 = null;
View Full Code Here

    TableDescriptor        triggerTable,
    TransactionController       tc
  )
    throws StandardException
  {
    ContextManager cm = lcc.getContextManager();
    DependencyManager dm;
    ProviderInfo[] providerInfo;

    LanguageConnectionFactory  lcf = lcc.getLanguageConnectionFactory();
View Full Code Here

TOP

Related Classes of org.apache.derby.iapi.services.context.ContextManager

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.