|
|
07b8b2 |
From 73145d799492ba1ae5553cd92a5f13af07896107 Mon Sep 17 00:00:00 2001
|
|
|
07b8b2 |
From: Mat Booth <mat.booth@redhat.com>
|
|
|
07b8b2 |
Date: Wed, 22 Jan 2020 18:34:26 +0000
|
|
|
07b8b2 |
Subject: [PATCH 2/2] Drop the dependencies on kxml/xpp3
|
|
|
07b8b2 |
|
|
|
07b8b2 |
Instead we use the SAX parser implementation from the JDK
|
|
|
07b8b2 |
|
|
|
07b8b2 |
Signed-off-by: Mat Booth <mat.booth@redhat.com>
|
|
|
07b8b2 |
---
|
|
|
07b8b2 |
bnd.bnd | 2 -
|
|
|
07b8b2 |
pom.xml | 6 -
|
|
|
07b8b2 |
.../scr/impl/BundleComponentActivator.java | 13 +-
|
|
|
07b8b2 |
.../scr/impl/parser/KXml2SAXHandler.java | 69 ------
|
|
|
07b8b2 |
.../felix/scr/impl/parser/KXml2SAXParser.java | 177 --------------
|
|
|
07b8b2 |
.../felix/scr/impl/parser/ParseException.java | 29 ---
|
|
|
07b8b2 |
.../apache/felix/scr/impl/xml/XmlHandler.java | 228 +++++++-----------
|
|
|
07b8b2 |
7 files changed, 99 insertions(+), 425 deletions(-)
|
|
|
07b8b2 |
delete mode 100644 src/main/java/org/apache/felix/scr/impl/parser/KXml2SAXHandler.java
|
|
|
07b8b2 |
delete mode 100644 src/main/java/org/apache/felix/scr/impl/parser/KXml2SAXParser.java
|
|
|
07b8b2 |
delete mode 100644 src/main/java/org/apache/felix/scr/impl/parser/ParseException.java
|
|
|
07b8b2 |
|
|
|
07b8b2 |
diff --git a/bnd.bnd b/bnd.bnd
|
|
|
07b8b2 |
index ae3fadb..299eb73 100644
|
|
|
07b8b2 |
--- a/bnd.bnd
|
|
|
07b8b2 |
+++ b/bnd.bnd
|
|
|
07b8b2 |
@@ -47,5 +47,3 @@ DynamicImport-Package: \
|
|
|
07b8b2 |
org.osgi.service.cm;version="[1.6,2)", \
|
|
|
07b8b2 |
org.osgi.service.log;version="[1.3,2)", \
|
|
|
07b8b2 |
org.osgi.service.metatype;version="[1.1,2)"
|
|
|
07b8b2 |
-
|
|
|
07b8b2 |
-Embed-Dependency: kxml2;inline=org/kxml2/io/KXmlParser.class|org/xmlpull/v1/XmlPull**
|
|
|
07b8b2 |
diff --git a/pom.xml b/pom.xml
|
|
|
07b8b2 |
index 682b07a..16819c7 100644
|
|
|
07b8b2 |
--- a/pom.xml
|
|
|
07b8b2 |
+++ b/pom.xml
|
|
|
07b8b2 |
@@ -129,12 +129,6 @@
|
|
|
07b8b2 |
<version>1.0.0</version>
|
|
|
07b8b2 |
<scope>provided</scope>
|
|
|
07b8b2 |
</dependency>
|
|
|
07b8b2 |
- <dependency>
|
|
|
07b8b2 |
- <groupId>net.sf.kxml</groupId>
|
|
|
07b8b2 |
- <artifactId>kxml2</artifactId>
|
|
|
07b8b2 |
- <version>2.2.2</version>
|
|
|
07b8b2 |
- <scope>provided</scope>
|
|
|
07b8b2 |
- </dependency>
|
|
|
07b8b2 |
|
|
|
07b8b2 |
|
|
|
07b8b2 |
<dependency>
|
|
|
07b8b2 |
diff --git a/src/main/java/org/apache/felix/scr/impl/BundleComponentActivator.java b/src/main/java/org/apache/felix/scr/impl/BundleComponentActivator.java
|
|
|
07b8b2 |
index 4a8c94a..9a5259f 100644
|
|
|
07b8b2 |
--- a/src/main/java/org/apache/felix/scr/impl/BundleComponentActivator.java
|
|
|
07b8b2 |
+++ b/src/main/java/org/apache/felix/scr/impl/BundleComponentActivator.java
|
|
|
07b8b2 |
@@ -18,10 +18,8 @@
|
|
|
07b8b2 |
*/
|
|
|
07b8b2 |
package org.apache.felix.scr.impl;
|
|
|
07b8b2 |
|
|
|
07b8b2 |
-import java.io.BufferedReader;
|
|
|
07b8b2 |
import java.io.IOException;
|
|
|
07b8b2 |
import java.io.InputStream;
|
|
|
07b8b2 |
-import java.io.InputStreamReader;
|
|
|
07b8b2 |
import java.net.URL;
|
|
|
07b8b2 |
import java.util.ArrayList;
|
|
|
07b8b2 |
import java.util.Collections;
|
|
|
07b8b2 |
@@ -34,6 +32,9 @@ import java.util.concurrent.CountDownLatch;
|
|
|
07b8b2 |
import java.util.concurrent.TimeUnit;
|
|
|
07b8b2 |
import java.util.concurrent.atomic.AtomicBoolean;
|
|
|
07b8b2 |
|
|
|
07b8b2 |
+import javax.xml.parsers.SAXParser;
|
|
|
07b8b2 |
+import javax.xml.parsers.SAXParserFactory;
|
|
|
07b8b2 |
+
|
|
|
07b8b2 |
import org.apache.felix.scr.impl.helper.ConfigAdminTracker;
|
|
|
07b8b2 |
import org.apache.felix.scr.impl.logger.BundleLogger;
|
|
|
07b8b2 |
import org.apache.felix.scr.impl.logger.ComponentLogger;
|
|
|
07b8b2 |
@@ -47,7 +48,6 @@ import org.apache.felix.scr.impl.manager.ExtendedServiceListener;
|
|
|
07b8b2 |
import org.apache.felix.scr.impl.manager.RegionConfigurationSupport;
|
|
|
07b8b2 |
import org.apache.felix.scr.impl.manager.ScrConfiguration;
|
|
|
07b8b2 |
import org.apache.felix.scr.impl.metadata.ComponentMetadata;
|
|
|
07b8b2 |
-import org.apache.felix.scr.impl.parser.KXml2SAXParser;
|
|
|
07b8b2 |
import org.apache.felix.scr.impl.xml.XmlHandler;
|
|
|
07b8b2 |
import org.osgi.framework.Bundle;
|
|
|
07b8b2 |
import org.osgi.framework.BundleContext;
|
|
|
07b8b2 |
@@ -420,12 +420,13 @@ public class BundleComponentActivator implements ComponentActivator
|
|
|
07b8b2 |
{
|
|
|
07b8b2 |
stream = descriptorURL.openStream();
|
|
|
07b8b2 |
|
|
|
07b8b2 |
- BufferedReader in = new BufferedReader( new InputStreamReader( stream, "UTF-8" ) );
|
|
|
07b8b2 |
XmlHandler handler = new XmlHandler( m_bundle, this.logger, getConfiguration().isFactoryEnabled(),
|
|
|
07b8b2 |
getConfiguration().keepInstances() );
|
|
|
07b8b2 |
- final KXml2SAXParser parser = new KXml2SAXParser( in );
|
|
|
07b8b2 |
+ final SAXParserFactory factory = SAXParserFactory.newInstance();
|
|
|
07b8b2 |
+ factory.setNamespaceAware(true);
|
|
|
07b8b2 |
+ final SAXParser parser = factory.newSAXParser();
|
|
|
07b8b2 |
|
|
|
07b8b2 |
- parser.parseXML( handler );
|
|
|
07b8b2 |
+ parser.parse( stream, handler );
|
|
|
07b8b2 |
|
|
|
07b8b2 |
// 112.4.2 Component descriptors may contain a single, root component element
|
|
|
07b8b2 |
// or one or more component elements embedded in a larger document
|
|
|
07b8b2 |
diff --git a/src/main/java/org/apache/felix/scr/impl/parser/KXml2SAXHandler.java b/src/main/java/org/apache/felix/scr/impl/parser/KXml2SAXHandler.java
|
|
|
07b8b2 |
deleted file mode 100644
|
|
|
07b8b2 |
index b6e4c36..0000000
|
|
|
07b8b2 |
--- a/src/main/java/org/apache/felix/scr/impl/parser/KXml2SAXHandler.java
|
|
|
07b8b2 |
+++ /dev/null
|
|
|
07b8b2 |
@@ -1,69 +0,0 @@
|
|
|
07b8b2 |
-/*
|
|
|
07b8b2 |
- * Licensed to the Apache Software Foundation (ASF) under one
|
|
|
07b8b2 |
- * or more contributor license agreements. See the NOTICE file
|
|
|
07b8b2 |
- * distributed with this work for additional information
|
|
|
07b8b2 |
- * regarding copyright ownership. The ASF licenses this file
|
|
|
07b8b2 |
- * to you under the Apache License, Version 2.0 (the
|
|
|
07b8b2 |
- * "License"); you may not use this file except in compliance
|
|
|
07b8b2 |
- * with the License. You may obtain a copy of the License at
|
|
|
07b8b2 |
- *
|
|
|
07b8b2 |
- * http://www.apache.org/licenses/LICENSE-2.0
|
|
|
07b8b2 |
- *
|
|
|
07b8b2 |
- * Unless required by applicable law or agreed to in writing,
|
|
|
07b8b2 |
- * software distributed under the License is distributed on an
|
|
|
07b8b2 |
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
07b8b2 |
- * KIND, either express or implied. See the License for the
|
|
|
07b8b2 |
- * specific language governing permissions and limitations
|
|
|
07b8b2 |
- * under the License.
|
|
|
07b8b2 |
- */
|
|
|
07b8b2 |
-package org.apache.felix.scr.impl.parser;
|
|
|
07b8b2 |
-
|
|
|
07b8b2 |
-import org.apache.felix.scr.impl.parser.KXml2SAXParser.Attributes;
|
|
|
07b8b2 |
-
|
|
|
07b8b2 |
-/**
|
|
|
07b8b2 |
- * Interface for a SAX like handler with kXML
|
|
|
07b8b2 |
- */
|
|
|
07b8b2 |
-public interface KXml2SAXHandler {
|
|
|
07b8b2 |
-
|
|
|
07b8b2 |
- /**
|
|
|
07b8b2 |
- * Method called when parsing text
|
|
|
07b8b2 |
- *
|
|
|
07b8b2 |
- * @param text
|
|
|
07b8b2 |
- * @exception ParseException
|
|
|
07b8b2 |
- */
|
|
|
07b8b2 |
- void characters(String text) throws ParseException;
|
|
|
07b8b2 |
-
|
|
|
07b8b2 |
- /**
|
|
|
07b8b2 |
- * Method called when a tag opens
|
|
|
07b8b2 |
- *
|
|
|
07b8b2 |
- * @param uri
|
|
|
07b8b2 |
- * @param localName
|
|
|
07b8b2 |
- * @param attributes
|
|
|
07b8b2 |
- * @exception ParseException
|
|
|
07b8b2 |
- */
|
|
|
07b8b2 |
- void startElement(
|
|
|
07b8b2 |
- String uri,
|
|
|
07b8b2 |
- String localName,
|
|
|
07b8b2 |
- Attributes attributes)
|
|
|
07b8b2 |
- throws ParseException;
|
|
|
07b8b2 |
-
|
|
|
07b8b2 |
- /**
|
|
|
07b8b2 |
- * Method called when a tag closes
|
|
|
07b8b2 |
- *
|
|
|
07b8b2 |
- * @param uri
|
|
|
07b8b2 |
- * @param localName
|
|
|
07b8b2 |
- * @exception ParseException
|
|
|
07b8b2 |
- */
|
|
|
07b8b2 |
- void endElement(
|
|
|
07b8b2 |
- String uri,
|
|
|
07b8b2 |
- String localName)
|
|
|
07b8b2 |
- throws ParseException;
|
|
|
07b8b2 |
-
|
|
|
07b8b2 |
- void processingInstruction(String target,
|
|
|
07b8b2 |
- String data)
|
|
|
07b8b2 |
- throws Exception;
|
|
|
07b8b2 |
-
|
|
|
07b8b2 |
- void setLineNumber(int lineNumber);
|
|
|
07b8b2 |
-
|
|
|
07b8b2 |
- void setColumnNumber(int columnNumber);
|
|
|
07b8b2 |
-}
|
|
|
07b8b2 |
diff --git a/src/main/java/org/apache/felix/scr/impl/parser/KXml2SAXParser.java b/src/main/java/org/apache/felix/scr/impl/parser/KXml2SAXParser.java
|
|
|
07b8b2 |
deleted file mode 100644
|
|
|
07b8b2 |
index 39717c8..0000000
|
|
|
07b8b2 |
--- a/src/main/java/org/apache/felix/scr/impl/parser/KXml2SAXParser.java
|
|
|
07b8b2 |
+++ /dev/null
|
|
|
07b8b2 |
@@ -1,177 +0,0 @@
|
|
|
07b8b2 |
-/*
|
|
|
07b8b2 |
- * Licensed to the Apache Software Foundation (ASF) under one
|
|
|
07b8b2 |
- * or more contributor license agreements. See the NOTICE file
|
|
|
07b8b2 |
- * distributed with this work for additional information
|
|
|
07b8b2 |
- * regarding copyright ownership. The ASF licenses this file
|
|
|
07b8b2 |
- * to you under the Apache License, Version 2.0 (the
|
|
|
07b8b2 |
- * "License"); you may not use this file except in compliance
|
|
|
07b8b2 |
- * with the License. You may obtain a copy of the License at
|
|
|
07b8b2 |
- *
|
|
|
07b8b2 |
- * http://www.apache.org/licenses/LICENSE-2.0
|
|
|
07b8b2 |
- *
|
|
|
07b8b2 |
- * Unless required by applicable law or agreed to in writing,
|
|
|
07b8b2 |
- * software distributed under the License is distributed on an
|
|
|
07b8b2 |
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
07b8b2 |
- * KIND, either express or implied. See the License for the
|
|
|
07b8b2 |
- * specific language governing permissions and limitations
|
|
|
07b8b2 |
- * under the License.
|
|
|
07b8b2 |
- */
|
|
|
07b8b2 |
-package org.apache.felix.scr.impl.parser;
|
|
|
07b8b2 |
-
|
|
|
07b8b2 |
-
|
|
|
07b8b2 |
-import java.io.Reader;
|
|
|
07b8b2 |
-import java.util.Stack;
|
|
|
07b8b2 |
-
|
|
|
07b8b2 |
-import org.kxml2.io.KXmlParser;
|
|
|
07b8b2 |
-import org.xmlpull.v1.XmlPullParser;
|
|
|
07b8b2 |
-import org.xmlpull.v1.XmlPullParserException;
|
|
|
07b8b2 |
-
|
|
|
07b8b2 |
-
|
|
|
07b8b2 |
-/**
|
|
|
07b8b2 |
- * The KXml2SAXParser extends the XmlParser from kxml. This is a very
|
|
|
07b8b2 |
- * simple parser that does not take into account the DTD
|
|
|
07b8b2 |
- *
|
|
|
07b8b2 |
- */
|
|
|
07b8b2 |
-public class KXml2SAXParser extends KXmlParser
|
|
|
07b8b2 |
-{
|
|
|
07b8b2 |
-
|
|
|
07b8b2 |
- /**
|
|
|
07b8b2 |
- * The constructor for a parser, it receives a java.io.Reader.
|
|
|
07b8b2 |
- *
|
|
|
07b8b2 |
- * @param reader The reader
|
|
|
07b8b2 |
- * @throws XmlPullParserException
|
|
|
07b8b2 |
- */
|
|
|
07b8b2 |
- public KXml2SAXParser( Reader reader ) throws XmlPullParserException
|
|
|
07b8b2 |
- {
|
|
|
07b8b2 |
- super();
|
|
|
07b8b2 |
- setInput( reader );
|
|
|
07b8b2 |
- setFeature( FEATURE_PROCESS_NAMESPACES, true );
|
|
|
07b8b2 |
- }
|
|
|
07b8b2 |
-
|
|
|
07b8b2 |
-
|
|
|
07b8b2 |
- /**
|
|
|
07b8b2 |
- * Parser from the reader provided in the constructor, and call
|
|
|
07b8b2 |
- * the startElement and endElement in a KxmlHandler
|
|
|
07b8b2 |
- *
|
|
|
07b8b2 |
- * @param handler The handler
|
|
|
07b8b2 |
- * @exception Exception thrown by the superclass
|
|
|
07b8b2 |
- */
|
|
|
07b8b2 |
- public void parseXML( KXml2SAXHandler handler ) throws Exception
|
|
|
07b8b2 |
- {
|
|
|
07b8b2 |
-
|
|
|
07b8b2 |
- final Stack<XmlElement> openElements = new Stack<XmlElement>();
|
|
|
07b8b2 |
- XmlElement currentElement = null;
|
|
|
07b8b2 |
- final Attributes attributes = new Attributes();
|
|
|
07b8b2 |
-
|
|
|
07b8b2 |
- while ( next() != XmlPullParser.END_DOCUMENT )
|
|
|
07b8b2 |
- {
|
|
|
07b8b2 |
- handler.setLineNumber( getLineNumber() );
|
|
|
07b8b2 |
- handler.setColumnNumber( getColumnNumber() );
|
|
|
07b8b2 |
-
|
|
|
07b8b2 |
- if ( getEventType() == XmlPullParser.START_TAG )
|
|
|
07b8b2 |
- {
|
|
|
07b8b2 |
- currentElement = new XmlElement( getNamespace(), getName(), getLineNumber(), getColumnNumber() );
|
|
|
07b8b2 |
- openElements.push( currentElement );
|
|
|
07b8b2 |
-
|
|
|
07b8b2 |
- handler.startElement( getNamespace(), getName(), attributes );
|
|
|
07b8b2 |
- }
|
|
|
07b8b2 |
- else if ( getEventType() == XmlPullParser.END_TAG )
|
|
|
07b8b2 |
- {
|
|
|
07b8b2 |
- ensureMatchingCurrentElement(currentElement);
|
|
|
07b8b2 |
- openElements.pop();
|
|
|
07b8b2 |
- currentElement = openElements.isEmpty() ? null : ( XmlElement ) openElements.peek();
|
|
|
07b8b2 |
-
|
|
|
07b8b2 |
- handler.endElement( getNamespace(), getName() );
|
|
|
07b8b2 |
- }
|
|
|
07b8b2 |
- else if ( getEventType() == XmlPullParser.TEXT )
|
|
|
07b8b2 |
- {
|
|
|
07b8b2 |
- String text = getText();
|
|
|
07b8b2 |
- handler.characters( text );
|
|
|
07b8b2 |
- }
|
|
|
07b8b2 |
- else if ( getEventType() == XmlPullParser.PROCESSING_INSTRUCTION )
|
|
|
07b8b2 |
- {
|
|
|
07b8b2 |
- // TODO extract the target from the evt.getText()
|
|
|
07b8b2 |
- handler.processingInstruction( null, getText() );
|
|
|
07b8b2 |
- }
|
|
|
07b8b2 |
- else
|
|
|
07b8b2 |
- {
|
|
|
07b8b2 |
- // do nothing
|
|
|
07b8b2 |
- }
|
|
|
07b8b2 |
- }
|
|
|
07b8b2 |
-
|
|
|
07b8b2 |
- if ( !openElements.isEmpty() )
|
|
|
07b8b2 |
- {
|
|
|
07b8b2 |
- throw new ParseException( "Unclosed elements found: " + openElements, null );
|
|
|
07b8b2 |
- }
|
|
|
07b8b2 |
- }
|
|
|
07b8b2 |
-
|
|
|
07b8b2 |
-
|
|
|
07b8b2 |
- private void ensureMatchingCurrentElement( final XmlElement currentElement ) throws Exception
|
|
|
07b8b2 |
- {
|
|
|
07b8b2 |
- if ( currentElement == null )
|
|
|
07b8b2 |
- {
|
|
|
07b8b2 |
- throw new ParseException( "Unexpected closing element "
|
|
|
07b8b2 |
- + new XmlElement( getNamespace(), getName(), getLineNumber(), getColumnNumber() ), null );
|
|
|
07b8b2 |
- }
|
|
|
07b8b2 |
-
|
|
|
07b8b2 |
- if ( !currentElement.match( getNamespace(), getName() ) )
|
|
|
07b8b2 |
- {
|
|
|
07b8b2 |
- throw new ParseException( "Unexpected closing element "
|
|
|
07b8b2 |
- + new XmlElement( getNamespace(), getName(), getLineNumber(), getColumnNumber() )
|
|
|
07b8b2 |
- + ": Does not match opening element " + currentElement, null );
|
|
|
07b8b2 |
- }
|
|
|
07b8b2 |
- }
|
|
|
07b8b2 |
-
|
|
|
07b8b2 |
- private static class XmlElement
|
|
|
07b8b2 |
- {
|
|
|
07b8b2 |
-
|
|
|
07b8b2 |
- final String namespaceUri;
|
|
|
07b8b2 |
- final String name;
|
|
|
07b8b2 |
- final int line;
|
|
|
07b8b2 |
- final int col;
|
|
|
07b8b2 |
-
|
|
|
07b8b2 |
-
|
|
|
07b8b2 |
- XmlElement( final String namespaceUri, final String name, final int line, final int col )
|
|
|
07b8b2 |
- {
|
|
|
07b8b2 |
- this.namespaceUri = namespaceUri;
|
|
|
07b8b2 |
- this.name = name;
|
|
|
07b8b2 |
- this.line = line;
|
|
|
07b8b2 |
- this.col = col;
|
|
|
07b8b2 |
- }
|
|
|
07b8b2 |
-
|
|
|
07b8b2 |
-
|
|
|
07b8b2 |
- boolean match( final String namespaceUri, final String name )
|
|
|
07b8b2 |
- {
|
|
|
07b8b2 |
- return namespaceUri.equals( this.namespaceUri ) && name.equals( this.name );
|
|
|
07b8b2 |
- }
|
|
|
07b8b2 |
-
|
|
|
07b8b2 |
- @Override
|
|
|
07b8b2 |
- public String toString()
|
|
|
07b8b2 |
- {
|
|
|
07b8b2 |
- return name + "@" + line + ":" + col;
|
|
|
07b8b2 |
- }
|
|
|
07b8b2 |
- }
|
|
|
07b8b2 |
-
|
|
|
07b8b2 |
- public class Attributes {
|
|
|
07b8b2 |
-
|
|
|
07b8b2 |
- public String getAttribute(String name) {
|
|
|
07b8b2 |
- return getAttributeValue("", name);
|
|
|
07b8b2 |
- }
|
|
|
07b8b2 |
-
|
|
|
07b8b2 |
- public String getAttribute(String uri, String name) {
|
|
|
07b8b2 |
- return getAttributeValue(uri, name);
|
|
|
07b8b2 |
- }
|
|
|
07b8b2 |
-
|
|
|
07b8b2 |
- public boolean getBoolAttribute(String name, boolean defaultValue) {
|
|
|
07b8b2 |
- return getBoolAttribute("", name, defaultValue);
|
|
|
07b8b2 |
- }
|
|
|
07b8b2 |
-
|
|
|
07b8b2 |
- public boolean getBoolAttribute(String uri, String name, boolean defaultValue) {
|
|
|
07b8b2 |
- final String val = getAttribute(uri, name);
|
|
|
07b8b2 |
- if ( val != null ) {
|
|
|
07b8b2 |
- return "true".equals(val);
|
|
|
07b8b2 |
- }
|
|
|
07b8b2 |
- return defaultValue;
|
|
|
07b8b2 |
- }
|
|
|
07b8b2 |
- }
|
|
|
07b8b2 |
-}
|
|
|
07b8b2 |
diff --git a/src/main/java/org/apache/felix/scr/impl/parser/ParseException.java b/src/main/java/org/apache/felix/scr/impl/parser/ParseException.java
|
|
|
07b8b2 |
deleted file mode 100644
|
|
|
07b8b2 |
index c1bf6f2..0000000
|
|
|
07b8b2 |
--- a/src/main/java/org/apache/felix/scr/impl/parser/ParseException.java
|
|
|
07b8b2 |
+++ /dev/null
|
|
|
07b8b2 |
@@ -1,29 +0,0 @@
|
|
|
07b8b2 |
-/*
|
|
|
07b8b2 |
- * Licensed to the Apache Software Foundation (ASF) under one
|
|
|
07b8b2 |
- * or more contributor license agreements. See the NOTICE file
|
|
|
07b8b2 |
- * distributed with this work for additional information
|
|
|
07b8b2 |
- * regarding copyright ownership. The ASF licenses this file
|
|
|
07b8b2 |
- * to you under the Apache License, Version 2.0 (the
|
|
|
07b8b2 |
- * "License"); you may not use this file except in compliance
|
|
|
07b8b2 |
- * with the License. You may obtain a copy of the License at
|
|
|
07b8b2 |
- *
|
|
|
07b8b2 |
- * http://www.apache.org/licenses/LICENSE-2.0
|
|
|
07b8b2 |
- *
|
|
|
07b8b2 |
- * Unless required by applicable law or agreed to in writing,
|
|
|
07b8b2 |
- * software distributed under the License is distributed on an
|
|
|
07b8b2 |
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
07b8b2 |
- * KIND, either express or implied. See the License for the
|
|
|
07b8b2 |
- * specific language governing permissions and limitations
|
|
|
07b8b2 |
- * under the License.
|
|
|
07b8b2 |
- */
|
|
|
07b8b2 |
-package org.apache.felix.scr.impl.parser;
|
|
|
07b8b2 |
-
|
|
|
07b8b2 |
-public class ParseException extends Exception
|
|
|
07b8b2 |
-{
|
|
|
07b8b2 |
- private static final long serialVersionUID = 7476908955452692098L;
|
|
|
07b8b2 |
-
|
|
|
07b8b2 |
- public ParseException(String msg, Exception originalException) {
|
|
|
07b8b2 |
- super(msg, originalException);
|
|
|
07b8b2 |
- }
|
|
|
07b8b2 |
-
|
|
|
07b8b2 |
-}
|
|
|
07b8b2 |
diff --git a/src/main/java/org/apache/felix/scr/impl/xml/XmlHandler.java b/src/main/java/org/apache/felix/scr/impl/xml/XmlHandler.java
|
|
|
07b8b2 |
index aa7acf2..eb758ce 100644
|
|
|
07b8b2 |
--- a/src/main/java/org/apache/felix/scr/impl/xml/XmlHandler.java
|
|
|
07b8b2 |
+++ b/src/main/java/org/apache/felix/scr/impl/xml/XmlHandler.java
|
|
|
07b8b2 |
@@ -32,16 +32,16 @@ import org.apache.felix.scr.impl.metadata.DSVersion;
|
|
|
07b8b2 |
import org.apache.felix.scr.impl.metadata.PropertyMetadata;
|
|
|
07b8b2 |
import org.apache.felix.scr.impl.metadata.ReferenceMetadata;
|
|
|
07b8b2 |
import org.apache.felix.scr.impl.metadata.ServiceMetadata;
|
|
|
07b8b2 |
-import org.apache.felix.scr.impl.parser.KXml2SAXHandler;
|
|
|
07b8b2 |
-import org.apache.felix.scr.impl.parser.KXml2SAXParser.Attributes;
|
|
|
07b8b2 |
-import org.apache.felix.scr.impl.parser.ParseException;
|
|
|
07b8b2 |
import org.osgi.framework.Bundle;
|
|
|
07b8b2 |
import org.osgi.service.log.LogService;
|
|
|
07b8b2 |
+import org.xml.sax.Attributes;
|
|
|
07b8b2 |
+import org.xml.sax.SAXException;
|
|
|
07b8b2 |
+import org.xml.sax.helpers.DefaultHandler;
|
|
|
07b8b2 |
|
|
|
07b8b2 |
/**
|
|
|
07b8b2 |
* XML Parser for the component XML
|
|
|
07b8b2 |
*/
|
|
|
07b8b2 |
-public class XmlHandler implements KXml2SAXHandler
|
|
|
07b8b2 |
+public class XmlHandler extends DefaultHandler
|
|
|
07b8b2 |
{
|
|
|
07b8b2 |
// the bundle containing the XML resource being parsed
|
|
|
07b8b2 |
private final Bundle m_bundle;
|
|
|
07b8b2 |
@@ -68,6 +68,8 @@ public class XmlHandler implements KXml2SAXHandler
|
|
|
07b8b2 |
// PropertyMetaData whose value attribute is missing, hence has element data
|
|
|
07b8b2 |
private PropertyMetadata m_pendingFactoryProperty;
|
|
|
07b8b2 |
|
|
|
07b8b2 |
+ private StringBuilder propertyBuilder;
|
|
|
07b8b2 |
+
|
|
|
07b8b2 |
/** Flag for detecting the first element. */
|
|
|
07b8b2 |
protected boolean firstElement = true;
|
|
|
07b8b2 |
|
|
|
07b8b2 |
@@ -99,16 +101,8 @@ public class XmlHandler implements KXml2SAXHandler
|
|
|
07b8b2 |
}
|
|
|
07b8b2 |
|
|
|
07b8b2 |
|
|
|
07b8b2 |
- /**
|
|
|
07b8b2 |
- * Method called when a tag opens
|
|
|
07b8b2 |
- *
|
|
|
07b8b2 |
- * @param uri
|
|
|
07b8b2 |
- * @param localName
|
|
|
07b8b2 |
- * @param attributes
|
|
|
07b8b2 |
- * @exception ParseException
|
|
|
07b8b2 |
- **/
|
|
|
07b8b2 |
@Override
|
|
|
07b8b2 |
- public void startElement( String uri, String localName, Attributes attributes ) throws ParseException
|
|
|
07b8b2 |
+ public void startElement( String uri, String localName, String qName, Attributes attributes ) throws SAXException
|
|
|
07b8b2 |
{
|
|
|
07b8b2 |
// according to the spec, the elements should have the namespace,
|
|
|
07b8b2 |
// except when the root element is the "component" element
|
|
|
07b8b2 |
@@ -152,77 +146,77 @@ public class XmlHandler implements KXml2SAXHandler
|
|
|
07b8b2 |
m_currentComponent = new ComponentMetadata( namespaceCode );
|
|
|
07b8b2 |
|
|
|
07b8b2 |
// name attribute is optional (since DS 1.1)
|
|
|
07b8b2 |
- if ( attributes.getAttribute( XmlConstants.ATTR_NAME ) != null )
|
|
|
07b8b2 |
+ if ( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, XmlConstants.ATTR_NAME ) != null )
|
|
|
07b8b2 |
{
|
|
|
07b8b2 |
- m_currentComponent.setName( attributes.getAttribute( XmlConstants.ATTR_NAME ) );
|
|
|
07b8b2 |
+ m_currentComponent.setName( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, XmlConstants.ATTR_NAME ) );
|
|
|
07b8b2 |
}
|
|
|
07b8b2 |
|
|
|
07b8b2 |
// enabled attribute is optional
|
|
|
07b8b2 |
- if ( attributes.getAttribute( "enabled" ) != null )
|
|
|
07b8b2 |
+ if ( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, "enabled" ) != null )
|
|
|
07b8b2 |
{
|
|
|
07b8b2 |
- m_currentComponent.setEnabled( attributes.getAttribute( "enabled" ).equals( "true" ) );
|
|
|
07b8b2 |
+ m_currentComponent.setEnabled( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, "enabled" ).equals( "true" ) );
|
|
|
07b8b2 |
}
|
|
|
07b8b2 |
|
|
|
07b8b2 |
// immediate attribute is optional
|
|
|
07b8b2 |
- if ( attributes.getAttribute( "immediate" ) != null )
|
|
|
07b8b2 |
+ if ( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, "immediate" ) != null )
|
|
|
07b8b2 |
{
|
|
|
07b8b2 |
- m_currentComponent.setImmediate( attributes.getAttribute( "immediate" ).equals( "true" ) );
|
|
|
07b8b2 |
+ m_currentComponent.setImmediate( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, "immediate" ).equals( "true" ) );
|
|
|
07b8b2 |
}
|
|
|
07b8b2 |
|
|
|
07b8b2 |
// factory attribute is optional
|
|
|
07b8b2 |
- if ( attributes.getAttribute( "factory" ) != null )
|
|
|
07b8b2 |
+ if ( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, "factory" ) != null )
|
|
|
07b8b2 |
{
|
|
|
07b8b2 |
- m_currentComponent.setFactoryIdentifier( attributes.getAttribute( "factory" ) );
|
|
|
07b8b2 |
+ m_currentComponent.setFactoryIdentifier( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, "factory" ) );
|
|
|
07b8b2 |
}
|
|
|
07b8b2 |
|
|
|
07b8b2 |
// configuration-policy is optional (since DS 1.1)
|
|
|
07b8b2 |
- if ( attributes.getAttribute( "configuration-policy" ) != null )
|
|
|
07b8b2 |
+ if ( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, "configuration-policy" ) != null )
|
|
|
07b8b2 |
{
|
|
|
07b8b2 |
- m_currentComponent.setConfigurationPolicy( attributes.getAttribute( "configuration-policy" ) );
|
|
|
07b8b2 |
+ m_currentComponent.setConfigurationPolicy( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, "configuration-policy" ) );
|
|
|
07b8b2 |
}
|
|
|
07b8b2 |
|
|
|
07b8b2 |
// activate attribute is optional (since DS 1.1)
|
|
|
07b8b2 |
- if ( attributes.getAttribute( "activate" ) != null )
|
|
|
07b8b2 |
+ if ( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, "activate" ) != null )
|
|
|
07b8b2 |
{
|
|
|
07b8b2 |
- m_currentComponent.setActivate( attributes.getAttribute( "activate" ) );
|
|
|
07b8b2 |
+ m_currentComponent.setActivate( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, "activate" ) );
|
|
|
07b8b2 |
}
|
|
|
07b8b2 |
|
|
|
07b8b2 |
// deactivate attribute is optional (since DS 1.1)
|
|
|
07b8b2 |
- if ( attributes.getAttribute( "deactivate" ) != null )
|
|
|
07b8b2 |
+ if ( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, "deactivate" ) != null )
|
|
|
07b8b2 |
{
|
|
|
07b8b2 |
- m_currentComponent.setDeactivate( attributes.getAttribute( "deactivate" ) );
|
|
|
07b8b2 |
+ m_currentComponent.setDeactivate( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, "deactivate" ) );
|
|
|
07b8b2 |
}
|
|
|
07b8b2 |
|
|
|
07b8b2 |
// modified attribute is optional (since DS 1.1)
|
|
|
07b8b2 |
- if ( attributes.getAttribute( "modified" ) != null )
|
|
|
07b8b2 |
+ if ( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, "modified" ) != null )
|
|
|
07b8b2 |
{
|
|
|
07b8b2 |
- m_currentComponent.setModified( attributes.getAttribute( "modified" ) );
|
|
|
07b8b2 |
+ m_currentComponent.setModified( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, "modified" ) );
|
|
|
07b8b2 |
}
|
|
|
07b8b2 |
|
|
|
07b8b2 |
// configuration-pid attribute is optional (since DS 1.2)
|
|
|
07b8b2 |
- String configurationPidString = attributes.getAttribute( "configuration-pid" );
|
|
|
07b8b2 |
+ String configurationPidString = attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, "configuration-pid" );
|
|
|
07b8b2 |
if (configurationPidString != null)
|
|
|
07b8b2 |
{
|
|
|
07b8b2 |
String[] configurationPid = configurationPidString.split( " " );
|
|
|
07b8b2 |
m_currentComponent.setConfigurationPid( configurationPid );
|
|
|
07b8b2 |
}
|
|
|
07b8b2 |
|
|
|
07b8b2 |
- m_currentComponent.setConfigurableServiceProperties("true".equals(attributes.getAttribute(XmlConstants.NAMESPACE_URI_1_0_FELIX_EXTENSIONS, XmlConstants.ATTR_CONFIGURABLE_SERVICE_PROPERTIES)));
|
|
|
07b8b2 |
- m_currentComponent.setPersistentFactoryComponent("true".equals(attributes.getAttribute(XmlConstants.NAMESPACE_URI_1_0_FELIX_EXTENSIONS, XmlConstants.ATTR_PERSISTENT_FACTORY_COMPONENT)));
|
|
|
07b8b2 |
- m_currentComponent.setDeleteCallsModify("true".equals(attributes.getAttribute(XmlConstants.NAMESPACE_URI_1_0_FELIX_EXTENSIONS, XmlConstants.ATTR_DELETE_CALLS_MODIFY)));
|
|
|
07b8b2 |
- if ( attributes.getAttribute(XmlConstants.NAMESPACE_URI_1_0_FELIX_EXTENSIONS, XmlConstants.ATTR_OBSOLETE_FACTORY_COMPONENT_FACTORY) != null)
|
|
|
07b8b2 |
+ m_currentComponent.setConfigurableServiceProperties("true".equals(attributes.getValue(XmlConstants.NAMESPACE_URI_1_0_FELIX_EXTENSIONS, XmlConstants.ATTR_CONFIGURABLE_SERVICE_PROPERTIES)));
|
|
|
07b8b2 |
+ m_currentComponent.setPersistentFactoryComponent("true".equals(attributes.getValue(XmlConstants.NAMESPACE_URI_1_0_FELIX_EXTENSIONS, XmlConstants.ATTR_PERSISTENT_FACTORY_COMPONENT)));
|
|
|
07b8b2 |
+ m_currentComponent.setDeleteCallsModify("true".equals(attributes.getValue(XmlConstants.NAMESPACE_URI_1_0_FELIX_EXTENSIONS, XmlConstants.ATTR_DELETE_CALLS_MODIFY)));
|
|
|
07b8b2 |
+ if ( attributes.getValue(XmlConstants.NAMESPACE_URI_1_0_FELIX_EXTENSIONS, XmlConstants.ATTR_OBSOLETE_FACTORY_COMPONENT_FACTORY) != null)
|
|
|
07b8b2 |
{
|
|
|
07b8b2 |
- m_currentComponent.setObsoleteFactoryComponentFactory("true".equals(attributes.getAttribute(XmlConstants.NAMESPACE_URI_1_0_FELIX_EXTENSIONS, XmlConstants.ATTR_OBSOLETE_FACTORY_COMPONENT_FACTORY)));
|
|
|
07b8b2 |
+ m_currentComponent.setObsoleteFactoryComponentFactory("true".equals(attributes.getValue(XmlConstants.NAMESPACE_URI_1_0_FELIX_EXTENSIONS, XmlConstants.ATTR_OBSOLETE_FACTORY_COMPONENT_FACTORY)));
|
|
|
07b8b2 |
}
|
|
|
07b8b2 |
else if ( !namespaceCode.isDS13() )
|
|
|
07b8b2 |
{
|
|
|
07b8b2 |
m_currentComponent.setObsoleteFactoryComponentFactory(m_globalObsoleteFactoryComponentFactory);
|
|
|
07b8b2 |
}
|
|
|
07b8b2 |
- m_currentComponent.setConfigureWithInterfaces("true".equals(attributes.getAttribute(XmlConstants.NAMESPACE_URI_1_0_FELIX_EXTENSIONS, XmlConstants.ATTR_CONFIGURE_WITH_INTERFACES)));
|
|
|
07b8b2 |
- m_currentComponent.setDelayedKeepInstances(m_globalDelayedKeepInstances || "true".equals(attributes.getAttribute(XmlConstants.NAMESPACE_URI_1_0_FELIX_EXTENSIONS, XmlConstants.ATTR_DELAYED_KEEP_INSTANCES)));
|
|
|
07b8b2 |
+ m_currentComponent.setConfigureWithInterfaces("true".equals(attributes.getValue(XmlConstants.NAMESPACE_URI_1_0_FELIX_EXTENSIONS, XmlConstants.ATTR_CONFIGURE_WITH_INTERFACES)));
|
|
|
07b8b2 |
+ m_currentComponent.setDelayedKeepInstances(m_globalDelayedKeepInstances || "true".equals(attributes.getValue(XmlConstants.NAMESPACE_URI_1_0_FELIX_EXTENSIONS, XmlConstants.ATTR_DELAYED_KEEP_INSTANCES)));
|
|
|
07b8b2 |
|
|
|
07b8b2 |
// activation-fields is optional (since DS 1.4)
|
|
|
07b8b2 |
- String activationFields = attributes.getAttribute( XmlConstants.ATTR_ACTIVATION_FIELDS );
|
|
|
07b8b2 |
+ String activationFields = attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, XmlConstants.ATTR_ACTIVATION_FIELDS );
|
|
|
07b8b2 |
if ( activationFields != null )
|
|
|
07b8b2 |
{
|
|
|
07b8b2 |
final String[] fields = activationFields.split(" ");
|
|
|
07b8b2 |
@@ -230,7 +224,7 @@ public class XmlHandler implements KXml2SAXHandler
|
|
|
07b8b2 |
}
|
|
|
07b8b2 |
|
|
|
07b8b2 |
// init is optional (since DS 1.4)
|
|
|
07b8b2 |
- String init = attributes.getAttribute( XmlConstants.ATTR_INIT );
|
|
|
07b8b2 |
+ String init = attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, XmlConstants.ATTR_INIT );
|
|
|
07b8b2 |
if ( init != null )
|
|
|
07b8b2 |
{
|
|
|
07b8b2 |
m_currentComponent.setInit( init );
|
|
|
07b8b2 |
@@ -252,7 +246,7 @@ public class XmlHandler implements KXml2SAXHandler
|
|
|
07b8b2 |
else if ( localName.equals( XmlConstants.EL_IMPL ) )
|
|
|
07b8b2 |
{
|
|
|
07b8b2 |
// Set the implementation class name (mandatory)
|
|
|
07b8b2 |
- m_currentComponent.setImplementationClassName( attributes.getAttribute( "class" ) );
|
|
|
07b8b2 |
+ m_currentComponent.setImplementationClassName( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, "class" ) );
|
|
|
07b8b2 |
}
|
|
|
07b8b2 |
// 112.4.5 [...] Property Elements
|
|
|
07b8b2 |
else if ( localName.equals( XmlConstants.EL_PROPERTY ) )
|
|
|
07b8b2 |
@@ -260,18 +254,18 @@ public class XmlHandler implements KXml2SAXHandler
|
|
|
07b8b2 |
PropertyMetadata prop = new PropertyMetadata();
|
|
|
07b8b2 |
|
|
|
07b8b2 |
// name attribute is mandatory
|
|
|
07b8b2 |
- prop.setName( attributes.getAttribute( XmlConstants.ATTR_NAME ) );
|
|
|
07b8b2 |
+ prop.setName( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, XmlConstants.ATTR_NAME ) );
|
|
|
07b8b2 |
|
|
|
07b8b2 |
// type attribute is optional
|
|
|
07b8b2 |
- if ( attributes.getAttribute( XmlConstants.ATTR_TYPE ) != null )
|
|
|
07b8b2 |
+ if ( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, XmlConstants.ATTR_TYPE ) != null )
|
|
|
07b8b2 |
{
|
|
|
07b8b2 |
- prop.setType( attributes.getAttribute( XmlConstants.ATTR_TYPE ) );
|
|
|
07b8b2 |
+ prop.setType( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, XmlConstants.ATTR_TYPE ) );
|
|
|
07b8b2 |
}
|
|
|
07b8b2 |
|
|
|
07b8b2 |
// 112.4.5: If the value attribute is specified, the body of the element is ignored.
|
|
|
07b8b2 |
- if ( attributes.getAttribute( XmlConstants.ATTR_VALUE ) != null )
|
|
|
07b8b2 |
+ if ( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, XmlConstants.ATTR_VALUE ) != null )
|
|
|
07b8b2 |
{
|
|
|
07b8b2 |
- prop.setValue( attributes.getAttribute( XmlConstants.ATTR_VALUE ) );
|
|
|
07b8b2 |
+ prop.setValue( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, XmlConstants.ATTR_VALUE ) );
|
|
|
07b8b2 |
m_currentComponent.addProperty( prop );
|
|
|
07b8b2 |
}
|
|
|
07b8b2 |
else
|
|
|
07b8b2 |
@@ -283,7 +277,7 @@ public class XmlHandler implements KXml2SAXHandler
|
|
|
07b8b2 |
// 112.4.5 Properties [...] Elements
|
|
|
07b8b2 |
else if ( localName.equals( XmlConstants.EL_PROPERTIES ) )
|
|
|
07b8b2 |
{
|
|
|
07b8b2 |
- final Properties props = readPropertiesEntry( attributes.getAttribute( "entry" ) );
|
|
|
07b8b2 |
+ final Properties props = readPropertiesEntry( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, "entry" ) );
|
|
|
07b8b2 |
// create PropertyMetadata for the properties from the file
|
|
|
07b8b2 |
for ( Map.Entry<Object, Object> pEntry: props.entrySet() )
|
|
|
07b8b2 |
{
|
|
|
07b8b2 |
@@ -300,18 +294,18 @@ public class XmlHandler implements KXml2SAXHandler
|
|
|
07b8b2 |
PropertyMetadata prop = new PropertyMetadata();
|
|
|
07b8b2 |
|
|
|
07b8b2 |
// name attribute is mandatory
|
|
|
07b8b2 |
- prop.setName( attributes.getAttribute( XmlConstants.ATTR_NAME ) );
|
|
|
07b8b2 |
+ prop.setName( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, XmlConstants.ATTR_NAME ) );
|
|
|
07b8b2 |
|
|
|
07b8b2 |
// type attribute is optional
|
|
|
07b8b2 |
- if ( attributes.getAttribute( XmlConstants.ATTR_TYPE ) != null )
|
|
|
07b8b2 |
+ if ( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, XmlConstants.ATTR_TYPE ) != null )
|
|
|
07b8b2 |
{
|
|
|
07b8b2 |
- prop.setType( attributes.getAttribute( XmlConstants.ATTR_TYPE ) );
|
|
|
07b8b2 |
+ prop.setType( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, XmlConstants.ATTR_TYPE ) );
|
|
|
07b8b2 |
}
|
|
|
07b8b2 |
|
|
|
07b8b2 |
// 112.4.5: If the value attribute is specified, the body of the element is ignored.
|
|
|
07b8b2 |
- if ( attributes.getAttribute( XmlConstants.ATTR_VALUE ) != null )
|
|
|
07b8b2 |
+ if ( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, XmlConstants.ATTR_VALUE ) != null )
|
|
|
07b8b2 |
{
|
|
|
07b8b2 |
- prop.setValue( attributes.getAttribute( XmlConstants.ATTR_VALUE ) );
|
|
|
07b8b2 |
+ prop.setValue( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, XmlConstants.ATTR_VALUE ) );
|
|
|
07b8b2 |
m_currentComponent.addFactoryProperty( prop );
|
|
|
07b8b2 |
}
|
|
|
07b8b2 |
else
|
|
|
07b8b2 |
@@ -323,7 +317,7 @@ public class XmlHandler implements KXml2SAXHandler
|
|
|
07b8b2 |
// 112.4.9 [...] Factory Properties Element
|
|
|
07b8b2 |
else if ( localName.equals( XmlConstants.EL_FACTORY_PROPERTIES ) )
|
|
|
07b8b2 |
{
|
|
|
07b8b2 |
- final Properties props = readPropertiesEntry( attributes.getAttribute( "entry" ) );
|
|
|
07b8b2 |
+ final Properties props = readPropertiesEntry( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, "entry" ) );
|
|
|
07b8b2 |
// create PropertyMetadata for the properties from the file
|
|
|
07b8b2 |
for ( Map.Entry<Object, Object> pEntry: props.entrySet() )
|
|
|
07b8b2 |
{
|
|
|
07b8b2 |
@@ -340,21 +334,21 @@ public class XmlHandler implements KXml2SAXHandler
|
|
|
07b8b2 |
m_currentService = new ServiceMetadata();
|
|
|
07b8b2 |
|
|
|
07b8b2 |
// servicefactory attribute is optional
|
|
|
07b8b2 |
- if ( attributes.getAttribute( "servicefactory" ) != null )
|
|
|
07b8b2 |
+ if ( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, "servicefactory" ) != null )
|
|
|
07b8b2 |
{
|
|
|
07b8b2 |
- m_currentService.setServiceFactory( attributes.getAttribute( "servicefactory" ).equals( "true" ) );
|
|
|
07b8b2 |
+ m_currentService.setServiceFactory( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, "servicefactory" ).equals( "true" ) );
|
|
|
07b8b2 |
}
|
|
|
07b8b2 |
|
|
|
07b8b2 |
- if ( attributes.getAttribute( "scope" ) != null )
|
|
|
07b8b2 |
+ if ( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, "scope" ) != null )
|
|
|
07b8b2 |
{
|
|
|
07b8b2 |
- m_currentService.setScope( attributes.getAttribute( "scope" ) );
|
|
|
07b8b2 |
+ m_currentService.setScope( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, "scope" ) );
|
|
|
07b8b2 |
}
|
|
|
07b8b2 |
|
|
|
07b8b2 |
m_currentComponent.setService( m_currentService );
|
|
|
07b8b2 |
}
|
|
|
07b8b2 |
else if ( localName.equals( XmlConstants.EL_PROVIDE ) )
|
|
|
07b8b2 |
{
|
|
|
07b8b2 |
- m_currentService.addProvide( attributes.getAttribute( XmlConstants.ATTR_INTERFACE ) );
|
|
|
07b8b2 |
+ m_currentService.addProvide( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, XmlConstants.ATTR_INTERFACE ) );
|
|
|
07b8b2 |
}
|
|
|
07b8b2 |
|
|
|
07b8b2 |
// 112.4.7 Reference element
|
|
|
07b8b2 |
@@ -363,58 +357,58 @@ public class XmlHandler implements KXml2SAXHandler
|
|
|
07b8b2 |
ReferenceMetadata ref = new ReferenceMetadata();
|
|
|
07b8b2 |
|
|
|
07b8b2 |
// name attribute is optional (since DS 1.1)
|
|
|
07b8b2 |
- if ( attributes.getAttribute( XmlConstants.ATTR_NAME ) != null )
|
|
|
07b8b2 |
+ if ( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, XmlConstants.ATTR_NAME ) != null )
|
|
|
07b8b2 |
{
|
|
|
07b8b2 |
- ref.setName( attributes.getAttribute( XmlConstants.ATTR_NAME ) );
|
|
|
07b8b2 |
+ ref.setName( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, XmlConstants.ATTR_NAME ) );
|
|
|
07b8b2 |
}
|
|
|
07b8b2 |
|
|
|
07b8b2 |
- ref.setInterface( attributes.getAttribute( XmlConstants.ATTR_INTERFACE ) );
|
|
|
07b8b2 |
+ ref.setInterface( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, XmlConstants.ATTR_INTERFACE ) );
|
|
|
07b8b2 |
|
|
|
07b8b2 |
// Cardinality
|
|
|
07b8b2 |
- if ( attributes.getAttribute( "cardinality" ) != null )
|
|
|
07b8b2 |
+ if ( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, "cardinality" ) != null )
|
|
|
07b8b2 |
{
|
|
|
07b8b2 |
- ref.setCardinality( attributes.getAttribute( "cardinality" ) );
|
|
|
07b8b2 |
+ ref.setCardinality( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, "cardinality" ) );
|
|
|
07b8b2 |
}
|
|
|
07b8b2 |
|
|
|
07b8b2 |
- if ( attributes.getAttribute( "policy" ) != null )
|
|
|
07b8b2 |
+ if ( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, "policy" ) != null )
|
|
|
07b8b2 |
{
|
|
|
07b8b2 |
- ref.setPolicy( attributes.getAttribute( "policy" ) );
|
|
|
07b8b2 |
+ ref.setPolicy( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, "policy" ) );
|
|
|
07b8b2 |
}
|
|
|
07b8b2 |
|
|
|
07b8b2 |
- if ( attributes.getAttribute( "policy-option" ) != null )
|
|
|
07b8b2 |
+ if ( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, "policy-option" ) != null )
|
|
|
07b8b2 |
{
|
|
|
07b8b2 |
- ref.setPolicyOption( attributes.getAttribute( "policy-option" ) );
|
|
|
07b8b2 |
+ ref.setPolicyOption( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, "policy-option" ) );
|
|
|
07b8b2 |
}
|
|
|
07b8b2 |
|
|
|
07b8b2 |
- if ( attributes.getAttribute( "scope" ) != null )
|
|
|
07b8b2 |
+ if ( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, "scope" ) != null )
|
|
|
07b8b2 |
{
|
|
|
07b8b2 |
- ref.setScope( attributes.getAttribute( "scope" ) );
|
|
|
07b8b2 |
+ ref.setScope( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, "scope" ) );
|
|
|
07b8b2 |
}
|
|
|
07b8b2 |
|
|
|
07b8b2 |
- if ( attributes.getAttribute( "target" ) != null)
|
|
|
07b8b2 |
+ if ( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, "target" ) != null)
|
|
|
07b8b2 |
{
|
|
|
07b8b2 |
- ref.setTarget( attributes.getAttribute( "target" ) );
|
|
|
07b8b2 |
+ ref.setTarget( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, "target" ) );
|
|
|
07b8b2 |
PropertyMetadata prop = new PropertyMetadata();
|
|
|
07b8b2 |
prop.setName( (ref.getName() == null? ref.getInterface(): ref.getName()) + ".target");
|
|
|
07b8b2 |
- prop.setValue( attributes.getAttribute( "target" ) );
|
|
|
07b8b2 |
+ prop.setValue( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, "target" ) );
|
|
|
07b8b2 |
m_currentComponent.addProperty( prop );
|
|
|
07b8b2 |
|
|
|
07b8b2 |
}
|
|
|
07b8b2 |
|
|
|
07b8b2 |
// method reference
|
|
|
07b8b2 |
- ref.setBind( attributes.getAttribute( "bind" ) );
|
|
|
07b8b2 |
- ref.setUpdated( attributes.getAttribute( "updated" ) );
|
|
|
07b8b2 |
- ref.setUnbind( attributes.getAttribute( "unbind" ) );
|
|
|
07b8b2 |
+ ref.setBind( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, "bind" ) );
|
|
|
07b8b2 |
+ ref.setUpdated( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, "updated" ) );
|
|
|
07b8b2 |
+ ref.setUnbind( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, "unbind" ) );
|
|
|
07b8b2 |
|
|
|
07b8b2 |
// field reference
|
|
|
07b8b2 |
- ref.setField( attributes.getAttribute( "field" ) );
|
|
|
07b8b2 |
- ref.setFieldOption( attributes.getAttribute( "field-option" ) );
|
|
|
07b8b2 |
- ref.setFieldCollectionType( attributes.getAttribute( "field-collection-type" ) );
|
|
|
07b8b2 |
+ ref.setField( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, "field" ) );
|
|
|
07b8b2 |
+ ref.setFieldOption( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, "field-option" ) );
|
|
|
07b8b2 |
+ ref.setFieldCollectionType( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, "field-collection-type" ) );
|
|
|
07b8b2 |
|
|
|
07b8b2 |
// DS 1.4 : references as parameter of the activator (method or constructor)
|
|
|
07b8b2 |
- if ( attributes.getAttribute( "parameter" ) != null)
|
|
|
07b8b2 |
+ if ( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, "parameter" ) != null)
|
|
|
07b8b2 |
{
|
|
|
07b8b2 |
- ref.setParameter( attributes.getAttribute( "parameter" ) );
|
|
|
07b8b2 |
+ ref.setParameter( attributes.getValue( XmlConstants.NAMESPACE_URI_EMPTY, "parameter" ) );
|
|
|
07b8b2 |
|
|
|
07b8b2 |
}
|
|
|
07b8b2 |
|
|
|
07b8b2 |
@@ -431,7 +425,7 @@ public class XmlHandler implements KXml2SAXHandler
|
|
|
07b8b2 |
}
|
|
|
07b8b2 |
catch ( Exception ex )
|
|
|
07b8b2 |
{
|
|
|
07b8b2 |
- throw new ParseException( "Exception during parsing", ex );
|
|
|
07b8b2 |
+ throw new SAXException( "Exception during parsing", ex );
|
|
|
07b8b2 |
}
|
|
|
07b8b2 |
}
|
|
|
07b8b2 |
|
|
|
07b8b2 |
@@ -445,14 +439,8 @@ public class XmlHandler implements KXml2SAXHandler
|
|
|
07b8b2 |
}
|
|
|
07b8b2 |
|
|
|
07b8b2 |
|
|
|
07b8b2 |
- /**
|
|
|
07b8b2 |
- * Method called when a tag closes
|
|
|
07b8b2 |
- *
|
|
|
07b8b2 |
- * @param uri
|
|
|
07b8b2 |
- * @param localName
|
|
|
07b8b2 |
- */
|
|
|
07b8b2 |
@Override
|
|
|
07b8b2 |
- public void endElement( String uri, String localName )
|
|
|
07b8b2 |
+ public void endElement(String uri, String localName, String qName) throws SAXException
|
|
|
07b8b2 |
{
|
|
|
07b8b2 |
if ( overrideNamespace != null && XmlConstants.NAMESPACE_URI_EMPTY.equals( uri ) )
|
|
|
07b8b2 |
{
|
|
|
07b8b2 |
@@ -475,71 +463,39 @@ public class XmlHandler implements KXml2SAXHandler
|
|
|
07b8b2 |
// 112.4.5 body expected to contain property value
|
|
|
07b8b2 |
// if so, the m_pendingProperty field would be null
|
|
|
07b8b2 |
// currently, we just ignore this situation
|
|
|
07b8b2 |
+ m_pendingProperty.setValues( propertyBuilder.toString() );
|
|
|
07b8b2 |
+ m_currentComponent.addProperty( m_pendingProperty );
|
|
|
07b8b2 |
m_pendingProperty = null;
|
|
|
07b8b2 |
+ propertyBuilder = null;
|
|
|
07b8b2 |
}
|
|
|
07b8b2 |
else if ( localName.equals( XmlConstants.EL_FACTORY_PROPERTY ) && m_pendingFactoryProperty != null )
|
|
|
07b8b2 |
{
|
|
|
07b8b2 |
// 112.4.5 body expected to contain property value
|
|
|
07b8b2 |
// if so, the m_pendingFactoryProperty field would be null
|
|
|
07b8b2 |
// currently, we just ignore this situation
|
|
|
07b8b2 |
+ m_pendingFactoryProperty.setValues( propertyBuilder.toString() );
|
|
|
07b8b2 |
+ m_currentComponent.addFactoryProperty( m_pendingFactoryProperty );
|
|
|
07b8b2 |
m_pendingFactoryProperty = null;
|
|
|
07b8b2 |
+ propertyBuilder = null;
|
|
|
07b8b2 |
}
|
|
|
07b8b2 |
}
|
|
|
07b8b2 |
}
|
|
|
07b8b2 |
|
|
|
07b8b2 |
|
|
|
07b8b2 |
- /**
|
|
|
07b8b2 |
- * @see org.apache.felix.scr.impl.parser.KXml2SAXHandler#characters(java.lang.String)
|
|
|
07b8b2 |
- */
|
|
|
07b8b2 |
@Override
|
|
|
07b8b2 |
- public void characters( String text )
|
|
|
07b8b2 |
+ public void characters(char[] ch, int start, int length) throws SAXException
|
|
|
07b8b2 |
{
|
|
|
07b8b2 |
// 112.4.5 If the value attribute is not specified, the body must contain one or more values
|
|
|
07b8b2 |
- if ( m_pendingProperty != null )
|
|
|
07b8b2 |
+ if ( m_pendingProperty != null || m_pendingFactoryProperty != null )
|
|
|
07b8b2 |
{
|
|
|
07b8b2 |
- m_pendingProperty.setValues( text );
|
|
|
07b8b2 |
- m_currentComponent.addProperty( m_pendingProperty );
|
|
|
07b8b2 |
- m_pendingProperty = null;
|
|
|
07b8b2 |
- }
|
|
|
07b8b2 |
- if ( m_pendingFactoryProperty != null )
|
|
|
07b8b2 |
- {
|
|
|
07b8b2 |
- m_pendingFactoryProperty.setValues( text );
|
|
|
07b8b2 |
- m_currentComponent.addFactoryProperty( m_pendingFactoryProperty );
|
|
|
07b8b2 |
- m_pendingFactoryProperty = null;
|
|
|
07b8b2 |
+ if (propertyBuilder == null) {
|
|
|
07b8b2 |
+ propertyBuilder = new StringBuilder();
|
|
|
07b8b2 |
+ }
|
|
|
07b8b2 |
+ propertyBuilder.append(String.valueOf( ch, start, length));
|
|
|
07b8b2 |
}
|
|
|
07b8b2 |
}
|
|
|
07b8b2 |
|
|
|
07b8b2 |
|
|
|
07b8b2 |
- /**
|
|
|
07b8b2 |
- * @see org.apache.felix.scr.impl.parser.KXml2SAXHandler#processingInstruction(java.lang.String, java.lang.String)
|
|
|
07b8b2 |
- */
|
|
|
07b8b2 |
- @Override
|
|
|
07b8b2 |
- public void processingInstruction( String target, String data )
|
|
|
07b8b2 |
- {
|
|
|
07b8b2 |
- // Not used
|
|
|
07b8b2 |
- }
|
|
|
07b8b2 |
-
|
|
|
07b8b2 |
-
|
|
|
07b8b2 |
- /**
|
|
|
07b8b2 |
- * @see org.apache.felix.scr.impl.parser.KXml2SAXHandler#setLineNumber(int)
|
|
|
07b8b2 |
- */
|
|
|
07b8b2 |
- @Override
|
|
|
07b8b2 |
- public void setLineNumber( int lineNumber )
|
|
|
07b8b2 |
- {
|
|
|
07b8b2 |
- // Not used
|
|
|
07b8b2 |
- }
|
|
|
07b8b2 |
-
|
|
|
07b8b2 |
-
|
|
|
07b8b2 |
- /**
|
|
|
07b8b2 |
- * @see org.apache.felix.scr.impl.parser.KXml2SAXHandler#setColumnNumber(int)
|
|
|
07b8b2 |
- */
|
|
|
07b8b2 |
- @Override
|
|
|
07b8b2 |
- public void setColumnNumber( int columnNumber )
|
|
|
07b8b2 |
- {
|
|
|
07b8b2 |
- // Not used
|
|
|
07b8b2 |
- }
|
|
|
07b8b2 |
-
|
|
|
07b8b2 |
-
|
|
|
07b8b2 |
/**
|
|
|
07b8b2 |
* Reads the name property file from the bundle owning this descriptor. All
|
|
|
07b8b2 |
* properties read from the properties file are added to the current
|
|
|
07b8b2 |
@@ -548,21 +504,21 @@ public class XmlHandler implements KXml2SAXHandler
|
|
|
07b8b2 |
* @param entryName The name of the bundle entry containing the propertes
|
|
|
07b8b2 |
* to be added. This must not be null .
|
|
|
07b8b2 |
*
|
|
|
07b8b2 |
- * @throws ParseException If the entry name is null or no
|
|
|
07b8b2 |
+ * @throws SAXException If the entry name is null or no
|
|
|
07b8b2 |
* entry with the given name exists in the bundle or an error occurrs
|
|
|
07b8b2 |
* reading the properties file.
|
|
|
07b8b2 |
*/
|
|
|
07b8b2 |
- private Properties readPropertiesEntry( String entryName ) throws ParseException
|
|
|
07b8b2 |
+ private Properties readPropertiesEntry( String entryName ) throws SAXException
|
|
|
07b8b2 |
{
|
|
|
07b8b2 |
if ( entryName == null )
|
|
|
07b8b2 |
{
|
|
|
07b8b2 |
- throw new ParseException( "Missing entry attribute of properties element", null );
|
|
|
07b8b2 |
+ throw new SAXException( "Missing entry attribute of properties element", null );
|
|
|
07b8b2 |
}
|
|
|
07b8b2 |
|
|
|
07b8b2 |
URL entryURL = m_bundle.getEntry( entryName );
|
|
|
07b8b2 |
if ( entryURL == null )
|
|
|
07b8b2 |
{
|
|
|
07b8b2 |
- throw new ParseException( "Missing bundle entry " + entryName, null );
|
|
|
07b8b2 |
+ throw new SAXException( "Missing bundle entry " + entryName, null );
|
|
|
07b8b2 |
}
|
|
|
07b8b2 |
|
|
|
07b8b2 |
Properties props = new Properties();
|
|
|
07b8b2 |
@@ -574,7 +530,7 @@ public class XmlHandler implements KXml2SAXHandler
|
|
|
07b8b2 |
}
|
|
|
07b8b2 |
catch ( IOException ioe )
|
|
|
07b8b2 |
{
|
|
|
07b8b2 |
- throw new ParseException( "Failed to read properties entry " + entryName, ioe );
|
|
|
07b8b2 |
+ throw new SAXException( "Failed to read properties entry " + entryName, ioe );
|
|
|
07b8b2 |
}
|
|
|
07b8b2 |
finally
|
|
|
07b8b2 |
{
|
|
|
07b8b2 |
--
|
|
|
07b8b2 |
2.21.1
|
|
|
07b8b2 |
|