modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/bundle/BundleAgentService.java | 34 ++++
modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataManager.java | 6
modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java | 20 ++
modules/core/client-api/src/main/java/org/rhq/core/clientapi/server/bundle/BundleServerService.java | 32 ++++
modules/core/client-api/src/main/resources/rhq-plugin.xsd | 16 ++
modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundleFacet.java | 31 +++
modules/core/plugin-container/src/main/java/org/rhq/core/pc/PluginContainer.java | 22 ++
modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java | 79 ++++++++++
modules/enterprise/server/ear/src/main/resources/server-comm-configuration.xml | 2
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleServerServiceImpl.java | 34 ++++
10 files changed, 274 insertions(+), 2 deletions(-)
New commits:
commit b8f76c60114b52087d80342636946d592664c817
Author: John Mazzitelli <mazz(a)redhat.com>
Date: Tue Feb 2 01:15:14 2010 -0500
initial start of the agent-side bundle subsystem. includes server side service impl/interface
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/bundle/BundleAgentService.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/bundle/BundleAgentService.java
new file mode 100644
index 0000000..d17a3ac
--- /dev/null
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/bundle/BundleAgentService.java
@@ -0,0 +1,34 @@
+/*
+ * 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, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * 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 and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.core.clientapi.agent.bundle;
+
+/**
+ * The interface to agent's bundle subsystem which allows the server to request
+ * the agent to perform tasks on a bundle (which is essentially a bundle of content
+ * that needs to be installed).
+ *
+ * @author John Mazzitelli
+ */
+public interface BundleAgentService {
+ void dummy();
+}
\ No newline at end of file
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataManager.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataManager.java
index 425c4da..7ba9673 100644
--- a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataManager.java
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataManager.java
@@ -33,6 +33,7 @@ import org.apache.commons.logging.LogFactory;
import org.jetbrains.annotations.Nullable;
import org.rhq.core.clientapi.descriptor.plugin.PluginDescriptor;
+import org.rhq.core.domain.bundle.BundleType;
import org.rhq.core.domain.resource.ResourceCategory;
import org.rhq.core.domain.resource.ResourceType;
@@ -97,6 +98,11 @@ public class PluginMetadataManager {
return (parser != null) ? parser.getComponentClass(resourceType) : null;
}
+ public BundleType getBundleType(ResourceType resourceType) {
+ PluginMetadataParser parser = this.parsersByPlugin.get(resourceType.getPlugin());
+ return (parser != null) ? parser.getBundleType(resourceType) : null;
+ }
+
/**
* Transforms the pluginDescriptor into domain object form and stores into this object's type system.
*
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java
index 5a9895a..348f9f5 100644
--- a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/agent/metadata/PluginMetadataParser.java
@@ -33,6 +33,7 @@ import java.util.Set;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.rhq.core.clientapi.descriptor.plugin.Bundle;
import org.rhq.core.clientapi.descriptor.plugin.ContentDescriptor;
import org.rhq.core.clientapi.descriptor.plugin.EventDescriptor;
import org.rhq.core.clientapi.descriptor.plugin.MetricDescriptor;
@@ -48,6 +49,7 @@ import org.rhq.core.clientapi.descriptor.plugin.RunsInsideType;
import org.rhq.core.clientapi.descriptor.plugin.ServerDescriptor;
import org.rhq.core.clientapi.descriptor.plugin.ServiceDescriptor;
import org.rhq.core.clientapi.descriptor.plugin.SubCategoryDescriptor;
+import org.rhq.core.domain.bundle.BundleType;
import org.rhq.core.domain.event.EventDefinition;
import org.rhq.core.domain.measurement.MeasurementDefinition;
import org.rhq.core.domain.resource.ClassLoaderType;
@@ -77,6 +79,7 @@ public class PluginMetadataParser {
// TODO: this isn't the most elegant... should we put these in the domain objects? or perhaps build another place for them to live?
private Map<ResourceType, String> discoveryClasses = new HashMap<ResourceType, String>();
private Map<ResourceType, String> componentClasses = new HashMap<ResourceType, String>();
+ private Map<ResourceType, BundleType> bundleTypes = new HashMap<ResourceType, BundleType>();
// a map keyed on plugin name that contains the parsers for all other known plugin descriptors
// this map is managed by this parser's PluginMetadataManager and is how the manager shares information
@@ -159,6 +162,12 @@ public class PluginMetadataParser {
+ "The <runs-inside> information will be ignored in resource type: " + platformResourceType);
}
+ Bundle bundle = platformDescriptor.getBundle();
+ if (bundle != null) {
+ String typeName = bundle.getType();
+ this.bundleTypes.put(platformResourceType, new BundleType(typeName, platformResourceType));
+ }
+
return platformResourceType;
}
@@ -581,6 +590,17 @@ public class PluginMetadataParser {
return this.componentClasses.get(resourceType);
}
+ /**
+ * Returns the type of bundle that the resource type can process, or <code>null</code> if there is no bundle type
+ * associated with a resource type.
+ *
+ * @param resourceType the ResourceType
+ * @return the bundle type
+ */
+ public BundleType getBundleType(ResourceType resourceType) {
+ return this.bundleTypes.get(resourceType);
+ }
+
private void registerResourceTypeAndComponentClasses(ResourceType resourceType, String discoveryClass,
String componentClass) {
this.resourceTypes.add(resourceType);
diff --git a/modules/core/client-api/src/main/java/org/rhq/core/clientapi/server/bundle/BundleServerService.java b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/server/bundle/BundleServerService.java
new file mode 100644
index 0000000..3726713
--- /dev/null
+++ b/modules/core/client-api/src/main/java/org/rhq/core/clientapi/server/bundle/BundleServerService.java
@@ -0,0 +1,32 @@
+/*
+ * 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, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * 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 and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.core.clientapi.server.bundle;
+
+/**
+ * Interface for agents to use when needing to inform the server about bundle tasks. Implementations of this interface, once registered with the
+ * plugin container, will received the requests that were issued updated with the operation results.
+ *
+ * @author John Mazzitelli
+ */
+public interface BundleServerService {
+}
\ No newline at end of file
diff --git a/modules/core/client-api/src/main/resources/rhq-plugin.xsd b/modules/core/client-api/src/main/resources/rhq-plugin.xsd
index b5b24e5..04fe173 100644
--- a/modules/core/client-api/src/main/resources/rhq-plugin.xsd
+++ b/modules/core/client-api/src/main/resources/rhq-plugin.xsd
@@ -646,6 +646,18 @@
<xs:complexContent>
<xs:extension base="rhq:resource">
<xs:sequence>
+ <xs:element name="bundle" type="rhq:bundle" minOccurs="0" maxOccurs="1">
+ <xs:annotation>
+ <xs:documentation>
+ Defines the type of bundle this resource can process. Resource components that support
+ bundles must implement BundleFacet.
+ </xs:documentation>
+ <xs:appinfo>
+ <jaxb:property name="bundle" />
+ </xs:appinfo>
+ </xs:annotation>
+ </xs:element>
+
<xs:element ref="rhq:server" minOccurs="0" maxOccurs="unbounded">
<xs:annotation>
<xs:documentation>
@@ -672,6 +684,10 @@
</xs:complexContent>
</xs:complexType>
+ <xs:complexType name="bundle">
+ <xs:attribute name="type" type="xs:string"/>
+ </xs:complexType>
+
<!-- SERVER -->
<xs:element name="server" type="rhq:server">
diff --git a/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundleFacet.java b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundleFacet.java
new file mode 100644
index 0000000..cb5ea35
--- /dev/null
+++ b/modules/core/plugin-api/src/main/java/org/rhq/core/pluginapi/bundle/BundleFacet.java
@@ -0,0 +1,31 @@
+/*
+ * 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, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * 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 and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.core.pluginapi.bundle;
+
+/**
+ * Facet that exposes a component's capabilities to process a bundle.
+ *
+ * @author John Mazzitelli
+ */
+public interface BundleFacet {
+}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/PluginContainer.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/PluginContainer.java
index 9962cd9..8970404 100644
--- a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/PluginContainer.java
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/PluginContainer.java
@@ -34,6 +34,7 @@ import java.util.concurrent.locks.ReentrantReadWriteLock;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.rhq.core.clientapi.agent.bundle.BundleAgentService;
import org.rhq.core.clientapi.agent.configuration.ConfigurationAgentService;
import org.rhq.core.clientapi.agent.content.ContentAgentService;
import org.rhq.core.clientapi.agent.discovery.DiscoveryAgentService;
@@ -45,6 +46,7 @@ import org.rhq.core.pc.agent.AgentRegistrar;
import org.rhq.core.pc.agent.AgentService;
import org.rhq.core.pc.agent.AgentServiceLifecycleListener;
import org.rhq.core.pc.agent.AgentServiceStreamRemoter;
+import org.rhq.core.pc.bundle.BundleManager;
import org.rhq.core.pc.configuration.ConfigurationManager;
import org.rhq.core.pc.configuration.ConfigurationManagerInitializer;
import org.rhq.core.pc.content.ContentManager;
@@ -93,6 +95,7 @@ public class PluginContainer implements ContainerService {
private ContentManager contentManager;
private EventManager eventManager;
private SupportManager supportManager;
+ private BundleManager bundleManager;
private Collection<AgentServiceLifecycleListener> agentServiceListeners = new LinkedHashSet<AgentServiceLifecycleListener>();
private AgentServiceStreamRemoter agentServiceStreamRemoter = null;
@@ -237,6 +240,7 @@ public class PluginContainer implements ContainerService {
contentManager = new ContentManager();
eventManager = new EventManager();
supportManager = new SupportManager();
+ bundleManager = new BundleManager();
startContainerService(pluginManager);
startContainerService(pluginComponentFactory);
@@ -248,6 +252,7 @@ public class PluginContainer implements ContainerService {
startContainerService(contentManager);
startContainerService(eventManager);
startContainerService(supportManager);
+ startContainerService(bundleManager);
started = true;
@@ -278,6 +283,7 @@ public class PluginContainer implements ContainerService {
boolean isInsideAgent = configuration.isInsideAgent();
+ bundleManager.shutdown();
supportManager.shutdown();
eventManager.shutdown();
contentManager.shutdown();
@@ -296,6 +302,7 @@ public class PluginContainer implements ContainerService {
ResourceContainer.shutdown();
+ bundleManager = null;
supportManager = null;
eventManager = null;
contentManager = null;
@@ -358,7 +365,7 @@ public class PluginContainer implements ContainerService {
if (containerService instanceof ConfigurationManager) {
ConfigurationManagerInitializer initializer = new ConfigurationManagerInitializer();
- initializer.initialize((ConfigurationManager)containerService);
+ initializer.initialize((ConfigurationManager) containerService);
}
}
@@ -508,6 +515,15 @@ public class PluginContainer implements ContainerService {
}
}
+ public BundleManager getBundleManager() {
+ Lock lock = obtainReadLock();
+ try {
+ return bundleManager;
+ } finally {
+ releaseLock(lock);
+ }
+ }
+
// The methods below return the manager implementations wrapped in their remote client interfaces.
// External clients to the plugin container should probably use these rather than the getXXXManager() methods.
@@ -539,6 +555,10 @@ public class PluginContainer implements ContainerService {
return getSupportManager();
}
+ public BundleAgentService getBundleAgentService() {
+ return getBundleManager();
+ }
+
public boolean isInsideAgent() {
return (this.configuration != null && this.configuration.isInsideAgent());
}
diff --git a/modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java
new file mode 100644
index 0000000..f2f8d98
--- /dev/null
+++ b/modules/core/plugin-container/src/main/java/org/rhq/core/pc/bundle/BundleManager.java
@@ -0,0 +1,79 @@
+/*
+ * RHQ Management
+ * 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, version 2, as
+ * published by the Free Software Foundation, and/or the GNU Lesser
+ * General Public License, version 2.1, also as published by the Free
+ * Software Foundation.
+ *
+ * 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 and the GNU Lesser General Public License
+ * for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * and the GNU Lesser General Public License along with this program;
+ * if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+package org.rhq.core.pc.bundle;
+
+import org.rhq.core.clientapi.agent.PluginContainerException;
+import org.rhq.core.clientapi.agent.bundle.BundleAgentService;
+import org.rhq.core.pc.ContainerService;
+import org.rhq.core.pc.PluginContainerConfiguration;
+import org.rhq.core.pc.agent.AgentService;
+import org.rhq.core.pc.util.ComponentUtil;
+import org.rhq.core.pc.util.FacetLockType;
+import org.rhq.core.pluginapi.bundle.BundleFacet;
+
+/**
+ * Manages the bundle subsystem, which allows bundles of content to be installed.
+ *
+ * <p>This is an agent service; its interface is made remotely accessible if this is deployed within the agent.</p>
+ *
+ * @author John Mazzitelli
+ */
+public class BundleManager extends AgentService implements BundleAgentService, ContainerService {
+
+ public BundleManager() {
+ super(BundleAgentService.class);
+ }
+
+ public void setConfiguration(PluginContainerConfiguration configuration) {
+ }
+
+ public void initialize() {
+ }
+
+ public void shutdown() {
+ }
+
+ /* (non-Javadoc)
+ * @see org.rhq.core.clientapi.agent.bundle.BundleAgentService#dummy()
+ */
+ public void dummy() {
+ // TODO Auto-generated method stub
+
+ }
+
+ /**
+ * Given a resource, this obtains that resource's {@link BundleFacet} interface.
+ * If the resource does not support that facet, an exception is thrown.
+ * The resource must be in the STARTED (i.e. connected) state.
+ *
+ * @param resourceId identifies the resource that is to perform the bundle activities
+ *
+ * @return the resource's bundle facet interface
+ *
+ * @throws PluginContainerException on error
+ */
+ protected BundleFacet getBundleFacet(int resourceId, long facetMethodTimeout) throws PluginContainerException {
+ return ComponentUtil.getComponent(resourceId, BundleFacet.class, FacetLockType.READ, facetMethodTimeout, false,
+ true);
+ }
+}
diff --git a/modules/enterprise/server/ear/src/main/resources/server-comm-configuration.xml b/modules/enterprise/server/ear/src/main/resources/server-comm-configuration.xml
index 93b49b4..c15c5cf 100644
--- a/modules/enterprise/server/ear/src/main/resources/server-comm-configuration.xml
+++ b/modules/enterprise/server/ear/src/main/resources/server-comm-configuration.xml
@@ -450,7 +450,7 @@ RHQ Server Communications Configuration
class.to.instantiate.via.noarg.constructor:interface.to.expose
-->
<entry key="rhq.communications.remote-pojos"
- value="org.rhq.enterprise.communications.PingImpl:org.rhq.enterprise.communications.Ping,org.rhq.enterprise.server.core.CoreServerServiceImpl:org.rhq.core.clientapi.server.core.CoreServerService,org.rhq.enterprise.server.discovery.DiscoveryServerServiceImpl:org.rhq.core.clientapi.server.discovery.DiscoveryServerService,org.rhq.enterprise.server.measurement.MeasurementServerServiceImpl:org.rhq.core.clientapi.server.measurement.MeasurementServerService,org.rhq.enterprise.server.operation.OperationServerServiceImpl:org.rhq.core.clientapi.server.operation.OperationServerService,org.rhq.enterprise.server.configuration.ConfigurationServerServiceImpl:org.rhq.core.clientapi.server.configuration.ConfigurationServerService,org.rhq.enterprise.server.resource.ResourceFactoryServerServiceImpl:org.rhq.core.clientapi.server.inventory.ResourceFactoryServerService,org.rhq.enterprise.server.content.ContentServerServiceImpl:org.rhq.core.clientapi.server.content.ContentServerService,org.rhq.enterprise.server.event.EventServerServiceImpl:org.rhq.core.clientapi.server.event.EventServerService" />
+ value="org.rhq.enterprise.communications.PingImpl:org.rhq.enterprise.communications.Ping,org.rhq.enterprise.server.core.CoreServerServiceImpl:org.rhq.core.clientapi.server.core.CoreServerService,org.rhq.enterprise.server.discovery.DiscoveryServerServiceImpl:org.rhq.core.clientapi.server.discovery.DiscoveryServerService,org.rhq.enterprise.server.measurement.MeasurementServerServiceImpl:org.rhq.core.clientapi.server.measurement.MeasurementServerService,org.rhq.enterprise.server.operation.OperationServerServiceImpl:org.rhq.core.clientapi.server.operation.OperationServerService,org.rhq.enterprise.server.configuration.ConfigurationServerServiceImpl:org.rhq.core.clientapi.server.configuration.ConfigurationServerService,org.rhq.enterprise.server.resource.ResourceFactoryServerServiceImpl:org.rhq.core.clientapi.server.inventory.ResourceFactoryServerService,org.rhq.enterprise.server.content.ContentServerServiceImpl:org.rhq.core.clientapi.server.content.ContentServerService,org.rhq.enterprise.server.event.EventServerServiceImpl:org.rhq.core.clientapi.server.event.EventServerService,org.rhq.enterprise.server.bundle.BundleServerServiceImpl:org.rhq.core.clientapi.server.bundle.BundleServerService" />
<!--
_______________________________________________________________
diff --git a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleServerServiceImpl.java b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleServerServiceImpl.java
new file mode 100644
index 0000000..21c60d1
--- /dev/null
+++ b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/bundle/BundleServerServiceImpl.java
@@ -0,0 +1,34 @@
+/*
+ * 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.bundle;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import org.rhq.core.clientapi.server.bundle.BundleServerService;
+
+/**
+ * Server-side implementation of the <code>BundleServerService</code>. This implmentation simply forwards
+ * the requests to the appropriate session bean.
+ *
+ * @author John Mazzitelli
+ */
+public class BundleServerServiceImpl implements BundleServerService {
+ private final Log log = LogFactory.getLog(this.getClass());
+}
\ No newline at end of file