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:34:34 UTC
svn commit: r543705 - in
/portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src:
main/java/org/apache/pluto/descriptors/services/castor/AbstractCastorDescriptorService.java
site/apt/ site/apt/index.apt site/site.xml
Author: esm
Date: Fri Jun 1 21:34:33 2007
New Revision: 543705
URL: http://svn.apache.org/viewvc?view=rev&rev=543705
Log:
[PLUTO-347]: If Pluto 1.1.x is being run under JDK 1.5+, give the option of using JAXP. Added system property org.apache.pluto.useJaxp with a default value of false, to maintain JDK 1.4/Pluto 1.1.x compatability.
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/branches/pluto-1.1.x/pluto-descriptor-impl/src/site/apt/
portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/site/apt/index.apt
Modified:
portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/main/java/org/apache/pluto/descriptors/services/castor/AbstractCastorDescriptorService.java
portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/site/site.xml
Modified: portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/main/java/org/apache/pluto/descriptors/services/castor/AbstractCastorDescriptorService.java
URL: http://svn.apache.org/viewvc/portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/main/java/org/apache/pluto/descriptors/services/castor/AbstractCastorDescriptorService.java?view=diff&rev=543705&r1=543704&r2=543705
==============================================================================
--- portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/main/java/org/apache/pluto/descriptors/services/castor/AbstractCastorDescriptorService.java (original)
+++ portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/main/java/org/apache/pluto/descriptors/services/castor/AbstractCastorDescriptorService.java Fri Jun 1 21:34:33 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 = "false";
+
+ /**
+ * 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/branches/pluto-1.1.x/pluto-descriptor-impl/src/site/apt/index.apt
URL: http://svn.apache.org/viewvc/portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/site/apt/index.apt?view=auto&rev=543705
==============================================================================
--- portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/site/apt/index.apt (added)
+++ portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/site/apt/index.apt Fri Jun 1 21:34:33 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.
Modified: portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/site/site.xml
URL: http://svn.apache.org/viewvc/portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/site/site.xml?view=diff&rev=543705&r1=543704&r2=543705
==============================================================================
--- portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/site/site.xml (original)
+++ portals/pluto/branches/pluto-1.1.x/pluto-descriptor-impl/src/site/site.xml Fri Jun 1 21:34:33 2007
@@ -1,24 +1,28 @@
-<?xml version="1.0" encoding="ISO-8859-1"?>
+<?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.
+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="Maven">
+
+<project name="Pluto Descriptor Implementation">
+
<bannerLeft>
<name>Pluto</name>
- <src>http://portals.apache.org/pluto/images/pluto11.png</src>
+ <src>http://portals.apache.org/pluto/images/pluto.png</src>
<href>http://portals.apache.org/pluto</href>
</bannerLeft>
<bannerRight>
@@ -29,16 +33,24 @@
<groupId>org.apache.pluto</groupId>
<artifactId>pluto-site-skin</artifactId>
<version>1.1.4-SNAPSHOT</version>
- </skin>
-
+ </skin>
+
<body>
+
<links>
- <item name="Pluto Home" href="http://portals.apache.org/pluto"/>
+ <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="Chinese Translation" href="http://heavyz.sourceforge.net/pluto_zh/pluto-container"/>
+ <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>
+