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

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


      // need to invalidate the statement
      if (!isValid || (inUseCount != 0))
        return;

      ContextManager cm = ContextService.getFactory().getCurrentContextManager();
      LanguageConnectionContext lcc =
        (LanguageConnectionContext)
        (cm.getContext(LanguageConnectionContext.CONTEXT_ID));

      // invalidate any prepared statements that
      // depended on this statement (including this one)
      // prepareToInvalidate(this, DependencyManager.PREPARED_STATEMENT_INVALID);
      try
View Full Code Here


    if (fid == null)
      throw StandardException.newException(SQLState.LANG_FILE_DOES_NOT_EXIST, sqlName,schemaName);

    long generationId = fid.getGenerationId();

        ContextManager cm = ContextService.getFactory().getCurrentContextManager();
    FileResource fr = af.getTransaction(cm).getFileHandler();

    String externalName = JarUtil.mkExternalName(schemaName, sqlName, fr.getSeparatorChar());

    return fr.getAsFile(externalName, generationId);
View Full Code Here

    TableDescriptor        triggerTable,
    TransactionController       tc
  )
    throws StandardException
  {
    ContextManager cm = lcc.getContextManager();
    LanguageConnectionFactory  lcf = lcc.getLanguageConnectionFactory();

    DataDictionary dd = getDataDictionary();

View Full Code Here

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

        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

            // invalidate the ps or activation (the latter is used
            // if the current role changes).
            DependencyManager dm = dd.getDependencyManager();
            RoleGrantDescriptor rgd =
              dd.getRoleDefinitionDescriptor(role);
            ContextManager cm = lcc.getContextManager();

            dm.addDependency(ps, rgd, cm);
            dm.addDependency(activation, rgd, cm);
          }
        }
View Full Code Here

        // is revoked, role is dropped, another role has been set), we
        // are able to invalidate the ps or activation (the latter is
        // used if the current role changes).
        DependencyManager dm = dd.getDependencyManager();
        RoleGrantDescriptor rgd = dd.getRoleDefinitionDescriptor(role);
        ContextManager cm = lcc.getContextManager();
        dm.addDependency(ps, rgd, cm);
        dm.addDependency(activation, rgd, cm);
      }
    }
View Full Code Here

          //select t1.c1 from t1, t2
          if (privType == Authorizer.MIN_SELECT_PRIV && permittedColumns != null) {
            DependencyManager dm = dd.getDependencyManager();
            RoleGrantDescriptor rgd =
              dd.getRoleDefinitionDescriptor(role);
            ContextManager cm = lcc.getContextManager();

            dm.addDependency(ps, rgd, cm);
            dm.addDependency(activation, rgd, cm);
            return;
          }

          //Use the privileges obtained through the role to satisfy
          //the column level privileges we need. If all the remaining
          //column level privileges are satisfied through this role,
          //we will quit out of this while loop
          for(int i = unresolvedColumns.anySetBit();
            i >= 0;
            i = unresolvedColumns.anySetBit(i)) {

            if(permittedColumns != null && permittedColumns.get(i)) {
              unresolvedColumns.clear(i);
            }
          }
        }
      }
    }
    TableDescriptor td = getTableDescriptor(dd);
    //if we are still here, then that means that we didn't find any select
    //privilege on the table or any column in the table
    if (privType == Authorizer.MIN_SELECT_PRIV)
      throw StandardException.newException( forGrant ? SQLState.AUTH_NO_TABLE_PERMISSION_FOR_GRANT
            : SQLState.AUTH_NO_TABLE_PERMISSION,
            authorizationId,
            getPrivName(),
            td.getSchemaName(),
            td.getName());

    int remains = unresolvedColumns.anySetBit();

    if (remains >= 0) {
      // No permission on this column.
      ColumnDescriptor cd = td.getColumnDescriptor(remains + 1);

      if(cd == null) {
        throw StandardException.newException(
          SQLState.AUTH_INTERNAL_BAD_UUID, "column");
      } else {
        throw StandardException.newException(
          (forGrant
           ? SQLState.AUTH_NO_COLUMN_PERMISSION_FOR_GRANT
           : SQLState.AUTH_NO_COLUMN_PERMISSION),
          authorizationId,
          getPrivName(),
          cd.getColumnName(),
          td.getSchemaName(),
          td.getName());
      }
    } else {
      // We found and successfully applied a role to resolve the
      // (remaining) required permissions.
      //
      // Also add a dependency on the role (qua provider), so
      // that if role is no longer available to the current
      // user (e.g. grant is revoked, role is dropped,
      // another role has been set), we are able to
      // invalidate the ps or activation (the latter is used
      // if the current role changes).
      DependencyManager dm = dd.getDependencyManager();
      RoleGrantDescriptor rgd =
        dd.getRoleDefinitionDescriptor(role);
      ContextManager cm = lcc.getContextManager();

      dm.addDependency(ps, rgd, cm);
      dm.addDependency(activation, rgd, cm);
    }
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.