Examples of GConstructorInfo


Examples of org.apache.geronimo.gbean.GConstructorInfo

        ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
        Thread.currentThread().setContextClassLoader(classLoader);
        Object instance = null;
        try {
            GConstructorInfo constructorInfo = gbeanInfo.getConstructor();
            Class[] parameterTypes = constructor.getParameterTypes();

            // create constructor parameter array
            Object[] parameters = new Object[parameterTypes.length];
            Iterator names = constructorInfo.getAttributeNames().iterator();
            for (int i = 0; i < parameters.length; i++) {
                String name = (String) names.next();
                if (referenceIndex.containsKey(name)) {
                    parameters[i] = getReferenceByName(name).getProxy();
                } else if (attributeIndex.containsKey(name)) {
View Full Code Here

Examples of org.apache.geronimo.gbean.GConstructorInfo

            setAttribute("kernel", kernel);
        } catch (Exception e) {
            setAttribute("kernel", null);
        }

        GConstructorInfo constructorInfo = gbeanInfo.getConstructor();
        Class[] parameterTypes = constructor.getParameterTypes();

        // create parameter array
        Object[] parameters = new Object[parameterTypes.length];
        Iterator names = constructorInfo.getAttributeNames().iterator();
        for (int i = 0; i < parameters.length; i++) {
            String name = (String) names.next();
            if (attributeIndex.containsKey(name)) {
                parameters[i] = getAttribute(name);
            } else if (referenceIndex.containsKey(name)) {
                GBeanMBeanReference reference = getReferenceByName(name);
                reference.online();
                parameters[i] = reference.getProxy();
            } else {
                throw new InvalidConfigurationException("Unknown attribute or reference name in constructor: name=" + name);
            }
            assert parameters[i] == null || parameterTypes[i].isPrimitive() || parameterTypes[i].isAssignableFrom(parameters[i].getClass()):
                    "Attempting to construct " + objectName + " of type " + gbeanInfo.getClassName()
                    + ". Constructor parameter " + i + " should be " + parameterTypes[i].getName()
                    + " but is " + parameters[i].getClass().getName();
        }

        // create instance
        try {
            target = constructor.newInstance(parameters);
        } catch (InvocationTargetException e) {
            Throwable targetException = e.getTargetException();
            if (targetException instanceof Exception) {
                throw (Exception) targetException;
            } else if (targetException instanceof Error) {
                throw (Error) targetException;
            }
            throw e;
        } catch (IllegalArgumentException e) {
            log.warn("Constructor mismatch for " + returnValue, e);
            throw e;
        }

        // bring all of the attributes online; this causes the persistent
        // values to be set into the instance if it is not a constructor arg
        for (int i = 0; i < attributes.length; i++) {
            attributes[i].online();
        }

        // bring any reference not used in the constructor online; this causes
        // the proxy to be set into the intstance
        for (int i = 0; i < references.length; i++) {
            GBeanMBeanReference reference = references[i];
            if (!constructorInfo.getAttributeNames().contains(reference.getName())) {
                reference.online();
            }
        }

        return returnValue;
View Full Code Here

Examples of org.apache.geronimo.gbean.GConstructorInfo

    public synchronized ObjectName preRegister(MBeanServer server, ObjectName objectName) throws Exception {
        ObjectName returnValue = super.preRegister(server, objectName);


        // get the constructor
        GConstructorInfo constructorInfo = gbeanInfo.getConstructor();
        Class[] parameterTypes = (Class[]) constructorInfo.getTypes().toArray(new Class[constructorInfo.getTypes().size()]);
        Constructor constructor = type.getConstructor(parameterTypes);

        // create the instance
        Object[] parameters = new Object[parameterTypes.length];
        Iterator names = constructorInfo.getAttributeNames().iterator();
        Iterator assertedTypes = constructorInfo.getTypes().iterator();
        for (int i = 0; i < parameters.length; i++) {
            String name = (String) names.next();
            if (attributeMap.containsKey(name)) {
                parameters[i] = getAttribute(name);
            } else if (referenceMap.containsKey(name)) {
                GBeanMBeanReference reference = (GBeanMBeanReference) referenceMap.get(name);
                reference.online();
                parameters[i] = reference.getProxy();
            } else {
                throw new InvalidConfigurationException("Unknown attribute or reference name in constructor: name=" + name);
            }
            Class assertedType = (Class) assertedTypes.next();
            assert parameters[i] == null || assertedType.isPrimitive() || assertedType.isAssignableFrom(parameters[i].getClass()):
                    "Attempting to construct " + objectName + " of type " + gbeanInfo.getClassName()
                    + ". Constructor parameter " + i + " should be " + assertedType.getName()
                    + " but is " + parameters[i].getClass().getName();
        }
        try {
            target = constructor.newInstance(parameters);
        } catch (InvocationTargetException e) {
            Throwable targetException = e.getTargetException();
            if(targetException instanceof Exception) {
                throw (Exception)targetException;
            } else if(targetException instanceof Error) {
                throw (Error)targetException;
            }
            throw e;
        } catch (IllegalArgumentException e) {
            log.warn("Constructor mismatch for "  + returnValue, e);
            throw e;
        }

        // bring all of the attributes online
        for (Iterator iterator = attributeMap.values().iterator(); iterator.hasNext();) {
            GBeanMBeanAttribute attribute = (GBeanMBeanAttribute) iterator.next();
            attribute.online();
        }

        // bring any reference not used in the constructor online
        // @todo this code sucks, but works
        for (Iterator iterator = referenceMap.values().iterator(); iterator.hasNext();) {
            GBeanMBeanReference reference = (GBeanMBeanReference) iterator.next();
            if (!constructorInfo.getAttributeNames().contains(reference.getName())) {
                reference.online();
            }
        }

        return returnValue;
View Full Code Here

Examples of org.apache.geronimo.gbean.GConstructorInfo

        ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
        Thread.currentThread().setContextClassLoader(classLoader);
        Object instance = null;
        try {
            GConstructorInfo constructorInfo = gbeanInfo.getConstructor();
            Class[] parameterTypes = constructor.getParameterTypes();

            // create constructor parameter array
            Object[] parameters = new Object[parameterTypes.length];
            Iterator names = constructorInfo.getAttributeNames().iterator();
            for (int i = 0; i < parameters.length; i++) {
                String name = (String) names.next();
                if (referenceIndex.containsKey(name)) {
                    parameters[i] = getReferenceByName(name).getProxy();
                } else if (attributeIndex.containsKey(name)) {
View Full Code Here

Examples of org.apache.geronimo.gbean.GConstructorInfo

            setAttribute("kernel", kernel);
        } catch (Exception e) {
            setAttribute("kernel", null);
        }

        GConstructorInfo constructorInfo = gbeanInfo.getConstructor();
        Class[] parameterTypes = constructor.getParameterTypes();

        // create parameter array
        Object[] parameters = new Object[parameterTypes.length];
        Iterator names = constructorInfo.getAttributeNames().iterator();
        for (int i = 0; i < parameters.length; i++) {
            String name = (String) names.next();
            if (attributeIndex.containsKey(name)) {
                parameters[i] = getAttribute(name);
            } else if (referenceIndex.containsKey(name)) {
                GBeanMBeanReference reference = getReferenceByName(name);
                reference.online();
                parameters[i] = reference.getProxy();
            } else {
                throw new InvalidConfigurationException("Unknown attribute or reference name in constructor: name=" + name);
            }
            assert parameters[i] == null || parameterTypes[i].isPrimitive() || parameterTypes[i].isAssignableFrom(parameters[i].getClass()):
                    "Attempting to construct " + objectName + " of type " + gbeanInfo.getClassName()
                    + ". Constructor parameter " + i + " should be " + parameterTypes[i].getName()
                    + " but is " + parameters[i].getClass().getName();
        }

        // create instance
        try {
            target = constructor.newInstance(parameters);
        } catch (InvocationTargetException e) {
            Throwable targetException = e.getTargetException();
            if (targetException instanceof Exception) {
                throw (Exception) targetException;
            } else if (targetException instanceof Error) {
                throw (Error) targetException;
            }
            throw e;
        } catch (IllegalArgumentException e) {
            log.warn("Constructor mismatch for " + returnValue, e);
            throw e;
        }

        // bring all of the attributes online; this causes the persistent
        // values to be set into the instance if it is not a constructor arg
        for (int i = 0; i < attributes.length; i++) {
            attributes[i].online();
        }

        // bring any reference not used in the constructor online; this causes
        // the proxy to be set into the intstance
        for (int i = 0; i < references.length; i++) {
            GBeanMBeanReference reference = references[i];
            if (!constructorInfo.getAttributeNames().contains(reference.getName())) {
                reference.online();
            }
        }

        return returnValue;
View Full Code Here

Examples of org.apache.geronimo.gbean.GConstructorInfo

        ClassLoader oldCL = Thread.currentThread().getContextClassLoader();
        Thread.currentThread().setContextClassLoader(classLoader);
        Object instance = null;
        try {
            GConstructorInfo constructorInfo = gbeanInfo.getConstructor();
            Class[] parameterTypes = constructor.getParameterTypes();

            // create constructor parameter array
            Object[] parameters = new Object[parameterTypes.length];
            Iterator names = constructorInfo.getAttributeNames().iterator();
            for (int i = 0; i < parameters.length; i++) {
                String name = (String) names.next();
                if (referenceIndex.containsKey(name)) {
                    parameters[i] = getReferenceByName(name).getProxy();
                } else if (attributeIndex.containsKey(name)) {
View Full Code Here

Examples of org.apache.geronimo.gbean.GConstructorInfo

            startTime = System.currentTimeMillis();
        }

        Object instance = null;
        try {
            GConstructorInfo constructorInfo = gbeanInfo.getConstructor();
            Class[] parameterTypes = constructor.getParameterTypes();

            // create constructor parameter array
            Object[] parameters = new Object[parameterTypes.length];
            Iterator names = constructorInfo.getAttributeNames().iterator();
            for (int i = 0; i < parameters.length; i++) {
                String name = (String) names.next();
                if (attributeIndex.containsKey(name)) {
                    GBeanAttribute attribute = getAttributeByName(name);
                    parameters[i] = attribute.getPersistentValue();
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.