Author: pnedonosko
Date: 2011-04-19 11:38:43 -0400 (Tue, 19 Apr 2011)
New Revision: 4256
Added:
ws/tags/2.1.8-GA-BONITA/
ws/tags/2.1.8-GA-BONITA/exo.ws.frameworks.servlet/
ws/tags/2.1.8-GA-BONITA/exo.ws.frameworks.servlet/pom.xml
ws/tags/2.1.8-GA-BONITA/exo.ws.frameworks.servlet/src/
ws/tags/2.1.8-GA-BONITA/exo.ws.frameworks.servlet/src/main/
ws/tags/2.1.8-GA-BONITA/exo.ws.frameworks.servlet/src/main/java/
ws/tags/2.1.8-GA-BONITA/exo.ws.frameworks.servlet/src/main/java/org/
ws/tags/2.1.8-GA-BONITA/exo.ws.frameworks.servlet/src/main/java/org/exoplatform/
ws/tags/2.1.8-GA-BONITA/exo.ws.frameworks.servlet/src/main/java/org/exoplatform/ws/
ws/tags/2.1.8-GA-BONITA/exo.ws.frameworks.servlet/src/main/java/org/exoplatform/ws/frameworks/
ws/tags/2.1.8-GA-BONITA/exo.ws.frameworks.servlet/src/main/java/org/exoplatform/ws/frameworks/servlet/
ws/tags/2.1.8-GA-BONITA/exo.ws.frameworks.servlet/src/main/java/org/exoplatform/ws/frameworks/servlet/AliasedURLRequestRedirector.java
ws/tags/2.1.8-GA-BONITA/exo.ws.frameworks.servlet/src/main/java/org/exoplatform/ws/frameworks/servlet/AnonymousUserContextRedirectionFilter.java
ws/tags/2.1.8-GA-BONITA/exo.ws.frameworks.servlet/src/main/java/org/exoplatform/ws/frameworks/servlet/PortalContainerInitializedFilter.java
ws/tags/2.1.8-GA-BONITA/exo.ws.frameworks.servlet/src/main/java/org/exoplatform/ws/frameworks/servlet/StandaloneContainerInitializedListener.java
ws/tags/2.1.8-GA-BONITA/pom.xml
Log:
WS-264 2.1.8-GA-BONITA tag
Added: ws/tags/2.1.8-GA-BONITA/exo.ws.frameworks.servlet/pom.xml
===================================================================
--- ws/tags/2.1.8-GA-BONITA/exo.ws.frameworks.servlet/pom.xml (rev
0)
+++ ws/tags/2.1.8-GA-BONITA/exo.ws.frameworks.servlet/pom.xml 2011-04-19 15:38:43 UTC (rev
4256)
@@ -0,0 +1,53 @@
+<!--
+
+ Copyright (C) 2009 eXo Platform SAS.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+
+-->
+<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.exoplatform.ws</groupId>
+ <artifactId>ws-parent</artifactId>
+ <version>2.1.8-GA-BONITA</version>
+ </parent>
+
+ <artifactId>exo.ws.frameworks.servlet</artifactId>
+
+ <name>eXo WS :: Framework :: Servlet</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.kernel</groupId>
+ <artifactId>exo.kernel.component.common</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.kernel</groupId>
+ <artifactId>exo.kernel.commons</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.kernel</groupId>
+ <artifactId>exo.kernel.container</artifactId>
+ </dependency>
+ </dependencies>
+</project>
Added:
ws/tags/2.1.8-GA-BONITA/exo.ws.frameworks.servlet/src/main/java/org/exoplatform/ws/frameworks/servlet/AliasedURLRequestRedirector.java
===================================================================
---
ws/tags/2.1.8-GA-BONITA/exo.ws.frameworks.servlet/src/main/java/org/exoplatform/ws/frameworks/servlet/AliasedURLRequestRedirector.java
(rev 0)
+++
ws/tags/2.1.8-GA-BONITA/exo.ws.frameworks.servlet/src/main/java/org/exoplatform/ws/frameworks/servlet/AliasedURLRequestRedirector.java 2011-04-19
15:38:43 UTC (rev 4256)
@@ -0,0 +1,234 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.exoplatform.ws.frameworks.servlet;
+
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.Map;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletRequestWrapper;
+
+/**
+ * Created by The eXo Platform SAS.
+ * @author <a href="mailto:vitaly.parfonov@gmail.com">Vitaly
Parfonov</a>
+ * @version $Id: $
+ */
+public class AliasedURLRequestRedirector implements Filter
+{
+
+ //TODO
+ private static String START_ESCAPED = "%7B$";
+
+ private static String END_ESCAPED = "%7D";
+
+ private static String START = "{$";
+
+ private static String END = "}";
+
+ Map<String, String> replaceMap = new HashMap<String, String>();
+
+ /**
+ * Filter configuration.
+ */
+ // private FilterConfig conf;
+
+ // private String contextName;
+
+ /**
+ * Filter initialization method.
+ *
+ * @param conf filter configuration
+ * @throws ServletException exception
+ * @see javax.servlet.Filter#init(javax.servlet.FilterConfig)
+ */
+ @SuppressWarnings("unchecked")
+ public void init(FilterConfig conf) throws ServletException
+ {
+ // this.contextName = conf.getServletContext().getServletContextName();
+ // this.conf = conf;
+ Enumeration<String> enumeration = conf.getInitParameterNames();
+ while (enumeration.hasMoreElements())
+ {
+ String key = (String)enumeration.nextElement();
+ String val = conf.getInitParameter(key);
+ replaceMap.put(key, val);
+ }
+ }
+
+ /**
+ * Filter finalization method.
+ *
+ * @see javax.servlet.Filter#destroy()
+ */
+ public void destroy()
+ {
+ }
+
+ /**
+ * The main filter method. Wraps the original http request with the custom wrapper and
calls chain.
+ *
+ * @param req original request
+ * @param res original response
+ * @param chain filter chain
+ * @throws IOException exception
+ * @throws ServletException exception
+ * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest,
javax.servlet.ServletResponse, javax.servlet.FilterChain)
+ */
+ public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)
throws IOException,
+ ServletException
+ {
+ chain.doFilter(createRequestWrapper(req), res);
+ }
+
+ /**
+ * Locates PageProvider component in the container, gets map of the URL parameters to
replace,
+ * then creates the custom wrapper and passes the map to it.
+ *
+ * @param req original request
+ * @return
+ */
+ private ServletRequest createRequestWrapper(ServletRequest req)
+ {
+ // replaceMap.put("context", contextName);
+ return new UrlReplacerWrapper((HttpServletRequest)req, replaceMap);
+ }
+
+ /**
+ * The custom http request wrapper that is designed to substitute given parameters in
URLs
+ * with corresponding values. Parameters are marked at an URL in the form:
{$parameter-name}
+ *
+ */
+ public class UrlReplacerWrapper extends HttpServletRequestWrapper
+ {
+
+ /**
+ * Map with substitutes.
+ */
+ private final Map<String, String> replaceMap;
+
+ /**
+ * Generated path info.
+ */
+ private String pathInfo;
+
+ /**
+ * Generated request uri.
+ */
+ private String requestUri;
+
+ /**
+ * Generated request url.
+ */
+ private StringBuffer requestUrl;
+
+ /**
+ * @param request original request
+ * @param replaceMap replace map
+ */
+ public UrlReplacerWrapper(HttpServletRequest request, Map<String, String>
replaceMap)
+ {
+ super(request);
+ this.replaceMap = replaceMap;
+ pathInfo = replaceByMap(super.getPathInfo());
+ requestUri = replaceByMap(super.getRequestURI());
+ StringBuffer sb = super.getRequestURL();
+ if (sb != null)
+ requestUrl = new StringBuffer(replaceByMap(sb.toString()));
+ else
+ requestUrl = null;
+ }
+
+ /**
+ * Actual URL substitution method.
+ *
+ * @param path
+ * @return
+ */
+ //TODO
+ private String replaceByMap(String path)
+ {
+ if (path == null)
+ return null;
+ // if (path.indexOf(START) < 0 || path.indexOf(START_ESCAPED)< 0)
+ // return path;
+ String result = path;
+ for (Iterator<String> i = replaceMap.keySet().iterator(); i.hasNext();)
+ {
+ String name = i.next();
+ String value = replaceMap.get(name);
+ if (value != null)
+ {
+ if (path.indexOf(START) > 0)
+ {
+ result = result.replace(START + name + END, value);
+ }
+ if (path.indexOf(START_ESCAPED) > 0)
+ {
+ result = result.replace(START_ESCAPED + name + END_ESCAPED, value);
+ }
+ }
+ }
+ return result;
+ }
+
+ /**
+ * Overridden method.
+ *
+ * @return actual path info
+ * @see javax.servlet.http.HttpServletRequestWrapper#getPathInfo()
+ */
+ public String getPathInfo()
+ {
+ return pathInfo;
+ }
+
+ /**
+ * Overridden method.
+ *
+ * @return actual URI
+ * @see javax.servlet.http.HttpServletRequestWrapper#getRequestURI()
+ */
+ public String getRequestURI()
+ {
+ return requestUri;
+ }
+
+ /**
+ * Overridden method.
+ *
+ * @return actual URL
+ * @see javax.servlet.http.HttpServletRequestWrapper#getRequestURL()
+ */
+ public StringBuffer getRequestURL()
+ {
+ return requestUrl;
+ }
+
+ }
+
+}
Added:
ws/tags/2.1.8-GA-BONITA/exo.ws.frameworks.servlet/src/main/java/org/exoplatform/ws/frameworks/servlet/AnonymousUserContextRedirectionFilter.java
===================================================================
---
ws/tags/2.1.8-GA-BONITA/exo.ws.frameworks.servlet/src/main/java/org/exoplatform/ws/frameworks/servlet/AnonymousUserContextRedirectionFilter.java
(rev 0)
+++
ws/tags/2.1.8-GA-BONITA/exo.ws.frameworks.servlet/src/main/java/org/exoplatform/ws/frameworks/servlet/AnonymousUserContextRedirectionFilter.java 2011-04-19
15:38:43 UTC (rev 4256)
@@ -0,0 +1,161 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.exoplatform.ws.frameworks.servlet;
+
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLEncoder;
+
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+/**
+ * Checks out if username present in HttpServletRequest then initializes
+ * SessionProvider by getting current credentials from AuthenticationService
+ * and keeps SessionProvider in ThreadLocalSessionProviderService.
+ * Otherwise redirect request to alternative URL. Alternative web application
+ * can ask about authentication again or not and gives or denies access to
+ * requested resource.
+ * Filter requires parameter <code>context-name</code>, otherwise
+ * ServletException will be thrown.
+ *
+ * @author <a href="mailto:andrew00x@gmail.com">Andrey
Parfonov</a>
+ * @version $Id: $
+ */
+public class AnonymousUserContextRedirectionFilter implements Filter
+{
+
+ /**
+ * context-name.
+ */
+ private final static String CONTEXT_NAME_PARAMETER = "context-name";
+
+ /**
+ * Logger.
+ */
+ private final static Log LOG =
ExoLogger.getLogger("exo.ws.frameworks.servlet.AnonymousUserContextRedirectionFilter");
+
+ /**
+ * The name of context.
+ */
+ private String contextName;
+
+ /**
+ * {@inheritDoc}
+ */
+ public void destroy()
+ {
+ // nothing to do.
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain
filterChain) throws IOException,
+ ServletException
+ {
+ HttpServletRequest httpRequest = (HttpServletRequest)request;
+ String user = httpRequest.getRemoteUser();
+
+ if (LOG.isDebugEnabled())
+ LOG.debug("Current user '" + user + "'.");
+
+ if (user != null)
+ {
+ filterChain.doFilter(request, response);
+ }
+ else
+ {
+
+ if (LOG.isDebugEnabled())
+ LOG.debug("Redirect user to context '" + contextName +
"'.");
+
+ String pathInfo = httpRequest.getPathInfo();
+ String query = httpRequest.getQueryString();
+
+ /* Problem with LinkGenerator required to do this!
+ * It is necessary to encode URI before redirect, otherwise
+ * we get invalid URL (if it contains not ASCII characters).
+ * When client (MS Word, for example) we get unparsed 'plus'
+ * in URL in WebDAV server. Currently it works and best
+ * solution for now.
+ *
+ * ******************************************************
+ * NOTE: We are not care about query parameters here!!!
+ *
+ * j2ee documentation says about method HttpServletRequest#getQueryString():
+ * "The value is not decoded by the container."
+ * This string must be encoded by client, for LinkGenerator.
+ */
+ ((HttpServletResponse)response).sendRedirect(encodeURL(contextName + pathInfo)
+ + (query != null ? "?" + query : ""));
+
+ }
+ }
+
+ /**
+ * Encode URL by URLEncoder#encode(url), then replace all '+' by '%20'
.
+ * @param url source String.
+ * @return encoded String.
+ * @throws UnsupportedEncodingException if encoding is unsupported.
+ */
+ private static String encodeURL(String url) throws UnsupportedEncodingException
+ {
+
+ StringBuffer sb = new StringBuffer();
+ String[] paths = url.split("/");
+ for (int i = 0; i < paths.length; i++)
+ {
+ if ("".equals(paths[i]))
+ continue;
+
+ String t = URLEncoder.encode(paths[i], "UTF-8");
+ t = t.replace("+", "%20");
+ sb.append('/').append(t);
+
+ }
+
+ return sb.toString();
+ }
+
+ /**
+ * Get context name. It must be specified as init parameter.
+ * {@inheritDoc}
+ */
+ public void init(FilterConfig filterConfig) throws ServletException
+ {
+ contextName = filterConfig.getInitParameter(CONTEXT_NAME_PARAMETER);
+ if (contextName == null)
+ {
+ LOG.error("AnonymousUserContextRedirectionFilter is not deployed. Set
Init-param '" + CONTEXT_NAME_PARAMETER
+ + " pointed to the target context name in the web.xml");
+ throw new ServletException("Filter error. Init-param '" +
CONTEXT_NAME_PARAMETER + "' is null.");
+ }
+ }
+
+}
Added:
ws/tags/2.1.8-GA-BONITA/exo.ws.frameworks.servlet/src/main/java/org/exoplatform/ws/frameworks/servlet/PortalContainerInitializedFilter.java
===================================================================
---
ws/tags/2.1.8-GA-BONITA/exo.ws.frameworks.servlet/src/main/java/org/exoplatform/ws/frameworks/servlet/PortalContainerInitializedFilter.java
(rev 0)
+++
ws/tags/2.1.8-GA-BONITA/exo.ws.frameworks.servlet/src/main/java/org/exoplatform/ws/frameworks/servlet/PortalContainerInitializedFilter.java 2011-04-19
15:38:43 UTC (rev 4256)
@@ -0,0 +1,94 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.exoplatform.ws.frameworks.servlet;
+
+import org.exoplatform.container.ExoContainer;
+import org.exoplatform.container.ExoContainerContext;
+import org.exoplatform.container.PortalContainer;
+import org.exoplatform.container.RootContainer;
+import org.exoplatform.container.web.AbstractFilter;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+
+import java.io.IOException;
+
+import javax.servlet.FilterChain;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+
+/**
+ * Created by The eXo Platform SAS .<br/>
+ * Servlet Filter that is used to initialize and remove the portal container from the
ThreadLocal
+ * of PortalContainer, it relies on PortalContainer.getCurrentInstance to retrieve the
right portal container.
+ *
+ * @author Gennady Azarenkov
+ * @version $Id: $
+ */
+public class PortalContainerInitializedFilter extends AbstractFilter
+{
+
+ private static final Log LOG =
ExoLogger.getLogger("exo.ws.frameworks.servlet.PortatContainerInitializedFilter");
+
+ /**
+ * initializes PortalContainer instance.
+ *
+ * @see javax.servlet.Filter#doFilter(javax.servlet.ServletRequest,
+ * javax.servlet.ServletResponse, javax.servlet.FilterChain)
+ */
+ public void doFilter(ServletRequest request, ServletResponse response, FilterChain
chain) throws IOException,
+ ServletException
+ {
+ ExoContainer container = getContainer();
+ if (!(container instanceof PortalContainer))
+ {
+ container =
RootContainer.getInstance().getPortalContainer(PortalContainer.DEFAULT_PORTAL_CONTAINER_NAME);
+ if (container == null)
+ {
+ throw new ServletException("Could not initialize PortalContainer."
+ "Current ExoContainer is: "
+ + ExoContainerContext.getCurrentContainer());
+ }
+ }
+ PortalContainer pcontainer = (PortalContainer)container;
+ try
+ {
+ PortalContainer.setInstance(pcontainer);
+ chain.doFilter(request, response);
+ }
+ finally
+ {
+ try
+ {
+ PortalContainer.setInstance(null);
+ }
+ catch (Exception e)
+ {
+ LOG.warn("An error occured while cleaning the ThreadLocal", e);
+ }
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void destroy()
+ {
+ }
+
+}
Added:
ws/tags/2.1.8-GA-BONITA/exo.ws.frameworks.servlet/src/main/java/org/exoplatform/ws/frameworks/servlet/StandaloneContainerInitializedListener.java
===================================================================
---
ws/tags/2.1.8-GA-BONITA/exo.ws.frameworks.servlet/src/main/java/org/exoplatform/ws/frameworks/servlet/StandaloneContainerInitializedListener.java
(rev 0)
+++
ws/tags/2.1.8-GA-BONITA/exo.ws.frameworks.servlet/src/main/java/org/exoplatform/ws/frameworks/servlet/StandaloneContainerInitializedListener.java 2011-04-19
15:38:43 UTC (rev 4256)
@@ -0,0 +1,121 @@
+/*
+ * Copyright (C) 2009 eXo Platform SAS.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+ */
+package org.exoplatform.ws.frameworks.servlet;
+
+import org.exoplatform.container.StandaloneContainer;
+import org.exoplatform.container.configuration.ConfigurationManagerImpl;
+import org.exoplatform.services.log.ExoLogger;
+import org.exoplatform.services.log.Log;
+import org.exoplatform.services.naming.InitialContextInitializer;
+
+import java.net.MalformedURLException;
+
+import javax.servlet.ServletContextEvent;
+import javax.servlet.ServletContextListener;
+
+/**
+ * Created by The eXo Platform SAS .<br/> Servlet context initializer that
+ * initializes standalone container at the context startup time. To activate
+ * this your web.xml have to be configured like:<br/>
+ * <listener><br/>
+ *
<listener-class>org.exoplatform.frameworks.web.common.StandaloneContainerInitializedListener</listener-class><br/>
+ * </listener><br/>
+ * You may also specify an URL to the
+ * configuration.xml stored the configuration for StandaloneContainer as
+ * servlet's init parameter called
'org.exoplatform.container.standalone.config'
+ *
+ * @author <a href="mailto:gennady.azarenkov@exoplatform.com">Gennady
+ * Azarenkov</a>
+ * @version $Id: StandaloneContainerInitializedListener.java 6739 2006-07-04
+ * 14:34:49Z gavrikvetal $
+ */
+
+public class StandaloneContainerInitializedListener implements ServletContextListener
+{
+
+ private static final Log LOG =
ExoLogger.getLogger("exo.ws.frameworks.servlet.StandaloneContainerInitializedListener");
+
+ private static final String CONF_URL_PARAMETER =
"org.exoplatform.container.standalone.config";
+
+ private static final String PREFIX_WAR = "war:";
+
+ /**
+ * Container.
+ */
+ private StandaloneContainer container;
+
+ /**
+ * {@inheritDoc}
+ */
+ public void contextInitialized(ServletContextEvent event)
+ {
+ String configurationURL =
event.getServletContext().getInitParameter(CONF_URL_PARAMETER);
+
+ try
+ {
+ if (configurationURL != null &&
configurationURL.startsWith(PREFIX_WAR))
+ {
+ configurationURL =
+
event.getServletContext().getResource(configurationURL.substring(PREFIX_WAR.length())).toExternalForm();
+ }
+ }
+ catch (Exception e)
+ {
+ LOG.error("Error of configurationURL read", e);
+ }
+
+ try
+ {
+ StandaloneContainer.addConfigurationURL(configurationURL);
+ }
+ catch (MalformedURLException e)
+ {
+ LOG.error("Error of addConfigurationURL", e);
+ }
+
+ try
+ {
+ container =
StandaloneContainer.getInstance(Thread.currentThread().getContextClassLoader());
+
+ // Patch for tomcat InitialContext
+ InitialContextInitializer ic =
+
(InitialContextInitializer)container.getComponentInstanceOfType(InitialContextInitializer.class);
+
+ if (ic != null)
+ {
+ ic.recall();
+ }
+
+
event.getServletContext().setAttribute("org.exoplatform.frameworks.web.eXoContainer",
container);
+ }
+ catch (Exception e)
+ {
+ LOG.error("Error of StandaloneContainer initialization", e);
+ }
+
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void contextDestroyed(ServletContextEvent event)
+ {
+ // container.stop();
+ }
+}
Added: ws/tags/2.1.8-GA-BONITA/pom.xml
===================================================================
--- ws/tags/2.1.8-GA-BONITA/pom.xml (rev 0)
+++ ws/tags/2.1.8-GA-BONITA/pom.xml 2011-04-19 15:38:43 UTC (rev 4256)
@@ -0,0 +1,179 @@
+<!--
+
+ Copyright (C) 2009 eXo Platform SAS.
+
+ This is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as
+ published by the Free Software Foundation; either version 2.1 of
+ the License, or (at your option) any later version.
+
+ This software is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public
+ License along with this software; if not, write to the Free
+ Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ 02110-1301 USA, or see the FSF site:
http://www.fsf.org.
+
+-->
+<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.exoplatform</groupId>
+ <artifactId>foundation-parent</artifactId>
+ <version>7</version>
+ </parent>
+
+ <groupId>org.exoplatform.ws</groupId>
+ <artifactId>ws-parent</artifactId>
+ <version>2.1.8-GA-BONITA</version>
+ <packaging>pom</packaging>
+ <name>eXo WS BONITA</name>
+
+ <scm>
+
<
connection>scm:svn:http://anonsvn.jboss.org/repos/exo-jcr/ws/tags/2.1....
+
<
developerConnection>scm:svn:https://svn.jboss.org/repos/exo-jcr/ws/tag...
+
<
url>http://fisheye.jboss.org/browse/exo-jcr/ws/tags/2.1.8-GA-BONITA<...
+ </scm>
+
+ <properties>
+ <exo.product.name>exo-ws</exo.product.name>
+ <exo.product.specification>2.1</exo.product.specification>
+
+
<org.exoplatform.kernel.version>2.2.8-GA</org.exoplatform.kernel.version>
+ <org.exoplatform.core.version>2.3.8-GA</org.exoplatform.core.version>
+ </properties>
+
+ <modules>
+ <module>exo.ws.frameworks.servlet</module>
+ </modules>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.exoplatform.kernel</groupId>
+ <artifactId>exo.kernel.commons</artifactId>
+ <version>${org.exoplatform.kernel.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.kernel</groupId>
+ <artifactId>exo.kernel.container</artifactId>
+ <version>${org.exoplatform.kernel.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.kernel</groupId>
+ <artifactId>exo.kernel.component.common</artifactId>
+ <version>${org.exoplatform.kernel.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.core</groupId>
+ <artifactId>exo.core.component.xml-processing</artifactId>
+ <version>${org.exoplatform.core.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.ws</groupId>
+ <artifactId>exo.ws.frameworks.json</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.ws</groupId>
+ <artifactId>exo.ws.testframework</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.ws</groupId>
+ <artifactId>exo.ws.commons</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.ws</groupId>
+ <artifactId>exo.ws.rest.core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.xml.stream</groupId>
+ <artifactId>stax-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.servlet</groupId>
+ <artifactId>servlet-api</artifactId>
+ <version>2.4</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.mail</groupId>
+ <artifactId>mail</artifactId>
+ <version>1.4</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.activation</groupId>
+ <artifactId>activation</artifactId>
+ <version>1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.xml.bind</groupId>
+ <artifactId>jaxb-api</artifactId>
+ <version>2.1</version>
+ </dependency>
+ <dependency>
+ <groupId>picocontainer</groupId>
+ <artifactId>picocontainer</artifactId>
+ <version>1.1</version>
+ </dependency>
+ <dependency>
+ <groupId>jtidy</groupId>
+ <artifactId>jtidy</artifactId>
+ <version>4aug2000r7-dev</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jvnet.jaxb2.maven2</groupId>
+ <artifactId>maven-jaxb2-plugin</artifactId>
+ <version>0.4</version>
+ </dependency>
+ <dependency>
+ <groupId>commons-fileupload</groupId>
+ <artifactId>commons-fileupload</artifactId>
+ <!-- <version>1.2.1</version>-->
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.ws.rs</groupId>
+ <artifactId>jsr311-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.annotation</groupId>
+ <artifactId>jsr250-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>xpp3</groupId>
+ <artifactId>xpp3</artifactId>
+ <version>1.1.3.4.O</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <version>1.5.8</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.codehaus.groovy</groupId>
+ <artifactId>groovy-all</artifactId>
+ <version>1.6.5</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-log4j12</artifactId>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+</project>