notify-dpml AT lists.ibiblio.org
Subject: DPML Notify
List archive
svn commit: r2071 - in development/laboratory/plus: api/kernel/src/main/net/dpml/metro/home core/src/main/net/dpml/metro/home/impl
- From: mcconnell AT dpml.net
- To: notify-dpml AT lists.ibiblio.org
- Subject: svn commit: r2071 - in development/laboratory/plus: api/kernel/src/main/net/dpml/metro/home core/src/main/net/dpml/metro/home/impl
- Date: Mon, 14 Mar 2005 14:47:52 -0500
Author: mcconnell AT dpml.net
Date: Mon Mar 14 14:47:50 2005
New Revision: 2071
Added:
development/laboratory/plus/api/kernel/src/main/net/dpml/metro/home/PartNotFoundException.java
Modified:
development/laboratory/plus/api/kernel/src/main/net/dpml/metro/home/Home.java
development/laboratory/plus/core/src/main/net/dpml/metro/home/impl/TransitHome.java
Log:
Modified:
development/laboratory/plus/api/kernel/src/main/net/dpml/metro/home/Home.java
==============================================================================
---
development/laboratory/plus/api/kernel/src/main/net/dpml/metro/home/Home.java
(original)
+++
development/laboratory/plus/api/kernel/src/main/net/dpml/metro/home/Home.java
Mon Mar 14 14:47:50 2005
@@ -21,6 +21,7 @@
import java.net.URI;
import java.io.IOException;
+import net.dpml.metro.part.Part;
import net.dpml.metro.part.PartHandler;
/**
@@ -32,5 +33,6 @@
*/
public interface Home
{
+ Part loadPart( URI uri ) throws HandlerNotFoundException, IOException;
PartHandler resolvePartHandler( URI uri ) throws
HandlerNotFoundException, IOException;
}
Added:
development/laboratory/plus/api/kernel/src/main/net/dpml/metro/home/PartNotFoundException.java
==============================================================================
--- (empty file)
+++
development/laboratory/plus/api/kernel/src/main/net/dpml/metro/home/PartNotFoundException.java
Mon Mar 14 14:47:50 2005
@@ -0,0 +1,50 @@
+/*
+ * Copyright (c) 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.metro.home;
+
+import java.net.URL;
+
+/**
+ * Exception thrown when an attempt is made to reference an unknown part.
+ *
+ * @author <a href="mailto:dev-dpml AT lists.ibiblio.org";>The Digital Product
Meta Library</a>
+ * @version $Revision: 1.2 $ $Date: 2004/03/17 10:30:09 $
+ */
+public class PartNotFoundException extends HomeException
+{
+ private URL m_url;
+
+ public PartNotFoundException( URL url )
+ {
+ this( url, null );
+ }
+
+ public PartNotFoundException( URL url, Exception cause )
+ {
+ super( url.toString(), cause );
+ m_url = url;
+ }
+
+ public URL getURL()
+ {
+ return m_url;
+ }
+
+}
+
Modified:
development/laboratory/plus/core/src/main/net/dpml/metro/home/impl/TransitHome.java
==============================================================================
---
development/laboratory/plus/core/src/main/net/dpml/metro/home/impl/TransitHome.java
(original)
+++
development/laboratory/plus/core/src/main/net/dpml/metro/home/impl/TransitHome.java
Mon Mar 14 14:47:50 2005
@@ -28,6 +28,7 @@
import net.dpml.metro.home.HomeRuntimeException;
import net.dpml.metro.part.PartHandler;
import net.dpml.metro.part.Handler;
+import net.dpml.metro.part.Part;
import net.dpml.transit.repository.StandardLoader;
import net.dpml.transit.TransitException;
@@ -59,6 +60,47 @@
}
}
+ public Part loadPart( URI url ) throws PartNotFoundException,
HandlerNotFoundException, IOException
+ {
+ InputStream input = url.openStream();
+ if( null == input )
+ {
+ throw new PartNotFoundException( uri );
+ }
+ ObjectInputStream stream = new ObjectInputStream( input );
+ try
+ {
+ PartHolder holder = (PartHolder) stream.readObject();
+ URI uri = holder.getPartHandlerURI();
+ PartHandler handler = resolvePartHandler( uri );
+ return handler.loadPart( uri, holder.getByteArray() );
+ }
+ catch( IOException e )
+ {
+ final String error =
+ "IO error while attempting to load the part ["
+ + url
+ + "].";
+ throw new HandlerNotFoundException( error, e );
+ }
+ catch( HandlerNotFoundException e )
+ {
+ final String error =
+ "Could not locate the handler for the part ["
+ + url
+ + "].";
+ throw new HandlerNotFoundException( error, e );
+ }
+ catch( Throwable e )
+ {
+ final String error =
+ "Internal error while attempting to load a part form the url ["
+ + url
+ + "].";
+ throw new HomeRuntimeException( error, e );
+ }
+ }
+
public PartHandler resolvePartHandler( URI uri ) throws
HandlerNotFoundException, IOException
{
Handler handler = resolveHandler( uri );
- svn commit: r2071 - in development/laboratory/plus: api/kernel/src/main/net/dpml/metro/home core/src/main/net/dpml/metro/home/impl, mcconnell, 03/14/2005
Archive powered by MHonArc 2.6.24.