portals-jetspeed-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dlest...@apache.org
Subject svn commit: r209328 [5/14] - in /portals/jetspeed-2/trunk/components/portal: src/ src/java/ src/java/org/ src/java/org/apache/ src/java/org/apache/jetspeed/ src/java/org/apache/jetspeed/aggregator/ src/java/org/apache/jetspeed/aggregator/impl/ src/java...
Date Tue, 05 Jul 2005 21:55:50 GMT
Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/deployment/impl/StandardDeploymentManager.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/deployment/impl/StandardDeploymentManager.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/deployment/impl/StandardDeploymentManager.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/deployment/impl/StandardDeploymentManager.java Tue Jul  5 14:55:37 2005
@@ -0,0 +1,365 @@
+/*
+ * Copyright 2000-2001,2004 The 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 org.apache.jetspeed.deployment.impl;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.StringTokenizer;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.components.portletregistry.PortletRegistry;
+import org.apache.jetspeed.deployment.DeploymentEvent;
+import org.apache.jetspeed.deployment.DeploymentEventListener;
+import org.apache.jetspeed.deployment.DeploymentException;
+import org.apache.jetspeed.deployment.DeploymentManager;
+import org.apache.jetspeed.deployment.DeploymentObject;
+import org.apache.jetspeed.deployment.DeploymentStatus;
+
+/**
+ * <p>
+ * StandardDeploymentManager
+ * </p>
+ * Implementation of {@link org.apache.jetspeed.deployment.DeploymentManager}
+ * 
+ * @author <a href="mailto:weaver@apache.org">Scott T. Weaver </a>
+ * @version $Id: StandardDeploymentManager.java 188611 2005-05-24 22:52:12Z ate $
+ */
+public class StandardDeploymentManager implements DeploymentManager
+{
+    protected Log               log = LogFactory.getLog("deployment");
+    protected FileSystemScanner scanner;
+    protected PortletRegistry   registry;
+    protected Collection        deploymentListeners;
+    protected long              scanningDelay;
+    protected String            stagingDirectories;
+    protected File[]            stagingDirectoriesAsFiles;
+    protected HashMap           ignoredFiles;
+
+    /**
+     * @param stagingDirectories
+     * @param scanningDelay
+     * @param deploymentListeners
+     */
+    public StandardDeploymentManager(String stagingDirectories, long scanningDelay, Collection deploymentListeners)
+    {
+        this.scanningDelay = scanningDelay;
+        this.stagingDirectories = stagingDirectories;
+        StringTokenizer dirTokenizer = new StringTokenizer(stagingDirectories, ",");
+        this.stagingDirectoriesAsFiles = new File[dirTokenizer.countTokens()];
+        int i = 0;
+        while (dirTokenizer.hasMoreTokens())
+        {
+            this.stagingDirectoriesAsFiles[i] = new File((String) dirTokenizer.nextToken());
+            i++;
+        }
+
+        this.deploymentListeners = deploymentListeners;
+        this.ignoredFiles = new HashMap();
+    }
+
+    /**
+     * <p>
+     * start
+     * </p>
+     * 
+     * @see org.picocontainer.Startable#start()
+     */
+    public void start()
+    {
+
+        log.info("Starting auto deployment service: " + getClass().getName());
+
+        log.info("Deployment scanning delay: " + scanningDelay);
+
+        log.info("Deployment staging directory: " + stagingDirectories);
+
+        for (int i = 0; i < stagingDirectoriesAsFiles.length; i++)
+        {
+            if (!stagingDirectoriesAsFiles[i].exists())
+            {
+                log
+                                .error(stagingDirectoriesAsFiles[i].getAbsolutePath()
+                                       + " does not exist, auto deployment disabled.");
+                stop();
+                return;
+            }
+        }
+
+        // initialize listeners (where needed)
+        Iterator itr = deploymentListeners.iterator();
+        while (itr.hasNext())
+        {
+            ((DeploymentEventListener) itr.next()).initialize();
+        }
+
+        if (scanningDelay > -1)
+        {
+            try
+            {
+                scanner = new FileSystemScanner(Thread.currentThread().getThreadGroup(),
+                                                "Autodeployment File Scanner Thread");
+
+                scanner.setDaemon(true);
+                // scanner.setContextClassLoader(Thread.currentThread().getContextClassLoader());
+                scanner.setContextClassLoader(getClass().getClassLoader());
+                scanner.start();
+                log.info("Deployment scanner successfuly started!");
+            }
+            catch (Exception e)
+            {
+                log.warn(
+                         "Unable to intialize Catalina Portlet Application Manager.  Auto deployment will be disabled: "
+                                                                                                    + e.toString(), e);
+
+                stop();
+                return;
+            }
+        }
+        else
+        {
+            log.info("Scanning delay set to " + scanningDelay
+                     + " has disabled automatic scanning of staging directory.");
+        }
+
+    }
+
+    /**
+     * <p>
+     * stop
+     * </p>
+     * 
+     * @see org.picocontainer.Startable#stop()
+     */
+    public void stop()
+    {
+        if (scanner != null)
+        {
+            scanner.safeStop();
+        }
+    }
+    
+    public synchronized DeploymentStatus deploy(File aFile) throws DeploymentException
+    {
+        DeploymentObject deploymentObject = new StandardDeploymentObject(aFile);
+        DeploymentEvent event = null;
+        try
+        {
+            event = new DeploymentEventImpl(deploymentObject);
+            dispatch(event);
+        }
+        finally
+        {
+            if ( deploymentObject != null )
+            {
+                try
+                {
+                    deploymentObject.close();
+                }
+                catch (IOException e)
+                {                    
+                }
+            }
+        }
+        return event;
+    }
+
+    public void fireDeploymentEvent()
+    {
+        File[] stagedFiles = getAllStagedFiles();
+        for (int i = 0; i < stagedFiles.length; i++)
+        {
+            // check for new deployment
+            File aFile = stagedFiles[i];
+            if (!ignoreFile(aFile))
+            {
+                boolean failed = false;
+                boolean unknown = false;
+
+                DeploymentStatus status = null;
+                Exception de = null;
+                try
+                {
+                    status = deploy(aFile);
+                }
+                catch (Exception e)
+                {                    
+                    de = e;
+                }
+                
+                if ( status != null && status.getStatus() == DeploymentStatus.STATUS_OKAY )
+                {
+                    if (aFile.exists())
+                    {
+                        log.info("File: " + aFile.getAbsolutePath() + " deployed");
+                        boolean result = aFile.delete();
+                        if (!result)
+                        {
+                           	log.error("Failed to remove: " + aFile);
+                        }
+                    }
+                }
+                else
+                {
+                    if (status == null || status.getStatus() == DeploymentStatus.STATUS_EVAL)
+                    {
+                        log.warn("Unrecognized file " + aFile.getAbsolutePath());
+                    }
+                    else if ( de != null )
+                    {
+                        log.error("Failure deploying " + aFile.getAbsolutePath(), de);
+                    }
+                    else
+                    {
+                        log.error("Failure deploying " + aFile.getAbsolutePath());
+                    }
+                    ignoredFiles.put(aFile.getAbsolutePath(), new Long(aFile.lastModified()));
+                }
+            }
+        }
+    }
+
+    /**
+     * <p>
+     * dispatch
+     * </p>
+     * 
+     * @see org.apache.jetspeed.deployment.DeploymentManager#dispatch(org.apache.jetspeed.deployment.DeploymentEvent)
+     * @param event
+     */
+    public void dispatch(DeploymentEvent event)
+    {
+        try
+        {
+            Iterator itr = deploymentListeners.iterator();
+            while (itr.hasNext())
+            {
+                DeploymentEventListener listener = (DeploymentEventListener) itr.next();
+                listener.invokeDeploy(event);
+                if (event.getStatus() != DeploymentStatus.STATUS_EVAL)
+                {
+                    break;
+                }
+            }
+        }
+        catch (DeploymentException e)
+        {
+            log.error(e.getMessage(), e);
+            event.setStatus(DeploymentStatus.STATUS_FAILED);
+        }
+    }
+
+    /**
+     * <p>
+     * ignoreFile
+     * </p>
+     * 
+     * @param fileName
+     * @return
+     */
+    protected boolean ignoreFile(File aFile)
+    {
+        Long previousModified = (Long) ignoredFiles.get(aFile.getAbsolutePath());
+        if (previousModified != null)
+        {
+            if (previousModified.longValue() != aFile.lastModified())
+            {
+                ignoredFiles.remove(aFile.getAbsolutePath());
+            }
+            else
+            {
+                return true;
+            }
+        }
+        return false;
+    }
+
+    /**
+     * <p>
+     * getAllStagedFiles
+     * </p>
+     * 
+     * @return
+     */
+    protected File[] getAllStagedFiles()
+    {
+        ArrayList fileList = new ArrayList();
+        for (int i = 0; i < stagingDirectoriesAsFiles.length; i++)
+        {
+            fileList.addAll(Arrays.asList(stagingDirectoriesAsFiles[i].listFiles()));
+        }
+
+        return (File[]) fileList.toArray(new File[fileList.size()]);
+    }
+
+    public class FileSystemScanner extends Thread
+    {
+
+        private boolean started = true;
+
+        public FileSystemScanner(ThreadGroup threadGroup, String name) throws FileNotFoundException, IOException
+        {
+            super(threadGroup, name);
+            setPriority(MIN_PRIORITY);
+        }
+
+        /**
+         * @see java.lang.Runnable#run()
+         */
+        public void run()
+        {
+            // use a double scanningDelay at startup to give the App Server some time to wake up...
+            // see: http://issues.apache.org/jira/browse/JS2-261
+            try
+            {
+                sleep(scanningDelay*2);
+            }
+            catch (InterruptedException e)
+            {
+
+            }
+           while (started)
+            {
+                fireDeploymentEvent();
+
+                try
+                {
+                    sleep(scanningDelay);
+                }
+                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;
+        }
+
+    }
+
+}
\ No newline at end of file

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/deployment/impl/StandardDeploymentObject.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/deployment/impl/StandardDeploymentObject.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/deployment/impl/StandardDeploymentObject.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/deployment/impl/StandardDeploymentObject.java Tue Jul  5 14:55:37 2005
@@ -0,0 +1,149 @@
+/*
+ * Copyright 2000-2001,2004 The 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 org.apache.jetspeed.deployment.impl;
+
+import java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipFile;
+
+import org.apache.jetspeed.deployment.DeploymentObject;
+
+/**
+ * <p>
+ * DeploymentObject
+ * </p>
+ * 
+ * @author <a href="mailto:weaver@apache.org">Scott T. Weaver </a>
+ * @version $Id: StandardDeploymentObject.java 188432 2005-03-23 22:48:43Z ate $
+ */
+public class StandardDeploymentObject implements DeploymentObject
+{
+    protected File    deploymentObject;
+    protected ZipFile zipFile;
+
+    /**
+     * @throws IOException
+     */
+    public StandardDeploymentObject(File deploymentObject) throws FileNotDeployableException
+    {
+        if (verifyExtension(deploymentObject))
+        {
+            this.deploymentObject = deploymentObject;
+        }
+        else
+        {
+            throw new FileNotDeployableException("File type for " + deploymentObject.getName()
+                                                 + " is not supported by StandardDeploymentObject.");
+        }
+
+    }
+
+    /**
+     * <p>
+     * close
+     * </p>
+     * 
+     * @see org.apache.jetspeed.deployment.DeploymentObject#close()
+     * @throws IOException
+     */
+    public void close() throws IOException
+    {
+        if (zipFile != null)
+        {
+            zipFile.close();
+            zipFile = null;
+        }
+    }
+
+    /**
+     * <p>
+     * getConfiguration
+     * </p>
+     * 
+     * @see org.apache.jetspeed.deployment.DeploymentObject#getConfiguration(java.lang.String)
+     * @param configPath
+     * @return
+     * @throws IOException
+     */
+    public InputStream getConfiguration(String configPath) throws IOException
+    {
+        ZipFile zipFile = getZipFile();
+        ZipEntry entry = zipFile.getEntry(configPath);
+        if (entry != null)
+        {
+            return zipFile.getInputStream(entry);
+        }
+        return null;
+    }
+
+    /**
+     * <p>
+     * getName
+     * </p>
+     * 
+     * @see org.apache.jetspeed.deployment.DeploymentObject#getName()
+     * @return
+     */
+    public String getName()
+    {
+        return deploymentObject.getName();
+    }
+
+    /**
+     * <p>
+     * getPath
+     * </p>
+     * 
+     * @see org.apache.jetspeed.deployment.DeploymentObject#getPath()
+     * @return
+     */
+    public String getPath()
+    {
+        return deploymentObject.getAbsolutePath();
+    }
+
+    public ZipFile getZipFile() throws IOException
+    {
+        if (zipFile == null)
+        {
+            zipFile = new ZipFile(deploymentObject);
+        }
+        return zipFile;
+    }
+
+    public File getFile()
+    {
+        return deploymentObject;
+    }
+
+    protected boolean verifyExtension(File file)
+    {
+        String fileName = file.getName();
+        int dot = fileName.lastIndexOf('.');
+        if (dot != -1)
+        {
+            String ext = fileName.substring(dot);
+            return ext.equals(".war") || ext.equals(".jar") || ext.equals(".zip");
+        }
+        else
+        {
+            return false;
+        }
+    }
+
+}
\ No newline at end of file

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/deployment/simpleregistry/Entry.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/deployment/simpleregistry/Entry.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/deployment/simpleregistry/Entry.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/deployment/simpleregistry/Entry.java Tue Jul  5 14:55:37 2005
@@ -0,0 +1,88 @@
+/**
+ * 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 185531 2004-01-14 19:32:57Z weaver $
+ *
+ */
+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();
+    }
+
+   
+
+}

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/deployment/simpleregistry/SimpleRegistry.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/deployment/simpleregistry/SimpleRegistry.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/deployment/simpleregistry/SimpleRegistry.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/deployment/simpleregistry/SimpleRegistry.java Tue Jul  5 14:55:37 2005
@@ -0,0 +1,62 @@
+/**
+ * Created on Jan 13, 2004
+ *
+ * 
+ * @author
+ */
+package org.apache.jetspeed.deployment.simpleregistry;
+
+import java.util.Collection;
+
+/**
+ * <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 186206 2004-03-25 21:42:32Z jford $
+ *
+ */
+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();
+
+}

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/deployment/simpleregistry/SimpleRegistryException.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/deployment/simpleregistry/SimpleRegistryException.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/deployment/simpleregistry/SimpleRegistryException.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/deployment/simpleregistry/SimpleRegistryException.java Tue Jul  5 14:55:37 2005
@@ -0,0 +1,56 @@
+/**
+ * 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 185531 2004-01-14 19:32:57Z weaver $
+ *
+ */
+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);        
+    }
+
+}

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/deployment/simpleregistry/impl/InMemoryRegistryImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/deployment/simpleregistry/impl/InMemoryRegistryImpl.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/deployment/simpleregistry/impl/InMemoryRegistryImpl.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/deployment/simpleregistry/impl/InMemoryRegistryImpl.java Tue Jul  5 14:55:37 2005
@@ -0,0 +1,93 @@
+/**
+ * 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 185531 2004-01-14 19:32:57Z weaver $
+ *
+ */
+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.");
+		}
+    }
+
+}

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/AbstractEngine.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/AbstractEngine.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/AbstractEngine.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/AbstractEngine.java Tue Jul  5 14:55:37 2005
@@ -0,0 +1,386 @@
+/*
+ * Copyright 2000-2001,2004 The 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 org.apache.jetspeed.engine;
+
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.text.DateFormat;
+import java.util.Date;
+import java.util.Properties;
+
+import javax.naming.NamingException;
+import javax.servlet.ServletConfig;
+
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.JetspeedPortalContext;
+import org.apache.jetspeed.PortalContext;
+import org.apache.jetspeed.PortalReservedParameters;
+import org.apache.jetspeed.components.ComponentManager;
+import org.apache.jetspeed.components.jndi.JNDIComponent;
+import org.apache.jetspeed.exception.JetspeedException;
+import org.apache.jetspeed.pipeline.Pipeline;
+import org.apache.jetspeed.request.RequestContext;
+import org.apache.jetspeed.request.RequestContextComponent;
+import org.apache.jetspeed.util.IsolatedLog4JLogger;
+import org.apache.log4j.Hierarchy;
+import org.apache.log4j.Level;
+import org.apache.log4j.PropertyConfigurator;
+import org.apache.log4j.spi.RootCategory;
+import org.apache.ojb.broker.util.ClassHelper;
+import org.apache.pluto.PortletContainer;
+import org.apache.pluto.PortletContainerException;
+import org.apache.pluto.factory.Factory;
+import org.apache.pluto.services.ContainerService;
+import org.apache.pluto.services.factory.FactoryManagerService;
+import org.springframework.beans.factory.NoSuchBeanDefinitionException;
+
+
+/**
+ * <p>
+ * AbstractEngine
+ * </p>
+ * <p>
+ *
+ * </p>
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor </a>
+ * @author <a href="mailto:weaver@apache.org">Scott T. Weaver</a>
+ * @version $Id: AbstractEngine.java 188433 2005-03-23 22:50:44Z ate $
+ *
+ */
+public abstract class AbstractEngine implements Engine
+{
+
+    public static final String JNDI_SUPPORT_FLAG_KEY = "portal.use.internal.jndi";
+    private PortalContext context;
+    private ServletConfig config = null;
+    private ComponentManager componentManager = null;
+    protected static final Log log = LogFactory.getLog(AbstractEngine.class);
+    private static final Log console = LogFactory.getLog(CONSOLE_LOGGER);
+    /** stores the most recent RequestContext on a per thread basis */
+    protected boolean useInternalJNDI;
+    protected String defaultPipelineName;
+
+    /**
+     * Initializes the engine with a commons configuration, starting all early
+     * initable services.
+     * 
+     * @param configuration
+     *                  a commons <code>Configuration</code> set
+     * @param applicationRoot
+     *                  a <code>String</code> path to the application root for
+     *                  resources
+     * @param
+     * @throws JetspeedException
+     *                   when the engine fails to initilialize
+     */
+    public void init( Configuration configuration, String applicationRoot, ServletConfig config ) throws JetspeedException
+    {
+        DateFormat format = DateFormat.getInstance();
+        Date startTime = new Date();
+        
+        
+        try
+        {
+            this.context = new JetspeedPortalContext(this);
+            this.config = config;
+            context.setApplicationRoot(applicationRoot);
+            context.setConfiguration(configuration);
+            useInternalJNDI = configuration.getBoolean(JNDI_SUPPORT_FLAG_KEY,
+                    true);
+            defaultPipelineName = configuration.getString(PIPELINE_DEFAULT, "jetspeed-pipeline");
+            configuration.setProperty(JetspeedEngineConstants.APPLICATION_ROOT_KEY, applicationRoot);
+            
+            if(System.getProperty(JNDI_SUPPORT_FLAG_KEY) ==  null)
+            {
+                 System.setProperty(JNDI_SUPPORT_FLAG_KEY, String
+                    .valueOf(useInternalJNDI));                 
+            }
+            else
+            {
+                // System property over rides the configurtaion                
+                useInternalJNDI = Boolean.getBoolean(JNDI_SUPPORT_FLAG_KEY);
+                log.warn("Internal JNDI has been flagged "+useInternalJNDI+" by the "+JNDI_SUPPORT_FLAG_KEY+" system  property.  This overrides the configuration setting of "+configuration.getBoolean(JNDI_SUPPORT_FLAG_KEY,
+                        true));
+            }
+            
+            //
+            // Configure Log4J
+            //
+            String log4jFile = configuration.getString(LOG4J_CONFIG_FILE,
+                    LOG4J_CONFIG_FILE_DEFAULT);
+            log4jFile = getRealPath(log4jFile);
+            Properties p = new Properties();
+            p.load(new FileInputStream(log4jFile));
+            p.setProperty(APPLICATION_ROOT_KEY, context.getApplicationRoot());
+            Hierarchy h = new Hierarchy(new RootCategory(Level.INFO));
+            new PropertyConfigurator().doConfigure(p,h);
+            IsolatedLog4JLogger.setHierarchy(h);
+            
+            log.info("Configured log4j from " + log4jFile);
+            log.info("Starting Jetspeed Engine ("+getClass().getName()+") at "+format.format(startTime));
+    
+            // patch up OJB
+            ClassLoader ploader2 = this.getClass().getClassLoader();
+            //ClassLoader ploader2 = Thread.currentThread().getContextClassLoader();
+            ClassHelper.setClassLoader(ploader2);
+            
+            //
+            // bootstrap the initable services
+            //
+            componentManager = initComponents(configuration, config);
+            log.info("Components initialization complete");
+                
+        }
+        catch (Throwable e)
+        {
+            e.printStackTrace();
+            log.error(e.toString());
+            throw new JetspeedException("Jetspeed Initialization exception!", e);
+        }
+        finally
+        {            
+            Date endTime = new Date();
+            long elapsedTime = (endTime.getTime() - startTime.getTime()) / 1000;
+            log.info("Finished starting Jetspeed Engine ("+getClass().getName()+") at "+format.format(endTime) 
+                         +".  Elapsed time: "+elapsedTime+" seconds.");
+        }
+    }
+
+    /**
+     * Get the servlet configuration if this engine is running under a servlet
+     * container.
+     * 
+     * @return config The servlet configuration
+     */
+    public ServletConfig getServletConfig()
+    {
+        return this.config;
+    }
+
+    /**
+     * Initializes the portlet container given a servlet configuration.
+     * 
+     * @param config
+     *                  The servlet configuration.
+     */
+    public void initContainer( ServletConfig config ) throws PortletContainerException
+    {
+        try
+        {
+            PortletContainer container = (PortletContainer) componentManager
+                    .getComponent(PortletContainer.class);
+
+            container.init("jetspeed", config, this, new Properties());
+        }
+        catch (Throwable e)
+        {
+            console.error("Unable to initalize Engine.", e);
+            log.error("Unable to initalize Engine.", e);
+            if (e instanceof PortletContainerException)
+            {
+                throw (PortletContainerException) e;
+            }
+            else
+            {
+                throw new PortletContainerException(e);
+            }
+        }
+    }
+
+    public void shutdown() throws JetspeedException
+    {        
+    
+        try
+        {
+            PortletContainer container = (PortletContainer) componentManager
+                    .getComponent(PortletContainer.class);
+            if (container != null)
+            {
+                container.shutdown();
+            }
+    
+            componentManager.stop();
+        }
+        catch (PortletContainerException e)
+        {
+            throw new JetspeedException(e);
+        }
+        System.gc();
+    }
+
+    public void service( RequestContext context ) throws JetspeedException
+    {
+        // requestContextPerThread.put(Thread.currentThread(), context);
+
+
+            if (useInternalJNDI)
+            {
+                // bind the current JNDI context to this service thread.
+                JNDIComponent jndi = (JNDIComponent) componentManager
+                        .getComponent(JNDIComponent.class);
+                if (jndi != null)
+                {
+                    try
+                    {
+                        jndi.bindToCurrentThread();
+                    }
+                    catch (NamingException e)
+                    {
+                        throw new JetspeedException("Unable bind jndi: "+e.toString(), e);
+                    }
+                }
+            }
+            String targetPipeline = context
+                    .getRequestParameter(PortalReservedParameters.PIPELINE);
+            if (null == targetPipeline)
+            {                
+                targetPipeline = (String)context.getAttribute(PortalReservedParameters.PIPELINE);                
+            }
+            // tlRequestContext.set(context);
+            Pipeline pipeline = getPipeline();
+            if (targetPipeline != null)
+            {
+                Pipeline specificPipeline = getPipeline(targetPipeline);
+                if (specificPipeline != null)
+                {
+                    pipeline = specificPipeline;
+                }
+            }
+            pipeline.invoke(context);
+   
+    }
+
+    /**
+     * Returns the context associated with this engine.
+     * 
+     * @return an <code>EngineContext</code> associated with this engine
+     */
+    public PortalContext getContext()
+    {
+        return this.context;
+    }
+
+    /**
+     * Given a application relative path, returns the real path relative to the
+     * application root
+     *  
+     */
+    public String getRealPath( String path )
+    {
+        String result = "";
+        String base = context.getApplicationRoot();
+        if (base.endsWith(java.io.File.separator))
+        {
+            if (path.startsWith("/"))
+            {
+                result = base.concat(path.substring(1));
+                return result;
+            }
+        }
+        else
+        {
+            if (!path.startsWith("/"))
+            {
+                result = base.concat("/").concat(path);
+                return result;
+            }
+        }
+        return base.concat(path);
+    }
+    
+    /**
+     * 
+     * <p>
+     * initComponents
+     * </p>
+     * Main responsibility of the subclassed implementation of this method
+     * is to provide a <code>ComponentManager</code> implementation for the 
+     * Engine.
+     *
+     * @param configuration Usually jetspeed.properties
+     * @throws IOException
+     * @throws ClassNotFoundException
+     * @throws NamingException
+     */
+    protected abstract ComponentManager initComponents( Configuration configuration, ServletConfig servletConfig )
+    throws IOException, ClassNotFoundException, NamingException;
+
+    public Pipeline getPipeline( String pipelineName )
+    {
+        return (Pipeline) componentManager.getComponent(pipelineName);
+    }
+
+    public Pipeline getPipeline()
+    {
+        return getPipeline(defaultPipelineName);
+    }
+
+    /**
+     * @see org.apache.jetspeed.engine.Engine#getCurrentRequestContext()
+     */
+    public RequestContext getCurrentRequestContext()
+    {
+        RequestContextComponent contextComponent = (RequestContextComponent) getComponentManager()
+            .getComponent(RequestContextComponent.class);
+        return contextComponent.getRequestContext();
+    }
+
+    public ComponentManager getComponentManager()
+    {
+        return this.componentManager;
+    }
+    /**
+     * <p>
+     * getFactory
+     * </p>
+     *
+     * @see org.apache.pluto.services.factory.FactoryManagerService#getFactory(java.lang.Class)
+     * @param theClass
+     * @return
+     */
+    public Factory getFactory( Class theClass )
+    {        
+        return (Factory) getComponentManager().getComponent(theClass);
+    }
+    /**
+     * <p>
+     * getContainerService
+     * </p>
+     *
+     * @see org.apache.pluto.services.PortletContainerEnvironment#getContainerService(java.lang.Class)
+     * @param service
+     * @return
+     */
+    public ContainerService getContainerService( Class service )
+    {
+        if(service.equals(FactoryManagerService.class))
+        {
+            return this;
+        }
+
+        try
+        {
+            return (ContainerService) getComponentManager().getComponent(service);
+        }
+        catch (NoSuchBeanDefinitionException e)
+        {
+            log.warn("No ContainerService defined for "+service.getName());
+            return null;
+        }
+    }
+}

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/Engine.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/Engine.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/Engine.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/Engine.java Tue Jul  5 14:55:37 2005
@@ -0,0 +1,124 @@
+/*
+ * Copyright 2000-2004 The 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 org.apache.jetspeed.engine;
+
+import javax.servlet.ServletConfig;
+
+import org.apache.commons.configuration.Configuration;
+import org.apache.jetspeed.PortalContext;
+import org.apache.jetspeed.components.ComponentManager;
+import org.apache.jetspeed.exception.JetspeedException;
+import org.apache.jetspeed.pipeline.Pipeline;
+import org.apache.jetspeed.request.RequestContext;
+import org.apache.pluto.PortletContainerException;
+import org.apache.pluto.services.PortletContainerEnvironment;
+import org.apache.pluto.services.factory.FactoryManagerService;
+
+
+/**
+ * Engine Abstraction - to run from both unit tests and servlet
+ *
+ * @author <a href="mailto:david@bluesunrise.com">David Sean Taylor</a>
+ * @version $Id: Engine.java 187178 2004-08-02 19:00:15Z weaver $
+ */
+public interface Engine extends JetspeedEngineConstants, FactoryManagerService, PortletContainerEnvironment 
+{
+    /**
+     * Initializes the engine with a commons configuration, starting all early initable services.
+     *
+     * @param configuration a commons <code>Configuration</code> set
+     * @param applicationRoot a <code>String</code> path to the application root for resources
+     * @param config the servlet configuration, this parameter can be null for unit tests or utilities
+     * @throws JetspeedException when the engine fails to initilialize
+     */
+    public void init(Configuration configuration, String applicationRoot, ServletConfig config)
+       throws JetspeedException;
+
+    /**
+     * Initializes the portlet container given a servlet configuration.
+     * 
+     * @param config The servlet configuration.
+     * @throws PortletContainerException when the container fails to initialize.
+     */
+    public void initContainer(ServletConfig config)
+        throws PortletContainerException; 
+    
+    /**
+     * Shuts down the Jetspeed engine and all associated services
+     *
+     * @throws JetspeedException when the engine fails to shutdown
+     */
+    public void shutdown()
+       throws JetspeedException;
+
+    /**
+     * Makes a service request to the engine.
+     *
+     * @param context a <code>RequestContext</code> with the state of the request.
+     * @throws JetspeedException when the engine fails to initilialize
+     */
+    public void service(RequestContext context)
+       throws JetspeedException;
+
+    /**
+     * Gets the engine's request default pipeline.
+     * 
+     * @return Pipeline The engine's request pipeline.
+     */
+    public Pipeline getPipeline();
+ 
+    /**
+     * Gets the specified engine's request pipeline.
+     * 
+     * @return Pipeline A specific request pipeline.
+     */ 
+    public Pipeline getPipeline(String pipelineName);
+ 
+    /**
+     * Get the Portal Context associated with running thread of the engine
+     * 
+     * @return PortalContext associated with this engine's thread
+     */
+    public PortalContext getContext();
+
+    /**
+     * Gets the real path to an application relative resource
+     * 
+     * @param path The application relative resource 
+     * @return String The real path to that resource
+     */
+    public String getRealPath(String path);
+    
+    /**
+     * Get the servlet configuration if this engine is running under a servlet container.
+     * 
+     * @return config The servlet configuration
+     */    
+    public ServletConfig getServletConfig();
+    
+    /**
+     * Returns the the RequestContext associated with the current
+     * thread.  This can be accessed throught <code>org.apache.jetspeed.Jetspeed</code>
+     * environment class.
+     * @return RequestContext associated with the current thread.
+     */
+    public RequestContext getCurrentRequestContext();
+
+    public ComponentManager getComponentManager();
+    
+    
+
+}

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/JetspeedEngineConstants.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/JetspeedEngineConstants.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/JetspeedEngineConstants.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/JetspeedEngineConstants.java Tue Jul  5 14:55:37 2005
@@ -0,0 +1,98 @@
+/*
+ * Copyright 2000-2004 The 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 org.apache.jetspeed.engine;
+
+/**
+ * This interface contains all the constants for the engine.
+ *
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id: JetspeedEngineConstants.java 185962 2004-03-08 01:03:33Z jford $
+ */
+public interface JetspeedEngineConstants
+{
+    /**
+     * <p>The prefix used to denote the namespace reserved for and
+     * used by Jetspeed-specific configuration parameters (such as
+     * those passed in via servlet container's config file
+     * (<code>server.xml</code>), or the web app deployment descriptor
+     * (<code>web.xml</code>).</p>
+     *
+     * <p>For example, a parameter in the Jetspeed namespace would be
+     * <code>org.apache.jetspeed.loggingRoot</code>.</p>
+     */
+    public static final String CONFIG_NAMESPACE = "org.apache.jetspeed";
+
+    /** The key for the Log4J File */
+    public static final String LOG4J_CONFIG_FILE = "log4j.file";
+
+    /** The default value for the Log4J File */
+    public static final String LOG4J_CONFIG_FILE_DEFAULT = "/WEB-INF/conf/Log4j.properties";
+
+    /** This is the default log file to be used for logging */
+    public static final String DEFAULT_LOGGER = "jetspeed";
+    public static final String CONSOLE_LOGGER = "console";
+
+    /**
+     * The logging facility which captures output from the SchedulerService.
+     */
+    public static final String SCHEDULER_LOG_FACILITY = "scheduler";
+
+    /**
+     * SMTP server uses to send mail.
+     */
+    public static final String MAIL_SERVER_KEY = "mail.server";
+
+
+    /** Default Value for the Logging Directory, relative to the webroot */
+    public static final String LOGGING_ROOT_DEFAULT = "/logs";
+    public static final String LOGGING_ROOT = "loggingRoot";
+
+    public static final String JETSPEED_PROPERTIES_KEY = "properties";
+    public static final String JETSPEED_PROPERTIES_DEFAULT = "/WEB-INF/conf/jetspeed.properties";
+    public static final String JETSPEED_CONFIGURATION_KEY = "configuration";
+    public static final String JETSPEED_CONFIGURATION_DEFAULT = "/WEB-INF/conf/jetspeed.xml";
+
+    /** If this value is set as applicationRoot, then the webContext is used
+     * as application root
+     */
+    public static final String WEB_CONTEXT = "webContext";
+
+    /** Key for the Path to the Resources.properties File */
+    public static final String APPLICATION_ROOT_KEY = "applicationRoot";
+
+    /** Default Value for the Path to the Resources.properties File */
+    public static final String APPLICATION_ROOT_DEFAULT = WEB_CONTEXT;
+
+    /** This is the key used in the jetspeed.properties to access resources
+     * relative to the Web Application root. It might differ from the
+     * Application root, but the normal case is, that the webapp root
+     * and the application root point to the same path.
+     */
+    public static final String WEBAPP_ROOT_KEY = "webappRoot";
+
+    public static final String PIPELINE_CLASS = "pipeline.class";
+    public static final String PIPELINE_DEFAULT = "pipeline.default";
+    public static final String PIPELINE_DIRECTORY = "pipeline.directory";
+
+    /**
+     * This specifies the factory to use the Jetspeed java.util.prefs.Preferences
+     * implementation.
+     */
+    public static final String PREFERENCES_FACTORY = "preferences.factory";
+    public static final String PREFERENCES_FACTORY_DEFAULT =
+        "org.apache.jetspeed.spi.services.prefs.impl.PreferencesFactoryImpl";
+
+}

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/JetspeedServlet.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/JetspeedServlet.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/JetspeedServlet.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/JetspeedServlet.java Tue Jul  5 14:55:37 2005
@@ -0,0 +1,292 @@
+/*
+ * Copyright 2000-2004 The 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 org.apache.jetspeed.engine;
+
+import java.io.IOException;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import org.apache.commons.configuration.Configuration;
+import org.apache.commons.configuration.PropertiesConfiguration;
+import org.apache.commons.lang.exception.ExceptionUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jetspeed.Jetspeed;
+import org.apache.jetspeed.engine.servlet.ServletHelper;
+import org.apache.jetspeed.exception.JetspeedException;
+import org.apache.jetspeed.request.RequestContext;
+import org.apache.jetspeed.request.RequestContextComponent;
+
+/**
+ * Jetspeed Servlet entry point.
+ * 
+ * @author <a href="mailto:david@bluesunrise.com">David Sean Taylor </a>
+ * @version $Id: JetspeedServlet.java 188003 2004-11-29 19:14:45Z weaver $
+ */
+public class JetspeedServlet extends HttpServlet implements JetspeedEngineConstants
+{
+    private final static Log log = LogFactory.getLog(JetspeedServlet.class);
+    private final static Log console = LogFactory.getLog(CONSOLE_LOGGER);
+
+    /**
+     * In certain situations the init() method is called more than once,
+     * somtimes even concurrently. This causes bad things to happen, so we use
+     * this flag to prevent it.
+     */
+    private static boolean firstInit = true;
+
+    /**
+     * Whether init succeeded or not.
+     */
+    private static Throwable initFailure = null;
+
+    /**
+     * Should initialization activities be performed during doGet() execution?
+     */
+    private static boolean firstDoGet = true;
+
+    /**
+     * The Jetspeed Engine
+     */
+    private static Engine engine;
+
+    private static String webappRoot;
+
+    // -------------------------------------------------------------------
+    // I N I T I A L I Z A T I O N
+    // -------------------------------------------------------------------
+    private static final String INIT_START_MSG = "Jetspeed Starting Initialization...";
+    private static final String INIT_DONE_MSG = "Jetspeed Initialization complete, Ready to service requests.";
+
+    /**
+     * Intialize Servlet.
+     */
+    public final void init( ServletConfig config ) throws ServletException
+    {
+        synchronized (this.getClass())
+        {
+            console.info(INIT_START_MSG);
+
+            super.init(config);
+
+            if (!firstInit)
+            {
+                log.info("Double initialization of Jetspeed was attempted!");
+                console.info("Double initialization of Jetspeed was attempted!");
+                return;
+            }
+            // executing init will trigger some static initializers, so we have
+            // only one chance.
+            firstInit = false;
+
+            try
+            {
+
+                ServletContext context = config.getServletContext();
+
+                String propertiesFilename = ServletHelper.findInitParameter(context, config, JETSPEED_PROPERTIES_KEY,
+                        JETSPEED_PROPERTIES_DEFAULT);
+
+                String applicationRoot = ServletHelper.findInitParameter(context, config, APPLICATION_ROOT_KEY,
+                        APPLICATION_ROOT_DEFAULT);
+
+                console.info("JetspeedServlet identifying web application root...");
+                webappRoot = config.getServletContext().getRealPath("/");
+                console.info("JetspeedServlet identifed web application root as " + webappRoot);
+
+                if (applicationRoot == null || applicationRoot.equals(WEB_CONTEXT))
+                {
+                    applicationRoot = webappRoot;
+                }
+
+                Configuration properties = (Configuration) new PropertiesConfiguration(ServletHelper.getRealPath(
+                        config, propertiesFilename));
+
+                properties.setProperty(APPLICATION_ROOT_KEY, applicationRoot);
+                properties.setProperty(WEBAPP_ROOT_KEY, webappRoot);
+
+                console.info("JetspeedServlet attempting to create the  portlet engine...");
+                String engineClassName = config.getInitParameter("engine");
+                if (engineClassName == null)
+                {
+                    throw new IllegalStateException(
+                            "You must define the engine init-parameter org.apache.jetspeed.engine.JetspeedServlet servlet.");
+                }
+                Class engineClass = Class.forName(engineClassName);
+
+                engine = Jetspeed.createEngine(properties, applicationRoot, config, engineClass);
+                if (engine != null)
+                {
+                    console.info("JetspeedServlet successfuly created the portal Engine. " + engine);
+                }
+                else
+                {
+                    throw new ServletException("Unable to create Jetspeed portal engine");
+                }
+                console.info("JetspeedServlet attempting to initialize the  portletcontainer...");
+                engine.initContainer(config);
+                console.info("JetspeedServlet has successfuly initialized the portlet container...");
+
+            }
+            catch (Throwable e)
+            {
+                // save the exception to complain loudly later :-)
+                final String msg = "Jetspeed: init() failed: ";
+                initFailure = e;               
+                log.fatal(msg, e);
+                console.fatal(msg, e);
+
+            }
+
+            console.info(INIT_DONE_MSG);
+            log.info(INIT_DONE_MSG);
+        }
+    }
+
+    /**
+     * Initializes the services which need <code>RunData</code> to initialize
+     * themselves (post startup).
+     * 
+     * @param data
+     *            The first <code>GET</code> request.
+     */
+    public final void init( HttpServletRequest request, HttpServletResponse response )
+    {
+        synchronized (JetspeedServlet.class)
+        {
+            if (firstDoGet)
+            {
+                // Mark that we're done.
+                firstDoGet = false;
+            }
+        }
+    }
+
+    // -------------------------------------------------------------------
+    // R E Q U E S T P R O C E S S I N G
+    // -------------------------------------------------------------------
+
+    /**
+     * The primary method invoked when the Jetspeed servlet is executed.
+     * 
+     * @param req
+     *            Servlet request.
+     * @param res
+     *            Servlet response.
+     * @exception IOException
+     *                a servlet exception.
+     * @exception ServletException
+     *                a servlet exception.
+     */
+    public final void doGet( HttpServletRequest req, HttpServletResponse res ) throws IOException, ServletException
+    {
+        try
+        {
+            // Check to make sure that we started up properly.
+            if (initFailure != null)
+            {
+                throw new ServletException("Failed to initalize jetspeed.  "+initFailure.toString(), initFailure);
+            }
+
+            // If this is the first invocation, perform some late
+            // initialization.
+            if (firstDoGet)
+            {
+                init(req, res);
+            }
+
+            //If we already passed though the content filter DON'T send it to the
+            // engine.  This is a crappy hack until we find a better solution.
+            String wasFiltered = (String) req.getAttribute("org.apache.jetspeed.content.filtered");
+            if (wasFiltered == null || !wasFiltered.equals("true"))
+            {
+
+                RequestContextComponent contextComponent = (RequestContextComponent) Jetspeed.getComponentManager()
+                        .getComponent(RequestContextComponent.class);
+                RequestContext context = contextComponent.create(req, res, getServletConfig());
+                engine.service(context);
+                contextComponent.release(context);
+            }
+
+        }
+        catch (JetspeedException e)
+        {
+            final String msg = "Fatal error encountered while processing portal request: "+e.toString();
+            log.fatal(msg, e);
+            throw new ServletException(msg, e);
+        }
+    }
+
+    /**
+     * In this application doGet and doPost are the same thing.
+     * 
+     * @param req
+     *            Servlet request.
+     * @param res
+     *            Servlet response.
+     * @exception IOException
+     *                a servlet exception.
+     * @exception ServletException
+     *                a servlet exception.
+     */
+    public final void doPost( HttpServletRequest req, HttpServletResponse res ) throws IOException, ServletException
+    {
+        doGet(req, res);
+    }
+
+    // -------------------------------------------------------------------
+    // S E R V L E T S H U T D O W N
+    // -------------------------------------------------------------------
+
+    /**
+     * The <code>Servlet</code> destroy method. Invokes
+     * <code>ServiceBroker</code> tear down method.
+     */
+    public final void destroy()
+    {
+        try
+        {
+            Jetspeed.shutdown();
+        }
+        catch (JetspeedException e)
+        {
+            log.fatal("Jetspeed: shutdown() failed: ", e);
+            System.err.println(ExceptionUtils.getStackTrace(e));
+        }
+
+        // Allow turbine to be started back up again.
+        firstInit = true;
+
+        log.info("Done shutting down!");
+    }
+
+    private void debugHeaders( HttpServletRequest req )
+    {
+        java.util.Enumeration e = req.getHeaderNames();
+        while (e.hasMoreElements())
+        {
+            String name = (String) e.nextElement();
+            String value = req.getHeader(name);
+            System.out.println("name = " + name);
+            System.out.println("value = " + value);
+        }
+    }
+}
\ No newline at end of file

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/SpringEngine.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/SpringEngine.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/SpringEngine.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/SpringEngine.java Tue Jul  5 14:55:37 2005
@@ -0,0 +1,116 @@
+/*
+ * Copyright 2000-2001,2004 The 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 org.apache.jetspeed.engine;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+
+import javax.naming.NamingException;
+import javax.servlet.ServletConfig;
+
+import org.apache.commons.configuration.Configuration;
+import org.apache.jetspeed.components.ComponentManager;
+import org.apache.jetspeed.components.SpringComponentManager;
+import org.apache.jetspeed.components.factorybeans.ServletConfigFactoryBean;
+import org.springframework.web.context.WebApplicationContext;
+
+/**
+ * <p>
+ * SpringEngine
+ * </p>
+ * <p>
+ * 
+ * </p>
+ * 
+ * @author <a href="mailto:weaver@apache.org">Scott T. Weaver </a>
+ * @version $Id: SpringEngine.java 188567 2005-05-12 21:00:45Z weaver $
+ *  
+ */
+public class SpringEngine extends AbstractEngine
+{
+
+    /**
+     * <p>
+     * initComponents
+     * </p>
+     * 
+     * @see org.apache.jetspeed.engine.AbstractEngine#initComponents(org.apache.commons.configuration.Configuration)
+     * @param configuration
+     * @return
+     * @throws IOException
+     * @throws ClassNotFoundException
+     * @throws NamingException
+     */
+    protected ComponentManager initComponents( Configuration configuration, ServletConfig servletConfig ) throws IOException, ClassNotFoundException,
+            NamingException
+    {
+        
+        ServletConfigFactoryBean.setServletConfig(servletConfig);
+        String relativeApplicationRoot = getRealPath("/");
+        String absApplicationRoot = new File(relativeApplicationRoot).getCanonicalPath();        
+        System.setProperty("applicationRoot", absApplicationRoot);        
+        
+        final String assemblyDir = configuration.getString("assembly.dir","/WEB-INF/assembly");
+        final String assemblyFileExtension = configuration.getString("assembly.extension",".xml");
+        
+        FileFilter extFilter = new FileFilter()
+        {
+            public boolean accept( File pathname )
+            {
+                boolean isConfig = pathname.getName().endsWith(assemblyFileExtension);
+                if(useInternalJNDI)
+                {
+                    return isConfig;
+                    
+                }
+                else
+                {
+                    return isConfig && pathname.getName().indexOf("pooled-datasource-support") < 0;
+                }
+            }
+            
+        };
+        
+        File assemblyDirFile = new File(getRealPath(assemblyDir));
+        if(!assemblyDirFile.exists())
+        {
+            throw new FileNotFoundException("The assembly path "+assemblyDirFile.getAbsolutePath()+" does not exist.");
+        }
+        
+        File[] configFiles = assemblyDirFile.listFiles(extFilter);
+        String[] configs = new String[configFiles.length];
+        for(int i=0; i<configFiles.length; i++)
+        {
+            configs[i] = configFiles[i].getCanonicalFile().toURL().toExternalForm();
+            if(configs[i].indexOf("pooled-datasource-support") > -1 && i > 0)
+            {	
+                String current0Offset = configs[0];
+                configs[0] = configs[i];
+                configs[i] = current0Offset;
+                
+            }          
+        }
+        
+        SpringComponentManager cm = new SpringComponentManager(configs, null);
+        servletConfig.getServletContext().setAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE, cm.getApplicationContext());
+        
+        return cm;
+    }    
+   
+
+}
\ No newline at end of file

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/core/PortalContextImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/core/PortalContextImpl.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/core/PortalContextImpl.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/core/PortalContextImpl.java Tue Jul  5 14:55:37 2005
@@ -0,0 +1,83 @@
+/*
+ * Copyright 2000-2004 The 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 org.apache.jetspeed.engine.core;
+
+import java.util.Enumeration;
+
+import javax.portlet.PortalContext;
+
+import org.apache.pluto.services.information.PortalContextProvider;
+import org.apache.pluto.util.Enumerator;
+
+/**
+ * PortalContextImpl
+ *
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id: PortalContextImpl.java 185962 2004-03-08 01:03:33Z jford $
+ */
+public class PortalContextImpl implements PortalContext
+{
+    PortalContextProvider provider = null;
+
+    public PortalContextImpl(PortalContextProvider provider) 
+    {
+        this.provider = provider;
+    }
+    
+    /* (non-Javadoc)
+     * @see javax.portlet.PortalContext#getProperty(java.lang.String)
+     */
+    public String getProperty(String name)
+    {
+        if (name == null)
+        {
+            throw new IllegalArgumentException("Property name == null");
+        }
+        return provider.getProperty(name);
+    }
+    
+    /* (non-Javadoc)
+     * @see javax.portlet.PortalContext#getPropertyNames()
+     */
+    public Enumeration getPropertyNames()
+    {
+        return(new Enumerator(provider.getPropertyNames()));
+    }
+    
+    /* (non-Javadoc)
+     * @see javax.portlet.PortalContext#getSupportedPortletModes()
+     */
+    public Enumeration getSupportedPortletModes()
+    {
+        return new Enumerator(provider.getSupportedPortletModes());
+    }
+    
+    /* (non-Javadoc)
+     * @see javax.portlet.PortalContext#getSupportedWindowStates()
+     */
+    public Enumeration getSupportedWindowStates()
+    {
+        return new Enumerator(provider.getSupportedWindowStates());        
+    }
+    
+    /* (non-Javadoc)
+     * @see javax.portlet.PortalContext#getPortalInfo()
+     */
+    public String getPortalInfo()
+    {
+        return provider.getPortalInfo();        
+    }
+}

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/core/PortalContextProviderImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/core/PortalContextProviderImpl.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/core/PortalContextProviderImpl.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/core/PortalContextProviderImpl.java Tue Jul  5 14:55:37 2005
@@ -0,0 +1,240 @@
+/*
+ * Copyright 2000-2004 The 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 org.apache.jetspeed.engine.core;
+
+import java.util.Collection;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Vector;
+import javax.portlet.PortletMode;
+import javax.portlet.WindowState;
+
+import javax.portlet.PortalContext;
+
+import org.apache.jetspeed.Jetspeed;
+import org.apache.pluto.services.information.PortalContextProvider;
+
+/**
+ * Provide information about the calling portal.
+ * 
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id: PortalContextProviderImpl.java 185962 2004-03-08 01:03:33Z jford $
+ */
+public class PortalContextProviderImpl 
+    implements PortalContextProvider
+{
+    PortalContextImpl portalContext = null;
+    /** Portal information */
+
+    private String info = null;
+    private String portalName = null;
+    private String portalVersion = null;
+    
+    /** supported portlet modes by this portal */
+    private Vector modes;
+
+    /** supported window states by this portal */
+    private Vector states;
+
+    /** portal properties */
+    private HashMap properties = new HashMap();
+
+
+    public PortalContextProviderImpl()
+    {
+        portalContext = new PortalContextImpl(this);
+        
+        modes = getDefaultModes();
+
+        // these are the minimum states that the portal needs to support
+
+        states = getDefaultStates(); 
+
+        // set info
+        portalName = Jetspeed.getContext().getConfiguration().getString("portal.name");
+        portalVersion = Jetspeed.getContext().getConfiguration().getString("portal.version");         
+        info = portalName + "/" + portalVersion;   
+        
+    }
+    
+    /* (non-Javadoc)
+     * @see org.apache.pluto.services.information.PortalContextProvider#getPortalContext()
+     */
+    public PortalContext getPortalContext() 
+    {
+        return portalContext;
+    }
+    
+    /** 
+     * <p>
+     * getPortalInfo
+     * </p>
+     * 
+     * @see org.apache.pluto.services.information.PortalContextProvider#getPortalInfo()
+     * @return
+     */
+    public String getPortalInfo()
+    {
+        return info;
+    }
+
+    /** 
+     * <p>
+     * getProperty
+     * </p>
+     * 
+     * @see org.apache.pluto.services.information.PortalContextProvider#getProperty(java.lang.String)
+     * @param name
+     * @return
+     */
+    public String getProperty(String name)
+    {        
+        if (name == null) 
+        {
+            throw new IllegalArgumentException("Property name == null");
+        }
+        return(String) properties.get(name);
+    }
+
+    /** 
+     * <p>
+     * getPropertyNames
+     * </p>
+     * 
+     * @see org.apache.pluto.services.information.PortalContextProvider#getPropertyNames()
+     * @return
+     */
+    public Collection getPropertyNames()
+    {     
+        return properties.keySet();
+    }
+
+    /** 
+     * <p>
+     * getSupportedPortletModes
+     * </p>
+     * 
+     * @see org.apache.pluto.services.information.PortalContextProvider#getSupportedPortletModes()
+     * @return
+     */
+    public Collection getSupportedPortletModes()
+    {
+        return modes;
+    }
+
+    /** 
+     * <p>
+     * getSupportedWindowStates
+     * </p>
+     * 
+     * @see org.apache.pluto.services.information.PortalContextProvider#getSupportedWindowStates()
+     * @return
+     */
+    public Collection getSupportedWindowStates()
+    {        
+        return states;
+    }
+
+    private Vector getDefaultModes()
+    {
+        Vector m = new Vector();
+        String[] supportedModes = Jetspeed.getContext().getConfiguration().getStringArray("supported.portletmode");
+        
+        for (int i=0; i<supportedModes.length; i++) 
+        {
+            m.add(new PortletMode(supportedModes[i].toString().toLowerCase()));
+        }
+
+        return m;
+    }
+
+    private Vector getDefaultStates()
+    {
+        Vector s = new Vector();
+        String[] supportedStates = Jetspeed.getContext().getConfiguration().getStringArray("supported.windowstate");
+
+        for (int i=0; i<supportedStates.length; i++) 
+        {
+            s.add(new WindowState(supportedStates[i].toString().toLowerCase()));
+        }
+
+        return s;
+    }
+
+    public void setProperty(String name, String value)
+    {
+        if (name == null) 
+        {
+            throw new IllegalArgumentException("Property name == null");
+        }
+        properties.put(name, value);
+    }      
+
+    // expects enumeration of PortletMode objects
+
+    public void setSupportedPortletModes(Enumeration portletModes)
+    {
+        Vector v = new Vector();
+
+        while (portletModes.hasMoreElements()) 
+        {
+            v.add(portletModes.nextElement());
+        }
+
+        modes = v;
+    }
+
+
+
+    // expects enumeration of WindowState objects
+
+    public void setSupportedWindowStates(Enumeration windowStates)
+    {
+        Vector v = new Vector();
+        while (windowStates.hasMoreElements()) 
+        {
+            v.add(windowStates.nextElement());
+        }
+
+        states = v;
+    }
+
+
+
+    /**
+     * reset all values to default portlet modes and window states;
+     * delete all properties and set the given portlet information
+     * as portlet info string.
+     * 
+     * @param  
+     * @param portalInfo  portal information string that will be returned
+     *                    by the <code>getPortalInfo</code> call.
+     */
+    public void reset(String portalInfo)
+
+    {
+        info = new String(portalInfo);
+
+        // these are the minimum modes that the portal needs to support
+        modes = getDefaultModes();
+
+        // these are the minimum states that the portal needs to support
+        states = getDefaultStates();    
+
+        properties.clear();
+    }
+
+}

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/core/PortletActionProviderImpl.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/core/PortletActionProviderImpl.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/core/PortletActionProviderImpl.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/core/PortletActionProviderImpl.java Tue Jul  5 14:55:37 2005
@@ -0,0 +1,64 @@
+/*
+ * Copyright 2000-2004 The 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 org.apache.jetspeed.engine.core;
+
+import javax.portlet.PortletMode;
+import javax.portlet.WindowState;
+
+import org.apache.pluto.om.window.PortletWindow;
+import org.apache.pluto.services.information.PortletActionProvider;
+import org.apache.jetspeed.container.state.MutableNavigationalState;
+
+/**
+ * Handle operations that the portlet may perform in an action method.
+ * This service is request based.
+ *
+ * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
+ * @version $Id: PortletActionProviderImpl.java 187753 2004-10-15 21:47:25Z ate $
+ */
+public class PortletActionProviderImpl implements PortletActionProvider
+{
+    private PortletWindow portletWindow;
+    private MutableNavigationalState navstate;
+    
+    public PortletActionProviderImpl(MutableNavigationalState navstate, PortletWindow portletWindow)
+    {
+        this.portletWindow = portletWindow;
+        this.navstate = navstate;       
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.pluto.services.information.PortletActionProvider#changePortletMode(PortletWindow, PortletMode)
+     */
+    public void changePortletMode(PortletMode mode)
+    {        
+        if (mode != null)
+        {
+            navstate.setMode(portletWindow, mode);
+        }
+    }
+
+    /* (non-Javadoc)
+     * @see org.apache.pluto.services.information.PortletActionProvider#changePortletWindowState(PortletWindow, WindowState)
+     */
+    public void changePortletWindowState(WindowState state)
+    {
+        if (state != null)
+        {
+            navstate.setState(portletWindow,state);
+        }
+    }
+}

Added: portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/HttpSessionWrapper.java
URL: http://svn.apache.org/viewcvs/portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/HttpSessionWrapper.java?rev=209328&view=auto
==============================================================================
--- portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/HttpSessionWrapper.java (added)
+++ portals/jetspeed-2/trunk/components/portal/src/java/org/apache/jetspeed/engine/servlet/HttpSessionWrapper.java Tue Jul  5 14:55:37 2005
@@ -0,0 +1,189 @@
+/*
+ * Copyright 2000-2004 The 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 org.apache.jetspeed.engine.servlet;
+
+import java.util.Enumeration;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpSession;
+
+/**
+ * @author Scott T Weaver
+ *
+ */
+public class HttpSessionWrapper implements HttpSession
+{
+    private HttpSession session;
+    
+    public HttpSessionWrapper(HttpSession session)
+    {
+        this.session = session;
+    }
+    
+
+    /* (non-Javadoc)
+     * @see java.lang.Object#equals(java.lang.Object)
+     */
+    public boolean equals(Object obj)
+    {
+        return session.equals(obj);
+    }
+    /**
+     * @param arg0
+     * @return
+     */
+    public Object getAttribute(String arg0)
+    {
+        return session.getAttribute(arg0);
+    }
+    /**
+     * @return
+     */
+    public Enumeration getAttributeNames()
+    {
+        return session.getAttributeNames();
+    }
+    /**
+     * @return
+     */
+    public long getCreationTime()
+    {
+        return session.getCreationTime();
+    }
+    /**
+     * @return
+     */
+    public String getId()
+    {
+        return session.getId();
+    }
+    /**
+     * @return
+     */
+    public long getLastAccessedTime()
+    {
+        return session.getLastAccessedTime();
+    }
+    /**
+     * @return
+     */
+    public int getMaxInactiveInterval()
+    {
+        return session.getMaxInactiveInterval();
+    }
+    /**
+     * @return
+     */
+    public ServletContext getServletContext()
+    {
+        return session.getServletContext();
+    }
+    
+    /**
+     * @deprecated As of Java(tm) Servlet API 2.1 
+     *  for security reasons, with no replacement.
+     * @return
+     */
+    public javax.servlet.http.HttpSessionContext getSessionContext()
+    {
+        return session.getSessionContext();
+    }
+    /**
+     * @deprecated @see javax.servlet.http.HttpSession#getValue(String)
+     * @param arg0
+     * @return
+     */
+    public Object getValue(String arg0)
+    {
+        return session.getValue(arg0);
+    }
+    
+    /**
+     * @deprecated @see javax.servlet.http.HttpSession#getValueNames(String)
+     * @return
+     */
+    public String[] getValueNames()
+    {
+        return session.getValueNames();
+    }
+    /* (non-Javadoc)
+     * @see java.lang.Object#hashCode()
+     */
+    public int hashCode()
+    {
+        return session.hashCode();
+    }
+    /**
+     * 
+     */
+    public void invalidate()
+    {
+        session.invalidate();
+    }
+    /**
+     * @return
+     */
+    public boolean isNew()
+    {
+        return session.isNew();
+    }
+    /**
+     * @deprecated @see javax.servlet.http.HttpSession#putValue(String,Object)
+     * @param arg0
+     * @param arg1
+     */
+    public void putValue(String arg0, Object arg1)
+    {
+        session.putValue(arg0, arg1);
+    }
+    /**
+     * @param arg0
+     */
+    public void removeAttribute(String arg0)
+    {
+        session.removeAttribute(arg0);
+    }
+    /**
+     * @deprecated @see javax.servlet.http.HttpSession#removeValue(String)
+     * @param arg0
+     */
+    public void removeValue(String arg0)
+    {
+        session.removeValue(arg0);
+    }
+    /**
+     * @param arg0
+     * @param arg1
+     */
+    public void setAttribute(String arg0, Object arg1)
+    {
+        session.setAttribute(arg0, arg1);
+    }
+    /**
+     * @param arg0
+     */
+    public void setMaxInactiveInterval(int arg0)
+    {
+        session.setMaxInactiveInterval(arg0);
+    }
+    /* (non-Javadoc)
+     * @see java.lang.Object#toString()
+     */
+    public String toString()
+    {
+        return session.toString();
+    }
+}



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


Mime
View raw message