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

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


    */
    if (recompIfInvalid &&
      (!valid ||
       (preparedStatement == null)))
    {
      ContextManager cm = ContextService.getFactory().getCurrentContextManager();

      /*
      ** Find the language connection context.  Get
      ** it each time in case a connection is dropped.
      */
      LanguageConnectionContext lcc = (LanguageConnectionContext)
          cm.getContext(LanguageConnectionContext.CONTEXT_ID);
     


      if (!((org.apache.derby.impl.sql.catalog.DataDictionaryImpl) (lcc.getDataDictionary())).readOnlyUpgrade) {

View Full Code Here


    /*
    ** The current connection is the one in the current
    ** connection context, so get the context.
    */
    ContextManager  cm = getCurrentContextManager();

    ConnectionContext localCC = null;

    /*
      cm is null the very first time, and whenever
      we aren't actually nested.
     */
    if (cm != null) {
      localCC = (ConnectionContext)
        (cm.getContext(ConnectionContext.CONTEXT_ID));
    }

    return localCC;
  }
View Full Code Here

            // error we get at this point is going to shut down the db.

            while (true)
            {
                // allocate new context and associate new xact with it.
                ContextManager cm      = contextFactory.newContextManager();
                contextFactory.setCurrentContextManager(cm);

        try {
                RawTransaction rawtran =
                    startTransaction(
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) {

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

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

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

  /**
    Get the locale from the ContextManager and then find the bundle
    based upon that locale.
  */
  public ResourceBundle getBundle(String messageId) {
    ContextManager cm;
    try {
      cm = ContextService.getFactory().getCurrentContextManager();
    } catch (ShutdownException se) {
      cm = null;
    }

    if (cm != null) {
      return MessageService.getBundleForLocale(cm.getMessageLocale(), messageId);
    }
    return null;
  }
View Full Code Here

            {
        throw StandardException.newException(
                        SQLState.FILE_EXISTS, file);
            }

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

            RawTransaction tran =
                factory.getRawStoreFactory().getXactFactory().findUserTransaction(
                        factory.getRawStoreFactory(),
View Full Code Here

  {
    if (factory.isReadOnly())
      throw StandardException.newException(SQLState.FILE_READ_ONLY);

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

        RawTransaction tran =
            factory.getRawStoreFactory().getXactFactory().findUserTransaction(
                        factory.getRawStoreFactory(),
                        cm,
View Full Code Here

  private  DataDictionary  getDataDictionary()
            throws StandardException
  {
    if ( dataDictionary == null )
      {
      ContextManager        cm  = ContextService.getFactory().getCurrentContextManager();
      DataDictionaryContext    ddc = (DataDictionaryContext)
                                    (cm.getContext(DataDictionaryContext.CONTEXT_ID));
      dataDictionary = ddc.getDataDictionary();
    }
    return  dataDictionary;
  }
View Full Code Here

        {
      throw T_Fail.testFailMsg(
                    getModuleToTestProtocolName() + " service not started.");
    }

    ContextManager cm1 = contextService.newContextManager();
    contextService.setCurrentContextManager(cm1);

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

    try {

      tc = store.getTransaction(cm1);

        pass = true;

            if (
                t_005(tc)   &&
                t_001(tc)   &&
                t_003(tc)   &&
                t_004(tc)   &&
                t_005(tc)   &&
                t_006(tc)   &&
                t_009(tc)   &&
                t_010(tc)   &&
                t_011(tc)   &&
                t_012(tc)   &&
                t_013(tc)   &&
                t_014(tc)   &&
        t_017(tc)   &&
        t_018(tc)   &&
        t_019(tc)   &&
        t_020(tc)  
                )
               
      {
        pass = true;

                if (SanityManager.DEBUG)
                {
                    pass = false;

                    // The following tests depend on SanityManager functionality
                    // so can not be run in an insane server.

                    if (t_002(tc) &&
                        t_007(tc) &&
                        t_008(tc) &&
                        t_015(tc) &&
                        t_016(tc)
                        )
                        pass = true;
                }
      }

      tc.commit();
      tc.destroy();
    }
    catch (StandardException e)
    {
      String  msg = e.getMessage();
      if (msg == null)
        msg = e.getClass().getName();
      REPORT(msg);

            e.printStackTrace(out.getPrintWriter());
            cm1.cleanupOnError(e);

            pass = false;
    }
        catch (Throwable t)
        {
      String  msg = t.getMessage();
      if (msg == null)
        msg = t.getClass().getName();
      REPORT(msg);

            t.printStackTrace(out.getPrintWriter());
            cm1.cleanupOnError(t);

            pass = false;
        }
    finally {
      contextService.resetCurrentContextManager(cm1);
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.