modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginManager.java | 1 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/bundle/BundleServerPluginContainer.java | 5 modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/bundle/BundleServerPluginFacet.java | 29 +++++ modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/bundle/BundleServerPluginManager.java | 54 ++++++++++ modules/enterprise/server/plugins/filetemplate-bundle/src/main/java/org/rhq/enterprise/server/plugins/filetemplate/BundleServerPluginComponent.java | 3 5 files changed, 90 insertions(+), 2 deletions(-)
New commits: commit 27317cceaaffe3c97a9c6c22318fa36ce748b5db Author: John Mazzitelli mazz@redhat.com Date: Tue Feb 23 13:31:57 2010 -0500
given a bundle type name, you can now get a plugin component from the bundle plugin that supports that type. BundleServerPluginFacet will be the interface of the bundle server plugin to the outside world (the SLSBs for example)
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginManager.java index 768162f..5f75e96 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginManager.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/ServerPluginManager.java @@ -486,7 +486,6 @@ public class ServerPluginManager { * * The new object will be loaded in the plugin's specific classloader. * - * @param pluginName the name of the plugin whose main component is to be retrieved * @param environment the environment in which the plugin will execute * * @return a new object loaded in the proper plugin classloader that can initialize/shutdown the plugin, diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/bundle/BundleServerPluginContainer.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/bundle/BundleServerPluginContainer.java index 59eb94c..6814b2b 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/bundle/BundleServerPluginContainer.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/bundle/BundleServerPluginContainer.java @@ -44,4 +44,9 @@ public class BundleServerPluginContainer extends AbstractTypeServerPluginContain protected ServerPluginManager createPluginManager() { return new BundleServerPluginManager(this); } + + public BundleServerPluginManager getBundleServerPluginManager() { + return (BundleServerPluginManager) getPluginManager(); + } + } \ No newline at end of file diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/bundle/BundleServerPluginFacet.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/bundle/BundleServerPluginFacet.java new file mode 100644 index 0000000..0585a4b --- /dev/null +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/bundle/BundleServerPluginFacet.java @@ -0,0 +1,29 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2010 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +package org.rhq.enterprise.server.plugin.pc.bundle; + +/** + * All bundle server plugins must implement this facet. + * + * @author John Mazzitelli + */ +public interface BundleServerPluginFacet { + +} diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/bundle/BundleServerPluginManager.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/bundle/BundleServerPluginManager.java index c1b542d..68f8a0f 100644 --- a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/bundle/BundleServerPluginManager.java +++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/plugin/pc/bundle/BundleServerPluginManager.java @@ -18,8 +18,11 @@ */ package org.rhq.enterprise.server.plugin.pc.bundle;
+import org.rhq.enterprise.server.plugin.pc.ServerPluginComponent; import org.rhq.enterprise.server.plugin.pc.ServerPluginEnvironment; import org.rhq.enterprise.server.plugin.pc.ServerPluginManager; +import org.rhq.enterprise.server.xmlschema.generated.serverplugin.bundle.BundlePluginDescriptorType; +import org.rhq.enterprise.server.xmlschema.generated.serverplugin.bundle.BundleType;
/** * This loads in all bundle server plugins that can be found. You can obtain a loaded plugin's @@ -38,4 +41,55 @@ public class BundleServerPluginManager extends ServerPluginManager { public void initialize() throws Exception { super.initialize(); } + + @Override + protected void loadPlugin(ServerPluginEnvironment env, boolean enabled) throws Exception { + if (enabled) { + // validate some things about this plugin that are specific for bundle functionality + + BundlePluginDescriptorType descriptor = (BundlePluginDescriptorType) env.getPluginDescriptor(); + BundleType bt = descriptor.getBundle(); + if (bt == null || bt.getType() == null || bt.getType().length() == 0) { + // if the xml parser did its job, this will probably never happen, but just in case, make sure there is + // a non-null, valid bundle type name - we have other code that expects this to be true + throw new Exception("The bundle plugin [" + env.getPluginKey().getPluginName() + + "] did not specify a valid bundle type in its descriptor"); + } + + ServerPluginComponent component = createServerPluginComponent(env); + if (!(component instanceof BundleServerPluginFacet)) { + throw new Exception("The bundle plugin [" + env.getPluginKey().getPluginName() + + "] has an invalid component [" + component + "]. It does not implement [" + + BundleServerPluginFacet.class + "]"); + } + } + + super.loadPlugin(env, enabled); + } + + /** + * Given the {@link BundleType#getName() name of a bundle type}, this will return the stateful plugin component + * that manages bundles of that type. + * + * @param bundleTypeName + * + * @return the plugin component object that will manage bundles of the named bundle type; <code>null</code> if there is no plugin + * that can support the given bundle type + */ + public BundleServerPluginFacet getBundleServerPluginFacet(String bundleTypeName) { + if (bundleTypeName == null) { + throw new IllegalArgumentException("bundleTypeName == null"); + } + + for (ServerPluginEnvironment env : getPluginEnvironments()) { + BundlePluginDescriptorType descriptor = (BundlePluginDescriptorType) env.getPluginDescriptor(); + if (bundleTypeName.equals(descriptor.getBundle().getType())) { + ServerPluginComponent component = getServerPluginComponent(env.getPluginKey().getPluginName()); + // we know this cast will work because our loadPlugin ensured that this component implements this interface + return (BundleServerPluginFacet) component; + } + } + + return null; + } } \ No newline at end of file diff --git a/modules/enterprise/server/plugins/filetemplate-bundle/src/main/java/org/rhq/enterprise/server/plugins/filetemplate/BundleServerPluginComponent.java b/modules/enterprise/server/plugins/filetemplate-bundle/src/main/java/org/rhq/enterprise/server/plugins/filetemplate/BundleServerPluginComponent.java index 0e8659e..58dd5b1 100644 --- a/modules/enterprise/server/plugins/filetemplate-bundle/src/main/java/org/rhq/enterprise/server/plugins/filetemplate/BundleServerPluginComponent.java +++ b/modules/enterprise/server/plugins/filetemplate-bundle/src/main/java/org/rhq/enterprise/server/plugins/filetemplate/BundleServerPluginComponent.java @@ -25,13 +25,14 @@ import org.rhq.enterprise.server.plugin.pc.ControlFacet; import org.rhq.enterprise.server.plugin.pc.ControlResults; import org.rhq.enterprise.server.plugin.pc.ServerPluginComponent; import org.rhq.enterprise.server.plugin.pc.ServerPluginContext; +import org.rhq.enterprise.server.plugin.pc.bundle.BundleServerPluginFacet;
/** * A bundle server-side plugin component that the server uses to process file template bundles. * * @author John Mazzitelli */ -public class BundleServerPluginComponent implements ServerPluginComponent, ControlFacet { +public class BundleServerPluginComponent implements ServerPluginComponent, BundleServerPluginFacet, ControlFacet {
private ServerPluginContext context;
rhq-commits@lists.fedorahosted.org