Examples of PojoMetadata


Examples of org.apache.felix.ipojo.parser.PojoMetadata

     * @param metadata the component metadata
     * @param dict the instance configuration
     */
    public void configure(Element metadata, Dictionary dict) {

        PojoMetadata manipulation = getPojoMetadata();

        m_instanceManager = getInstanceManager();

        m_jmxConfigFieldMap = new JmxConfigFieldMap();

        // Build the hashmap
        Element[] mbeans = metadata.getElements(JMX_CONFIG_ELT, m_namespace);

        if (mbeans.length != 1) {
            error("A component must have at most one " + JMX_CONFIG_ELT + ".");
            error("The JMX handler configuration is ignored.");
            return;
        }

        // retrieve kind of MBeanServer to use
        m_usesMOSGi = Boolean.parseBoolean(mbeans[0]
            .getAttribute(JMX_USES_MOSGI_ELT));

        // retrieve object name
        m_completeObjNameElt = mbeans[0].getAttribute(JMX_OBJ_NAME_ELT);
        m_domainElt = mbeans[0].getAttribute(JMX_OBJ_NAME_DOMAIN_ELT);
        m_objNameWODomainElt = mbeans[0]
            .getAttribute(JMX_OBJ_NAME_WO_DOMAIN_ELT);

        // test if Pojo is interested in registration callbacks
        m_registerCallbacks = manipulation
            .isInterfaceImplemented(MBeanRegistration.class.getName());
        if (m_registerCallbacks) {
            // don't need to check that methods exist, the pojo implements
            // MBeanRegistration interface
            String[] preRegisterParams = { MBeanServer.class.getName(),
                    ObjectName.class.getName() };
            m_preRegisterMeth = manipulation.getMethod(PRE_REGISTER_METH_NAME,
                preRegisterParams);

            String[] postRegisterParams = { Boolean.class.getName() };
            m_postRegisterMeth = manipulation.getMethod(
                POST_REGISTER_METH_NAME, postRegisterParams);

            m_preDeregisterMeth = manipulation.getMethod(
                PRE_DEREGISTER_METH_NAME, new String[0]);

            m_postDeregisterMeth = manipulation.getMethod(
                POST_DEREGISTER_METH_NAME, new String[0]);
        }

        // set property
        Element[] attributes = mbeans[0].getElements(JMX_PROPERTY_ELT, m_namespace);

        if (attributes == null) {
            attributes = mbeans[0].getElements(JMX_PROPERTY_ELT);
            if (attributes != null) {
                warn("The JMX property element should use the '" + m_namespace + "' namespace.");
            }
        }

        // String[] fields = new String[attributes.length];
        if (attributes != null) {
            for (int i = 0; attributes != null && i < attributes.length; i++) {
                boolean notif = false;
                String rights;
                String name;
                String field = attributes[i].getAttribute(JMX_FIELD_ELT);

                if (attributes[i].containsAttribute(JMX_NAME_ELT)) {
                    name = attributes[i].getAttribute(JMX_NAME_ELT);
                } else {
                    name = field;
                }
                if (attributes[i].containsAttribute(JMX_RIGHTS_ELT)) {
                    rights = attributes[i].getAttribute(JMX_RIGHTS_ELT);
                } else {
                    rights = "r";
                }

                PropertyField property = new PropertyField(name, field, rights,
                    getTypeFromAttributeField(field, manipulation));

                if (attributes[i].containsAttribute(JMX_NOTIFICATION_ELT)) {
                    notif = Boolean.parseBoolean(attributes[i]
                        .getAttribute(JMX_NOTIFICATION_ELT));
                }

                property.setNotifiable(notif);

                if (notif) {
                    // add the new notifiable property in structure
                    NotificationField notification = new NotificationField(
                        name, this.getClass().getName() + "." + field, null);
                    m_jmxConfigFieldMap.addNotificationFromName(name,
                        notification);
                }
                m_jmxConfigFieldMap.addPropertyFromName(name, property);
                getInstanceManager().register(manipulation.getField(field),
                    this);
                info("property exposed:" + name + " " + field + ":"
                        + getTypeFromAttributeField(field, manipulation) + " "
                        + rights + ", Notif=" + notif);
            }
View Full Code Here

Examples of org.apache.felix.ipojo.parser.PojoMetadata

     * @throws ConfigurationException if the element describing the factory is malformed.
     */
    public void check(Element element) throws ConfigurationException {
        m_classname = element.getAttribute("classname");
        if (m_classname == null) { throw new ConfigurationException("A component needs a class name : " + element); }
        m_manipulation = new PojoMetadata(m_componentMetadata);
    }
View Full Code Here

Examples of org.apache.felix.ipojo.parser.PojoMetadata

     * @param dictionary the instance configuration.
     * @throws ConfigurationException if the dependency is not configured correctly
     * @see org.apache.felix.ipojo.Handler#configure(org.apache.felix.ipojo.metadata.Element, java.util.Dictionary)
     */
    public void configure(Element meta, Dictionary dictionary) throws ConfigurationException {
        PojoMetadata manipulation = getFactory().getPojoMetadata();
        Element[] deps = meta.getElements("requires", NAMESPACE);
        for (int i = 0; i < deps.length; i++) {
            if (!deps[i].containsAttribute("field") || m_dependencies.contains(deps[i].getAttribute("field"))) {
                error("One temporal dependency must be attached to a field or the field is already used");
                return;
            }
            String field = deps[i].getAttribute("field");

            FieldMetadata fieldmeta = manipulation.getField(field);
            if (fieldmeta == null) {
                error("The field " + field + " does not exist in the class " + getInstanceManager().getClassName());
                return;
            }            
                       
            String fil = deps[i].getAttribute("filter");
            Filter filter = null;
            if (fil != null) {
                try {
                    filter = getInstanceManager().getContext().createFilter(fil);
                } catch (InvalidSyntaxException e) {
                    error("Cannot create the field from " + fil + ": " + e.getMessage());
                    return;
                }
            }
           
            boolean agg = false;
            boolean collection = false;
            String spec = fieldmeta.getFieldType();
            if (spec.endsWith("[]")) {
                agg = true;
                spec = spec.substring(0, spec.length() - 2);
            } else if (Collection.class.getName().equals(spec)) {
                agg = true;
                collection = true;
                // Collection detected. Check for the specification attribute
                spec = deps[i].getAttribute("specification");
                if (spec == null) {
                    error("A dependency injected inside a Collection must contain the 'specification' attribute");
                }
            }
           
            String prox = deps[i].getAttribute("proxy");
            boolean proxy = prox != null && prox.equals("true");
            if (proxy && agg) {
                if (! collection) {
                    error("Proxied aggregate temporal dependencies cannot be an array. Only collections are supported");
                }
            }
           
            long timeout = DEFAULT_TIMEOUT;
            if (deps[i].containsAttribute("timeout")) {
                String to = deps[i].getAttribute("timeout");
                if (to.equalsIgnoreCase("infinite"|| to.equalsIgnoreCase("-1")) {
                    timeout = Long.MAX_VALUE; // Infinite wait time ...
                } else {
                    timeout = new Long(deps[i].getAttribute("timeout")).longValue();
                }
            }
           
            int policy = NO_POLICY;
            String di = null;
            String onTimeout = deps[i].getAttribute("onTimeout");
            if (onTimeout != null) {
                if (onTimeout.equalsIgnoreCase("nullable")) {
                    policy = NULLABLE;
                } else if (onTimeout.equalsIgnoreCase("empty-array"|| onTimeout.equalsIgnoreCase("empty")) {
                    policy = EMPTY;
                    if (! agg) {
                        // The empty array policy can only be used on aggregate dependencies
                        error("Cannot use the empty array policy for " + field + " : non aggregate dependency.");
                    }
                } else if (onTimeout.equalsIgnoreCase("null")) {
                    policy = NULL;
                } else if (onTimeout.length() > 0) {
                    di = onTimeout;
                    policy = DEFAULT_IMPLEMENTATION;
                }
            }
        
            Class specification = DependencyModel.loadSpecification(spec, getInstanceManager().getContext());
            TemporalDependency dep = new TemporalDependency(specification, agg, collection, proxy, filter, getInstanceManager().getContext(), timeout, policy, di, this);
            m_dependencies.add(dep);
           
            if (! proxy) { // Register method interceptor only if are not a proxy
                MethodMetadata[] methods = manipulation.getMethods();
                for (int k = 0; k < methods.length; k++) {
                    getInstanceManager().register(methods[k], dep);
                }
            }
           
View Full Code Here

Examples of org.apache.felix.ipojo.parser.PojoMetadata

                String name = subscriberMetadata.getName();
                info(LOG_PREFIX + "Checking subscriber " + name);

                // Determine the event callback prototype
                PojoMetadata pojoMetadata = getPojoMetadata();
                String callbackType;
                if (subscriberMetadata.getDataKey() == null) {
                    callbackType = Event.class.getName();
                } else {
                    callbackType = subscriberMetadata.getDataType().getName();
                }

                // Check the event callback method is present
                MethodMetadata methodMetadata = pojoMetadata.getMethod(
                        subscriberMetadata.getCallback(),
                        new String[] { callbackType });
                String callbackSignature = subscriberMetadata.getCallback()
                        + "(" + callbackType + ")";
                if (methodMetadata == null) {
View Full Code Here

Examples of org.apache.felix.ipojo.parser.PojoMetadata

                for (int j = 0; j < subscriberTopics.length; j++) {
                    topics.add(subscriberTopics[j]);
                }

                // Determine the event callback prototype
                PojoMetadata pojoMetadata = getPojoMetadata();
                String callbackType;
                if (subscriberMetadata.getDataKey() == null) {
                    callbackType = Event.class.getName();
                } else {
                    callbackType = subscriberMetadata.getDataType().getName();
                }

                // Create the specified callback and register it
                MethodMetadata methodMetadata = pojoMetadata.getMethod(
                        subscriberMetadata.getCallback(),
                        new String[] { callbackType });
                Callback callback = new Callback(methodMetadata, m_manager);
                m_callbacksByName.put(name, callback);
View Full Code Here

Examples of org.sql2o.reflection.PojoMetadata

        this.quirks = quirks;
    }

    @SuppressWarnings("unchecked")
    public <T> ResultSetHandlerFactory<T> newFactory(Class<T> clazz) {
        PojoMetadata pojoMetadata = new PojoMetadata(clazz, caseSensitive, autoDeriveColumnNames, columnMappings);
        return new DefaultResultSetHandlerFactory(pojoMetadata, quirks);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.