You are viewing a plain text version of this content. The canonical link for it is here.
Posted to scm@geronimo.apache.org by gd...@apache.org on 2003/12/11 12:56:53 UTC
cvs commit: incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/deployment/goal NormalizedURLDeploymentGoal.java URLDeploymentGoal.java DistributeURL.java RedeployURL.java DeployURL.java UndeployURL.java
gdamour 2003/12/11 03:56:53
Modified: modules/kernel/src/java/org/apache/geronimo/kernel/deployment/goal
DistributeURL.java RedeployURL.java DeployURL.java
UndeployURL.java
Added: modules/kernel/src/java/org/apache/geronimo/kernel/deployment/goal
NormalizedURLDeploymentGoal.java
URLDeploymentGoal.java
Log:
Geronimo-122 submitted by Ed Letifov.
Refactoring of the URL deployment goals.
Revision Changes Path
1.2 +3 -40 incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/deployment/goal/DistributeURL.java
Index: DistributeURL.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/deployment/goal/DistributeURL.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- DistributeURL.java 17 Nov 2003 10:57:40 -0000 1.1
+++ DistributeURL.java 11 Dec 2003 11:56:53 -0000 1.2
@@ -55,8 +55,6 @@
*/
package org.apache.geronimo.kernel.deployment.goal;
-import java.io.File;
-import java.net.MalformedURLException;
import java.net.URL;
import org.apache.geronimo.kernel.deployment.scanner.URLType;
@@ -71,43 +69,8 @@
*
* @version $Revision$ $Date$
*/
-public class DistributeURL extends DeploymentGoal {
- private final URL url;
- private final URLType type;
-
+public class DistributeURL extends NormalizedURLDeploymentGoal {
public DistributeURL(final GeronimoTargetModule targetModule, final URL url, final URLType type) {
- super(targetModule);
- if (url == null) {
- throw new IllegalArgumentException("URL is null");
- }
- if (type == null) {
- throw new IllegalArgumentException("URLType is null");
- }
-
- this.url = normalizeURL(url);
- this.type = type;
- }
-
- public URL getUrl() {
- return url;
- }
-
- public URLType getType() {
- return type;
- }
-
- private static URL normalizeURL(URL url) {
- assert url != null;
-
- if (url.getProtocol().equals("file")) {
- String filename = url.getFile().replace('/', File.separatorChar);
- File file = new File(filename);
- try {
- url = file.toURI().toURL();
- } catch (MalformedURLException ignore) {
- }
- }
-
- return url;
+ super(targetModule,url,type);
}
}
1.3 +3 -10 incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/deployment/goal/RedeployURL.java
Index: RedeployURL.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/deployment/goal/RedeployURL.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- RedeployURL.java 17 Nov 2003 10:57:40 -0000 1.2
+++ RedeployURL.java 11 Dec 2003 11:56:53 -0000 1.3
@@ -63,15 +63,8 @@
*
* @version $Revision$ $Date$
*/
-public class RedeployURL extends DeploymentGoal {
- private final URL url;
-
+public class RedeployURL extends URLDeploymentGoal {
public RedeployURL(final GeronimoTargetModule targetModule, URL url) {
- super(targetModule);
- this.url = url;
- }
-
- public URL getUrl() {
- return url;
+ super(targetModule, url, false);
}
}
1.3 +3 -40 incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/deployment/goal/DeployURL.java
Index: DeployURL.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/deployment/goal/DeployURL.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- DeployURL.java 17 Nov 2003 10:57:40 -0000 1.2
+++ DeployURL.java 11 Dec 2003 11:56:53 -0000 1.3
@@ -55,8 +55,6 @@
*/
package org.apache.geronimo.kernel.deployment.goal;
-import java.io.File;
-import java.net.MalformedURLException;
import java.net.URL;
import org.apache.geronimo.kernel.deployment.scanner.URLType;
@@ -67,43 +65,8 @@
*
* @version $Revision$ $Date$
*/
-public class DeployURL extends DeploymentGoal {
- private final URL url;
- private final URLType type;
-
+public class DeployURL extends NormalizedURLDeploymentGoal {
public DeployURL(final GeronimoTargetModule targetModule, final URL url, final URLType type) {
- super(targetModule);
- if (url == null) {
- throw new IllegalArgumentException("URL is null");
- }
- if (type == null) {
- throw new IllegalArgumentException("URLType is null");
- }
-
- this.url = normalizeURL(url);
- this.type = type;
- }
-
- public URL getUrl() {
- return url;
- }
-
- public URLType getType() {
- return type;
- }
-
- private static URL normalizeURL(URL url) {
- assert url != null;
-
- if (url.getProtocol().equals("file")) {
- String filename = url.getFile().replace('/', File.separatorChar);
- File file = new File(filename);
- try {
- url = file.toURI().toURL();
- } catch (MalformedURLException ignore) {
- }
- }
-
- return url;
+ super(targetModule, url, type);
}
}
1.3 +3 -10 incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/deployment/goal/UndeployURL.java
Index: UndeployURL.java
===================================================================
RCS file: /home/cvs/incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/deployment/goal/UndeployURL.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- UndeployURL.java 17 Nov 2003 10:57:40 -0000 1.2
+++ UndeployURL.java 11 Dec 2003 11:56:53 -0000 1.3
@@ -63,15 +63,8 @@
*
* @version $Revision$ $Date$
*/
-public class UndeployURL extends DeploymentGoal {
- private final URL url;
-
+public class UndeployURL extends URLDeploymentGoal {
public UndeployURL(final GeronimoTargetModule targetModule, URL url) {
- super(targetModule);
- this.url = url;
- }
-
- public URL getUrl() {
- return url;
+ super(targetModule, url, false);
}
}
1.1 incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/deployment/goal/NormalizedURLDeploymentGoal.java
Index: NormalizedURLDeploymentGoal.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Geronimo" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Geronimo", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* ====================================================================
*/
package org.apache.geronimo.kernel.deployment.goal;
import org.apache.geronimo.kernel.deployment.GeronimoTargetModule;
import org.apache.geronimo.kernel.deployment.scanner.URLType;
import java.net.URL;
/**
* Adds support for {@link URLType} to {@link URLDeploymentGoal}.
* Always normalizes file-protocol based URLs.
*/
class NormalizedURLDeploymentGoal extends URLDeploymentGoal {
private final URLType type;
/**
* Initializes the NormalizedURLDeploymentGoal.
* File-protocol based URLs are normalized.
* @param targetModule associated GeronimoTargetModule
* @param url associated URL
* @param type associated URLType
* @throws IllegalArgumentException if either <code>url</code>
* or <code>type</code> parameters are passed as <code>null</code>.
*/
protected NormalizedURLDeploymentGoal(GeronimoTargetModule targetModule, URL url, URLType type) {
super(targetModule, url, true);
if (type == null) {
throw new IllegalArgumentException("URLType is null");
}
this.type = type;
}
/**
* Returns the URLType used on creation
* @return URLType used on creation
*/
public URLType getType() {
return type;
}
}
1.1 incubator-geronimo/modules/kernel/src/java/org/apache/geronimo/kernel/deployment/goal/URLDeploymentGoal.java
Index: URLDeploymentGoal.java
===================================================================
/* ====================================================================
* The Apache Software License, Version 1.1
*
* Copyright (c) 2003 The Apache Software Foundation. All rights
* reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in
* the documentation and/or other materials provided with the
* distribution.
*
* 3. The end-user documentation included with the redistribution,
* if any, must include the following acknowledgment:
* "This product includes software developed by the
* Apache Software Foundation (http://www.apache.org/)."
* Alternately, this acknowledgment may appear in the software itself,
* if and wherever such third-party acknowledgments normally appear.
*
* 4. The names "Apache" and "Apache Software Foundation" and
* "Apache Geronimo" must not be used to endorse or promote products
* derived from this software without prior written permission. For
* written permission, please contact apache@apache.org.
*
* 5. Products derived from this software may not be called "Apache",
* "Apache Geronimo", nor may "Apache" appear in their name, without
* prior written permission of the Apache Software Foundation.
*
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
* ====================================================================
*
* This software consists of voluntary contributions made by many
* individuals on behalf of the Apache Software Foundation. For more
* information on the Apache Software Foundation, please see
* <http://www.apache.org/>.
*
* ====================================================================
*/
package org.apache.geronimo.kernel.deployment.goal;
import org.apache.geronimo.kernel.deployment.GeronimoTargetModule;
import java.net.URL;
import java.net.MalformedURLException;
import java.io.File;
/**
* Adds support for URL to the DeploymentGoal.
* Can be used with or without normalizing of the file-protocl based URLs.
*/
abstract class URLDeploymentGoal extends DeploymentGoal {
protected final URL url;
/**
* Initializes the URLDeploymentGoal.
* File-protocol based URLs are normalized if the <code>normalize</code> parameter is set to <code>true</code>.
* @param targetModule associated GeronimoTargetModule
* @param url associated URL
* @param normalize indicates if the provided URL must be normalized.
* @throws IllegalArgumentException if urls are to be normalized and
* <code>url</code> parameter is passed as <code>null</code>.
*/
protected URLDeploymentGoal(GeronimoTargetModule targetModule, URL url, final boolean normalize) {
super(targetModule);
if (normalize) {
if (url == null) {
throw new IllegalArgumentException("URL is null");
}
this.url = normalizeURL(url);
} else {
this.url = url;
}
}
/**
* Gets the value of <code>url</code> attribute.
* If the original url was file-protocol based a normalized form is returned.
* @return the original or normalized url
*/
public URL getUrl() {
return url;
}
private static URL normalizeURL(URL url) {
assert url != null;
if (url.getProtocol().equals("file")) {
String filename = url.getFile().replace('/', File.separatorChar);
File file = new File(filename);
try {
url = file.toURI().toURL();
} catch (MalformedURLException ignore) {
}
}
return url;
}
}