From 906f386f09175b85d9eada8c34846d011607d782 Mon Sep 17 00:00:00 2001 From: Heiko Studt Date: Mon, 28 Aug 2023 12:23:09 +0200 Subject: [PATCH 1/3] all repositories to https --- .../application/runtime/itests/IsolatedCfgAdminRuntimeTest.java | 2 +- .../aries/application/runtime/itests/IsolatedRuntimeTest.java | 2 +- jmx/jmx-whiteboard/pom.xml | 2 +- parent/pom.xml | 2 +- sandbox/samples/dgoat/dgoat-web/pom.xml | 2 +- sandbox/samples/goat/goat-web/pom.xml | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/IsolatedCfgAdminRuntimeTest.java b/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/IsolatedCfgAdminRuntimeTest.java index 64d494d03e..07ce7b4044 100644 --- a/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/IsolatedCfgAdminRuntimeTest.java +++ b/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/IsolatedCfgAdminRuntimeTest.java @@ -371,7 +371,7 @@ public static Option[] configuration() throws Exception { mavenBundle("org.ops4j.pax.logging", "pax-logging-service").versionAsInProject(), // Repository - repository("http://repository.ops4j.org/maven2"), + repository("https://repository.ops4j.org/maven2"), // Logging systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"), diff --git a/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/IsolatedRuntimeTest.java b/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/IsolatedRuntimeTest.java index 68681d7320..685b140bd5 100644 --- a/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/IsolatedRuntimeTest.java +++ b/application/application-itests/src/test/java/org/apache/aries/application/runtime/itests/IsolatedRuntimeTest.java @@ -319,7 +319,7 @@ public static Option[] configuration() { mavenBundle("org.ops4j.pax.logging", "pax-logging-service").versionAsInProject(), // Repository - repository("http://repository.ops4j.org/maven2"), + repository("https://repository.ops4j.org/maven2"), // Logging systemProperty("org.ops4j.pax.logging.DefaultServiceLog.level").value("INFO"), diff --git a/jmx/jmx-whiteboard/pom.xml b/jmx/jmx-whiteboard/pom.xml index 1103faacc0..e850886249 100644 --- a/jmx/jmx-whiteboard/pom.xml +++ b/jmx/jmx-whiteboard/pom.xml @@ -253,7 +253,7 @@ ops4j ops4j - http://repository.ops4j.org/maven2 + https://repository.ops4j.org/maven2 false diff --git a/parent/pom.xml b/parent/pom.xml index ae7b535c9e..64e31395ff 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -88,7 +88,7 @@ EclipseLink Repo - http://download.eclipse.org/rt/eclipselink/maven.repo/ + https://download.eclipse.org/rt/eclipselink/maven.repo/ ops4j.sonatype.snapshots.deploy diff --git a/sandbox/samples/dgoat/dgoat-web/pom.xml b/sandbox/samples/dgoat/dgoat-web/pom.xml index bd53510cc9..7b66cbc5f2 100644 --- a/sandbox/samples/dgoat/dgoat-web/pom.xml +++ b/sandbox/samples/dgoat/dgoat-web/pom.xml @@ -143,7 +143,7 @@ dwr-snapshots DWR SNAPSHOT Repository - http://download.directwebremoting.org/maven2-snapshot/ + https://download.directwebremoting.org/maven2-snapshot/ diff --git a/sandbox/samples/goat/goat-web/pom.xml b/sandbox/samples/goat/goat-web/pom.xml index 5c950a6995..4887d42083 100644 --- a/sandbox/samples/goat/goat-web/pom.xml +++ b/sandbox/samples/goat/goat-web/pom.xml @@ -143,7 +143,7 @@ dwr-snapshots DWR SNAPSHOT Repository - http://download.directwebremoting.org/maven2-snapshot/ + https://download.directwebremoting.org/maven2-snapshot/ From b91080b14f5e27e6ae3d63c4598fbde3f628ae8d Mon Sep 17 00:00:00 2001 From: Heiko Studt Date: Mon, 28 Aug 2023 12:25:00 +0200 Subject: [PATCH 2/3] Snapshot versions --- proxy/proxy-itests/pom.xml | 4 ++-- subsystem/subsystem-scope-itests/pom.xml | 2 +- transaction/transaction-itests/pom.xml | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/proxy/proxy-itests/pom.xml b/proxy/proxy-itests/pom.xml index 0fdcaac7d4..85e26e8090 100644 --- a/proxy/proxy-itests/pom.xml +++ b/proxy/proxy-itests/pom.xml @@ -63,13 +63,13 @@ org.apache.aries.proxy org.apache.aries.proxy.api test - 1.1.1-SNAPSHOT + 1.1.2-SNAPSHOT org.apache.aries.proxy org.apache.aries.proxy test - 1.1.8-SNAPSHOT + 1.1.14-SNAPSHOT diff --git a/subsystem/subsystem-scope-itests/pom.xml b/subsystem/subsystem-scope-itests/pom.xml index accfb05893..77890a3d25 100644 --- a/subsystem/subsystem-scope-itests/pom.xml +++ b/subsystem/subsystem-scope-itests/pom.xml @@ -35,7 +35,7 @@ - 3.4.0 + 4.13.5 1.6.0 diff --git a/transaction/transaction-itests/pom.xml b/transaction/transaction-itests/pom.xml index c014f0556c..11c6e3120d 100644 --- a/transaction/transaction-itests/pom.xml +++ b/transaction/transaction-itests/pom.xml @@ -143,7 +143,7 @@ org.apache.aries.transaction org.apache.aries.transaction.blueprint test - 2.3.0-SNAPSHOT + 2.3.2-SNAPSHOT org.apache.aries.transaction From 9a9c15067d75a74ab9c8eb9e79fdc8a0652c9adf Mon Sep 17 00:00:00 2001 From: Heiko Studt Date: Mon, 28 Aug 2023 12:25:32 +0200 Subject: [PATCH 3/3] (Temp) ComponentDefinitionElementException --- blueprint/blueprint-parent/pom.xml | 6 +- .../ComponentDefinitionElementException.java | 97 +++++++++++ .../apache/aries/blueprint/parser/Parser.java | 155 ++++++++++++------ 3 files changed, 202 insertions(+), 56 deletions(-) create mode 100644 blueprint/blueprint-parser/src/main/java/org/apache/aries/blueprint/parser/ComponentDefinitionElementException.java diff --git a/blueprint/blueprint-parent/pom.xml b/blueprint/blueprint-parent/pom.xml index 4856bc5ab4..a203ac5648 100644 --- a/blueprint/blueprint-parent/pom.xml +++ b/blueprint/blueprint-parent/pom.xml @@ -45,9 +45,9 @@ 1.0.2-SNAPSHOT - 1.10.2-SNAPSHOT - 1.3.2-SNAPSHOT - 1.6.1-SNAPSHOT + 1.10.4-SNAPSHOT + 1.3.3-SNAPSHOT + 1.6.2-SNAPSHOT 1.0.1-SNAPSHOT 1.0.0-SNAPSHOT 1.0.0-SNAPSHOT diff --git a/blueprint/blueprint-parser/src/main/java/org/apache/aries/blueprint/parser/ComponentDefinitionElementException.java b/blueprint/blueprint-parser/src/main/java/org/apache/aries/blueprint/parser/ComponentDefinitionElementException.java new file mode 100644 index 0000000000..cde780d4ba --- /dev/null +++ b/blueprint/blueprint-parser/src/main/java/org/apache/aries/blueprint/parser/ComponentDefinitionElementException.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) OSGi Alliance (2008, 2009). All Rights Reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.apache.aries.blueprint.parser; + +import org.osgi.service.blueprint.container.ComponentDefinitionException; +import org.w3c.dom.Element; +import org.w3c.dom.Node; + +/** + * A ComponentDefinitionException with specifying a node in the blueprint XML. + * It will expand the explanation with the node but does not store the node. + * + * @version $Revision$ + */ +public class ComponentDefinitionElementException extends ComponentDefinitionException { + + private static final long serialVersionUID = 1L; + + /** + * Creates a Component Definition Exception with no message or exception + * cause. + */ + public ComponentDefinitionElementException() { + super(); + } + + /** + * Creates a Component Definition Exception with the specified message. + * The node is regarded as the cause path and will be added to the explanation. + * + * @param node The element path in which the exception originates. + * @param explanation The associated message. + */ + public ComponentDefinitionElementException(Node node, String explanation) { + super(getElementPathForError(node) + ": " + explanation); + } + + /** + * Creates a Component Definition Exception with the specified message and + * exception cause. + * The node is regarded as the cause path and will be added to the explanation. + * + * @param node The element path in which the exception originates. + * @param explanation The associated message. + * @param cause The cause of this exception. + */ + public ComponentDefinitionElementException(Node node, String explanation, Throwable cause) { + super(getElementPathForError(node) + ": " + explanation, cause); + } + + private static String getElementPathForError(Node node) { + if (node == null) { + return ""; + } + StringBuilder result = new StringBuilder(); + while (node != null) { + if (node instanceof Element) { + Element element = (Element) node; + + String errorElement = "<" + + element.getLocalName() + // the following are possibly helping attributes to find the malfunction path + + getErrorPathAttributeString(element, Parser.ID_ATTRIBUTE) + + getErrorPathAttributeString(element, Parser.NAME_ATTRIBUTE) + + getErrorPathAttributeString(element, Parser.KEY_ATTRIBUTE) + + getErrorPathAttributeString(element, Parser.CLASS_ATTRIBUTE) + + ">"; + result.insert(0, errorElement); // prefix the parent + } + node = node.getParentNode(); + } + return result.toString(); + } + + private static String getErrorPathAttributeString(Element element, String attributeName) { + if (element.hasAttribute(attributeName)) { + return " " + attributeName + + "=\"" + element.getAttribute(attributeName) + "\""; + } + return ""; + } + +} diff --git a/blueprint/blueprint-parser/src/main/java/org/apache/aries/blueprint/parser/Parser.java b/blueprint/blueprint-parser/src/main/java/org/apache/aries/blueprint/parser/Parser.java index 3afcf5030e..41d3349b06 100644 --- a/blueprint/blueprint-parser/src/main/java/org/apache/aries/blueprint/parser/Parser.java +++ b/blueprint/blueprint-parser/src/main/java/org/apache/aries/blueprint/parser/Parser.java @@ -428,7 +428,8 @@ private void loadComponents(Document doc) { Metadata component = parseCustomElement(element, null); if (component != null) { if (!(component instanceof ComponentMetadata)) { - throw new ComponentDefinitionException("Expected a ComponentMetadata to be returned when parsing element " + element.getNodeName()); + throw new ComponentDefinitionElementException(element, + "Expected a ComponentMetadata to be returned when parsing element " + element.getNodeName()); } registry.registerComponentDefinition((ComponentMetadata) component); } @@ -471,7 +472,8 @@ public T parseElement(Class type, ComponentMetadata enclosingComponent, E } else if (Metadata.class.isAssignableFrom(type)) { return type.cast(parseValueGroup(element, enclosingComponent, null, true)); } else { - throw new ComponentDefinitionException("Unknown type to parse element: " + type.getName()); + throw new ComponentDefinitionElementException(element, + "Unknown type to parse element: " + type.getName()); } } @@ -493,7 +495,8 @@ private void parseBlueprintElement(Element element) { ComponentMetadata references = parseRefList(element, true); registry.registerComponentDefinition(references); } else { - throw new ComponentDefinitionException("Unknown element " + element.getNodeName() + " in namespace " + BLUEPRINT_NAMESPACE); + throw new ComponentDefinitionElementException(element, + "Unknown element " + element.getNodeName() + " in namespace " + BLUEPRINT_NAMESPACE); } } @@ -517,7 +520,8 @@ private void parseTypeConverters(Element element) { target = parseCustomElement(e, null); } if (!(target instanceof Target)) { - throw new ComponentDefinitionException("Metadata parsed for element " + e.getNodeName() + " can not be used as a type converter"); + throw new ComponentDefinitionElementException(e, + "Metadata parsed for element " + e.getNodeName() + " can not be used as a type converter"); } registry.registerTypeConverter((Target) target); } @@ -542,7 +546,8 @@ private URI getNamespaceForAttributeValue(Node attrNode) throws ComponentDefinit if(uriStr!=null){ uri = URI.create(uriStr); }else{ - throw new ComponentDefinitionException("Unsupported attribute namespace prefix "+parts[0]+" "+attr); + throw new ComponentDefinitionElementException(attrNode, + "Unsupported attribute namespace prefix " + parts[0] + " " + attr); } } } @@ -570,10 +575,10 @@ private String getScope(Node attrNode) throws ComponentDefinitionException { if(namespaceURI!=null){ scope = new QName(namespaceURI, localName).toString(); }else{ - throw new ComponentDefinitionException("Unable to determine namespace binding for prefix, " + prefix); + throw new ComponentDefinitionElementException(attrNode, + "Unable to determine namespace binding for prefix, " + prefix); } - } - else { + }else{ scope = attrValue; } } @@ -604,7 +609,8 @@ private ComponentMetadata handleCustomScope(Node scope, Element bean, ComponentM ParserContextImpl context = new ParserContextImpl(this, registry, metadata, scope); metadata = nsHandler.decorate(scope, metadata, context); }else if(scopeNS!=null){ - throw new ComponentDefinitionException("Custom scopes cannot use the blueprint namespace "+scope); + throw new ComponentDefinitionElementException(bean, + "Custom scopes cannot use the blueprint namespace " + scope); } return metadata; } @@ -618,7 +624,8 @@ private ComponentMetadata parseBeanMetadata(Element element, boolean topElement) if (!metadata.getScope().equals(BeanMetadata.SCOPE_SINGLETON)) { if (element.hasAttribute(ACTIVATION_ATTRIBUTE)) { if (element.getAttribute(ACTIVATION_ATTRIBUTE).equals(ACTIVATION_EAGER)) { - throw new ComponentDefinitionException("A with a prototype or custom scope can not have an eager activation"); + throw new ComponentDefinitionElementException(element, + "A with a prototype or custom scope can not have an eager activation"); } } metadata.setActivation(ComponentMetadata.ACTIVATION_LAZY); @@ -653,13 +660,16 @@ private ComponentMetadata parseBeanMetadata(Element element, boolean topElement) // Do some validation if (metadata.getClassName() == null && metadata.getFactoryComponent() == null) { - throw new ComponentDefinitionException("Bean class or factory-ref must be specified"); + throw new ComponentDefinitionElementException(element, + "Bean class or factory-ref must be specified"); } if (metadata.getFactoryComponent() != null && metadata.getFactoryMethod() == null) { - throw new ComponentDefinitionException("factory-method is required when factory-component is set"); + throw new ComponentDefinitionElementException(element, + "factory-method is required when factory-component is set"); } if (MetadataUtil.isPrototypeScope(metadata) && metadata.getDestroyMethod() != null) { - throw new ComponentDefinitionException("destroy-method must not be set for a with a prototype scope"); + throw new ComponentDefinitionElementException(element, + "destroy-method must not be set for a with a prototype scope"); } // Parse elements @@ -736,13 +746,15 @@ private ComponentMetadata parseService(Element element, boolean topElement) { } else if (AUTO_EXPORT_ALL.equals(autoExport)) { service.setAutoExport(ServiceMetadata.AUTO_EXPORT_ALL_CLASSES); } else { - throw new ComponentDefinitionException("Illegal value (" + autoExport + ") for " + AUTO_EXPORT_ATTRIBUTE + " attribute"); + throw new ComponentDefinitionElementException(element, + "Illegal value (" + autoExport + ") for " + AUTO_EXPORT_ATTRIBUTE + " attribute"); } String ranking = element.hasAttribute(RANKING_ATTRIBUTE) ? element.getAttribute(RANKING_ATTRIBUTE) : RANKING_DEFAULT; try { service.setRanking(Integer.parseInt(ranking)); } catch (NumberFormatException e) { - throw new ComponentDefinitionException("Attribute " + RANKING_ATTRIBUTE + " must be a valid integer (was: " + ranking + ")"); + throw new ComponentDefinitionElementException(element, + "Attribute " + RANKING_ATTRIBUTE + " must be a valid integer (was: " + ranking + ")"); } // Parse elements NodeList nl = element.getChildNodes(); @@ -753,7 +765,8 @@ private ComponentMetadata parseService(Element element, boolean topElement) { if (isBlueprintNamespace(e.getNamespaceURI())) { if (nodeNameEquals(e, INTERFACES_ELEMENT)) { if (hasInterfaceNameAttribute) { - throw new ComponentDefinitionException("Only one of " + INTERFACE_ATTRIBUTE + " attribute or " + INTERFACES_ELEMENT + " element must be used"); + throw new ComponentDefinitionElementException(e, + "Only one of " + INTERFACE_ATTRIBUTE + " attribute or " + INTERFACES_ELEMENT + " element must be used"); } service.setInterfaceNames(parseInterfaceNames(e)); } else if (nodeNameEquals(e, SERVICE_PROPERTIES_ELEMENT)) { @@ -763,21 +776,25 @@ private ComponentMetadata parseService(Element element, boolean topElement) { service.addRegistrationListener(parseRegistrationListener(e, service)); } else if (nodeNameEquals(e, BEAN_ELEMENT)) { if (service.getServiceComponent() != null) { - throw new ComponentDefinitionException("Only one of " + REF_ATTRIBUTE + " attribute, " + BEAN_ELEMENT + " element, " + REFERENCE_ELEMENT + " element or " + REF_ELEMENT + " element can be set"); + throw new ComponentDefinitionElementException(e, + "Only one of " + REF_ATTRIBUTE + " attribute, " + BEAN_ELEMENT + " element, " + REFERENCE_ELEMENT + " element or " + REF_ELEMENT + " element can be set"); } service.setServiceComponent((Target) parseBeanMetadata(e, false)); } else if (nodeNameEquals(e, REF_ELEMENT)) { if (service.getServiceComponent() != null) { - throw new ComponentDefinitionException("Only one of " + REF_ATTRIBUTE + " attribute, " + BEAN_ELEMENT + " element, " + REFERENCE_ELEMENT + " element or " + REF_ELEMENT + " element can be set"); + throw new ComponentDefinitionElementException(e, + "Only one of " + REF_ATTRIBUTE + " attribute, " + BEAN_ELEMENT + " element, " + REFERENCE_ELEMENT + " element or " + REF_ELEMENT + " element can be set"); } String component = e.getAttribute(COMPONENT_ID_ATTRIBUTE); if (component == null || component.length() == 0) { - throw new ComponentDefinitionException("Element " + REF_ELEMENT + " must have a valid " + COMPONENT_ID_ATTRIBUTE + " attribute"); + throw new ComponentDefinitionElementException(e, + "Element " + REF_ELEMENT + " must have a valid " + COMPONENT_ID_ATTRIBUTE + " attribute"); } service.setServiceComponent(new RefMetadataImpl(component)); } else if (nodeNameEquals(e, REFERENCE_ELEMENT)) { if (service.getServiceComponent() != null) { - throw new ComponentDefinitionException("Only one of " + REF_ATTRIBUTE + " attribute, " + BEAN_ELEMENT + " element, " + REFERENCE_ELEMENT + " element or " + REF_ELEMENT + " element can be set"); + throw new ComponentDefinitionElementException(e, + "Only one of " + REF_ATTRIBUTE + " attribute, " + BEAN_ELEMENT + " element, " + REFERENCE_ELEMENT + " element or " + REF_ELEMENT + " element can be set"); } service.setServiceComponent((Target) parseReference(e, false)); } @@ -786,15 +803,18 @@ private ComponentMetadata parseService(Element element, boolean topElement) { } // Check service if (service.getServiceComponent() == null) { - throw new ComponentDefinitionException("One of " + REF_ATTRIBUTE + " attribute, " + BEAN_ELEMENT + " element, " + REFERENCE_ELEMENT + " element or " + REF_ELEMENT + " element must be set"); + throw new ComponentDefinitionElementException(element, + "One of " + REF_ATTRIBUTE + " attribute, " + BEAN_ELEMENT + " element, " + REFERENCE_ELEMENT + " element or " + REF_ELEMENT + " element must be set"); } // Check interface if (service.getAutoExport() == ServiceMetadata.AUTO_EXPORT_DISABLED && service.getInterfaces().isEmpty()) { - throw new ComponentDefinitionException(INTERFACE_ATTRIBUTE + " attribute or " + INTERFACES_ELEMENT + " element must be set when " + AUTO_EXPORT_ATTRIBUTE + " is set to " + AUTO_EXPORT_DISABLED); + throw new ComponentDefinitionElementException(element, + INTERFACE_ATTRIBUTE + " attribute or " + INTERFACES_ELEMENT + " element must be set when " + AUTO_EXPORT_ATTRIBUTE + " is set to " + AUTO_EXPORT_DISABLED); } // Check for non-disabled auto-exports and interfaces if (service.getAutoExport() != ServiceMetadata.AUTO_EXPORT_DISABLED && !service.getInterfaces().isEmpty()) { - throw new ComponentDefinitionException(INTERFACE_ATTRIBUTE + " attribute or " + INTERFACES_ELEMENT + " element must not be set when " + AUTO_EXPORT_ATTRIBUTE + " is set to anything else than " + AUTO_EXPORT_DISABLED); + throw new ComponentDefinitionElementException(element, + INTERFACE_ATTRIBUTE + " attribute or " + INTERFACES_ELEMENT + " element must not be set when " + AUTO_EXPORT_ATTRIBUTE + " is set to anything else than " + AUTO_EXPORT_DISABLED); } ComponentMetadata s = service; @@ -854,7 +874,8 @@ public PropsMetadata parseProps(Element element) { private MapEntry parseProperty(Element element) { // Parse attributes if (!element.hasAttribute(KEY_ATTRIBUTE)) { - throw new ComponentDefinitionException(KEY_ATTRIBUTE + " attribute is required"); + throw new ComponentDefinitionElementException(element, + KEY_ATTRIBUTE + " attribute is required"); } String value; if (element.hasAttribute(VALUE_ATTRIBUTE)) { @@ -908,7 +929,8 @@ private MapEntry parseMapEntry(Element element, ComponentMetadata enclosingCompo } // Check key if (keyValue != null && (key != null || keyRef != null) || (keyValue == null && key == null && keyRef == null)) { - throw new ComponentDefinitionException("Only and only one of " + KEY_ATTRIBUTE + " attribute, " + KEY_REF_ATTRIBUTE + " attribute or " + KEY_ELEMENT + " element must be set"); + throw new ComponentDefinitionElementException(element, + "Only and only one of " + KEY_ATTRIBUTE + " attribute, " + KEY_REF_ATTRIBUTE + " attribute or " + KEY_ELEMENT + " element must be set"); } else if (keyValue == null && key != null) { keyValue = new ValueMetadataImpl(key, keyType); } else if (keyValue == null /*&& keyRef != null*/) { @@ -916,7 +938,8 @@ private MapEntry parseMapEntry(Element element, ComponentMetadata enclosingCompo } // Check value if (valValue != null && (value != null || valueRef != null) || (valValue == null && value == null && valueRef == null)) { - throw new ComponentDefinitionException("Only and only one of " + VALUE_ATTRIBUTE + " attribute, " + VALUE_REF_ATTRIBUTE + " attribute or sub element must be set"); + throw new ComponentDefinitionElementException(element, + "Only and only one of " + VALUE_ATTRIBUTE + " attribute, " + VALUE_REF_ATTRIBUTE + " attribute or sub element must be set"); } else if (valValue == null && value != null) { valValue = new ValueMetadataImpl(value, valueType); } else if (valValue == null /*&& valueRef != null*/) { @@ -970,7 +993,8 @@ public RegistrationListener parseRegistrationListener(Element element, Component listener.setUnregistrationMethod(unregistrationMethod); } if (registrationMethod == null && unregistrationMethod == null) { - throw new ComponentDefinitionException("One of " + REGISTRATION_METHOD_ATTRIBUTE + " or " + UNREGISTRATION_METHOD_ATTRIBUTE + " must be set"); + throw new ComponentDefinitionElementException(element, + "One of " + REGISTRATION_METHOD_ATTRIBUTE + " or " + UNREGISTRATION_METHOD_ATTRIBUTE + " must be set"); } // Parse elements NodeList nl = element.getChildNodes(); @@ -981,39 +1005,46 @@ public RegistrationListener parseRegistrationListener(Element element, Component if (isBlueprintNamespace(e.getNamespaceURI())) { if (nodeNameEquals(e, REF_ELEMENT)) { if (listenerComponent != null) { - throw new ComponentDefinitionException("Only one of " + REF_ATTRIBUTE + " attribute, " + REF_ELEMENT + ", " + BEAN_ELEMENT + ", " + REFERENCE_ELEMENT + ", " + SERVICE_ELEMENT + " or custom element can be set"); + throw new ComponentDefinitionElementException(e, + "Only one of " + REF_ATTRIBUTE + " attribute, " + REF_ELEMENT + ", " + BEAN_ELEMENT + ", " + REFERENCE_ELEMENT + ", " + SERVICE_ELEMENT + " or custom element can be set"); } String component = e.getAttribute(COMPONENT_ID_ATTRIBUTE); if (component == null || component.length() == 0) { - throw new ComponentDefinitionException("Element " + REF_ELEMENT + " must have a valid " + COMPONENT_ID_ATTRIBUTE + " attribute"); + throw new ComponentDefinitionElementException(e, + "Element " + REF_ELEMENT + " must have a valid " + COMPONENT_ID_ATTRIBUTE + " attribute"); } listenerComponent = new RefMetadataImpl(component); } else if (nodeNameEquals(e, BEAN_ELEMENT)) { if (listenerComponent != null) { - throw new ComponentDefinitionException("Only one of " + REF_ATTRIBUTE + " attribute, " + REF_ELEMENT + ", " + BEAN_ELEMENT + ", " + REFERENCE_ELEMENT + ", " + SERVICE_ELEMENT + " or custom element can be set"); + throw new ComponentDefinitionElementException(e, + "Only one of " + REF_ATTRIBUTE + " attribute, " + REF_ELEMENT + ", " + BEAN_ELEMENT + ", " + REFERENCE_ELEMENT + ", " + SERVICE_ELEMENT + " or custom element can be set"); } listenerComponent = parseBeanMetadata(e, false); } else if (nodeNameEquals(e, REFERENCE_ELEMENT)) { if (listenerComponent != null) { - throw new ComponentDefinitionException("Only one of " + REF_ATTRIBUTE + " attribute, " + REF_ELEMENT + ", " + BEAN_ELEMENT + ", " + REFERENCE_ELEMENT + ", " + SERVICE_ELEMENT + " or custom element can be set"); + throw new ComponentDefinitionElementException(e, + "Only one of " + REF_ATTRIBUTE + " attribute, " + REF_ELEMENT + ", " + BEAN_ELEMENT + ", " + REFERENCE_ELEMENT + ", " + SERVICE_ELEMENT + " or custom element can be set"); } listenerComponent = parseReference(e, false); } else if (nodeNameEquals(e, SERVICE_ELEMENT)) { if (listenerComponent != null) { - throw new ComponentDefinitionException("Only one of " + REF_ATTRIBUTE + " attribute, " + REF_ELEMENT + ", " + BEAN_ELEMENT + ", " + REFERENCE_ELEMENT + ", " + SERVICE_ELEMENT + " or custom element can be set"); + throw new ComponentDefinitionElementException(e, + "Only one of " + REF_ATTRIBUTE + " attribute, " + REF_ELEMENT + ", " + BEAN_ELEMENT + ", " + REFERENCE_ELEMENT + ", " + SERVICE_ELEMENT + " or custom element can be set"); } listenerComponent = parseService(e, false); } } else { if (listenerComponent != null) { - throw new ComponentDefinitionException("Only one of " + REF_ATTRIBUTE + " attribute, " + REF_ELEMENT + ", " + BEAN_ELEMENT + ", " + REFERENCE_ELEMENT + ", " + SERVICE_ELEMENT + " or custom element can be set"); + throw new ComponentDefinitionElementException(e, + "Only one of " + REF_ATTRIBUTE + " attribute, " + REF_ELEMENT + ", " + BEAN_ELEMENT + ", " + REFERENCE_ELEMENT + ", " + SERVICE_ELEMENT + " or custom element can be set"); } listenerComponent = parseCustomElement(e, enclosingComponent); } } } if (listenerComponent == null) { - throw new ComponentDefinitionException("One of " + REF_ATTRIBUTE + " attribute, " + REF_ELEMENT + ", " + BEAN_ELEMENT + ", " + REFERENCE_ELEMENT + ", " + SERVICE_ELEMENT + " or custom element must be set"); + throw new ComponentDefinitionElementException(element, + "One of " + REF_ATTRIBUTE + " attribute, " + REF_ELEMENT + ", " + BEAN_ELEMENT + ", " + REFERENCE_ELEMENT + ", " + SERVICE_ELEMENT + " or custom element must be set"); } listener.setListenerComponent((Target) listenerComponent); return listener; @@ -1029,7 +1060,8 @@ private ComponentMetadata parseReference(Element element, boolean topElement) { try { reference.setTimeout(Long.parseLong(timeout)); } catch (NumberFormatException e) { - throw new ComponentDefinitionException("Attribute " + TIMEOUT_ATTRIBUTE + " must be a valid long (was: " + timeout + ")"); + throw new ComponentDefinitionElementException(element, + "Attribute " + TIMEOUT_ATTRIBUTE + " must be a valid long (was: " + timeout + ")"); } ComponentMetadata r = reference; @@ -1108,7 +1140,8 @@ private void parseReference(Element element, ServiceReferenceMetadataImpl refere } else if (AVAILABILITY_OPTIONAL.equals(availability)) { reference.setAvailability(ServiceReferenceMetadata.AVAILABILITY_OPTIONAL); } else { - throw new ComponentDefinitionException("Illegal value for " + AVAILABILITY_ATTRIBUTE + " attribute: " + availability); + throw new ComponentDefinitionElementException(element, + "Illegal value for " + AVAILABILITY_ATTRIBUTE + " attribute: " + availability); } // Parse elements NodeList nl = element.getChildNodes(); @@ -1143,7 +1176,8 @@ private ReferenceListener parseServiceListener(Element element, ComponentMetadat listener.setUnbindMethod(unbindMethodName); } if (bindMethodName == null && unbindMethodName == null) { - throw new ComponentDefinitionException("One of " + BIND_METHOD_ATTRIBUTE + " or " + UNBIND_METHOD_ATTRIBUTE + " must be set"); + throw new ComponentDefinitionElementException(element, + "One of " + BIND_METHOD_ATTRIBUTE + " or " + UNBIND_METHOD_ATTRIBUTE + " must be set"); } // Parse elements NodeList nl = element.getChildNodes(); @@ -1154,39 +1188,46 @@ private ReferenceListener parseServiceListener(Element element, ComponentMetadat if (isBlueprintNamespace(e.getNamespaceURI())) { if (nodeNameEquals(e, REF_ELEMENT)) { if (listenerComponent != null) { - throw new ComponentDefinitionException("Only one of " + REF_ATTRIBUTE + " attribute, " + REF_ELEMENT + ", " + BLUEPRINT_ELEMENT + ", " + REFERENCE_ELEMENT + ", " + SERVICE_ELEMENT + " or custom element can be set"); + throw new ComponentDefinitionElementException(e, + "Only one of " + REF_ATTRIBUTE + " attribute, " + REF_ELEMENT + ", " + BLUEPRINT_ELEMENT + ", " + REFERENCE_ELEMENT + ", " + SERVICE_ELEMENT + " or custom element can be set"); } String component = e.getAttribute(COMPONENT_ID_ATTRIBUTE); if (component == null || component.length() == 0) { - throw new ComponentDefinitionException("Element " + REF_ELEMENT + " must have a valid " + COMPONENT_ID_ATTRIBUTE + " attribute"); + throw new ComponentDefinitionElementException(e, + "Element " + REF_ELEMENT + " must have a valid " + COMPONENT_ID_ATTRIBUTE + " attribute"); } listenerComponent = new RefMetadataImpl(component); } else if (nodeNameEquals(e, BEAN_ELEMENT)) { if (listenerComponent != null) { - throw new ComponentDefinitionException("Only one of " + REF_ATTRIBUTE + " attribute, " + REF_ELEMENT + ", " + BLUEPRINT_ELEMENT + ", " + REFERENCE_ELEMENT + ", " + SERVICE_ELEMENT + " or custom element can be set"); + throw new ComponentDefinitionElementException(e, + "Only one of " + REF_ATTRIBUTE + " attribute, " + REF_ELEMENT + ", " + BLUEPRINT_ELEMENT + ", " + REFERENCE_ELEMENT + ", " + SERVICE_ELEMENT + " or custom element can be set"); } listenerComponent = parseBeanMetadata(e, false); } else if (nodeNameEquals(e, REFERENCE_ELEMENT)) { if (listenerComponent != null) { - throw new ComponentDefinitionException("Only one of " + REF_ATTRIBUTE + " attribute, " + REF_ELEMENT + ", " + BLUEPRINT_ELEMENT + ", " + REFERENCE_ELEMENT + ", " + SERVICE_ELEMENT + " or custom element can be set"); + throw new ComponentDefinitionElementException(e, + "Only one of " + REF_ATTRIBUTE + " attribute, " + REF_ELEMENT + ", " + BLUEPRINT_ELEMENT + ", " + REFERENCE_ELEMENT + ", " + SERVICE_ELEMENT + " or custom element can be set"); } listenerComponent = parseReference(e, false); } else if (nodeNameEquals(e, SERVICE_ELEMENT)) { if (listenerComponent != null) { - throw new ComponentDefinitionException("Only one of " + REF_ATTRIBUTE + " attribute, " + REF_ELEMENT + ", " + BLUEPRINT_ELEMENT + ", " + REFERENCE_ELEMENT + ", " + SERVICE_ELEMENT + " or custom element can be set"); + throw new ComponentDefinitionElementException(e, + "Only one of " + REF_ATTRIBUTE + " attribute, " + REF_ELEMENT + ", " + BLUEPRINT_ELEMENT + ", " + REFERENCE_ELEMENT + ", " + SERVICE_ELEMENT + " or custom element can be set"); } listenerComponent = parseService(e, false); } } else { if (listenerComponent != null) { - throw new ComponentDefinitionException("Only one of " + REF_ATTRIBUTE + " attribute, " + REF_ELEMENT + ", " + BLUEPRINT_ELEMENT + ", " + REFERENCE_ELEMENT + ", " + SERVICE_ELEMENT + " or custom element can be set"); + throw new ComponentDefinitionElementException(e, + "Only one of " + REF_ATTRIBUTE + " attribute, " + REF_ELEMENT + ", " + BLUEPRINT_ELEMENT + ", " + REFERENCE_ELEMENT + ", " + SERVICE_ELEMENT + " or custom element can be set"); } listenerComponent = parseCustomElement(e, enclosingComponent); } } } if (listenerComponent == null) { - throw new ComponentDefinitionException("One of " + REF_ATTRIBUTE + " attribute, " + REF_ELEMENT + ", " + BLUEPRINT_ELEMENT + ", " + REFERENCE_ELEMENT + ", " + SERVICE_ELEMENT + " or custom element must be set"); + throw new ComponentDefinitionElementException(element, + "One of " + REF_ATTRIBUTE + " attribute, " + REF_ELEMENT + ", " + BLUEPRINT_ELEMENT + ", " + REFERENCE_ELEMENT + ", " + SERVICE_ELEMENT + " or custom element must be set"); } listener.setListenerComponent((Target) listenerComponent); return listener; @@ -1202,11 +1243,13 @@ public List parseInterfaceNames(Element element) { if (nodeNameEquals(e, VALUE_ELEMENT)) { String v = getTextValue(e).trim(); if (interfaceNames.contains(v)) { - throw new ComponentDefinitionException("The element " + INTERFACES_ELEMENT + " should not contain the same interface twice"); + throw new ComponentDefinitionElementException(element, + "The element " + INTERFACES_ELEMENT + " should not contain the same interface twice"); } interfaceNames.add(getTextValue(e)); } else { - throw new ComponentDefinitionException("Unsupported element " + e.getNodeName() + " inside an " + INTERFACES_ELEMENT + " element"); + throw new ComponentDefinitionElementException(element, + "Unsupported element " + e.getNodeName() + " inside an " + INTERFACES_ELEMENT + " element"); } } } @@ -1244,15 +1287,17 @@ private Metadata parseArgumentOrPropertyValue(Element element, ComponentMetadata if (value == null) { value = v; } else { - throw new ComponentDefinitionException("Only one of " + REF_ATTRIBUTE + " attribute, " + VALUE_ATTRIBUTE + " attribute or sub element must be set"); + throw new ComponentDefinitionElementException(element, + "Only one of " + REF_ATTRIBUTE + " attribute, " + VALUE_ATTRIBUTE + " attribute or sub element must be set"); } } } if (value == null) { - throw new ComponentDefinitionException("One of " + REF_ATTRIBUTE + " attribute, " + VALUE_ATTRIBUTE + " attribute or sub element must be set"); + throw new ComponentDefinitionElementException(element, + "One of " + REF_ATTRIBUTE + " attribute, " + VALUE_ATTRIBUTE + " attribute or sub element must be set"); } - + return value; } @@ -1285,7 +1330,8 @@ private Metadata parseValueGroup(Element element, ComponentMetadata enclosingCom } else if (nodeNameEquals(element, ARRAY_ELEMENT)) { return parseArray(element, enclosingComponent); } else { - throw new ComponentDefinitionException("Unknown blueprint element " + element.getNodeName()); + throw new ComponentDefinitionElementException(element, + "Unknown blueprint element " + element.getNodeName()); } } else { return parseCustomElement(element, enclosingComponent); @@ -1305,14 +1351,16 @@ private ValueMetadata parseValue(Element element, String collectionType) { private RefMetadata parseRef(Element element) { String component = element.getAttribute(COMPONENT_ID_ATTRIBUTE); if (component == null || component.length() == 0) { - throw new ComponentDefinitionException("Element " + REF_ELEMENT + " must have a valid " + COMPONENT_ID_ATTRIBUTE + " attribute"); + throw new ComponentDefinitionElementException(element, + "Element " + REF_ELEMENT + " must have a valid " + COMPONENT_ID_ATTRIBUTE + " attribute"); } return new RefMetadataImpl(component); } private Metadata parseIdRef(Element element) { String component = element.getAttribute(COMPONENT_ID_ATTRIBUTE); if (component == null || component.length() == 0) { - throw new ComponentDefinitionException("Element " + IDREF_ELEMENT + " must have a valid " + COMPONENT_ID_ATTRIBUTE + " attribute"); + throw new ComponentDefinitionElementException(element, + "Element " + IDREF_ELEMENT + " must have a valid " + COMPONENT_ID_ATTRIBUTE + " attribute"); } return new IdRefMetadataImpl(component); } @@ -1324,7 +1372,8 @@ private int parseActivation(Element element) { } else if (ACTIVATION_LAZY.equals(initialization)) { return ComponentMetadata.ACTIVATION_LAZY; } else { - throw new ComponentDefinitionException("Attribute " + ACTIVATION_ATTRIBUTE + " must be equal to " + ACTIVATION_EAGER + " or " + ACTIVATION_LAZY); + throw new ComponentDefinitionElementException(element, + "Attribute " + ACTIVATION_ATTRIBUTE + " must be equal to " + ACTIVATION_EAGER + " or " + ACTIVATION_LAZY); } }