⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 commoninstanceprovider.java

📁 Pegasus is an open-source implementationof the DMTF CIM and WBEM standards. It is designed to be por
💻 JAVA
📖 第 1 页 / 共 4 页
字号:
         System.err.println (providerName + "::invokeMethod: oc         = " + oc);         System.err.println (providerName + "::invokeMethod: cop        = " + cop);         System.err.println (providerName + "::invokeMethod: methodName = " + methodName);         System.err.print (providerName + "::invokeMethod: inArgs     = ");         if (inArgs != null)         {            System.err.print ("{");            for (int i = 0; i < inArgs.size (); i++)            {               System.err.print (inArgs.elementAt (i));               if (i < inArgs.size () - 1)               {                  System.err.print (",");               }            }            System.err.println ("}");         }         else         {            System.err.println ("null");         }         System.err.print (providerName + "::invokeMethod: outArgs    = ");         if (outArgs != null)         {            System.err.print ("{");            for (int i = 0; i < outArgs.size (); i++)            {               System.err.print (outArgs.elementAt (i));               if (i < outArgs.size () - 1)               {                  System.err.print (",");               }            }            System.err.println ("}");         }         else         {            System.err.println ("null");         }      }      // Ensure that the namespace is valid      if (!cop.getNameSpace ().equalsIgnoreCase (namespace))      {         throw new CIMException (CIMException.CIM_ERR_INVALID_NAMESPACE);      }      // Ensure that the class exists in the specified namespace      if (!cop.getObjectName ().equalsIgnoreCase (propertyTypesClassname))      {         throw new CIMException (CIMException.CIM_ERR_INVALID_CLASS);      }      if (methodName.equalsIgnoreCase ("sayHello"))      {         return new CIMValue (new String ("hello"));      }      else if (methodName.equalsIgnoreCase ("enableModifications"))      {         if (inArgs == null)         {            throw new CIMException (CIMException.CIM_ERR_INVALID_PARAMETER);         }         else if (inArgs.size () != 1)         {            throw new CIMException (CIMException.CIM_ERR_INVALID_PARAMETER);         }         else         {            String      name  = null;            CIMValue    value = null;            CIMDataType type  = null;            Object      o0    = inArgs.elementAt (0);            if (DEBUG)            {               System.err.println (providerName + "::invokeMethod: o0 class   = " + o0.getClass ());            }            if (o0 instanceof CIMArgument)            {               CIMArgument ca = (CIMArgument)inArgs.elementAt (0);               name  = ca.getName ();               value = ca.getValue ();               type  = ca.getType ();            }            else if (o0 instanceof CIMProperty)            {               CIMProperty cp = (CIMProperty)inArgs.elementAt (0);               name  = cp.getName ();               value = cp.getValue ();               type  = cp.getType ();            }            if (!name.equalsIgnoreCase ("fState"))            {               throw new CIMException (CIMException.CIM_ERR_INVALID_PARAMETER);            }            else if (type.getType () != CIMDataType.BOOLEAN)            {               throw new CIMException (CIMException.CIM_ERR_INVALID_PARAMETER);            }            Boolean fNewState = (Boolean)value.getValue ();            if (DEBUG)            {               System.err.println (providerName + "::invokeMethod: Setting fEnableModifications to " + fNewState);            }            fEnableModifications = fNewState.booleanValue ();            return new CIMValue (new Boolean (true));         }      }      else if (methodName.equalsIgnoreCase ("resetProvider"))      {         if (  inArgs == null            || inArgs.size () == 0            )         {            if (DEBUG)            {               System.err.println (providerName + "::invokeMethod: resetting the provider's state!");            }            pathsTestElements      = new SortableVector (new CIMObjectPathComparer ());            instancesTestElements  = new SortableVector (new CIMInstanceComparer ());            pathsPropertyTypes     = new SortableVector (new CIMObjectPathComparer ());            instancesPropertyTypes = new SortableVector (new CIMInstanceComparer ());            fEnableModifications   = false;            initialize (handle);            return new CIMValue (new Boolean (true));         }         else         {            throw new CIMException (CIMException.CIM_ERR_INVALID_PARAMETER);         }      }      else      {         throw new CIMException (CIMException.CIM_ERR_METHOD_NOT_AVAILABLE);      }   }   private boolean validateTestElementPath (CIMObjectPath cop)   {      return false;   }   private boolean validatePropertyTypePath (CIMObjectPath cop)   {      Vector keys = cop.getKeys ();      if (keys.size () < PROPERTYTYPES_KEYS.length)      {         if (DEBUG)         {            System.err.println (providerName + "::validatePropertyTypePath: Bad1: " + keys.size () + " != " + PROPERTYTYPES_KEYS.length);         }         return false;      }      for (int i = 0, is = PROPERTYTYPES_KEYS.length; i < is; i++)      {         boolean fFound = false;         for (int j = 0, js = keys.size (); j < js; j++)         {            CIMProperty cp = (CIMProperty)keys.elementAt (j);            if (PROPERTYTYPES_KEYS[i].equalsIgnoreCase (cp.getName ()))            {               fFound = true;            }         }         if (!fFound)         {            if (DEBUG)            {               System.err.println (providerName + "::validatePropertyTypePath: Bad2: " + PROPERTYTYPES_KEYS[i] + " not in " + keys);            }            return false;         }      }      return true;   }   private CIMObjectPath validateTestElementInstance (CIMInstance cimInstance,                                                      boolean     fStrict)   {      if (cimInstance.getPropertyCount () != TESTELEMENT_PROPS.length)      {         if (DEBUG)         {            System.err.println (providerName + "::validateTestElementInstance: Bad1: " + cimInstance.getPropertyCount () + " != " + TESTELEMENT_PROPS.length);         }         if (fStrict)         {            return null;         }      }      for (int i = 0, is = TESTELEMENT_PROPS.length; i < is; i++)      {         CIMProperty cp = cimInstance.getProperty (TESTELEMENT_PROPS[i]);         if (cp == null)         {            if (DEBUG)            {               System.err.println (providerName + "::validateTestElementInstance: Bad2: " + TESTELEMENT_PROPS[i]);            }            if (fStrict)            {               return null;            }         }      }      CIMObjectPath ret = new CIMObjectPath (propertyTypesClassname,                                             namespace);      for (int i = 0, is = TESTELEMENT_KEYS.length; i < is; i++)      {         CIMProperty cp = cimInstance.getProperty (TESTELEMENT_KEYS[i]);         if (cp != null)         {            ret.addKey (TESTELEMENT_KEYS[i],                        cp.getValue ());         }         else         {            if (DEBUG)            {               System.err.println (providerName + "::validateTestElementInstance: Bad3: " + TESTELEMENT_KEYS[i]);            }            return null;         }      }      return ret;   }   private CIMObjectPath validatePropertyTypeInstance (CIMInstance cimInstance,                                                       boolean     fStrict)   {      if (cimInstance.getPropertyCount () != PROPERTYTYPES_PROPS.length)      {         if (DEBUG)         {            System.err.println (providerName + "::validatePropertyTypeInstance: Bad1: " + cimInstance.getPropertyCount () + " != " + PROPERTYTYPES_PROPS.length);         }         if (fStrict)         {            return null;         }      }      for (int i = 0, is = PROPERTYTYPES_PROPS.length; i < is; i++)      {         CIMProperty cp = cimInstance.getProperty (PROPERTYTYPES_PROPS[i]);         if (cp == null)         {            if (DEBUG)            {               System.err.println (providerName + "::validatePropertyTypeInstance: Bad2: " + PROPERTYTYPES_PROPS[i]);            }            if (fStrict)            {               return null;            }         }      }      CIMObjectPath ret = new CIMObjectPath (propertyTypesClassname,                                             namespace);      for (int i = 0, is = PROPERTYTYPES_KEYS.length; i < is; i++)      {         CIMProperty cp = cimInstance.getProperty (PROPERTYTYPES_KEYS[i]);         if (cp != null)         {            ret.addKey (PROPERTYTYPES_KEYS[i],                        cp.getValue ());         }         else         {            if (DEBUG)            {               System.err.println (providerName + "::validatePropertyTypeInstance: Bad3: " + PROPERTYTYPES_KEYS[i]);            }            return null;         }      }      return ret;   }   private int findCOPInTestElements (CIMObjectPath cop1)   {      String path1 = cop1.toString ();      for (int i = 0; i < pathsTestElements.size (); i++)      {         CIMObjectPath cop2  = (CIMObjectPath)pathsTestElements.elementAt (i);         String        path2 = cop2.toString ();         if (DEBUG)         {            System.err.println (providerName + "::findCOPInTestElements: \"" + path1 + "\" == \"" + path2 + "\"");         }         if (path2.equalsIgnoreCase (path1))         {            if (DEBUG)            {               System.err.println (providerName + "::findCOPInTestElements: found!");            }            return i;         }      }      return -1;   }   private int findCOPInPropertyTypes (CIMObjectPath cop1)   {      String path1 = cop1.toString ();      for (int i = 0; i < pathsPropertyTypes.size (); i++)      {         CIMObjectPath cop2  = (CIMObjectPath)pathsPropertyTypes.elementAt (i);         String        path2 = cop2.toString ();         if (DEBUG)         {            System.err.println (providerName + "::findCOPInPropertyTypes: \"" + path1 + "\" == \"" + path2 + "\"");         }         if (path2.equalsIgnoreCase (path1))         {            if (DEBUG)            {               System.err.println (providerName + "::findCOPInPropertyTypes: found!");            }            return i;         }      }      return -1;   }   private int findCOPInPropertyTypesNew (CIMObjectPath cop1)   {       HashMap hashPaths = new HashMap ();       if (DEBUG)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -