Package org.apache.geronimo.kernel.config

Examples of org.apache.geronimo.kernel.config.ConfigurationManager


        kernel.loadGBean(configuration, classLoader);
        kernel.setAttribute(configName, "baseURL", classLoader.getResource("/"));
        kernel.startRecursiveGBean(configName);

        // load and start the configurations
        ConfigurationManager configurationManager = ConfigurationUtil.getConfigurationManager(kernel);
        try {
            for (Iterator i = configurations.iterator(); i.hasNext();) {
                URI configID = (URI) i.next();
                List list = configurationManager.loadRecursive(configID);
                for (Iterator iterator = list.iterator(); iterator.hasNext();) {
                    ObjectName name = (ObjectName) iterator.next();
                    kernel.startRecursiveGBean(name);
                }
            }
View Full Code Here


    public Deployer(Collection builders, Collection stores, Collection watchers, Kernel kernel) {
        this(builders, stores, watchers, getArtifactResolver(kernel), kernel);
    }

    private static ArtifactResolver getArtifactResolver(Kernel kernel) {
        ConfigurationManager configurationManager = ConfigurationUtil.getConfigurationManager(kernel);
        return configurationManager.getArtifactResolver();
    }
View Full Code Here

        ObjectName configurationManagerName = new ObjectName(":j2eeType=ConfigurationManager,name=Basic");
        GBeanData configurationManagerData = new GBeanData(configurationManagerName, ConfigurationManagerImpl.GBEAN_INFO);
        configurationManagerData.setReferencePatterns("Stores", Collections.singleton(store.getName()));
        kernel.loadGBean(configurationManagerData, getClass().getClassLoader());
        kernel.startGBean(configurationManagerName);
        ConfigurationManager configurationManager = (ConfigurationManager) kernel.getProxyManager().createProxy(configurationManagerName, ConfigurationManager.class);

        ObjectName baseConfigName = configurationManager.load((URI) parentId.get(0));
        kernel.startGBean(baseConfigName);

        Collection defaultServlets = new HashSet();
        Collection defaultFilters = new HashSet();
        Collection defaultFilterMappings = new HashSet();
View Full Code Here

        }

        getLog().debug("Starting configurations..." + Arrays.asList(deploymentConfigs));

        // start the Configuration we're going to use for this deployment
        ConfigurationManager configurationManager = ConfigurationUtil.getConfigurationManager(kernel);
        try {
            for (String artifactName : deploymentConfigs) {
                org.apache.geronimo.kernel.repository.Artifact configName = org.apache.geronimo.kernel.repository.Artifact.create(artifactName);
                if (!configurationManager.isLoaded(configName)) {
                    RecordingLifecycleMonitor monitor = new RecordingLifecycleMonitor();
                    try {
                        configurationManager.loadConfiguration(configName, monitor);
                    } catch (LifecycleException e) {
                        getLog().error("Could not load deployer configuration: " + configName + "\n" + monitor.toString(), e);
                    }
                    monitor = new RecordingLifecycleMonitor();
                    try {
                        configurationManager.startConfiguration(configName, monitor);
                        getLog().info("Started deployer: " + configName);
                    } catch (LifecycleException e) {
                        getLog().error("Could not start deployer configuration: " + configName + "\n" + monitor.toString(), e);
                    }
                }
View Full Code Here

    public void processAction(ActionRequest actionRequest, ActionResponse actionResponse) throws PortletException, IOException {
        String action = actionRequest.getParameter("action");
        actionResponse.setRenderParameter("message", ""); // set to blank first
        try {
            ConfigurationManager configurationManager = ConfigurationUtil.getConfigurationManager(kernel);
            String config = getConfigID(actionRequest);
            Artifact configId = Artifact.create(config);

            if (START_ACTION.equals(action)) {
                if(!configurationManager.isLoaded(configId)) {
                    configurationManager.loadConfiguration(configId);
                }
                if(!configurationManager.isRunning(configId)) {
                    configurationManager.startConfiguration(configId);
                    messageStatus = "Started application<br /><br />";
                }
            } else if (STOP_ACTION.equals(action)) {
                if(configurationManager.isRunning(configId)) {
                    configurationManager.stopConfiguration(configId);
                }
                if(configurationManager.isLoaded(configId)) {
                    configurationManager.unloadConfiguration(configId);
                    messageStatus = "Stopped application<br /><br />";
                }
            } else if (UNINSTALL_ACTION.equals(action)) {
                configurationManager.uninstallConfiguration(configId);
                messageStatus = "Uninstalled application<br /><br />";
            } else if (RESTART_ACTION.equals(action)) {
                configurationManager.restartConfiguration(configId);
                messageStatus = "Restarted application<br /><br />";
            } else {
                messageStatus = "Invalid value for changeState: " + action + "<br /><br />";
                throw new PortletException("Invalid value for changeState: " + action);
            }
View Full Code Here

        if (WindowState.MINIMIZED.equals(renderRequest.getWindowState())) {
            return;
        }

        List moduleDetails = new ArrayList();
        ConfigurationManager configManager = ConfigurationUtil.getConfigurationManager(kernel);
        DependencyManager depMgr = kernel.getDependencyManager();
        List infos = configManager.listConfigurations();
        for (Iterator j = infos.iterator(); j.hasNext();) {
            ConfigurationInfo info = (ConfigurationInfo) j.next();
            if (shouldListConfig(info)) {
                ModuleDetails details = new ModuleDetails(info.getConfigID(), info.getType(), info.getState());

                if (info.getType().getValue()== ConfigurationModuleType.WAR.getValue()){
                    WebModule webModule = (WebModule) PortletManager.getModule(renderRequest, info.getConfigID());
                    if (webModule != null) {
                        details.setContextPath(webModule.getContextPath());
                        details.setUrlFor(webModule.getURLFor());
                    }
                }
                try {
                    AbstractName configObjName = Configuration.getConfigurationAbstractName(info.getConfigID());
                    boolean flag = false;
                    // Check if the configuration is loaded.  If not, load it to get information.
                    if(!kernel.isLoaded(configObjName)) {
                        flag = true;
                        try {
                            configManager.loadConfiguration(configObjName.getArtifact());
                        } catch (NoSuchConfigException e) {
                            // Should not occur
                            e.printStackTrace();
                        } catch (LifecycleException e) {
                            // TODO Auto-generated catch block
                            e.printStackTrace();
                        }
                    }

                    java.util.Set parents = depMgr.getParents(configObjName);
                    for(Iterator itr = parents.iterator(); itr.hasNext(); ) {
                        AbstractName parent = (AbstractName)itr.next();
                        details.getParents().add(parent.getArtifact());
                    }
                    java.util.Set children = depMgr.getChildren(configObjName);
                    for(Iterator itr = children.iterator(); itr.hasNext(); ) {
                        AbstractName child = (AbstractName)itr.next();
                        //if(configManager.isConfiguration(child.getArtifact()))
                        if(child.getNameProperty("configurationName") != null) {
                            details.getChildren().add(child.getArtifact());
                        }
                    }
                    Collections.sort(details.getParents());
                    Collections.sort(details.getChildren());

                    // Unload the configuration if it has been loaded earlier for the sake of getting information
                    if(flag) {
                        try {
                            configManager.unloadConfiguration(configObjName.getArtifact());
                        } catch (NoSuchConfigException e) {
                            // Should not occur
                            e.printStackTrace();
                        }
                    }
View Full Code Here

        // The array entry types are security.realm.SecurityRealm (the subclass)
        org.apache.geronimo.management.geronimo.SecurityRealm[] realms = PortletManager.getCurrentServer(request).getSecurityRealms();
        ExistingRealm[] results = new ExistingRealm[realms.length];

        // ConfigurationManager is used to determine if the SecurityRealm is deployed as a "SERVICE", i.e., "Server-wide"
        ConfigurationManager configMgr = null;
        if(results.length > 0) {
            // Needed only when there are any SecurityRealms
            configMgr = ConfigurationUtil.getConfigurationManager(kernel);
        }
        for (int i = 0; i < results.length; i++) {
            final GeronimoManagedBean managedBean = (GeronimoManagedBean) realms[i];
            AbstractName abstractName = PortletManager.getNameFor(request, realms[i]);
            String parent;
            Configuration parentConfig = configMgr.getConfiguration(abstractName.getArtifact());
            ConfigurationModuleType parentType = parentConfig.getModuleType();
            if(ConfigurationModuleType.SERVICE.equals(parentType)) {
                parent = null; // Server-wide
            } else {
                parent = abstractName.getArtifact().toString();
View Full Code Here

        // load the configuration manager bootstrap service
        ConfigurationData bootstrap = new ConfigurationData(new Artifact("bootstrap", "bootstrap", "", "car"), kernel.getNaming());
        bootstrap.addGBean("ConfigurationManager", KernelConfigurationManager.GBEAN_INFO);
        ConfigurationUtil.loadBootstrapConfiguration(kernel, bootstrap, getClass().getClassLoader());
        ConfigurationManager configurationManager = (ConfigurationManager) kernel.getGBean(ConfigurationManager.class);

        // create a configuration for our test bean
        Artifact configurationId = new Artifact("test", "test", "", "car");
        ConfigurationData configurationData = new ConfigurationData(configurationId, kernel.getNaming());
        GBeanData mockBean1 = configurationData.addGBean("MyBean", TestGBean.getGBeanInfo());
        mockBean1.setAttribute("value", "1234");

        // load and start the configuration
        configurationManager.loadConfiguration(configurationData);
        configurationManager.startConfiguration(configurationId);

        // invoke GBean directly
        TestGBean testGBean = (TestGBean) kernel.getGBean("MyBean");
        assertEquals("1234", testGBean.getValue());
        assertEquals("1234", testGBean.fetchValue());

        // invoke GBean by short name
        assertEquals("1234", kernel.getAttribute("MyBean", "value"));
        assertEquals("1234", kernel.invoke("MyBean", "fetchValue"));
        // this does not work without addOperation
        assertEquals("1234", kernel.invoke("MyBean", "getValue"));
       
        // invoke GBean by type
        assertEquals("1234", kernel.getAttribute(TestGBean.class, "value"));
        assertEquals("1234", kernel.invoke(TestGBean.class, "fetchValue"));

        // invoke GBean by name and type
        assertEquals("1234", kernel.getAttribute("MyBean", TestGBean.class, "value"));
        assertEquals("1234", kernel.invoke("MyBean", TestGBean.class, "fetchValue"));

        // stop and unload configuration
        configurationManager.stopConfiguration(configurationId);
        configurationManager.unloadConfiguration(configurationId);

        // stop the kernel
        kernel.shutdown();
    }
View Full Code Here

        }

        log.debug("Starting configurations..." + Arrays.asList(deploymentConfigs));

        // start the Configuration we're going to use for this deployment
        ConfigurationManager configurationManager = ConfigurationUtil.getConfigurationManager(kernel);
        try {
            for (String artifactName : deploymentConfigs) {
                org.apache.geronimo.kernel.repository.Artifact configName = org.apache.geronimo.kernel.repository.Artifact.create(artifactName);
                if (!configurationManager.isLoaded(configName)) {
                    RecordingLifecycleMonitor monitor = new RecordingLifecycleMonitor();
                    try {
                        configurationManager.loadConfiguration(configName, monitor);
                    } catch (LifecycleException e) {
                        log.error("Could not load deployer configuration: " + configName + "\n" + monitor.toString(), e);
                    }
                    monitor = new RecordingLifecycleMonitor();
                    try {
                        configurationManager.startConfiguration(configName, monitor);
                        log.info("Started deployer: " + configName);
                    } catch (LifecycleException e) {
                        log.error("Could not start deployer configuration: " + configName + "\n" + monitor.toString(), e);
                    }
                }
View Full Code Here

    public void processAction(ActionRequest actionRequest, ActionResponse actionResponse) throws PortletException, IOException {
        String action = actionRequest.getParameter("action");
        actionResponse.setRenderParameter("message", ""); // set to blank first
        try {
            ConfigurationManager configurationManager = ConfigurationUtil.getConfigurationManager(kernel);
            String config = getConfigID(actionRequest);
            Artifact configId = Artifact.create(config);

            if (START_ACTION.equals(action)) {
                if(!configurationManager.isLoaded(configId)) {
                    configurationManager.loadConfiguration(configId);
                }
                if(!configurationManager.isRunning(configId)) {
                    org.apache.geronimo.kernel.config.LifecycleResults lcresult = configurationManager.startConfiguration(configId);
                    message(actionResponse, lcresult, "Started application<br /><br />");
                }
            } else if (STOP_ACTION.equals(action)) {
                if(configurationManager.isRunning(configId)) {
                    configurationManager.stopConfiguration(configId);
                }
                if(configurationManager.isLoaded(configId)) {
                    LifecycleResults lcresult = configurationManager.unloadConfiguration(configId);
                    message(actionResponse, lcresult, "Stopped application<br /><br />");
                }
            } else if (UNINSTALL_ACTION.equals(action)) {
                configurationManager.uninstallConfiguration(configId);
                message(actionResponse, null, "Uninstalled application<br /><br />"+configId+"<br /><br />");
            } else if (RESTART_ACTION.equals(action)) {
                LifecycleResults lcresult = configurationManager.restartConfiguration(configId);
                message(actionResponse, lcresult, "Restarted application<br /><br />");
            } else {
                message(actionResponse, null, "Invalid value for changeState: " + action + "<br /><br />");
                throw new PortletException("Invalid value for changeState: " + action);
            }
View Full Code Here

TOP

Related Classes of org.apache.geronimo.kernel.config.ConfigurationManager

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.