Skip to Content.
Sympa Menu

notify-dpml - r1846 - trunk/main/transit/core/src/main/net/dpml/transit

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: r1846 - trunk/main/transit/core/src/main/net/dpml/transit
  • Date: Fri, 9 Feb 2007 00:55:33 +0100

Author: mcconnell
Date: 2007-02-09 00:55:30 +0100 (Fri, 09 Feb 2007)
New Revision: 1846

Added:

trunk/main/transit/core/src/main/net/dpml/transit/ArtifactAlreadyExistsException.java
trunk/main/transit/core/src/main/net/dpml/transit/ArtifactException.java

trunk/main/transit/core/src/main/net/dpml/transit/ArtifactNotFoundException.java
trunk/main/transit/core/src/main/net/dpml/transit/CacheManager.java
trunk/main/transit/core/src/main/net/dpml/transit/ContentHandler.java
trunk/main/transit/core/src/main/net/dpml/transit/ContentManager.java
trunk/main/transit/core/src/main/net/dpml/transit/HostManager.java

trunk/main/transit/core/src/main/net/dpml/transit/InvalidArtifactException.java
trunk/main/transit/core/src/main/net/dpml/transit/LinkManager.java

trunk/main/transit/core/src/main/net/dpml/transit/LinkNotFoundException.java
trunk/main/transit/core/src/main/net/dpml/transit/Monitor.java
trunk/main/transit/core/src/main/net/dpml/transit/TransitManager.java
trunk/main/transit/core/src/main/net/dpml/transit/package-info.java
Removed:
trunk/main/transit/core/src/main/net/dpml/transit/AbstractLayout.java
trunk/main/transit/core/src/main/net/dpml/transit/CacheHandler.java
trunk/main/transit/core/src/main/net/dpml/transit/ClassicLayout.java
trunk/main/transit/core/src/main/net/dpml/transit/ConnectionCache.java
trunk/main/transit/core/src/main/net/dpml/transit/DTD.java
trunk/main/transit/core/src/main/net/dpml/transit/DTDResolver.java
trunk/main/transit/core/src/main/net/dpml/transit/DefaultCacheHandler.java
trunk/main/transit/core/src/main/net/dpml/transit/DefaultCacheModel.java
trunk/main/transit/core/src/main/net/dpml/transit/DefaultCodeBaseModel.java
trunk/main/transit/core/src/main/net/dpml/transit/DefaultHostModel.java
trunk/main/transit/core/src/main/net/dpml/transit/DefaultLayoutModel.java

trunk/main/transit/core/src/main/net/dpml/transit/DefaultLayoutRegistry.java

trunk/main/transit/core/src/main/net/dpml/transit/DefaultLayoutRegistryModel.java
trunk/main/transit/core/src/main/net/dpml/transit/DefaultModel.java
trunk/main/transit/core/src/main/net/dpml/transit/DefaultProxyModel.java
trunk/main/transit/core/src/main/net/dpml/transit/DefaultResourceHost.java
trunk/main/transit/core/src/main/net/dpml/transit/DefaultTransitModel.java

trunk/main/transit/core/src/main/net/dpml/transit/DelegatingAuthenticator.java
trunk/main/transit/core/src/main/net/dpml/transit/Disposable.java
trunk/main/transit/core/src/main/net/dpml/transit/EclipseLayout.java
trunk/main/transit/core/src/main/net/dpml/transit/Environment.java
trunk/main/transit/core/src/main/net/dpml/transit/EnvironmentException.java
trunk/main/transit/core/src/main/net/dpml/transit/LayoutRegistry.java

trunk/main/transit/core/src/main/net/dpml/transit/ModelRuntimeException.java
trunk/main/transit/core/src/main/net/dpml/transit/ModernLayout.java
trunk/main/transit/core/src/main/net/dpml/transit/NetworkLoader.java

trunk/main/transit/core/src/main/net/dpml/transit/NullArgumentException.java

trunk/main/transit/core/src/main/net/dpml/transit/PluginClassNotFoundException.java
trunk/main/transit/core/src/main/net/dpml/transit/RepositoryException.java
trunk/main/transit/core/src/main/net/dpml/transit/ResourceHost.java
trunk/main/transit/core/src/main/net/dpml/transit/SaxMonitor.java

trunk/main/transit/core/src/main/net/dpml/transit/SecuredTransitContext.java
trunk/main/transit/core/src/main/net/dpml/transit/StandardLayoutModel.java

trunk/main/transit/core/src/main/net/dpml/transit/TransitAlreadyInitializedException.java
trunk/main/transit/core/src/main/net/dpml/transit/TransitAuthenticator.java

trunk/main/transit/core/src/main/net/dpml/transit/TransitAuthenticatorImpl.java
trunk/main/transit/core/src/main/net/dpml/transit/TransitBuilder.java
trunk/main/transit/core/src/main/net/dpml/transit/ZipCache.java
trunk/main/transit/core/src/main/net/dpml/transit/package.html
Modified:
trunk/main/transit/core/src/main/net/dpml/transit/Artifact.java
trunk/main/transit/core/src/main/net/dpml/transit/Layout.java
trunk/main/transit/core/src/main/net/dpml/transit/Transit.java
Log:
SDK 2.X staged commit.

Deleted: trunk/main/transit/core/src/main/net/dpml/transit/AbstractLayout.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/AbstractLayout.java
2007-02-08 23:53:26 UTC (rev 1845)
+++ trunk/main/transit/core/src/main/net/dpml/transit/AbstractLayout.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -1,49 +0,0 @@
-/*
- * 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;
-
-import java.io.Serializable;
-
-
-/**
- * Abstract base class for layout implementations.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-abstract class AbstractLayout implements Layout, Serializable
-{
- public boolean equals( Object other )
- {
- if( null == other )
- {
- return false;
- }
- else
- {
- return getClass().equals( other.getClass() );
- }
- }
-
- public int hashCode()
- {
- return getClass().hashCode();
- }
-}

Modified: trunk/main/transit/core/src/main/net/dpml/transit/Artifact.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/Artifact.java
2007-02-08 23:53:26 UTC (rev 1845)
+++ trunk/main/transit/core/src/main/net/dpml/transit/Artifact.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -21,7 +21,6 @@

import java.io.Serializable;
import java.net.URLStreamHandler;
-
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
@@ -85,13 +84,14 @@
* @exception java.net.URISyntaxException if the supplied uri is not
valid.
* @exception UnsupportedSchemeException if the URI does not have
"artifact"
* or "link" as its <strong>scheme</strong>.
+ * @exception NullPointerException if the supplied uri argument is null
*/
public static final Artifact createArtifact( String uri )
- throws URISyntaxException, UnsupportedSchemeException
+ throws URISyntaxException, UnsupportedSchemeException,
NullPointerException
{
if( null == uri )
{
- throw new NullArgumentException( "uri" );
+ throw new NullPointerException( "uri" );
}
int asterix = uri.indexOf( "!" );
if( asterix == -1 )
@@ -130,13 +130,14 @@
* @return the new artifact
* @exception UnsupportedSchemeException if the URI does not have
"artifact"
* or "link" as its <strong>scheme</strong>.
+ * @exception NullPointerException if the supplied uri argument is null
*/
public static final Artifact createArtifact( URI uri )
- throws UnsupportedSchemeException
+ throws UnsupportedSchemeException, NullPointerException
{
if( null == uri )
{
- throw new NullArgumentException( "uri" );
+ throw new NullPointerException( "uri" );
}
String scheme = uri.getScheme();
if( null == scheme )
@@ -145,13 +146,10 @@
"URI does not declare a scheme: " + uri;
throw new UnsupportedSchemeException( error );
}
- //if( !scheme.equals( ARTIFACT ) && !scheme.equals( LINK ) &&
!scheme.equals( LOCAL ) )
- //{
- // final String error =
- // "URI contains a scheme that is not recognized: " + uri;
- // throw new UnsupportedSchemeException( error );
- //}
- return new Artifact( uri );
+ else
+ {
+ return new Artifact( uri );
+ }
}

/**
@@ -163,12 +161,13 @@
* @param version the version
* @param type the type
* @return the new artifact
- * @exception NullArgumentException if any of the <code>group</code>,
+ * @exception NullPointerException if any of the <code>group</code>,
* <code>name</code> or <code>type</code> arguments are
* <code>null</code>.
*/
- public static Artifact createArtifact( String group, String name, String
version, String type )
- throws NullArgumentException
+ public static Artifact createArtifact(
+ String group, String name, String version, String type )
+ throws NullPointerException
{
return createArtifact( ARTIFACT, group, name, version, type );
}
@@ -183,24 +182,25 @@
* @param version the version
* @param type the type
* @return the new artifact
- * @exception NullArgumentException if any of the <code>group</code>,
+ * @exception NullPointerException if any of the <code>group</code>,
* <code>name</code> or <code>type</code> arguments are
* <code>null</code>.
*/
- public static Artifact createArtifact( String scheme, String group,
String name, String version, String type )
- throws NullArgumentException
+ public static Artifact createArtifact(
+ String scheme, String group, String name, String version, String type )
+ throws NullPointerException
{
if( name == null )
{
- throw new NullArgumentException( "name" );
+ throw new NullPointerException( "name" );
}
if( type == null )
{
- throw new NullArgumentException( "type" );
+ throw new NullPointerException( "type" );
}
if( scheme == null )
{
- throw new NullArgumentException( "scheme" );
+ throw new NullPointerException( "scheme" );
}
String composite = buildComposite( scheme, group, name, version,
type );
try
@@ -233,11 +233,6 @@
buffer.append( "/" );
}
buffer.append( name );
- //if( null != query )
- //{
- // buffer.append( "?" );
- // buffer.append( query );
- //}
if( null != version )
{
buffer.append( "#" );
@@ -272,6 +267,11 @@
{
return uri.toURL();
}
+ catch( IllegalArgumentException iae )
+ {
+ throw new InvalidArtifactException( iae.getMessage() );
+ }
+
catch( MalformedURLException mue )
{
throw mue;
@@ -343,11 +343,15 @@
* @param uri a uri of the form [scheme]:[type]:[group]/[name]#[version]
* where [scheme] is one of 'link', 'artifact' or 'local'.
*/
- private Artifact( URI uri )
- throws IllegalArgumentException
+ private Artifact( URI uri ) throws InvalidArtifactException
{
- m_uri = uri;
- String ssp = uri.getSchemeSpecificPart();
+ m_uri = reconstructURI( uri );
+ String ssp = m_uri.getSchemeSpecificPart();
+
+ if( ssp.indexOf( '?' ) > -1 )
+ {
+ ssp = ssp.substring( 0, ssp.indexOf( '?' ) );
+ }

if( ssp.indexOf( "//" ) > -1
|| ssp.indexOf( ":/" ) > -1
@@ -356,7 +360,7 @@
final String error =
"Invalid character sequence in uri ["
+ uri + "].";
- throw new IllegalArgumentException( error );
+ throw new InvalidArtifactException( error );
}

int typeIndex = ssp.indexOf( ':' );
@@ -370,10 +374,10 @@
{
final String error = "Supplied artifact specification ["
+ uri + "] does not contain a type.";
- throw new IllegalArgumentException( error );
+ throw new InvalidArtifactException( error );
}

- // ssp now contains group, name and version
+ // ssp now contains group and name

int groupIndex = ssp.lastIndexOf( '/' );
if( groupIndex > -1 )
@@ -388,7 +392,7 @@
m_name = ssp;
}

- String ver = uri.getFragment();
+ String ver = m_uri.getFragment();
if( ver != null )
{
if( ver.indexOf( '/' ) >= 0
@@ -413,13 +417,57 @@
{
final String error =
"Supplied artifact specification ["
- + uri
+ + m_uri
+ "] contains illegal characters in the Version part.";
- throw new IllegalArgumentException( error );
+ throw new InvalidArtifactException( error );
}
}
}

+ private URI reconstructURI( URI uri )
+ {
+ String fragment = uri.getFragment();
+
+ // if the fragment cointains a '?' character then reconstruct the uri
+ // such that the query is in the ssp
+
+ if( null != fragment )
+ {
+ int n = fragment.indexOf( '?' );
+ if( n > -1 )
+ {
+ try
+ {
+ String version = fragment.substring( 0, n );
+ String query = fragment.substring( n + 1 );
+ String scheme = uri.getScheme();
+ String ssp = uri.getSchemeSpecificPart();
+ return new URI( scheme, ssp + "?" + query, version );
+ }
+ catch( Exception e )
+ {
+ throw new InvalidArtifactException( e.getMessage() );
+ }
+ }
+ }
+ return uri;
+
+ /*
+ String ssp = uri.getSchemeSpecificPart();
+ int n = ssp.indexOf( '?' );
+ if( n > -1 )
+ {
+ String body = ssp.substring( 0, n );
+ String query = ssp.substring( n+1 );
+ System.out.println( " SSP: " + ssp );
+ System.out.println( " BODY: " + body );
+ System.out.println( "QUERY: " + query );
+ }
+ return uri;
+ */
+ }
+
+
//
------------------------------------------------------------------------
// public
//
------------------------------------------------------------------------
@@ -508,15 +556,15 @@
String scheme = getScheme();
if( ARTIFACT.equals( scheme ) )
{
- return toURL( new net.dpml.transit.artifact.Handler() );
+ return toURL( new dpml.transit.artifact.Handler() );
}
else if( LINK.equals( scheme ) )
{
- return toURL( new net.dpml.transit.link.Handler() );
+ return toURL( new dpml.transit.link.Handler() );
}
else if( LOCAL.equals( scheme ) )
{
- return toURL( new net.dpml.transit.local.Handler() );
+ return toURL( new dpml.transit.local.Handler() );
}
else
{
@@ -570,11 +618,11 @@
* @param object the object to compare with this instance
* @return the comparative order of the supplied object relative to this
* artifact
- * @exception NullArgumentException if the supplied object argument is
null.
+ * @exception NullPointerException if the supplied object argument is
null.
* @exception ClassCastException if the supplied object is not an
Artifact.
*/
public int compareTo( Object object )
- throws NullArgumentException, ClassCastException
+ throws NullPointerException, ClassCastException
{
if( object instanceof Artifact )
{
@@ -583,7 +631,7 @@
}
else if( null == object )
{
- throw new NullArgumentException( "object" );
+ throw new NullPointerException( "object" );
}
else
{

Copied:
trunk/main/transit/core/src/main/net/dpml/transit/ArtifactAlreadyExistsException.java
(from rev 1789,
trunk/main/transit/core/src/main/net/dpml/transit/artifact/ArtifactAlreadyExistsException.java)
===================================================================
---
trunk/main/transit/core/src/main/net/dpml/transit/artifact/ArtifactAlreadyExistsException.java
2006-11-30 21:08:46 UTC (rev 1789)
+++
trunk/main/transit/core/src/main/net/dpml/transit/ArtifactAlreadyExistsException.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -0,0 +1,69 @@
+/*
+ * Copyright 2004-2005 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.
+ */
+
+package net.dpml.transit;
+
+/**
+ * Exception to indicate that the Artifact already exists in the cache and
+ * can therefor not be written to.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class ArtifactAlreadyExistsException extends ArtifactException
+{
+ /**
+ * Serial version identifier.
+ */
+ static final long serialVersionUID = 1L;
+
+ //
------------------------------------------------------------------------
+ // state
+ //
------------------------------------------------------------------------
+
+ /**
+ * The artifact that we tried to write to.
+ */
+ private final Artifact m_artifact;
+
+ //
------------------------------------------------------------------------
+ // constructor
+ //
------------------------------------------------------------------------
+
+ /**
+ * Construct a new <code>ArtifactAlreadyExistsException</code> instance.
+ *
+ * @param message the exception message
+ * @param artifact the subject artifact
+ */
+ public ArtifactAlreadyExistsException( final String message, final
Artifact artifact )
+ {
+ super( message );
+ m_artifact = artifact;
+ }
+
+ /**
+ * Returns the Artifact that were attempted to be written to.
+ * @return the subject artifact
+ */
+ public Artifact getArtifact()
+ {
+ return m_artifact;
+ }
+}
+

Copied:
trunk/main/transit/core/src/main/net/dpml/transit/ArtifactException.java
(from rev 1789,
trunk/main/transit/core/src/main/net/dpml/transit/artifact/ArtifactException.java)
===================================================================
---
trunk/main/transit/core/src/main/net/dpml/transit/artifact/ArtifactException.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/transit/core/src/main/net/dpml/transit/ArtifactException.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -0,0 +1,60 @@
+/*
+ * 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;
+
+/**
+ * Exception to indicate that there was an Artifact related error.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class ArtifactException extends TransitException
+{
+ /**
+ * Serial version identifier.
+ */
+ static final long serialVersionUID = 1L;
+
+ //
------------------------------------------------------------------------
+ // constructor
+ //
------------------------------------------------------------------------
+
+ /**
+ * Construct a new <code>ArtifactException</code> instance.
+ *
+ * @param message The detail message for this exception.
+ */
+ public ArtifactException( final String message )
+ {
+ super( message );
+ }
+
+ /**
+ * Construct a new <code>ArtifactException</code> instance.
+ *
+ * @param message The detail message for this exception.
+ * @param cause the root cause of the exception
+ */
+ public ArtifactException( final String message, final Throwable cause )
+ {
+ super( message, cause );
+ }
+}
+

Copied:
trunk/main/transit/core/src/main/net/dpml/transit/ArtifactNotFoundException.java
(from rev 1789,
trunk/main/transit/core/src/main/net/dpml/transit/artifact/ArtifactNotFoundException.java)
===================================================================
---
trunk/main/transit/core/src/main/net/dpml/transit/artifact/ArtifactNotFoundException.java
2006-11-30 21:08:46 UTC (rev 1789)
+++
trunk/main/transit/core/src/main/net/dpml/transit/ArtifactNotFoundException.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -0,0 +1,70 @@
+/*
+ * Copyright 2004-2005 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.
+ */
+
+package net.dpml.transit;
+
+import java.net.URI;
+
+/**
+ * Exception to indicate that an Artifact could not be located.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class ArtifactNotFoundException extends ArtifactException
+{
+ /**
+ * Serial version identifier.
+ */
+ static final long serialVersionUID = 1L;
+
+ //
------------------------------------------------------------------------
+ // state
+ //
------------------------------------------------------------------------
+
+ /**
+ * The artifact that we not found.
+ */
+ private final URI m_artifact;
+
+ //
------------------------------------------------------------------------
+ // constructor
+ //
------------------------------------------------------------------------
+
+ /**
+ * Construct a new <code>ArtifactNotFoundException</code> instance.
+ *
+ * @param message The detail message for this exception.
+ * @param artifact the subject artifact
+ */
+ public ArtifactNotFoundException( final String message, final URI
artifact )
+ {
+ super( message );
+ m_artifact = artifact;
+ }
+
+ /**
+ * Returns the uri that could not be found.
+ * @return the subject uri
+ */
+ public URI getURI()
+ {
+ return m_artifact;
+ }
+}
+

Deleted: trunk/main/transit/core/src/main/net/dpml/transit/CacheHandler.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/CacheHandler.java
2007-02-08 23:53:26 UTC (rev 1845)
+++ trunk/main/transit/core/src/main/net/dpml/transit/CacheHandler.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -1,127 +0,0 @@
-/*
- * 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;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import net.dpml.transit.artifact.ArtifactAlreadyExistsException;
-
-/**
- * The CacheHandler interface defines the contract for classes capable of
- * supporting the cache management aspects of a transit system. Cache
management
- * encompasses the retreval of resources based on artifact identifiers. A
cache
- * manager implementations may provide varying levels of quality-of-services.
- * Selection of a cache manager is defined under the transit cache
configuration
- * properties.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public interface CacheHandler
-{
- /**
- * Return the cache directory.
- * @param artifact the artifact to resolve
- * @return the working cache directory
- * @exception IOException if an IO error occurs
- */
- File getLocalFile( Artifact artifact ) throws IOException;
-
- /**
- * Initialization of the cache handler. This operation is invoked by
- * the transit context following the establishment of bootstrap
- * services. During initialization the implementation loads any custom
- * resource hosts.
- *
- * @exception IOException if an IO error occurs
- */
- void initialize() throws IOException;
-
- /**
- * Attempts to download and cache a remote artifact using a set of remote
- * repositories.
- *
- * @param artifact the artifact to retrieve and cache
- * @return an input stream to the local resource
- * @exception IOException if an IO error occurs
- * @exception TransitException is a transit system error occurs
- */
- InputStream getResource( Artifact artifact )
- throws IOException, TransitException;
-
- /**
- * Attempts to download and cache a remote artifact using a set of remote
- * repositories.
- * <p>
- * This method allows an internal reference to be passed to the
- * cache handler and it is expected to return the InputStream of the
- * internal item inside Jar/Zip files. If this method is called, the
- * implementation can assume that the artifact is a Zip file.
- * </p>
- *
- * @param artifact the artifact to retrieve and cache
- * @param internalReference referencing a item within the artifact. This
- * argument may start with "!" or "!/", which should be ignored.
- * @return a file referencing the local resource
- * @exception IOException if an IO error occurs
- * @exception TransitException is a transit system error occurs
- */
- InputStream getResource( Artifact artifact, String internalReference )
- throws IOException, TransitException;
-
- /** Creates an output stream to where the artifact content can be written
- * to.
- * <p>
- * If the artifact already exists, a
<code>ArtifactAlreadyExistsException</code>
- * will be thrown. If the directory doesn't exists, it will be created.
- * The CacheHandler is responsible to recognize the completion of the
- * writes through the <code>close()</code> method in the output stream,
- * and do any post-processing there.
- * </p>
- * @param artifact the artifact
- * @return an output stream
- * @exception NullArgumentException if the artifact argument is null.
- * @exception ArtifactAlreadyExistsException if the artifact already
exists in the cache.
- * @exception IOException if an IO error occurs
- */
- OutputStream createOutputStream( Artifact artifact )
- throws NullArgumentException, ArtifactAlreadyExistsException,
IOException;
-
- /**
- * Return the layout used by the cache.
- * @return the cache layout
- */
- Layout getLayout();
-
- /**
- * Return the layout registry.
- * @return the layout registry.
- */
- LayoutRegistry getLayoutRegistry();
-
- /**
- * Return the current cache directory.
- * @return the cache directory.
- */
- File getCacheDirectory();
-}

Added: trunk/main/transit/core/src/main/net/dpml/transit/CacheManager.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/CacheManager.java
2007-02-08 23:53:26 UTC (rev 1845)
+++ trunk/main/transit/core/src/main/net/dpml/transit/CacheManager.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2006 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.
+ */
+
+package net.dpml.transit;
+
+import javax.management.MXBean;
+
+/**
+ * Cache management interface.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+@MXBean
+public interface CacheManager
+{
+ /**
+ * Return the Transit cache directory path.
+ * @return the cache path
+ */
+ String getPath();
+
+ /**
+ * Return the Transit cache directory location as a string.
+ * @return the cache file value
+ */
+ String getDirectory();
+
+ /**
+ * Return the Transit cache layout id.
+ * @return the cache layout identifier
+ */
+ String getLayoutID();
+
+ /**
+ * Return the hosts assigned in this Transit configuration
+ * @return the host manager array
+ */
+ HostManager[] getHosts();
+}
\ No newline at end of file

Deleted: trunk/main/transit/core/src/main/net/dpml/transit/ClassicLayout.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/ClassicLayout.java
2007-02-08 23:53:26 UTC (rev 1845)
+++ trunk/main/transit/core/src/main/net/dpml/transit/ClassicLayout.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -1,117 +0,0 @@
-/*
- * 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;
-
-/**
- * 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
- implements Layout
-{
- /**
- * 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();
- }
- }
-}

Deleted:
trunk/main/transit/core/src/main/net/dpml/transit/ConnectionCache.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/ConnectionCache.java
2007-02-08 23:53:26 UTC (rev 1845)
+++ trunk/main/transit/core/src/main/net/dpml/transit/ConnectionCache.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -1,202 +0,0 @@
-/*
- * 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;
-
-import java.net.URLConnection;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.WeakHashMap;
-
-/**
- * Internal cache for url connections.
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-final class ConnectionCache implements Runnable
-{
- private static final Object DUMMY = new Object();
- private static final long TIME_TO_LIVE = 30000;
- private static final int PAUSE_DELAY = 10000;
- private static ConnectionCache m_INSTANCE;
-
- private final HashMap m_hardStore;
- private final WeakHashMap m_weakStore;
- private Thread m_thread;
-
- static
- {
- m_INSTANCE = new ConnectionCache();
- }
-
- /**
- * Return the connection cacne instance.
- * @return the singleton instance
- */
- public static ConnectionCache getInstance()
- {
- return m_INSTANCE;
- }
-
- /**
- * Internal constructor of the connection cache.
- */
- private ConnectionCache()
- {
- m_hardStore = new HashMap();
- m_weakStore = new WeakHashMap();
- }
-
- /**
- * Return the cached url connnection for an artifact.
- * @param key the arfifact
- * @return the cached url connection or null if not cached
- */
- public URLConnection get( Artifact key )
- {
- synchronized( this ) // ensure no ConcurrentModificationException
can occur.
- {
- Entry entry = (Entry) m_hardStore.get( key );
- if( entry == null )
- {
- return null;
- }
- URLConnection conn = entry.m_connection;
- return conn;
- }
- }
-
- /**
- * Put a connection into the cache.
- * @param key the artifact to be used as the cache key
- * @param conn the url connection to cache
- */
- public void put( Artifact key, URLConnection conn )
- {
- synchronized( this ) // ensure no ConcurrentModificationException
can occur.
- {
- Entry entry = new Entry( conn );
- m_hardStore.put( key, entry );
- if( m_thread == null )
- {
- m_thread = new Thread( this, "ConnectionCache-cleaner" );
- m_thread.setDaemon( true );
- m_thread.start();
- }
- }
- }
-
- /**
- * Start the cache.
- */
- public void run()
- {
- while( true )
- {
- try
- {
- synchronized( this )
- {
- long now = System.currentTimeMillis();
- Iterator list = m_hardStore.values().iterator();
- while( list.hasNext() )
- {
- Entry entry = (Entry) list.next();
- if( entry.m_collectTime < now )
- {
- m_weakStore.put( entry.m_connection, DUMMY );
- list.remove();
- }
- }
- if( m_hardStore.size() == 0 )
- {
- m_thread = null; // mark to start a new thread
next time.
- break; // Exit the thread
- }
- wait( PAUSE_DELAY );
- }
- }
- catch( Exception e )
- {
- // Can not happen?
- // Just ignore and it will be handled in the next round.
- e.printStackTrace();
- }
- }
- }
-
- /**
- * Internal class used for cache entries.
- */
- private class Entry
- {
- private final URLConnection m_connection;
- private final long m_collectTime;
-
- /**
- * Creation of a new cache entry instance.
- * @param conn the url connection
- */
- Entry( URLConnection conn )
- {
- m_connection = conn;
- m_collectTime = System.currentTimeMillis() + TIME_TO_LIVE;
- }
-
- /**
- * Test for equality.
- * @param obj the other object
- * @return the equality status
- */
- public boolean equals( Object obj )
- {
- if( obj == null )
- {
- return false;
- }
- if( !obj.getClass().equals( Entry.class ) )
- {
- return false;
- }
- Entry other = (Entry) obj;
- if( !m_connection.equals( other.m_connection ) )
- {
- return false;
- }
- return true;
- }
-
- /**
- * Return the hashcode for the instance.
- * @return the hashcode
- */
- public int hashCode()
- {
- return m_connection.hashCode();
- }
-
- /**
- * Return the string representation of the instance.
- * @return the string
- */
- public String toString()
- {
- return "Entry[" + m_connection + ", " + m_collectTime + "]";
- }
- }
-}

Added: trunk/main/transit/core/src/main/net/dpml/transit/ContentHandler.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/ContentHandler.java
2007-02-08 23:53:26 UTC (rev 1845)
+++ trunk/main/transit/core/src/main/net/dpml/transit/ContentHandler.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2006 Stephen 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.
+ */
+
+package net.dpml.transit;
+
+import java.io.IOException;
+import java.net.URLConnection;
+
+import net.dpml.transit.ContentManager;
+
+/**
+ * Abstract base class for artifact content handler.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public abstract class ContentHandler extends java.net.ContentHandler
+{
+ /**
+ * Returns the type tha the content handler supports.
+ * @return the content type name
+ */
+ public abstract String getType();
+
+}

Added: trunk/main/transit/core/src/main/net/dpml/transit/ContentManager.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/ContentManager.java
2007-02-08 23:53:26 UTC (rev 1845)
+++ trunk/main/transit/core/src/main/net/dpml/transit/ContentManager.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -0,0 +1,40 @@
+/*
+ * Copyright 2006 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.
+ */
+
+package net.dpml.transit;
+
+import javax.management.MXBean;
+import javax.management.MBeanException;
+
+/**
+ * Management interface to a content type handler.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+ @MXBean
+public interface ContentManager
+{
+ /**
+ * Returns the artifact type identifier supported by the
+ * content manager implementation.
+ * @return the artifact type
+ * @exception MBeanException if a JMX error occurs
+ */
+ String getType() throws MBeanException;
+}
\ No newline at end of file

Deleted: trunk/main/transit/core/src/main/net/dpml/transit/DTD.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/DTD.java 2007-02-08
23:53:26 UTC (rev 1845)
+++ trunk/main/transit/core/src/main/net/dpml/transit/DTD.java 2007-02-08
23:55:30 UTC (rev 1846)
@@ -1,78 +0,0 @@
-/*
- * Copyright 2006 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.
- */
-
-package net.dpml.transit;
-
-import java.net.URI;
-
-/**
- * DTD reference.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-class DTD
-{
- /**
- * Public identifier.
- */
- private final String m_public;
-
- /**
- * The system identifier.
- */
- private final String m_system;
-
- /**
- * Local resource.
- */
- private final String m_resource;
-
- /**
- * Factory uri.
- */
- private final URI m_factory;
-
- public DTD( final String publicId, final String systemId, final String
resource, URI factory )
- {
- m_public = publicId;
- m_system = systemId;
- m_resource = resource;
- m_factory = factory;
- }
-
- public String getPublicId()
- {
- return m_public;
- }
-
- public String getSystemId()
- {
- return m_system;
- }
-
- public String getResource()
- {
- return m_resource;
- }
-
- public URI getFactory()
- {
- return m_factory;
- }
-}

Deleted: trunk/main/transit/core/src/main/net/dpml/transit/DTDResolver.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/DTDResolver.java
2007-02-08 23:53:26 UTC (rev 1845)
+++ trunk/main/transit/core/src/main/net/dpml/transit/DTDResolver.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -1,171 +0,0 @@
-/*
- * Copyright 2004-2006 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.
- */
-
-package net.dpml.transit;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-
-import net.dpml.lang.StandardClassLoader;
-
-import org.xml.sax.EntityResolver;
-import org.xml.sax.InputSource;
-import org.xml.sax.SAXException;
-
-/**
- * A Class to help to resolve Entitys for items such as DTDs or
- * Schemas.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-class DTDResolver implements EntityResolver
-{
- /**
- * The list of DTDs that can be resolved by this class.
- */
- private final DTD[] m_dtds;
-
- /**
- * The ClassLoader to use when loading resources for DTDs.
- */
- private final ClassLoader m_classloader;
-
- /**
- * Construct a resolver using specified DTDInfos where resources are
loaded
- * from specified ClassLoader.
- */
- public DTDResolver( final DTD[] dtds, final ClassLoader classLoader )
- {
- m_dtds = dtds;
- m_classloader = classLoader;
-
- /*
- final ClassLoader loader = getClassLoader();
- for( int i=0; i<dtds.length; i++ )
- {
- DTD dtd = dtds[i];
- final String path = dtd.getResource();
- URL url = loader.getResource( path );
- if( null == url )
- {
- if( null == ClassLoader.getSystemClassLoader().getResource(
path ) )
- {
- String stack = StandardClassLoader.toString( loader,
null );
- String sysLoaderProp = System.getProperty(
"java.system.class.loader" );
- ClassLoader sysLoader =
ClassLoader.getSystemClassLoader();
- final String error =
- "Unresolvable DTD resource ["
- + path
- + "]"
- + "\nPROP: " + sysLoaderProp
- + "\nSYSTEM: " + sysLoader
- + "\nCCL-STACK: " + stack
- + "\nSYS-STACK: " + StandardClassLoader.toString(
sysLoader, null );
- throw new TransitError( error );
- }
- }
- }
- */
- }
-
- /**
- * Resolve an entity in the XML file.
- * Called by parser to resolve DTDs.
- */
- public InputSource resolveEntity( final String publicId, final String
systemId )
- throws IOException, SAXException
- {
- //System.out.println( "# PUBLIC: " + publicId );
- //System.out.println( "# SYSTEM: " + systemId );
-
- for( int i=0; i<m_dtds.length; i++ )
- {
- final DTD info = m_dtds[i];
-
- if( ( publicId != null && publicId.equals( info.getPublicId() )
)
- || ( systemId != null && systemId.equals( info.getSystemId()
) ) )
- {
- final String path = info.getResource();
- final InputStream inputStream = resolveInputStream( path );
- if( null == inputStream )
- {
- final String error =
- "Matched DTD identifier returned an unresolvable
resource path."
- + "\nPublic ID: " + info.getPublicId()
- + "\nSystem ID: " + info.getSystemId()
- + "\nResource: '" + path + "'";
- throw new TransitError( error );
- }
- else
- {
- return new InputSource( inputStream );
- }
- }
- }
- return null;
- }
-
- private InputStream resolveInputStream( String path )
- {
- InputStream input =
ClassLoader.getSystemClassLoader().getResourceAsStream( path );
- if( null != input )
- {
- return input;
- }
- ClassLoader context = Thread.currentThread().getContextClassLoader();
- if( null != context )
- {
- input = context.getResourceAsStream( path );
- if( null != input )
- {
- return input;
- }
- }
- if( null != m_classloader )
- {
- input = m_classloader.getResourceAsStream( path );
- if( null != input )
- {
- return input;
- }
- }
- return null;
- }
-
- /**
- * Return CLassLoader to load resource from.
- * If a ClassLoader is specified in the constructor use that,
- * else use ContextClassLoader unless that is null in which case
- * use the current classes ClassLoader.
- */
- private ClassLoader getClassLoader()
- {
- ClassLoader classLoader = m_classloader;
- if( null == classLoader )
- {
- classLoader = Thread.currentThread().getContextClassLoader();
- }
- if( null == classLoader )
- {
- classLoader = getClass().getClassLoader();
- }
- return classLoader;
- }
-}

Deleted:
trunk/main/transit/core/src/main/net/dpml/transit/DefaultCacheHandler.java
===================================================================
---
trunk/main/transit/core/src/main/net/dpml/transit/DefaultCacheHandler.java
2007-02-08 23:53:26 UTC (rev 1845)
+++
trunk/main/transit/core/src/main/net/dpml/transit/DefaultCacheHandler.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -1,753 +0,0 @@
-/*
- * 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;
-
-import java.io.BufferedInputStream;
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.UnknownHostException;
-import java.rmi.Remote;
-import java.rmi.NoSuchObjectException;
-import java.rmi.RemoteException;
-import java.rmi.server.UnicastRemoteObject;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.Map;
-import java.util.TreeMap;
-import java.util.WeakHashMap;
-import java.util.zip.ZipEntry;
-import java.util.zip.ZipFile;
-
-import net.dpml.util.Logger;
-
-import net.dpml.transit.artifact.ArtifactNotFoundException;
-import net.dpml.transit.artifact.ArtifactAlreadyExistsException;
-import net.dpml.transit.model.CacheModel;
-import net.dpml.transit.model.CacheListener;
-import net.dpml.transit.model.CacheDirectoryChangeEvent;
-import net.dpml.transit.model.HostModel;
-import net.dpml.transit.model.CacheEvent;
-import net.dpml.transit.model.LayoutModel;
-import net.dpml.transit.model.LayoutRegistryModel;
-import net.dpml.transit.monitor.CacheMonitorRouter;
-
-/**
- * Default cache handler that maintains a file based cache.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-class DefaultCacheHandler extends UnicastRemoteObject implements
CacheHandler, CacheListener, Disposable
-{
- //
------------------------------------------------------------------------
- // state
- //
------------------------------------------------------------------------
-
- /**
- * The base directory of the cache.
- */
- private File m_cacheDir;
-
- /**
- * The resource hosts.
- */
- private TreeMap m_resourceHosts;
-
- private Layout m_resolver;
-
- private ZipCache m_zipCache;
-
- private final Logger m_logger;
-
- private final CacheModel m_model;
-
- private final Map m_plugins = new WeakHashMap(); // plugin uris as keys
to plugin classes
-
- private LayoutRegistry m_registry;
-
- //
------------------------------------------------------------------------
- // constructor
- //
------------------------------------------------------------------------
-
- /**
- * Creation of a new file based cache controller using a supplied
- * configuration model and cache layout resolver.
- *
- * @param model the cache system confiuguration model
- */
- public DefaultCacheHandler( CacheModel model, Logger logger ) throws
IOException
- {
- super();
-
- m_model = model;
- m_logger = logger;
- m_zipCache = new ZipCache();
- m_resourceHosts = new TreeMap();
-
- LayoutRegistryModel layoutModel = model.getLayoutRegistryModel();
- m_registry = new DefaultLayoutRegistry( layoutModel, logger );
- LayoutModel layout = model.getLayoutModel();
-
- try
- {
- String key = layout.getID();
- m_resolver = m_registry.getLayout( key );
- }
- catch( Throwable e )
- {
- final String error =
- "Cannot construct cache handler due to a cache layout
resolution failure.";
- throw new TransitException( error, e );
- }
-
- if( getLogger().isTraceEnabled() )
- {
- getLogger().trace( "cache initialization" );
- }
-
- //
- // For all of the declared host models we check for hosts that do not
- // declare a plugin uri. If no plugin uri is declared we are
dealing with
- // a classic resource host that serves as a bootstrap host. Leter
on the
- // SecuredTransitContext will initialize this instance and we will
continue
- // with host loading for plugin based resource hosts.
- //
-
- HostModel[] hosts = model.getHostModels();
- if( getLogger().isTraceEnabled() )
- {
- getLogger().trace( "host count: " + hosts.length );
- }
- for( int i=0; i < hosts.length; i++ )
- {
- HostModel host = hosts[i];
- String id = host.getID();
- ResourceHost handler = createDefaultResourceHost( host );
- m_resourceHosts.put( id, handler );
- }
-
- //
- // setup the cache directory
- //
-
- File cache = model.getCacheDirectory();
- setLocalCacheDirectory( cache );
-
- if( getLogger().isTraceEnabled() )
- {
- getLogger().trace( "bootstrap initialization complete" );
- }
- }
-
- //
------------------------------------------------------------------------
- // CacheListener
- //
------------------------------------------------------------------------
-
- /**
- * Return a file referencing the the locally cached resource.
- *
- * @return the cached file
- */
- public File getLocalFile( Artifact artifact ) throws IOException
- {
- File cache = getLocalCacheDirectory();
- String name = m_resolver.resolvePath( artifact );
- return new File( cache, name );
- }
-
- /**
- * Notify the listener of a change to the cache directory.
- * @param event the cache directory change event
- */
- public void cacheDirectoryChanged( CacheDirectoryChangeEvent event )
throws RemoteException
- {
- File cache = m_model.getCacheDirectory();
- synchronized( this )
- {
- setLocalCacheDirectory( cache );
- }
- }
-
- /**
- * Notify the listener of the addition of a new host.
- * @param event the host added event
- */
- public void hostAdded( CacheEvent event ) throws RemoteException
- {
- HostModel host = event.getHostModel();
- try
- {
- handleHostAddition( host );
- }
- catch( Throwable e )
- {
- final String error =
- "An internal error occured while attempting to handle host
addition.";
- getLogger().error( error, e );
- }
- }
-
- /**
- * Notify the listener of the removal of a host.
- * @param event the host removed event
- */
- public void hostRemoved( CacheEvent event ) throws RemoteException
- {
- synchronized( m_resourceHosts )
- {
- HostModel model = event.getHostModel();
- String id = model.getID();
- ResourceHost host = (ResourceHost) m_resourceHosts.get( id );
- if( null != host )
- {
- if( getLogger().isDebugEnabled() )
- {
- getLogger().debug( "removing host: " + id );
- }
- if( host instanceof Disposable )
- {
- Disposable handler = (Disposable) host;
- handler.dispose();
- }
- m_resourceHosts.remove( id );
- }
- }
- }
-
- //
------------------------------------------------------------------------
- // Disposable
- //
------------------------------------------------------------------------
-
- /**
- * Dispose of the manager. During disposal a manager is required to
- * release all references such as listeners and internal resources
- * in preparation for garbage collection.
- */
- public synchronized void dispose()
- {
- try
- {
- m_model.removeCacheListener( this );
- synchronized( m_resourceHosts )
- {
- ResourceHost[] hosts =
- (ResourceHost[]) m_resourceHosts.values().toArray( new
ResourceHost[0] );
- for( int i=0; i < hosts.length; i++ )
- {
- ResourceHost host = hosts[i];
- terminate( host );
- }
- m_resourceHosts.clear();
- }
- terminate( m_registry );
- }
- catch( RemoteException e )
- {
- final String warning =
- "Unexpected remote exception occured while attempting to
dispose of the cache handler.";
- getLogger().error( warning, e );
- }
- }
-
- private void terminate( Object object )
- {
- if( object instanceof Disposable )
- {
- Disposable disposable = (Disposable) object;
- disposable.dispose();
- }
- if( object instanceof Remote )
- {
- try
- {
- Remote remote = (Remote) object;
- UnicastRemoteObject.unexportObject( remote, true );
- }
- catch( NoSuchObjectException e )
- {
- // ignore
- }
- catch( Throwable e )
- {
- e.printStackTrace();
- }
- }
- }
-
- //
------------------------------------------------------------------------
- // impl
- //
------------------------------------------------------------------------
-
- /**
- * Initialization of the cache controller. This operation is invoked by
- * the secure transit context following the establishment of bootstrap
- * services. During initialization the implementation loads any custom
- * resource hosts.
- *
- * @exception TransitException if a custom host deployment error occurs
- */
- public void initialize() throws IOException
- {
- if( getLogger().isTraceEnabled() )
- {
- getLogger().trace( "secondary initialization phase" );
- }
- m_model.addCacheListener( this );
- if( getLogger().isTraceEnabled() )
- {
- getLogger().trace( "cache subsystem established" );
- }
- }
-
- /**
- * Set the local cache directory.
- * @param file the cache directory
- */
- private synchronized void setLocalCacheDirectory( File file )
- {
- if( null == file )
- {
- throw new NullArgumentException( "file" );
- }
- File cache = file;
- if( getLogger().isTraceEnabled() )
- {
- if( null == m_cacheDir )
- {
- final String message =
- "Setting cache to: "
- + cache;
- getLogger().trace( message );
- }
- else
- {
- final String message =
- "Changing cache:"
- + "\nOld: " + m_cacheDir
- + "\nNew: " + cache;
- getLogger().trace( message );
- }
- }
- if( !cache.isAbsolute() )
- {
- cache = new File( Transit.DPML_DATA, file.toString() );
- }
- cache.mkdirs();
- m_cacheDir = cache;
- }
-
- /**
- * Return a directory established to provide the local cache.
- *
- * @return the local cache directory
- */
- protected File getLocalCacheDirectory()
- {
- return m_cacheDir;
- }
-
- //
------------------------------------------------------------------------
- // CacheHandler
- //
------------------------------------------------------------------------
-
- /**
- * Return the current cache directory.
- * @return the cache directory.
- */
- public File getCacheDirectory()
- {
- return getLocalCacheDirectory();
- }
-
- /**
- * Attempts to download and cache a remote artifact using a set of remote
- * repositories. The operation is not fail fast and so it keeps trying
if
- * the first repository does not have the artifact in question.
- *
- * @param artifact the artifact to retrieve and cache
- * @return input stream containing the artifact content.
- * @exception IOException if an IO error occurs.
- * @exception TransitException if a transit system error occurs.
- * @exception NullArgumentException if the artifact argument is null.
- */
- public InputStream getResource( Artifact artifact )
- throws IOException, TransitException, NullArgumentException
- {
- File destination = getResourceFile( artifact );
-
- if( destination.exists() )
- {
- FileInputStream stream = new FileInputStream( destination );
- return new BufferedInputStream( stream );
- }
-
- String error = "Unresolvable artifact: [" + artifact + "]. (" +
destination + ")";
- throw new ArtifactNotFoundException( error, artifact.toURI() );
- }
-
- /**
- * Attempts to download and cache a remote artifact using a set of remote
- * repositories.
- * <p>
- * This method allows an internal reference to be passed to the
- * cache handler and it is expected to return the InputStream of the
- * internal item inside Jar/Zip files. If this method is called, the
- * implementation can assume that the artifact is a Zip file.
- * </p>
- *
- * @param artifact the artifact to retrieve and cache
- * @param internalReference referencing a item within the artifact. This
- * argument may start with "!" or "!/", which should be ignored.
- * @return a file referencing the local resource
- * @exception IOException if an IO error occurs
- * @exception TransitException is a transit system error occurs
- */
- public InputStream getResource( Artifact artifact, String
internalReference )
- throws IOException, TransitException
- {
- synchronized( this )
- {
- if( internalReference.startsWith( "!" ) )
- {
- internalReference = internalReference.substring( 1 );
- }
- if( internalReference.startsWith( "/" ) )
- {
- internalReference = internalReference.substring( 1 );
- }
-
- ZipFile zip = m_zipCache.get( artifact );
- if( zip == null )
- {
- File resourceFile = getResourceFile( artifact );
- zip = new ZipFile( resourceFile );
- m_zipCache.put( artifact, zip );
- }
- ZipEntry entry = zip.getEntry( internalReference );
- InputStream stream = zip.getInputStream( entry );
- return new BufferedInputStream( stream );
- }
- }
-
- /** Creates an output stream to where the artifact content can be written
- * to.
- * <p>
- * If the artifact already exists and the artifact is not a link a
- * <code>ArtifactAlreadyExistsException</code>
- * will be thrown. If the directory doesn't exists, it will be created.
- * </p>
- * @exception IOException if an IO error occurs.
- * @exception NullArgumentException if the artifact argument is null.
- * @exception ArtifactAlreadyExistsException if the artifact already
exists
- * in the cache and the artifact is not a link.
- */
- public OutputStream createOutputStream( Artifact artifact )
- throws NullArgumentException, ArtifactAlreadyExistsException,
IOException
- {
- if( null == artifact )
- {
- throw new NullArgumentException( "artifact" );
- }
- ResourceHost any = findAnyPresence( artifact );
- String scheme = artifact.getScheme();
- boolean flag = !"link".equals( scheme );
- if( ( any != null ) && flag )
- {
- throw new ArtifactAlreadyExistsException( "Artifact found on
server.", artifact );
- }
- String path = m_resolver.resolvePath( artifact );
- File destination = new File( m_cacheDir, path );
- if( destination.exists() && flag )
- {
- throw new ArtifactAlreadyExistsException( "Artifact found in
cache.", artifact );
- }
- File parentDir = destination.getParentFile();
- if( !parentDir.exists() )
- {
- parentDir.mkdirs();
- }
- return new FileOutputStream( destination );
- }
-
- /**
- * Return the layout used by the cache.
- * @return the cache layout
- */
- public Layout getLayout()
- {
- return m_resolver;
- }
-
- /**
- * Return the layout registry.
- * @return the layout registry.
- */
- public LayoutRegistry getLayoutRegistry()
- {
- return m_registry;
- }
-
- //
------------------------------------------------------------------------
- // implementation
- //
------------------------------------------------------------------------
-
- /**
- * Return a resource host.
- * @param artifact the artifact
- * @return the resource host (possibly null)
- */
- private ResourceHost findKnownGroupHost( Artifact artifact )
- {
- synchronized( m_resourceHosts )
- {
- Iterator list = m_resourceHosts.values().iterator();
- while ( list.hasNext() )
- {
- ResourceHost host = (ResourceHost) list.next();
- if( host.isEnabled() )
- {
- if( host.checkPresence( artifact, true ) )
- {
- return host;
- }
- }
- }
- return null;
- }
- }
-
- /**
- * Find any host.
- * @param artifact the artifact
- * @return the resource host (possibly null)
- */
- private ResourceHost findAnyPresence( Artifact artifact )
- {
- synchronized( m_resourceHosts )
- {
- Iterator list = m_resourceHosts.values().iterator();
- while ( list.hasNext() )
- {
- ResourceHost host = (ResourceHost) list.next();
- if( host.isEnabled() )
- {
- if( host.checkPresence( artifact, false ) )
- {
- return host;
- }
- }
- }
- return null;
- }
- }
-
- /**
- * Download an artifact from a host to the cache.
- * @param host the remote host
- * @param artifact the artifact being retrieved
- * @param destination the cached destination
- * @return TRUE if downloaded
- * @exception IOException if an IO error occurs
- * @exception TransitException if a transit system error occurs
- */
- private boolean download( ResourceHost host, Artifact artifact, File
destination )
- throws IOException, TransitException
- {
- if( host == null )
- {
- return false;
- }
-
- CacheMonitorRouter monitor =
Transit.getInstance().getCacheMonitorRouter();
-
- File parentDir = destination.getParentFile();
- File tempFile = File.createTempFile( "~dpml", ".tmp", parentDir );
- tempFile.deleteOnExit(); // safety harness in case we abort
abnormally
- FileOutputStream tempOut = new FileOutputStream( tempFile );
-
- try
- {
- Date lastModified = host.download( artifact, tempOut );
- // An atomic operation and no risk of a corrupted
- // artifact content.
- tempFile.renameTo( destination );
- destination.setLastModified( lastModified.getTime() );
- return true;
- }
- catch( Throwable e )
- {
- tempFile.delete();
- if( monitor != null )
- {
- monitor.failedDownloadFromHost( host.toString(), artifact, e
);
- }
- return false;
- }
- }
-
- private void endNotifyMonitor(
- CacheMonitorRouter monitor, boolean existed, Artifact artifact, File
destination )
- {
- if( monitor != null )
- {
- if( existed )
- {
- monitor.updatedLocalCache( artifact.toURL(), destination );
- }
- else
- {
- monitor.addedToLocalCache( artifact.toURL(), destination );
- }
- }
- }
-
- private void checkInternalConsistency( Artifact artifact, File
destination )
- {
- if( destination.exists() )
- {
- return;
- }
- final String error =
- "Download reported [success], but the destination does not exist: "
- + artifact
- + ", "
- + destination;
- throw new InternalError( error );
- }
-
- /** Locates and if necessary downloads the artifact.
- * @param artifact the Artifact to download and locate in the cache.
- * @return the File pointing to the artifact. The file may not exist if
the
- * download has failed.
- */
- private File getResourceFile( Artifact artifact )
- throws TransitException, IOException
- {
- CacheMonitorRouter monitor =
Transit.getInstance().getCacheMonitorRouter();
- if( monitor != null )
- {
- monitor.resourceRequested( artifact );
- }
- if( null == artifact )
- {
- throw new NullArgumentException( "artifact" );
- }
- String path = m_resolver.resolvePath( artifact );
- File destination = new File( m_cacheDir, path );
- File parentDir = destination.getParentFile();
- parentDir.mkdirs();
- boolean exist = destination.exists();
- boolean success;
- if( exist )
- {
- success = true;
- }
- else
- {
- ResourceHost known = findKnownGroupHost( artifact );
- success = download( known, artifact, destination );
- if( !success )
- {
- ResourceHost any = findAnyPresence( artifact );
- success = download( any, artifact, destination );
- }
- }
- if( success )
- {
- checkInternalConsistency( artifact, destination );
- endNotifyMonitor( monitor, exist, artifact, destination );
- }
-
- if( !destination.exists() && monitor != null )
- {
- monitor.failedDownload( artifact );
- }
-
- return destination;
- }
-
- //
------------------------------------------------------------------------
- // internals
- //
------------------------------------------------------------------------
-
- private void handleHostAddition( HostModel model )
- throws UnknownHostException, TransitException, IOException
- {
- synchronized( m_resourceHosts )
- {
- String id = model.getID();
- if( getLogger().isDebugEnabled() )
- {
- getLogger().debug( "adding host: " + id );
- }
- if( null == m_resourceHosts.get( id ) )
- {
- ResourceHost host = createResourceHost( model );
- m_resourceHosts.put( id, host );
- }
- else
- {
- final String error =
- "Illegal attempt to override existing host handler: " + id;
- throw new TransitException( error );
- }
- }
- }
-
- private ResourceHost createResourceHost( HostModel model )
- throws UnknownHostException, TransitException, IOException
- {
- return createDefaultResourceHost( model );
- }
-
- private ResourceHost createDefaultResourceHost( HostModel model ) throws
IOException
- {
- if( getLogger().isTraceEnabled() )
- {
- final String message =
- "Creating host ["
- + model.getID()
- + "] on "
- + model.getBaseURL();
- getLogger().trace( message );
- }
- try
- {
- return new DefaultResourceHost( model, m_registry, m_logger );
- }
- catch( Throwable e )
- {
- final String error =
- "Unexpected exception while attempting to load standard host:
" + model.getID()
- + "\nBase URL: " + model.getBaseURL();
- throw new TransitException( error, e );
- }
- }
-
- private Logger getLogger()
- {
- return m_logger;
- }
-}
-

Deleted:
trunk/main/transit/core/src/main/net/dpml/transit/DefaultCacheModel.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/DefaultCacheModel.java
2007-02-08 23:53:26 UTC (rev 1845)
+++ trunk/main/transit/core/src/main/net/dpml/transit/DefaultCacheModel.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -1,516 +0,0 @@
-/*
- * Copyright 2005 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.
- */
-
-package net.dpml.transit;
-
-import java.io.File;
-import java.rmi.Remote;
-import java.rmi.RemoteException;
-import java.rmi.NoSuchObjectException;
-import java.rmi.server.UnicastRemoteObject;
-import java.net.MalformedURLException;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.EventObject;
-import java.util.EventListener;
-import java.util.Set;
-import java.util.TreeSet;
-
-import net.dpml.util.Logger;
-
-import net.dpml.transit.info.LayoutDirective;
-import net.dpml.transit.info.CacheDirective;
-import net.dpml.transit.info.HostDirective;
-import net.dpml.transit.model.CacheModel;
-import net.dpml.transit.model.LayoutModel;
-import net.dpml.transit.model.LayoutRegistryModel;
-import net.dpml.transit.model.HostModel;
-import net.dpml.transit.model.CacheListener;
-import net.dpml.transit.model.CacheDirectoryChangeEvent;
-import net.dpml.transit.model.CacheEvent;
-
-import net.dpml.lang.DuplicateKeyException;
-import net.dpml.lang.UnknownKeyException;
-
-import net.dpml.util.PropertyResolver;
-import net.dpml.util.EventQueue;
-
-/**
- * Default implementation of the cache model that maintains information
- * about the current cache directory and the associated hosts.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-class DefaultCacheModel extends DefaultModel implements CacheModel
-{
- //
------------------------------------------------------------------------
- // state
- //
------------------------------------------------------------------------
-
- private final String m_path;
-
- private final Set m_list = Collections.synchronizedSortedSet( new
TreeSet() );
-
- private final File m_cache;
-
- private final LayoutModel m_layout;
-
- private final LayoutRegistryModel m_registry;
-
- private HostModel[] m_sortedHosts;
-
- //
------------------------------------------------------------------------
- // constructor
- //
------------------------------------------------------------------------
-
- /**
- * Construct a new cache model.
- *
- * @param logger the assigned logging channel
- * @param directive the cache configuration directive
- * @exception Exception if an error occurs
- */
- public DefaultCacheModel( EventQueue queue, Logger logger,
CacheDirective directive )
- throws Exception
- {
- super( queue, logger );
-
- if( null == directive )
- {
- throw new NullPointerException( "directive" );
- }
-
- try
- {
- Logger log = logger.getChildLogger( "layout" );
- LayoutDirective[] layouts = directive.getLayoutDirectives();
- m_registry = new DefaultLayoutRegistryModel( queue, log, layouts
);
- String layout = directive.getCacheLayout();
- m_layout = m_registry.getLayoutModel( layout );
- }
- catch( Exception e )
- {
- final String error =
- "Unexpected internal error while constructing layout registry
model.";
- throw new ModelRuntimeException( error, e );
- }
-
- // set the cache directory
-
- m_path = directive.getCache();
- String resolved = PropertyResolver.resolve( m_path );
- File cache = new File( resolved );
- if( !cache.isAbsolute() )
- {
- File anchor = getAnchorDirectory();
- cache = new File( anchor, resolved );
- cache.mkdirs();
- }
-
- if( logger.isDebugEnabled() )
- {
- logger.debug( "setting cache: " + cache );
- }
-
- m_cache = cache;
-
- // setup the standard local respository host
-
- m_sortedHosts = sortHosts();
- String localPath = directive.getLocal();
- String localLayout = directive.getLocalLayout();
- HostDirective local = createLocalHostDirective( localPath,
localLayout );
- addHostModel( local, false );
-
- // setup the supplimentary hosts
-
- HostDirective[] hosts = directive.getHostDirectives();
- for( int i=0; i < hosts.length; i++ )
- {
- HostDirective host = hosts[i];
- addHostModel( host, false );
- }
- }
-
- //
------------------------------------------------------------------------
- // CacheModel
- //
------------------------------------------------------------------------
-
- /**
- * Return the cache layout strategy model used by the cache
implementation.
- * @return the layout model
- * @exception RemoteException if a remote exception occurs
- */
- public LayoutModel getLayoutModel()
- {
- return m_layout;
- }
-
- /**
- * Return the layout registry model.
- * @return the registry of layout models
- * @exception RemoteException if a remote exception occurs
- */
- public LayoutRegistryModel getLayoutRegistryModel()
- {
- return m_registry;
- }
-
- /**
- * Return an array of host models established by the implementation.
- * @return the host model array
- * @exception RemoteException if a remote exception occurs
- */
- public HostModel[] getHostModels()
- {
- synchronized( getLock() )
- {
- return m_sortedHosts;
- }
- }
-
- /**
- * Return an identified host model .
- * @param id the host model id
- * @return the host model
- * @exception UnknownKeyException the host model id is not recognized
- */
- public HostModel getHostModel( String id ) throws UnknownKeyException
- {
- synchronized( getLock() )
- {
- HostModel[] managers = getHostModels();
- for( int i=0; i < managers.length; i++ )
- {
- HostModel manager = managers[i];
- try
- {
- if( id.equals( manager.getID() ) )
- {
- return manager;
- }
- }
- catch( RemoteException e )
- {
- throw new ModelRuntimeException( e.getMessage(), e );
- }
- }
- throw new UnknownKeyException( id );
- }
- }
-
- /**
- * Return the cache directory path.
- * @return the cache path.
- * @exception RemoteException if a remote exception occurs
- */
- public String getCacheDirectoryPath()
- {
- return m_path;
- }
-
- /**
- * Return the directory to be used by the cache handler as the cache
directory.
- * @return the cache directory.
- * @exception RemoteException if a remote exception occurs
- */
- public File getCacheDirectory()
- {
- return m_cache;
- }
-
- /**
- * Add a cache change listener.
- * @param listener the listener to add
- * @exception RemoteException if a remote exception occurs
- */
- public void addCacheListener( CacheListener listener )
- {
- super.addListener( listener );
- }
-
- /**
- * Remove a cache change listener.
- * @param listener the listener to remove
- * @exception RemoteException if a remote exception occurs
- */
- public void removeCacheListener( CacheListener listener )
- {
- super.removeListener( listener );
- }
-
- //
------------------------------------------------------------------------
- // Disposable
- //
------------------------------------------------------------------------
-
- /**
- * Disposal of the cache model.
- * @exception RemoteException if a remote exception occurs
- */
- public synchronized void dispose()
- {
- HostModel[] hosts = getHostModels();
- for( int i=0; i<hosts.length; i++ )
- {
- HostModel host = hosts[i];
- dispose( host );
- }
- dispose( m_registry );
- super.dispose();
- }
-
- private void dispose( Object object )
- {
- if( object instanceof Disposable )
- {
- Disposable disposable = (Disposable) object;
- disposable.dispose();
- }
- if( object instanceof Remote )
- {
- try
- {
- Remote remote = (Remote) object;
- UnicastRemoteObject.unexportObject( remote, true );
- }
- catch( NoSuchObjectException e )
- {
- // ignore
- }
- catch( RemoteException re )
- {
- getLogger().warn( "Unexpected error during remote reference
removal.", re );
- }
- }
- }
-
- //
------------------------------------------------------------------------
- // internal
- //
------------------------------------------------------------------------
-
- /**
- * Add a new host model to the cache model.
- * @param directive the host model configuration
- * @param notify if true issue a notification event of host model addition
- * @exception DuplicateKeyException a host model with a matching id
already exists
- * @exception UnknownKeyException the host model requests a layout model
id that is not recognized
- * @exception MalformedURLException the host model base url is malformed
- * @exception RemoteException if a remote exception occurs
- */
- void addHostModel( HostDirective directive, boolean notify )
- throws DuplicateKeyException, UnknownKeyException,
MalformedURLException
- {
- try
- {
- String id = directive.getID();
- Logger logger = getLogger().getChildLogger( id );
- LayoutRegistryModel registry = getLayoutRegistryModel();
- EventQueue queue = getEventQueue();
- HostModel model = new DefaultHostModel( queue, logger,
directive, registry );
- addHostModel( model, notify );
- }
- catch( RemoteException e )
- {
- throw new ModelRuntimeException( e.getMessage(), e );
- }
- }
-
- /**
- * Add a new host model to the cache model.
- * @param manager the host model to be added
- * @param notify if TRUE issue a modification event
- * @exception DuplicateKeyException a host model with a matching id
already exists
- * @exception RemoteException if a remote exception occurs
- */
- void addHostModel( HostModel manager, boolean notify ) throws
DuplicateKeyException
- {
- synchronized( getLock() )
- {
- try
- {
- String id = manager.getID();
- HostModel m = getHostModel( id );
- throw new DuplicateKeyException( id );
- }
- catch( UnknownKeyException e )
- {
- m_list.add( manager );
- m_sortedHosts = sortHosts();
- if( notify )
- {
- HostAddedEvent event = new HostAddedEvent( this, manager
);
- enqueueEvent( event );
- }
- }
- catch( RemoteException e )
- {
- throw new ModelRuntimeException( e.getMessage(), e );
- }
- }
- }
-
- /**
- * Internal processing of an event.
- * @param event the event
- */
- public void processEvent( EventObject event )
- {
- if( event instanceof CacheEvent )
- {
- processCacheEvent( (CacheEvent) event );
- }
- else if( event instanceof CacheDirectoryChangeEvent )
- {
- processCacheDirectoryChangeEvent( (CacheDirectoryChangeEvent)
event );
- }
- }
-
- private void processCacheEvent( CacheEvent event )
- {
- EventListener[] listeners = super.getEventListeners();
- for( int i=0; i < listeners.length; i++ )
- {
- EventListener eventListener = listeners[i];
- if( eventListener instanceof CacheListener )
- {
- CacheListener listener = (CacheListener) eventListener;
- if( event instanceof HostAddedEvent )
- {
- try
- {
- listener.hostAdded( event );
- }
- catch( Throwable e )
- {
- final String error =
- "CacheListener host addition notification error.";
- getLogger().error( error, e );
- }
- }
- else if( event instanceof HostRemovedEvent )
- {
- try
- {
- listener.hostRemoved( event );
- }
- catch( Throwable e )
- {
- final String error =
- "CacheListener host removed notification error.";
- getLogger().error( error, e );
- }
- }
- }
- }
- }
-
- private void processCacheDirectoryChangeEvent( CacheDirectoryChangeEvent
event )
- {
- EventListener[] listeners = super.getEventListeners();
- for( int i=0; i < listeners.length; i++ )
- {
- EventListener listener = listeners[i];
- if( listener instanceof CacheListener )
- {
- CacheListener cl = (CacheListener) listener;
- try
- {
- cl.cacheDirectoryChanged( event );
- }
- catch( Throwable e )
- {
- final String error =
- "CacheListener host addition notification error.";
- getLogger().error( error, e );
- }
- }
- }
- }
-
- private HostModel[] sortHosts()
- {
- synchronized( getLock() )
- {
- HostModel[] hosts = (HostModel[]) m_list.toArray( new
HostModel[0] );
- HostModel[] list = new HostModel[ hosts.length ];
- for( int i=0; i < hosts.length; i++ )
- {
- list[i] = hosts[i];
- }
- Arrays.sort( list );
- return list;
- }
- }
-
- private File getAnchorDirectory()
- {
- return Transit.DPML_DATA;
- }
-
- private HostDirective createLocalHostDirective( String path, String
layout )
- {
- return new HostDirective(
- "local",
- 10,
- path,
- null,
- null,
- null,
- true,
- true,
- layout,
- null,
- null );
- }
-
- /**
- * Host addition event.
- */
- static class HostAddedEvent extends CacheEvent
- {
- private int m_priority;
-
- /**
- * Creation of a new host addition event.
- * @param source the source cache model
- * @param host the host model that was added
- */
- public HostAddedEvent( CacheModel source, HostModel host )
- {
- super( source, host );
- }
- }
-
- /**
- * Host removal event.
- */
- static class HostRemovedEvent extends CacheEvent
- {
- /**
- * Creation of a new host removal event.
- * @param source the source cache model
- * @param host the host model that was removed
- */
- public HostRemovedEvent( CacheModel source, HostModel host )
- {
- super( source, host );
- }
- }
-}
-

Deleted:
trunk/main/transit/core/src/main/net/dpml/transit/DefaultCodeBaseModel.java
===================================================================
---
trunk/main/transit/core/src/main/net/dpml/transit/DefaultCodeBaseModel.java
2007-02-08 23:53:26 UTC (rev 1845)
+++
trunk/main/transit/core/src/main/net/dpml/transit/DefaultCodeBaseModel.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -1,201 +0,0 @@
-/*
- * Copyright 2005 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.
- */
-
-package net.dpml.transit;
-
-import java.net.URI;
-import java.rmi.RemoteException;
-import java.util.EventObject;
-import java.util.EventListener;
-
-import net.dpml.lang.Value;
-import net.dpml.lang.ValueDirective;
-import net.dpml.lang.Construct;
-
-import net.dpml.transit.info.CodeBaseDirective;
-import net.dpml.transit.model.CodeBaseModel;
-import net.dpml.transit.model.CodeBaseListener;
-import net.dpml.transit.model.CodeBaseEvent;
-import net.dpml.transit.model.LocationEvent;
-import net.dpml.transit.model.ParametersEvent;
-
-import net.dpml.util.Logger;
-import net.dpml.util.EventQueue;
-
-/**
- * The abstract codebase is an implementation that monitors configuration
changes
- * to a a codebase storage unit containg a uri attribute. Modifications to
the uri value
- * will trigger a CodeBaseEvent which can be monitored by controllers
dealing with
- * pluggable system maintenance.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-abstract class DefaultCodeBaseModel extends DefaultModel implements
CodeBaseModel
-{
- //
------------------------------------------------------------------------
- // state
- //
------------------------------------------------------------------------
-
- private Value[] m_parameters;
- private URI m_uri;
-
- //
------------------------------------------------------------------------
- // constructor
- //
------------------------------------------------------------------------
-
- /**
- * Construction of a new codebase model using a supplied codebase storage
unit.
- * @param logger the assigned logging channel
- * @param directive the codebase storage directive
- * @exception RemoteException if a remote exception occurs
- */
- public DefaultCodeBaseModel( EventQueue queue, Logger logger,
CodeBaseDirective directive )
- throws RemoteException
- {
- super( queue, logger );
- if( null == directive )
- {
- throw new NullPointerException( "directive" );
- }
- m_uri = directive.getCodeBaseURI();
- ValueDirective[] values = directive.getValueDirectives();
- m_parameters = new Value[ values.length ];
- for( int i=0; i<values.length; i++ )
- {
- ValueDirective value = values[i];
- m_parameters[i] = new Construct( value );
- }
- }
-
- //
------------------------------------------------------------------------
- // CodeBaseModel
- //
------------------------------------------------------------------------
-
- /**
- * Return the codebase uri.
- * @return the codebase uri
- */
- public URI getCodeBaseURI()
- {
- synchronized( getLock() )
- {
- return m_uri;
- }
- }
-
- /**
- * Add a codebase listener to the model.
- * @param listener the listener to add
- */
- public void addCodeBaseListener( CodeBaseListener listener )
- {
- super.addListener( listener );
- }
-
- /**
- * Remove a codebase listener from the model.
- * @param listener the listener to remove
- */
- public void removeCodeBaseListener( CodeBaseListener listener )
- {
- super.removeListener( listener );
- }
-
- /**
- * Return the array of codebase parameters.
- *
- * @return the parameters array
- */
- public Value[] getParameters()
- {
- synchronized( getLock() )
- {
- return m_parameters;
- }
- }
-
- //
------------------------------------------------------------------------
- // internals
- //
------------------------------------------------------------------------
-
- /**
- * Internal event handler.
- * @param eventObject the event
- */
- public void processEvent( EventObject eventObject )
- {
- if( eventObject instanceof CodeBaseEvent )
- {
- CodeBaseEvent event = (CodeBaseEvent) eventObject;
- processCodeBaseEvent( event );
- }
- else
- {
- final String error =
- "Event class not recognized: " +
eventObject.getClass().getName();
- throw new IllegalArgumentException( error );
- }
- }
-
- private void processCodeBaseEvent( CodeBaseEvent event )
- {
- EventListener[] listeners = super.getEventListeners();
- for( int i=0; i < listeners.length; i++ )
- {
- EventListener listener = listeners[i];
- if( listener instanceof CodeBaseListener )
- {
- CodeBaseListener pl = (CodeBaseListener) listener;
- if( event instanceof LocationEvent )
- {
- try
- {
- pl.codeBaseChanged( (LocationEvent) event );
- }
- catch( Throwable e )
- {
- final String error =
- "CodeBaseListener notification error.";
- getLogger().error( error, e );
- }
- }
- else if( event instanceof ParametersEvent )
- {
- try
- {
- pl.parametersChanged( (ParametersEvent) event );
- }
- catch( Throwable e )
- {
- final String error =
- "CodeBaseListener notification error.";
- getLogger().error( error, e );
- }
- }
- else
- {
- final String error =
- "Event class not recognized: " +
event.getClass().getName();
- throw new IllegalArgumentException( error );
- }
- }
- }
- }
-}
-

Deleted:
trunk/main/transit/core/src/main/net/dpml/transit/DefaultHostModel.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/DefaultHostModel.java
2007-02-08 23:53:26 UTC (rev 1845)
+++ trunk/main/transit/core/src/main/net/dpml/transit/DefaultHostModel.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -1,565 +0,0 @@
-/*
- * Copyright 2005 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.
- */
-
-package net.dpml.transit;
-
-import java.rmi.RemoteException;
-import java.util.ArrayList;
-import java.util.EventObject;
-import java.util.EventListener;
-import java.net.URL;
-import java.net.MalformedURLException;
-import java.net.PasswordAuthentication;
-
-import net.dpml.transit.info.HostDirective;
-import net.dpml.transit.model.HostModel;
-import net.dpml.transit.model.LayoutModel;
-import net.dpml.transit.model.LayoutRegistryModel;
-import net.dpml.transit.model.HostListener;
-import net.dpml.transit.model.HostChangeEvent;
-import net.dpml.transit.model.HostLayoutEvent;
-import net.dpml.transit.model.HostPriorityEvent;
-import net.dpml.transit.model.HostNameEvent;
-import net.dpml.transit.model.RequestIdentifier;
-
-import net.dpml.lang.UnknownKeyException;
-
-import net.dpml.util.PropertyResolver;
-import net.dpml.util.Logger;
-import net.dpml.util.EventQueue;
-
-/**
- * Default implementation of a host manager.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-class DefaultHostModel extends DefaultModel implements HostModel,
Comparable, Disposable
-{
- private static final int DEFAULT_PRIORITY = 600;
-
- private final LayoutRegistryModel m_registry;
-
- private String m_id;
- private String m_base;
- private String m_index;
- private URL m_baseURL;
- private URL m_indexURL;
- private boolean m_enabled = false;
- private boolean m_trusted = false;
- private LayoutModel m_layout;
- private int m_priority = DEFAULT_PRIORITY;
- private RequestIdentifier m_identifier;
- private PasswordAuthentication m_authentication;
-
- private Throwable m_error;
-
- //
------------------------------------------------------------------------
- // constructor
- //
------------------------------------------------------------------------
-
- /**
- * Creation of a new host model.
- *
- * @param logger the assigned logging channel
- * @param directive the host configuration directive
- * @param registry the layout model registry
- * @exception UnknownKeyException if the layout id is unknown
- * @exception MalformedURLException if the host base url path is malformed
- * @exception RemoteException if a remote exception occurs
- */
- public DefaultHostModel( EventQueue queue, Logger logger, HostDirective
directive, LayoutRegistryModel registry )
- throws RemoteException, UnknownKeyException, MalformedURLException
- {
- super( queue, logger );
-
- m_registry = registry;
-
- m_id = directive.getID();
- m_trusted = directive.getTrusted();
- m_enabled = directive.getEnabled();
- m_priority = directive.getPriority();
-
- m_base = resolveBaseValue( directive.getHost() );
- m_index = directive.getIndex();
- m_baseURL = resolveBaseURL( m_id, m_base );
- m_indexURL = resolveIndexURL( m_id, m_baseURL, m_index );
-
- String username = directive.getUsername();
- if( null != username )
- {
- m_authentication = new PasswordAuthentication( username,
directive.getPassword() );
- }
- else
- {
- m_authentication = new PasswordAuthentication( null, new char[0]
);
- }
-
- String key = directive.getLayout();
- m_layout = registry.getLayoutModel( key );
- String scheme = directive.getScheme();
- String prompt = directive.getPrompt();
- m_identifier = getRequestIdentifier( m_baseURL, scheme, prompt );
- }
-
- //----------------------------------------------------------------------
- // Disposable
- //----------------------------------------------------------------------
-
- /**
- * Dispose of the model.
- */
- public void dispose()
- {
- super.dispose();
- }
-
- //----------------------------------------------------------------------
- // HostModel
- //----------------------------------------------------------------------
-
- /**
- * Return the host priority.
- * @return the host priority setting
- */
- public int getPriority()
- {
- synchronized( getLock() )
- {
- return m_priority;
- }
- }
-
- /**
- * Return the id of the resource host. The value returned may be used to
uniquely
- * identify the host within the set of managed hosts.
- */
- public String getID()
- {
- synchronized( getLock() )
- {
- return m_id;
- }
- }
-
- /**
- * Return the host base url path.
- * @return the base url path
- */
- public String getBasePath()
- {
- synchronized( getLock() )
- {
- return m_base;
- }
- }
-
- /**
- * Return the host base url.
- * @return the base url
- */
- public URL getBaseURL()
- {
- synchronized( getLock() )
- {
- return m_baseURL;
- }
- }
-
- /**
- * Return index url path.
- * @return the index url path
- */
- public String getIndexPath()
- {
- synchronized( getLock() )
- {
- return m_index;
- }
- }
-
- /**
- * Return index url.
- * @return the index url
- */
- public URL getIndexURL()
- {
- synchronized( getLock() )
- {
- return m_indexURL;
- }
- }
-
- /**
- * Return the enabled status of the host.
- * @return TRUE if enabled
- */
- public boolean getEnabled()
- {
- synchronized( getLock() )
- {
- return m_enabled;
- }
- }
-
- /**
- * Return the trusted status.
- * @return TRUE if trusted
- */
- public boolean getTrusted()
- {
- synchronized( getLock() )
- {
- return m_trusted;
- }
- }
-
- /**
- * Return the host password authentication credentials.
- * @return the password authentication credentials
- */
- public PasswordAuthentication getAuthentication()
- {
- synchronized( getLock() )
- {
- return m_authentication;
- }
- }
-
- /**
- * Return the host request identifier.
- * @return the identifier
- */
- public RequestIdentifier getRequestIdentifier()
- {
- synchronized( getLock() )
- {
- return m_identifier;
- }
- }
-
- /**
- * Return the layout strategy model.
- * @return the layout model
- */
- public LayoutModel getLayoutModel()
- {
- synchronized( getLock() )
- {
- return m_layout;
- }
- }
-
- /**
- * Add a host change listener to the model.
- * @param listener the host change listener to add
- */
- public void addHostListener( HostListener listener )
- {
- super.addListener( listener );
- }
-
- /**
- * Remove a host change listener from the model.
- * @param listener the host change listener to remove
- */
- public void removeHostListener( HostListener listener )
- {
- super.removeListener( listener );
- }
-
- //----------------------------------------------------------------------
- // Comparable
- //----------------------------------------------------------------------
-
- /**
- * Compare this host with another object.
- * @param other the object to compare with this host model
- * @return the comparitive value based on a comparison of host priorities
- */
- public int compareTo( Object other )
- {
- if( null == other )
- {
- return -1;
- }
- else if( !( other instanceof HostModel ) )
- {
- return -1;
- }
- else
- {
- try
- {
- HostModel host = (HostModel) other;
- Integer i = new Integer( getPriority() );
- Integer j = new Integer( host.getPriority() );
- return i.compareTo( j );
- }
- catch( RemoteException e )
- {
- final String error =
- "Unable to compare host due to a remote exception.";
- throw new ModelRuntimeException( error, e );
- }
- }
- }
-
- //----------------------------------------------------------------------
- // internal
- //----------------------------------------------------------------------
-
- /**
- * Internal event handler.
- * @param event the event to handle
- */
- public void processEvent( EventObject event )
- {
- if( event instanceof HostChangeEvent )
- {
- processHostChangeEvent( (HostChangeEvent) event );
- }
- else if( event instanceof HostLayoutEvent )
- {
- processHostLayoutEvent( (HostLayoutEvent) event );
- }
- else if( event instanceof HostPriorityEvent )
- {
- processHostPriorityEvent( (HostPriorityEvent) event );
- }
- else if( event instanceof HostNameEvent )
- {
- processHostNameEvent( (HostNameEvent) event );
- }
- }
-
- private void processHostLayoutEvent( HostLayoutEvent event )
- {
- HostListener[] listeners = getHostListeners();
- for( int i=0; i < listeners.length; i++ )
- {
- HostListener listener = listeners[i];
- try
- {
- listener.layoutChanged( event );
- }
- catch( Throwable e )
- {
- final String error =
- "HostListener resolver change notification error.";
- getLogger().warn( error, e );
- }
- }
- }
-
- private void processHostPriorityEvent( HostPriorityEvent event )
- {
- HostListener[] listeners = getHostListeners();
- for( int i=0; i < listeners.length; i++ )
- {
- HostListener listener = listeners[i];
- try
- {
- listener.priorityChanged( event );
- }
- catch( Throwable e )
- {
- final String error =
- "HostListener priority change notification error.";
- getLogger().warn( error, e );
- }
- }
- }
-
- private void processHostNameEvent( HostNameEvent event )
- {
- HostListener[] listeners = getHostListeners();
- for( int i=0; i < listeners.length; i++ )
- {
- HostListener listener = listeners[i];
- try
- {
- listener.nameChanged( event );
- }
- catch( Throwable e )
- {
- final String error =
- "HostListener name change notification error.";
- getLogger().warn( error, e );
- }
- }
- }
-
- private void processHostChangeEvent( HostChangeEvent event )
- {
- HostListener[] listeners = getHostListeners();
- for( int i=0; i < listeners.length; i++ )
- {
- HostListener listener = listeners[i];
- try
- {
- listener.hostChanged( event );
- }
- catch( Throwable e )
- {
- final String error =
- "HostListener change notification error.";
- getLogger().warn( error, e );
- }
- }
- }
-
- private HostListener[] getHostListeners()
- {
- ArrayList list = new ArrayList();
- EventListener[] listeners = super.getEventListeners();
- for( int i=0; i < listeners.length; i++ )
- {
- EventListener eventListener = listeners[i];
- if( eventListener instanceof HostListener )
- {
- HostListener listener = (HostListener) eventListener;
- list.add( listener );
- }
- }
- return (HostListener[]) list.toArray( new HostListener[0] );
- }
-
- //
------------------------------------------------------------------------
- // static (utils)
- //
------------------------------------------------------------------------
-
- private static String resolveBaseValue( String path )
- {
- //
- // make sure the base path ends with a "/" otherwise relative url
references
- // will not be correct
- //
-
- if( !path.endsWith( "/" ) )
- {
- return path + "/";
- }
- else
- {
- return path;
- }
- }
-
- private static RequestIdentifier getRequestIdentifier( URL base, String
scheme, String prompt )
- {
- if( null == base )
- {
- throw new NullPointerException( "base" );
- }
- if( null == scheme )
- {
- throw new NullPointerException( "scheme" );
- }
- if( null == prompt )
- {
- throw new NullPointerException( "prompt" );
- }
- String protocol = base.getProtocol();
- String host = base.getHost();
- int port = base.getPort();
- if( port == 0 )
- {
- if( protocol.equals( "http" ) )
- {
- port = HTTP_PORT;
- }
- else if( protocol.equals( "ftp" ) )
- {
- port = FTP_PORT;
- }
- else if( protocol.equals( "https" ) )
- {
- port = HTTPS_PORT;
- }
- }
- return new RequestIdentifier( host, port, protocol, scheme, prompt );
- }
-
- private static URL resolveBaseURL( String id, String path ) throws
MalformedURLException
- {
- if( null == path )
- {
- return getDefaultHostURL();
- }
- try
- {
- String spec = PropertyResolver.resolve( path );
- return new URL( spec );
- }
- catch( MalformedURLException e )
- {
- final String error =
- "Invalid host base url"
- + "\nHost ID: " + id
- + "\nHost Path: " + path
- + "\nCause: " + e.getMessage();
- throw new MalformedURLException( error );
- }
- }
-
- private static URL resolveIndexURL( String id, URL base, String path )
throws MalformedURLException
- {
- if( null == path )
- {
- return null;
- }
-
- String resolved = PropertyResolver.resolve( path );
-
- try
- {
- return new URL( resolved );
- }
- catch( MalformedURLException e )
- {
- try
- {
- return new URL( base, resolved );
- }
- catch( MalformedURLException ee )
- {
- final String error =
- "Invalid index url"
- + "\nHost ID: " + id
- + "\nHost Path: " + base
- + "\nIndex Path: " + path
- + "\nCause: " + e.getMessage();
- throw new MalformedURLException( error );
- }
- }
- }
-
- private static URL getDefaultHostURL()
- {
- try
- {
- return new URL( "http://localhost"; );
- }
- catch( Exception e )
- {
- return null;
- }
- }
-}
-

Deleted:
trunk/main/transit/core/src/main/net/dpml/transit/DefaultLayoutModel.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/DefaultLayoutModel.java
2007-02-08 23:53:26 UTC (rev 1845)
+++ trunk/main/transit/core/src/main/net/dpml/transit/DefaultLayoutModel.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -1,174 +0,0 @@
-/*
- * Copyright 2005 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.
- */
-
-package net.dpml.transit;
-
-import java.rmi.RemoteException;
-import java.util.EventObject;
-import java.util.EventListener;
-
-import net.dpml.transit.info.LayoutDirective;
-import net.dpml.transit.model.LayoutModel;
-import net.dpml.transit.model.LayoutListener;
-import net.dpml.transit.model.LayoutEvent;
-
-import net.dpml.util.EventQueue;
-import net.dpml.util.Logger;
-
-/**
- * The DefaultLayoutModel is a model supplied to a layout strategy handler.
It
- * provides two mdes of construction - one dealing with local layout handlers
- * (the classic layout and the ecli8pse layout) and the second dealing with
- * plugin layout strategies.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-class DefaultLayoutModel extends DefaultCodeBaseModel implements
LayoutModel, Disposable
-{
- //----------------------------------------------------------------------
- // state
- //----------------------------------------------------------------------
-
- private final String m_id;
- private final String m_title;
-
- //----------------------------------------------------------------------
- // constructor
- //----------------------------------------------------------------------
-
- /**
- * Creation of a new layout model using a supplied layout configuration.
- * @param logger the assigned logging channel
- * @param directive the layout configuration
- * @exception RemoteException if a remote exception occurs
- */
- public DefaultLayoutModel( final EventQueue queue, final Logger logger,
final LayoutDirective directive )
- throws RemoteException
- {
- super( queue, logger, directive );
-
- m_id = directive.getID();
- m_title = directive.getTitle();
- }
-
- //----------------------------------------------------------------------
- // LayoutModel
- //----------------------------------------------------------------------
-
- /**
- * Returns the human readable name of the resolver.
- * @return the resolver human readable name
- */
- public String getID()
- {
- return m_id;
- }
-
- /**
- * Returns the human readable name of the resolver.
- * @return the resolver human readable name
- */
- public String getTitle()
- {
- return m_title;
- }
-
- /**
- * Returns the layout classname.
- * @return the classname (always returns null)
- */
- public String getClassname()
- {
- return null;
- }
-
- /**
- * Add a layout listener to the model.
- * @param listener the listener to add
- */
- public void addLayoutListener( LayoutListener listener )
- {
- super.addListener( listener );
- }
-
- /**
- * Remove a layout listener from the director.
- * @param listener the listener to remove
- */
- public void removeLayoutListener( LayoutListener listener )
- {
- super.removeListener( listener );
- }
-
- //----------------------------------------------------------------------
- // Disposable
- //----------------------------------------------------------------------
-
- /**
- * Dispose of the layout model.
- */
- public void dispose()
- {
- super.dispose();
- }
-
- //
------------------------------------------------------------------------
- // internal
- //
------------------------------------------------------------------------
-
- /**
- * Internal event handler.
- * @param event the event to handle
- */
- public void processEvent( EventObject event )
- {
- if( event instanceof LayoutEvent )
- {
- processLayoutEvent( (LayoutEvent) event );
- }
- else
- {
- super.processEvent( event );
- }
- }
-
- private void processLayoutEvent( LayoutEvent event )
- {
- EventListener[] listeners = super.getEventListeners();
- for( int i=0; i < listeners.length; i++ )
- {
- EventListener eventListener = listeners[i];
- if( eventListener instanceof LayoutListener )
- {
- LayoutListener listener = (LayoutListener) eventListener;
- try
- {
- listener.titleChanged( event );
- }
- catch( Throwable e )
- {
- final String error =
- "LayoutListener title change notification error.";
- getLogger().error( error, e );
- }
- }
- }
- }
-}
-

Deleted:
trunk/main/transit/core/src/main/net/dpml/transit/DefaultLayoutRegistry.java
===================================================================
---
trunk/main/transit/core/src/main/net/dpml/transit/DefaultLayoutRegistry.java
2007-02-08 23:53:26 UTC (rev 1845)
+++
trunk/main/transit/core/src/main/net/dpml/transit/DefaultLayoutRegistry.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -1,220 +0,0 @@
-/*
- * Copyright 2005 Stephen 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.
- */
-
-package net.dpml.transit;
-
-import java.io.IOException;
-import java.net.URI;
-import java.rmi.RemoteException;
-import java.rmi.server.UnicastRemoteObject;
-import java.util.Map;
-import java.util.WeakHashMap;
-
-import net.dpml.transit.model.LayoutRegistryModel;
-import net.dpml.transit.model.LayoutRegistryListener;
-import net.dpml.transit.model.LayoutRegistryEvent;
-import net.dpml.transit.model.LayoutModel;
-
-import net.dpml.lang.UnknownKeyException;
-import net.dpml.util.Logger;
-
-import net.dpml.lang.Part;
-import net.dpml.lang.Plugin;
-
-/**
- * A registry of descriptions of plugable layout models.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-class DefaultLayoutRegistry extends UnicastRemoteObject
- implements LayoutRegistry, LayoutRegistryListener
-{
- //
------------------------------------------------------------------------
- // state
- //
------------------------------------------------------------------------
-
- private final Logger m_logger;
-
- private final Map m_plugins = new WeakHashMap();
-
- private final LayoutRegistryModel m_model;
-
- //
------------------------------------------------------------------------
- // constructor
- //
------------------------------------------------------------------------
-
- /**
- * Provides support for the resolution of location resolver instances.
- */
- public DefaultLayoutRegistry( LayoutRegistryModel model, Logger logger )
throws RemoteException
- {
- super();
-
- m_model = model;
- m_logger = logger;
- model.addLayoutRegistryListener( this );
- }
-
- //
------------------------------------------------------------------------
- // LayoutRegistry
- //
------------------------------------------------------------------------
-
- public Layout getLayout( final String id ) throws UnknownKeyException,
IOException
- {
- LayoutModel model = m_model.getLayoutModel( id );
- return getLayout( model );
- }
-
- /**
- * Locate and return a location resolver.
- * @param model the location resolver model
- * @return the resolver
- */
- protected Layout getLayout( LayoutModel model ) throws
UnknownKeyException, IOException
- {
- String id = model.getID();
- String classname = model.getClassname();
- if( null != classname )
- {
- return loadLayout( classname );
- }
- else
- {
- return loadLayout( model );
- }
- }
-
- protected Layout loadLayout( final String classname ) throws
TransitException
- {
- if( ClassicLayout.class.getName().equals( classname ) )
- {
- return CLASSIC_RESOLVER;
- }
- else if( ModernLayout.class.getName().equals( classname ) )
- {
- return MODERN_RESOLVER;
- }
- else if( EclipseLayout.class.getName().equals( classname ) )
- {
- return ECLIPSE_RESOLVER;
- }
- else
- {
- final String error =
- "Bootstrap location resolver classname not recognized."
- + "\nClassname: " + classname;
- throw new TransitException( error );
- }
- }
-
- protected Layout loadLayout( LayoutModel model ) throws IOException
- {
- Class clazz = loadLayoutClass( model );
- try
- {
- return (Layout) Plugin.instantiate( clazz, new Object[]{model} );
- }
- catch( Throwable e )
- {
- final String error =
- "Unable to load request model due to an instantiation failure."
- + "\nLayout ID: " + model.getID();
- throw new TransitException( error, e );
- }
- }
-
- protected Class loadLayoutClass( LayoutModel model ) throws IOException
- {
- URI uri = model.getCodeBaseURI();
- Class clazz = (Class) m_plugins.get( uri );
- if( null != clazz )
- {
- return clazz;
- }
- else
- {
- try
- {
- m_logger.debug( "loading resolver plugin: " + uri );
- Part part = Part.load( uri );
- if( part instanceof Plugin )
- {
- Plugin plugin = (Plugin) part;
- clazz = plugin.getPluginClass();
- }
- else
- {
- final String error =
- "Cannot load non-plugin part (impementation assumes
plugin strategy)."
- + "\nURI: " + uri;
- throw new IOException( error );
- }
- }
- catch( Exception e )
- {
- final String error =
- "Unable to load a layout plugin due to an unexpected
exception.";
- throw new TransitException( error, e );
- }
-
- if( Layout.class.isAssignableFrom( clazz ) )
- {
- m_plugins.put( uri, clazz );
- return clazz;
- }
- else
- {
- final String error =
- "Plugin is not assignable to a
net.dpml.transit.location.Layout."
- + "\nPlugin URI: " + uri
- + "\nPlugin Class: " + clazz.getName();
- throw new TransitException( error );
- }
- }
- }
-
- //
------------------------------------------------------------------------
- // LayoutRegistryListener
- //
------------------------------------------------------------------------
-
- /**
- * Notify all listeners of the addition of a layout model.
- * @param event the registry event
- */
- public void layoutAdded( LayoutRegistryEvent event ) throws
RemoteException
- {
- }
-
- /**
- * Notify all listeners of the removal of a content model.
- * @param event the registry event
- */
- public void layoutRemoved( LayoutRegistryEvent event ) throws
RemoteException
- {
- }
-
- //
------------------------------------------------------------------------
- // static
- //
------------------------------------------------------------------------
-
- private static final Layout MODERN_RESOLVER = new ModernLayout();
- private static final Layout CLASSIC_RESOLVER = new ClassicLayout();
- private static final Layout ECLIPSE_RESOLVER = new EclipseLayout();
-}
-

Deleted:
trunk/main/transit/core/src/main/net/dpml/transit/DefaultLayoutRegistryModel.java
===================================================================
---
trunk/main/transit/core/src/main/net/dpml/transit/DefaultLayoutRegistryModel.java
2007-02-08 23:53:26 UTC (rev 1845)
+++
trunk/main/transit/core/src/main/net/dpml/transit/DefaultLayoutRegistryModel.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -1,347 +0,0 @@
-/*
- * Copyright 2005 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.
- */
-
-package net.dpml.transit;
-
-import java.rmi.Remote;
-import java.rmi.RemoteException;
-import java.rmi.NoSuchObjectException;
-import java.rmi.server.UnicastRemoteObject;
-import java.util.List;
-import java.util.LinkedList;
-import java.util.EventObject;
-import java.util.EventListener;
-
-import net.dpml.transit.info.LayoutDirective;
-import net.dpml.transit.model.LayoutRegistryModel;
-import net.dpml.transit.model.LayoutModel;
-import net.dpml.transit.model.LayoutRegistryListener;
-import net.dpml.transit.model.LayoutRegistryEvent;
-
-import net.dpml.lang.UnknownKeyException;
-import net.dpml.lang.DuplicateKeyException;
-
-import net.dpml.util.Logger;
-import net.dpml.util.EventQueue;
-
-/**
- * Default implementation of a layout registry model that maitains
- * information about the set of available layout models.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-class DefaultLayoutRegistryModel extends DefaultModel
- implements LayoutRegistryModel
-{
- //
------------------------------------------------------------------------
- // state
- //
------------------------------------------------------------------------
-
- private final List m_list = new LinkedList();
-
- //
------------------------------------------------------------------------
- // constructor
- //
------------------------------------------------------------------------
-
- /**
- * Creation of a new layout registry model.
- * @param logger the assinged logging channel
- * @param layouts an array of custom layout configurations
- * @exception DuplicateKeyException if a duplicate layout is declared
- * @exception RemoteException if a remote exception occurs
- */
- public DefaultLayoutRegistryModel( EventQueue queue, Logger logger,
LayoutDirective[] layouts )
- throws DuplicateKeyException, RemoteException
- {
- super( queue, logger );
-
- // add the standard layouts
-
- LayoutModel modern =
- new StandardLayoutModel(
- queue, logger.getChildLogger( "modern" ),
- "modern", "Modern", ModernLayout.class.getName() );
- addLayoutModel( modern, false );
- LayoutModel classic =
- new StandardLayoutModel(
- queue, logger.getChildLogger( "classic" ),
- "classic", "Classic", ClassicLayout.class.getName() );
- addLayoutModel( classic, false );
- LayoutModel eclipse =
- new StandardLayoutModel(
- queue, logger.getChildLogger( "eclipse" ),
- "eclipse", "Eclipse", EclipseLayout.class.getName() );
- addLayoutModel( eclipse, false );
-
- // add the custom layouts
-
- for( int i=0; i < layouts.length; i++ )
- {
- LayoutDirective directive = layouts[i];
- addLayoutModel( directive, false );
- }
- }
-
- //
------------------------------------------------------------------------
- // Disposable
- //
------------------------------------------------------------------------
-
- /**
- * Disposal of the cache model.
- * @exception RemoteException if a remote exception occurs
- */
- public synchronized void dispose()
- {
- LayoutModel[] models = getLayoutModels();
- for( int i=0; i<models.length; i++ )
- {
- LayoutModel model = models[i];
- dispose( model );
- }
- super.dispose();
- }
-
- private void dispose( Object object )
- {
- if( object instanceof Disposable )
- {
- Disposable disposable = (Disposable) object;
- disposable.dispose();
- }
- if( object instanceof Remote )
- {
- try
- {
- Remote remote = (Remote) object;
- UnicastRemoteObject.unexportObject( remote, true );
- }
- catch( NoSuchObjectException e )
- {
- // ignore
- }
- catch( RemoteException re )
- {
- getLogger().warn( "Unexpected error during remote reference
removal.", re );
- }
- }
- }
-
- //
------------------------------------------------------------------------
- // LayoutRegistryModel
- //
------------------------------------------------------------------------
-
- /**
- * Add a layout registry change listener.
- * @param listener the registry change listener to add
- */
- public void addLayoutRegistryListener( LayoutRegistryListener listener )
- {
- super.addListener( listener );
- }
-
- /**
- * Remove a layout registry change listener.
- * @param listener the registry change listener to remove
- * @exception RemoteException if a remote exception occurs
- */
- public void removeLayoutRegistryListener( LayoutRegistryListener
listener )
- {
- super.removeListener( listener );
- }
-
- /**
- * Return an array of content managers currently assigned to the registry.
- * @return the content manager array
- * @exception RemoteException if a remote exception occurs
- */
- public LayoutModel[] getLayoutModels()
- {
- synchronized( getLock() )
- {
- return (LayoutModel[]) m_list.toArray( new LayoutModel[0] );
- }
- }
-
- /**
- * Return a layout resolver model matching the supplied id. If the id is
unknown
- * an implementation shall return a null value.
- *
- * @return the layout model
- */
- public LayoutModel getLayoutModel( String id ) throws UnknownKeyException
- {
- synchronized( getLock() )
- {
- if( null == id )
- {
- throw new NullPointerException( "id" );
- }
- LayoutModel[] managers = getLayoutModels();
- for( int i=0; i < managers.length; i++ )
- {
- LayoutModel manager = managers[i];
- try
- {
- if( id.equals( manager.getID() ) )
- {
- return manager;
- }
- }
- catch( RemoteException e )
- {
- throw new ModelRuntimeException( "remote-exception", e );
- }
- }
- throw new UnknownKeyException( id );
- }
- }
-
- //
------------------------------------------------------------------------
- // impl
- //
------------------------------------------------------------------------
-
- private void addLayoutModel( LayoutDirective directive, boolean notify )
- throws DuplicateKeyException
- {
- String id = directive.getID();
- Logger logger = getLogger().getChildLogger( id );
- try
- {
- EventQueue queue = getEventQueue();
- LayoutModel model = new DefaultLayoutModel( queue, logger,
directive );
- addLayoutModel( model, notify );
- }
- catch( RemoteException e )
- {
- throw new ModelRuntimeException( "remote-exception", e );
- }
- }
-
- private void addLayoutModel( LayoutModel manager, boolean notify )
- throws DuplicateKeyException
- {
- synchronized( getLock() )
- {
- try
- {
- String id = manager.getID();
- LayoutModel m = getLayoutModel( id );
- throw new DuplicateKeyException( id );
- }
- catch( UnknownKeyException e )
- {
- m_list.add( manager );
- if( notify )
- {
- LayoutAddedEvent event = new LayoutAddedEvent( this,
manager );
- enqueueEvent( event );
- }
- }
- catch( RemoteException e )
- {
- throw new ModelRuntimeException( "remote-exception", e );
- }
- }
- }
-
- /**
- * Internal event handler.
- * @param event the event to handle
- */
- public void processEvent( EventObject event )
- {
- if( event instanceof LayoutRegistryEvent )
- {
- processLayoutRegistryEvent( (LayoutRegistryEvent) event );
- }
- }
-
- private void processLayoutRegistryEvent( LayoutRegistryEvent event )
- {
- EventListener[] listeners = super.getEventListeners();
- for( int i=0; i < listeners.length; i++ )
- {
- EventListener listener = listeners[i];
- if( listener instanceof LayoutRegistryListener )
- {
- LayoutRegistryListener rl = (LayoutRegistryListener)
listener;
- if( event instanceof LayoutAddedEvent )
- {
- try
- {
- rl.layoutAdded( event );
- }
- catch( Throwable e )
- {
- final String error =
- "LayoutRegistryListener locator addition
notification error.";
- getLogger().error( error, e );
- }
- }
- else if( event instanceof LayoutRemovedEvent )
- {
- try
- {
- rl.layoutRemoved( event );
- }
- catch( Throwable e )
- {
- final String error =
- "LayoutRegistryListener locator removed
notification error.";
- getLogger().error( error, e );
- }
- }
- }
- }
- }
-
- /**
- * Layout addition event.
- */
- static class LayoutAddedEvent extends LayoutRegistryEvent
- {
- /**
- * Creation of a new layout model addition event.
- * @param source the layout registry
- * @param handler the layout model that was added
- */
- public LayoutAddedEvent( LayoutRegistryModel source, LayoutModel
handler )
- {
- super( source, handler );
- }
- }
-
- /**
- * Layout removal event.
- */
- static class LayoutRemovedEvent extends LayoutRegistryEvent
- {
- /**
- * Creation of a new layout model removal event.
- * @param source the layout registry
- * @param handler the layout model that was removed
- */
- public LayoutRemovedEvent( LayoutRegistryModel source, LayoutModel
handler )
- {
- super( source, handler );
- }
- }
-}
-
-

Deleted: trunk/main/transit/core/src/main/net/dpml/transit/DefaultModel.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/DefaultModel.java
2007-02-08 23:53:26 UTC (rev 1845)
+++ trunk/main/transit/core/src/main/net/dpml/transit/DefaultModel.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -1,139 +0,0 @@
-/*
- * Copyright 2005 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.
- */
-
-package net.dpml.transit;
-
-import java.rmi.RemoteException;
-import java.util.EventObject;
-import java.util.EventListener;
-import java.util.Map;
-import java.util.WeakHashMap;
-
-import net.dpml.transit.monitor.LoggingAdapter;
-
-import net.dpml.util.Logger;
-import net.dpml.util.UnicastEventSource;
-import net.dpml.util.EventQueue;
-
-/**
- * A abstract base class that established an event queue and handles event
dispatch
- * operations for listeners declared in classes extending this base class.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public abstract class DefaultModel extends UnicastEventSource implements
Disposable
-{
- //
------------------------------------------------------------------------
- // state
- //
------------------------------------------------------------------------
-
- private Map m_listeners = new WeakHashMap();
-
- //
------------------------------------------------------------------------
- // constructor
- //
------------------------------------------------------------------------
-
- /**
- * Creation of a new model.
- * @param queue the event queue
- * @param name the name used to construct a logging channel
- * @exception RemoteException if a remote exception occurs
- */
- public DefaultModel( EventQueue queue, String name )
- throws RemoteException
- {
- this( queue, getLoggerForCategory( name ) );
- }
-
- /**
- * Creation of a new model.
- * @param queue the event queue
- * @param logger the assigned logging channel
- * @exception NullPointerException if the supplied logging channel is null
- * @exception RemoteException if a remote exception occurs
- */
- public DefaultModel( EventQueue queue, Logger logger )
- throws NullPointerException, RemoteException
- {
- super( queue, logger );
- }
-
- //
------------------------------------------------------------------------
- // DefaultModel
- //
------------------------------------------------------------------------
-
- /**
- * Return the assigned logging channel.
- * @return the logging channel
- */
- protected Logger getLogger()
- {
- return super.getLocalLogger();
- }
-
- /**
- * Dispose of the model.
- */
- public synchronized void dispose()
- {
- EventListener[] listeners = getEventListeners();
- for( int i=0; i < listeners.length; i++ )
- {
- EventListener listener = listeners[i];
- removeListener( listener );
- }
- super.terminate();
- getLogger().debug( "disposed" );
- }
-
- /**
- * Enqueue an event for delivery to registered
- * listeners unless there are no registered
- * listeners.
- *
- * @param event the event object to add to the queue
- * @param waitForCompletion if TRUE the implementation will apply
- * the event to the event source event handler and return on
- * copmpletion of evetn delivery
- */
- protected void enqueueEvent( EventObject event, boolean
waitForCompletion )
- {
- if( m_listeners.size() > 0 )
- {
- getEventQueue().enqueueEvent( event, waitForCompletion );
- }
- }
-
- /**
- * Return a logging channel for the supplied name.
- * @param name the name to use in construction of the logging channel
- * @return the logging channel
- */
- static Logger getLoggerForCategory( String name )
- {
- if( null == name )
- {
- return new LoggingAdapter( "" );
- }
- else
- {
- return new LoggingAdapter( name );
- }
- }
-}

Deleted:
trunk/main/transit/core/src/main/net/dpml/transit/DefaultProxyModel.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/DefaultProxyModel.java
2007-02-08 23:53:26 UTC (rev 1845)
+++ trunk/main/transit/core/src/main/net/dpml/transit/DefaultProxyModel.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -1,222 +0,0 @@
-/*
- * Copyright 2005 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.
- */
-
-package net.dpml.transit;
-
-import java.rmi.RemoteException;
-import java.util.EventObject;
-import java.util.EventListener;
-import java.net.MalformedURLException;
-import java.net.PasswordAuthentication;
-import java.net.URL;
-
-import net.dpml.transit.info.ProxyDirective;
-import net.dpml.transit.model.ProxyModel;
-import net.dpml.transit.model.ProxyListener;
-import net.dpml.transit.model.ProxyEvent;
-import net.dpml.transit.model.RequestIdentifier;
-
-import net.dpml.util.EventQueue;
-import net.dpml.util.Logger;
-
-/**
- * The ProxyModel class maintains an active configuration model of the
- * Transit proxy configuration.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-class DefaultProxyModel extends DefaultModel implements ProxyModel
-{
- //
------------------------------------------------------------------------
- // state
- //
------------------------------------------------------------------------
-
- private URL m_host;
- private PasswordAuthentication m_authentication;
- private String[] m_excludes;
-
- //
------------------------------------------------------------------------
- // constructor
- //
------------------------------------------------------------------------
-
- /**
- * Construction of a new proxy model.
- * @param logger the assigned logging channel
- * @param directive the proxy congfiguration
- * @exception NullPointerException if the logging channel or directive
arguments are null
- * @exception RemoteException if a remote exception occurs
- */
- public DefaultProxyModel( EventQueue queue, Logger logger,
ProxyDirective directive )
- throws NullPointerException, MalformedURLException, RemoteException
- {
- super( queue, logger );
-
- if( null == directive )
- {
- throw new NullPointerException( "directive" );
- }
-
- m_host = new URL( directive.getHost() );
- String username = directive.getUsername();
- if( null != username )
- {
- m_authentication =
- new PasswordAuthentication( username, directive.getPassword()
);
- }
- else
- {
- m_authentication = NULL_AUTHENTICATION;
- }
- m_excludes = directive.getExcludes();
- }
-
- //
------------------------------------------------------------------------
- // ProxyModel
- //
------------------------------------------------------------------------
-
- /**
- * Return the proxy host name.
- * @return the proxy host (possibly null)
- */
- public URL getHost()
- {
- return m_host;
- }
-
- /**
- * Return the proxy authentication or null if not defined.
- * @return the proxy authentication credentials
- */
- public PasswordAuthentication getAuthentication()
- {
- return m_authentication;
- }
-
- /**
- * Return the proxy host request identifier.
- * @return the request identifier for the proxy host or null if not
defined.
- */
- public RequestIdentifier getRequestIdentifier()
- {
- return getRequestIdentifier( m_host );
- }
-
- /**
- * Return the set of excluded hosts as an array.
- * @return the excluded host array
- */
- public String[] getExcludes()
- {
- return m_excludes;
- }
-
- /**
- * Add a proxy listener to the model.
- * @param listener the listener to add
- */
- public void addProxyListener( ProxyListener listener )
- {
- super.addListener( listener );
- }
-
- /**
- * Remove a proxy listener from the model.
- * @param listener the listener to remove
- */
- public void removeProxyListener( ProxyListener listener )
- {
- super.removeListener( listener );
- }
-
- //
------------------------------------------------------------------------
- // internal
- //
------------------------------------------------------------------------
-
- public void dispose()
- {
- EventListener[] listeners = super.getEventListeners();
- for( int i=0; i<listeners.length; i++ )
- {
- EventListener listener = listeners[i];
- removeListener( listener );
- }
- }
-
- /**
- * Internal event handler.
- * @param eventObject the event to handle
- */
- public void processEvent( EventObject eventObject )
- {
- if( eventObject instanceof ProxyEvent )
- {
- ProxyEvent event = (ProxyEvent) eventObject;
- processProxyEvent( event );
- }
- else
- {
- final String error =
- "Event class not recognized: " +
eventObject.getClass().getName();
- throw new IllegalArgumentException( error );
- }
- }
-
- private void processProxyEvent( ProxyEvent event )
- {
- EventListener[] listeners = super.getEventListeners();
- for( int i=0; i < listeners.length; i++ )
- {
- EventListener listener = listeners[i];
- if( listener instanceof ProxyListener )
- {
- ProxyListener pl = (ProxyListener) listener;
- try
- {
- pl.proxyChanged( event );
- }
- catch( Throwable e )
- {
- final String error =
- "Proxy listener notification error.";
- getLogger().error( error, e );
- }
- }
- }
- }
-
- private static final PasswordAuthentication NULL_AUTHENTICATION =
- new PasswordAuthentication( "", new char[0] );
-
- private static RequestIdentifier getRequestIdentifier( URL url )
- {
- if( null == url )
- {
- return null;
- }
- else
- {
- String protocol = url.getProtocol();
- String scheme = "";
- String prompt = "";
- int port = url.getPort();
- String host = url.getHost();
- return new RequestIdentifier( host, port, protocol, scheme,
prompt );
- }
- }
-}

Deleted:
trunk/main/transit/core/src/main/net/dpml/transit/DefaultResourceHost.java
===================================================================
---
trunk/main/transit/core/src/main/net/dpml/transit/DefaultResourceHost.java
2007-02-08 23:53:26 UTC (rev 1845)
+++
trunk/main/transit/core/src/main/net/dpml/transit/DefaultResourceHost.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -1,684 +0,0 @@
-/*
- * Copyright 2004 Niclas Hedhman.
- * Copyright 2005 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.
- */
-
-package net.dpml.transit;
-
-import javax.net.ssl.HttpsURLConnection;
-import javax.net.ssl.SSLContext;
-import javax.net.ssl.SSLSocketFactory;
-import javax.net.ssl.TrustManager;
-import javax.net.ssl.X509TrustManager;
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.PrintWriter;
-import java.net.HttpURLConnection;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.net.UnknownHostException;
-import java.net.PasswordAuthentication;
-import java.security.KeyManagementException;
-import java.security.NoSuchAlgorithmException;
-import java.security.cert.X509Certificate;
-import java.rmi.RemoteException;
-import java.rmi.server.UnicastRemoteObject;
-import java.util.Date;
-import java.util.HashMap;
-import java.util.HashSet;
-
-import net.dpml.transit.model.HostModel;
-import net.dpml.transit.model.RequestIdentifier;
-import net.dpml.transit.model.HostListener;
-import net.dpml.transit.model.HostNameEvent;
-import net.dpml.transit.model.HostChangeEvent;
-import net.dpml.transit.model.HostPriorityEvent;
-import net.dpml.transit.model.HostLayoutEvent;
-import net.dpml.util.Util;
-
-import net.dpml.lang.UnknownKeyException;
-import net.dpml.util.Logger;
-
-/**
- * This class represents a single host where resources are stored at.
- * <p>
- * <strong>NOTE:</strong> This ResourceHost does NOT currently support
- * realm/domain authentication. It may be introduced in the future.
- * </p>
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-class DefaultResourceHost extends UnicastRemoteObject
- implements ResourceHost, HostListener, Disposable
-{
- //
------------------------------------------------------------------------
- // state
- //
------------------------------------------------------------------------
-
- /**
- * Known groups.
- */
- private HashSet m_knownGroups = new HashSet();
-
- /**
- * The key is the Artifact one wants to lock against, and the value is an
- * anonymously lock object.
- */
- private HashMap m_locks = new HashMap();
-
- /**
- * Connections.
- */
- private ConnectionCache m_connections;
-
- private LayoutRegistry m_registry;
-
- private Layout m_layout;
-
- private HostModel m_model;
-
- private Logger m_logger;
-
- private int m_priority;
-
- private URL m_base;
-
- private boolean m_enabled;
- private boolean m_trusted;
-
- //
------------------------------------------------------------------------
- // constructor
- //
------------------------------------------------------------------------
-
- /**
- * Constructor for a resource host using a supplied host configuration.
- *
- * @param model the host model
- * @param registry the host layout registry
- * @exception UnknownHostException if the supplied base url references
an unknown host
- */
- public DefaultResourceHost( HostModel model, LayoutRegistry registry,
Logger logger )
- throws UnknownHostException, UnknownKeyException, IOException
- {
- super();
-
- m_model = model;
- m_priority = model.getPriority();
- m_base = model.getBaseURL();
- m_trusted = model.getTrusted();
- m_enabled = model.getEnabled();
- m_registry = registry;
- m_logger = logger;
- m_layout = registry.getLayout( model.getLayoutModel().getID() );
- model.addHostListener( this );
- m_connections = ConnectionCache.getInstance();
- String[] groups = setupGroups();
- resetGroups( groups );
- setupAuthenticator();
- }
-
- //
------------------------------------------------------------------------
- // Disposable
- //
------------------------------------------------------------------------
-
- /**
- * Dispose of the manager. During disposal a manager is required to
- * release all references such as listeners and internal resources
- * in preparation for garbage collection.
- */
- public void dispose()
- {
- try
- {
- m_model.removeHostListener( this );
- }
- catch( RemoteException e )
- {
- final String error =
- "Unexpected remote exception while disposing of resource
host.";
- m_logger.error( error, e );
- }
- }
-
- //
------------------------------------------------------------------------
- // HostListener
- //
------------------------------------------------------------------------
-
- /**
- * Notify a consumer of an aggregated set of changes.
- * @param event the host change event
- */
- public void hostChanged( HostChangeEvent event ) throws RemoteException
- {
- synchronized( this )
- {
- if( getLogger().isDebugEnabled() )
- {
- getLogger().debug( "updating runtime" );
- }
- try
- {
- m_base = event.getBaseURL();
- m_enabled = event.getEnabled();
- m_trusted = event.getTrusted();
- setupAuthenticator();
- String[] groups = setupGroups();
- resetGroups( groups );
- }
- catch( Exception e )
- {
- final String error =
- "Could not complete host update due to a internal error.";
- getLogger().error( error, e );
- }
- }
- }
-
- /**
- * Notify a consumer of a change to the enabled state.
- * @param event the host event
- */
- public void nameChanged( HostNameEvent event ) throws RemoteException
- {
- // not used by the runtime
- }
-
- /**
- * Notify a consumer of a change to the host priority.
- * @param event the host event
- */
- public void priorityChanged( HostPriorityEvent event ) throws
RemoteException
- {
- if( getLogger().isDebugEnabled() )
- {
- getLogger().debug( "setting priority to " + event.getPriority()
);
- }
- int priority = event.getPriority();
- m_priority = priority;
- }
-
- /**
- * Notify a consumer of a change to the assigned resolver.
- * @param event the resolver id change event
- */
- public void layoutChanged( HostLayoutEvent event ) throws RemoteException
- {
- synchronized( m_layout )
- {
- try
- {
- final String id = event.getLayoutModel().getID();
- if( getLogger().isDebugEnabled() )
- {
- getLogger().debug( "setting layout to " + id );
- }
- m_layout = m_registry.getLayout( id );
- }
- catch( Exception e )
- {
- final String error =
- "Layout change could not be completed.";
- getLogger().error( error, e );
- }
- }
- }
-
- //
------------------------------------------------------------------------
- // ResourceHost
- //
------------------------------------------------------------------------
-
- /**
- * Return the host name.
- * @return the hostname
- */
- public String getHostName()
- {
- return m_base.getHost();
- }
-
- /**
- * Returns the full host url.
- *
- * @return the host url
- */
- public URL getURL()
- {
- return m_base;
- }
-
- /**
- * Return the host priority.
- * @return the priority
- */
- public int getPriority()
- {
- return m_priority;
- }
-
- /**
- * Downloads a given artifact.
- * @param artifact the artifact that is requested to be downloaded.
- * @param dest the destination output stream into which download content
is to be written
- * @exception IOException if an IO related error occurs
- */
- public Date download( Artifact artifact, OutputStream dest )
- throws IOException
- {
- Object lock = obtainLock( artifact );
- synchronized ( lock )
- {
- NetworkLoader loader = new NetworkLoader();
- URL url = createRemoteUrl( artifact );
- URLConnection connection;
- synchronized ( m_connections )
- {
- connection = m_connections.get( artifact );
- if( connection == null )
- {
- // Not in cache. Why not? ---> Garbage Collection has
occurred.
- String message = this + " - Info: Connection no longer
in cache. Reconnecting.";
- Transit.getInstance().getLogWriter().println( message );
- URL remote = createRemoteUrl( artifact );
- connection = remote.openConnection();
- connection.connect();
- }
- }
-
- return loader.loadResource( url, connection, dest );
- }
- }
-
- /** Uploads the given file to the resource host as an artifact.
- *
- * @param artifact the artifact destination specification.
- * @param source The input stream from where to read the content to be
uploaded.
- * @exception IOException if an IO related error occurs
- */
- public void upload( Artifact artifact, InputStream source )
- throws IOException
- {
- // TODO: implement upload through HTTP POST requests.
- }
-
- /** Checks if the Artifact is present on the resource host.
- *
- * <p>
- * Performs a check to see if the artifact exists on the resource
host. If
- * <i>knownOnly</i> is set to true, then the implementation will only
- * consult the knownGroups table, and if found there, it is considered
- * found without checking at the resource host itself. If
<i>knownOnly</i>
- * is false, however, a connection will be established to the resource
- * host and a check of the actual resource existence.
- * </p>
- *
- * @param artifact the artifact for which the method checks its presence.
- * @param knownOnly does not perform a remote connection, and instead
lookup
- * the group table, and if not found there it will return false.
- *
- * @return true if the artifact can be located, false otherwise.
- */
- public boolean checkPresence( Artifact artifact, boolean knownOnly )
- {
- if( "file".equals( getURL().getProtocol() ) )
- {
- return checkAtServer( artifact );
- }
- else if( knownOnly )
- {
- return checkKnown( artifact );
- }
- else
- {
- return checkAtServer( artifact );
- }
- }
-
- /**
- * Return true if the reosurce host is enabled and online.
- *
- * @return true if the reosurce host is enabled and online.
- */
- public boolean isEnabled()
- {
- return m_enabled;
- }
-
- /** Returns true if the ResourceHost is considered trusted.
- *
- * @return true if the ResourceHost is considered trusted.
- */
- public boolean isTrusted()
- {
- return m_trusted;
- }
-
- /** Returns the layout assigned to the host.
- *
- * @return the layout model
- */
- public Layout getLayout()
- {
- return m_layout;
- }
-
- //
------------------------------------------------------------------------
- // implementation
- //
------------------------------------------------------------------------
-
- private String[] setupGroups() throws IOException
- {
- URL index = m_model.getIndexURL();
- if( null != index )
- {
- return getKnownGroups( index );
- }
- else
- {
- return new String[0];
- }
- }
-
- private void resetGroups( String[] groups )
- {
- synchronized( m_knownGroups )
- {
- m_knownGroups.clear();
- for( int i=0; i < groups.length; i++ )
- {
- String group = groups[i];
- m_knownGroups.add( group );
- }
- }
- }
-
- private void setupAuthenticator() throws RemoteException
- {
- RequestIdentifier id = m_model.getRequestIdentifier();
- PasswordAuthentication auth = m_model.getAuthentication();
- TransitAuthenticator ta = new TransitAuthenticatorImpl( auth );
- DelegatingAuthenticator da = DelegatingAuthenticator.getInstance();
- da.addTransitAuthenticator( ta, id );
- }
-
- /**
- * Check if the supplied artifact group is known.
- * @param artifact the subject artifact to check
- * @return TRUE if known else FALSE
- */
- private boolean checkKnown( Artifact artifact )
- {
- String group = artifact.getGroup();
- return m_knownGroups.contains( group );
- }
-
- /**
- * Ckeck if the server conection is available.
- * @param artifact the subject artifact
- * @return TRUE if a connection is available
- */
- private boolean checkAtServer( Artifact artifact )
- {
- try
- {
- URL remote = createRemoteUrl( artifact );
- String protocol = remote.getProtocol();
- if( protocol.startsWith( "file" ) )
- {
- String path = remote.getPath();
- File f = new File( path );
- return f.exists();
- }
- else
- {
- return openRemoteConnection( artifact );
- }
- }
- catch( IOException e )
- {
- return false;
- }
- catch( NoSuchAlgorithmException e )
- {
- return false;
- }
- catch( KeyManagementException e )
- {
- return false;
- }
- catch( RuntimeException e )
- {
- return false;
- }
- }
-
- /**
- * Obtain a lock on the supplied artifact.
- * @param artifact the artifact to obtain a lock on
- * @return the lock
- */
- private Object obtainLock( Artifact artifact )
- {
- synchronized ( this )
- {
- Object lock = m_locks.get( artifact );
- if( lock == null )
- {
- lock = new Object();
- m_locks.put( artifact, lock );
- }
- return lock;
- }
- }
-
- /**
- * Open a remote connection relative to a supplied artifact.
- * @param artifact the artifact against which a connection will be
established
- * @exception IOException if an IO error occurs
- * @exception KeyManagementException if a key management error occurs
- * @exception NoSuchAlgorithmException if no such algorithm exists?
- * @return true if the atrifact was found and could be opened, false if
not
- * available at this resource host.
- */
- private boolean openRemoteConnection( Artifact artifact )
- throws IOException, KeyManagementException, NoSuchAlgorithmException
- {
- PrintWriter log = Transit.getInstance().getLogWriter();
- log.println( this + " - opening connection: " + artifact );
- URL remote = createRemoteUrl( artifact );
- URLConnection conn = remote.openConnection();
- if( conn instanceof HttpsURLConnection )
- {
- log.println( this + " - HTTPS connection opened." );
- if( isTrusted() )
- {
- log.println( this + " - Using NullTrustManager." );
- HttpsURLConnection ssl = (HttpsURLConnection) conn;
- TrustManager nullTrustManager = new NullTrustManager();
- SSLContext ctx = SSLContext.getInstance( "SSLv3" );
- ctx.init( null, new TrustManager[]{nullTrustManager}, null );
- log.println( this + " - Setting SSLv3 socket factory." );
- SSLSocketFactory factory = ctx.getSocketFactory();
- ssl.setSSLSocketFactory( factory );
- }
- }
- conn.connect();
- if( conn instanceof HttpURLConnection )
- {
- int code = ( (HttpURLConnection) conn ).getResponseCode();
- log.println( this + " - ResponseCode: " + code );
- if( code == HttpURLConnection.HTTP_UNAUTHORIZED )
- {
- throw new IOException( "Unauthorized request." );
- }
- else if( code == HttpURLConnection.HTTP_NOT_FOUND )
- {
- return false;
- }
- else if( code != HttpURLConnection.HTTP_OK )
- {
- throw new IOException( "Unexpected Result: " + code );
- }
- }
- synchronized ( m_connections )
- {
- log.println( this + " - caching connection: " + conn );
- m_connections.put( artifact, conn );
- }
- return true;
- }
-
- /**
- * Create a remote urtl from an artifact.
- *
- * @param artifact the subject artifact
- * @return the remote url connection
- * @exception MalformedURLException if the artifact path is not
resolvable to a url
- */
- private URL createRemoteUrl( Artifact artifact )
- throws MalformedURLException
- {
- String path = m_layout.resolvePath( artifact );
- URL base = getURL();
- URL url = new URL( base, path );
- return url;
- }
-
- /**
- * Return a string representation of this host.
- * @return the representation
- */
- public String toString()
- {
- return "[HOST: " + getURL() + "]";
- }
-
- private Logger getLogger()
- {
- return m_logger;
- }
-
- //
------------------------------------------------------------------------
- // static (utils)
- //
------------------------------------------------------------------------
-
- /**
- * A null trust manager that will accept any certificate. I.e. this
- * class performs NO TRUST MANAGEMENT and simply serves as a mechanism
- * through which https connections can be established with the same notion
- * of trust as a http connection (i.e. none).
- */
- private static final class NullTrustManager
- implements X509TrustManager
- {
- /**
- * Empty certificate sequence.
- */
- private static final X509Certificate[] EMPTY_CERTS = new
X509Certificate[0];
-
- /**
- * Null implementation.
- * @param certs the supplied certs (ignored)
- * @param authType the supplied type (ignored)
- */
- public void checkServerTrusted( final X509Certificate[] certs, final
String authType )
- {
- PrintWriter log = Transit.getInstance().getLogWriter();
- log.println( "NullTrustManager: authType=" + authType );
- log.println( "Server Certificates" );
- log.println( "-------------------" );
- for( int i=0; i < certs.length; i++ )
- {
- log.println( " " + certs[ i ] );
- }
- }
-
- /**
- * Null implementation.
- * @param certs the supplied certs (ignored)
- * @param authType the supplied type (ignored)
- */
- public void checkClientTrusted( final X509Certificate[] certs, final
String authType )
- {
- PrintWriter log = Transit.getInstance().getLogWriter();
- log.println( "NullTrustManager: authType=" + authType );
- log.println( "Client Certificates" );
- log.println( "-------------------" );
- for( int i=0; i < certs.length; i++ )
- {
- log.println( " " + certs[ i ] );
- }
- }
-
- /**
- * Null implementation.
- * @return an empty certificate array
- */
- public X509Certificate[] getAcceptedIssuers()
- {
- return EMPTY_CERTS;
- }
- }
-
- /**
- * Return a set of known groups froma host.
- * @param href the host against which the request is to be made
- * @return the set of known group names
- * @exception TransitException if an error occurs while attempting to
read the
- * remote address
- */
- private static String[] getKnownGroups( URL href ) throws
TransitException
- {
- if( href != null )
- {
- try
- {
- return Util.readListFile( href );
- }
- catch( Exception e )
- {
- final String error =
- "Unable to extract the groups from "
- + href;
- throw new TransitException( error, e );
- }
- }
- else
- {
- return new String[0];
- }
- }
-
- /**
- * HTTP port number.
- */
- private static final int HTTP_PORT = 80;
-
- /**
- * FTP port number.
- */
- private static final int FTP_PORT = 21;
-
- /**
- * HTTPS port number.
- */
- private static final int HTTPS_PORT = 443;
-
-}

Deleted:
trunk/main/transit/core/src/main/net/dpml/transit/DefaultTransitModel.java
===================================================================
---
trunk/main/transit/core/src/main/net/dpml/transit/DefaultTransitModel.java
2007-02-08 23:53:26 UTC (rev 1845)
+++
trunk/main/transit/core/src/main/net/dpml/transit/DefaultTransitModel.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -1,465 +0,0 @@
-/*
- * Copyright 2005 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.
- */
-
-package net.dpml.transit;
-
-import java.io.File;
-import java.net.URL;
-import java.net.URI;
-import java.rmi.RemoteException;
-import java.rmi.NoSuchObjectException;
-import java.rmi.server.UnicastRemoteObject;
-import java.util.EventObject;
-import java.util.EventListener;
-
-import net.dpml.transit.info.CacheDirective;
-import net.dpml.transit.info.ProxyDirective;
-import net.dpml.transit.info.TransitDirective;
-import net.dpml.transit.model.CacheModel;
-import net.dpml.transit.model.ProxyModel;
-import net.dpml.transit.model.TransitModel;
-import net.dpml.transit.model.DisposalEvent;
-import net.dpml.transit.model.DisposalListener;
-import net.dpml.transit.monitor.LoggingAdapter;
-
-import net.dpml.util.EventQueue;
-import net.dpml.util.Logger;
-
-/**
- * The DefaultTransitModel class maintains an active configuration of the
- * Transit system.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public class DefaultTransitModel extends DefaultModel implements TransitModel
-{
- //
------------------------------------------------------------------------
- // static
- //
------------------------------------------------------------------------
-
- /**
- * Default configuration url path.
- */
- public static final String DEFAULT_PROFILE_PATH =
"local:xml:dpml/transit/standard";
-
- /**
- * Default configuration url path.
- */
- public static final URI DEFAULT_PROFILE_URI = createStaticURI(
DEFAULT_PROFILE_PATH );
-
- /**
- * System property key used to hold an overriding configuration url.
- */
- public static final String PROFILE_KEY = "dpml.transit.profile";
-
- /**
- * Return a model that is restricted to the secure local environment with
- * no proxy setting or external hosts.
- * @param logger the logging channel to assign to the model
- * @return the transit model
- */
- public static DefaultTransitModel getSecureModel( Logger logger )
- {
- try
- {
- TransitDirective directive = new TransitDirective( null, new
CacheDirective() );
- if( logger.isTraceEnabled() )
- {
- ClassLoader system = ClassLoader.getSystemClassLoader();
- int id = System.identityHashCode( system );
- logger.trace( "system classloader id: " + id );
- }
- EventQueue queue = new EventQueue( logger, "DPML Transit Event
Queue" );
- return new DefaultTransitModel( queue, logger, directive );
- }
- catch( Exception e )
- {
- final String error =
- "Unexpected error while constructing static secure model.";
- throw new RuntimeException( error, e );
- }
- }
-
- /**
- * Resolve the transit configuration using the default resource path
- * <tt>local:xml:dpml/transit/config</tt>. If the resource does not exist
a classic
- * default scenario will be returned.
- *
- * @return the transit model
- * @exception Exception if an error occurs during model construction
- */
- public static DefaultTransitModel getDefaultModel() throws Exception
- {
- return getDefaultModel( "transit" );
- }
-
- /**
- * Resolve the transit configuration using the default resource path
- * <tt>local:xml:dpml/transit/config</tt>. If the resource does not exist
a classic
- * default scenario will be returned.
- *
- * @param category the logging channel category name
- * @return the transit model
- * @exception Exception if an error occurs during model construction
- */
- public static DefaultTransitModel getDefaultModel( String category )
throws Exception
- {
- LoggingAdapter adapter = new LoggingAdapter( category );
- return getDefaultModel( adapter );
- }
-
- /**
- * Resolve the transit configuration using the default resource path
- * <tt>local:xml:dpml/transit/config</tt>. If the resource does not exist
a classic
- * default scenario will be returned.
- *
- * @param logger the logging channel
- * @return the transit model
- * @exception Exception if an error occurs during model construction
- */
- public static DefaultTransitModel getDefaultModel( Logger logger )
throws Exception
- {
- String path = System.getProperty( PROFILE_KEY );
- if( logger.isTraceEnabled() )
- {
- ClassLoader system = ClassLoader.getSystemClassLoader();
- int id = System.identityHashCode( system );
- logger.trace( "system classloader id: " + id );
- }
- if( null != path )
- {
- URI uri = Artifact.createArtifact( path ).toURI();
- URL url = uri.toURL();
- TransitBuilder builder = new TransitBuilder( logger );
- TransitDirective directive = builder.load( url );
- return new DefaultTransitModel( logger, directive );
- }
- else
- {
- File prefs = Transit.DPML_PREFS;
- File config = new File( prefs, "dpml/transit/xmls/standard.xml"
);
- if( config.exists() )
- {
- URI uri = config.toURI();
- URL url = uri.toURL();
- TransitBuilder builder = new TransitBuilder( logger );
- TransitDirective directive = builder.load( url );
- return new DefaultTransitModel( logger, directive );
- }
- else
- {
- return getClassicModel( logger );
- }
- }
- }
-
- //
------------------------------------------------------------------------
- // state
- //
------------------------------------------------------------------------
-
- private final DefaultProxyModel m_proxy;
- private final DefaultCacheModel m_cache;
-
- //
------------------------------------------------------------------------
- // constructor
- //
------------------------------------------------------------------------
-
- /**
- * Creation of a new TransitModel using a supplied configuration
- * and logging channel. The implementation will construct a proxy
- * model, layout registry model, cache model, and repository codebase
- * model using the supplied configuration.
- *
- * @param logger the assigned loging channel
- * @param directive the transit configuration
- * @exception NullPointerException if the logger or directive arguments
are null
- * @exception RemoteException if a remote exception occurs
- */
- public DefaultTransitModel( Logger logger, TransitDirective directive )
- throws RemoteException, NullPointerException
- {
- this(
- new EventQueue( logger, "DPML Transit Event Queue" ),
- logger, directive );
- }
-
- /**
- * Creation of a new TransitModel using a supplied configuration
- * and logging channel. The implementation will construct a proxy
- * model, layout registry model, cache model, and repository codebase
- * model using the supplied configuration.
- *
- * @param queue the event queue
- * @param logger the assigned logging channel
- * @param directive the transit configuration
- * @exception NullPointerException if the logger or directive arguments
are null
- * @exception RemoteException if a remote exception occurs
- */
- public DefaultTransitModel( EventQueue queue, Logger logger,
TransitDirective directive )
- throws RemoteException, NullPointerException
- {
- super( queue, logger );
-
- if( null == directive )
- {
- throw new NullPointerException( "directive" );
- }
-
- m_proxy = createProxyModel( queue, directive );
- m_cache = createCacheModel( queue, directive );
- }
-
- //
------------------------------------------------------------------------
- // TransitModel
- //
------------------------------------------------------------------------
-
- /**
- * Return the proxy configuration model.
- * @return the proxy model (null if no proxy config defined).
- */
- public ProxyModel getProxyModel()
- {
- return m_proxy;
- }
-
- /**
- * Return the cache model.
- * @return the cache model
- */
- public CacheModel getCacheModel()
- {
- return m_cache;
- }
-
- /**
- * Add a disposal listener to the model.
- * @param listener the listener to add
- */
- public void addDisposalListener( DisposalListener listener )
- {
- super.addListener( listener );
- }
-
- /**
- * Remove a disposal listener from the model.
- * @param listener the listener to remove
- */
- public void removeDisposalListener( DisposalListener listener )
- {
- super.removeListener( listener );
- }
-
- /**
- * Internal event handler.
- * @param eventObject the event to handle
- */
- public void processEvent( EventObject eventObject )
- {
- if( eventObject instanceof DisposalEvent )
- {
- DisposalEvent event = (DisposalEvent) eventObject;
- processDisposalEvent( event );
- }
- }
-
- private void processDisposalEvent( DisposalEvent event )
- {
- EventListener[] listeners = super.getEventListeners();
- for( int i=0; i < listeners.length; i++ )
- {
- EventListener listener = listeners[i];
- if( listener instanceof DisposalListener )
- {
- DisposalListener pl = (DisposalListener) listener;
- try
- {
- pl.notifyDisposal( event );
- }
- catch( Throwable e )
- {
- final String error =
- "Disposal notification error.";
- getLogger().error( error, e );
- }
- }
- }
- }
-
- //
------------------------------------------------------------------------
- // impl
- //
------------------------------------------------------------------------
-
- Logger getLoggingChannel()
- {
- return getLogger();
- }
-
- /**
- * Trigger disposal of the transit model.
- */
- public synchronized void dispose()
- {
- DisposalEvent event = new DisposalEvent( this );
- enqueueEvent( event, true );
- disposeCacheModel();
- disposeProxyModel();
- super.dispose();
- getEventQueue().terminateDispatchThread();
- Thread thread = new Terminator( this );
- thread.start();
- }
-
- /**
- * Internal model terminator.
- */
- private class Terminator extends Thread
- {
- private final DefaultTransitModel m_model;
- Terminator( DefaultTransitModel model )
- {
- m_model = model;
- }
-
- /**
- * Initiate model retraction from the RMI.
- */
- public void run()
- {
- try
- {
- UnicastRemoteObject.unexportObject( m_model, true );
- }
- catch( NoSuchObjectException e )
- {
- // ignore
- }
- catch( RemoteException e )
- {
- e.printStackTrace();
- }
- }
- }
-
- private synchronized void disposeProxyModel()
- {
- if( null == m_proxy )
- {
- return;
- }
- else
- {
- m_proxy.dispose();
- try
- {
- UnicastRemoteObject.unexportObject( m_proxy, true );
- }
- catch( NoSuchObjectException e )
- {
- // ignore
- }
- catch( RemoteException e )
- {
- getLogger().warn( "Remote error during proxy reference
removal.", e );
- }
- }
- }
-
- private synchronized void disposeCacheModel()
- {
- m_cache.dispose();
- try
- {
- UnicastRemoteObject.unexportObject( m_cache, true );
- }
- catch( NoSuchObjectException e )
- {
- // ignore
- }
- catch( RemoteException e )
- {
- getLogger().warn( "Remote error during cache reference
removal.", e );
- }
- }
-
- private DefaultProxyModel createProxyModel( final EventQueue queue,
final TransitDirective directive )
- {
- try
- {
- ProxyDirective config = directive.getProxyDirective();
- if( null == config )
- {
- return null;
- }
- else
- {
- Logger logger = getLogger().getChildLogger( "proxy" );
- return new DefaultProxyModel( queue, logger, config );
- }
- }
- catch( Throwable e )
- {
- final String error =
- "An error occured during construction of the proxy model.";
- throw new TransitError( error, e );
- }
- }
-
- private DefaultCacheModel createCacheModel( final EventQueue queue,
final TransitDirective directive )
- {
- try
- {
- Logger logger = getLogger().getChildLogger( "cache" );
- CacheDirective config = directive.getCacheDirective();
- return new DefaultCacheModel( queue, logger, config );
- }
- catch( Throwable e )
- {
- final String error =
- "An error occured during construction of the cache model.";
- throw new TransitError( error, e );
- }
- }
-
- static DefaultTransitModel getBootstrapModel() throws Exception
- {
- Logger logger = new LoggingAdapter( "transit" );
- return getSecureModel( logger );
- }
-
- static DefaultTransitModel getClassicModel( Logger logger ) throws
Exception
- {
- TransitDirective directive = TransitDirective.CLASSIC_PROFILE;
- EventQueue queue = new EventQueue( logger, "DPML Transit Event
Queue" );
- return new DefaultTransitModel( queue, logger, directive );
- }
-
- private static URI createStaticURI( String path )
- {
- try
- {
- return Artifact.createArtifact( path ).toURI();
- }
- catch( Exception e )
- {
- return null;
- }
- }
-
-}
-

Deleted:
trunk/main/transit/core/src/main/net/dpml/transit/DelegatingAuthenticator.java
===================================================================
---
trunk/main/transit/core/src/main/net/dpml/transit/DelegatingAuthenticator.java
2007-02-08 23:53:26 UTC (rev 1845)
+++
trunk/main/transit/core/src/main/net/dpml/transit/DelegatingAuthenticator.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -1,165 +0,0 @@
-/*
- * Copyright 2004 Niclas Hedhman, DPML
- * Copyright 2005 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.
- */
-
-package net.dpml.transit;
-
-import java.io.PrintWriter;
-import java.net.Authenticator;
-import java.net.PasswordAuthentication;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-
-import net.dpml.transit.model.RequestIdentifier;
-
-/**
- * Internal class used to handle delegated authentication.
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-final class DelegatingAuthenticator extends Authenticator
-{
- //
------------------------------------------------------------------------
- // static
- //
------------------------------------------------------------------------
-
- /**
- * The singleton delegating authenticator instance.
- */
- private static DelegatingAuthenticator m_INSTANCE;
-
- //
------------------------------------------------------------------------
- // state
- //
------------------------------------------------------------------------
-
- /**
- * The set of registered authenticators keyed by id.
- */
- private Map m_authenticators;
-
- /**
- * Return the singleton authenticator.
- * @return the authenticator
- */
- public static DelegatingAuthenticator getInstance()
- {
- synchronized( DelegatingAuthenticator.class )
- {
- if( m_INSTANCE == null )
- {
- m_INSTANCE = new DelegatingAuthenticator();
- Authenticator.setDefault( m_INSTANCE );
- }
- return m_INSTANCE;
- }
- }
-
- //
------------------------------------------------------------------------
- // constructor
- //
------------------------------------------------------------------------
-
- /**
- * Creation of a new delegating authenticator.
- */
- private DelegatingAuthenticator()
- {
- m_authenticators = new HashMap();
- }
-
- //
------------------------------------------------------------------------
- // implementation
- //
------------------------------------------------------------------------
-
- /**
- * Add an authenticator to the set of authenticators managed by the
- * singleton delegating authenticator.
- * @param authenticator the authenticator to add
- * @param id the request identifier
- */
- public void addTransitAuthenticator( TransitAuthenticator authenticator,
RequestIdentifier id )
- {
- synchronized( m_authenticators )
- {
- m_authenticators.put( id, authenticator );
- }
- }
-
- /**
- * Remove an authenticator from the set of authenticators managed by the
- * singleton delegating authenticator.
- * @param authenticator the authenticator to remove
- */
- public void removeTransitAuthenticator( TransitAuthenticator
authenticator )
- {
- synchronized( m_authenticators )
- {
- Iterator list = m_authenticators.values().iterator();
- while( list.hasNext() )
- {
- Authenticator item = (Authenticator) list.next();
- if( item.equals( authenticator ) )
- {
- list.remove();
- }
- }
- }
- }
-
- /**
- * Returns the password authenticator.
- * @return the password authenticator
- */
- protected PasswordAuthentication getPasswordAuthentication()
- {
- String host = getRequestingHost();
- String protocol = getRequestingProtocol();
- String prompt = getRequestingPrompt();
- String scheme = getRequestingScheme();
- int port = getRequestingPort();
- if( host == null )
- {
- host = getRequestingSite().getHostName();
- if( host == null || "".equals( host ) )
- {
- host = getRequestingSite().getHostAddress();
- }
- }
- RequestIdentifier id = new RequestIdentifier( host, port, protocol,
scheme, prompt );
- try
- {
- PrintWriter log = Transit.getInstance().getLogWriter();
- log.println( "Authentication Required: " + id );
- log.println( "Authenticators Available: " + m_authenticators );
- }
- catch( Exception e )
- {
- boolean ignorable = true;
- }
-
- synchronized( m_authenticators )
- {
- TransitAuthenticator auth = (TransitAuthenticator)
m_authenticators.get( id );
- if( auth == null )
- {
- return null;
- }
- return auth.resolvePasswordAuthentication( this );
- }
- }
-}

Deleted: trunk/main/transit/core/src/main/net/dpml/transit/Disposable.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/Disposable.java
2007-02-08 23:53:26 UTC (rev 1845)
+++ trunk/main/transit/core/src/main/net/dpml/transit/Disposable.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -1,36 +0,0 @@
-/*
- * Copyright 2005 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.
- */
-
-package net.dpml.transit;
-
-/**
- * The Disposable interface is implemented by a disposable sub-system within
Transit.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public interface Disposable
-{
- /**
- * Dispose of the service. During disposal a sub-system is required to
- * release all references such as listeners and internal resources
- * in preparation for garbage collection.
- */
- void dispose();
-}
-

Deleted: trunk/main/transit/core/src/main/net/dpml/transit/EclipseLayout.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/EclipseLayout.java
2007-02-08 23:53:26 UTC (rev 1845)
+++ trunk/main/transit/core/src/main/net/dpml/transit/EclipseLayout.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -1,118 +0,0 @@
-/*
- * 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;
-
-/**
- * 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 AbstractLayout
- implements Layout
-{
- /**
- * 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();
- }
-}

Deleted: trunk/main/transit/core/src/main/net/dpml/transit/Environment.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/Environment.java
2007-02-08 23:53:26 UTC (rev 1845)
+++ trunk/main/transit/core/src/main/net/dpml/transit/Environment.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -1,594 +0,0 @@
-/*
- * Copyright 2004-2005 Stephen J. McConnell.
- * Copyright 2004 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.
- */
-
-package net.dpml.transit;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.BufferedReader;
-import java.io.InputStreamReader;
-
-import java.util.Properties;
-import java.util.Enumeration;
-
-
-/**
- * Encapsulates operating system and shell specific access to environment
- * variables.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public class Environment extends Properties
-{
- /**
- * os.name System property
- */
- public static final String OSNAME = System.getProperty( "os.name" );
-
- /**
- * user.name System property
- */
- public static final String USERNAME = System.getProperty( "user.name" );
-
- /**
- * the user's platform specific shell executable
- */
- private static String m_SHELL = null;
-
- /**
- * the last Env instance created
- */
- private static Environment m_INSTANCE = null;
-
- /**
- * Creates a snapshot of the current shell environment variables for a
user.
- *
- * @throws EnvironmentException if there is an error accessing the
environment
- */
- public Environment() throws EnvironmentException
- {
- Properties properties = getEnvVariables();
- Enumeration list = properties.propertyNames();
- while ( list.hasMoreElements() )
- {
- String key = ( String ) list.nextElement();
- setProperty( key, properties.getProperty( key ) );
- }
- m_INSTANCE = this;
- }
-
- /**
- * Gets a copy of the last Environment instance without parsing the
user's shell
- * environment. Use this method if you do not want to reparse the
- * environment every time an environment variable is accessed. If an
- * environment has not been created yet one is created then cloned
- * and a copy is returned instead of returning null.
- *
- * @return a copy of the last Environment object created
- * @throws EnvironmentException if there is an error accessing the
environment
- */
- Environment getLastEnv() throws EnvironmentException
- {
- if( m_INSTANCE == null )
- {
- m_INSTANCE = new Environment();
- }
-
- // return cloned copy so there is no cross interference
- return ( Environment ) m_INSTANCE.clone();
- }
-
-
- /**
- * Gets the value of a shell environment variable.
- *
- * @param name the name of variable
- * @return the String representation of an environment variable value
- * @throws EnvironmentException if there is a problem accessing the
environment
- */
- public static String getEnvVariable( String name )
- throws EnvironmentException
- {
- String osName = System.getProperty( "os.name" );
-
- if( isUnix() )
- {
- Properties properties = getUnixShellVariables();
- return properties.getProperty( name );
- }
- else if( isWindows() )
- {
- return getWindowsShellVariable( name );
- }
-
- throw new EnvironmentException( name,
- "Unrecognized operating system: " + osName );
- }
-
- /**
- * Checks to see if the operating system is a UNIX variant.
- *
- * @return true of the OS is a UNIX variant, false otherwise
- */
- public static boolean isUnix()
- {
- if( -1 != OSNAME.indexOf( "Linux" )
- || -1 != OSNAME.indexOf( "SunOS" )
- || -1 != OSNAME.indexOf( "Solaris" )
- || -1 != OSNAME.indexOf( "MPE/iX" )
- || -1 != OSNAME.indexOf( "AIX" )
- || -1 != OSNAME.indexOf( "FreeBSD" )
- || -1 != OSNAME.indexOf( "Irix" )
- || -1 != OSNAME.indexOf( "Digital Unix" )
- || -1 != OSNAME.indexOf( "HP-UX" )
- || -1 != OSNAME.indexOf( "Mac OS X" ) )
- {
- return true;
- }
-
- return false;
- }
-
-
- /**
- * Checks to see if the operating system is a Windows variant.
- *
- * @return true of the OS is a Windows variant, false otherwise
- */
- public static boolean isWindows()
- {
- return ( -1 != OSNAME.indexOf( "Windows" ) );
- }
-
- /**
- * Checks to see if the operating system is NetWare.
- *
- * @return true of the OS is NetWare, false otherwise
- */
- public static boolean isNetWare()
- {
- return ( -1 != OSNAME.indexOf( "netware" ) );
- }
-
- /**
- * Checks to see if the operating system is OpenVMS.
- *
- * @return true of the OS is a NetWare variant, false otherwise
- */
- public static boolean isOpenVMS()
- {
- return ( -1 != OSNAME.indexOf( "openvms" ) );
- }
-
- /**
- * Gets all environment variables within a Properties instance where the
- * key is the environment variable name and value is the value of the
- * property.
- *
- * @return the environment variables and values as Properties
- * @throws EnvironmentException if os is not recognized
- */
- public static Properties getEnvVariables() throws EnvironmentException
- {
- if( isUnix() )
- {
- return getUnixShellVariables();
- }
-
- if( isWindows() )
- {
- return getWindowsShellVariables();
- }
-
- throw new EnvironmentException(
- new UnsupportedOperationException( "Environment operations not "
- + "supported on unrecognized operatings system" ) );
- }
-
-
- /**
- * Gets the user's shell executable.
- *
- * @return the shell executable for the user
- * @throws EnvironmentException the there is a problem accessing shell
- * information
- */
- public static String getUserShell() throws EnvironmentException
- {
- if( -1 != OSNAME.indexOf( "Mac OS X" ) )
- {
- return getMacUserShell();
- }
-
- if( isWindows() )
- {
- return getWindowsUserShell();
- }
-
- throw new EnvironmentException(
- new UnsupportedOperationException( "Environment operations not "
- + "supported on unrecognized operatings system" ) );
- }
-
- //
------------------------------------------------------------------------
- // Private UNIX Shell Operations
- //
------------------------------------------------------------------------
-
- /**
- * Gets the default login shell used by a mac user.
- *
- * @return the Mac user's default shell as referenced by cmd:
- * 'nidump passwd /'
- * @throws EnvironmentException if os information is not resolvable
- */
- private static String getMacUserShell()
- throws EnvironmentException
- {
- Process process = null;
- BufferedReader reader = null;
-
- if( null != m_SHELL )
- {
- return m_SHELL;
- }
-
- try
- {
- String entry = null;
- String [] args = {"nidump", "passwd", "/"};
- process = Runtime.getRuntime().exec( args );
- reader = new BufferedReader(
- new InputStreamReader( process.getInputStream() ) );
-
- while ( null != ( entry = reader.readLine() ) )
- {
- // Skip entries other than the one for this username
- if( !entry.startsWith( USERNAME ) )
- {
- continue;
- }
-
- // Get the shell part of the passwd entry
- int index = entry.lastIndexOf( ':' );
-
- if( index == -1 )
- {
- throw new EnvironmentException(
- "passwd database contains malformed user entry for "
- + USERNAME );
- }
-
- m_SHELL = entry.substring( index + 1 );
- return m_SHELL;
- }
-
- process.waitFor();
- reader.close();
- }
- catch( Throwable t )
- {
- throw new EnvironmentException( t );
- }
- finally
- {
- if( process != null )
- {
- process.destroy();
- }
-
- try
- {
- if( null != reader )
- {
- reader.close();
- }
- }
- catch( IOException e )
- {
- // do nothing
- final boolean ignorable = true;
- }
- }
-
- throw new EnvironmentException( "User " + USERNAME
- + " is not present in the passwd database" );
- }
-
-
- /**
- * Adds a set of Windows variables to a set of properties.
- * @return the environment properties
- * @exception EnvironmentException if an error occurs
- */
- private static Properties getUnixShellVariables()
- throws EnvironmentException
- {
- Process process = null;
- Properties properties = new Properties();
-
- // Read from process here
- BufferedReader reader = null;
-
- // fire up the shell and get echo'd results on stdout
- try
- {
- String [] args = {getUnixEnv()};
- process = Runtime.getRuntime().exec( args );
- reader = new BufferedReader(
- new InputStreamReader( process.getInputStream() ) );
-
- String line = null;
- while ( null != ( line = reader.readLine() ) )
- {
- int index = line.indexOf( '=' );
-
- if( -1 == index )
- {
- if( line.length() != 0 )
- {
- System.err.println(
- "Skipping line - could not find '=' in"
- + " line: '" + line + "'" );
- }
- continue;
- }
-
- String name = line.substring( 0, index );
- String value = line.substring( index + 1, line.length() );
- properties.setProperty( name, value );
- }
-
- process.waitFor();
- reader.close();
- }
- catch( Throwable t )
- {
- throw new EnvironmentException( "NA", t );
- }
- finally
- {
- process.destroy();
-
- try
- {
- if( null != reader )
- {
- reader.close();
- }
- }
- catch( IOException e )
- {
- // ignore
- final boolean ignorable = true;
- }
- }
-
- // Check that we exited normally before returning an invalid output
- if( 0 != process.exitValue() )
- {
- throw new EnvironmentException(
- "Environment process failed "
- + " with non-zero exit code of "
- + process.exitValue() );
- }
-
- return properties;
- }
-
-
- /**
- * Gets the UNIX env executable path.
- *
- * @return the absolute path to the env program
- * @throws EnvironmentException if it cannot be found
- */
- private static String getUnixEnv() throws EnvironmentException
- {
- File env = new File( "/bin/env" );
-
- if( env.exists() && env.canRead() && env.isFile() )
- {
- return env.getAbsolutePath();
- }
-
- env = new File( "/usr/bin/env" );
- if( env.exists() && env.canRead() && env.isFile() )
- {
- return env.getAbsolutePath();
- }
-
- throw new EnvironmentException(
- "Could not find the UNIX env executable" );
- }
-
-
- //
------------------------------------------------------------------------
- // Private Windows Shell Operations
- //
------------------------------------------------------------------------
-
-
- /**
- * Gets the shell used by the Windows user.
- *
- * @return the shell: cmd.exe or command.com.
- */
- private static String getWindowsUserShell()
- {
- if( null != m_SHELL )
- {
- return m_SHELL;
- }
-
- if( -1 != OSNAME.indexOf( "98" )
- || -1 != OSNAME.indexOf( "95" )
- || -1 != OSNAME.indexOf( "Me" ) )
- {
- m_SHELL = "command.com";
- return m_SHELL;
- }
-
- m_SHELL = "cmd.exe";
- return m_SHELL;
- }
-
-
- /**
- * Adds a set of Windows variables to a set of properties.
- * @return the environment properties
- * @exception EnvironmentException if an error occurs
- */
- private static Properties getWindowsShellVariables()
- throws EnvironmentException
- {
- String line = null;
- Process process = null;
- BufferedReader reader = null;
- Properties properties = new Properties();
-
- // build the command based on the shell used: cmd.exe or command.com
- StringBuffer buffer = new StringBuffer( getWindowsUserShell() );
- buffer.append( " /C SET" );
-
- // fire up the shell and get echo'd results on stdout
- try
- {
- process = Runtime.getRuntime().exec( buffer.toString() );
- reader = new BufferedReader(
- new InputStreamReader( process.getInputStream() ) );
- while ( null != ( line = reader.readLine() ) )
- {
- int index = line.indexOf( '=' );
-
- if( -1 == index )
- {
- System.err.println( "Skipping line - could not find '='
in"
- + " line: '" + line + "'" );
- continue;
- }
-
- String name = line.substring( 0, index );
- String value = line.substring( index + 1, line.length() );
- properties.setProperty( name, value );
- }
-
- process.waitFor();
- reader.close();
- }
- catch( Throwable t )
- {
- throw new EnvironmentException( t );
- }
- finally
- {
- process.destroy();
-
- try
- {
- if( null != reader )
- {
- reader.close();
- }
- }
- catch( IOException e )
- {
- // ignore
- final boolean ignorable = true;
- }
- }
-
- if( 0 != process.exitValue() )
- {
- throw new EnvironmentException( "Environment process failed"
- + " with non-zero exit code of " + process.exitValue() );
- }
-
- return properties;
- }
-
-
- /**
- * Gets the value for a windows command shell environment variable.
- *
- * @param name the name of the variable
- * @return the value of the variable
- * @throws EnvironmentException if there is an error accessing the value
- */
- private static String getWindowsShellVariable( String name )
- throws EnvironmentException
- {
- String value = null;
- Process process = null;
- BufferedReader reader = null;
-
- StringBuffer buffer = new StringBuffer( getWindowsUserShell() );
- buffer.append( " /C echo %" );
- buffer.append( name );
- buffer.append( '%' );
-
- // fire up the shell and get echo'd results on stdout
- try
- {
- process = Runtime.getRuntime().exec( buffer.toString() );
- reader = new BufferedReader(
- new InputStreamReader( process.getInputStream() ) );
- value = reader.readLine();
- process.waitFor();
- reader.close();
- }
- catch( Throwable t )
- {
- throw new EnvironmentException( name, t );
- }
- finally
- {
- process.destroy();
-
- try
- {
- if( null != reader )
- {
- reader.close();
- }
- }
- catch( IOException e )
- {
- // ignore
- final boolean ignorable = true;
- }
- }
-
- if( 0 == process.exitValue() )
- {
- // Handle situations where the env property does not exist.
- if( value.startsWith( "%" ) && value.endsWith( "%" ) )
- {
- return null;
- }
-
- return value;
- }
-
- throw new EnvironmentException(
- name,
- "Environment process failed"
- + " with non-zero exit code of "
- + process.exitValue() );
- }
-}

Deleted:
trunk/main/transit/core/src/main/net/dpml/transit/EnvironmentException.java
===================================================================
---
trunk/main/transit/core/src/main/net/dpml/transit/EnvironmentException.java
2007-02-08 23:53:26 UTC (rev 1845)
+++
trunk/main/transit/core/src/main/net/dpml/transit/EnvironmentException.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -1,153 +0,0 @@
-/*
- * Copyright 2004-2005 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.
- */
-
-package net.dpml.transit;
-
-/**
- * A simple wrapper exception around exceptions that could occur while
accessing
- * environment parameters.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public class EnvironmentException extends RuntimeException
-{
- /**
- * Serial version identifier.
- */
- static final long serialVersionUID = 1L;
-
- /**
- * the environment variable name if available
- */
- private final String m_variable;
-
- /**
- * root cause
- */
- private final Throwable m_cause;
-
- /**
- * Creates an exception denoting a failure while attempting to access an
- * environment variable within an operating system and shell specific
- * environment that is caused by another exception.
- *
- * @param cause the underlying exception that caused the failure
- */
- EnvironmentException( final Throwable cause )
- {
- super();
-
- m_variable = null;
- m_cause = cause;
- }
-
-
- /**
- * Creates an exception denoting a failure while attempting to access an
- * environment variable within an operating system and shell specific
- * environment.
- *
- * @param message the reason for the access failure
- */
- EnvironmentException( final String message )
- {
- super( message );
-
- m_variable = null;
- m_cause = null;
- }
-
-
- /**
- * Creates an exception denoting a failure while attempting to access an
- * environment variable within an operating system and shell specific
- * environment that is caused by another exception.
- *
- * @param variable the variable whose value was to be accessed
- * @param cause the underlying exception that caused the failure
- */
- EnvironmentException( final String variable, final Throwable cause )
- {
- super();
-
- m_variable = variable;
- m_cause = cause;
- }
-
-
- /**
- * Creates an exception denoting a failure while attempting to access an
- * environment variable within an operating system and shell specific
- * environment.
- *
- * @param variable the variable whose value was to be accessed
- * @param message the reason for the access failure
- */
- EnvironmentException( final String variable, final String message )
- {
- super( message );
-
- m_variable = variable;
- m_cause = null;
- }
-
-
- /**
- * Gets the variable that was to be accessed.
- *
- * @return the value of the variable
- */
- public String getVariable()
- {
- return m_variable;
- }
-
-
- /**
- * Return the causal exception.
- *
- * @return the exception that caused this exception (possibly null)
- */
- public Throwable getCause()
- {
- return m_cause;
- }
-
-
- /**
- * Prepends variable name to the base message.
- * @return the exception message
- * @see java.lang.Throwable#getMessage()
- */
- public String getMessage()
- {
- String base = super.getMessage();
-
- if ( null == base )
- {
- return "Failed to access " + m_variable + " environment
variable";
- }
-
- return "Failed to access " + m_variable
- + " environment variable - " + base;
- }
-}
-
-
-

Added: trunk/main/transit/core/src/main/net/dpml/transit/HostManager.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/HostManager.java
2007-02-08 23:53:26 UTC (rev 1845)
+++ trunk/main/transit/core/src/main/net/dpml/transit/HostManager.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -0,0 +1,75 @@
+/*
+ * Copyright 2006 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.
+ */
+
+package net.dpml.transit;
+
+import javax.management.MXBean;
+import javax.management.MBeanException;
+
+/**
+ * Management interface to a resource host.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+ @MXBean
+public interface HostManager
+{
+ /**
+ * Returns the host identifier.
+ * @return the host id
+ * @exception MBeanException if a JMX error occurs
+ */
+ String getID() throws MBeanException;
+
+ /**
+ * Returns the host priority.
+ * @return the host priority value
+ * @exception MBeanException if a JMX error occurs
+ */
+ int getPriority() throws MBeanException;
+
+ /**
+ * Returns the host base url.
+ * @return the host url
+ * @exception MBeanException if a JMX error occurs
+ */
+ String getBase() throws MBeanException;
+
+ /**
+ * Returns the host layout strategy identifier
+ * @return the layout identifier
+ * @exception MBeanException if a JMX error occurs
+ */
+ String getLayoutID() throws MBeanException;
+
+ /**
+ * Returns the host enabled status.
+ * @return the enabled state
+ * @exception MBeanException if a JMX error occurs
+ */
+ boolean isEnabled() throws MBeanException;
+
+ /**
+ * Returns the host trusted status.
+ * @return the trusted state
+ * @exception MBeanException if a JMX error occurs
+ */
+ boolean isTrusted() throws MBeanException;
+
+}
\ No newline at end of file

Added:
trunk/main/transit/core/src/main/net/dpml/transit/InvalidArtifactException.java
===================================================================
---
trunk/main/transit/core/src/main/net/dpml/transit/InvalidArtifactException.java
2007-02-08 23:53:26 UTC (rev 1845)
+++
trunk/main/transit/core/src/main/net/dpml/transit/InvalidArtifactException.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -0,0 +1,49 @@
+/*
+ * Copyright 2004-2005 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.
+ */
+
+package net.dpml.transit;
+
+/**
+ * Exception to indicate that the Artifact already exists in the cache and
+ * can therefor not be written to.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class InvalidArtifactException extends IllegalArgumentException
+{
+ /**
+ * Serial version identifier.
+ */
+ static final long serialVersionUID = 1L;
+
+ //
------------------------------------------------------------------------
+ // constructor
+ //
------------------------------------------------------------------------
+
+ /**
+ * Construct a new <code>InvalidArtifactException</code> instance.
+ *
+ * @param message the exception message
+ */
+ public InvalidArtifactException( final String message )
+ {
+ super( message );
+ }
+}
+

Modified: trunk/main/transit/core/src/main/net/dpml/transit/Layout.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/Layout.java
2007-02-08 23:53:26 UTC (rev 1845)
+++ trunk/main/transit/core/src/main/net/dpml/transit/Layout.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -1,6 +1,5 @@
/*
- * Copyright 2004 Niclas Hedhman.
- * Copyright 2005 Stephen McConnell
+ * Copyright 2006 Stephen McConnell
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,24 +18,69 @@

package net.dpml.transit;

-/**
- * A Layout abstracts the decoding process of the location
- * of artifacts in various filesystems.
- *
+import java.util.Map;
+import java.util.Hashtable;
+import java.util.ServiceLoader;
+
+/**
+ * Definition of a repository layout. Specialized layouts must extend from
+ * this base abstract class. The class includes static methods supporting
+ * the resolution of available layouts. Each layout instance is associated
with
+ * a unique identifier and represents the mapping between a layout strategy
+ * name and the physical structural representation of a repository.
Operations
+ * on the layout class support the translation of artifact addresses to their
+ * corresponding physicaly layout on remote systems.
+ *
* @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
* @version @PROJECT-VERSION@
*/
-public interface Layout
+public abstract class Layout
{
+ private static final Map<String, Layout> LAYOUTS = new Hashtable<String,
Layout>();
+ static
+ {
+ ServiceLoader<Layout> loaders = ServiceLoader.load( Layout.class );
+ for( Layout layout : loaders )
+ {
+ String key = layout.getID();
+ if( !LAYOUTS.containsKey( key ) )
+ {
+ LAYOUTS.put( key, layout );
+ }
+ }
+ }
+
+ /**
+ * Return a location resolver capable for supporting the supplied id. If
+ * a handler is available the handler is returned otherwise the returned
+ * value is null.
+ *
+ * @param id the layout identifier
+ * @return the location resolver or null if not available
+ */
+ public static Layout getLayout( final String id )
+ {
+ return LAYOUTS.get( id );
+ }
+
/**
- * Return the base path for an artifact. The base path is the location
- * where the file will be found. The base + "/" filename is equal to the
- * full path.
+ * Return the layout identifier. The id value is used
+ * to identify layout instances assigned to cache handlers and
+ * resource host handlers.
*
- * @param artifact the Artifact to resolve.
- * @return the base path
+ * @return the layout id
*/
- String resolveBase( Artifact artifact );
+ public abstract String getID();
+
+ /**
+ * Return the base path for an artifact. The base path is the location
+ * where the file will be found. The base + "/" filename is equal to the
+ * full path.
+ *
+ * @param artifact the Artifact to resolve.
+ * @return the base path
+ */
+ public abstract String resolveBase( Artifact artifact );

/**
* Returns the full path of the artifact relative to a logical root
directory.
@@ -47,7 +91,7 @@
* @param artifact the Artifact to resolve.
* @return the logical artifact path
*/
- String resolvePath( Artifact artifact );
+ public abstract String resolvePath( Artifact artifact );

/**
* Return the filename for an artifact. The base + "/" filename is equal
@@ -58,5 +102,5 @@
* @param artifact the Artifact to resolve.
* @return the logical artifact path
*/
- String resolveFilename( Artifact artifact );
+ public abstract String resolveFilename( Artifact artifact );
}

Deleted: trunk/main/transit/core/src/main/net/dpml/transit/LayoutRegistry.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/LayoutRegistry.java
2007-02-08 23:53:26 UTC (rev 1845)
+++ trunk/main/transit/core/src/main/net/dpml/transit/LayoutRegistry.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -1,49 +0,0 @@
-/*
- * Copyright 2005 Stephen 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.
- */
-
-package net.dpml.transit;
-
-import java.io.IOException;
-
-import net.dpml.lang.UnknownKeyException;
-
-/**
- * A interface supporting access to pluggable content handlers.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public interface LayoutRegistry
-{
- /**
- * Constrant layout plugin key.
- */
- public static final String LAYOUT_HANDLER_PLUGIN_KEY =
"dpml.transit.layout.plugin";
-
- /**
- * Return a location resolver capable for supporting the supplied id. If
- * a handler is available the handler is returned otherwise the returned
- * value is null.
- *
- * @param id the layout identifier
- * @return the location resolver or null if not available
- * @exception UnknownKeyException if the key is not recognized
- * @exception IOException if an IO error occurs
- */
- Layout getLayout( final String id ) throws UnknownKeyException,
IOException;
-}

Copied: trunk/main/transit/core/src/main/net/dpml/transit/LinkManager.java
(from rev 1789,
trunk/main/transit/core/src/main/net/dpml/transit/link/LinkManager.java)
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/link/LinkManager.java
2006-11-30 21:08:46 UTC (rev 1789)
+++ trunk/main/transit/core/src/main/net/dpml/transit/LinkManager.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -0,0 +1,55 @@
+/*
+ * Copyright 2005 Niclas Hedhman
+ * Copyright 2005-2006 Stephen 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.
+ */
+
+package net.dpml.transit;
+
+import java.io.IOException;
+import java.net.URI;
+
+/**
+ * The LinkManager is responsible for storing the mapping between a Link
+ * instance and a URI.
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public interface LinkManager
+{
+ /**
+ * Sets the URI for the provided link URI.
+ * The LinkManager is required to persist this information between
+ * JVM restarts and should be persisted on a scope larger than a
+ * single JVM, typically a host or a local area network. LinkManagers
+ * are encouraged to establish other virtual scopes independent of
+ * network topologies.
+ *
+ * @param link the uri of the link
+ * @param target the uri of the target that the link redirects to
+ * @exception IOException if an IO error occurs
+ */
+ void setTargetURI( URI link, URI target ) throws IOException;
+
+ /**
+ * Returns the URI that the supplied link URI is referencing.
+ *
+ * @param link the link uri
+ * @return the target uri
+ * @exception IOException if an IO error occurs
+ */
+ URI getTargetURI( URI link ) throws IOException;
+
+}

Copied:
trunk/main/transit/core/src/main/net/dpml/transit/LinkNotFoundException.java
(from rev 1789,
trunk/main/transit/core/src/main/net/dpml/transit/link/LinkNotFoundException.java)
===================================================================
---
trunk/main/transit/core/src/main/net/dpml/transit/link/LinkNotFoundException.java
2006-11-30 21:08:46 UTC (rev 1789)
+++
trunk/main/transit/core/src/main/net/dpml/transit/LinkNotFoundException.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -0,0 +1,53 @@
+/*
+ * Copyright 2004-2005 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.
+ */
+
+package net.dpml.transit;
+
+import java.net.URI;
+
+import net.dpml.transit.ArtifactNotFoundException;
+
+/**
+ * Exception to indicate that a link could not be located.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public class LinkNotFoundException extends ArtifactNotFoundException
+{
+ /**
+ * Serial version identifier.
+ */
+ static final long serialVersionUID = 1L;
+
+ //
------------------------------------------------------------------------
+ // constructor
+ //
------------------------------------------------------------------------
+
+ /**
+ * Construct a new <code>LinkNotFoundException</code> instance.
+ *
+ * @param message The detail message for this exception.
+ * @param uri the link uri
+ */
+ public LinkNotFoundException( final String message, final URI uri )
+ {
+ super( message, uri );
+ }
+}
+

Deleted:
trunk/main/transit/core/src/main/net/dpml/transit/ModelRuntimeException.java
===================================================================
---
trunk/main/transit/core/src/main/net/dpml/transit/ModelRuntimeException.java
2007-02-08 23:53:26 UTC (rev 1845)
+++
trunk/main/transit/core/src/main/net/dpml/transit/ModelRuntimeException.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -1,51 +0,0 @@
-/*
- * Copyright 2005 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.
- */
-
-package net.dpml.transit;
-
-
-/**
- * Exception to indicate that there was a configuration model related error.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public class ModelRuntimeException extends TransitRuntimeException
-{
- /**
- * Construct a new <code>ModelRuntimeException</code> instance.
- *
- * @param message The detail message for this exception.
- */
- public ModelRuntimeException( final String message )
- {
- this( message, null );
- }
-
- /**
- * Construct a new <code>ModelRuntimeException</code> instance.
- *
- * @param message The detail message for this exception.
- * @param cause the root cause of the exception
- */
- public ModelRuntimeException( final String message, final Throwable
cause )
- {
- super( message, cause );
- }
-}
-

Deleted: trunk/main/transit/core/src/main/net/dpml/transit/ModernLayout.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/ModernLayout.java
2007-02-08 23:53:26 UTC (rev 1845)
+++ trunk/main/transit/core/src/main/net/dpml/transit/ModernLayout.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -1,142 +0,0 @@
-/*
- * 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;
-
-/**
- * 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
- implements Layout
-{
- /**
- * 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/Monitor.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/Monitor.java
2007-02-08 23:53:26 UTC (rev 1845)
+++ trunk/main/transit/core/src/main/net/dpml/transit/Monitor.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2006 Stephen 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.
+ */
+
+package net.dpml.transit;
+
+import java.io.File;
+
+import java.net.URL;
+
+/**
+ * Transit event monitor.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+public interface Monitor
+{
+ // cache monitoring functions
+
+ /**
+ * Notify the monitor that an artifact has been requested.
+ * @param artifact the requested artifact
+ */
+ void resourceRequested( Artifact artifact );
+
+ /**
+ * Notify the monitor that an artifact has been added to the local cache.
+ * @param resource the url of the resource added to the local cache
+ * @param localFile the local file resident in the cache
+ */
+ void addedToLocalCache( URL resource, File localFile );
+
+ /**
+ * Notify the monitor that an artifact in the local cache has been
updated.
+ * @param resource the url of the resource updating the local cache
+ * @param localFile the local file that has been updated
+ */
+ void updatedLocalCache( URL resource, File localFile );
+
+ /**
+ * Notify the monitor that an artifact has been removed from the local
cache.
+ * @param resource the url of the resource removed from the local cache
+ * @param localFile the local file removed from the cache
+ */
+ void removedFromLocalCache( URL resource, File localFile );
+
+ /**
+ * Notify the monitor of a failed download attempt relative to an
identified host.
+ * @param host the host raising the fail status
+ * @param artifact the requested artifact
+ * @param cause the exception causing the failure
+ */
+ void failedDownloadFromHost( String host, Artifact artifact, Throwable
cause );
+
+ /**
+ * Notify the monitor of a failed download attempt.
+ * @param artifact the requested artifact
+ */
+ void failedDownload( Artifact artifact );
+
+ // network monitoring
+
+ /**
+ * Notify the monitor of the update in the download status.
+ *
+ * @param resource the name of the remote resource being downloaded.
+ * @param expected the expected number of bytes to be downloaded.
+ * @param count the number of bytes downloaded.
+ */
+ void notifyUpdate( URL resource, int expected, int count );
+
+ /**
+ * Notify the monitor of the successful completion of a download
+ * process.
+ * @param resource the name of the remote resource.
+ */
+ void notifyCompletion( URL resource );
+
+
+}

Deleted: trunk/main/transit/core/src/main/net/dpml/transit/NetworkLoader.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/NetworkLoader.java
2007-02-08 23:53:26 UTC (rev 1845)
+++ trunk/main/transit/core/src/main/net/dpml/transit/NetworkLoader.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -1,90 +0,0 @@
-/*
- * 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;
-
-import net.dpml.transit.artifact.ArtifactException;
-import net.dpml.transit.monitor.NetworkMonitorRouter;
-import net.dpml.util.StreamUtils;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.net.HttpURLConnection;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.Date;
-
-/**
- * Nework loader utility.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-class NetworkLoader
-{
- /**
- * Network monitor router.
- */
- private NetworkMonitorRouter m_monitor;
-
- /**
- * Creation of a new network loader.
- * @exception TransitException if an error in transit system
establishment occurs
- */
- public NetworkLoader()
- throws TransitException
- {
- m_monitor = Transit.getInstance().getNetworkMonitorRouter();
- }
-
- //
------------------------------------------------------------------------
- // implementation
- //
------------------------------------------------------------------------
-
- /**
- * Retrieve a remote resource.
- *
- * @param url the of the file to retrieve
- * @param connection the url connection
- * @param destination where to store it
- * @return the lastModified date of the downloaded artifact.
- * @exception net.dpml.transit.ArtifactException if an artifact related
errror occurs
- * @exception IOException if an IO error occurs
- */
- public Date loadResource( URL url, URLConnection connection,
OutputStream destination )
- throws ArtifactException, IOException
- {
- if( connection instanceof HttpURLConnection )
- {
- HttpURLConnection httpConnection = (HttpURLConnection)
connection;
- int code = httpConnection.getResponseCode();
- // test for 401 result (HTTP only)
- if ( code == HttpURLConnection.HTTP_UNAUTHORIZED )
- {
- throw new IOException( "Not authorized." );
- }
- }
-
- InputStream in = connection.getInputStream();
- int expected = connection.getContentLength();
- StreamUtils.copyStream( m_monitor, url, expected, in, destination,
true );
- long remoteTimestamp = connection.getLastModified();
- return new Date( remoteTimestamp );
- }
-}

Deleted:
trunk/main/transit/core/src/main/net/dpml/transit/NullArgumentException.java
===================================================================
---
trunk/main/transit/core/src/main/net/dpml/transit/NullArgumentException.java
2007-02-08 23:53:26 UTC (rev 1845)
+++
trunk/main/transit/core/src/main/net/dpml/transit/NullArgumentException.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -1,59 +0,0 @@
-/*
- * Copyright 2005 Niclas Hedhman.
- * Copyright 2005 Stephen 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.
- */
-
-package net.dpml.transit;
-
-
-/**
- * Exception thrown when the argument to a method or constructor is
- * <i>null</i> and not handled by the method/constructor/class.
- *
- * The argument in the only constructor of this exception should only
- * take the name of the declared argument that is null, for instance;
- * <code><pre>
- * public Person( String name, int age )
- * {
- * if( name == null )
- * throw new NullArgumentException( "name" );
- * if( age > 120 )
- * throw new IllegalArgumentException( "age > 120" );
- * if( age < 0 )
- * throw new IllegalArgumentException( "age < 0" );
- * }
- * </pre></code>
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public class NullArgumentException extends IllegalArgumentException
-{
- /**
- * Serial version identifier.
- */
- static final long serialVersionUID = 1L;
-
- /** Constructor taking the name of the argument that was null.
- * @param argumentName the source code name of the argument that caused
- * this exception.
- */
- public NullArgumentException( String argumentName )
- {
- super( argumentName );
- }
-}
\ No newline at end of file

Deleted:
trunk/main/transit/core/src/main/net/dpml/transit/PluginClassNotFoundException.java
===================================================================
---
trunk/main/transit/core/src/main/net/dpml/transit/PluginClassNotFoundException.java
2007-02-08 23:53:26 UTC (rev 1845)
+++
trunk/main/transit/core/src/main/net/dpml/transit/PluginClassNotFoundException.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -1,58 +0,0 @@
-/*
- * 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;
-
-/**
- * Exception thrown when a plugin class cannot be found.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public class PluginClassNotFoundException extends RepositoryException
-{
- /**
- * Serial version identifier.
- */
- static final long serialVersionUID = 1L;
-
- /**
- * Construct a new <code>PluginClassNotFoundException</code> instance.
- *
- * @param message The detail message for this exception.
- */
- public PluginClassNotFoundException( final String message )
- {
- this( message, null );
- }
-
- /**
- * Construct a new <code>RepositoryException</code> instance.
- *
- * @param message The detail message for this exception.
- * @param cause the root cause of the exception
- */
- public PluginClassNotFoundException( final String message, final
Throwable cause )
- {
- super( message, cause );
- }
-
-}
-
-

Deleted:
trunk/main/transit/core/src/main/net/dpml/transit/RepositoryException.java
===================================================================
---
trunk/main/transit/core/src/main/net/dpml/transit/RepositoryException.java
2007-02-08 23:53:26 UTC (rev 1845)
+++
trunk/main/transit/core/src/main/net/dpml/transit/RepositoryException.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -1,60 +0,0 @@
-/*
- * 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;
-
-import java.io.IOException;
-
-/**
- * Exception to indicate that there was a repository related error.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public class RepositoryException extends IOException
-{
- /**
- * Serial version identifier.
- */
- static final long serialVersionUID = 1L;
-
- /**
- * Construct a new <code>RepositoryException</code> instance.
- *
- * @param message The detail message for this exception.
- */
- public RepositoryException( final String message )
- {
- this( message, null );
- }
-
- /**
- * Construct a new <code>RepositoryException</code> instance.
- *
- * @param message The detail message for this exception.
- * @param cause the root cause of the exception
- */
- public RepositoryException( final String message, final Throwable cause )
- {
- super( message );
- super.initCause( cause );
- }
-}
-
-

Deleted: trunk/main/transit/core/src/main/net/dpml/transit/ResourceHost.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/ResourceHost.java
2007-02-08 23:53:26 UTC (rev 1845)
+++ trunk/main/transit/core/src/main/net/dpml/transit/ResourceHost.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -1,121 +0,0 @@
-/*
- * Copyright 2004 Niclas Hedhman.
- * Copyright 2005 Stephen 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.
- */
-
-package net.dpml.transit;
-
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.IOException;
-
-import java.net.URL;
-
-import java.util.Date;
-
-/**
- * An interface that represents locations where the artifacts can be
- * downloaded.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public interface ResourceHost
-{
- /** Downloads the given artifact to the directory indicated.
- * <p>
- * The cachedir argument is the root cache directory, and the
ResourceHost
- * class is responsible for the creation of the directory structure of
the
- * group if nonexistent.
- * </p>
- * <p>
- * If the knownOnly argument is true, then only attempt download if the
- * group is known to exist on this resource host.
- * </p>
- * @param artifact the artifact that is requested to be downloaded.
- * @param dest The output stream where to write the downloaded content.
- * @exception IOException if an IO related error occurs
- * @return the lastModified date of the downloaded artifact.
- */
- Date download( Artifact artifact, OutputStream dest )
- throws IOException;
-
- /** Uploads the given file to the resource host as an artifact.
- *
- * @param artifact the artifact destination specification.
- * @param source The input stream from where to read the content to be
uploaded.
- * @exception IOException if an IO related error occurs
- */
- void upload( Artifact artifact, InputStream source )
- throws IOException;
-
- /** Checks if the Artifact is present on the resource host.
- *
- * <p>
- * Performs a check to see if the artifact exists on the resource
host. If
- * <i>knownOnly</i> is set to true, then the implementation will only
- * consult the knownGroups table, and if found there, it is considered
- * found without checking at the resource host itself. If
<i>knownOnly</i>
- * is false, however, a connection will be established to the resource
- * host and a check of the actual resource existence.
- * </p>
- *
- * @param artifact the artifact for which the method checks its presence.
- * @param knownOnly does not perform a remote connection, and instead
lookup
- * the group table, and if not found there it will return false.
- *
- * @return true if the artifact can be located, false otherwise.
- */
- boolean checkPresence( Artifact artifact, boolean knownOnly );
-
- /** Returns the hostname of the resource host.
- *
- * <p>
- * This does not include any of the path, but does include any port
number
- * of this resource host.
- * </p>
- * @return the hostname
- */
- String getHostName();
-
- /**
- * Returns the full host url.
- *
- * @return the host url
- */
- URL getURL();
-
- /**
- * Return true if the resource host has been enabled.
- *
- * @return true if the resource host is enabled, false if not.
- */
- boolean isEnabled();
-
- /** Returns true if the ResourceHost is considered trusted.
- * @return true if the host is trusted
- */
- boolean isTrusted();
-
- /** Returns the priority of the resource host.
- *
- * A high number indicates a more important host that should take
precendence
- * over a host with lower number.
- * @return the host priority
- */
- int getPriority();
-}

Deleted: trunk/main/transit/core/src/main/net/dpml/transit/SaxMonitor.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/SaxMonitor.java
2007-02-08 23:53:26 UTC (rev 1845)
+++ trunk/main/transit/core/src/main/net/dpml/transit/SaxMonitor.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -1,71 +0,0 @@
-/*
- * Copyright 2006 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.
- */
-
-package net.dpml.transit;
-
-import org.xml.sax.ErrorHandler;
-import org.xml.sax.SAXException;
-import org.xml.sax.SAXParseException;
-
-import net.dpml.util.Logger;
-
-/**
- * Utility class supporting the reading and writing of standard plugins
definitions.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-final class SaxMonitor implements ErrorHandler
-{
- private Logger m_logger;
-
- public SaxMonitor( Logger logger )
- {
- if( null == logger )
- {
- throw new NullPointerException( "logger" );
- }
- m_logger = logger;
- }
-
- public void error( SAXParseException e ) throws SAXException
- {
- final String message = getMessage( e );
- m_logger.warn( message );
- }
-
- public void fatalError( SAXParseException e ) throws SAXException
- {
- final String message = getMessage( e );
- m_logger.error( message );
- }
-
- public void warning( SAXParseException e ) throws SAXException
- {
- final String message = getMessage( e );
- m_logger.warn( message );
- }
-
- private String getMessage( SAXParseException e )
- {
- return e.getMessage()
- + "(" + e.getLineNumber()
- + "," + e.getColumnNumber()
- + ")";
- }
-}

Deleted:
trunk/main/transit/core/src/main/net/dpml/transit/SecuredTransitContext.java
===================================================================
---
trunk/main/transit/core/src/main/net/dpml/transit/SecuredTransitContext.java
2007-02-08 23:53:26 UTC (rev 1845)
+++
trunk/main/transit/core/src/main/net/dpml/transit/SecuredTransitContext.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -1,467 +0,0 @@
-/*
- * Copyright 2004-2005 Niclas Hedhman
- * Copyright 2005 Stephen 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.
- */
-
-package net.dpml.transit;
-
-import java.io.IOException;
-import java.rmi.NoSuchObjectException;
-import java.rmi.Remote;
-import java.rmi.RemoteException;
-import java.rmi.server.UnicastRemoteObject;
-import java.net.PasswordAuthentication;
-import java.net.URL;
-import java.util.Properties;
-
-import net.dpml.transit.link.ArtifactLinkManager;
-import net.dpml.transit.link.LinkManager;
-import net.dpml.transit.model.CacheModel;
-import net.dpml.transit.model.TransitModel;
-import net.dpml.transit.model.ProxyModel;
-import net.dpml.transit.model.ProxyListener;
-import net.dpml.transit.model.ProxyEvent;
-import net.dpml.transit.model.RequestIdentifier;
-import net.dpml.transit.model.DisposalListener;
-import net.dpml.transit.model.DisposalEvent;
-import net.dpml.transit.monitor.LoggingAdapter;
-
-import net.dpml.lang.UnknownKeyException;
-import net.dpml.util.Logger;
-
-
-/**
- * The initial context of the transit system.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public final class SecuredTransitContext
-{
- //------------------------------------------------------------------
- // static
- //------------------------------------------------------------------
-
- /**
- * Creation of the transit context. If the transit context has already
- * been established the method returns the singeton context otherwise a
new
- * context is created relative to the authoritve url and returned.
- * @param model the active transit model
- * @return the secured transit context
- * @exception TransitException if an error occurs during context creation
- * @exception NullArgumentException if the supplied configration model is
null
- * and an instance of this class has not been created already.
- */
- public static SecuredTransitContext create( TransitModel model )
- throws TransitException, NullArgumentException
- {
- synchronized( SecuredTransitContext.class )
- {
- if( m_CONTEXT != null )
- {
- return m_CONTEXT;
- }
-
- if( null == model )
- {
- throw new NullArgumentException( "model" );
- }
-
- Logger logger = resolveLogger( model );
- if( logger.isDebugEnabled() )
- {
- logger.debug( "creating transit context" );
- }
-
- try
- {
- m_CONTEXT = new SecuredTransitContext( model, logger );
- }
- catch( TransitException e )
- {
- throw e;
- }
- catch( Exception e )
- {
- String error = "Unable to establish the transit context.";
- throw new TransitException( error, e );
- }
-
- return m_CONTEXT;
- }
- }
-
- private static Logger resolveLogger( TransitModel model )
- {
- if( model instanceof DefaultTransitModel )
- {
- DefaultTransitModel m = (DefaultTransitModel) model;
- return m.getLoggingChannel();
- }
- else
- {
- return new LoggingAdapter();
- }
- }
-
- /**
- * Return the singleton context.
- * @return the secure context
- */
- public static SecuredTransitContext getInstance()
- {
- synchronized( SecuredTransitContext.class )
- {
- if( null == m_CONTEXT )
- {
- throw new IllegalStateException( "context" );
- }
- else
- {
- return m_CONTEXT;
- }
- }
- }
-
- //------------------------------------------------------------------
- // state
- //------------------------------------------------------------------
-
- /**
- * The configuration model.
- */
- private TransitModel m_model;
-
- /**
- * The cache handler.
- */
- private CacheHandler m_cacheHandler;
-
- /**
- * The LinkManager instance.
- */
- private LinkManager m_linkManager;
-
- /**
- * Logging channel.
- */
- private Logger m_logger;
-
- private ProxyController m_proxyController;
-
- private DisposalController m_disposalController;
-
- //------------------------------------------------------------------
- // constructors
- //------------------------------------------------------------------
- /**
- * Creation of a new secured transit context.
- * @param model the transit configuration model
- * @param logger the assigned logging channel
- * @exception IOException if an I/O error occurs
- */
- private SecuredTransitContext( TransitModel model, Logger logger )
throws IOException
- {
- m_model = model;
- m_logger = logger;
-
- CacheModel cacheModel = model.getCacheModel();
- Logger cacheLogger = logger.getChildLogger( "cache" );
- DefaultCacheHandler cache = new DefaultCacheHandler( cacheModel,
cacheLogger );
- m_cacheHandler = cache;
- ProxyModel proxy = m_model.getProxyModel();
- if( null != proxy )
- {
- synchronized( proxy )
- {
- setupProxy();
- m_proxyController = new ProxyController();
- proxy.addProxyListener( m_proxyController );
- }
- }
- m_disposalController = new DisposalController();
- model.addDisposalListener( m_disposalController );
- }
-
- //------------------------------------------------------------------
- // SecuredTransitContext
- //------------------------------------------------------------------
-
- /**
- * Return a layout object matching the supplied identifier.
- * @param id the layout identifier
- * @return the layout object
- * @exception UnknownKeyException if the supplied layout id is unknown
- * @exception IOException if an IO error occurs
- */
- public Layout getLayout( String id ) throws UnknownKeyException,
IOException
- {
- LayoutRegistry registry = m_cacheHandler.getLayoutRegistry();
- Layout layout = registry.getLayout( id );
- if( null == layout )
- {
- throw new UnknownKeyException( id );
- }
- else
- {
- return layout;
- }
- }
-
- /**
- * Return the cache layout.
- * @return the layout
- */
- public Layout getCacheLayout()
- {
- return getCacheHandler().getLayout();
- }
-
- /**
- * Return the cache handler.
- * @return the cache handler
- */
- public CacheHandler getCacheHandler()
- {
- return m_cacheHandler;
- }
-
- /**
- * Return the link manager.
- * @return the cache handler
- */
- public LinkManager getLinkManager()
- {
- return m_linkManager;
- }
-
- //------------------------------------------------------------------
- // internals
- //------------------------------------------------------------------
-
- /**
- * General setup.
- * @exception RemoteException if a remote error occurs
- */
- protected synchronized void setupProxy() throws RemoteException
- {
- ProxyModel model = m_model.getProxyModel();
- URL proxy = model.getHost();
- if( null != proxy )
- {
- PasswordAuthentication auth = model.getAuthentication();
- if( null != auth )
- {
- TransitAuthenticator ta = new TransitAuthenticatorImpl( auth
);
- RequestIdentifier id = model.getRequestIdentifier();
- DelegatingAuthenticator da =
DelegatingAuthenticator.getInstance();
- da.addTransitAuthenticator( ta, id );
- }
-
- int port = proxy.getPort();
- Properties system = System.getProperties();
- system.put( "http.proxyHost", proxy );
- system.put( "http.proxyPort", "" + port );
- String[] excludes = model.getExcludes();
- String path = toExcludesPath( excludes );
- if( null != path )
- {
- system.put( "http.nonProxyHosts", path );
- }
- }
- }
-
- /**
- * Initialization of any sub-systems following the establishment of the
initial
- * transit system. As a general principal any subsystems that cannot be
established
- * for technical reasons (security or permission restrictions, etc.)
should log
- * an appropriate message and fallback to the initial setup thereby
ensuring that
- * an operable transit system is available.
- *
- * @exception IOException if an io error occurs
- */
- protected void initialize() throws IOException
- {
- m_linkManager = new ArtifactLinkManager();
- initializeCache();
- }
-
- /**
- * Cache initialization.
- *
- * @exception IOException if an initialization error occurs
- */
- private void initializeCache() throws IOException
- {
- getCacheHandler().initialize();
- }
-
- /**
- * Internal listener to the proxy model.
- */
- private class ProxyController extends UnicastRemoteObject implements
ProxyListener
- {
- /**
- * Listener creation.
- * @exception RemoteException if a remote error occurs
- */
- public ProxyController() throws RemoteException
- {
- super();
- }
-
- /**
- * Notify a listener of the change to Transit proxy settings.
- * @param event the proxy change event
- */
- public void proxyChanged( ProxyEvent event )
- {
- try
- {
- setupProxy();
- }
- catch( RemoteException e )
- {
- final String error =
- "Unexpected error while attrempting to set proxy
settings.";
- getLogger().error( error, e );
- }
- }
- }
-
- /**
- * Internal listener to the proxy model.
- */
- private class DisposalController extends UnicastRemoteObject implements
DisposalListener
- {
- /**
- * Listener creation.
- * @exception RemoteException if a remote error occurs
- */
- public DisposalController() throws RemoteException
- {
- super();
- }
-
- /**
- * Notify a listener of transit model disposal.
- * @param event the disposal event
- */
- public void notifyDisposal( DisposalEvent event )
- {
- Thread thread = new Terminator();
- thread.start();
- }
- }
-
- /**
- * Internal model terminator.
- */
- private class Terminator extends Thread
- {
- Terminator()
- {
- }
-
- /**
- * Initiate model retraction from the RMI.
- */
- public void run()
- {
- m_logger.debug( "initiating transit runtime disposal" );
- terminate( m_proxyController );
- terminate( m_cacheHandler );
- terminate( m_disposalController );
- m_logger.debug( "transit runtime disposal complete" );
- }
-
- private void terminate( Object object )
- {
- if( object instanceof Disposable )
- {
- Disposable disposable = (Disposable) object;
- disposable.dispose();
- }
- if( object instanceof Remote )
- {
- try
- {
- Remote remote = (Remote) object;
- UnicastRemoteObject.unexportObject( remote, true );
- }
- catch( NoSuchObjectException e )
- {
- // ignore
- }
- catch( Throwable e )
- {
- final String error =
- "Unexpected error encountered during transit runtime
termination.";
- m_logger.warn( error, e );
- }
- }
- }
- }
-
- private Logger getLogger()
- {
- return m_logger;
- }
-
- //------------------------------------------------------------------
- // static (utils)
- //------------------------------------------------------------------
-
- /**
- * Resolve the list of host names to be assigned as non-proxied hosts. If
proxy
- * excludes are defined the string returned contains the host name
(wilcards allowed)
- * separated by the "|" character. If no proxy excludes are defined the
value returned
- * shall be null. The implementation reads the set of attribute names
associated
- * with a preferences node named "excludes". Each attribute name is
appended to
- * a single string where names are separated by the "|" character.
- *
- * @param names an array of named excludes
- * @return a string containing a sequence of excluded hosts (possibly
null)
- */
- private static String toExcludesPath( String[] names )
- {
- String spec = null;
- for( int i=0; i < names.length; i++ )
- {
- String name = names[i];
- if( null == spec )
- {
- spec = name;
- }
- else
- {
- spec = spec + "|" + name;
- }
- }
- return spec;
- }
-
- /**
- * The namespace string for transit related properties.
- */
- public static final String DOMAIN = "dpml.transit";
-
- /**
- * The singleton transit context.
- */
- private static SecuredTransitContext m_CONTEXT;
-}

Deleted:
trunk/main/transit/core/src/main/net/dpml/transit/StandardLayoutModel.java
===================================================================
---
trunk/main/transit/core/src/main/net/dpml/transit/StandardLayoutModel.java
2007-02-08 23:53:26 UTC (rev 1845)
+++
trunk/main/transit/core/src/main/net/dpml/transit/StandardLayoutModel.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -1,211 +0,0 @@
-/*
- * Copyright 2005 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.
- */
-
-package net.dpml.transit;
-
-import java.net.URI;
-import java.rmi.RemoteException;
-import java.util.EventObject;
-import java.util.EventListener;
-
-import net.dpml.lang.Value;
-
-import net.dpml.transit.model.LayoutModel;
-import net.dpml.transit.model.LayoutListener;
-import net.dpml.transit.model.LayoutEvent;
-import net.dpml.transit.model.CodeBaseListener;
-
-import net.dpml.util.EventQueue;
-import net.dpml.util.Logger;
-
-/**
- * The StandardLayoutModel represents a standard layout included with the
- * core Transit system.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-class StandardLayoutModel extends DefaultModel implements LayoutModel
-{
- //----------------------------------------------------------------------
- // state
- //----------------------------------------------------------------------
-
- private final String m_id;
- private final String m_title;
- private final String m_classname;
-
- //----------------------------------------------------------------------
- // constructor
- //----------------------------------------------------------------------
-
- /**
- * Creation of a new layout model using a supplied layout configuration.
- * @param logger the assigned logging channel
- * @param id the layout identifier
- * @param title the layout title
- * @param classname the layout classname
- * @exception RemoteException if a remote exception occurs
- */
- public StandardLayoutModel(
- final EventQueue queue, final Logger logger, final String id, final
String title, final String classname )
- throws RemoteException
- {
- super( queue, logger );
-
- m_id = id;
- m_title = title;
- m_classname = classname;
- }
-
- //----------------------------------------------------------------------
- // LayoutModel
- //----------------------------------------------------------------------
-
- /**
- * Return a possibly null classname. If the classname is not null the
- * manager represents a bootstrap layout model.
- *
- * @return the layout classname
- * @exception RemoteException if a remote exception occurs
- */
- public String getClassname()
- {
- return m_classname;
- }
-
- /**
- * Returns the human readable name of the resolver.
- * @return the resolver human readable name
- */
- public String getTitle()
- {
- return m_title;
- }
-
- /**
- * Add a layout listener to the model.
- * @param listener the listener to add
- */
- public void addLayoutListener( LayoutListener listener )
- {
- super.addListener( listener );
- }
-
- /**
- * Remove a layout listener from the director.
- * @param listener the listener to remove
- */
- public void removeLayoutListener( LayoutListener listener )
- {
- super.removeListener( listener );
- }
-
- //----------------------------------------------------------------------
- // CodeBaseModel
- //----------------------------------------------------------------------
-
- /**
- * Return the immutable model identifier.
- * @return the resolver identifier
- * @exception RemoteException if a remote exception occurs
- */
- public String getID()
- {
- return m_id;
- }
-
- /**
- * Return the uri of the plugin to be used for the subsystem.
- * @return the codebase plugin uri
- * @exception RemoteException if a remote exception occurs
- */
- public URI getCodeBaseURI()
- {
- return null;
- }
-
- /**
- * Add a codebase listener to the model.
- * @param listener the listener to add
- * @exception RemoteException if a remote exception occurs
- */
- public void addCodeBaseListener( CodeBaseListener listener )
- {
- }
-
- /**
- * Remove a codebase listener from the model.
- * @param listener the listener to remove
- * @exception RemoteException if a remote exception occurs
- */
- public void removeCodeBaseListener( CodeBaseListener listener )
- {
- }
-
- /**
- * Return the array of codebase parameter values.
- *
- * @return the parameter value array
- * @exception RemoteException if a remote exception occurs
- */
- public Value[] getParameters()
- {
- return new Value[0];
- }
-
- //
------------------------------------------------------------------------
- // internal
- //
------------------------------------------------------------------------
-
- /**
- * Internal event handler.
- * @param event the event to handle
- */
- public void processEvent( EventObject event )
- {
- if( event instanceof LayoutEvent )
- {
- processLayoutEvent( (LayoutEvent) event );
- }
- }
-
- private void processLayoutEvent( LayoutEvent event )
- {
- EventListener[] listeners = super.getEventListeners();
- for( int i=0; i < listeners.length; i++ )
- {
- EventListener eventListener = listeners[i];
- if( eventListener instanceof LayoutListener )
- {
- LayoutListener listener = (LayoutListener ) eventListener;
- try
- {
- listener.titleChanged( event );
- }
- catch( Throwable e )
- {
- final String error =
- "LayoutListener title change notification error.";
- getLogger().error( error, e );
- }
- }
- }
- }
-}
-

Modified: trunk/main/transit/core/src/main/net/dpml/transit/Transit.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/Transit.java
2007-02-08 23:53:26 UTC (rev 1845)
+++ trunk/main/transit/core/src/main/net/dpml/transit/Transit.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -1,5 +1,5 @@
/*
- * Copyright 2004-2005 Stephen McConnell.
+ * Copyright 2004-2006 Stephen McConnell.
* Copyright 2004-2005 Niclas Hedhman.
*
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -19,27 +19,62 @@

package net.dpml.transit;

+import dpml.util.DefaultLogger;
+
+import dpml.transit.*;
+
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
+import java.io.FileNotFoundException;
+import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
+import java.net.URI;
+import java.net.URL;

-import net.dpml.transit.link.LinkManager;
-import net.dpml.transit.monitor.LoggingAdapter;
-import net.dpml.transit.monitor.RepositoryMonitorRouter;
-import net.dpml.transit.monitor.CacheMonitorRouter;
-import net.dpml.transit.monitor.NetworkMonitorRouter;
-import net.dpml.transit.model.TransitModel;
+import dpml.transit.info.TransitDirective;

-import net.dpml.lang.UnknownKeyException;
import net.dpml.util.Logger;

/**
- * The Transit class manages the establishment of a singleton transit
instance
- * together with a service supporting the deployment of a application plugin
and
- * access to transit monitor routers.
+ * The Transit class manages the establishment of a singleton transit
instance.
+ * The implementation establishes an internal cache management system, a
suite
+ * of protocol handlers, and a dynamic content handler service.
+ *
+ * During initialization Transit will load an XML configuration descibing
the
+ * available remote hosts. The XML file will be resolved using the
following
+ * strategy:
*
+ * <ul>
+ * <li>if the system property <tt>dpml.transit.profile</tt> is defined then
+ * <ul>
+ * <li>if the value contains the ':' character the value will be
+ * treated as a URL referencing a remote configuration</li>
+ * <li>otherwise the value will be treated as a relative file path
+ * that is first evaluated relative to the current working
directory
+ * and a file exists at that location it will be loaded,
otherwise,
+ * the path will be evaluated relative to the DPML Preferences root
+ * directory</li>
+ * </ul>
+ * </li>
+ * <li>otherwise, the default configuration path
+ * <tt>dpml/transit/xmls/standard.xml</tt> will be resolved relative to
the
+ * Preferences root directory</li>
+ * <li>if no default configuration is found, Transit will assign a standard
+ * profile</li>
+ * </ul>
+ *
+ * During initialization Transit will create the following system properties:
+ *
+ * <ul>
+ * <li><tt>dpml.home</tt> home directory</li>
+ * <li><tt>dpml.data</tt> data directory</li>
+ * <li><tt>dpml.prefs</tt> preferences repository root directory</li>
+ * <li><tt>dpml.share</tt> shared system root directory</li>
+ * <li><tt>dpml.transit.version</tt> Transit system version</li>
+ * </ul>
+ *
* @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
* @version @PROJECT-VERSION@
*/
@@ -52,151 +87,141 @@
/**
* DPML home key.
*/
- public static final String HOME_KEY = "dpml.home";
+ private static final String HOME_KEY = "dpml.home";

/**
* DPML data key.
*/
- public static final String DATA_KEY = "dpml.data";
+ private static final String DATA_KEY = "dpml.data";

/**
* DPML prefs key.
*/
- public static final String PREFS_KEY = "dpml.prefs";
+ private static final String PREFS_KEY = "dpml.prefs";

/**
* Transit system key.
*/
- public static final String SYSTEM_KEY = "dpml.system";
+ private static final String SYSTEM_KEY = "dpml.system";

/**
* Transit share key (alias to dpml.system).
*/
- public static final String SHARE_KEY = "dpml.share";
+ private static final String SHARE_KEY = "dpml.share";

/**
* DPML environment variable string.
*/
- public static final String HOME_SYMBOL = "DPML_HOME";
+ private static final String HOME_SYMBOL = "DPML_HOME";

/**
* DPML environment variable string.
*/
- public static final String SYSTEM_SYMBOL = "DPML_SYSTEM";
+ private static final String SYSTEM_SYMBOL = "DPML_SYSTEM";

/**
* The DPML home directory established via assesment of the the
${dpml.home}
- * system property and the DPML_HOME environment variable.
+ * system property and the <tt>DPML_HOME</tt> environment variable.
*/
- public static final File DPML_HOME;
+ public static final File HOME;

/**
* If a system property named "dpml.system" is defined then the value
* is assigned otherwise the implementation will look for an environment
- * variable named "DPML_SYSTEM".
+ * variable <tt>DPML_SYSTEM</tt>.
*/
- public static final File DPML_SYSTEM;
+ public static final File SYSTEM;

/**
* The Transit personal data directory. The location of this diectory is
system
* dependent.
*/
- public static final File DPML_DATA;
+ public static final File DATA;

/**
* The Transit personal preferences directory. The location of this
diectory is system
* dependent.
*/
- public static final File DPML_PREFS;
+ public static final File PREFS;

/**
* The Transit system version.
*/
public static final String VERSION = "@PROJECT-VERSION@";

+ /**
+ * Default configuration path.
+ */
+ private static final String STANDARD_PATH =
"dpml/transit/xmls/standard.xml";
+
+ /**
+ * System property key used to hold an overriding configuration url.
+ */
+ private static final String PROFILE_KEY = "dpml.transit.profile";
+
+ private static final Logger LOGGER = new DefaultLogger( "dpml.transit" );
+
static
{
- System.setProperty( "java.protocol.handler.pkgs", "net.dpml.transit"
);
+ String pkgs = System.getProperty( "java.protocol.handler.pkgs" );
+ if( null == pkgs )
+ {
+ System.setProperty( "java.protocol.handler.pkgs",
"dpml.transit|net.dpml.transit" );
+ }
+ else
+ {
+ System.setProperty( "java.protocol.handler.pkgs", pkgs +
"|dpml.transit|net.dpml.transit" );
+ }
+
System.setProperty( "dpml.transit.version", VERSION );
+
+ HOME = resolveHomeDirectory();
+ SYSTEM = resolveSystemDirectory( HOME );
+ DATA = resolveDataDirectory( HOME );
+ PREFS = resolvePreferencesDirectory( HOME );

- DPML_HOME = resolveHomeDirectory();
- DPML_SYSTEM = resolveSystemDirectory( DPML_HOME );
- DPML_DATA = resolveDataDirectory( DPML_HOME );
- DPML_PREFS = resolvePreferencesDirectory( DPML_HOME );
-
- System.setProperty( SYSTEM_KEY, DPML_SYSTEM.getAbsolutePath() );
- System.setProperty( SHARE_KEY, DPML_SYSTEM.getAbsolutePath() );
- System.setProperty( HOME_KEY, DPML_HOME.getAbsolutePath() );
- System.setProperty( DATA_KEY, DPML_DATA.getAbsolutePath() );
- System.setProperty( PREFS_KEY, DPML_PREFS.getAbsolutePath() );
+ System.setProperty( SYSTEM_KEY, SYSTEM.getAbsolutePath() );
+ System.setProperty( SHARE_KEY, SYSTEM.getAbsolutePath() );
+ System.setProperty( HOME_KEY, HOME.getAbsolutePath() );
+ System.setProperty( DATA_KEY, DATA.getAbsolutePath() );
+ System.setProperty( PREFS_KEY, PREFS.getAbsolutePath() );
}
-
+
/**
* Returns the singleton instance of the transit system. If Transit
- * has not been initialized a the transit model will be resolved
+ * has not been initialized the transit configuration will be resolved
* using the System property <tt>dpml.transit.profile</tt>.
* @return the singleton transit instance
* @exception TransitError if an error occurs during establishment
- * @see DefaultTransitModel#getDefaultModel
*/
- public static Transit getInstance() throws TransitError
+ public synchronized static Transit getInstance() throws TransitError
{
- synchronized( Transit.class )
+ if( null == m_INSTANCE )
{
- if( m_INSTANCE == null )
+ if( LOGGER.isTraceEnabled() )
{
- try
- {
- Logger logger = new LoggingAdapter( "dpml.transit" );
- TransitModel model =
DefaultTransitModel.getDefaultModel( logger );
- return getInstance( model );
- }
- catch( Throwable e )
- {
- String message = e.getMessage();
- Throwable cause = e.getCause();
- throw new TransitError( message, cause );
- }
+ LOGGER.trace( "version " + VERSION );
+ LOGGER.trace( "codebase: "
+ +
Transit.class.getProtectionDomain().getCodeSource().getLocation()
+ );
}
- else
+ try
{
+ TransitDirective directive = loadTransitDirective();
+ m_INSTANCE = new Transit( directive );
return m_INSTANCE;
}
- }
- }
-
- /**
- * Returns the singleton instance of the transit system. If this method
- * has already been invoked the server and monitor argument will be
ignored.
- *
- * @param model the activate transit model
- * @return the singleton transit instance
- * @exception IOException if an error occurs during establishment
- * @exception TransitAlreadyInitializedException if Transit is already
initialized
- */
- public static Transit getInstance( TransitModel model )
- throws IOException, TransitAlreadyInitializedException
- {
- synchronized( Transit.class )
- {
- if( m_INSTANCE == null )
+ catch( Throwable e )
{
- m_INSTANCE = new Transit( model );
-
- // before returning from this method we need to give the
transit
- // subsystems a chance to complete initialization actions
that
- // are themselves dependent on an establish Transit instance
-
- m_INSTANCE.getTransitContext().initialize();
- return m_INSTANCE;
- }
- else
- {
final String error =
- "Transit has already been initialized.";
- throw new TransitAlreadyInitializedException( error );
+ "Transit initialization failure.";
+ throw new TransitError( error, e );
}
}
+ else
+ {
+ return m_INSTANCE;
+ }
}

//------------------------------------------------------------------
@@ -204,34 +229,48 @@
//------------------------------------------------------------------

/**
- * Singleton repository monitor router.
+ * Internal transit context.
*/
- private RepositoryMonitorRouter m_repositoryMonitor;
+ private TransitContext m_context;

- /**
- * Singleton cache monitor router.
- */
- private CacheMonitorRouter m_cacheMonitor;
+ //------------------------------------------------------------------
+ // constructor
+ //------------------------------------------------------------------

/**
- * Singleton network monitor router.
+ * Private constructor of a transit instance.
+ *
+ * @param directive the transit configuration
+ * @exception TransitException if an establishment error occurs
*/
- private NetworkMonitorRouter m_networkMonitor;
+ private Transit( TransitDirective directive ) throws TransitException
+ {
+ try
+ {
+ m_context = TransitContext.create( directive );
+ }
+ //catch( TransitException e )
+ //{
+ // throw e;
+ //}
+ catch( Throwable e )
+ {
+ final String error = "Internal error while attempting to create
the Transit context.";
+ throw new TransitException( error, e );
+ }
+ }
+
+ //------------------------------------------------------------------
+ // implementation
+ //------------------------------------------------------------------

/**
- * PrintWriter where operations troubleshooting messages
- * can be written to.
- */
- private PrintWriter m_logWriter;
-
- private SecuredTransitContext m_context;
-
- /**
* Return the singleton transit content.
+ *
* @return the context instance
* @exception IllegalStateException if transit has not been initialized
*/
- SecuredTransitContext getTransitContext() throws IllegalStateException
+ TransitContext getTransitContext() throws IllegalStateException
{
if( null == m_context )
{
@@ -246,63 +285,6 @@
}

/**
- * Private constructor of a transit instance.
- * @param model the active transit model
- * @exception TransitException if an establishment error occurs
- */
- private Transit( TransitModel model ) throws TransitException
- {
- //
- // create the transit context
- //
-
- try
- {
- m_context = SecuredTransitContext.create( model );
- }
- catch( TransitException e )
- {
- throw e;
- }
- catch( Throwable e )
- {
- final String error = "Unable to construct transit context.";
- throw new TransitException( error, e );
- }
-
- //
- // setup the monitors
- //
-
- m_repositoryMonitor = new RepositoryMonitorRouter();
- m_cacheMonitor = new CacheMonitorRouter();
- m_networkMonitor = new NetworkMonitorRouter();
-
- try
- {
- // Setting up a temporary directory for Transit.
-
- File temp = new File( DPML_DATA, "temp" );
- temp.mkdirs();
-
- // Setting up a permanent output troubleshooting resource
- // for Transit.
- File logs = new File( DPML_DATA, "logs" );
- File logDir = new File( logs, "transit" );
- logDir.mkdirs();
- File logFile = new File( logDir, "transit.log" );
- FileOutputStream fos = new FileOutputStream( logFile );
- OutputStreamWriter osw = new OutputStreamWriter( fos, "UTF-8" );
- m_logWriter = new PrintWriter( osw, true );
- }
- catch( Throwable e )
- {
- final String error = "Unable to construct transit instance.";
- throw new TransitException( error, e );
- }
- }
-
- /**
* Return the current cache directory.
* @return the cache directory.
*/
@@ -330,74 +312,26 @@
}

/**
- * Return a layout object matching the supplied identifier.
- * @param id the layout identifier
- * @return the layout object
- * @exception UnknownKeyException if the supplied layout id is unknown
- * @exception IOException if an IO error occurs
+ * Add a monitor to Transit.
+ * @param monitor the monitor to add
*/
- public Layout getLayout( String id ) throws UnknownKeyException,
IOException
+ public void addMonitor( Monitor monitor )
{
- return getTransitContext().getLayout( id );
+ getTransitContext().addMonitor( monitor );
}

/**
- * Return the Transit repository service.
- * @return the repository service
- * @exception IllegalStateException if Transit has not been initialized
+ * Return the content handler fo the supplied content type.
+ * @return the content handler or null if no content handler found
*/
- //public Repository getRepository() throws IllegalStateException
- //{
- // return getTransitContext().getRepository();
- //}
-
- /**
- * Returns a reference to the repository monitor router. Client
application
- * may use the router to add, remove or replace existing monitors.
- * @return the repository monitor router
- */
- public RepositoryMonitorRouter getRepositoryMonitorRouter()
+ public ContentHandler getContentHandler( String type )
{
- return m_repositoryMonitor;
+ return getTransitContext().getContentHandler( type );
}
-
+
/**
- * Returns a reference to the cache monitor router. Client application
- * may use the router to add, remove or replace existing monitors.
- * @return the cache monitor router
- */
- public CacheMonitorRouter getCacheMonitorRouter()
- {
- return m_cacheMonitor;
- }
-
- /**
- * Returns a reference to the netowork monitor router. Client application
- * may use the router to add, remove or replace existing monitors.
- * @return the network monitor router
- */
- public NetworkMonitorRouter getNetworkMonitorRouter()
- {
- return m_networkMonitor;
- }
-
- /** Returns the LogWriter for the Transit system.
- * This writer should only be used to report information that
- * should not be output to the user in the course of normal
- * execution but can aid to determine what has gone wrong in
- * Transit, such as configuration problems, network problems
- * and security issues.
- * @return a PrintWriter where troubleshooting information can
- * be written to.
- */
- public PrintWriter getLogWriter()
- {
- return m_logWriter;
- }
-
- /**
* Resolve the DPML home directory using assesment of the the ${dpml.home}
- * system property, the DPML_HOME environment variable. If DPML_HOME is
+ * system property, the HOME environment variable. If HOME is
* not declared, the behaviour is platform specific. If the os is
Windows,
* the value returned is equivalent to $APPDATA\DPML whereas Unix
environment
* will return ${user.home}/.dpml. The value returned may be overriden by
@@ -412,7 +346,7 @@
{
return new File( home );
}
- home = Environment.getEnvVariable( HOME_SYMBOL );
+ home = System.getenv( HOME_SYMBOL );
if( null != home )
{
return new File( home );
@@ -420,7 +354,7 @@
String os = System.getProperty( "os.name" ).toLowerCase();
if( os.indexOf( "win" ) >= 0 )
{
- home = Environment.getEnvVariable( "APPDATA" );
+ home = System.getenv( "APPDATA" );
File data = new File( home );
return new File( data, "DPML" );
}
@@ -435,11 +369,11 @@
* Resolve the DPML system home directory. If a system property
* named "dpml.system" is defined then the value as a file is
* returned otherwise the implementation will look for an environment
- * variable named "DPML_SYSTEM" which if defined will be
+ * variable named "SYSTEM" which if defined will be
* returned as a file otherwise a value equivalent to
* <tt>${dpml.home}/share</tt> will be returned.
*
- * @param dpmlHomeDir the default DPML_HOME value
+ * @param dpmlHomeDir the default HOME value
* @return the transit system directory
*/
private static File resolveSystemDirectory( File dpmlHomeDir )
@@ -449,7 +383,7 @@
{
return new File( home );
}
- home = Environment.getEnvVariable( SYSTEM_SYMBOL );
+ home = System.getenv( SYSTEM_SYMBOL );
if( null != home )
{
return new File( home );
@@ -466,7 +400,7 @@
* system property otherwise the default value returned
* will be equivalent to <tt>${dpml.home}/data</tt>.
*
- * @param dir the default DPML_HOME value
+ * @param dir the default HOME value
* @return the transit personal data directory
*/
private static File resolveDataDirectory( File dir )
@@ -488,7 +422,7 @@
* system property otherwise the default value returned
* will be equivalent to <tt>${dpml.home}/prefs</tt>.
*
- * @param dir the default DPML_HOME value
+ * @param dir the default HOME value
* @return the transit personal data directory
*/
private static File resolvePreferencesDirectory( File dir )
@@ -513,4 +447,80 @@
*/
private static Transit m_INSTANCE;

+ /**
+ * Resolve the transit configuration using the default resource path
+ * <tt>local:xml:dpml/transit/config</tt>. If the resource does not exist
a classic
+ * default scenario will be returned.
+ *
+ * @return the transit configuration directive
+ * @exception Exception if an error occurs during model construction
+ */
+ private static TransitDirective loadTransitDirective() throws Exception
+ {
+ String path = System.getProperty( PROFILE_KEY );
+ if( null != path )
+ {
+ URL url = resolveURL( path );
+ return loadTransitDirective( url );
+ }
+ else
+ {
+ File prefs = Transit.PREFS;
+ File config = new File( prefs, STANDARD_PATH );
+ if( config.exists() )
+ {
+ URI uri = config.toURI();
+ URL url = uri.toURL();
+ return loadTransitDirective( url );
+ }
+ else
+ {
+ return TransitDirective.CLASSIC_PROFILE;
+ }
+ }
+ }
+
+ private static TransitDirective loadTransitDirective( URL url ) throws
Exception
+ {
+ if( LOGGER.isTraceEnabled() )
+ {
+ LOGGER.trace(
+ "configuration ["
+ + url
+ + "]" );
+ }
+ return TransitDirective.decode( url );
+ }
+
+ private static URL resolveURL( String path ) throws Exception
+ {
+ if( path.indexOf( ":" ) > -1 )
+ {
+ // its a url
+ URI uri = new URI( path );
+ return Artifact.toURL( uri );
+ }
+ else
+ {
+ // its a file path
+ File file = new File( path );
+ if( file.exists() )
+ {
+ return file.toURI().toURL();
+ }
+ else
+ {
+ File prefs = Transit.PREFS;
+ File alt = new File( prefs, path );
+ if( alt.exists() )
+ {
+ return alt.toURI().toURL();
+ }
+ else
+ {
+ throw new FileNotFoundException( path );
+ }
+ }
+ }
+ }
}

Deleted:
trunk/main/transit/core/src/main/net/dpml/transit/TransitAlreadyInitializedException.java
===================================================================
---
trunk/main/transit/core/src/main/net/dpml/transit/TransitAlreadyInitializedException.java
2007-02-08 23:53:26 UTC (rev 1845)
+++
trunk/main/transit/core/src/main/net/dpml/transit/TransitAlreadyInitializedException.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -1,57 +0,0 @@
-/*
- * Copyright 2004-2005 Stephen J. McConnell.
- * Copyright 2004-2005 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;
-
-/**
- * Runtime exception throw when an attempt is made to initialize transit
- * when an existing Transit instance is already active.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public class TransitAlreadyInitializedException extends
TransitRuntimeException
-{
- /**
- * Serial version identifier.
- */
- static final long serialVersionUID = 1L;
-
- /**
- * Construct a new <code>TransitAlreadyInitializedException</code>
instance.
- *
- * @param message The detail message for this exception.
- */
- public TransitAlreadyInitializedException( final String message )
- {
- this( message, null );
- }
-
- /**
- * Construct a new <code>TransitAlreadyInitializedException</code>
instance.
- *
- * @param message The detail message for this exception.
- * @param cause the root cause of the exception
- */
- public TransitAlreadyInitializedException( final String message, final
Throwable cause )
- {
- super( message, cause );
- }
-}
-

Deleted:
trunk/main/transit/core/src/main/net/dpml/transit/TransitAuthenticator.java
===================================================================
---
trunk/main/transit/core/src/main/net/dpml/transit/TransitAuthenticator.java
2007-02-08 23:53:26 UTC (rev 1845)
+++
trunk/main/transit/core/src/main/net/dpml/transit/TransitAuthenticator.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -1,38 +0,0 @@
-/*
- * Copyright 2004-2005 Stephen McConnell, DPML
- *
- * 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;
-
-import java.net.Authenticator;
-import java.net.PasswordAuthentication;
-
-/**
- * Transit authenticator contract.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public interface TransitAuthenticator
-{
- /**
- * Returns the password authenticator.
- * @param authenticator the default authenticator
- * @return the password authenticator
- */
- PasswordAuthentication resolvePasswordAuthentication( Authenticator
authenticator );
-}

Deleted:
trunk/main/transit/core/src/main/net/dpml/transit/TransitAuthenticatorImpl.java
===================================================================
---
trunk/main/transit/core/src/main/net/dpml/transit/TransitAuthenticatorImpl.java
2007-02-08 23:53:26 UTC (rev 1845)
+++
trunk/main/transit/core/src/main/net/dpml/transit/TransitAuthenticatorImpl.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -1,99 +0,0 @@
-/*
- * Copyright 2004-2005 Stephen McConnell, DPML
- * Copyright 2004 Niclas Hedhman, DPML
- *
- * 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;
-
-import java.net.Authenticator;
-import java.net.PasswordAuthentication;
-
-/**
- * Default authenticator that provides support for username password
- * based authentication in conjunction with the repository proxy settings.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-final class TransitAuthenticatorImpl
- implements TransitAuthenticator
-{
- //
------------------------------------------------------------------------
- // state
- //
------------------------------------------------------------------------
-
- /**
- * Proxy username.
- */
- private final PasswordAuthentication m_authentication;
-
- //
------------------------------------------------------------------------
- // constructor
- //
------------------------------------------------------------------------
-
- /**
- * Creation of a new simple authenticator.
- * @param authenticator a password authenticator
- * @exception NullArgumentException if either the authenticator argument
is null
- */
- public TransitAuthenticatorImpl( PasswordAuthentication authenticator )
- throws NullArgumentException
- {
- if( authenticator == null )
- {
- m_authentication = new PasswordAuthentication( "",
"".toCharArray() );
- }
- else
- {
- m_authentication = authenticator;
- }
- }
-
- /**
- * Creation of a new simple authenticator.
- * @param username the username
- * @param password the password
- * @exception NullArgumentException if either the username or password
argument is null
- */
- public TransitAuthenticatorImpl( String username, String password )
- throws NullArgumentException
- {
- if( username == null )
- {
- throw new NullArgumentException( "username" );
- }
- if( password == null )
- {
- throw new NullArgumentException( "password" );
- }
- m_authentication = new PasswordAuthentication( username,
password.toCharArray() );
- }
-
- //
------------------------------------------------------------------------
- // implementation
- //
------------------------------------------------------------------------
-
- /**
- * Returns the password authenticator.
- * @param authenticator an default authenticator
- * @return the password authenticator
- */
- public PasswordAuthentication resolvePasswordAuthentication(
Authenticator authenticator )
- {
- return m_authentication;
- }
-}

Deleted: trunk/main/transit/core/src/main/net/dpml/transit/TransitBuilder.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/TransitBuilder.java
2007-02-08 23:53:26 UTC (rev 1845)
+++ trunk/main/transit/core/src/main/net/dpml/transit/TransitBuilder.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -1,541 +0,0 @@
-/*
- * Copyright 2006 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.
- */
-
-package net.dpml.transit;
-
-import java.net.URI;
-import java.net.URL;
-import java.net.URLConnection;
-import java.io.InputStream;
-import java.io.OutputStream;
-import java.io.IOException;
-import java.io.Writer;
-import java.io.OutputStreamWriter;
-
-import javax.xml.parsers.DocumentBuilder;
-import javax.xml.parsers.DocumentBuilderFactory;
-
-import net.dpml.util.ElementHelper;
-import net.dpml.transit.info.TransitDirective;
-import net.dpml.transit.info.CacheDirective;
-import net.dpml.transit.info.HostDirective;
-import net.dpml.transit.info.ProxyDirective;
-import net.dpml.transit.info.LayoutDirective;
-
-import net.dpml.lang.ValueDirective;
-import net.dpml.util.DecodingException;
-import net.dpml.util.Logger;
-
-import org.xml.sax.ErrorHandler;
-
-import org.w3c.dom.Element;
-import org.w3c.dom.Document;
-
-/**
- * Utility class supporting the reading of Transit XML configurations.
- *
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-public class TransitBuilder
-{
- private static final String XML_HEADER =
- "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";
-
- private static final String NAME = "transit";
-
- private static final String PUBLIC_ID =
- "-//DPML//DTD Transit Configuration Version 1.0//EN";
-
- private static final String SYSTEM_ID =
- "http://download.dpml.net/dtds/transit_1_0.dtd";;
-
- private static final String RESOURCE =
- "net/dpml/transit/transit_1_0.dtd";
-
- private static final String DOCTYPE =
- "\n<!DOCTYPE "
- + NAME
- + " PUBLIC \""
- + PUBLIC_ID
- + "\" \""
- + SYSTEM_ID
- + "\" >";
-
- private static final DTD[] DTDS = new DTD[]
- {
- new DTD(
- PUBLIC_ID,
- SYSTEM_ID,
- RESOURCE, null )
- };
-
- //private static final DTDResolver DTD_RESOLVER =
- // new DTDResolver( DTDS, TransitBuilder.class.getClassLoader() );
-
- private Logger m_logger;
-
- /**
- * Creation of a new transit configuration builder.
- * @param logger the assigned logging channel
- */
- public TransitBuilder( Logger logger )
- {
- m_logger = logger;
- }
-
- /**
- * Construct a transit configuration from a supplied uri.
- * @param url the configuration url
- * @return the transit configuration
- * @exception Exception if an error occurs during configuration loading
- */
- public TransitDirective load( final URL url ) throws Exception
- {
- URLConnection connection = url.openConnection();
- InputStream input = connection.getInputStream();
-
- final DocumentBuilderFactory factory =
- DocumentBuilderFactory.newInstance();
- factory.setValidating( true );
- factory.setNamespaceAware( true );
- factory.setExpandEntityReferences( true );
- DocumentBuilder builder = factory.newDocumentBuilder();
- DTDResolver resolver =
- new DTDResolver( DTDS, getClass().getClassLoader() );
- builder.setEntityResolver( resolver );
- ErrorHandler errors = new SaxMonitor( m_logger );
- builder.setErrorHandler( errors );
-
- final Document document = builder.parse( input );
- final Element root = document.getDocumentElement();
- return build( root );
- }
-
- /**
- * Write a transit directive to an output stream as XML.
- * @param directive the directive to externalize
- * @param output the output stream to write to
- * @exception IOException if an I/O error occurs
- */
- public void write( TransitDirective directive, OutputStream output )
throws IOException
- {
- final Writer writer = new OutputStreamWriter( output );
- try
- {
- writer.write( XML_HEADER );
- writer.write( DOCTYPE );
-
- CacheDirective cache = directive.getCacheDirective();
- String cachePath = cache.getCache();
- String cacheLayout = cache.getCacheLayout();
- writeHeader( writer, cachePath, cacheLayout );
-
- ProxyDirective proxy = directive.getProxyDirective();
- writeProxy( writer, proxy );
-
- String localPath = cache.getLocal();
- String localLayout = cache.getLocalLayout();
- writeLocal( writer, localPath, localLayout );
-
- HostDirective[] hosts = cache.getHostDirectives();
- writeHosts( writer, hosts );
-
- writeFooter( writer );
- writer.write( "\n" );
- }
- finally
- {
- writer.flush();
- writer.close();
- }
- }
-
- //-------------------------------------------------------------
- // internals supporting XML to directive transformation
- //-------------------------------------------------------------
-
- private TransitDirective build( Element root ) throws Exception
- {
- String name = root.getTagName();
- if( !NAME.equals( name ) )
- {
- final String error =
- "Invalid root element name ["
- + name
- + "].";
- throw new IOException( error );
- }
-
- String cachePath = ElementHelper.getAttribute( root, "cache" );
- String cacheLayout = ElementHelper.getAttribute( root, "layout" );
-
- Element localElement = ElementHelper.getChild( root, "local" );
- String localPath = ElementHelper.getAttribute( localElement, "path"
);
- String localLayout = ElementHelper.getAttribute( localElement,
"layout" );
-
- Element proxyElement = ElementHelper.getChild( root, "proxy" );
- ProxyDirective proxy = buildProxyDirective( proxyElement );
-
- Element hostsElement = ElementHelper.getChild( root, "hosts" );
- HostDirective[] hosts = buildHosts( hostsElement );
-
- Element layoutsElement = ElementHelper.getChild( root, "layouts" );
- LayoutDirective[] layouts = buildLayouts( layoutsElement );
-
- // handlers TBD
-
- CacheDirective cache =
- new CacheDirective(
- cachePath, cacheLayout, localPath, localLayout,
- CacheDirective.EMPTY_LAYOUTS, hosts );
- return new TransitDirective( proxy, cache );
- }
-
- private LayoutDirective[] buildLayouts( Element element ) throws
Exception
- {
- if( null == element )
- {
- return null;
- }
- else
- {
- Element[] layoutElements = ElementHelper.getChildren( element,
"layout" );
- LayoutDirective[] layouts = new LayoutDirective[
layoutElements.length ];
- for( int i=0; i<layoutElements.length; i++ )
- {
- Element elem = layoutElements[i];
- layouts[i] = buildLayout( elem );
- }
- return layouts;
- }
- }
-
- private LayoutDirective buildLayout( Element element ) throws Exception
- {
- String id = ElementHelper.getAttribute( element, "id" );
- String title = ElementHelper.getAttribute( element, "title" );
- Element codebase = ElementHelper.getChild( element, "codebase" );
- URI uri = decodeURI( codebase );
- ValueDirective[] values = getValueDirectives( codebase );
- return new LayoutDirective( id, title, uri, values );
- }
-
- private URI decodeURI( Element element ) throws DecodingException
- {
- String uri = ElementHelper.getAttribute( element, "uri" );
- if( null == uri )
- {
- final String error = "Missing uri attribute.";
- throw new DecodingException( element, error );
- }
- else
- {
- try
- {
- return new URI( uri );
- }
- catch( Exception e )
- {
- final String error = "Bad uri argument [" + uri + "].";
- throw new DecodingException( element, error );
-
- }
- }
- }
-
- private ValueDirective[] getValueDirectives( Element element )
- {
- if( null == element )
- {
- return null;
- }
- else
- {
- Element[] valueElements = ElementHelper.getChildren( element,
"value" );
- ValueDirective[] values = new ValueDirective[
valueElements.length ];
- for( int i=0; i<valueElements.length; i++ )
- {
- Element elem = valueElements[i];
- values[i] = buildValue( elem );
- }
- return values;
- }
- }
-
- private ValueDirective buildValue( Element element )
- {
- String target = ElementHelper.getAttribute( element, "target" );
- String method = ElementHelper.getAttribute( element, "method" );
- String value = ElementHelper.getAttribute( element, "value" );
- if( value != null )
- {
- return new ValueDirective( target, method, value );
- }
- else
- {
- ValueDirective[] values = getValueDirectives( element );
- return new ValueDirective( target, method, values );
- }
- }
-
- private ProxyDirective buildProxyDirective( Element element )
- {
- if( null == element )
- {
- return null;
- }
- else
- {
- String host = ElementHelper.getAttribute( element, "host" );
- Element credentialsElement = ElementHelper.getChild( element,
"credentials" );
- String username = getUsername( credentialsElement );
- char[] password = getPassword( credentialsElement );
- String[] excludes = buildProxyExcludes( element );
- return new ProxyDirective( host, excludes, username, password );
- }
- }
-
- private String[] buildProxyExcludes( Element element )
- {
- if( null == element )
- {
- return null;
- }
- else
- {
- Element[] elements = ElementHelper.getChildren( element,
"exclude" );
- String[] excludes = new String[ elements.length ];
- for( int i=0; i<excludes.length; i++ )
- {
- Element elem = elements[i];
- excludes[i] = ElementHelper.getValue( elem );
- }
- return excludes;
- }
- }
-
- private HostDirective[] buildHosts( Element element )
- {
- Element[] elements = ElementHelper.getChildren( element, "host" );
- HostDirective[] hosts = new HostDirective[ elements.length ];
- for( int i=0; i<hosts.length; i++ )
- {
- Element elem = elements[i];
- String id = ElementHelper.getAttribute( elem, "id" );
- int priority = Integer.parseInt( ElementHelper.getAttribute(
elem, "priority" ) );
- String url = ElementHelper.getAttribute( elem, "url" );
- String layout = ElementHelper.getAttribute( elem, "layout" );
- boolean enabled = ElementHelper.getBooleanAttribute( elem,
"enabled" );
- boolean trusted = ElementHelper.getBooleanAttribute( elem,
"trusted" );
- String index = ElementHelper.getAttribute( elem, "index" );
- String scheme = ElementHelper.getAttribute( elem, "scheme" );
- String prompt = ElementHelper.getAttribute( elem, "prompt" );
- Element credentialsElement = ElementHelper.getChild( elem,
"credentials" );
- String username = getUsername( credentialsElement );
- char[] password = getPassword( credentialsElement );
- hosts[i] =
- new HostDirective(
- id, priority, url, index, username, password, enabled,
trusted,
- layout, scheme, prompt );
- }
- return hosts;
- }
-
- private String getUsername( Element element )
- {
- if( null == element )
- {
- return null;
- }
- else
- {
- return ElementHelper.getAttribute( element, "username" );
- }
- }
-
- private char[] getPassword( Element element )
- {
- if( null == element )
- {
- return null;
- }
- else
- {
- String password = ElementHelper.getAttribute( element,
"password" );
- if( null == password )
- {
- return null;
- }
- else
- {
- return password.toCharArray();
- }
- }
- }
-
- //-------------------------------------------------------------
- // internals supporting directive to XML transformation
- //-------------------------------------------------------------
-
- private void writeHeader( Writer writer, String cache, String layout )
throws IOException
- {
- writer.write( "\n\n<" + NAME + " cache=\"" + cache + "\" layout=\""
+ layout + "\">" );
- }
-
- private void writeFooter( Writer writer ) throws IOException
- {
- writer.write( "\n</" + NAME + ">" );
- }
-
- private void writeProxy( Writer writer, ProxyDirective proxy ) throws
IOException
- {
- if( null != proxy )
- {
- String host = proxy.getHost();
- String username = proxy.getUsername();
- String password = getPassword( proxy.getPassword() );
- String[] excludes = proxy.getExcludes();
-
- boolean credentials = ( ( null != username ) || ( null !=
password ) );
-
- if( excludes.length == 0 && ( !credentials ) )
- {
- writer.write(
- "\n <proxy host=\"" + host + "\"/>" );
- }
- else
- {
- writer.write( "\n <proxy host=\"" + host + "\">" );
- if( credentials )
- {
- writer.write( "\n <credentials" );
- if( null != username )
- {
- writer.write( " username=\"" + username + "\"" );
- }
- if( null != password )
- {
- writer.write( " password=\"" + password + "\"" );
- }
- writer.write( "/>" );
- }
- if( excludes.length > 0 )
- {
- writer.write( "\n <excludes>" );
- for( int i=0; i<excludes.length; i++ )
- {
- String exclude = excludes[i];
- writer.write( "\n <exclude>" + exclude +
"</exclude>" );
- }
- writer.write( "\n </excludes>" );
- }
-
- writer.write( "\n </proxy>" );
- }
- }
- }
-
- private void writeLocal( Writer writer, String path, String layout )
throws IOException
- {
- writer.write( "\n <local path=\"" + path + "\" layout=\"" + layout
+ "\"/>" );
- }
-
- private void writeHosts( Writer writer, HostDirective[] hosts ) throws
IOException
- {
- writer.write( "\n <hosts>" );
- for( int i=0; i<hosts.length; i++ )
- {
- HostDirective host = hosts[i];
- writeHost( writer, host );
- }
- writer.write( "\n </hosts>" );
- }
-
- private void writeHost( Writer writer, HostDirective host ) throws
IOException
- {
- String id = host.getID();
- int priority = host.getPriority();
- String url = host.getHost();
- boolean enabled = host.getEnabled();
- boolean trusted = host.getTrusted();
- String layout = host.getLayout();
- String index = host.getIndex();
- String scheme = host.getScheme();
- String prompt = host.getPrompt();
- String username = host.getUsername();
- String password = getPassword( host.getPassword() );
- boolean credentials = ( ( null != username ) || ( null != password )
);
-
- writer.write( "\n <host id=\"" + id + "\" priority=\"" + priority
+ "\" url=\"" + url + "\"" );
- if( !enabled )
- {
- writer.write( " enabled=\"false\"" );
- }
- if( trusted )
- {
- writer.write( " trusted=\"true\"" );
- }
- if( null != layout )
- {
- writer.write( " layout=\"" + layout + "\"" );
- }
- if( null != index )
- {
- writer.write( " index=\"" + index + "\"" );
- }
- if( ( null != scheme ) && !scheme.equals( "" ) )
- {
- writer.write( " scheme=\"" + scheme + "\"" );
- }
- if( ( null != prompt ) && !prompt.equals( "" ) )
- {
- writer.write( " prompt=\"" + prompt + "\"" );
- }
- if( credentials )
- {
- writer.write( "\n <credentials" );
- if( null != username )
- {
- writer.write( " username=\"" + username + "\"" );
- }
- if( null != password )
- {
- writer.write( " password=\"" + password + "\"" );
- }
- writer.write( "/>" );
- writer.write( "\n </host>" );
- }
- else
- {
- writer.write( "/>" );
- }
- }
-
- private String getPassword( char[] password )
- {
- if( null == password )
- {
- return null;
- }
- else
- {
- return new String( password );
- }
- }
-}

Added: trunk/main/transit/core/src/main/net/dpml/transit/TransitManager.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/TransitManager.java
2007-02-08 23:53:26 UTC (rev 1845)
+++ trunk/main/transit/core/src/main/net/dpml/transit/TransitManager.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -0,0 +1,68 @@
+/*
+ * Copyright 2006 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.
+ */
+
+package net.dpml.transit;
+
+import javax.management.MXBean;
+
+/**
+ * Transit management interface.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+@MXBean
+public interface TransitManager
+{
+ /**
+ * Return the Transit home directory.
+ * @return the home directory
+ */
+ String getHome();
+
+ /**
+ * Return the Transit data directory.
+ * @return the data directory
+ */
+ String getData();
+
+ /**
+ * Return the Transit prefs directory.
+ * @return the prefs directory
+ */
+ String getPrefs();
+
+ /**
+ * Return the Transit share directory.
+ * @return the share directory
+ */
+ String getShare();
+
+ /**
+ * Return the Transit version.
+ * @return the version string
+ */
+ String getVersion();
+
+ /**
+ * Return the Transit proxy host
+ * @return the host name
+ */
+ String getProxyHost();
+
+}
\ No newline at end of file

Deleted: trunk/main/transit/core/src/main/net/dpml/transit/ZipCache.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/ZipCache.java
2007-02-08 23:53:26 UTC (rev 1845)
+++ trunk/main/transit/core/src/main/net/dpml/transit/ZipCache.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -1,178 +0,0 @@
-/*
- * 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;
-
-import java.util.HashMap;
-import java.util.Iterator;
-
-import java.util.zip.ZipFile;
-
-/**
- * Internal cache.
- * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
- * @version @PROJECT-VERSION@
- */
-class ZipCache implements Runnable
-{
- private static final int TIME_TO_LIVE = 30000;
- private static final int DELAY = 10000;
-
- private HashMap m_store;
- private long m_timeToLive;
- private Thread m_thread;
-
- /**
- * Internal zip cache constructor.
- */
- ZipCache()
- {
- m_store = new HashMap();
- m_timeToLive = TIME_TO_LIVE;
- }
-
- ZipFile get( Artifact key )
- {
- synchronized( this ) // ensure no ConcurrentModificationException
can occur.
- {
- Entry entry = (Entry) m_store.get( key );
- if( entry == null )
- {
- return null;
- }
- ZipFile zip = entry.m_file;
- return zip;
- }
- }
-
- void put( Artifact key, ZipFile file )
- {
- synchronized( this ) // ensure no ConcurrentModificationException
can occur.
- {
- Entry entry = new Entry( file );
- m_store.put( key, entry );
- if( m_thread == null )
- {
- m_thread = new Thread( this, "DPML Transit Zip Cache
Cleaner" );
- m_thread.setDaemon( true );
- m_thread.start();
- }
- }
- }
-
- /**
- * Start the cache handler.
- */
- public void run()
- {
- while( true )
- {
- try
- {
- synchronized( this )
- {
- long now = System.currentTimeMillis();
- Iterator list = m_store.values().iterator();
- while( list.hasNext() )
- {
- Entry entry = (Entry) list.next();
- if( entry.m_collectTime < now )
- {
- entry.m_file.close();
- list.remove();
- }
- }
- if( m_store.size() == 0 )
- {
- m_thread = null;
- break;
- }
- wait( DELAY );
- }
- }
- catch( Exception e )
- {
- // Can not happen?
- // Just ignore and it will be handled in the next round.
- e.printStackTrace();
- }
- }
- }
-
- /**
- * Internal class that maintains a cache entry.
- */
- class Entry
- {
- private ZipFile m_file;
- private long m_collectTime;
-
- /**
- * Creation of a new zip cache entry.
- * @param file the zip file to cache
- */
- Entry( ZipFile file )
- {
- m_file = file;
- m_collectTime = System.currentTimeMillis() + m_timeToLive;
- }
-
- /**
- * Test this objexct for equality with another.
- * @param obj the other object
- * @return the equaility status
- */
- public boolean equals( Object obj )
- {
- if( obj == null )
- {
- return false;
- }
- if( !obj.getClass().equals( Entry.class ) )
- {
- return false;
- }
- Entry other = (Entry) obj;
-
- if( !m_file.equals( other.m_file ) )
- {
- return false;
- }
-
- return true;
- }
-
- /**
- * Retun the instance hashcode.
- * @return the hashcode value
- */
- public int hashCode()
- {
- return m_file.hashCode();
- }
-
- /**
- * Return a string represention of the cache entry.
- * @return the string value
- */
- public String toString()
- {
- return "Entry[" + m_file + ", " + m_collectTime + "]";
- }
- }
-}

Added: trunk/main/transit/core/src/main/net/dpml/transit/package-info.java
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/package-info.java
2007-02-08 23:53:26 UTC (rev 1845)
+++ trunk/main/transit/core/src/main/net/dpml/transit/package-info.java
2007-02-08 23:55:30 UTC (rev 1846)
@@ -0,0 +1,32 @@
+/*
+ * Copyright 2004-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.
+ */
+
+/**
+ * The transit package contains the primary runtime classes within the
Transit
+ * resource management system.
+ *
+ * The principal <a href="Transit.html">Transit</a> class is responsible for
the
+ * establishment of the Transit runtime based on a default or explicit
+ * <a href="info/TransitDirective.html">TransitDirective</a>. The Transit
class provides
+ * the internal machinery for a protocol handler dealing with the
"artifact", "link" and
+ * "local" uri schemes and the corresponding url protocol handlers.
+ *
+ * @author <a href="@PUBLISHER-URL@">@PUBLISHER-NAME@</a>
+ * @version @PROJECT-VERSION@
+ */
+package net.dpml.transit;

Deleted: trunk/main/transit/core/src/main/net/dpml/transit/package.html
===================================================================
--- trunk/main/transit/core/src/main/net/dpml/transit/package.html
2007-02-08 23:53:26 UTC (rev 1845)
+++ trunk/main/transit/core/src/main/net/dpml/transit/package.html
2007-02-08 23:55:30 UTC (rev 1846)
@@ -1,24 +0,0 @@
-
-<body>
-
-<p>
-The transit package contains the primary runtime classes within the Transit
-resource management system.
-</p>
-
-<p>
-The principal <a href="Transit.html">Transit</a> class is responsible for
the
-establishment of the Transit runtime based on a default or explicit
-<a href="model/TransitModel.html">TransitModel</a>. The Transit class
provides
-the internal machinery for a protocol handler dealing with the "artifact"
and
-"link" uri schemes and the corresponding url protocols. In addition Transit
-provides access to classloader construction services via the following
static
-operation:
-</p>
-
-<code>
- <a href="Repository.html">Repository</a>
Transit.getInstance().getRepository();
-</code>
-
-</body>
-




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

Archive powered by MHonArc 2.6.24.

Top of Page