summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/builder/src/main
diff options
context:
space:
mode:
authorslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2010-07-27 09:05:26 +0000
committerslaws <slaws@13f79535-47bb-0310-9956-ffa450edef68>2010-07-27 09:05:26 +0000
commite1ac47593af2b7e377aaffe3183d4d29658a6e88 (patch)
tree95ac9e0ceefa441a7f553b2cc037082b043f9800 /sca-java-2.x/trunk/modules/builder/src/main
parent897af0d35e57cea2955421d5d3299267859f92af (diff)
Some defensive code to avert an NPE that's now causing ASM_8005, ASM_8017, ASM_8018 to fail. It's not clear why this code is being hit now when it wasn't previously.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@979597 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/builder/src/main')
-rw-r--r--sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java38
1 files changed, 31 insertions, 7 deletions
diff --git a/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java b/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java
index 13e30f7f78..ec9683a030 100644
--- a/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java
+++ b/sca-java-2.x/trunk/modules/builder/src/main/java/org/apache/tuscany/sca/builder/impl/ComponentBuilderImpl.java
@@ -270,7 +270,7 @@ public class ComponentBuilderImpl {
calculateBindings(component, componentService, componentTypeService, context);
// add callback reference model objects
- createCallbackReference(component, componentService);
+ createCallbackReference(component, componentService, monitor);
}
}
@@ -312,7 +312,7 @@ public class ComponentBuilderImpl {
calculateBindings(componentReference, componentTypeReference);
// add callback service model objects
- createCallbackService(component, componentReference);
+ createCallbackService(component, componentReference, monitor);
// Propagate autowire setting from the component down the structural
// hierarchy
@@ -1156,12 +1156,12 @@ public class ComponentBuilderImpl {
* @param component
* @param service
*/
- private void createCallbackReference(Component component, ComponentService service) {
+ private void createCallbackReference(Component component, ComponentService service, Monitor monitor) {
// if the service has a callback interface create a reference
// to represent the callback
if (service.getInterfaceContract() != null && // can be null in unit tests
- service.getInterfaceContract().getCallbackInterface() != null) {
+ service.getInterfaceContract().getCallbackInterface() != null) {
ComponentReference callbackReference = assemblyFactory.createComponentReference();
callbackReference.setForCallback(true);
@@ -1197,7 +1197,19 @@ public class ComponentBuilderImpl {
if (((CompositeService)implService).getPromotedService().isUnresolved() == false){
String referenceName = ((CompositeService)implService).getPromotedService().getName();
ComponentReference promotedReference = ((CompositeService)implService).getPromotedComponent().getReference(referenceName);
- implCompReference.getPromotedReferences().add(promotedReference);
+
+ if (promotedReference != null){
+ implCompReference.getPromotedReferences().add(promotedReference);
+ } else {
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "PromotedCallbackReferenceNotFound",
+ component.getName(),
+ service.getName(),
+ ((CompositeService)implService).getPromotedComponent().getName(),
+ referenceName);
+ }
}
implReference = implCompReference;
@@ -1263,7 +1275,7 @@ public class ComponentBuilderImpl {
* @param component
* @param service
*/
- private void createCallbackService(Component component, ComponentReference reference) {
+ private void createCallbackService(Component component, ComponentReference reference, Monitor monitor) {
if (reference.getInterfaceContract() != null && // can be null in unit tests
reference.getInterfaceContract().getCallbackInterface() != null) {
ComponentService callbackService = assemblyFactory.createComponentService();
@@ -1299,7 +1311,19 @@ public class ComponentBuilderImpl {
if (((CompositeReference)implReference).getPromotedReferences().get(0).isUnresolved() == false){
String serviceName = ((CompositeReference)implReference).getPromotedReferences().get(0).getName();
ComponentService promotedService = ((CompositeReference)implReference).getPromotedComponents().get(0).getService(serviceName);
- implCompService.setPromotedService(promotedService);
+
+ if (promotedService != null){
+ implCompService.setPromotedService(promotedService);
+ } else {
+ Monitor.error(monitor,
+ this,
+ Messages.ASSEMBLY_VALIDATION,
+ "PromotedCallbackServiceNotFound",
+ component.getName(),
+ reference.getName(),
+ ((CompositeReference)implReference).getPromotedComponents().get(0).getName(),
+ serviceName);
+ }
}
implService = implCompService;