Examples of GBeanInfo


Examples of org.apache.geronimo.gbean.GBeanInfo

        try {
            AbstractName aname = new AbstractName(URI.create(abstractName));
            info.add(new String[] { "abstractName", aname.toString() });
            ObjectName oname = aname.getObjectName();
            info.add(new String[] { "objectName", oname.toString() });
            GBeanInfo beanInfo = kernel.getGBeanInfo(aname);
            String className = beanInfo.getClassName();
            info.add(new String[] { "className", className });
            String domain = oname.getDomain();
            info.add(new String[] { "domain", domain });
            String j2eeType = beanInfo.getJ2eeType();
            info.add(new String[] { "j2eeType", j2eeType });
            // String sourceClass = beanInfo.getSourceClass();
            // info.add(new String[] { "sourceClass", sourceClass });
        } catch (Exception e) {
            // GBean not found, just ignore
View Full Code Here

Examples of org.apache.geronimo.gbean.GBeanInfo

        return new Integer(kernel.listGBeans((AbstractNameQuery)null).size());
    }

    public MBeanInfo getMBeanInfo(ObjectName name) throws InstanceNotFoundException, ReflectionException {
        AbstractName abstractName = toAbstractName(name);
        GBeanInfo gbeanInfo;
        try {
            gbeanInfo = kernel.getGBeanInfo(abstractName);
        } catch (GBeanNotFoundException e) {
            throw (InstanceNotFoundException)new InstanceNotFoundException(name.getCanonicalName()).initCause(e);
        } catch (InternalKernelException e) {
View Full Code Here

Examples of org.apache.geronimo.gbean.GBeanInfo

    }

    public ObjectInstance getObjectInstance(ObjectName objectName) throws InstanceNotFoundException {
        AbstractName abstractName = toAbstractName(objectName);
        try {
            GBeanInfo gbeanInfo = kernel.getGBeanInfo(abstractName);
            return new ObjectInstance(objectName, gbeanInfo.getClassName());
        } catch (GBeanNotFoundException e) {
            throw (InstanceNotFoundException)new InstanceNotFoundException(objectName.getCanonicalName()).initCause(e);
        }
    }
View Full Code Here

Examples of org.apache.geronimo.gbean.GBeanInfo

        assertEquals("black/black", GBeanFormatBinding.format("{bar}/{bar}", map));
        assertEquals("java:white/test/black/test", GBeanFormatBinding.format("java:{foo}/test/{bar}/test", map));
    }

    public void testGBeanInfos() throws Exception {
        GBeanInfo info = ResourceBinding.getGBeanInfo();
        info = GBeanFormatBinding.getGBeanInfo();
    }
View Full Code Here

Examples of org.apache.geronimo.gbean.GBeanInfo

        this.kernel = kernel;
        this.lifecycleBroadcaster = lifecycleBroadcaster;
        this.gbeanInstanceState = new GBeanInstanceState(abstractName, kernel, dependencyManager, this, lifecycleBroadcaster);
        this.classLoader = classLoader;

        GBeanInfo gbeanInfo = gbeanData.getGBeanInfo();
        try {
            type = classLoader.loadClass(gbeanInfo.getClassName());
        } catch (ClassNotFoundException e) {
            throw new InvalidConfigurationException("Could not load GBeanInfo class from classloader: " + classLoader +
                    " className=" + gbeanInfo.getClassName(), e);
        }

        name = gbeanInfo.getName();

        //
        Set constructorArgs = new HashSet(gbeanInfo.getConstructor().getAttributeNames());

        // interfaces
        interfaces = (String[]) gbeanInfo.getInterfaces().toArray(new String[0]);

        // attributes
        Map attributesMap = new HashMap();
        for (Iterator iterator = gbeanInfo.getAttributes().iterator(); iterator.hasNext();) {
            GAttributeInfo attributeInfo = (GAttributeInfo) iterator.next();
            attributesMap.put(attributeInfo.getName(), new GBeanAttribute(this, attributeInfo, constructorArgs.contains(attributeInfo.getName())));
        }
        addManagedObjectAttributes(attributesMap);
        attributes = (GBeanAttribute[]) attributesMap.values().toArray(new GBeanAttribute[attributesMap.size()]);
        for (int i = 0; i < attributes.length; i++) {
            attributeIndex.put(attributes[i].getName(), new Integer(i));
        }

        // references
        Set referencesSet = new HashSet();
        Set dependencySet = new HashSet();
        // add the references
        Map dataReferences = gbeanData.getReferences();
        for (Iterator iterator = gbeanInfo.getReferences().iterator(); iterator.hasNext();) {
            GReferenceInfo referenceInfo = (GReferenceInfo) iterator.next();
            String referenceName = referenceInfo.getName();
            ReferencePatterns referencePatterns = (ReferencePatterns) dataReferences.remove(referenceName);
            if (referenceInfo.getProxyType().equals(Collection.class.getName())) {
                referencesSet.add(new GBeanCollectionReference(this, referenceInfo, kernel, referencePatterns));

            } else {
                referencesSet.add(new GBeanSingleReference(this, referenceInfo, kernel, referencePatterns));
                if (referencePatterns != null) {
                    dependencySet.add(new GBeanDependency(this, referencePatterns.getAbstractName(), kernel));
                }
            }
        }
        if (!dataReferences.isEmpty()) {
            throw new IllegalStateException("Attempting to set unknown references: " + dataReferences.keySet());
        }

        references = (GBeanReference[]) referencesSet.toArray(new GBeanReference[referencesSet.size()]);
        for (int i = 0; i < references.length; i++) {
            referenceIndex.put(references[i].getName(), new Integer(i));
        }

        //dependencies
        for (Iterator iterator = gbeanData.getDependencies().iterator(); iterator.hasNext();) {
            AbstractName dependencyName = ((ReferencePatterns) iterator.next()).getAbstractName();
            dependencySet.add(new GBeanDependency(this, dependencyName, kernel));
        }

        dependencies = (GBeanDependency[]) dependencySet.toArray(new GBeanDependency[dependencySet.size()]);

        // framework operations -- all framework operations have currently been removed

        // operations
        Map operationsMap = new HashMap();
        for (Iterator iterator = gbeanInfo.getOperations().iterator(); iterator.hasNext();) {
            GOperationInfo operationInfo = (GOperationInfo) iterator.next();
            GOperationSignature signature = new GOperationSignature(operationInfo.getName(), operationInfo.getParameterList());
            // do not allow overriding of framework operations
            if (!operationsMap.containsKey(signature)) {
                GBeanOperation operation = new GBeanOperation(this, operationInfo);
                operationsMap.put(signature, operation);
            }
        }
        operations = new GBeanOperation[operationsMap.size()];
        int opCounter = 0;
        for (Iterator iterator = operationsMap.entrySet().iterator(); iterator.hasNext();) {
            Map.Entry entry = (Map.Entry) iterator.next();
            operations[opCounter] = (GBeanOperation) entry.getValue();
            operationIndex.put(entry.getKey(), new Integer(opCounter));
            opCounter++;
        }

        // get the constructor
        List arguments = gbeanInfo.getConstructor().getAttributeNames();
        Class[] parameterTypes = new Class[arguments.size()];
        for (int i = 0; i < parameterTypes.length; i++) {
            String argumentName = (String) arguments.get(i);
            if (referenceIndex.containsKey(argumentName)) {
                Integer index = (Integer) referenceIndex.get(argumentName);
                GBeanReference reference = references[index.intValue()];
                parameterTypes[i] = reference.getProxyType();
            } else if (attributeIndex.containsKey(argumentName)) {
                Integer index = (Integer) attributeIndex.get(argumentName);
                GBeanAttribute attribute = attributes[index.intValue()];
                parameterTypes[i] = attribute.getType();
            }
        }
        try {
            constructor = type.getConstructor(parameterTypes);
        } catch (NoSuchMethodException e) {
            StringBuffer buf = new StringBuffer("Could not find a valid constructor for GBean: ").append(gbeanInfo.getName()).append("\n");
            buf.append("ParameterTypes: ").append(Arrays.asList(parameterTypes)).append("\n");
            Constructor[] constructors = type.getConstructors();
            for (int i = 0; i < constructors.length; i++) {
                Constructor testConstructor = constructors[i];
                buf.append("constructor types: ").append(Arrays.asList(testConstructor.getParameterTypes())).append("\n");
                if (testConstructor.getParameterTypes().length == parameterTypes.length) {
                    Class[] testParameterTypes = testConstructor.getParameterTypes();
                    for (int k = 0; k < testParameterTypes.length; k++) {
                        Class testParameterType = testParameterTypes[k];
                        if (parameterTypes[k].getName().equals(testParameterType.getName())) {
                            if (parameterTypes[k].getClassLoader() != testParameterType.getClassLoader()) {
                                buf.append("different classloaders in position: ").append(k).append(" class name: ").append(testParameterType.getName()).append("\n");
                                buf.append("parameter type classloader: ").append(parameterTypes[k].getClassLoader()).append("\n");
                                buf.append("constructor type classloader: ").append(testParameterType.getClassLoader()).append("\n");
                            }
                        } else {
                            buf.append("different type in position: ").append(k).append("\n");
                        }
                    }
                }
            }
            throw new InvalidConfigurationException(buf.toString());
        } catch (NoClassDefFoundError e) {
            throw new InvalidConfigurationException(e);
        }

        // rebuild the gbean info based on the current attributes, operations, and references because
        // the above code add new attributes and operations
        this.gbeanInfo = rebuildGBeanInfo(gbeanInfo.getConstructor(), gbeanInfo.getJ2eeType());

        // create the raw invokers
        rawInvoker = new RawInvoker(this);

        // set the initial attribute values
View Full Code Here

Examples of org.apache.geronimo.gbean.GBeanInfo

        Set interfaceInfos = new HashSet();
        for (int i = 0; i < interfaces.length; i++) {
            interfaceInfos.add(interfaces[i]);
        }

        return new GBeanInfo(name,
                type.getName(),
                j2eeType,
                attributeInfos,
                constructor,
                operationInfos,
View Full Code Here

Examples of org.apache.geronimo.gbean.GBeanInfo

        Set gbeans = new HashSet();
        Set all = listGBeans((AbstractNameQuery)null);
        for (Iterator it = all.iterator(); it.hasNext();) {
            AbstractName name = (AbstractName) it.next();
            try {
                GBeanInfo info = getGBeanInfo(name);
                Set intfs = info.getInterfaces();
                for (int i = 0; i < interfaces.length; i++) {
                    String candidate = interfaces[i];
                    if(intfs.contains(candidate)) {
                        gbeans.add(name);
                        break;
View Full Code Here

Examples of org.apache.geronimo.gbean.GBeanInfo

        artifactResolverGBean.setReferencePattern("ArtifactManager", artifactManagerGBean.getAbstractName());

        Set storeNames = new HashSet();

        // Source config store
        GBeanInfo configStoreInfo = GBeanInfo.getGBeanInfo(MavenConfigStore.class.getName(), cl);
        GBeanData storeGBean = bootstrap.addGBean("ConfigStore", configStoreInfo);
        if (configStoreInfo.getReference("Repository") != null) {
            storeGBean.setReferencePattern("Repository", repoGBean.getAbstractName());
        }
        storeNames.add(storeGBean.getAbstractName());

        // Target config store
        GBeanInfo targetConfigStoreInfo = GBeanInfo.getGBeanInfo(RepositoryConfigurationStore.class.getName(), cl);
        GBeanData targetStoreGBean = bootstrap.addGBean("TargetConfigStore", targetConfigStoreInfo);
        if (targetConfigStoreInfo.getReference("Repository") != null) {
            targetStoreGBean.setReferencePattern("Repository", targetRepoGBean.getAbstractName());
        }
        storeNames.add(targetStoreGBean.getAbstractName());

        targetConfigStoreAName = targetStoreGBean.getAbstractName();
View Full Code Here

Examples of org.apache.geronimo.gbean.GBeanInfo

            GBeanInfoBuilder infoBuilder = new GBeanInfoBuilder(ActivationSpecWrapperGBean.class, ActivationSpecWrapperGBean.GBEAN_INFO);
            Set<String> ignore = Collections.singleton("resourceAdapter");
            setUpDynamicGBean(activationSpecClassName, infoBuilder, ignore, cl, true);


            GBeanInfo gbeanInfo = infoBuilder.getBeanInfo();

            GBeanData activationSpecInfo = new GBeanData(gbeanInfo);
            activationSpecInfo.setAttribute("activationSpecClass", activationSpecClassName);
            activationSpecInfos.put(messageListenerInterface, activationSpecInfo);
        }
View Full Code Here

Examples of org.apache.geronimo.gbean.GBeanInfo


    private GBeanData setUpDynamicGBeanWithProperties(String className, GBeanInfoBuilder infoBuilder, ConfigPropertyType[] configProperties, ClassLoader cl, Set<String> ignore) throws DeploymentException {
        setUpDynamicGBean(className, infoBuilder, ignore, cl, false);

        GBeanInfo gbeanInfo = infoBuilder.getBeanInfo();
        GBeanData gbeanData = new GBeanData(gbeanInfo);
        for (ConfigPropertyType configProperty : configProperties) {
            if (configProperty.isSetConfigPropertyValue()) {
                String name = configProperty.getConfigPropertyName().getStringValue();
                if (gbeanInfo.getAttribute(name) == null) {
                    String originalName = name;
                    name = switchCase(name);
                    if (gbeanInfo.getAttribute(name) == null) {
                        log.warn("Unsupported config-property: " + originalName);
                        continue;
                    }
                }
                String type = configProperty.getConfigPropertyType().getStringValue();
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.