portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wea...@apache.org
Subject cvs commit: jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/deployment/impl DeployDecoratorEventListener.java
Date Wed, 14 Jan 2004 19:32:57 GMT
weaver      2004/01/14 11:32:57

  Added:       portal/src/java/org/apache/jetspeed/deployment/simpleregistry
                        SimpleRegistry.java Entry.java
                        SimpleRegistryException.java
               portal/src/java/org/apache/jetspeed/deployment/fs
                        FileSystemScanner.java FileObjectHandler.java
                        JARObjectHandlerImpl.java FSObjectHandler.java
               portal/src/java/org/apache/jetspeed/deployment
                        DeploymentEvent.java DeploymentEventListener.java
                        DeploymentHandler.java DeploymentEventImpl.java
                        DeploymentEventDispatcher.java
                        DeploymentException.java
               portal/src/java/org/apache/jetspeed/deployment/simpleregistry/impl
                        InMemoryRegistryImpl.java
               portal/src/java/org/apache/jetspeed/deployment/impl
                        DeployDecoratorEventListener.java
  Log:
  First run at a FileScanning deployment system to be used in conjunction with the PAM
  
  Revision  Changes    Path
  1.1                  jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/deployment/simpleregistry/SimpleRegistry.java
  
  Index: SimpleRegistry.java
  ===================================================================
  /**
   * Created on Jan 13, 2004
   *
   * 
   * @author
   */
  package org.apache.jetspeed.deployment.simpleregistry;
  
  import java.util.Collection;
  import java.util.List;
  
  /**
   * <p>
   * SimpleRegistry
   * </p>
   * <p>
   *   This is an interface for creating simple registry systems.  A good example would be an
   *   in memory registry that gets populate at runtime and is lost on shutdown.
   * 
   * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
   * @version $Id: SimpleRegistry.java,v 1.1 2004/01/14 19:32:57 weaver Exp $
   *
   */
  public interface SimpleRegistry
  {
  	/**
  	 * Registers the entry.
  	 * 
  	 * @throws java.lang.IllegalAgrumentException in <code>entry</code> is null or
  	 * <code>entry.getId()</code> is null
  	 * @throws org.apache.jetspeed.cps.simpleregistry if this <code>entry</code> is 
  	 * already registered.
  	 * @param entry
  	 */
  	public void register(Entry entry) throws SimpleRegistryException;
  	
  	/**
  	 * De-registers the entry
  	 * @param entry
  	 * @throws java.lang.IllegalAgrumentException in <code>entry</code> is null or
  	 * <code>entry.getId()</code> is null
  	 */
  	public void deRegister(Entry entry);
  	
  	/**
  	 * Verifies whether or not this entry is registered.
  	 * @param entry
  	 * 
  	 * @return boolean <code>true</code> is the <code>entry</code> is registered
  	 * otherwise <code>false</code>.
  	 * @throws java.lang.IllegalAgrumentException in <code>entry</code> is null or
  	 * <code>entry.getId()</code> is null
  	 */
  	public boolean isRegistered(Entry entry);
  	
  	/**
  	 * Provides a Cloolection of <code>org.apache.jetspeed.cps.simpleregistry.Entry</code>
  	 * objects that are currently registered to this registery
  	 * @return
  	 */	
  	public Collection getRegistry();
  
  }
  
  
  
  1.1                  jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/deployment/simpleregistry/Entry.java
  
  Index: Entry.java
  ===================================================================
  /**
   * Created on Jan 13, 2004
   *
   * 
   * @author
   */
  package org.apache.jetspeed.deployment.simpleregistry;
  
  import java.util.HashMap;
  import java.util.Map;
  
  /**
   * <p>
   * Entry
   * </p>
   * Simple data type representing some regitered resource.
   * 
   * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
   * @version $Id: Entry.java,v 1.1 2004/01/14 19:32:57 weaver Exp $
   *
   */
  public class Entry
  {
  	private String id;
  	private Map attributes;
  	
  	public Entry()
  	{
  		super();
  		attributes = new HashMap();
  	}
  
      /**
       * @return
       */
      public String getId()
      {
          return id;
      }
  
      /**
       * @param string
       */
      public void setId(String string)
      {
          id = string;
      }
      
      public Object getAttribute(String key)
      {
      	return attributes.get(key);
      }
      
      public void setAttribute(String key, Object value)
      {
      	attributes.put(key, value);
      }
  
      /**
       * @see java.lang.Object#equals(java.lang.Object)
       */
      public boolean equals(Object obj)
      {        
          if(obj != null && obj instanceof Entry)
          {
          	Entry entry = (Entry) obj;
          	return entry.getId() != null && getId() != null && getId().equals(entry.getId());
          }
          
          return false;
      }
  
      /**
       * @see java.lang.Object#hashCode()
       */
      public int hashCode()
      {        
          return toString().hashCode();
      }
  
      public String toString()
      {
          return getClass().toString().toString()+":"+getId();
      }
  
     
  
  }
  
  
  
  1.1                  jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/deployment/simpleregistry/SimpleRegistryException.java
  
  Index: SimpleRegistryException.java
  ===================================================================
  /**
   * Created on Jan 13, 2004
   *
   * 
   * @author
   */
  package org.apache.jetspeed.deployment.simpleregistry;
  
  import org.apache.jetspeed.exception.JetspeedException;
  
  /**
   * <p>
   * SimpleRegistryException
   * </p>
   * 
   * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
   * @version $Id: SimpleRegistryException.java,v 1.1 2004/01/14 19:32:57 weaver Exp $
   *
   */
  public class SimpleRegistryException extends JetspeedException
  {
  
      /**
       * 
       */
      public SimpleRegistryException()
      {
          super();        
      }
  
      /**
       * @param message
       */
      public SimpleRegistryException(String message)
      {
          super(message);        
      }
  
      /**
       * @param nested
       */
      public SimpleRegistryException(Throwable nested)
      {
          super(nested);        
      }
  
      /**
       * @param msg
       * @param nested
       */
      public SimpleRegistryException(String msg, Throwable nested)
      {
          super(msg, nested);        
      }
  
  }
  
  
  
  1.1                  jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/deployment/fs/FileSystemScanner.java
  
  Index: FileSystemScanner.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Jetspeed" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Jetspeed", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.jetspeed.deployment.fs;
  
  import java.io.File;
  import java.io.FileNotFoundException;
  import java.io.FilenameFilter;
  import java.io.IOException;
  import java.util.ArrayList;
  import java.util.List;
  import java.util.Map;
  import java.util.Set;
  
  import org.apache.commons.configuration.Configuration;
  import org.apache.commons.configuration.PropertiesConfiguration;
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  import org.apache.jetspeed.deployment.DeploymentEvent;
  import org.apache.jetspeed.deployment.DeploymentEventDispatcher;
  import org.apache.jetspeed.deployment.DeploymentEventImpl;
  
  /**
   * <p>
   * FileSystemWatcher
   * </p>
   * 
   * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
   * @version $Id: FileSystemScanner.java,v 1.1 2004/01/14 19:32:57 weaver Exp $
   *
   */
  public class FileSystemScanner extends Thread
  {
      private String directoryToWatch;
      private File directoryToWatchFile;
      private FilenameFilter filter;
      private Map fileTypeHandlers;
      private long delay;
      private DeploymentEventDispatcher dispatcher;
      private Map fileDates;
      private boolean started = true;
      private List deployedFiles;
      private String configPath;
  
      private static final Log log = LogFactory.getLog(FileSystemScanner.class);
  
      public FileSystemScanner(
          String directoryToWatch,
          Map fileTypeHandlers,
          DeploymentEventDispatcher dispatcher,
          long delay,
          String configPath) throws FileNotFoundException, IOException
      {
          this.directoryToWatch = directoryToWatch;
          this.directoryToWatchFile = new File(directoryToWatch);
          if(!directoryToWatchFile.exists())
          {
          	throw new FileNotFoundException(directoryToWatchFile.getCanonicalFile()+" does not exist.");
          }
          this.fileTypeHandlers = fileTypeHandlers;
          this.delay = delay;
          this.dispatcher = dispatcher;
          this.deployedFiles = new ArrayList();
          this.configPath = configPath;
  
          Set fileExtensions = fileTypeHandlers.keySet();
          this.filter = new AllowedFileTypeFilter((String[]) fileExtensions.toArray(new String[1]));        
          setPriority(MIN_PRIORITY);
      }
  
      /**
       * @see java.lang.Runnable#run()
       */
      public void run()
      {
          while (started)
          {
              File[] stagedFiles = getStagedFiles();
              undeployRemovedArtifacts(stagedFiles);
              redeployChangedArtifacts(stagedFiles);
              deployNewArtifacts(stagedFiles);
  
              try
              {
                  sleep(delay);
              }
              catch (InterruptedException e)
              {
  
              }
          }
      }
  
      /**
       * notifies a switch variable that exits the watcher's montior loop started in the <code>run()</code>
       * method.      
       *
       */
      public void safeStop()
      {
          started = false;
      }
  
      private void deployNewArtifacts(File[] stagedFiles)
      {
          for (int i = 0; i < stagedFiles.length; i++)
          {
              // check for new deployment
              File aFile = stagedFiles[i];
              if (!isDeployed(aFile))
              {
                  
                  
                  try
                  {
  					FSObjectHandler objHandler = getFSObjectHandler(aFile);                    
                      
                      DeploymentEvent event =
                          new DeploymentEventImpl(DeploymentEvent.EVENT_TYPE_DEPLOY, objHandler);
                      dispatcher.dispatch(event);
                      // we are responsible for reclaiming the FSObject's resource
                      objHandler.close();
                      deployedFiles.add(aFile);
                      // record the lastModified so we can watch for re-deployment
                      fileDates.put(aFile, new Long(aFile.lastModified()));
  
                  }
                  catch (Exception e1)
                  {
                      log.error("Error deploying " + aFile.getAbsolutePath(), e1);
                  }
              }
          }
      }
  
      protected boolean isDeployed(File aFile)
      {
          return deployedFiles.contains(aFile);
      }
  
      private void redeployChangedArtifacts(File[] stagedFiles)
      {
  
      }
  
      private void undeployRemovedArtifacts(File[] stagedFiles)
      {
  
      }
  
      protected File[] getStagedFiles()
      {
          return this.directoryToWatchFile.listFiles(this.filter);
  		// return this.directoryToWatchFile.listFiles();
      }
  
      protected FSObjectHandler getFSObjectHandler(File file) throws Exception
      {
          String name = file.getName();
          int extIndex = name.lastIndexOf('.');
          if (extIndex != -1 && (extIndex + 1) < name.length())
          {
              String extension = name.substring(extIndex + 1);
               Class fsoClass = (Class) fileTypeHandlers.get(extension);
  			FSObjectHandler fso = (FSObjectHandler) fsoClass.newInstance();
              fso.setFile(file);
              return fso;
          }
          else
          {
              FSObjectHandler fso = new FileObjectHandler();
              fso.setFile(file);
              return fso;
          }
      }
  
      class AllowedFileTypeFilter implements FilenameFilter
      {
          private String[] fileTypes;
  
          public AllowedFileTypeFilter(String[] fileTypes)
          {
              this.fileTypes = fileTypes;
          }
  
          /**
           * @see java.io.FilenameFilter#accept(java.io.File, java.lang.String)
           */
          public boolean accept(File dir, String name)
          {
              if (fileTypes != null)
              {
  
                  int extIndex = name.lastIndexOf('.');
                  if (extIndex != -1 && (extIndex + 1) < name.length())
                  {
                      String extension = name.substring(extIndex + 1);
                      for (int i = 0; i < fileTypes.length; i++)
                      {
                          if (fileTypes[i].equalsIgnoreCase(extension))
                          {
                              return true;
                          }
                      }
                  }
              }
              else
              {
                  // null fileTypes == directories only!
                  return new File(dir + File.separator + name).isDirectory();
  
              }
              return false;
          }
  
      }
  
  }
  
  
  
  1.1                  jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/deployment/fs/FileObjectHandler.java
  
  Index: FileObjectHandler.java
  ===================================================================
  /**
   * Created on Jan 13, 2004
   *
   * 
   * @author
   */
  package org.apache.jetspeed.deployment.fs;
  
  import java.io.File;
  import java.io.FileInputStream;
  import java.io.FileReader;
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.Reader;
  
  import javax.imageio.stream.FileImageInputStream;
  
  import org.apache.commons.configuration.Configuration;
  
  /**
   * <p>
   * FileObjectHandler
   * </p>
   * 
   * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
   * @version $Id: FileObjectHandler.java,v 1.1 2004/01/14 19:32:57 weaver Exp $
   *
   */
  public class FileObjectHandler implements FSObjectHandler
  {
  
      protected File file;
  	private InputStream content;
  
      /**
       * @see org.apache.jetspeed.deployment.fs.FSObjectHandler#getPath()
       */
      public String getPath()
      {        
          return file.getAbsolutePath();
      }
  
      /**
       * @see org.apache.jetspeed.deployment.fs.FSObjectHandler#setPath(java.lang.String)
       */
      public void setPath(String path)
      {
          file = new File(path);
      }
  
      /**
       * @see org.apache.jetspeed.deployment.fs.FSObjectHandler#setFile(java.io.File)
       */
      public void setFile(File file)
      {
          this.file = file;
  
      }
  
      /**
       * @see org.apache.jetspeed.deployment.fs.FSObjectHandler#getAsStream()
       */
      public InputStream getAsStream() throws IOException
      {
          if (content == null)
          {
              content = new FileInputStream(file);
          }
          return content;
      }
  
      /**
       * @see org.apache.jetspeed.deployment.fs.FSObjectHandler#getAsReader()
       */
      public Reader getAsReader() throws IOException
      {
          return new FileReader(file);
      }
  
      /**
       * @see org.apache.jetspeed.deployment.fs.FSObjectHandler#close()
       */
      public void close() throws IOException
      {
          if(content != null)
          {
          	content.close();	
          }
      }
  
      /**
       * @see org.apache.jetspeed.deployment.fs.FSObjectHandler#getConfiguration()
       */
      public Configuration getConfiguration(String configPath)
      {
          // TODO Auto-generated method stub
          return null;
      }
  
  }
  
  
  
  1.1                  jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/deployment/fs/JARObjectHandlerImpl.java
  
  Index: JARObjectHandlerImpl.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Jetspeed" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Jetspeed", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.jetspeed.deployment.fs;
  
  import java.io.File;
  import java.io.FileInputStream;
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.InputStreamReader;
  import java.io.Reader;
  import java.util.jar.JarEntry;
  import java.util.jar.JarFile;
  import java.util.jar.JarInputStream;
  
  import org.apache.commons.configuration.Configuration;
  import org.apache.commons.configuration.PropertiesConfiguration;
  
  /**
   * <p>
   * JARObjectHandlerImpl
   * </p>
   * 
   * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
   * @version $Id: JARObjectHandlerImpl.java,v 1.1 2004/01/14 19:32:57 weaver Exp $
   *
   */
  public class JARObjectHandlerImpl implements FSObjectHandler
  {
  	private File jar;
  	private JarInputStream content;
  	
      private JarFile jarFile;
      /**
       * @see org.apache.jetspeed.deployment.fs.FSObjectHandler#getPath()
       */
      public String getPath()
      {        
          return jar.getAbsolutePath();
      }
  
      /**
       * @see org.apache.jetspeed.deployment.fs.FSObjectHandler#setPath(java.lang.String)
       */
      public void setPath(String path)
      {
          this.jar = new File(path); 
  
      }
  
      /**
       * @see org.apache.jetspeed.deployment.fs.FSObjectHandler#setFile(java.io.File)
       */
      public void setFile(File file) throws IOException
      {        
          jar = file;
  		jarFile = new JarFile(jar);
      }
  
      /**
       * @see org.apache.jetspeed.deployment.fs.FSObjectHandler#getAsStream()
       */
      public InputStream getAsStream() throws IOException
      {        
      	if(content == null)
      	{
  			content = new JarInputStream(new FileInputStream(jar));
              
      	}
          return content;
      }
  
      /**
       * @see org.apache.jetspeed.deployment.fs.FSObjectHandler#getAsReader()
       */
      public Reader getAsReader() throws IOException
      {        
          return new InputStreamReader(getAsStream());
      }  
      /**
       * @see org.apache.jetspeed.deployment.fs.FSObjectHandler#close()
       */
      public void close() throws IOException
      {
          if(content != null)
          {
          	content.close();
          }
  
      }
  
      /**
       * @see org.apache.jetspeed.deployment.fs.FSObjectHandler#getConfiguration()
       */
      public Configuration getConfiguration(String configPath) throws IOException
      {
      	JarEntry jarEntry = jarFile.getJarEntry(configPath);
      	InputStream configStream = jarFile.getInputStream(jarEntry);
  		PropertiesConfiguration conf = new PropertiesConfiguration();
      	conf.load(configStream);
      	return conf;       
      }
  
  }
  
  
  
  1.1                  jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/deployment/fs/FSObjectHandler.java
  
  Index: FSObjectHandler.java
  ===================================================================
  /**
   * Created on Dec 24, 2003
   *
   * 
   * @author
   */
  package org.apache.jetspeed.deployment.fs;
  
  import java.io.File;
  import java.io.IOException;
  
  import org.apache.jetspeed.deployment.DeploymentHandler;
  
  
  /**
   * <p>
   * FSObjectHandler
   * </p>
   * 
   * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
   * @version $Id: FSObjectHandler.java,v 1.1 2004/01/14 19:32:57 weaver Exp $
   *
   */
  public interface FSObjectHandler extends DeploymentHandler
  {
  	String getPath();
  	
  	void setPath(String path);
  	
  	void setFile(File file) throws IOException;
  	
  
  }
  
  
  
  1.1                  jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/deployment/DeploymentEvent.java
  
  Index: DeploymentEvent.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Jetspeed" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Jetspeed", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.jetspeed.deployment;
  
  import java.io.InputStream;
  
  import org.apache.commons.configuration.Configuration;
  
  /**
   * <p>
   * DeploymentEvent
   * </p>
   * <p>
   * A <code>DeploymentEvent</code> is fired when a DeploymentEventDispatcher is notified that
   * a deployment event has occurred, for example, a JAR file being drop into a specific directory.
   * </p>
   * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
   * @version $Id: DeploymentEvent.java,v 1.1 2004/01/14 19:32:57 weaver Exp $
   *
   */
  public interface DeploymentEvent 
  {
      /** Standard deployment event */
      String EVENT_TYPE_DEPLOY = "deploy";
      /** Standard re-deployment event */
      String EVENT_TYPE_REDEPLOY = "redeploy";
      /** Standard un-deployment event */
      String EVENT_TYPE_UNDEPLOY = "undeploy";
  	
  	/**
  	 * Returns the type of event this is.  You can use one of the three pre-defined types
  	 * or use a custom one as event types are freeform.
  	 * @return String this event's type.
  	 */
  	String getEventType();
  	
  	/**
  	 * This is the absolute path where content for this event should be deployed to.
  	 * @return String absolute path to the final home of the deployed content.
  	 */
  	String getDeploymentRoot();
  	
  	void setDeploymentRoot(String deploymentRoot);
  	
  
  	/**
  	 * Returns an <code>java.io.InputStream</code> containing the deployed content.  Most often
  	 * this will be a <code>java.utiljar.JARInputStream</code>.
  	 * @return InputStream containing the information to be deployed.
  	 */	
  	DeploymentHandler getHandler();
  	
  }
  
  
  
  1.1                  jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/deployment/DeploymentEventListener.java
  
  Index: DeploymentEventListener.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Jetspeed" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Jetspeed", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.jetspeed.deployment;
  
  /**
   * <p>
   * DeploymentEventListener
   * </p>
   * 
   * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
   * @version $Id: DeploymentEventListener.java,v 1.1 2004/01/14 19:32:57 weaver Exp $
   *
   */
  public interface DeploymentEventListener
  {
  	public void invoke(DeploymentEvent event) throws DeploymentException;
  	
  }
  
  
  
  1.1                  jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/deployment/DeploymentHandler.java
  
  Index: DeploymentHandler.java
  ===================================================================
  /**
   * Created on Jan 14, 2004
   *
   * 
   * @author
   */
  package org.apache.jetspeed.deployment;
  
  import java.io.IOException;
  import java.io.InputStream;
  import java.io.Reader;
  
  import org.apache.commons.configuration.Configuration;
  
  /**
   * <p>
   * DeploymentHandler
   * </p>
   * 
   * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
   * @version $Id: DeploymentHandler.java,v 1.1 2004/01/14 19:32:57 weaver Exp $
   *
   */
  public interface DeploymentHandler
  {
  
  	
  	InputStream getAsStream() throws IOException;
  	
  	Reader getAsReader() throws IOException;
  	
  	void close() throws IOException;
  	
  	Configuration getConfiguration(String configPath) throws IOException;
  		
  
  }
  
  
  
  1.1                  jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/deployment/DeploymentEventImpl.java
  
  Index: DeploymentEventImpl.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Jetspeed" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Jetspeed", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.jetspeed.deployment;
  
  import java.io.InputStream;
  
  import org.apache.commons.configuration.Configuration;
  
  /**
   * <p>
   * DeploymentEventImpl
   * </p>
   * 
   * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
   * @version $Id: DeploymentEventImpl.java,v 1.1 2004/01/14 19:32:57 weaver Exp $
   *
   */
  public class DeploymentEventImpl implements DeploymentEvent
  {
  	
  	private String type;
  	private DeploymentHandler handler;
  	private String deploymentRoot;
  	
  
      /**
       * 
       */
      public DeploymentEventImpl(String type, DeploymentHandler handler, String depRoot)
      {
          super();
          this.type = type;
          this.handler = handler;
          this.deploymentRoot = depRoot;
          
          
      }
      
  	public DeploymentEventImpl(String type, DeploymentHandler handler)
  	{
  		super();
  		this.type = type;
  		this.handler = handler;        
  	}
  
      /**
       * @see org.apache.jetspeed.deployment.DeploymentEvent#getEventType()
       */
      public String getEventType()
      {        
          return this.type;
      }
  
      /**
       * @see org.apache.jetspeed.deployment.DeploymentEvent#getDeploymentRoot()
       */
      public String getDeploymentRoot()
      {        
          return this.deploymentRoot;
      }
  
      /**
       * @param string
       */
      public void setDeploymentRoot(String string)
      {
          deploymentRoot = string;
      }
  
  
      /**
       * @see org.apache.jetspeed.deployment.DeploymentEvent#getHandler()
       */
      public DeploymentHandler getHandler()
      {        
          return handler;
      }
  
  }
  
  
  
  1.1                  jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/deployment/DeploymentEventDispatcher.java
  
  Index: DeploymentEventDispatcher.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Jetspeed" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Jetspeed", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.jetspeed.deployment;
  
  import java.util.ArrayList;
  import java.util.Iterator;
  import java.util.List;
  
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  
  /**
   * <p>
   * DeploymentEventDispatcher
   * </p>
   * 
   * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
   * @version $Id: DeploymentEventDispatcher.java,v 1.1 2004/01/14 19:32:57 weaver Exp $
   *
   */
  public class DeploymentEventDispatcher
  {
      private List deploymentListeners;
      private String deploymentRoot;
      
      private static final Log log = LogFactory.getLog(DeploymentEventDispatcher.class);
      
  
      public DeploymentEventDispatcher(String deploymentRoot)
      {
  		deploymentListeners = new ArrayList();        
  		this.deploymentRoot = deploymentRoot;
      }
      
      public void addDeploymentListener(DeploymentEventListener listener)
      {
  		deploymentListeners.add(listener);
      }
      
      public void dispatch(DeploymentEvent event)
      {
      	Iterator itr = deploymentListeners.iterator();
      	event.setDeploymentRoot(deploymentRoot);
      	while(itr.hasNext())
      	{
      		DeploymentEventListener listener = (DeploymentEventListener) itr.next();
      		try
              {
                  listener.invoke(event);
              }
              catch (DeploymentException e)
              {   
              	// log and continue
              	             
                  
              }
      	}
      }
  
      
  
  }
  
  
  
  1.1                  jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/deployment/DeploymentException.java
  
  Index: DeploymentException.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2000-2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, are permitted provided that the following conditions
   * are met:
   *
   * 1. Redistributions of source code must retain the above copyright
   *    notice, this list of conditions and the following disclaimer.
   *
   * 2. Redistributions in binary form must reproduce the above copyright
   *    notice, this list of conditions and the following disclaimer in
   *    the documentation and/or other materials provided with the
   *    distribution.
   *
   * 3. The end-user documentation included with the redistribution,
   *    if any, must include the following acknowledgment:
   *       "This product includes software developed by the
   *        Apache Software Foundation (http://www.apache.org/)."
   *    Alternately, this acknowledgment may appear in the software itself,
   *    if and wherever such third-party acknowledgments normally appear.
   *
   * 4. The names "Apache" and "Apache Software Foundation" and
   *    "Apache Jetspeed" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Jetspeed", nor may "Apache" appear in their name, without
   *    prior written permission of the Apache Software Foundation.
   *
   * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
   * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
   * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
   * DISCLAIMED.  IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
   * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
   * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
   * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
   * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
   * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
   * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
   * SUCH DAMAGE.
   * ====================================================================
   *
   * This software consists of voluntary contributions made by many
   * individuals on behalf of the Apache Software Foundation.  For more
   * information on the Apache Software Foundation, please see
   * <http://www.apache.org/>.
   */
  package org.apache.jetspeed.deployment;
  
  import org.apache.commons.lang.exception.NestableException;
  
  /**
   * <p>
   * DeploymentException
   * </p>
   * 
   * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
   * @version $Id: DeploymentException.java,v 1.1 2004/01/14 19:32:57 weaver Exp $
   *
   */
  public class DeploymentException extends NestableException
  {
  
      /**
       * 
       */
      public DeploymentException()
      {
          super();
          // TODO Auto-generated constructor stub
      }
  
      /**
       * @param arg0
       */
      public DeploymentException(String arg0)
      {
          super(arg0);
          // TODO Auto-generated constructor stub
      }
  
      /**
       * @param arg0
       */
      public DeploymentException(Throwable arg0)
      {
          super(arg0);
          // TODO Auto-generated constructor stub
      }
  
      /**
       * @param arg0
       * @param arg1
       */
      public DeploymentException(String arg0, Throwable arg1)
      {
          super(arg0, arg1);
          // TODO Auto-generated constructor stub
      }
  
  }
  
  
  
  1.1                  jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/deployment/simpleregistry/impl/InMemoryRegistryImpl.java
  
  Index: InMemoryRegistryImpl.java
  ===================================================================
  /**
   * Created on Jan 13, 2004
   *
   * 
   * @author
   */
  package org.apache.jetspeed.deployment.simpleregistry.impl;
  
  import java.util.Collection;
  import java.util.HashMap;
  import java.util.Map;
  
  import org.apache.jetspeed.deployment.simpleregistry.Entry;
  import org.apache.jetspeed.deployment.simpleregistry.SimpleRegistry;
  import org.apache.jetspeed.deployment.simpleregistry.SimpleRegistryException;
  
  /**
   * <p>
   * InMemoryRegistryImpl
   * </p>
   * 
   * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
   * @version $Id: InMemoryRegistryImpl.java,v 1.1 2004/01/14 19:32:57 weaver Exp $
   *
   */
  public class InMemoryRegistryImpl implements SimpleRegistry
  {
  	protected Map registry;
  	
  	public InMemoryRegistryImpl()
  	{
  		super();
  		registry = new HashMap();
  	}
  
      /**
       * @see org.apache.jetspeed.cps.simpleregistry.SimpleRegistry#register(org.apache.jetspeed.cps.simpleregistry.Entry)
       */
      public void register(Entry entry) throws SimpleRegistryException
      {
      	checkArguments(entry);	
          if(!isRegistered(entry))
          {
          	registry.put(entry.getId(), entry);
          }
          else
          {
          	throw new SimpleRegistryException(entry.getId()+" is already registered.");
          }
  
      }
  
      /**
       * @see org.apache.jetspeed.cps.simpleregistry.SimpleRegistry#deRegister(org.apache.jetspeed.cps.simpleregistry.Entry)
       */
      public void deRegister(Entry entry)
      {
          checkArguments(entry);
          registry.remove(entry.getId());
  
      }
  
      /**
       * @see org.apache.jetspeed.cps.simpleregistry.SimpleRegistry#isRegistered(org.apache.jetspeed.cps.simpleregistry.Entry)
       */
      public boolean isRegistered(Entry entry)
      {        
      	checkArguments(entry);
          return registry.containsKey(entry.getId());
      }
  
      /**
       * @see org.apache.jetspeed.cps.simpleregistry.SimpleRegistry#getRegistry()
       */
      public Collection getRegistry()
      {
          return registry.values();
      }
      
      protected void checkArguments(Entry entry)
      {
      	if(entry == null )
      	{
      		throw new IllegalArgumentException("Entry cannot be null.");
      	}
      	
  		if(entry.getId() == null )
  		{
  			throw new IllegalArgumentException("Entry.getId() cannot be null.");
  		}
      }
  
  }
  
  
  
  1.1                  jakarta-jetspeed-2/portal/src/java/org/apache/jetspeed/deployment/impl/DeployDecoratorEventListener.java
  
  Index: DeployDecoratorEventListener.java
  ===================================================================
  /**
   * Created on Jan 13, 2004
   *
   * 
   * @author
   */
  package org.apache.jetspeed.deployment.impl;
  
  import java.io.File;
  import java.io.FileOutputStream;
  import java.io.IOException;
  import java.util.jar.JarEntry;
  import java.util.jar.JarInputStream;
  
  import org.apache.commons.configuration.Configuration;
  import org.apache.commons.logging.Log;
  import org.apache.commons.logging.LogFactory;
  import org.apache.jetspeed.deployment.DeploymentEvent;
  import org.apache.jetspeed.deployment.DeploymentEventListener;
  import org.apache.jetspeed.deployment.DeploymentException;
  import org.apache.jetspeed.deployment.simpleregistry.Entry;
  import org.apache.jetspeed.deployment.simpleregistry.SimpleRegistry;
  import org.apache.jetspeed.deployment.simpleregistry.SimpleRegistryException;
  
  /**
   * <p>
   * DirectFolderEventListener
   * </p>
   * 
   * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
   * @version $Id: DeployDecoratorEventListener.java,v 1.1 2004/01/14 19:32:57 weaver Exp $
   *
   */
  public class DeployDecoratorEventListener implements DeploymentEventListener
  {
      protected SimpleRegistry registry;
      protected static final Log log = LogFactory.getLog(DeployDecoratorEventListener.class);
  
      public DeployDecoratorEventListener(SimpleRegistry registry)
      {
          this.registry = registry;
      }
  
      /**
       * @see org.apache.jetspeed.deployment.DeploymentEventListener#invoke(org.apache.jetspeed.deployment.DeploymentEvent)
       */
      public void invoke(DeploymentEvent event) throws DeploymentException
      {
          // In most cases we are already looking at the target deployment directory
          // and all we need to do is register the folder name
          if (event.getEventType().equals(DeploymentEvent.EVENT_TYPE_DEPLOY))
          {
  			Configuration conf;
              try
              {
                  conf = event.getHandler().getConfiguration("decorator.properties");
              }
              catch (IOException e1)
              {
                  // TODO Auto-generated catch block
                  throw new DeploymentException("Error readin configuration from jar: "+e1.toString(), e1);
              }
              
              String id = conf.getString("id");
              if (id != null)
              {
              	
                  Entry entry = new Entry();
                  entry.setId(id);
                  if (!registry.isRegistered(entry))
                  {
                      try
                      {
  
                          String mediaType = conf.getString("media.type", "html");
                          String deployPath = event.getDeploymentRoot() + File.separator + mediaType + File.separator + id;
                          JarInputStream jis = (JarInputStream) event.getHandler().getAsStream();
                          JarEntry jarEntry = jis.getNextJarEntry();
                          while (jarEntry != null)
                          {
                              String entryName = jarEntry.getName();
                              File fullPath = new File(deployPath + File.separator + entryName);
                              if (!fullPath.exists())
                              {
                              	// First create parnets
                              	fullPath.getParentFile().mkdirs();
                                  fullPath.createNewFile();
  
                              }
  
                              FileOutputStream fos = new FileOutputStream(fullPath);
                              byte[] buf = new byte[1024];
                              int len;
                              while ((len = jis.read(buf)) > 0)
                              {
                                  fos.write(buf, 0, len);
                              }
  
                              jarEntry = jis.getNextJarEntry();
                          }
  
                          registry.register(entry);
                          log.info("Registering decorator " + event.getDeploymentRoot() + "/" + id);
                      }
                      catch (Exception e)
                      {
                          
                          e.printStackTrace();
                      }
                  }
  
              }
              else
              {
                  log.error("Unable to register directory, \"id\" attribute not defined in configuration");
              }
  
          }
  
      }
  
  }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: jetspeed-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jetspeed-dev-help@jakarta.apache.org


Mime
View raw message