Package org.apache.felix.ipojo

Examples of org.apache.felix.ipojo.ConfigurationException


     */
    if (relation.getTargetKind() != null) {
      try {
        searchMethod();
      } catch (NoSuchMethodException e) {
        throw new ConfigurationException("invalid method declaration in callback "+getMethod()+ " for relation "+relation.getIdentifier());
      }
    }

  }
View Full Code Here


                    if (interceptor == null)
                        continue;

                } catch (ClassNotFoundException error) {
            throw new ConfigurationException("error injecting relation "
                + injection.getName() + " :"
                            + error.getLocalizedMessage());
                }

                if (injection instanceof InjectedField) {
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 property callback "+getMethod());
    }
  }
View Full Code Here

            this.consumerId     = NAME+"["+instance.getInstanceName()+","+relation.getIdentifier()+","+injection.getName()+"]";
            this.wires          = new HashMap<String,Wire>();
            this.buffer         = new ArrayBlockingQueue<Object>(MAX_BUFFER_SIZE);
            this.fieldBuffer  = new ApAMQueue<Object>(buffer);
        } catch (ClassNotFoundException e) {
            throw new ConfigurationException(e.getLocalizedMessage());
        }
      
        instance.addInjection(this);
    }
View Full Code Here

      Set<Class<?>> providedFlavors       =  new HashSet<Class<?>>();
      for (MessageReference providedMessage : providedMessages) {
      try {
        providedFlavors.add(getFactory().loadClass(providedMessage.getJavaType()));
      } catch (ClassNotFoundException e) {
        throw new ConfigurationException(e.getLocalizedMessage());
      }
    }
     
      isRegisteredProducer  = !providedFlavors.isEmpty();
      messageFlavors      = providedFlavors.toArray(new Class[providedFlavors.size()]);
     

      producerId         = NAME+"["+getInstanceManager().getInstanceName()+"]";
      sessionId        = Long.toString(System.currentTimeMillis());

      wires.clear();

      ApamAtomicComponentFactory implementation  = (ApamAtomicComponentFactory) getFactory();
      ImplementationDeclaration declaration    = implementation.getDeclaration();
     
      if (! (declaration instanceof AtomicImplementationDeclaration))
        return;
     
      /*
       * Register instrumentation for message push at the provider side
       */
      PojoMetadata manipulation           = getFactory().getPojoMetadata();
      AtomicImplementationDeclaration primitive  = (AtomicImplementationDeclaration) declaration;
      for (ProviderInstrumentation providerInstrumentation : primitive.getProviderInstrumentation()) {
       
          MessageReference messageReference = providerInstrumentation.getProvidedResource().as(MessageReference.class);
        if (messageReference == null)
          continue;

        if (! (providerInstrumentation instanceof ProviderInstrumentation.MessageProviderMethodInterception))
          continue;

        ProviderInstrumentation.MessageProviderMethodInterception interception =
            (ProviderInstrumentation.MessageProviderMethodInterception) providerInstrumentation;
         
      /*
       * Search for the specified method to intercept, we always look for a perfect match of the
       * specified signature, and do not allow ambiguous method names
       */
     
      MethodMetadata candidate = null;
      for (MethodMetadata method :  manipulation.getMethods(interception.getMethodName())) {
       
        if (interception.getMethodSignature() == null) {
          candidate = method;
          break;
        }
       
        String signature[]  = Util.split(interception.getMethodSignature());
        String arguments[]  = method.getMethodArguments();
        boolean match     = (signature.length == arguments.length);

        for (int i = 0; match && i < signature.length; i++) {
          if (!signature[i].equals(arguments[i]))
            match = false;
        }
       
        match = match && method.getMethodReturn().equals(messageReference.getJavaType());
        if (match) {
          candidate = method;
          break;
        }
      }
       
      if (candidate != null) {
        getInstanceManager().register(candidate,this);
        continue;
      }
     
      throw new ConfigurationException("Message producer intercepted methdod not found "+interception.getMethodName()+
                  "("+interception.getMethodSignature() != null ? interception.getMethodSignature(): ""+")");
      }
     
    }
View Full Code Here

            Filter filter = null;
            if (fil != null) {
                try {
                    filter = getInstanceManager().getContext().createFilter(fil);
                } catch (InvalidSyntaxException e) {
                    throw new ConfigurationException("A requirement filter is invalid : " + filter, e);
                }
            }

            String prox = deps[i].getAttribute("proxy");
            // Use proxy by default except for array:
View Full Code Here

            throws ConfigurationException {
        if (requiresFiltersValue != null
                && requiresFiltersValue.getClass().isArray()) {
            String[] filtersArray = (String[]) requiresFiltersValue;
            if (filtersArray.length % 2 != 0) {
                throw new ConfigurationException(
                        "A requirement filter is invalid : "
                                + requiresFiltersValue);
            }
            Dictionary requiresFilters = new Hashtable();
            for (int i = 0; i < filtersArray.length; i += 2) {
View Full Code Here

        switch (elem.length) {
            case 0:
                // No matching element in metadata, throw a configuration error.
                // It actually happen only if you force the handler to be plugged.
                throw new ConfigurationException("No properties found");
            case 1:
                // One 'properties' found, get attributes.
                m_file = elem[0].getAttribute("file");
                if (m_file == null) {
                    // if file is null, throw a configuration error.
                    throw new ConfigurationException("Malformed properties element : file attribute must be set");
                }
                break;
            default:
                // To simplify we handle only one properties element.
                throw new ConfigurationException("Only one properties element is supported");
        }

        // Look if the instance overrides file location :
        String instanceFile = (String) configuration.get("properties.file");
        if (instanceFile != null) {
            m_file = instanceFile;
        }

        // Load properties
        try {
            loadProperties();
        } catch (IOException e) {
            throw new ConfigurationException("Error when reading the " + m_file + " file : " + e.getMessage());
        }

        // Register fields
        // By convention, properties file entry are field name, so look for each property to get field list.

        //First get Pojo Metadata metadata :
        PojoMetadata pojoMeta = getPojoMetadata();
        Enumeration e = m_properties.keys();
        while (e.hasMoreElements()) {
            String field = (String) e.nextElement();
            FieldMetadata fm = pojoMeta.getField(field);

            if (fm == null) { // The field does not exist
                throw new ConfigurationException("The field " + field + " is declared in the properties file but does not exist in the pojo");
            }

            // Then check that the field is a String field
            if (!fm.getFieldType().equals(String.class.getName())) {
                throw new ConfigurationException("The field " + field + " exists in the pojo, but is not a String");
            }

            // All checks are ok, register the interceptor.
            getInstanceManager().register(fm, this);
        }
View Full Code Here

                    m_trackers.add(tracker);
                } else if (srcs[0].equalsIgnoreCase("global")) {
                    SourceTracker tracker = new SourceTracker(srcs[1], global);
                    m_trackers.add(tracker);
                } else {
                    throw new ConfigurationException("Unknowns context scope : " + srcs[0]);
                }
            } else {
                throw new ConfigurationException("Malformed context source : " + sources[i]);
            }
        }
    }
View Full Code Here

            String fil = "(&(" + Constants.OBJECTCLASS + "=" + ContextSource.class.getName() + ")(" + SOURCE_NAME + "=" + name + "))";
            try {
                Filter filter = countext.createFilter(fil);
                m_tracker = new Tracker(countext, filter, this);
            } catch (InvalidSyntaxException e) {
                throw new ConfigurationException("A Context source filter is invalid " + fil, e);
            }
        }
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.