Package org.apache.geronimo.gbean

Examples of org.apache.geronimo.gbean.GBeanData


    public void testSerialization() throws Exception {
        Kernel kernel = new BasicKernel("test");
        kernel.boot();
        AbstractName abstractName = new AbstractName(URI.create("foo/bar/1/car?name=ConnectionManager"));
        GBeanData data = new GBeanData(abstractName, GenericConnectionManagerGBean.GBEAN_INFO);
        data.setAttribute("transactionSupport", NoTransactions.INSTANCE);
        data.setAttribute("pooling", new SinglePool(10, 0, 5000, 5, false, false, true));
        kernel.loadGBean(data, this.getClass().getClassLoader());
        kernel.startGBean(abstractName);
        Object cm = kernel.getGBean(abstractName);
        assertTrue(cm instanceof GenericConnectionManagerGBean);
        ByteArrayOutputStream baos = new ByteArrayOutputStream();
View Full Code Here


        super.setUp();
        kernel = KernelFactory.newInstance().createKernel(KERNEL_NAME);
        kernel.boot();
        ClassLoader cl = MockConnectionTrackingCoordinator.class.getClassLoader();

        GBeanData ctc = buildGBeanData("name", "ConnectionTrackingCoordinator", MockConnectionTrackingCoordinator.getGBeanInfo());
        AbstractName ctcName = ctc.getAbstractName();
        kernel.loadGBean(ctc, cl);

        GBeanData cmf = buildGBeanData("name", "ConnectionManagerContainer", GenericConnectionManagerGBean.getGBeanInfo());
        AbstractName cmfName = cmf.getAbstractName();
        cmf.setAttribute("transactionSupport", NoTransactions.INSTANCE);
        cmf.setAttribute("pooling", new NoPool());
        cmf.setReferencePattern("ConnectionTracker", ctcName);
        kernel.loadGBean(cmf, cl);


        GBeanData mcfw = buildGBeanData("name", TARGET_NAME, ManagedConnectionFactoryWrapperGBean.getGBeanInfo());
        managedConnectionFactoryName = mcfw.getAbstractName();
        mcfw.setAttribute("managedConnectionFactoryClass", MockManagedConnectionFactory.class.getName());
        mcfw.setAttribute("connectionFactoryInterface", ConnectionFactory.class.getName());
        mcfw.setAttribute("implementedInterfaces", new String[]{Serializable.class.getName(), ConnectionFactoryExtension.class.getName()});
        mcfw.setAttribute("connectionFactoryImplClass", MockConnectionFactory.class.getName());
        mcfw.setAttribute("connectionInterface", Connection.class.getName());
        mcfw.setAttribute("connectionImplClass", MockConnection.class.getName());
        //"ResourceAdapterWrapper",
        mcfw.setReferencePattern("ConnectionManagerContainer", cmfName);
        //"ManagedConnectionFactoryListener",
        kernel.loadGBean(mcfw, cl);

        kernel.startGBean(ctcName);
        kernel.startGBean(cmfName);
View Full Code Here

        kernel.startGBean(cmfName);
        kernel.startGBean(managedConnectionFactoryName);
    }
    private GBeanData buildGBeanData(String key, String value, GBeanInfo info) {
        AbstractName abstractName = buildAbstractName(key, value);
        return new GBeanData(abstractName, info);
    }
View Full Code Here

     * This contains Repository and ConfigurationStore GBeans that map to
     * the local maven installation.
     */
    private static void bootDeployerSystem(Kernel kernel, File repository) throws Exception {
        ClassLoader cl = PackageBuilder.class.getClassLoader();
        GBeanData repoGBean = new GBeanData(REPOSITORY_NAME, MavenRepository.GBEAN_INFO);
        repoGBean.setAttribute("root", repository);
        kernel.loadGBean(repoGBean, cl);
        kernel.startGBean(REPOSITORY_NAME);

        GBeanData storeGBean = new GBeanData(CONFIGSTORE_NAME, MavenConfigStore.GBEAN_INFO);
        storeGBean.setReferencePattern("Repository", REPOSITORY_NAME);
        kernel.loadGBean(storeGBean, cl);
        kernel.startGBean(CONFIGSTORE_NAME);

        GBeanData configManagerGBean = new GBeanData(CONFIGMANAGER_NAME, ConfigurationManagerImpl.GBEAN_INFO);
        configManagerGBean.setReferencePattern("Stores", CONFIGSTORE_NAME);
        kernel.loadGBean(configManagerGBean, cl);
        kernel.startGBean(CONFIGMANAGER_NAME);

        GBeanData attrManagerGBean = new GBeanData(ATTRIBUTESTORE_NAME, MavenAttributeStore.GBEAN_INFO);
        kernel.loadGBean(attrManagerGBean, cl);
        kernel.startGBean(ATTRIBUTESTORE_NAME);
    }
View Full Code Here

    public synchronized ObjectName loadConfiguration(URI configId) throws NoSuchConfigException, IOException, InvalidConfigException {
        if (!repository.hasURI(configId)) {
            throw new NoSuchConfigException("Configuration not found: " + configId);
        }

        GBeanData config = new GBeanData();
        URL baseURL = new URL("jar:" + repository.getURL(configId).toString() + "!/");
        InputStream jis = null;
        try {
            URL stateURL = new URL(baseURL, "META-INF/config.ser");
            jis = stateURL.openStream();
            ObjectInputStream ois = new ObjectInputStream(jis);
            config.readExternal(ois);
            config.setReferencePattern("ConfigurationStore", objectName);
        } catch (ClassNotFoundException e) {
            throw new InvalidConfigException("Unable to load class from config: " + configId, e);
        } finally {
            if (jis != null) {
                jis.close();
            }
        }

        ObjectName name;
        try {
            name = Configuration.getConfigurationObjectName(configId);
        } catch (MalformedObjectNameException e) {
            throw new InvalidConfigException("Cannot convert id to ObjectName: ", e);
        }
        config.setName(name);
        ObjectName pattern;
        try {
            pattern = attributeStore == null ? null : new ObjectName(attributeStore.getObjectName());
        } catch (MalformedObjectNameException e) {
            throw new InvalidConfigException("Invalid ObjectName for AttributeStore: " + attributeStore.getObjectName());
        }
        config.setReferencePattern("AttributeStore", pattern);

        try {
            kernel.loadGBean(config, Configuration.class.getClassLoader());
        } catch (Exception e) {
            throw new InvalidConfigException("Unable to register configuration", e);
View Full Code Here

            configList.add(new URI(st.nextToken()));
        }
        File root = new File(getGeronimoHome());
        URL systemURL = new File(root, "bin/server.jar").toURL();
        URL configURL = new URL("jar:" + systemURL.toString() + "!/META-INF/config.ser");
        GBeanData configuration = new GBeanData();
        ObjectInputStream ois = new ObjectInputStream(configURL.openStream());
        try {
            configuration.readExternal(ois);
        } finally {
            ois.close();
        }
        URI configurationId = (URI) configuration.getAttribute("id");
        ObjectName configName = Configuration.getConfigurationObjectName(configurationId);
        configuration.setName(configName);

        // build a basic kernel without a configuration-store, our configuration store is
        Kernel kernel = KernelFactory.newInstance().createKernel(getKernelName());
        kernel.boot();
View Full Code Here

                                   ObjectName resourceAdapterObjectName,
                                   GBeanData managedConnectionFactoryPrototypeGBeanData,
                                   GerConnectiondefinitionInstanceType connectiondefinitionInstance,
                                   String transactionSupport,
                                   ClassLoader cl) throws DeploymentException {
        GBeanData managedConnectionFactoryInstanceGBeanData = new GBeanData(managedConnectionFactoryPrototypeGBeanData);
        // ConnectionManager
        ObjectName connectionManagerObjectName = configureConnectionManager(earContext, j2eeContext, transactionSupport, connectiondefinitionInstance, cl);

        // ManagedConnectionFactory
        setDynamicGBeanDataAttributes(managedConnectionFactoryInstanceGBeanData, connectiondefinitionInstance.getConfigPropertySettingArray(), cl);
        try {
            if (resourceAdapterObjectName != null) {
                managedConnectionFactoryInstanceGBeanData.setReferencePattern("ResourceAdapterWrapper", resourceAdapterObjectName);
            }
            managedConnectionFactoryInstanceGBeanData.setReferencePattern("ConnectionManagerContainer", connectionManagerObjectName);
            //additional interfaces implemented by connection factory
            String[] implementedInterfaces = connectiondefinitionInstance.getImplementedInterfaceArray();
            if (implementedInterfaces != null) {
                for (int i = 0; i < implementedInterfaces.length; i++) {
                    implementedInterfaces[i] = implementedInterfaces[i].trim();
                }
            } else {
                implementedInterfaces = new String[0];
            }
            managedConnectionFactoryInstanceGBeanData.setAttribute("implementedInterfaces", implementedInterfaces);

        } catch (Exception e) {
            throw new DeploymentException(e);
        }

        ObjectName managedConnectionFactoryObjectName = null;
        try {
            managedConnectionFactoryObjectName = NameFactory.getComponentName(null, null, null, null, null, connectiondefinitionInstance.getName(), NameFactory.JCA_MANAGED_CONNECTION_FACTORY, j2eeContext);
        } catch (MalformedObjectNameException e) {
            throw new DeploymentException("Could not construct managed connection factory object name", e);
        }
        managedConnectionFactoryInstanceGBeanData.setName(managedConnectionFactoryObjectName);
        earContext.addGBean(managedConnectionFactoryInstanceGBeanData);

        // ConnectionFactory
        ObjectName connectionFactoryObjectName = null;
        try {
            connectionFactoryObjectName = NameFactory.getComponentName(null, null, null, null, null, connectiondefinitionInstance.getName(), NameFactory.JCA_CONNECTION_FACTORY, j2eeContext);
        } catch (MalformedObjectNameException e) {
            throw new DeploymentException("Could not construct connection factory object name", e);
        }
        GBeanData connectionFactoryGBeanData = new GBeanData(connectionFactoryObjectName, JCAConnectionFactoryImplGBean.GBEAN_INFO);
        connectionFactoryGBeanData.setReferencePattern("J2EEServer", earContext.getServerObjectName());
        connectionFactoryGBeanData.setAttribute("managedConnectionFactory", managedConnectionFactoryObjectName.getCanonicalName());

        earContext.addGBean(connectionFactoryGBeanData);
    }
View Full Code Here

            List results = new ArrayList();
            GBeanQuery query = new GBeanQuery(null, JettyWebConnector.class.getName());
            Set set = kernel.listGBeans(query); // all Jetty connectors
            for (Iterator it = set.iterator(); it.hasNext();) {
                ObjectName name = (ObjectName) it.next(); // a single Jetty connector
                GBeanData data = kernel.getGBeanData(name);
                Set refs = data.getReferencePatterns(JettyConnector.CONNECTOR_CONTAINER_REFERENCE);
                for (Iterator refit = refs.iterator(); refit.hasNext();) {
                    ObjectName ref = (ObjectName) refit.next();
                    boolean match = false;
                    if(ref.isPattern()) {
                        Set matches = kernel.listGBeans(ref);
View Full Code Here

        }
        return (GBeanData) activationSpecInfos.get(messageListenerInterface);
    }

    public GBeanData locateResourceAdapterGBeanData(GBeanData resourceAdapterModuleData) throws DeploymentException {
        GBeanData data = (GBeanData) resourceAdapterModuleData.getAttribute("resourceAdapterGBeanData");
        if (data == null) {
            throw new DeploymentException("No resource adapter info found for resource adapter module: " + resourceAdapterModuleData.getName());
        }
        return data;
    }
View Full Code Here

            List results = new ArrayList();
            GBeanQuery query = new GBeanQuery(null, JettyWebConnector.class.getName());
            Set set = kernel.listGBeans(query); // all Jetty connectors
            for (Iterator it = set.iterator(); it.hasNext();) {
                ObjectName name = (ObjectName) it.next(); // a single Jetty connector
                GBeanData data = kernel.getGBeanData(name);
                Set refs = data.getReferencePatterns(JettyConnector.CONNECTOR_CONTAINER_REFERENCE);
                for (Iterator refit = refs.iterator(); refit.hasNext();) {
                    ObjectName ref = (ObjectName) refit.next();
                    if(ref.isPattern()) {
                        Set matches = kernel.listGBeans(ref);
                        if(matches.size() != 1) {
View Full Code Here

TOP

Related Classes of org.apache.geronimo.gbean.GBeanData

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.