Package org.apache.geronimo.gbean

Examples of org.apache.geronimo.gbean.GBeanData$PriorityComparator


        kernel = KernelFactory.newInstance().createKernel("test.kernel");
        kernel.boot();

        //ServerInfo
        serverInfoName = new ObjectName("geronimo.system:role=ServerInfo");
        serverInfoGBean = new GBeanData(serverInfoName, BasicServerInfo.GBEAN_INFO);
        serverInfoGBean.setAttribute("baseDirectory", ".");

        start(serverInfoGBean);

        //Default Realm
        Map initParams = new HashMap();

        if (realmClass != null){
            initParams.put("userClassNames","org.apache.geronimo.security.realm.providers.GeronimoUserPrincipal");
            initParams.put("roleClassNames","org.apache.geronimo.security.realm.providers.GeronimoGroupPrincipal");
            realm = new GBeanData(realmName, RealmGBean.GBEAN_INFO);
            realm.setAttribute("className", realmClass);
            realm.setAttribute("initParams", initParams);
            start(realm);
        }

        //Default Host
        initParams.clear();
        initParams.put("workDir","work");
        initParams.put("name","localhost");
        initParams.put("appBase","");
        host = new GBeanData(hostName, HostGBean.GBEAN_INFO);
        host.setAttribute("className", "org.apache.catalina.core.StandardHost");
        host.setAttribute("initParams", initParams);
        start(host);

        //Default Engine
        initParams.clear();
        initParams.put("name","Geronimo");
        initParams.put("defaultHost","localhost");
        engine = new GBeanData(engineName, EngineGBean.GBEAN_INFO);
        engine.setAttribute("className", "org.apache.geronimo.tomcat.TomcatEngine");
        engine.setAttribute("initParams", initParams);
        if (realmClass != null)
            engine.setReferencePattern("RealmGBean", realmName);
        engine.setReferencePattern("Hosts", hostName);
        start(engine);

        // Need to override the constructor for unit tests
        container = new GBeanData(containerName, TomcatContainer.GBEAN_INFO);
        container.setAttribute("classLoader", cl);
        container.setAttribute("catalinaHome", "target/var/catalina");
        container.setReferencePattern("EngineGBean", engineName);
        container.setReferencePattern("ServerInfo", serverInfoName);

        connector = new GBeanData(connectorName, ConnectorGBean.GBEAN_INFO);
        connector.setAttribute("port", new Integer(8080));
        connector.setAttribute("host", "localhost");
        connector.setAttribute("name", "HTTP");
        connector.setReferencePattern("TomcatContainer", containerName);

        start(container);
        start(connector);

        tm = new GBeanData(tmName, TransactionManagerImplGBean.GBEAN_INFO);
        Set patterns = new HashSet();
        patterns.add(ObjectName.getInstance("geronimo.server:j2eeType=JCAManagedConnectionFactory,*"));
        tm.setAttribute("defaultTransactionTimeoutSeconds", new Integer(10));
        tm.setReferencePatterns("ResourceManagers", patterns);
        start(tm);
        tcm = new GBeanData(tcmName, TransactionContextManagerGBean.GBEAN_INFO);
        tcm.setReferencePattern("TransactionManager", tmName);
        start(tcm);
        ctc = new GBeanData(ctcName, ConnectionTrackingCoordinatorGBean.GBEAN_INFO);
        start(ctc);
    }
View Full Code Here


            is.close();
        }

        URI configId;
        try {
            GBeanData config = loadConfig(configurationDir);
            configId = (URI) config.getAttribute("id");
            index.setProperty(configId.toString(), configurationDir.getName());
        } catch (Exception e) {
            delete(configurationDir);
            throw new InvalidConfigException("Unable to get ID from downloaded configuration", e);
        }
View Full Code Here

        log.info("Uninstalled configuration " + configID);
        delete(configDir);
    }

    public synchronized ObjectName loadConfiguration(URI configId) throws NoSuchConfigException, IOException, InvalidConfigException {
        GBeanData config = loadConfig(getRoot(configId));

        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

        try {
            FileOutputStream fos = new FileOutputStream(stateFile);
            ObjectOutputStream oos;
            try {
                oos = new ObjectOutputStream(fos);
                GBeanData configurationGBeanData = ExecutableConfigurationUtil.getConfigurationGBeanData(configurationData);
                configurationGBeanData.writeExternal(oos);
                oos.flush();
            } finally {
                fos.close();
            }
        } catch (Exception e) {
View Full Code Here

                        // If the configuration is not loaded by the kernel
                        // and defined by the store, then it is stopped.
                        state = State.STOPPED;
                    }

                    GBeanData bean = loadConfig(getRoot(configId));
                    ConfigurationModuleType type = (ConfigurationModuleType) bean.getAttribute("type");

                    configs.add(new ConfigurationInfo(objectName, configId, state, type));
                } catch (Exception e) {
                    // bad configuration in store - ignored for this purpose
                    log.info("Unable get configuration info for configuration " + configId, e);
View Full Code Here

        }

        FileInputStream fis = new FileInputStream(file);
        try {
            ObjectInputStream ois = new ObjectInputStream(new BufferedInputStream(fis));
            GBeanData config = new GBeanData();
            try {
                config.readExternal(ois);
            } catch (ClassNotFoundException e) {
                //TODO more informative exceptions
                throw new InvalidConfigException("Unable to read attribute ", e);
            } catch (Exception e) {
                throw new InvalidConfigException("Unable to set attribute ", e);
            }
            config.setReferencePattern("ConfigurationStore", objectName);
            return config;
        } finally {
            fis.close();
        }
    }
View Full Code Here

    public void register(GBeanData gbean) {
        registry.put(gbean.getName(), gbean);
    }

    public synchronized GBeanData getGBeanInstance(ObjectName name) throws GBeanNotFoundException {
        GBeanData gbeanData = (GBeanData) registry.get(name);
        if (gbeanData == null) {
            throw new GBeanNotFoundException(name);
        }
        return gbeanData;
    }
View Full Code Here

    }

    public static void writeConfiguration(ConfigurationData configurationData, JarOutputStream out) throws IOException, InvalidConfigException {

        // convert the configuration data to a gbeandata object
        GBeanData configurationGBeanData = ExecutableConfigurationUtil.getConfigurationGBeanData(configurationData);

        // save the persisted form in the source directory
        out.putNextEntry(new ZipEntry("META-INF/config.ser"));
        ObjectOutputStream objectOutputStream = null;
        try {
            objectOutputStream = new ObjectOutputStream(out);
            configurationGBeanData.writeExternal(objectOutputStream);
        } catch (IOException e) {
            throw e;
        } catch (Exception e) {
            throw new InvalidConfigException("Unable to save configuration state", e);
        } finally {
View Full Code Here

        }
    }

    public static void writeConfiguration(ConfigurationData configurationData, File source) throws InvalidConfigException, IOException {
        // convert the configuration data to a gbeandata object
        GBeanData configurationGBeanData = getConfigurationGBeanData(configurationData);

        // save the persisted form in the source directory
        File metaInf = new File(source, "META-INF");
        metaInf.mkdirs();
        File configSer = new File(metaInf, "config.ser");
        ObjectOutputStream out = null;
        try {
            out = new ObjectOutputStream(new FileOutputStream(configSer));
            try {
                configurationGBeanData.writeExternal(out);
            } catch (IOException e) {
                throw e;
            } catch (Exception e) {
                throw new InvalidConfigException("Unable to save configuration state", e);
            }
View Full Code Here

    }

    public static GBeanData getConfigurationGBeanData(ConfigurationData configurationData) throws InvalidConfigException {
        try {
            URI id = configurationData.getId();
            GBeanData config = new GBeanData(Configuration.getConfigurationObjectName(id), Configuration.GBEAN_INFO);
            config.setAttribute("id", id);
            config.setAttribute("type", configurationData.getModuleType());
            config.setAttribute("domain", configurationData.getDomain());
            config.setAttribute("server", configurationData.getServer());

            List parentId = configurationData.getParentId();
            if (parentId.size() > 0) {
                config.setAttribute("parentId", parentId.toArray(new URI[parentId.size()]));
            }

            config.setAttribute("gBeanState", Configuration.storeGBeans(configurationData.getGBeans()));
            config.setReferencePatterns("Repositories", Collections.singleton(new ObjectName("*:name=Repository,*")));
            config.setAttribute("dependencies", configurationData.getDependencies());
            config.setAttribute("classPath", configurationData.getClassPath());

            return config;
        } catch (MalformedObjectNameException e) {
            throw new InvalidConfigException(e);
        }
View Full Code Here

TOP

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

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.