Package org.jboss.cache.config

Examples of org.jboss.cache.config.ConfigurationException


         {
            // try other setters that may fit later on.  Don't throw this exception though.
         }
         catch (Exception e)
         {
            throw new ConfigurationException("Unable to invoke setter " + setter + " on " + objectClass, e);
         }

         boolean setterFound = false;
         // if we get here, we could not find a String or Element setter.
         for (Method m : objectClass.getMethods())
         {
            if (setter.equals(m.getName()))
            {
               Class paramTypes[] = m.getParameterTypes();
               if (paramTypes.length != 1)
               {
                  if (log.isTraceEnabled())
                  {
                     log.trace("Rejecting setter " + m + " on class " + objectClass + " due to incorrect number of parameters");
                  }
                  continue; // try another param with the same name.                 
               }

               Class parameterType = paramTypes[0];
               PropertyEditor editor = PropertyEditorManager.findEditor(parameterType);
               if (editor == null)
               {
                  throw new ConfigurationException("Couldn't find a property editor for parameter type " + parameterType);
               }

               editor.setAsText((String) attribs.get(propName));

               Object parameter = editor.getValue();
               //if (log.isDebugEnabled()) log.debug("Invoking setter method: " + setter + " with parameter \"" + parameter + "\" of type " + parameter.getClass());

               try
               {
                  m.invoke(target, parameter);
                  setterFound = true;
                  break;
               }
               catch (Exception e)
               {
                  throw new ConfigurationException("Unable to invoke setter " + setter + " on " + objectClass, e);
               }
            }
         }
         if (!setterFound && failOnMissingSetter)
         {
            throw new ConfigurationException("Couldn't find a setter named [" + setter + "] which takes a single parameter, for parameter " + propName + " on class [" + objectClass + "]");
         }
      }
   }
View Full Code Here


         root.normalize();
         return root;
      }
      catch (Exception e)
      {
         throw new ConfigurationException("Could not parse the config file", e);
      }
   }
View Full Code Here

      }

      private void logAndThrowException(SAXParseException exception)
      {
         log.error("Configuration warning: " + exception.getMessage());
         throw new ConfigurationException("Incorrect configuration file. Use '-Djbosscache.config.validate=false' to disable validation.", exception);
      }
View Full Code Here

         if (cache == null)
         {
            if (config == null)
            {
               throw new ConfigurationException("Must call setConfiguration() or setCache() before call to create()");
            }

            constructCache();
         }
View Full Code Here

      {
         evictionConfig.setWakeupInterval(getInt(wakeUpInterval));
      }
      else
      {
         throw new ConfigurationException("Missing mandatory attribute wakeUpInterval");
      }

      List<EvictionRegionConfig> evictionRegionConfigs = new LinkedList<EvictionRegionConfig>();
      Element defaultRegion = getSingleElementInCoreNS("default", evictionElement);
View Full Code Here

         {
            algorithm = Util.getInstance(algorithmClass);
         }
         catch (Exception e)
         {
            throw new ConfigurationException("Unable to construct eviction algorithm class [" + algorithmClassName + "]", e);
         }

         try
         {
            algorithmConfig = Util.getInstance(algorithm.getConfigurationClass());
         }
         catch (Exception e)
         {
            throw new RuntimeException("Failed to instantiate eviction algorithm configuration class [" +
                  algorithm.getConfigurationClass() + "]", e);
         }
      }
      else
      {
         if (!isDefault)
         {
            if (defaultRegion == null || defaultRegion.getEvictionAlgorithmConfig() == null)
            {
               throw new MissingPolicyException("There is no Eviction Algorithm Class specified on the region or for the entire cache!");
            }
            else
            {
               try
               {
                  algorithmConfig = defaultRegion.getEvictionAlgorithmConfig().clone();
               }
               catch (CloneNotSupportedException e)
               {
                  throw new ConfigurationException("Unable to clone eviction algorithm configuration from default", e);
               }
            }
         }
      }
View Full Code Here

    * Builds the interceptor based on the interceptor class and also sets all its attributes.
    */
   private CommandInterceptor buildCommandInterceptor(Element element)
   {
      String interceptorClass = getAttributeValue(element, "class");
      if (!existsAttribute(interceptorClass)) throw new ConfigurationException("Interceptor class cannot be empty!");
      CommandInterceptor result;
      try
      {
         result = (CommandInterceptor) Util.loadClass(interceptorClass).newInstance();
      }
      catch (Exception e)
      {
         throw new ConfigurationException("CommandInterceptor class is not properly loaded in classloader", e);
      }
      Properties p = XmlConfigHelper.extractProperties(element);
      XmlConfigHelper.setValues(result, p, false, true);
      return result;
   }
View Full Code Here

   public void startBatch()
   {
      if (!configuration.isInvocationBatchingEnabled())
      {
         throw new ConfigurationException("Invocation batching not enabled in current configuration!  Please use the <invocationBatching /> element.");
      }
      batchContainer.startBatch();
   }
View Full Code Here

   public void endBatch(boolean successful)
   {
      if (!configuration.isInvocationBatchingEnabled())
      {
         throw new ConfigurationException("Invocation batching not enabled in current configuration!  Please use the <invocationBatching /> element.");
      }
      batchContainer.endBatch(successful);
   }
View Full Code Here

      if (list == null || list.getLength() == 0)
      {
         // try looking for a QUALIFIED_CONFIG_ROOT
         list = root.getElementsByTagName(QUALIFIED_CONFIG_ROOT);
         if (list == null || list.getLength() == 0)
            throw new ConfigurationException("Can't find " + CONFIG_ROOT + " or " + QUALIFIED_CONFIG_ROOT + " tag");
      }

      Map<String, Configuration> result = new HashMap<String, Configuration>();

      for (int i = 0; i < list.getLength(); i++)
      {
         Node node = list.item(i);
         if (node.getNodeType() != Node.ELEMENT_NODE)
         {
            continue;
         }

         Element element = (Element) node;
         String name = element.getAttribute(CONFIG_NAME);
         if (name == null || name.trim().length() == 0)
            throw new ConfigurationException("Element " + element + " has no name attribute");

         XmlConfigurationParser parser = new XmlConfigurationParser();
         Configuration c = parser.parseElementIgnoringRoot(element);

         // Prove that we can successfully clone it
View Full Code Here

TOP

Related Classes of org.jboss.cache.config.ConfigurationException

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.