/[Apache-SVN]/cocoon/whiteboard/block-deployer/src/impl/org/apache/cocoon/blockdeployer/block/BlockFactory.java
ViewVC logotype

Diff of /cocoon/whiteboard/block-deployer/src/impl/org/apache/cocoon/blockdeployer/block/BlockFactory.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

--- cocoon/whiteboard/block-deployer/src/impl/org/apache/cocoon/blockdeployer/block/RemoteBlockFactory.java	2005/03/25 14:29:38	159025
+++ cocoon/whiteboard/block-deployer/src/impl/org/apache/cocoon/blockdeployer/block/BlockFactory.java	2005/04/04 12:56:46	160036
@@ -38,37 +38,34 @@ import org.xml.sax.SAXException;
  * 
  * @since 0.1
  */
-public class RemoteBlockFactory {
+public class BlockFactory {
 
     /**
-     * Creates a RemoteBlock based on the descriptor and is called from
-     * a locator which wants to provide a RemoteBlock. (It's not the job of
+     * Creates a Block based on the descriptor and is called from
+     * a locator which wants to provide a Block. (It's not the job of
      * the locator to know where to find and how to read the descriptor file.)
      * 
      * @param descriptorString is a string containing the BlockDescription (block.xml)
-     * @return the RemoteBlock
+     * @return the Block
      */
     /*
-     * FIXME the factory should analyse the doctype of the descriptor (not the namespace)
      * FIXME the descriptor should be analyzed whether it is correct - otherwise raise an exception
      */
-    public static RemoteBlock getRemoteBlock(InputStream descriptor, Locator locator) {
+    public static Block getRemoteBlock(InputStream descriptor, Locator locator) {
         if(descriptor == null) {
             throw new NullPointerException("The descriptor mustn't be null.");
         }
         
-        RemoteBlock block = null;
+        Block block = null;
 
-        // analyse the descriptor and decide which RemoteBlock implementation should be used
+        // analyse the descriptor and decide which Block implementation should be used
         // by finding out the namespace of the root element
         DOMParser parser = new DOMParser();
         try {
 			parser.parse(new InputSource(descriptor));
-		} catch (SAXException e) {
-            
-		} catch (IOException e) {
-            
-		}
+		} catch (Exception e) {
+            throw new RuntimeException("Block descriptor can't be read.");
+        }
         Document descriptorDocument = parser.getDocument();   
         NodeList rootNodeList = descriptorDocument.getChildNodes();
         String namespace = null;
@@ -82,21 +79,21 @@ public class RemoteBlockFactory {
         
         if(Cob10.NAMESPACE.equals(namespace)) {
             // it's a Cob10 ...
-            Cob10 realRemoteBlock = new Cob10();
-            realRemoteBlock.setBlockDescriptor(createCOB10Descriptor(descriptorDocument));
-            realRemoteBlock.setBlockId(realRemoteBlock.getBlockDescriptor().getBlockId());
+            Cob10 cob10 = new Cob10();
+            cob10.setBlockDescriptor(createCOB10Descriptor(descriptorDocument));
+            cob10.setBlockId(cob10.getBlockDescriptor().getBlockId());
             if(locator == null) {
                 throw new NullPointerException("The locator mustn't be null.");
             }        
-            realRemoteBlock.setLocator(locator);
-            block = realRemoteBlock;
+            cob10.setLocator(locator);
+            block = cob10;
         }
         
         return block;
     }
     
     private static Cob10Descriptor createCOB10Descriptor(Node descriptor) {
-        Cob10Descriptor realBlockDescriptor = null;
+        Cob10Descriptor cob10Descriptor = null;
         try {
 	        Mapping mapping = new Mapping();
 	        mapping.loadMapping(Cob10Descriptor.class.getClassLoader().
@@ -107,11 +104,11 @@ public class RemoteBlockFactory {
 	        unmarshaller.setIgnoreExtraAttributes(true);
 	        unmarshaller.setIgnoreExtraElements(true);
 	        // unmarshaller.setDebug(true);
-	        realBlockDescriptor = (Cob10Descriptor)unmarshaller.unmarshal(descriptor);
+	        cob10Descriptor = (Cob10Descriptor)unmarshaller.unmarshal(descriptor);
         } catch(Exception e) {
             throw new RuntimeException(e);
         }
-        return realBlockDescriptor;
+        return cob10Descriptor;
     }
     
 }

 

infrastructure at apache.org
ViewVC Help
Powered by ViewVC 1.1.26