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

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


    TableName  tableName,
    String    columnName
  )
    throws StandardException
  {
    ContextManager  cm = getContextManager();
    NodeFactory    nodeFactory = getNodeFactory();

    ResultColumn  rc = (ResultColumn) nodeFactory.getNode
      (
        C_NodeTypes.RESULT_COLUMN,
View Full Code Here


                    C_NodeTypes.TABLE_NAME,
                    null,
                    null,
                    getContextManager());

    ContextManager cm = getContextManager();

    int size = size();
    for (int index = 0; index < size; index++)
    {
      boolean     nullableResult;
View Full Code Here

    TableName  tableName,
    String    columnName
  )
    throws StandardException
  {
    ContextManager  cm = getContextManager();
    NodeFactory    nodeFactory = getNodeFactory();

    ResultColumn  rc = (ResultColumn) nodeFactory.getNode
      (
        C_NodeTypes.RESULT_COLUMN,
View Full Code Here

     **/
    public TransactionManager getInternalTransaction()
        throws StandardException
    {
        // Get the context manager.
        ContextManager cm = getContextManager();

        // Allocate a new transaction no matter what.
       
        // Create a transaction, make a context for it, and push the context.
        // Note this puts the raw store transaction context
View Full Code Here

     **/
    public TransactionController startNestedUserTransaction(boolean readOnly)
        throws StandardException
    {
        // Get the context manager.
        ContextManager cm = getContextManager();

        // Allocate a new transaction no matter what.
       
        // Create a transaction, make a context for it, and push the context.
        // Note this puts the raw store transaction context
View Full Code Here

   *
   * @exception StandardException thrown if something goes wrong
   */
  private void resetSavepoints() throws StandardException
  {
    final ContextManager cm = getContextManager();
    final List stmts = cm.getContextStack(org.apache.derby.
                        iapi.reference.
                        ContextId.LANG_STATEMENT);
    final int end = stmts.size();
    for (int i = 0; i < end; ++i) {
      ((StatementContext)stmts.get(i)).resetSavePoint();
View Full Code Here

    //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

  /**
    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

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.