Skip to Content.
Sympa Menu

notify-dpml - r1845 - trunk/main/transit/core/src/main/net/dpml/transit/layout

notify-dpml AT lists.ibiblio.org

Subject: DPML Notify

List archive

Chronological Thread  
  • From: mcconnell at BerliOS <mcconnell AT mail.berlios.de>
  • To: notify-dpml AT lists.ibiblio.org
  • Subject: r1845 - trunk/main/transit/core/src/main/net/dpml/transit/layout
  • Date: Fri, 9 Feb 2007 00:53:33 +0100

Author: mcconnell
Date: 2007-02-09 00:53:26 +0100 (Fri, 09 Feb 2007)
New Revision: 1845

Added:
trunk/main/transit/core/src/main/net/dpml/transit/layout/ClassicLayout.java
trunk/main/transit/core/src/main/net/dpml/transit/layout/EclipseLayout.java
trunk/main/transit/core/src/main/net/dpml/transit/layout/ModernLayout.java
trunk/main/transit/core/src/main/net/dpml/transit/layout/package-info.java
Log:
SDK 2.X staged commit.

Copied:
trunk/main/transit/core/src/main/net/dpml/transit/layout/ClassicLayout.java
(from rev 1789,
trunk/main/transit/core/src/main/net/dpml/transit/ClassicLayout.java)
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/ClassicLayout.java
2006-11-30 21:08:46 UTC (rev 1789)
+++
trunk/main/transit/core/src/main/net/dpml/transit/layout/ClassicLayout.java
2007-02-08 23:53:26 UTC (rev 1845)
@@ -0,0 +1,134 @@
+/*
+ * Copyright 2004-2005 Stephen J. McConnell.
+ * Copyright 2004 Niclas Hedhman.
+ *
+ * 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.
+ */
+
+package net.dpml.transit.layout;
+
+import net.dpml.transit.Artifact;
+import net.dpml.transit.Layout;
+import net.dpml.transit.TransitRuntimeException;
+
+/**
+ * The ClassicLayout decodes artifacts into the Classic/Maven layout
+ * of artifacts on a file system or http server.
+ * This format says that for an artifact
<code>artifact:[type]:[group]/[name]#[version]</code>
+ * the location of such artifact would be;
+ * <code>[group]/[type]s/[name]-[version].[type]</code>.
+ * Example; <code>artifact:jar:metro/cache/dpml-cache-main#1.0.0</code>
+ * would return the path
<code>metro/cache/jars/dpml-cache-main-1.0.0.jar</code>.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class ClassicLayout extends Layout
+{
+ private static final String CLASSIC_IDENTIFIER = "classic";
+
+ /**
+ * Return the layout identifier. The id value is used
+ * to identify layout instances assigned to cache handlers and
+ * resource host handlers.
+ *
+ * @return the layout id
+ */
+ public String getID()
+ {
+ return CLASSIC_IDENTIFIER;
+ }
+
+ /**
+ * Return the base path for an artifact. The base path is derived from
+ * the artifact group and type. For an artifact group of "metro/cache"
and a
+ * type equal to "jar", the base value will be translated using the
pattern
+ * "[group]/[type]s" to form "metro/cache/jars". The base path value
represents
+ * the directory path relative to a repository root of the directory
containing
+ * this artifact.
+ *
+ * @param artifact the resource artifact
+ * @return the base path
+ */
+ public final String resolveBase( Artifact artifact )
+ {
+ if( null == artifact.getGroup() )
+ {
+ return artifact.getType() + "s";
+ }
+ else
+ {
+ return artifact.getGroup() + "/" + artifact.getType() + "s";
+ }
+ }
+
+ /**
+ * Returns the full path of the artifact relative to a logical root
directory.
+ * The full path is equivalent to the base path and artifact filename
using the
+ * pattern "[base]/[filename]". Path values may be used to resolve an
artifact
+ * from a remote repository or local cache relative to the repository or
cache
+ * root. An artifact such as
<code>artifact:jar:metro/cache/dpml-cache-main#1.0.0</code>
+ * would return the path
<code>metro/cache/jars/dpml-cache-main-1.0.0.jar</code>.
+ *
+ * @param artifact the resource artifact
+ * @see #resolveBase
+ * @see #resolveFilename
+ * @return the logical artifact path
+ */
+ public final String resolvePath( Artifact artifact )
+ {
+ return resolveBase( artifact ) + "/" + resolveFilename( artifact );
+ }
+
+ /**
+ * Return the expanded filename of the artifact. The filename is
expressed
+ * as [name]-[version].[type] or in case of a null version simply
[name].[type].
+ *
+ * @param artifact the resource artifact
+ * @return the artifact expanded filename
+ */
+ public String resolveFilename( Artifact artifact )
+ {
+ String scheme = artifact.getScheme();
+ String filename = resolveBaseFilename( artifact );
+ if( "artifact".equals( scheme ) )
+ {
+ return filename;
+ }
+ else if( "link".equals( scheme ) )
+ {
+ return filename + ".link";
+ }
+ else
+ {
+ final String error =
+ "Protocol not recognized: " + scheme;
+ throw new TransitRuntimeException( error );
+ }
+ }
+
+ private String resolveBaseFilename( Artifact artifact )
+ {
+ String ver = artifact.getVersion();
+ if( null == ver )
+ {
+ return artifact.getName() + "." + artifact.getType();
+ }
+ else
+ {
+ return artifact.getName() + "-" + ver + "." + artifact.getType();
+ }
+ }
+}

Copied:
trunk/main/transit/core/src/main/net/dpml/transit/layout/EclipseLayout.java
(from rev 1789,
trunk/main/transit/core/src/main/net/dpml/transit/EclipseLayout.java)
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/EclipseLayout.java
2006-11-30 21:08:46 UTC (rev 1789)
+++
trunk/main/transit/core/src/main/net/dpml/transit/layout/EclipseLayout.java
2007-02-08 23:53:26 UTC (rev 1845)
@@ -0,0 +1,161 @@
+/*
+ * Copyright 2004-2005 Stephen J. McConnell.
+ * Copyright 2004 Niclas Hedhman.
+ *
+ * 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.
+ */
+
+package net.dpml.transit.layout;
+
+import net.dpml.transit.Artifact;
+import net.dpml.transit.Layout;
+import net.dpml.transit.TransitRuntimeException;
+
+/**
+ * The EclipseLayout decodes artifacts into the Eclipse specified layout
+ * of artifacts on a file system or http server.
+ * This format says that for an artifact
<code>artifact:[type]:[group]/[name]#[version]</code>
+ * the location of such artifact would be;
+ * <code>[group]-[version]/[name].[type]</code>.
+ * Example;
<code>artifact:jar:eclipse/plugins/eclipse-osgi-runtime/core#3.1.0</code>
+ * would return the path
<code>eclipse/plugins/eclipse-osgi-runtime-3.1.0/core.jar</code>.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class EclipseLayout extends Layout
+{
+ private static final String LAYOUT_IDENTIFIER = "eclipse";
+
+ /**
+ * Return the layout identifier. The id value is used
+ * to identify layout instances assigned to cache handlers and
+ * resource host handlers.
+ *
+ * @return the layout id
+ */
+ public String getID()
+ {
+ return LAYOUT_IDENTIFIER;
+ }
+
+ /**
+ * Return the base path for an artifact. The base path is derived from
+ * the artifact group and version. For an artifact group of
"metro/cache" and a
+ * version equal to "1.3", the base value will be translated using the
pattern
+ * "[group]-[version]" to form "metro/cache-1.3". The base path value
represents
+ * the directory path relative to a repository root of the directory
containing
+ * this artifact.
+ *
+ * @param artifact the artifact to resolve the base path from
+ * @return the base path
+ */
+ public final String resolveBase( Artifact artifact )
+ {
+ if( null == artifact.getGroup() )
+ {
+ return artifact.getVersion();
+ }
+ else
+ {
+ return artifact.getGroup() + "-" + artifact.getVersion();
+ }
+ }
+
+ /**
+ * Returns the full path of the artifact relative to a logical root
directory.
+ * The full path is equivalent to the base path and artifact filename
using the
+ * pattern "[base]/[filename]". Path values may be used to resolve an
artifact
+ * from a remote repository or local cache relative to the repository or
cache
+ * root. An artifact such as
+ *
<code>artifact:jar:eclipse/plugins/eclipse-osgi-runtime/core#3.1.0</code>
+ * would return the path
+ * <code>eclipse/plugins/eclipse-osgi-runtime-3.1.0/core.jar</code>.
+ *
+ * @param artifact the artifact to resolve the path from
+ * @see #resolveBase
+ * @see #resolveFilename
+ * @return the logical artifact path
+ */
+ public final String resolvePath( Artifact artifact )
+ {
+ return resolveBase( artifact ) + "/" + resolveFilename( artifact );
+ }
+
+ /**
+ * Return the expanded filename of the artifact.
+ * The filename is expressed as <code>[name].[type]</code>.
+ *
+ * @param artifact the artifact to resolve
+ * @return the artifact expanded filename
+ */
+ public String resolveFilename( Artifact artifact )
+ {
+ String scheme = artifact.getScheme();
+ String filename = resolveBaseFilename( artifact );
+ if( "artifact".equals( scheme ) )
+ {
+ return filename;
+ }
+ else if( "link".equals( scheme ) )
+ {
+ return filename + ".link";
+ }
+ else
+ {
+ final String error =
+ "Protocol not recognized: " + scheme;
+ throw new TransitRuntimeException( error );
+ }
+ }
+
+ /**
+ * Return the expanded filename of the artifact.
+ * The filename is expressed as <code>[name].[type]</code>.
+ *
+ * @param artifact the artifact to resolve
+ * @return the artifact expanded filename
+ */
+ public String resolveBaseFilename( Artifact artifact )
+ {
+ return artifact.getName() + "." + artifact.getType();
+ }
+
+ /**
+ * Compare this object with another for equality.
+ * @param other the object to compare with this object
+ * @return true if the objects are equal
+ */
+ public boolean equals( Object other )
+ {
+ if( null == other )
+ {
+ return false;
+ }
+ else
+ {
+ return getClass().equals( other.getClass() );
+ }
+ }
+
+ /**
+ * Compare the object hash code.
+ * @return the hash value
+ */
+ public int hashCode()
+ {
+ return getClass().hashCode();
+ }
+}

Copied:
trunk/main/transit/core/src/main/net/dpml/transit/layout/ModernLayout.java
(from rev 1789,
trunk/main/transit/core/src/main/net/dpml/transit/ModernLayout.java)
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/ModernLayout.java
2006-11-30 21:08:46 UTC (rev 1789)
+++
trunk/main/transit/core/src/main/net/dpml/transit/layout/ModernLayout.java
2007-02-08 23:53:26 UTC (rev 1845)
@@ -0,0 +1,160 @@
+/*
+ * Copyright 2004-2005 Stephen J. McConnell.
+ * Copyright 2004 Niclas Hedhman.
+ *
+ * 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.
+ */
+
+package net.dpml.transit.layout;
+
+import net.dpml.transit.Artifact;
+import net.dpml.transit.Layout;
+import net.dpml.transit.TransitRuntimeException;
+
+/**
+ * The ModernLayout decodes artifacts into a layout scheme that follows the
+ * convention of group/name/version/expanded-name pattern. Specifically the
+ * layout maps artifacts according to the rule
+ * [group[/[subgroup[/...]]]/[name]/[version]/name[-[version]].type.
+ * Example: <code>artifact:jar:metro/cache/dpml-cache-main#1.0.0</code>
+ * would return the path
<code>metro/cache/dpml-cache-main/1.0.0/dpml-cache-main-1.0.0.jar</code>.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class ModernLayout
+ extends Layout
+{
+ private static final String LAYOUT_IDENTIFIER = "modern";
+
+ /**
+ * Return the layout identifier. The id value is used
+ * to identify layout instances assigned to cache handlers and
+ * resource host handlers.
+ *
+ * @return the layout id
+ */
+ public String getID()
+ {
+ return LAYOUT_IDENTIFIER;
+ }
+
+ /**
+ * Return the base path for an artifact. The base path is derived from
+ * the artifact group and type. The base path value represents
+ * the directory path relative to a repository root of the directory
containing
+ * this artifact.
+ *
+ * @param artifact the resource artifact
+ * @return the base path
+ */
+ public final String resolveBase( Artifact artifact )
+ {
+ String version = artifact.getVersion();
+ if( null == version )
+ {
+ if( null == artifact.getGroup() )
+ {
+ return artifact.getName();
+ }
+ else
+ {
+ String group = getGroupPath( artifact );
+ return group + "/" + artifact.getName();
+ }
+ }
+ else
+ {
+ if( null == artifact.getGroup() )
+ {
+ return artifact.getName() + "/" + version;
+ }
+ else
+ {
+ String group = getGroupPath( artifact );
+ return group + "/" + artifact.getName() + "/" + version;
+ }
+ }
+ }
+
+ /**
+ * Returns the full path of the artifact relative to a logical root
directory.
+ * The full path is equivalent to the base path and artifact filename
using the
+ * pattern "[base]/[filename]". Path values may be used to resolve an
artifact
+ * from a remote repository or local cache relative to the repository or
cache
+ * root.
+ *
+ * @param artifact the resource artifact
+ * @see #resolveBase
+ * @see #resolveFilename
+ * @return the logical artifact path
+ */
+ public final String resolvePath( Artifact artifact )
+ {
+ return resolveBase( artifact ) + "/" + resolveFilename( artifact );
+ }
+
+ /**
+ * Return the expanded filename of the artifact. The filename is
expressed
+ * as [name]-[version].[type] or in case of a null version simply
[name].[type].
+ *
+ * @param artifact the resource artifact
+ * @return the artifact expanded filename
+ */
+ public String resolveFilename( Artifact artifact )
+ {
+ String scheme = artifact.getScheme();
+ String filename = resolveBaseFilename( artifact );
+ if( "artifact".equals( scheme ) )
+ {
+ return filename;
+ }
+ else if( "link".equals( scheme ) )
+ {
+ return filename + ".link";
+ }
+ else
+ {
+ final String error =
+ "Protocol not recognized: " + scheme;
+ throw new TransitRuntimeException( error );
+ }
+ }
+
+ private String resolveBaseFilename( Artifact artifact )
+ {
+ String version = artifact.getVersion();
+ if( null == version )
+ {
+ return artifact.getName() + "." + artifact.getType();
+ }
+ else
+ {
+ return artifact.getName() + "-" + version + "." +
artifact.getType();
+ }
+ }
+
+ /**
+ * To be compatible with the maven-2 strategy we need to subsitute period
+ * characters with a group separator.
+ * @param artifact the artifact from which to resolve the group path
+ * @return the group path
+ */
+ private String getGroupPath( Artifact artifact )
+ {
+ String group = artifact.getGroup();
+ return group.replace( '.', '/' );
+ }
+}

Added:
trunk/main/transit/core/src/main/net/dpml/transit/layout/package-info.java
===================================================================
---
trunk/main/transit/core/src/main/net/dpml/transit/layout/package-info.java
2007-02-08 23:52:51 UTC (rev 1844)
+++
trunk/main/transit/core/src/main/net/dpml/transit/layout/package-info.java
2007-02-08 23:53:26 UTC (rev 1845)
@@ -0,0 +1,25 @@
+/*
+ * Copyright 2005-2007 Stephen J. McConnell.
+ *
+ * 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.
+ */
+
+/**
+ * <p>Standard layout strategies.</p>
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+package net.dpml.transit.layout;




  • r1845 - trunk/main/transit/core/src/main/net/dpml/transit/layout, mcconnell at BerliOS, 02/08/2007

Archive powered by MHonArc 2.6.24.

Top of Page