plugins/org.apache.geronimo.st.v21.core/src/main/java/org/apache/geronimo/st/v21/core/operations/GeronimoServerV21PluginManager.java [87:214]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        ServerWorkingCopy copy = (ServerWorkingCopy)aServer;
        server = copy.getOriginal();
        try {
            if (server != null) {
                GeronimoServerBehaviourDelegate delegate = (GeronimoServerBehaviourDelegate) server
                    .getAdapter(GeronimoServerBehaviourDelegate.class);
                if (delegate != null) {
                    MBeanServerConnection connection = delegate.getServerConnection();
                    if (connection != null) {
                        kernel = new KernelDelegate(connection);
                    }
                    pluginInstaller = getPluginInstaller();                
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            Trace.trace(Trace.WARNING, "Kernel connection failed. "
                + e.getMessage(), Activator.logOperations);
        }
        Trace.tracePoint("Constructor", Activator.traceOperations, "GeronimoServerPluginManager");
    }
    
    private PluginInstaller getPluginInstaller() {
        Set<AbstractName> set = kernel.listGBeans(new AbstractNameQuery(PluginInstaller.class.getName()));
        for (AbstractName name : set) {
            return (PluginInstaller) kernel.getProxyManager().createProxy(name, PluginInstaller.class);
        }
        throw new IllegalStateException("No plugin installer found");
    }
    
    public List<String> getPluginList () {
        Trace.tracePoint("Entry", Activator.traceOperations, "GeronimoServerPluginManager.getPluginList");

        String name;
        boolean added;
        if (pluginInstaller != null){
            try {
                data = pluginInstaller.createPluginListForRepositories(null);

                List<PluginType> aList = data.getPlugin();
                pluginList = new ArrayList<String>(aList.size());
                for (int i = 0; i < aList.size(); i++) {
                    name = aList.get(i).getName();
                    added = false;
                    for (int j = 0; j < pluginList.size() && added == false; j++) {
                        if (name.compareTo(pluginList.get(j)) < 0) {
                            pluginList.add(j, name);
                            added = true;
                        }
                    }
                    if (added == false) {
                        pluginList.add(name);
                    }
                }
            } catch (Throwable e) {
                e.printStackTrace();
            }
        }

        Trace.tracePoint("Exit", Activator.traceOperations, "GeronimoServerPluginManager.getPluginList", pluginList);
        return pluginList;
    }

    // mimics org.apache.geronimo.console.car.AssemblyViewHandler.actionAfterView
    public void assembleServer (String group, String artifact, String version,
                        String format, String relativeServerPath, int[] selected) {
        Trace.tracePoint("Entry", Activator.traceOperations, "GeronimoServerPluginManager.assembleServer",
                group, artifact, version, format);

        PluginListType selectedPlugins = new PluginListType();
        String name;
        boolean found;

        for (int i = 0; i < selected.length; i++) {
            name = pluginList.get(selected[i]);
            found = false;
            for (int j = 0 ; j < data.getPlugin().size() && found == false; j++) {
                if (name.equals(data.getPlugin().get(j).getName())) {
                    selectedPlugins.getPlugin().add(data.getPlugin().get(j));
                    found = true;
                }
            }
        }

        try {
            GeronimoConnectionFactory gcFactory = GeronimoConnectionFactory.getInstance();
            RemoteDeploymentManager remoteDM = (RemoteDeploymentManager)gcFactory.getDeploymentManager(server);
            remoteDM.installPluginList("repository", relativeServerPath, selectedPlugins);
            remoteDM.archive(relativeServerPath, "var/temp", new Artifact(group, artifact, (String)version, format));
        }
        catch (Exception e) {
            e.printStackTrace();
        }
        Trace.tracePoint("Exit", Activator.traceOperations, "GeronimoServerPluginManager.assembleServer");
    }

    // mimics org.apache.geronimo.console.util.KernelManagementHelper.getConfigurations()
    public List<String> getConfigurationList () {
        Trace.tracePoint("Entry", Activator.traceOperations, "GeronimoServerPluginManager.getConfigurationList");

        ConfigurationManager mgr = getConfigurationManager();
        List<AbstractName> stores = mgr.listStores();
        List<String> results = new ArrayList<String>();
        for (AbstractName storeName : stores) {
            try {
                List<ConfigurationInfo> infos = mgr.listConfigurations(storeName);
                for (ConfigurationInfo info : infos) {
                    if (info.getConfigID().getType().equalsIgnoreCase("car"))
                    {
                       results.add(info.getConfigID().toString());
                    }
                }
            } catch (Exception e) {
                throw new RuntimeException(CommonMessages.badConfigId, e);
            }
        }
        Collections.sort(results);

        Trace.tracePoint("Entry", Activator.traceOperations, "GeronimoServerPluginManager.getConfigurationList", results);
        return results;
    }

    public PluginType getPluginMetadata (String configId) {
        Artifact artifact = Artifact.create(configId);
        PluginType metadata = null;
        if (pluginInstaller != null)
            metadata = pluginInstaller.getPluginMetadata(artifact);
        return metadata;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



plugins/org.apache.geronimo.st.v30.core/src/main/java/org/apache/geronimo/st/v30/core/operations/GeronimoServerPluginManager.java [86:213]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        ServerWorkingCopy copy = (ServerWorkingCopy)aServer;
        server = copy.getOriginal();
        try {
            if (server != null) {
                GeronimoServerBehaviourDelegate delegate = (GeronimoServerBehaviourDelegate) server
                    .getAdapter(GeronimoServerBehaviourDelegate.class);
                if (delegate != null) {
                    MBeanServerConnection connection = delegate.getServerConnection();
                    if (connection != null) {
                        kernel = new KernelDelegate(connection);
                    }
                    pluginInstaller = getPluginInstaller();                
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
            Trace.trace(Trace.WARNING, "Kernel connection failed. "
                + e.getMessage(), Activator.logOperations);
        }
        Trace.tracePoint("Constructor", Activator.traceOperations, "GeronimoServerPluginManager");
    }
    
    private PluginInstaller getPluginInstaller() {
        Set<AbstractName> set = kernel.listGBeans(new AbstractNameQuery(PluginInstaller.class.getName()));
        for (AbstractName name : set) {
            return (PluginInstaller) kernel.getProxyManager().createProxy(name, PluginInstaller.class);
        }
        throw new IllegalStateException("No plugin installer found");
    }
    
    public List<String> getPluginList () {
        Trace.tracePoint("Entry", Activator.traceOperations, "GeronimoServerPluginManager.getPluginList");

        String name;
        boolean added;
        if (pluginInstaller != null){
            try {
                data = pluginInstaller.createPluginListForRepositories(null);

                List<PluginType> aList = data.getPlugin();
                pluginList = new ArrayList<String>(aList.size());
                for (int i = 0; i < aList.size(); i++) {
                    name = aList.get(i).getName();
                    added = false;
                    for (int j = 0; j < pluginList.size() && added == false; j++) {
                        if (name.compareTo(pluginList.get(j)) < 0) {
                            pluginList.add(j, name);
                            added = true;
                        }
                    }
                    if (added == false) {
                        pluginList.add(name);
                    }
                }
            } catch (Throwable e) {
                e.printStackTrace();
            }
        }

        Trace.tracePoint("Exit", Activator.traceOperations, "GeronimoServerPluginManager.getPluginList", pluginList);
        return pluginList;
    }

    // mimics org.apache.geronimo.console.car.AssemblyViewHandler.actionAfterView
    public void assembleServer (String group, String artifact, String version,
                        String format, String relativeServerPath, int[] selected) {
        Trace.tracePoint("Entry", Activator.traceOperations, "GeronimoServerPluginManager.assembleServer",
                group, artifact, version, format);

        PluginListType selectedPlugins = new PluginListType();
        String name;
        boolean found;

        for (int i = 0; i < selected.length; i++) {
            name = pluginList.get(selected[i]);
            found = false;
            for (int j = 0 ; j < data.getPlugin().size() && found == false; j++) {
                if (name.equals(data.getPlugin().get(j).getName())) {
                    selectedPlugins.getPlugin().add(data.getPlugin().get(j));
                    found = true;
                }
            }
        }

        try {
            GeronimoConnectionFactory gcFactory = GeronimoConnectionFactory.getInstance();
            RemoteDeploymentManager remoteDM = (RemoteDeploymentManager)gcFactory.getDeploymentManager(server);
            remoteDM.installPluginList("repository", relativeServerPath, selectedPlugins);
            remoteDM.archive(relativeServerPath, "var/temp", new Artifact(group, artifact, (String)version, format));
        }
        catch (Exception e) {
            e.printStackTrace();
        }
        Trace.tracePoint("Exit", Activator.traceOperations, "GeronimoServerPluginManager.assembleServer");
    }

    // mimics org.apache.geronimo.console.util.KernelManagementHelper.getConfigurations()
    public List<String> getConfigurationList () {
        Trace.tracePoint("Entry", Activator.traceOperations, "GeronimoServerPluginManager.getConfigurationList");

        ConfigurationManager mgr = getConfigurationManager();
        List<AbstractName> stores = mgr.listStores();
        List<String> results = new ArrayList<String>();
        for (AbstractName storeName : stores) {
            try {
                List<ConfigurationInfo> infos = mgr.listConfigurations(storeName);
                for (ConfigurationInfo info : infos) {
                    if (info.getConfigID().getType().equalsIgnoreCase("car"))
                    {
                       results.add(info.getConfigID().toString());
                    }
                }
            } catch (Exception e) {
                throw new RuntimeException(CommonMessages.badConfigId, e);
            }
        }
        Collections.sort(results);

        Trace.tracePoint("Entry", Activator.traceOperations, "GeronimoServerPluginManager.getConfigurationList", results);
        return results;
    }

    public PluginType getPluginMetadata (String configId) {
        Artifact artifact = Artifact.create(configId);
        PluginType metadata = null;
        if (pluginInstaller != null)
            metadata = pluginInstaller.getPluginMetadata(artifact);
        return metadata;
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



