Package org.apache.felix.ipojo

Examples of org.apache.felix.ipojo.ConfigurationException


        } else if (propa.equalsIgnoreCase("requiresnew")) {
            return TransactionalMethod.REQUIRES_NEW;
        }

       throw new ConfigurationException("Unknown propgation policy : " + propa);
    }
View Full Code Here


        if (elems == null  || elems.length == 0) {
          // Alternative way
          Element[] whiteboards = elem.getElements("whiteboards", NAMESPACE);
          if (whiteboards == null) {
            throw new ConfigurationException("Cannot configure the whiteboard pattern handler - no suitable configuration found");
          } else {
            elems = whiteboards[0].getElements("wbp", NAMESPACE);
          }
        }

        // Last check.
        if (elems == null) {
          throw new ConfigurationException("Cannot configure the whiteboard pattern handler - no suitable configuration found");
        }

        for (int i = 0; i < elems.length; i++) {
            String filter = elems[i].getAttribute("filter");
            String onArrival = elems[i].getAttribute("onArrival");
            String onDeparture = elems[i].getAttribute("onDeparture");
            String onModification = elems[i].getAttribute("onModification");

            if (filter == null) {
                throw new ConfigurationException("The white board pattern element requires a filter attribute");
            }
            if (onArrival == null || onDeparture == null) {
                throw new ConfigurationException("The white board pattern element requires the onArrival and onDeparture attributes");
            }

            try {
                WhiteBoardManager wbm = new WhiteBoardManager(this, getInstanceManager().getContext().createFilter(filter), onArrival, onDeparture, onModification);
                m_managers.add(wbm);
            } catch (InvalidSyntaxException e) {
                throw new ConfigurationException("The filter " + filter + " is invalid : " + e);
            }
        }

    }
View Full Code Here

        // NAME_ATTRIBUTE
        if (publisher.containsAttribute(NAME_ATTRIBUTE)) {
            m_name = publisher.getAttribute(NAME_ATTRIBUTE);
        } else {
            throw new ConfigurationException(
                    "Missing required attribute in component configuration : "
                            + NAME_ATTRIBUTE);
        }

        // FIELD_ATTRIBUTE
        if (publisher.containsAttribute(FIELD_ATTRIBUTE)) {
            m_field = publisher.getAttribute(FIELD_ATTRIBUTE);
        } else {
            throw new ConfigurationException(
                    "Missing required attribute in component configuration : "
                            + FIELD_ATTRIBUTE);
        }

        // TOPICS_ATTRIBUTE
View Full Code Here

                EventUtil.TOPIC_SEPARATOR);
        // Check each topic is valid
        for (int i = 0; i < newTopics.length; i++) {
            String topic = newTopics[i];
            if (!EventUtil.isValidTopic(topic)) {
                throw new ConfigurationException("Invalid topic : \"" + topic
                        + "\".");
            }
        }
        m_topics = newTopics;
    }
View Full Code Here

     *
     * @throws ConfigurationException if a required attribute is missing
     */
    public void check() throws ConfigurationException {
        if (m_topics == null || m_topics.length == 0) {
            throw new ConfigurationException(
                    "Missing required attribute in component or instance configuration : "
                            + TOPICS_ATTRIBUTE);
        }
    }
View Full Code Here

                String field = publisherMetadata.getField();
                FieldMetadata fieldMetadata = getPojoMetadata()
                        .getField(publisherMetadata.getField(),
                                Publisher.class.getName());
                if (fieldMetadata == null) {
                    throw new ConfigurationException(
                            "Field not found in the component : "
                                    + Publisher.class.getName() + " " + field);
                }

                // Check name and field are unique
                if (nameSet.contains(name)) {
                    throw new ConfigurationException(
                            "A publisher with the same name already exists : "
                                    + name);
                } else if (fieldSet.contains(field)) {
                    throw new ConfigurationException("The field " + field
                            + " is already associated to a publisher");
                }
                nameSet.add(name);
                fieldSet.add(field);
            }
View Full Code Here

     * possible. This however has a cost in terms of early class loading. 
     */
    try {
      searchMethod();
    } catch (NoSuchMethodException e) {
      throw new ConfigurationException("invalid method declaration in callback "+getMethod());
    }
  }
View Full Code Here

      if (definition.getField() != null) {
        FieldMetadata field = getPojoMetadata().getField(
            definition.getField());
        if (field == null)
          throw new ConfigurationException("Invalid property definition "  + definition.getName()+ ": the specified field does not exist");

      }

      if (definition.getCallback() != null) {
        MethodMetadata method = getPojoMetadata().getMethod(definition.getCallback());
        if (method == null)
          throw new ConfigurationException("Invalid property definition "  + definition.getName() + ": the specified method does not exist");
      }
    }
  }
View Full Code Here

      this.declaration = parser.decode(m_componentMetadata,this);

    } catch (Exception e) {
      e.printStackTrace();
      this.declaration    = null;
      this.declarationError   = new ConfigurationException(e.getLocalizedMessage());
      return requiredHandlers;
    }

    /*
     * Calculate the minimal set of handlers based on the component declaration
View Full Code Here

    @SuppressWarnings({ "rawtypes" })
    public final ApamInstanceManager createInstance(Dictionary configuration, IPojoContext context, HandlerManager[] handlers)
            throws ConfigurationException {

        if (! isInstantiable())
            throw new ConfigurationException(
                    "Only APAM instantiable components can be directly instantiated by Ipojo, use instead the APAM API");

        /*
           * Create a native APAM instance and configure it.
           */
        ApamInstanceManager instance = createApamInstance(context,handlers);

        try {
            instance.configure(m_componentMetadata, configuration);
            instance.start();
            return instance;
        } catch (ConfigurationException e) {
            // An exception occurs while executing the configure or start
            // methods.
            if (instance != null) {
                instance.dispose();
                instance = null;
            }
            throw e;
        } catch (Exception e) { // All others exception are handled here.
            if (instance != null) {
                instance.dispose();
                instance = null;
            }
            m_logger.log(Logger.ERROR, e.getMessage(), e);
            throw new ConfigurationException(e.getMessage());
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.felix.ipojo.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.