You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@maven.apache.org by br...@apache.org on 2005/05/21 17:17:51 UTC
svn commit: r171223 - in /maven/maven-1/jelly-tags/trunk: project.xml
src/main/java/org/apache/maven/jelly/tags/maven/GrabClassLoaderTag.java
src/main/java/org/apache/maven/jelly/tags/maven/MavenTagLibrary.java
src/main/java/org/apache/maven/jelly/tags/maven/UnGrabClassLoaderTag.java
Author: brett
Date: Sat May 21 08:17:50 2005
New Revision: 171223
URL: http://svn.apache.org/viewcvs?rev=171223&view=rev
Log:
PR: MPXDOC-128
Submitted by: Vincent Siveton
Reviewed by: Brett Porter, Arnaud Heritier
Internationalization support for xdoc.
Applied with changes
Added:
maven/maven-1/jelly-tags/trunk/src/main/java/org/apache/maven/jelly/tags/maven/GrabClassLoaderTag.java (with props)
maven/maven-1/jelly-tags/trunk/src/main/java/org/apache/maven/jelly/tags/maven/UnGrabClassLoaderTag.java (with props)
Modified:
maven/maven-1/jelly-tags/trunk/project.xml
maven/maven-1/jelly-tags/trunk/src/main/java/org/apache/maven/jelly/tags/maven/MavenTagLibrary.java
Modified: maven/maven-1/jelly-tags/trunk/project.xml
URL: http://svn.apache.org/viewcvs/maven/maven-1/jelly-tags/trunk/project.xml?rev=171223&r1=171222&r2=171223&view=diff
==============================================================================
--- maven/maven-1/jelly-tags/trunk/project.xml (original)
+++ maven/maven-1/jelly-tags/trunk/project.xml Sat May 21 08:17:50 2005
@@ -182,6 +182,10 @@
<version>1.0</version>
<url>http://jakarta.apache.org/commons/jelly/tags/ant/</url>
</dependency>
+ <dependency>
+ <id>forehead</id>
+ <version>1.0-beta-5</version>
+ </dependency>
<!-- Runtime dependencies -->
<dependency>
Added: maven/maven-1/jelly-tags/trunk/src/main/java/org/apache/maven/jelly/tags/maven/GrabClassLoaderTag.java
URL: http://svn.apache.org/viewcvs/maven/maven-1/jelly-tags/trunk/src/main/java/org/apache/maven/jelly/tags/maven/GrabClassLoaderTag.java?rev=171223&view=auto
==============================================================================
--- maven/maven-1/jelly-tags/trunk/src/main/java/org/apache/maven/jelly/tags/maven/GrabClassLoaderTag.java (added)
+++ maven/maven-1/jelly-tags/trunk/src/main/java/org/apache/maven/jelly/tags/maven/GrabClassLoaderTag.java Sat May 21 08:17:50 2005
@@ -0,0 +1,89 @@
+package org.apache.maven.jelly.tags.maven;
+
+/* ====================================================================
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * 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.
+ * ====================================================================
+ */
+
+import java.io.File;
+import java.net.MalformedURLException;
+
+import org.apache.commons.jelly.JellyTagException;
+import org.apache.commons.jelly.MissingAttributeException;
+import org.apache.commons.jelly.XMLOutput;
+import org.apache.maven.jelly.tags.BaseTagSupport;
+
+import com.werken.forehead.ForeheadClassLoader;
+
+/**
+ * Add a specific ressource to the current Maven context
+ *
+ * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton</a>
+ * @version 1.0
+ */
+public class GrabClassLoaderTag extends BaseTagSupport {
+ /** Resource to include in the Maven context. */
+ private String resource;
+
+ /*
+ * @see org.apache.commons.jelly.Tag#doTag(org.apache.commons.jelly.XMLOutput)
+ */
+ public void doTag(XMLOutput arg0) throws MissingAttributeException, JellyTagException {
+ if (getMavenContext() == null) {
+ throw new JellyTagException("The current MavenContext is null!");
+ }
+
+ checkAttribute(this.resource, "include");
+
+ ForeheadClassLoader currentClassLoader = null;
+ try {
+ currentClassLoader = (ForeheadClassLoader) getMavenContext().getClassLoader();
+ } catch (ClassCastException e) {
+ throw new JellyTagException("The current classloader in the MavenContext is not an instance of ForeheadClassLoader");
+ }
+
+ if (currentClassLoader == null) {
+ throw new JellyTagException("No classloader found in the current MavenContext");
+ }
+
+ try {
+ File f = new File(this.resource);
+
+ currentClassLoader.addURL(f.toURL());
+ } catch (MalformedURLException e) {
+ throw new JellyTagException("The directory to include specified by " + getResource() + " is malformed");
+ }
+
+ ForeheadClassLoader newClassLoader = new ForeheadClassLoader(currentClassLoader, currentClassLoader.getName() + "_TEMP");
+ getMavenContext().setClassLoader(newClassLoader);
+ }
+
+ /**
+ * Get the includeDir.
+ *
+ * @return the includeDir.
+ */
+ public String getResource() {
+ return this.resource;
+ }
+ /**
+ * Set the includeDir
+ *
+ * @param includeDir includeDir to set.
+ */
+ public void setResource(String includeDir) {
+ this.resource = includeDir;
+ }
+}
Propchange: maven/maven-1/jelly-tags/trunk/src/main/java/org/apache/maven/jelly/tags/maven/GrabClassLoaderTag.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/maven-1/jelly-tags/trunk/src/main/java/org/apache/maven/jelly/tags/maven/GrabClassLoaderTag.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
Modified: maven/maven-1/jelly-tags/trunk/src/main/java/org/apache/maven/jelly/tags/maven/MavenTagLibrary.java
URL: http://svn.apache.org/viewcvs/maven/maven-1/jelly-tags/trunk/src/main/java/org/apache/maven/jelly/tags/maven/MavenTagLibrary.java?rev=171223&r1=171222&r2=171223&view=diff
==============================================================================
--- maven/maven-1/jelly-tags/trunk/src/main/java/org/apache/maven/jelly/tags/maven/MavenTagLibrary.java (original)
+++ maven/maven-1/jelly-tags/trunk/src/main/java/org/apache/maven/jelly/tags/maven/MavenTagLibrary.java Sat May 21 08:17:50 2005
@@ -58,5 +58,8 @@
registerTag( "user-check", UserCheck.class);
registerTag( "param-check", ParamCheck.class);
registerTag( "copy-resources", CopyResources.class);
+
+ registerTag( "grabClassLoader", GrabClassLoaderTag.class);
+ registerTag( "unGrabClassLoader", UnGrabClassLoaderTag.class);
}
}
Added: maven/maven-1/jelly-tags/trunk/src/main/java/org/apache/maven/jelly/tags/maven/UnGrabClassLoaderTag.java
URL: http://svn.apache.org/viewcvs/maven/maven-1/jelly-tags/trunk/src/main/java/org/apache/maven/jelly/tags/maven/UnGrabClassLoaderTag.java?rev=171223&view=auto
==============================================================================
--- maven/maven-1/jelly-tags/trunk/src/main/java/org/apache/maven/jelly/tags/maven/UnGrabClassLoaderTag.java (added)
+++ maven/maven-1/jelly-tags/trunk/src/main/java/org/apache/maven/jelly/tags/maven/UnGrabClassLoaderTag.java Sat May 21 08:17:50 2005
@@ -0,0 +1,58 @@
+package org.apache.maven.jelly.tags.maven;
+
+/* ====================================================================
+ * Copyright 2001-2004 The Apache Software Foundation.
+ *
+ * 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.
+ * ====================================================================
+ */
+
+import org.apache.commons.jelly.JellyTagException;
+import org.apache.commons.jelly.MissingAttributeException;
+import org.apache.commons.jelly.XMLOutput;
+import org.apache.maven.jelly.tags.BaseTagSupport;
+
+import com.werken.forehead.ForeheadClassLoader;
+
+/**
+ * Return to the old classloader
+ *
+ * @see GrabClassLoaderTag
+ *
+ * @author <a href="mailto:vincent.siveton@gmail.com">Vincent Siveton </a>
+ * @version 1.0
+ */
+public class UnGrabClassLoaderTag extends BaseTagSupport {
+ /*
+ * @see org.apache.commons.jelly.Tag#doTag(org.apache.commons.jelly.XMLOutput)
+ */
+ public void doTag(XMLOutput arg0) throws MissingAttributeException, JellyTagException {
+ if (getMavenContext() == null) {
+ throw new JellyTagException("The current MavenContext is null!");
+ }
+
+ ForeheadClassLoader currentClassLoader = null;
+ try {
+ currentClassLoader = (ForeheadClassLoader) getMavenContext().getClassLoader();
+ } catch (ClassCastException e) {
+ throw new JellyTagException("The current classloader in the MavenContext is not an instance of ForeheadClassLoader");
+ }
+
+ if (currentClassLoader == null) {
+ throw new JellyTagException("No classloader found in the current MavenContext");
+ }
+
+ ClassLoader oldClassLoader = currentClassLoader.getParent();
+ getMavenContext().setClassLoader(oldClassLoader);
+ }
+}
Propchange: maven/maven-1/jelly-tags/trunk/src/main/java/org/apache/maven/jelly/tags/maven/UnGrabClassLoaderTag.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/maven-1/jelly-tags/trunk/src/main/java/org/apache/maven/jelly/tags/maven/UnGrabClassLoaderTag.java
------------------------------------------------------------------------------
svn:keywords = "Author Date Id Revision"
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org