Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Commit

Permalink
[BZ 1069547] Support for API-based bundle handlers
Browse files Browse the repository at this point in the history
This is to support new type of dedicated bundle handlers able to do more
than just file-system modifications. In order to enable them to e.g.
connect to some remote endpoint, a more complex configuration data needs
to be passed over.

This creates coupling between the bundle destination definition and the
handler that is able to deploy to such destinations (because it needs to be
able to use the configuration offered by the destination definition) but
that is unavoidable given the specific things the handlers would be doing.

* The resource types can use the new "destination-definition" tag under
bundle target to define new type of destinations that can use
a "connection string" expression + can pass all or parts of resource or
plugin configs or traits to the bundle handler.

* The agent-side bundle handlers have access to the bundle deployment
configuration even in the purge scenario. This is to support the more
complex bundle handlers needing the config to better identify the bundle
deployment.

* The deploy directory is no longer a required argument when creating a
bundle destination. This is because for the API based bundle handlers,
such configuration property might not make any sense and would only create
confusion on the user side.

* It is no longer required for the server bundle plugins to come up with
the full list of the required files upon reading the recipe alone.
The bundle plugins can therefore choose whether they support piece-wise
upload of the bundle version or only support uploading a full bundle
distribution file.
  • Loading branch information
metlos committed Jul 11, 2014
1 parent e103ea0 commit b10ccc1
Show file tree
Hide file tree
Showing 19 changed files with 1,729 additions and 292 deletions.
Expand Up @@ -31,12 +31,17 @@
import java.util.Map;
import java.util.Set;

import javax.xml.bind.JAXBElement;

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.BundleConfigFullCopy;
import org.rhq.core.clientapi.descriptor.plugin.BundleConfigPropertyReference;
import org.rhq.core.clientapi.descriptor.plugin.BundleTargetDescriptor;
import org.rhq.core.clientapi.descriptor.plugin.BundleTargetDescriptor.DestinationBaseDir;
import org.rhq.core.clientapi.descriptor.plugin.BundleTraitReference;
import org.rhq.core.clientapi.descriptor.plugin.ContentDescriptor;
import org.rhq.core.clientapi.descriptor.plugin.DiscoveryCallbacksType;
import org.rhq.core.clientapi.descriptor.plugin.DiscoveryTypeCallbackType;
Expand Down Expand Up @@ -612,17 +617,75 @@ private void parseResourceDescriptor(ResourceDescriptor resourceDescriptor, Reso

BundleTargetDescriptor bundleTarget = resourceDescriptor.getBundleTarget();
if (bundleTarget != null) {
List<DestinationBaseDir> destBaseDirs = bundleTarget.getDestinationBaseDir();
if (destBaseDirs != null && destBaseDirs.size() > 0) {
List<Object> destDefs = bundleTarget.getDestinationBaseDirOrDestinationDefinition();
if (destDefs != null && destDefs.size() > 0) {
Configuration c = new Configuration();
ResourceTypeBundleConfiguration bundleConfiguration = new ResourceTypeBundleConfiguration(c);
for (DestinationBaseDir destBaseDir : destBaseDirs) {
String name = destBaseDir.getName();
String valueContext = destBaseDir.getValueContext();
String valueName = destBaseDir.getValueName();
String description = destBaseDir.getDescription();
bundleConfiguration.addBundleDestinationBaseDirectory(name, valueContext, valueName,
description);
for (Object destDef : destDefs) {
if (destDef instanceof DestinationBaseDir) {
DestinationBaseDir destBaseDir = (DestinationBaseDir) destDef;
String name = destBaseDir.getName();
String valueContext = destBaseDir.getValueContext();
String valueName = destBaseDir.getValueName();
String description = destBaseDir.getDescription();
bundleConfiguration.addBundleDestinationBaseDirectory(name, valueContext, valueName,
description);
} else if (destDef instanceof BundleTargetDescriptor.DestinationDefinition) {
BundleTargetDescriptor.DestinationDefinition def =
(BundleTargetDescriptor.DestinationDefinition) destDef;

ResourceTypeBundleConfiguration.BundleDestinationDefinition.Builder bld = bundleConfiguration
.createDestinationDefinitionBuilder(def.getName());
bld.withDescription(def.getDescription()).withConnectionString(def.getConnection());

for (JAXBElement<?> ref : def.getReferencedConfiguration()
.getMapPropertyRefOrListPropertyRefOrSimplePropertyRef()) {

String tagName = ref.getName().getLocalPart();
if ("simple-property-ref".equals(tagName)) {
BundleConfigPropertyReference r = (BundleConfigPropertyReference) ref.getValue();
if ("pluginConfiguration".equals(r.getContext())) {
bld.addPluginConfigurationSimplePropertyReference(r.getName(),
r.getTargetName());
} else if ("resourceConfiguration".equals(r.getContext())) {
bld.addResourceConfigurationSimplePropertyReference(r.getName(),
r.getTargetName());
}
} else if ("list-property-ref".equals(tagName)) {
BundleConfigPropertyReference r = (BundleConfigPropertyReference) ref.getValue();
if ("pluginConfiguration".equals(r.getContext())) {
bld.addPluginConfigurationListPropertyReference(r.getName(),
r.getTargetName());
} else if ("resourceConfiguration".equals(r.getContext())) {
bld.addResourceConfigurationListPropertyReference(r.getName(),
r.getTargetName());
}
} else if ("map-property-ref".equals(tagName)) {
BundleConfigPropertyReference r = (BundleConfigPropertyReference) ref.getValue();
if ("pluginConfiguration".equals(r.getContext())) {
bld.addPluginConfigurationMapPropertyReference(r.getName(),
r.getTargetName());
} else if ("resourceConfiguration".equals(r.getContext())) {
bld.addResourceConfigurationMapPropertyReference(r.getName(),
r.getTargetName());
}
} else if ("trait-ref".equals(tagName)) {
BundleTraitReference r = (BundleTraitReference) ref.getValue();
bld.addMeasurementTraitReference(r.getName(), r.getTargetName());
} else if ("all".equals(tagName)) {
BundleConfigFullCopy r = (BundleConfigFullCopy) ref.getValue();
if ("pluginConfiguration".equals(r.getOf())) {
bld.addFullPluginConfigurationReference(r.getPrefix());
} else if ("resourceConfiguration".equals(r.getOf())) {
bld.addFullResourceConfigurationReference(r.getPrefix());
} else if ("traits".equals(r.getOf())) {
bld.addFullMeasurementTraitsReference(r.getPrefix());
}
}
}

bld.build();
}
}
resourceType.setResourceTypeBundleConfiguration(bundleConfiguration);
}
Expand Down Expand Up @@ -879,4 +942,4 @@ private CreateDeletePolicy convertCreateDeletePolicy(ResourceCreateDeletePolicy
public void cleanDescriptor() {
pluginDescriptor=null;
}
}
}

0 comments on commit b10ccc1

Please sign in to comment.