You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by cz...@apache.org on 2006/12/25 22:43:29 UTC
svn commit: r490176 - in /cocoon/trunk/core: ./
cocoon-configuration/cocoon-configuration-impl/src/main/java/org/apache/cocoon/configuration/impl/
cocoon-xml/cocoon-xml-impl/src/main/java/org/apache/cocoon/core/xml/impl/
cocoon-xml/cocoon-xml-resolver/...
Author: cziegeler
Date: Mon Dec 25 13:43:28 2006
New Revision: 490176
URL: http://svn.apache.org/viewvc?view=rev&rev=490176
Log:
Activate xml modules
Implement system entity resolver
Added:
cocoon/trunk/core/cocoon-xml/cocoon-xml-resolver/src/main/java/org/
cocoon/trunk/core/cocoon-xml/cocoon-xml-resolver/src/main/java/org/apache/
cocoon/trunk/core/cocoon-xml/cocoon-xml-resolver/src/main/java/org/apache/cocoon/
cocoon/trunk/core/cocoon-xml/cocoon-xml-resolver/src/main/java/org/apache/cocoon/core/
cocoon/trunk/core/cocoon-xml/cocoon-xml-resolver/src/main/java/org/apache/cocoon/core/xml/
cocoon/trunk/core/cocoon-xml/cocoon-xml-resolver/src/main/java/org/apache/cocoon/core/xml/resolver/
cocoon/trunk/core/cocoon-xml/cocoon-xml-resolver/src/main/java/org/apache/cocoon/core/xml/resolver/CocoonSystemResolver.java (with props)
cocoon/trunk/core/cocoon-xml/cocoon-xml-resolver/src/main/resources/META-INF/cocoon/spring/
cocoon/trunk/core/cocoon-xml/cocoon-xml-resolver/src/main/resources/META-INF/cocoon/spring/cocoon-xml-resolver.xml (with props)
Modified:
cocoon/trunk/core/cocoon-configuration/cocoon-configuration-impl/src/main/java/org/apache/cocoon/configuration/impl/DeploymentUtil.java
cocoon/trunk/core/cocoon-xml/cocoon-xml-impl/src/main/java/org/apache/cocoon/core/xml/impl/DefaultEntityResolver.java
cocoon/trunk/core/cocoon-xml/cocoon-xml-resolver/pom.xml
cocoon/trunk/core/pom.xml
Modified: cocoon/trunk/core/cocoon-configuration/cocoon-configuration-impl/src/main/java/org/apache/cocoon/configuration/impl/DeploymentUtil.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-configuration/cocoon-configuration-impl/src/main/java/org/apache/cocoon/configuration/impl/DeploymentUtil.java?view=diff&rev=490176&r1=490175&r2=490176
==============================================================================
--- cocoon/trunk/core/cocoon-configuration/cocoon-configuration-impl/src/main/java/org/apache/cocoon/configuration/impl/DeploymentUtil.java (original)
+++ cocoon/trunk/core/cocoon-configuration/cocoon-configuration-impl/src/main/java/org/apache/cocoon/configuration/impl/DeploymentUtil.java Mon Dec 25 13:43:28 2006
@@ -135,6 +135,27 @@
deployBlockResources("blocks", destinationDirectory);
}
+ public static void deployJarResources(String pattern, String destinationDirectory)
+ throws IOException {
+ final Enumeration jarUrls = DeploymentUtil.class.getClassLoader().getResources(pattern);
+ while ( jarUrls.hasMoreElements() ) {
+ final URL resourceUrl = (URL)jarUrls.nextElement();
+
+ String url = resourceUrl.toExternalForm();
+ // we only handle jars!
+ if ( "jar".equals(resourceUrl.getProtocol()) ) {
+ // if this is a jar url, it has this form: "jar:{url-to-jar}!/{resource-path}"
+ // to open the jar, we can simply remove everything after "!/"
+ int pos = url.indexOf('!');
+ url = url.substring(0, pos+2); // +2 as we include "!/"
+ final URL jarUrl = new URL(url);
+ final JarURLConnection connection = (JarURLConnection)jarUrl.openConnection();
+ final JarFile jarFile = connection.getJarFile();
+ deploy(jarFile, pattern, destinationDirectory);
+ }
+ }
+ }
+
/**
* Get a map that associates a block name with the root URL of the blocks resources
*
Modified: cocoon/trunk/core/cocoon-xml/cocoon-xml-impl/src/main/java/org/apache/cocoon/core/xml/impl/DefaultEntityResolver.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-xml/cocoon-xml-impl/src/main/java/org/apache/cocoon/core/xml/impl/DefaultEntityResolver.java?view=diff&rev=490176&r1=490175&r2=490176
==============================================================================
--- cocoon/trunk/core/cocoon-xml/cocoon-xml-impl/src/main/java/org/apache/cocoon/core/xml/impl/DefaultEntityResolver.java (original)
+++ cocoon/trunk/core/cocoon-xml/cocoon-xml-impl/src/main/java/org/apache/cocoon/core/xml/impl/DefaultEntityResolver.java Mon Dec 25 13:43:28 2006
@@ -123,9 +123,9 @@
* Set the configuration. Load the system catalog and apply any
* parameters that may have been specified in cocoon.xconf
* @param params The configuration information
- * @exception ParameterException
*/
- protected void init() {
+ protected void init()
+ throws Exception {
// Over-ride debug level that is set by CatalogManager.properties
if ( this.verbosity != null ) {
if (this.getLogger().isDebugEnabled()) {
Modified: cocoon/trunk/core/cocoon-xml/cocoon-xml-resolver/pom.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-xml/cocoon-xml-resolver/pom.xml?view=diff&rev=490176&r1=490175&r2=490176
==============================================================================
--- cocoon/trunk/core/cocoon-xml/cocoon-xml-resolver/pom.xml (original)
+++ cocoon/trunk/core/cocoon-xml/cocoon-xml-resolver/pom.xml Mon Dec 25 13:43:28 2006
@@ -35,6 +35,11 @@
<dependencies>
<dependency>
<groupId>org.apache.cocoon</groupId>
+ <artifactId>cocoon-configuration-impl</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.cocoon</groupId>
<artifactId>cocoon-xml-impl</artifactId>
<version>1.0.0-SNAPSHOT</version>
</dependency>
Added: cocoon/trunk/core/cocoon-xml/cocoon-xml-resolver/src/main/java/org/apache/cocoon/core/xml/resolver/CocoonSystemResolver.java
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-xml/cocoon-xml-resolver/src/main/java/org/apache/cocoon/core/xml/resolver/CocoonSystemResolver.java?view=auto&rev=490176
==============================================================================
--- cocoon/trunk/core/cocoon-xml/cocoon-xml-resolver/src/main/java/org/apache/cocoon/core/xml/resolver/CocoonSystemResolver.java (added)
+++ cocoon/trunk/core/cocoon-xml/cocoon-xml-resolver/src/main/java/org/apache/cocoon/core/xml/resolver/CocoonSystemResolver.java Mon Dec 25 13:43:28 2006
@@ -0,0 +1,55 @@
+/*
+ * 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.
+ */
+package org.apache.cocoon.core.xml.resolver;
+
+import java.io.File;
+
+import org.apache.cocoon.configuration.Settings;
+import org.apache.cocoon.configuration.impl.DeploymentUtil;
+import org.apache.cocoon.core.xml.impl.DefaultEntityResolver;
+
+/**
+ *
+ * @version $Id$
+ * @since 2.2
+ */
+public class CocoonSystemResolver extends DefaultEntityResolver {
+
+ /** Cocoon settings. */
+ protected Settings settings;
+
+ public void setSettings(Settings settings) {
+ this.settings = settings;
+ }
+
+ /**
+ * @see org.apache.cocoon.core.xml.impl.DefaultEntityResolver#init()
+ */
+ protected void init()
+ throws Exception {
+ // create temporary directory for our entities
+ final File workDirectory = new File(settings.getWorkDirectory());
+ final File entitiesDirectory = new File(workDirectory, "cocoon_xml_resolver_entities");
+ entitiesDirectory.mkdir();
+ // deploy resources
+ DeploymentUtil.deployJarResources("META-INF/cocoon/entities", entitiesDirectory.getAbsolutePath());
+ // set catalog
+ this.setCatalog(entitiesDirectory.getAbsolutePath() + File.separator + "catalog");
+ // now initialize
+ super.init();
+ }
+}
Propchange: cocoon/trunk/core/cocoon-xml/cocoon-xml-resolver/src/main/java/org/apache/cocoon/core/xml/resolver/CocoonSystemResolver.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/trunk/core/cocoon-xml/cocoon-xml-resolver/src/main/java/org/apache/cocoon/core/xml/resolver/CocoonSystemResolver.java
------------------------------------------------------------------------------
svn:keywords = Id
Added: cocoon/trunk/core/cocoon-xml/cocoon-xml-resolver/src/main/resources/META-INF/cocoon/spring/cocoon-xml-resolver.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/cocoon-xml/cocoon-xml-resolver/src/main/resources/META-INF/cocoon/spring/cocoon-xml-resolver.xml?view=auto&rev=490176
==============================================================================
--- cocoon/trunk/core/cocoon-xml/cocoon-xml-resolver/src/main/resources/META-INF/cocoon/spring/cocoon-xml-resolver.xml (added)
+++ cocoon/trunk/core/cocoon-xml/cocoon-xml-resolver/src/main/resources/META-INF/cocoon/spring/cocoon-xml-resolver.xml Mon Dec 25 13:43:28 2006
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN"
+ "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
+<!--
+ 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.
+-->
+
+<!-- @version $Id$ -->
+<beans>
+ <!-- The Entity Resolver -->
+ <bean name="org.xml.sax.EntityResolver"
+ class="org.apache.cocoon.core.xml.resolver.CocoonSystemResolver">
+ <property name="settings" ref="org.apache.cocoon.configuration.Settings"></property>
+ </bean>
+</beans>
\ No newline at end of file
Propchange: cocoon/trunk/core/cocoon-xml/cocoon-xml-resolver/src/main/resources/META-INF/cocoon/spring/cocoon-xml-resolver.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: cocoon/trunk/core/cocoon-xml/cocoon-xml-resolver/src/main/resources/META-INF/cocoon/spring/cocoon-xml-resolver.xml
------------------------------------------------------------------------------
svn:keywords = Id
Modified: cocoon/trunk/core/pom.xml
URL: http://svn.apache.org/viewvc/cocoon/trunk/core/pom.xml?view=diff&rev=490176&r1=490175&r2=490176
==============================================================================
--- cocoon/trunk/core/pom.xml (original)
+++ cocoon/trunk/core/pom.xml Mon Dec 25 13:43:28 2006
@@ -43,6 +43,7 @@
<module>cocoon-thread</module>
<module>cocoon-util</module>
<module>cocoon-webapp</module>
+ <module>cocoon-xml</module>
</modules>
<scm>
<connection>scm:svn:http://svn.apache.org/repos/asf/cocoon/trunk/core</connection>