Author: cziegeler
Date: Tue Apr 28 06:47:36 2009
New Revision: 769263
URL: http://svn.apache.org/viewvc?rev=769263&view=rev
Log:
Start portal container implementation for Sling.
Added:
incubator/sling/whiteboard/portal/
incubator/sling/whiteboard/portal/container-api/
incubator/sling/whiteboard/portal/container-api/pom.xml (with props)
incubator/sling/whiteboard/portal/container-api/src/
incubator/sling/whiteboard/portal/container-api/src/main/
incubator/sling/whiteboard/portal/container-api/src/main/java/
incubator/sling/whiteboard/portal/container-api/src/main/java/org/
incubator/sling/whiteboard/portal/container-api/src/main/java/org/apache/
incubator/sling/whiteboard/portal/container-api/src/main/java/org/apache/sling/
incubator/sling/whiteboard/portal/container-api/src/main/java/org/apache/sling/portal/
incubator/sling/whiteboard/portal/container-api/src/main/java/org/apache/sling/portal/container/
incubator/sling/whiteboard/portal/container-api/src/main/java/org/apache/sling/portal/container/api/
incubator/sling/whiteboard/portal/container-api/src/main/java/org/apache/sling/portal/container/api/Container.java
(with props)
incubator/sling/whiteboard/portal/container-api/src/main/java/org/apache/sling/portal/container/api/ContainerServlet.java
(with props)
incubator/sling/whiteboard/portal/container-api/src/main/java/org/apache/sling/portal/container/api/PortletApplication.java
(with props)
incubator/sling/whiteboard/portal/container-api/src/main/java/org/apache/sling/portal/container/api/PortletApplicationRegistry.java
(with props)
incubator/sling/whiteboard/portal/container-api/src/main/java/org/apache/sling/portal/container/api/PortletApplicationRegistryListener.java
(with props)
Added: incubator/sling/whiteboard/portal/container-api/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/sling/whiteboard/portal/container-api/pom.xml?rev=769263&view=auto
==============================================================================
--- incubator/sling/whiteboard/portal/container-api/pom.xml (added)
+++ incubator/sling/whiteboard/portal/container-api/pom.xml Tue Apr 28 06:47:36
2009
@@ -0,0 +1,73 @@
+<?xml version="1.0" encoding="ISO-8859-1"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one
+ or more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information
+ regarding copyright ownership. The ASF licenses this file
+ to you 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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0
http://maven.apache.org/maven-v4_0_0.xsd">
+
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.sling</groupId>
+ <artifactId>sling</artifactId>
+ <version>5-incubator-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.apache.sling.portal</groupId>
+ <artifactId>org.apache.sling.portal.container.api</artifactId>
+ <version>0.1.0-SNAPSHOT</version>
+ <packaging>jar</packaging>
+
+ <name>Apache Sling Portal Container API</name>
+ <description>
+ The shared portal container API for the Apache Sling Portal container.
+ </description>
+
+ <scm>
+
<connection>scm:svn:http://svn.apache.org/repos/asf/incubator/sling/whiteboard/portal/container-api</connection>
+
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/incubator/sling/whiteboard/portal/container-api</developerConnection>
+
<url>http://svn.apache.org/viewvc/incubator/sling/whiteboard/portal/container-api</url>
+ </scm>
+
+ <!--
====================================================================== -->
+ <!-- R E P O R T I N G
-->
+ <!--
====================================================================== -->
+ <reporting>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-javadoc-plugin</artifactId>
+ </plugin>
+ </plugins>
+ </reporting>
+
+ <dependencies>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.4</version>
+ <scope>provided</scope>
+ </dependency>
+
+ <!-- Portlet API -->
+ <dependency>
+ <groupId>javax.portlet</groupId>
+ <artifactId>portlet-api</artifactId>
+ <version>2.0</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+</project>
Propchange: incubator/sling/whiteboard/portal/container-api/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: incubator/sling/whiteboard/portal/container-api/pom.xml
------------------------------------------------------------------------------
svn:keywords = Id
Propchange: incubator/sling/whiteboard/portal/container-api/pom.xml
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
incubator/sling/whiteboard/portal/container-api/src/main/java/org/apache/sling/portal/container/api/Container.java
URL:
http://svn.apache.org/viewvc/incubator/sling/whiteboard/portal/container-api/src/main/java/org/apache/sling/portal/container/api/Container.java?rev=769263&view=auto
==============================================================================
---
incubator/sling/whiteboard/portal/container-api/src/main/java/org/apache/sling/portal/container/api/Container.java
(added)
+++
incubator/sling/whiteboard/portal/container-api/src/main/java/org/apache/sling/portal/container/api/Container.java
Tue Apr 28 06:47:36 2009
@@ -0,0 +1,41 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.sling.portal.container.api;
+
+import java.io.IOException;
+
+import javax.portlet.PortletException;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+
+/**
+ * The main container interface which is used in combination with the
+ * {...@link ContainerServlet}. The Apache Sling portal forwards portlet
+ * requests to the portlet application. The container servlet receives
+ * the request and then invokes the container.
+ * This ensures that the proper http request and response objects are
+ * used for serving the request.
+ */
+public interface Container {
+
+ /** The request attribute containing the container. */
+ String ATTR_CONTAINER = Container.class.getName();
+
+ void service(HttpServletRequest request, HttpServletResponse response)
+ throws PortletException, IOException;
+}
Propchange:
incubator/sling/whiteboard/portal/container-api/src/main/java/org/apache/sling/portal/container/api/Container.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/sling/whiteboard/portal/container-api/src/main/java/org/apache/sling/portal/container/api/Container.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Propchange:
incubator/sling/whiteboard/portal/container-api/src/main/java/org/apache/sling/portal/container/api/Container.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
incubator/sling/whiteboard/portal/container-api/src/main/java/org/apache/sling/portal/container/api/ContainerServlet.java
URL:
http://svn.apache.org/viewvc/incubator/sling/whiteboard/portal/container-api/src/main/java/org/apache/sling/portal/container/api/ContainerServlet.java?rev=769263&view=auto
==============================================================================
---
incubator/sling/whiteboard/portal/container-api/src/main/java/org/apache/sling/portal/container/api/ContainerServlet.java
(added)
+++
incubator/sling/whiteboard/portal/container-api/src/main/java/org/apache/sling/portal/container/api/ContainerServlet.java
Tue Apr 28 06:47:36 2009
@@ -0,0 +1,93 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.sling.portal.container.api;
+
+import java.io.IOException;
+
+import javax.portlet.PortletException;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * Apache Sling Container servlet filter. This servlet filter
+ * is the entry point for all portlet invocations.
+ */
+public class ContainerServlet
+ extends HttpServlet
+ implements PortletApplication {
+
+ /** The classloader. */
+ private ClassLoader classloader;
+
+ /**
+ * @see
org.apache.sling.portal.container.api.PortletApplication#getClassLoader()
+ */
+ public ClassLoader getClassLoader() {
+ return this.classloader;
+ }
+
+ /**
+ * @see javax.servlet.GenericServlet#init(javax.servlet.ServletConfig)
+ */
+ public void init(ServletConfig config) throws ServletException {
+ // register this portlet application
+ super.init(config);
+ this.classloader = Thread.currentThread().getContextClassLoader();
+ if ( this.classloader == null ) {
+ this.classloader = this.getClass().getClassLoader();
+ }
+
PortletApplicationRegistry.getContainerPortletRegistry().register(this);
+ }
+
+ /**
+ * @see javax.servlet.GenericServlet#destroy()
+ */
+ public void destroy() {
+ // unregister this portlet application
+
PortletApplicationRegistry.getContainerPortletRegistry().unregister(this);
+ this.classloader = null;
+ super.destroy();
+ }
+
+ /**
+ * @see
javax.servlet.http.HttpServlet#service(javax.servlet.ServletRequest,
javax.servlet.ServletResponse)
+ */
+ public void service(ServletRequest req, ServletResponse res)
+ throws ServletException, IOException {
+ if ( req instanceof HttpServletRequest &&
+ req.getAttribute(Container.ATTR_CONTAINER) != null ) {
+ // this is a portlet invocation!
+
+ final HttpServletRequest request = (HttpServletRequest)req;
+ final HttpServletResponse response = (HttpServletResponse)res;
+
+ final Container container = (Container)
request.getAttribute(Container.ATTR_CONTAINER);
+ try {
+ container.service(request, response);
+ } catch (PortletException ex) {
+ throw new ServletException(ex);
+ } finally {
+ req.removeAttribute(Container.ATTR_CONTAINER);
+ }
+ }
+ }
+}
Propchange:
incubator/sling/whiteboard/portal/container-api/src/main/java/org/apache/sling/portal/container/api/ContainerServlet.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/sling/whiteboard/portal/container-api/src/main/java/org/apache/sling/portal/container/api/ContainerServlet.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Propchange:
incubator/sling/whiteboard/portal/container-api/src/main/java/org/apache/sling/portal/container/api/ContainerServlet.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
incubator/sling/whiteboard/portal/container-api/src/main/java/org/apache/sling/portal/container/api/PortletApplication.java
URL:
http://svn.apache.org/viewvc/incubator/sling/whiteboard/portal/container-api/src/main/java/org/apache/sling/portal/container/api/PortletApplication.java?rev=769263&view=auto
==============================================================================
---
incubator/sling/whiteboard/portal/container-api/src/main/java/org/apache/sling/portal/container/api/PortletApplication.java
(added)
+++
incubator/sling/whiteboard/portal/container-api/src/main/java/org/apache/sling/portal/container/api/PortletApplication.java
Tue Apr 28 06:47:36 2009
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.sling.portal.container.api;
+
+import javax.servlet.ServletContext;
+
+
+/**
+ * This is a singleton container portlet registry keeping track
+ * of all registered portlets.
+ */
+public interface PortletApplication {
+
+ /**
+ * Get the servlet context for this portlet application.
+ */
+ ServletContext getServletContext();
+
+ /**
+ * Get the classloader for this portlet application
+ */
+ ClassLoader getClassLoader();
+}
Propchange:
incubator/sling/whiteboard/portal/container-api/src/main/java/org/apache/sling/portal/container/api/PortletApplication.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/sling/whiteboard/portal/container-api/src/main/java/org/apache/sling/portal/container/api/PortletApplication.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Propchange:
incubator/sling/whiteboard/portal/container-api/src/main/java/org/apache/sling/portal/container/api/PortletApplication.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
incubator/sling/whiteboard/portal/container-api/src/main/java/org/apache/sling/portal/container/api/PortletApplicationRegistry.java
URL:
http://svn.apache.org/viewvc/incubator/sling/whiteboard/portal/container-api/src/main/java/org/apache/sling/portal/container/api/PortletApplicationRegistry.java?rev=769263&view=auto
==============================================================================
---
incubator/sling/whiteboard/portal/container-api/src/main/java/org/apache/sling/portal/container/api/PortletApplicationRegistry.java
(added)
+++
incubator/sling/whiteboard/portal/container-api/src/main/java/org/apache/sling/portal/container/api/PortletApplicationRegistry.java
Tue Apr 28 06:47:36 2009
@@ -0,0 +1,100 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.sling.portal.container.api;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * This is a singleton container portlet registry keeping track
+ * of all registered portlets.
+ * A portlet application should register and unregister itself through
+ * {...@link #register(PortletApplication)} and
+ * {...@link #unregister(PortletApplication)}.
+ * A portal should add itself as a listener {...@link
#addListener(PortletApplicationRegistryListener)}.
+ */
+public class PortletApplicationRegistry {
+
+ /** The singleton */
+ private static final PortletApplicationRegistry SINGLETON = new
PortletApplicationRegistry();
+
+ /** Listeners */
+ private final List<PortletApplicationRegistryListener> listeners = new
ArrayList<PortletApplicationRegistryListener>();
+
+ /** Callbacks */
+ private final List<PortletApplication> callbacks = new
ArrayList<PortletApplication>();
+
+ /**
+ * Return the container registry singleton.
+ */
+ public static PortletApplicationRegistry getContainerPortletRegistry() {
+ return SINGLETON;
+ }
+
+ /**
+ * Register a new portlet application.
+ */
+ public synchronized void register(final PortletApplication callback) {
+ if ( callback != null ) {
+ this.callbacks.add(callback);
+ for(final PortletApplicationRegistryListener listener : listeners)
{
+ listener.notifyPortletApplicationAdded(callback);
+ }
+ }
+ }
+
+ /**
+ * Unrgister a portlet application.
+ */
+ public synchronized void unregister(final PortletApplication callback) {
+ if ( callback != null ) {
+ this.callbacks.remove(callback);
+ for(final PortletApplicationRegistryListener listener : listeners)
{
+ listener.notifyPortletApplicationRemoved(callback);
+ }
+ }
+ }
+
+ /**
+ * Add a listener.
+ * When a listener is added all currently registered portlet applications
+ * are notified to the new listener.
+ */
+ public synchronized void addListener(PortletApplicationRegistryListener
listener) {
+ if ( listener != null ) {
+ this.listeners.add(listener);
+ for(final PortletApplication callback : callbacks) {
+ listener.notifyPortletApplicationAdded(callback);
+ }
+ }
+ }
+
+ /**
+ * Remove a listener.
+ * When a listener is removed all currently registred portelt applications
+ * are notified as removed to the removed listener.
+ */
+ public synchronized void removeListener(PortletApplicationRegistryListener
listener) {
+ if ( listener != null ) {
+ this.listeners.add(listener);
+ for(final PortletApplication callback : callbacks) {
+ listener.notifyPortletApplicationRemoved(callback);
+ }
+ }
+ }
+}
Propchange:
incubator/sling/whiteboard/portal/container-api/src/main/java/org/apache/sling/portal/container/api/PortletApplicationRegistry.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/sling/whiteboard/portal/container-api/src/main/java/org/apache/sling/portal/container/api/PortletApplicationRegistry.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Propchange:
incubator/sling/whiteboard/portal/container-api/src/main/java/org/apache/sling/portal/container/api/PortletApplicationRegistry.java
------------------------------------------------------------------------------
svn:mime-type = text/plain
Added:
incubator/sling/whiteboard/portal/container-api/src/main/java/org/apache/sling/portal/container/api/PortletApplicationRegistryListener.java
URL:
http://svn.apache.org/viewvc/incubator/sling/whiteboard/portal/container-api/src/main/java/org/apache/sling/portal/container/api/PortletApplicationRegistryListener.java?rev=769263&view=auto
==============================================================================
---
incubator/sling/whiteboard/portal/container-api/src/main/java/org/apache/sling/portal/container/api/PortletApplicationRegistryListener.java
(added)
+++
incubator/sling/whiteboard/portal/container-api/src/main/java/org/apache/sling/portal/container/api/PortletApplicationRegistryListener.java
Tue Apr 28 06:47:36 2009
@@ -0,0 +1,33 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You 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.sling.portal.container.api;
+
+/**
+ * This is a listener for the portlet registry.
+ */
+public interface PortletApplicationRegistryListener {
+
+ /**
+ * Notify the listener about a new portlet application.
+ */
+ void notifyPortletApplicationAdded(PortletApplication callback);
+
+ /**
+ * Notify the listenre about a removed portlet application.
+ */
+ void notifyPortletApplicationRemoved(PortletApplication callback);
+}
Propchange:
incubator/sling/whiteboard/portal/container-api/src/main/java/org/apache/sling/portal/container/api/PortletApplicationRegistryListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange:
incubator/sling/whiteboard/portal/container-api/src/main/java/org/apache/sling/portal/container/api/PortletApplicationRegistryListener.java
------------------------------------------------------------------------------
svn:keywords = author date id revision rev url
Propchange:
incubator/sling/whiteboard/portal/container-api/src/main/java/org/apache/sling/portal/container/api/PortletApplicationRegistryListener.java
------------------------------------------------------------------------------
svn:mime-type = text/plain