You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by sv...@apache.org on 2008/02/18 15:10:22 UTC
svn commit: r628749 - in
/incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml:
BaseAssemblyProcessor.java CompositeProcessor.java
Author: svkrish
Date: Mon Feb 18 06:10:22 2008
New Revision: 628749
URL: http://svn.apache.org/viewvc?rev=628749&view=rev
Log:
adding code for resolution of intents and policysets specified in the componentType
Modified:
incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java
incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java
Modified: incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java?rev=628749&r1=628748&r2=628749&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java (original)
+++ incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/BaseAssemblyProcessor.java Mon Feb 18 06:10:22 2008
@@ -244,6 +244,32 @@
if (implementation.isUnresolved()) {
extensionProcessor.resolve(implementation, resolver);
if (!implementation.isUnresolved()) {
+ //resolve policies
+ if ( implementation instanceof PolicySetAttachPoint ) {
+ PolicySetAttachPoint policiedImpl = (PolicySetAttachPoint)implementation;
+ resolveIntents(policiedImpl.getRequiredIntents(), resolver);
+ resolvePolicySets(policiedImpl.getPolicySets(), resolver);
+ validatePolicySets(policiedImpl);
+
+ for ( Service service : implementation.getServices() ) {
+ resolveIntents(service.getRequiredIntents(), resolver);
+ resolvePolicySets(service.getPolicySets(), resolver);
+ validatePolicySets(service, policiedImpl.getApplicablePolicySets());
+
+ for ( ConfiguredOperation svcOp : service.getConfiguredOperations() ) {
+ resolveIntents(svcOp.getRequiredIntents(), resolver);
+ resolvePolicySets(svcOp.getPolicySets(), resolver);
+ validatePolicySets(svcOp, policiedImpl.getApplicablePolicySets());
+ }
+ }
+
+ for ( Reference reference : implementation.getReferences() ) {
+ resolveIntents(reference.getRequiredIntents(), resolver);
+ resolvePolicySets(reference.getPolicySets(), resolver);
+ validatePolicySets(reference, policiedImpl.getApplicablePolicySets());
+ }
+ }
+
resolver.addModel(implementation);
}
}
@@ -318,7 +344,7 @@
resolvePolicySets(policiedBinding.getPolicySets(), resolver);
//validate if attached policysets apply to the binding
resolvePolicySets(policiedBinding.getApplicablePolicySets(), resolver);
- validatePolicySets(contract, policiedBinding);
+ validatePolicySets(policiedBinding);
}
if (binding instanceof OperationsConfigurator) {
OperationsConfigurator opConfigurator = (OperationsConfigurator)binding;
@@ -352,7 +378,7 @@
PolicySetAttachPoint policiedBinding = (PolicySetAttachPoint)binding;
resolvePolicySets(policiedBinding.getPolicySets(), resolver);
resolvePolicySets(policiedBinding.getApplicablePolicySets(), resolver);
- validatePolicySets(contract.getCallback(), policiedBinding);
+ validatePolicySets(policiedBinding);
}
if (binding instanceof OperationsConfigurator) {
OperationsConfigurator opConfigurator = (OperationsConfigurator)binding;
@@ -675,14 +701,22 @@
}
}
- protected void validatePolicySets(Base parent, PolicySetAttachPoint policySetAttachPoint) throws ContributionResolveException {
+
+ protected void validatePolicySets(PolicySetAttachPoint policySetAttachPoint)
+ throws ContributionResolveException {
+ validatePolicySets(policySetAttachPoint, policySetAttachPoint.getApplicablePolicySets());
+ }
+
+
+ protected void validatePolicySets(PolicySetAttachPoint policySetAttachPoint,
+ List<PolicySet> applicablePolicySets) throws ContributionResolveException {
//Since the applicablePolicySets in a policySetAttachPoint will already have the
//list of policysets that might ever be applicable to this attachPoint, just check
//if the defined policysets feature in the list of applicable policysets
IntentAttachPointType attachPointType = policySetAttachPoint.getType();
for ( PolicySet definedPolicySet : policySetAttachPoint.getPolicySets() ) {
if ( !definedPolicySet.isUnresolved() ) {
- if ( !policySetAttachPoint.getApplicablePolicySets().contains(definedPolicySet)) {
+ if ( !applicablePolicySets.contains(definedPolicySet)) {
throw new ContributionResolveException("Policy Set '" + definedPolicySet.getName()
+ "' does not apply to binding type "
+ attachPointType.getName());
Modified: incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java?rev=628749&r1=628748&r2=628749&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java (original)
+++ incubator/tuscany/java/sca/modules/assembly-xml/src/main/java/org/apache/tuscany/sca/assembly/xml/CompositeProcessor.java Mon Feb 18 06:10:22 2008
@@ -804,6 +804,13 @@
//resolve component implemenation
Implementation implementation = component.getImplementation();
if (implementation != null) {
+ //resolve intents and policysets specified on this implementation
+ //before copying them over to the component. Before that, from the component
+ //copy over the applicablePolicySets alone as it might have to be
+ //used to validate the policysets specified on the implementation
+
+ resolveImplIntentsAndPolicySets(implementation, component.getApplicablePolicySets(), resolver);
+
copyPoliciesToComponent(component, implementation, resolver);
//now resolve the implementation so that even if there is a shared instance
@@ -821,27 +828,46 @@
}
}
+ private void resolveImplIntentsAndPolicySets(Implementation implementation,
+ List<PolicySet> inheritedApplicablePolicySets,
+ ModelResolver resolver) throws ContributionResolveException
+ {
+ if ( implementation instanceof PolicySetAttachPoint ) {
+ PolicySetAttachPoint policiedImpl = (PolicySetAttachPoint)implementation;
+
+ policiedImpl.getApplicablePolicySets().addAll(inheritedApplicablePolicySets);
+
+ resolveIntents(policiedImpl.getRequiredIntents(), resolver);
+ resolvePolicySets(policiedImpl.getPolicySets(), resolver);
+ resolvePolicySets(policiedImpl.getApplicablePolicySets(), resolver);
+ validatePolicySets(policiedImpl);
+
+ if ( implementation instanceof OperationsConfigurator ) {
+ for ( ConfiguredOperation implConfOp : ((OperationsConfigurator)implementation).getConfiguredOperations() ) {
+ resolveIntents(implConfOp.getRequiredIntents(), resolver);
+ resolvePolicySets(implConfOp.getPolicySets(), resolver);
+ resolvePolicySets(implConfOp.getApplicablePolicySets(), resolver);
+ validatePolicySets(implConfOp, policiedImpl.getApplicablePolicySets());
+ }
+ }
+ }
+ }
+
private void copyPoliciesToComponent(Component component,
Implementation implementation,
ModelResolver resolver) throws ContributionResolveException {
if (implementation instanceof PolicySetAttachPoint) {
- resolveIntents(((PolicySetAttachPoint)implementation).getRequiredIntents(), resolver);
- resolvePolicySets(((PolicySetAttachPoint)implementation).getPolicySets(), resolver);
- resolvePolicySets(((PolicySetAttachPoint)implementation).getApplicablePolicySets(), resolver);
- validatePolicySets(component, (PolicySetAttachPoint)implementation);
//add implementation policies into component... since implementation instance are
//reused and its likely that this implementation instance will not hold after its resolution
component.getRequiredIntents().addAll(((PolicySetAttachPoint)implementation).getRequiredIntents());
component.getPolicySets().addAll(((PolicySetAttachPoint)implementation).getPolicySets());
component.getApplicablePolicySets().addAll(((PolicySetAttachPoint)implementation).getApplicablePolicySets());
+
if ( implementation instanceof OperationsConfigurator ) {
boolean notFound;
List<ConfiguredOperation> opsFromImplementation = new ArrayList<ConfiguredOperation>();
for ( ConfiguredOperation implConfOp : ((OperationsConfigurator)implementation).getConfiguredOperations() ) {
notFound = true;
- resolveIntents(implConfOp.getRequiredIntents(), resolver);
- resolvePolicySets(implConfOp.getPolicySets(), resolver);
- resolvePolicySets(implConfOp.getApplicablePolicySets(), resolver);
for ( ConfiguredOperation compConfOp : ((OperationsConfigurator)component).getConfiguredOperations() ) {
if ( implConfOp.getName().equals(compConfOp.getName()) ) {
notFound = false;
@@ -860,8 +886,6 @@
}
((PolicySetAttachPoint)implementation).getRequiredIntents().clear();
((PolicySetAttachPoint)implementation).getPolicySets().clear();
- ((PolicySetAttachPoint)implementation).getApplicablePolicySets().clear();
-
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org