You are viewing a plain text version of this content. The canonical link for it is here.
Posted to pluto-scm@portals.apache.org by es...@apache.org on 2007/06/02 06:32:36 UTC
svn commit: r543704 - in /portals/pluto/trunk: ./
maven-pluto-plugin/src/main/java/org/apache/pluto/maven/
maven-pluto-plugin/src/main/resources/ pluto-descriptor-impl/
pluto-descriptor-impl/src/main/java/org/apache/pluto/descriptors/services/castor/
p...
Author: esm
Date: Fri Jun 1 21:32:29 2007
New Revision: 543704
URL: http://svn.apache.org/viewvc?view=rev&rev=543704
Log:
[PLUTO-347]: Remove dependency on shared/lib xerces and xmlAPIs. Added system property org.apache.pluto.useJaxp with a default value of true. When true, Castor is instructed to use JAXP instead of the parser defined by org.exolab.castor.parser. The reason this is hard-coded versus using a castor.properties file is because the castor.properties file would go into a shared classloader which may adversely affect other applications that rely on Castor (for an example see PLUTO-329).
Added:
portals/pluto/trunk/pluto-descriptor-impl/src/site/
portals/pluto/trunk/pluto-descriptor-impl/src/site/apt/
portals/pluto/trunk/pluto-descriptor-impl/src/site/apt/index.apt
portals/pluto/trunk/pluto-descriptor-impl/src/site/site.xml
Modified:
portals/pluto/trunk/maven-pluto-plugin/src/main/java/org/apache/pluto/maven/InstallationDependency.java
portals/pluto/trunk/maven-pluto-plugin/src/main/resources/versions.properties
portals/pluto/trunk/pluto-descriptor-impl/pom.xml
portals/pluto/trunk/pluto-descriptor-impl/src/main/java/org/apache/pluto/descriptors/services/castor/AbstractCastorDescriptorService.java
portals/pluto/trunk/pluto-portal/src/main/webapp/WEB-INF/classes/castor.properties
portals/pluto/trunk/pom.xml
Modified: portals/pluto/trunk/maven-pluto-plugin/src/main/java/org/apache/pluto/maven/InstallationDependency.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/maven-pluto-plugin/src/main/java/org/apache/pluto/maven/InstallationDependency.java?view=diff&rev=543704&r1=543703&r2=543704
==============================================================================
--- portals/pluto/trunk/maven-pluto-plugin/src/main/java/org/apache/pluto/maven/InstallationDependency.java (original)
+++ portals/pluto/trunk/maven-pluto-plugin/src/main/java/org/apache/pluto/maven/InstallationDependency.java Fri Jun 1 21:32:29 2007
@@ -74,21 +74,11 @@
new InstallationDependency("org.codehaus.castor", "castor",
VERSION_PROPERTIES.getProperty("castor.version"));
- public static final InstallationDependency XERCES =
- new InstallationDependency("xerces", "xercesImpl",
- VERSION_PROPERTIES.getProperty("xercesImpl.version"));
-
- public static final InstallationDependency XML_PARSER_APIS =
- new InstallationDependency("xerces", "xmlParserAPIs",
- VERSION_PROPERTIES.getProperty("xmlParserAPIs.version"));
private static final List ENDORSED = new ArrayList();
private static final List SHARED = new ArrayList();
static {
- ENDORSED.add(XERCES);
- ENDORSED.add(XML_PARSER_APIS);
-
SHARED.add(PORTLET_API);
SHARED.add(DESCRIPTOR_API);
SHARED.add(DESCRIPTOR_IMPL);
Modified: portals/pluto/trunk/maven-pluto-plugin/src/main/resources/versions.properties
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/maven-pluto-plugin/src/main/resources/versions.properties?view=diff&rev=543704&r1=543703&r2=543704
==============================================================================
--- portals/pluto/trunk/maven-pluto-plugin/src/main/resources/versions.properties (original)
+++ portals/pluto/trunk/maven-pluto-plugin/src/main/resources/versions.properties Fri Jun 1 21:32:29 2007
@@ -24,9 +24,6 @@
jsp-api.version=${jsp-api.version}
jstl.version=${jstl.version}
taglibs.standard.version=${taglibs.standard.version}
-xerces.version=${xerces.version}
-xercesImpl.version=${xerces.version}
-xmlParserAPIs.version=${xerces.version}
castor.version=${castor.version}
commons-digester.version=${commons-digester.version}
commons-cli.version=${commons-cli.version}
Modified: portals/pluto/trunk/pluto-descriptor-impl/pom.xml
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-descriptor-impl/pom.xml?view=diff&rev=543704&r1=543703&r2=543704
==============================================================================
--- portals/pluto/trunk/pluto-descriptor-impl/pom.xml (original)
+++ portals/pluto/trunk/pluto-descriptor-impl/pom.xml Fri Jun 1 21:32:29 2007
@@ -59,18 +59,6 @@
</dependency>
<dependency>
- <groupId>xerces</groupId>
- <artifactId>xercesImpl</artifactId>
- <version>${xerces.version}</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
- <groupId>xerces</groupId>
- <artifactId>xmlParserAPIs</artifactId>
- <version>${xerces.version}</version>
- <scope>compile</scope>
- </dependency>
- <dependency>
<groupId>commons-logging</groupId>
<artifactId>commons-logging-api</artifactId>
<version>${commons-logging.version}</version>
Modified: portals/pluto/trunk/pluto-descriptor-impl/src/main/java/org/apache/pluto/descriptors/services/castor/AbstractCastorDescriptorService.java
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-descriptor-impl/src/main/java/org/apache/pluto/descriptors/services/castor/AbstractCastorDescriptorService.java?view=diff&rev=543704&r1=543703&r2=543704
==============================================================================
--- portals/pluto/trunk/pluto-descriptor-impl/src/main/java/org/apache/pluto/descriptors/services/castor/AbstractCastorDescriptorService.java (original)
+++ portals/pluto/trunk/pluto-descriptor-impl/src/main/java/org/apache/pluto/descriptors/services/castor/AbstractCastorDescriptorService.java Fri Jun 1 21:32:29 2007
@@ -22,6 +22,8 @@
import java.io.OutputStream;
import java.io.OutputStreamWriter;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
import org.exolab.castor.mapping.Mapping;
import org.exolab.castor.mapping.MappingException;
import org.exolab.castor.util.LocalConfiguration;
@@ -39,6 +41,38 @@
abstract class AbstractCastorDescriptorService {
/**
+ * Logger
+ */
+ private static final Log LOG = LogFactory.getLog(AbstractCastorDescriptorService.class);
+
+ /**
+ * The name of the system property that when set to the string
+ * value "true" has Castor use JAXP instead of the parser specified
+ * by the <code>org.exolab.castor.parser</code> property.
+ *
+ * By using JAXP, the Pluto descriptor services no longer require
+ * an XML parser in a shared classloader.
+ *
+ * By default the value of this property is "true" For Pluto 1.2 and
+ * higher.
+ */
+ private static final String JAXP_PROPERTY = "org.apache.pluto.useJaxp";
+
+ /**
+ * Default value of org.apache.pluto.useJaxp system property.
+ * In Pluto 1.2.x it should be "true". In Pluto 1.1.4 and up (but still
+ * within the 1.1 line) it should be "false".
+ */
+ private static final String JAXP_DEFAULT = "true";
+
+ /**
+ * Whether or not Castor should use JAXP. If Castor is not using
+ * JAXP, then default to the parser specified by
+ * <code>org.exolab.castor.parser</code>.
+ */
+ protected static boolean USING_JAXP = System.getProperty(JAXP_PROPERTY, JAXP_DEFAULT).equalsIgnoreCase("true");
+
+ /**
* Read the and convert the descriptor into it's Object graph.
* @return
* @throws IOException
@@ -46,10 +80,24 @@
protected Object readInternal(InputStream is) throws IOException {
Object object = null;
try {
+ // Use JAXP if we are instructed to do so.
+ if (USING_JAXP) {
+ LocalConfiguration castorConfig = LocalConfiguration.getInstance();
+ // empty string means "use JAXP" for Castor
+ castorConfig.getProperties().setProperty("org.exolab.castor.parser", "");
+ castorConfig.getProperties().setProperty("org.exolab.castor.xml.serializer.factory",
+ "org.exolab.castor.xml.XercesJDK5XMLSerializerFactory" );
+ }
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Pluto descriptor service implementation using JAXP: [" + USING_JAXP + "]");
+ }
+
Mapping mapping = getCastorMapping();
Unmarshaller unmarshaller = new Unmarshaller(mapping);
unmarshaller.setEntityResolver(new EntityResolverImpl());
unmarshaller.setIgnoreExtraElements(getIgnoreExtraElements());
+
if(is!=null) {
InputStreamReader in = new InputStreamReader(is);
object = unmarshaller.unmarshal(in);
@@ -87,7 +135,21 @@
// http://castor.org/javadoc/org/exolab/castor/xml/Marshaller.html#setDoctype(java.lang.String,%20java.lang.String)
Marshaller marshaller = new Marshaller(writer);
marshaller.setMapping(getCastorMapping());
- LocalConfiguration.getInstance().getProperties().setProperty("org.exolab.castor.indent", "true");
+
+ // Use JAXP if we are instructed to do so.
+ LocalConfiguration castorConfig = LocalConfiguration.getInstance();
+ if (USING_JAXP) {
+ // empty string means "use JAXP" for Castor
+ castorConfig.getProperties().setProperty("org.exolab.castor.parser", "" );
+ castorConfig.getProperties().setProperty("org.exolab.castor.xml.serializer.factory",
+ "org.exolab.castor.xml.XercesJDK5XMLSerializerFactory" );
+ }
+
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Pluto descriptor service implementation using JAXP: [" + USING_JAXP + "]");
+ }
+
+ castorConfig.getProperties().setProperty("org.exolab.castor.indent", "true");
setCastorMarshallerOptions(marshaller, object);
marshaller.marshal(object);
} catch(IOException io) {
Added: portals/pluto/trunk/pluto-descriptor-impl/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-descriptor-impl/src/site/apt/index.apt?view=auto&rev=543704
==============================================================================
--- portals/pluto/trunk/pluto-descriptor-impl/src/site/apt/index.apt (added)
+++ portals/pluto/trunk/pluto-descriptor-impl/src/site/apt/index.apt Fri Jun 1 21:32:29 2007
@@ -0,0 +1,68 @@
+~~ Licensed to the Apache Software Foundation (ASF) under one or more
+~~ contributor license agreements. See the NOTICE file distributed with
+~~ this work for additional information regarding copyright ownership.
+~~ The ASF licenses this file to You 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.
+
+ ---
+ Pluto Descriptor Service Implementation
+ ---
+ Elliot Metsger
+ ---
+ June 1, 2006
+
+Pluto Descriptor Service Implementation
+
+ The Pluto descriptor services provide an entry point for reading and
+writing object models representing the web and portlet descriptor files
+(<<<WEB-INF/web.xml>>> and <<<WEB-INF/portlet.xml>>>). The implementation
+uses {{{http://www.castor.org}Castor}} for marshalling and unmarshalling
+the object models.
+
+ If you use the Pluto descriptor services in your own project, be
+sure to code to the interfaces <<<org.apache.pluto.descriptors.services.PortletAppDescriptorService>>>
+and <<<org.apache.pluto.descriptors.services.WebAppDescriptorService>>> and
+not directly to the implementation classes. The purpose of this documentation
+is to detail which XML parser the descriptor service implementation uses.
+
+*--------------+--------------------------------------+
+|Pluto Version |org.apache.pluto.useJaxp default value|
+*--------------+--------------------------------------+
+|1.2.x |true |
+*--------------+--------------------------------------+
+|1.1.4+ |false |
+*--------------+--------------------------------------+
+Default value of the <<<org.apache.pluto.useJaxp>>> system property
+
+* XML parsing in Pluto 1.2.x
+
+ In Pluto 1.2.x, Castor uses {{{http://java.sun.com/webservices/jaxp/}JAXP API}}
+and the default JDK 1.5 XML parser for (un)marshalling the descriptor files. Note
+that JDK 1.5 or greater is required to run Pluto 1.2.x. This eliminates the need
+for Pluto to have an XML parser in a shared classloader.
+
+ If for some reason you need to disable the use of JAXP, set the system property
+<<<org.apache.pluto.useJaxp>>> to the string <<<false>>>. When the property is
+set to <<<false>>>, Castor will use the parser defined by the
+<<<org.exolab.castor.parser>>> property. You will be responsible for providing
+the XML parser APIs and implementation libraries.
+
+* XML parsing in Pluto 1.1.4 and up
+
+ If you use Pluto 1.1.4 or greater (but still within the 1.1 line), Castor will
+use the Xerces parser distributed with Pluto, to maintain JDK 1.4 compatibility.
+However, if you run Pluto 1.1.4 under JDK 1.5, you can enable JAXP by setting the
+system property <<<org.apache.pluto.useJaxp>>> equal to the string <<<true>>>. In
+this case, the parser that was defined by the Castor property <<<org.exolab.castor.parser>>>
+will be overridden.
Added: portals/pluto/trunk/pluto-descriptor-impl/src/site/site.xml
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-descriptor-impl/src/site/site.xml?view=auto&rev=543704
==============================================================================
--- portals/pluto/trunk/pluto-descriptor-impl/src/site/site.xml (added)
+++ portals/pluto/trunk/pluto-descriptor-impl/src/site/site.xml Fri Jun 1 21:32:29 2007
@@ -0,0 +1,50 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one or more
+contributor license agreements. See the NOTICE file distributed with
+this work for additional information regarding copyright ownership.
+The ASF licenses this file to You 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.
+-->
+
+<project name="Pluto Descriptor Implementation">
+
+ <bannerLeft>
+ <name>Pluto</name>
+ <src>http://portals.apache.org/pluto/images/pluto.png</src>
+ <href>http://portals.apache.org/pluto</href>
+ </bannerLeft>
+ <bannerRight>
+ <src>http://portals.apache.org/pluto/images/banner.png</src>
+ </bannerRight>
+
+ <body>
+
+ <links>
+ <item name="Pluto Home" href="http://portals.apache.org/pluto/"/>
+ <item name="JSR 168" href="http://jcp.org/en/jsr/detail?id=168"/>
+ <item name="JSR 286" href="http://jcp.org/en/jsr/detail?id=286"/>
+ <item name="Chinese Translation" href="http://people.apache.org/~zheng/pluto/chinese/"/>
+ </links>
+
+ <menu name="Descriptor Services Implementation">
+ <item name="Getting Started" href="/index.html"/>
+ </menu>
+
+ ${reports}
+
+ </body>
+
+</project>
+
Modified: portals/pluto/trunk/pluto-portal/src/main/webapp/WEB-INF/classes/castor.properties
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pluto-portal/src/main/webapp/WEB-INF/classes/castor.properties?view=diff&rev=543704&r1=543703&r2=543704
==============================================================================
--- portals/pluto/trunk/pluto-portal/src/main/webapp/WEB-INF/classes/castor.properties (original)
+++ portals/pluto/trunk/pluto-portal/src/main/webapp/WEB-INF/classes/castor.properties Fri Jun 1 21:32:29 2007
@@ -24,5 +24,3 @@
org.exolab.castor.parser.namespaces=true
org.exolab.castor.indent=true
org.exolab.castor.debug=false
-
-
Modified: portals/pluto/trunk/pom.xml
URL: http://svn.apache.org/viewvc/portals/pluto/trunk/pom.xml?view=diff&rev=543704&r1=543703&r2=543704
==============================================================================
--- portals/pluto/trunk/pom.xml (original)
+++ portals/pluto/trunk/pom.xml Fri Jun 1 21:32:29 2007
@@ -230,7 +230,6 @@
<jsp-api.version>1.2</jsp-api.version>
<jstl.version>1.0.6</jstl.version>
<taglibs.standard.version>1.0.6</taglibs.standard.version>
- <xerces.version>2.6.2</xerces.version>
<castor.version>1.1.1</castor.version>
<commons-digester.version>1.8</commons-digester.version>
<commons-collections.version>3.2</commons-collections.version>