Author: mstruk
Date: 2011-04-23 16:02:26 -0400 (Sat, 23 Apr 2011)
New Revision: 6334
Added:
sandbox/cdi_support/gatein-api/trunk/pom.xml
sandbox/cdi_support/gatein-api/trunk/src/
sandbox/cdi_support/gatein-api/trunk/src/main/
sandbox/cdi_support/gatein-api/trunk/src/main/java/
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/annotations/
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/annotations/GateInService.java
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/app/
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/app/PortalRequestContext.java
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/app/PortletRequestContext.java
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/app/RequestContext.java
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/app/WebuiRequestContext.java
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/kernel/
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/kernel/GateInContainer.java
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/kernel/GateInContainerContext.java
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/kernel/PortalContainer.java
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/kernel/RootContainer.java
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/portlet/
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/portlet/InputRenderParameters.java
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/portlet/OutputRenderParameters.java
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/security/
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/security/ConversationState.java
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/util/
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/util/Availability.java
Log:
CDI support for portlets - Injection friendly API that wraps exo classes
Added: sandbox/cdi_support/gatein-api/trunk/pom.xml
===================================================================
--- sandbox/cdi_support/gatein-api/trunk/pom.xml (rev 0)
+++ sandbox/cdi_support/gatein-api/trunk/pom.xml 2011-04-23 20:02:26 UTC (rev 6334)
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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.gatein</groupId>
+ <artifactId>gatein-parent</artifactId>
+ <version>1.0.1-GA</version>
+ </parent>
+
+ <groupId>org.gatein.api</groupId>
+ <artifactId>gatein-api</artifactId>
+
+ <name>GateIn API</name>
+ <version>1.0.0-Alpha01-SNAPSHOT</version>
+
+ <packaging>jar</packaging>
+
+ <properties>
+
<org.exoplatform.kernel.version>2.2.7-GA</org.exoplatform.kernel.version>
+ <org.exoplatform.core.version>2.3.7-GA</org.exoplatform.core.version>
+
<org.exoplatform.webui.version>3.2.0-Beta01-SNAPSHOT</org.exoplatform.webui.version>
+ </properties>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.webui.framework</artifactId>
+ <version>${org.exoplatform.webui.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.webui.portal</artifactId>
+ <version>${org.exoplatform.webui.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.core</groupId>
+ <artifactId>exo.core.component.organization.api</artifactId>
+ <version>${org.exoplatform.core.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.interceptor</groupId>
+ <artifactId>jboss-interceptor</artifactId>
+ <version>1.0.0-CR11</version>
+ <scope>provided</scope>
+ </dependency>
+ <!--dependency>
+ <groupId>picocontainer</groupId>
+ <artifactId>picocontainer</artifactId>
+ <version>1.1</version>
+ </dependency-->
+ </dependencies>
+</project>
Added:
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/annotations/GateInService.java
===================================================================
---
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/annotations/GateInService.java
(rev 0)
+++
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/annotations/GateInService.java 2011-04-23
20:02:26 UTC (rev 6334)
@@ -0,0 +1,39 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * 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.gatein.api.annotations;
+
+import java.lang.annotation.Documented;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+@Documented
+(a)Retention(RetentionPolicy.RUNTIME)
+(a)Target({ElementType.TYPE, ElementType.FIELD, ElementType.PARAMETER,
ElementType.METHOD})
+public @interface GateInService
+{
+}
Added:
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/app/PortalRequestContext.java
===================================================================
---
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/app/PortalRequestContext.java
(rev 0)
+++
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/app/PortalRequestContext.java 2011-04-23
20:02:26 UTC (rev 6334)
@@ -0,0 +1,124 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * 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.gatein.api.app;
+
+import org.w3c.dom.Element;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class PortalRequestContext extends
WebuiRequestContext<org.exoplatform.portal.application.PortalRequestContext>
+{
+ public PortalRequestContext()
+ {}
+
+ public PortalRequestContext(org.exoplatform.portal.application.PortalRequestContext
delegate)
+ {
+ super(delegate);
+ }
+
+ public HttpServletRequest getRequest() throws Exception
+ {
+ return delegate.getRequest();
+ }
+
+ public HttpServletResponse getResponse() throws Exception
+ {
+ return delegate.getResponse();
+ }
+
+ public void addExtraMarkupHeader(Element element, String portletWindowId)
+ {
+ delegate.addExtraMarkupHeader(element, portletWindowId);
+ }
+
+ public void refreshResourceBundle() throws Exception
+ {
+ delegate.refreshResourceBundle();
+ }
+
+ public String getTitle() throws Exception
+ {
+ return delegate.getTitle();
+ }
+
+ public Map<String, String> getMetaInformation()
+ {
+ return delegate.getMetaInformation();
+ }
+
+ public String getCacheLevel()
+ {
+ return delegate.getCacheLevel();
+ }
+
+ public Map<String, String[]> getPortletParameters()
+ {
+ return delegate.getPortletParameters();
+ }
+
+ public String getPortalOwner()
+ {
+ return delegate.getPortalOwner();
+ }
+
+ public String getNodePath()
+ {
+ return delegate.getNodePath();
+ }
+
+ public String getRequestURI()
+ {
+ return delegate.getRequestURI();
+ }
+
+ public String getPortalURI()
+ {
+ return delegate.getPortalURI();
+ }
+
+ public int getAccessPath()
+ {
+ return delegate.getAccessPath();
+ }
+
+ public void setHeaders(Map<String, String> headers)
+ {
+ delegate.setHeaders(headers);
+ }
+
+ public List<String> getExtraMarkupHeadersAsStrings() throws Exception
+ {
+ return delegate.getExtraMarkupHeadersAsStrings();
+ }
+
+ public List<Element> getExtraMarkupHeaders()
+ {
+ return delegate.getExtraMarkupHeaders();
+ }
+}
Added:
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/app/PortletRequestContext.java
===================================================================
---
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/app/PortletRequestContext.java
(rev 0)
+++
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/app/PortletRequestContext.java 2011-04-23
20:02:26 UTC (rev 6334)
@@ -0,0 +1,84 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * 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.gatein.api.app;
+
+import javax.portlet.PortletMode;
+import javax.portlet.PortletModeException;
+import javax.portlet.PortletRequest;
+import javax.portlet.PortletResponse;
+import java.io.Writer;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class PortletRequestContext extends
WebuiRequestContext<org.exoplatform.webui.application.portlet.PortletRequestContext>
+{
+
+ public PortletRequestContext()
+ {}
+
+ public
PortletRequestContext(org.exoplatform.webui.application.portlet.PortletRequestContext
delegate)
+ {
+ super(delegate);
+ }
+
+ public void init(Writer writer, PortletRequest req, PortletResponse res)
+ {
+ delegate.init(writer, req, res);
+ }
+
+ public PortletRequest getRequest()
+ {
+ return delegate.getRequest();
+ }
+
+ public PortletResponse getResponse()
+ {
+ return delegate.getResponse();
+ }
+
+ public PortletMode getApplicationMode()
+ {
+ return delegate.getApplicationMode();
+ }
+
+ public void setApplicationMode(PortletMode mode) throws PortletModeException
+ {
+ delegate.setApplicationMode(mode);
+ }
+
+ public boolean hasProcessAction()
+ {
+ return delegate.hasProcessAction();
+ }
+
+ public void setProcessAction(boolean b)
+ {
+ delegate.setProcessAction(b);
+ }
+
+ public String getWindowId()
+ {
+ return delegate.getWindowId();
+ }
+}
Added:
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/app/RequestContext.java
===================================================================
---
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/app/RequestContext.java
(rev 0)
+++
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/app/RequestContext.java 2011-04-23
20:02:26 UTC (rev 6334)
@@ -0,0 +1,139 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * 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.gatein.api.app;
+
+import org.exoplatform.services.resources.Orientation;
+import org.exoplatform.web.application.Application;
+import org.exoplatform.web.application.ApplicationSession;
+import org.exoplatform.web.application.JavascriptManager;
+import org.exoplatform.web.application.URLBuilder;
+
+import java.io.Writer;
+import java.util.Locale;
+import java.util.ResourceBundle;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class RequestContext<T extends
org.exoplatform.web.application.RequestContext>
+{
+ protected T delegate;
+
+ public RequestContext()
+ {}
+
+ public RequestContext(T delegate)
+ {
+ this.delegate = delegate;
+ }
+
+ public Orientation getOrientation()
+ {
+ return delegate.getOrientation();
+ }
+
+ public String getRequestParameter(String name)
+ {
+ return delegate.getRequestParameter(name);
+ }
+
+ public String[] getRequestParameterValues(String name)
+ {
+ return delegate.getRequestParameterValues(name);
+ }
+
+ public URLBuilder<?> getURLBuilder()
+ {
+ return delegate.getURLBuilder();
+ }
+
+ public boolean useAjax()
+ {
+ return delegate.useAjax();
+ }
+
+ public Application getApplication()
+ {
+ return delegate.getApplication();
+ }
+
+ public Locale getLocale()
+ {
+ return delegate.getLocale();
+ }
+
+ public ResourceBundle getApplicationResourceBundle()
+ {
+ return delegate.getApplicationResourceBundle();
+ }
+
+ public JavascriptManager getJavascriptManager()
+ {
+ return delegate.getJavascriptManager();
+ }
+
+ public String getRemoteUser()
+ {
+ return delegate.getRemoteUser();
+ }
+
+ public boolean isUserInRole(String roleUser)
+ {
+ return delegate.isUserInRole(roleUser);
+ }
+
+ public boolean getFullRender()
+ {
+ return delegate.getFullRender();
+ }
+
+ public ApplicationSession getApplicationSession()
+ {
+ return delegate.getApplicationSession();
+ }
+
+ public Writer getWriter() throws Exception
+ {
+ return delegate.getWriter();
+ }
+
+ public void setWriter(Writer writer)
+ {
+ delegate.setWriter(writer);
+ }
+
+ public RequestContext getParentAppRequestContext()
+ {
+ return WebuiRequestContext.wrap(delegate.getParentAppRequestContext());
+ }
+
+ public void setParentAppRequestContext(RequestContext context)
+ {
+ delegate.setParentAppRequestContext(context.getDelegate());
+ }
+
+ private org.exoplatform.web.application.RequestContext getDelegate()
+ {
+ return delegate;
+ }
+}
Added:
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/app/WebuiRequestContext.java
===================================================================
---
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/app/WebuiRequestContext.java
(rev 0)
+++
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/app/WebuiRequestContext.java 2011-04-23
20:02:26 UTC (rev 6334)
@@ -0,0 +1,157 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * 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.gatein.api.app;
+
+import org.exoplatform.resolver.ResourceResolver;
+import org.exoplatform.web.application.URLBuilder;
+import org.exoplatform.webui.application.StateManager;
+import org.exoplatform.webui.core.UIApplication;
+import org.exoplatform.webui.core.UIComponent;
+
+import java.util.ResourceBundle;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public abstract class WebuiRequestContext<T extends
org.exoplatform.webui.application.WebuiRequestContext> extends RequestContext<T>
+{
+ public WebuiRequestContext()
+ {}
+
+ public WebuiRequestContext(T delegate)
+ {
+ super(delegate);
+ }
+
+ public String getSessionId()
+ {
+ return delegate.getSessionId();
+ }
+
+ public UIApplication getUIApplication()
+ {
+ return delegate.getUIApplication();
+ }
+
+ public void setUIApplication(UIApplication uiApplication) throws Exception
+ {
+ delegate.setUIApplication(uiApplication);
+ }
+
+ public ResourceBundle getApplicationResourceBundle()
+ {
+ return delegate.getApplicationResourceBundle();
+ }
+
+ public String getActionParameterName()
+ {
+ return delegate.getActionParameterName();
+ }
+
+ public String getUIComponentIdParameterName()
+ {
+ return delegate.getUIComponentIdParameterName();
+ }
+
+ public URLBuilder<UIComponent> getURLBuilder()
+ {
+ return delegate.getURLBuilder();
+ }
+
+ public String getRequestContextPath()
+ {
+ return delegate.getRequestContextPath();
+ }
+
+ public String getPortalContextPath()
+ {
+ return delegate.getPortalContextPath();
+ }
+
+ public abstract <T> T getRequest() throws Exception;
+
+ public abstract <T> T getResponse() throws Exception;
+
+ public boolean isResponseComplete()
+ {
+ return delegate.isResponseComplete();
+ }
+
+ public void setResponseComplete(boolean b)
+ {
+ delegate.setResponseComplete(b);
+ }
+
+ public void sendRedirect(String url) throws Exception
+ {
+ delegate.sendRedirect(url);
+ }
+
+ public boolean getProcessRender()
+ {
+ return delegate.getProcessRender();
+ }
+
+ public void setProcessRender(boolean b)
+ {
+ delegate.setProcessRender(b);
+ }
+
+ public Set<UIComponent> getUIComponentToUpdateByAjax()
+ {
+ return delegate.getUIComponentToUpdateByAjax();
+ }
+
+ public void addUIComponentToUpdateByAjax(UIComponent uicomponent)
+ {
+ delegate.addUIComponentToUpdateByAjax(uicomponent);
+ }
+
+ public ResourceResolver getResourceResolver(String uri)
+ {
+ return delegate.getResourceResolver(uri);
+ }
+
+ public StateManager getStateManager()
+ {
+ return delegate.getStateManager();
+ }
+
+ public void setStateManager(StateManager manager)
+ {
+ delegate.setStateManager(manager);
+ }
+
+ public static WebuiRequestContext wrap(org.exoplatform.web.application.RequestContext
ctx)
+ {
+ if (ctx == null)
+ return null;
+ if (ctx instanceof org.exoplatform.portal.application.PortalRequestContext)
+ return new PortalRequestContext(
(org.exoplatform.portal.application.PortalRequestContext) ctx);
+ else if (ctx instanceof
org.exoplatform.webui.application.portlet.PortletRequestContext)
+ return new PortletRequestContext(
(org.exoplatform.webui.application.portlet.PortletRequestContext) ctx);
+
+ throw new IllegalArgumentException("RequestContext of unexpected type: "
+ ctx.getClass());
+ }
+}
Added:
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/kernel/GateInContainer.java
===================================================================
---
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/kernel/GateInContainer.java
(rev 0)
+++
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/kernel/GateInContainer.java 2011-04-23
20:02:26 UTC (rev 6334)
@@ -0,0 +1,263 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * 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.gatein.api.kernel;
+
+import org.exoplatform.container.ConcurrentPicoContainer;
+import org.exoplatform.container.ContainerLifecyclePlugin;
+import org.exoplatform.container.ExoContainer;
+import org.exoplatform.container.component.ComponentLifecyclePlugin;
+import org.exoplatform.container.xml.InitParams;
+import org.exoplatform.management.ManagementContext;
+import org.picocontainer.ComponentAdapter;
+import org.picocontainer.Parameter;
+import org.picocontainer.PicoContainer;
+import org.picocontainer.PicoException;
+import org.picocontainer.PicoRegistrationException;
+import org.picocontainer.PicoVisitor;
+import org.picocontainer.defaults.DuplicateComponentKeyRegistrationException;
+
+import java.util.Collection;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class GateInContainer<T extends ExoContainer>
+{
+ protected T delegate;
+
+ public GateInContainer()
+ {}
+
+ public GateInContainer(T delegate)
+ {
+ this.delegate = delegate;
+ }
+
+ public GateInContainerContext getContext()
+ {
+ return new GateInContainerContext(delegate.getContext());
+ }
+
+ public static GateInContainer wrap(ExoContainer container)
+ {
+ if (container == null)
+ return null;
+
+ if (container instanceof org.exoplatform.container.RootContainer)
+ return new RootContainer((org.exoplatform.container.RootContainer) container);
+ else if (container instanceof org.exoplatform.container.PortalContainer)
+ return new PortalContainer((org.exoplatform.container.PortalContainer)
container);
+
+ throw new IllegalArgumentException("ExoContainer of unexpected type: " +
container.getClass());
+ }
+/*
+ public void initContainer() throws Exception
+ {
+ delegate.initContainer();
+ }
+
+ public void dispose()
+ {
+ delegate.dispose();
+ }
+
+ public void start(boolean init)
+ {
+ delegate.start(init);
+ }
+
+ public void start()
+ {
+ delegate.start();
+ }
+
+ public void stop()
+ {
+ delegate.stop();
+ }
+
+ public void startContainer() throws Exception
+ {
+ delegate.startContainer();
+ }
+
+ public void stopContainer() throws Exception
+ {
+ delegate.stopContainer();
+ }
+
+ public void destroyContainer() throws Exception
+ {
+ delegate.destroyContainer();
+ }
+*/
+
+ public void addComponentLifecylePlugin(ComponentLifecyclePlugin plugin)
+ {
+ delegate.addComponentLifecylePlugin(plugin);
+ }
+
+ public void addContainerLifecylePlugin(ContainerLifecyclePlugin plugin)
+ {
+ delegate.addContainerLifecylePlugin(plugin);
+ }
+
+ public <T> T createComponent(Class<T> clazz) throws Exception
+ {
+ return delegate.createComponent(clazz);
+ }
+
+ public <T> T createComponent(Class<T> clazz, InitParams params) throws
Exception
+ {
+ return delegate.createComponent(clazz, params);
+ }
+
+ public Set<String> getRegisteredComponentNames() throws PicoException
+ {
+ return delegate.getRegisteredComponentNames();
+ }
+
+ public ManagementContext getManagementContext()
+ {
+ return delegate.getManagementContext();
+ }
+
+ public ComponentAdapter registerComponent(ComponentAdapter componentAdapter) throws
DuplicateComponentKeyRegistrationException
+ {
+ return delegate.registerComponent(componentAdapter);
+ }
+
+ public ComponentAdapter registerComponentInstance(Object componentKey, Object
componentInstance) throws PicoRegistrationException
+ {
+ return delegate.registerComponentInstance(componentKey, componentInstance);
+ }
+
+ public ComponentAdapter getComponentAdapterOfType(Class componentType)
+ {
+ return delegate.getComponentAdapterOfType(componentType);
+ }
+
+ public List getComponentAdaptersOfType(Class componentType)
+ {
+ return delegate.getComponentAdaptersOfType(componentType);
+ }
+
+ public List getComponentInstancesOfType(Class componentType) throws PicoException
+ {
+ return delegate.getComponentInstancesOfType(componentType);
+ }
+
+ public Object getComponentInstance(Object componentKey) throws PicoException
+ {
+ return delegate.getComponentInstance(componentKey);
+ }
+
+ public Object getComponentInstanceOfType(Class componentType)
+ {
+ return delegate.getComponentInstanceOfType(componentType);
+ }
+
+ public ComponentAdapter unregisterComponent(Object componentKey)
+ {
+ return delegate.unregisterComponent(componentKey);
+ }
+
+ public ComponentAdapter registerComponentInstance(Object component) throws
PicoRegistrationException
+ {
+ return delegate.registerComponentInstance(component);
+ }
+
+ public ComponentAdapter registerComponentImplementation(Class componentImplementation)
throws PicoRegistrationException
+ {
+ return delegate.registerComponentImplementation(componentImplementation);
+ }
+
+ public ComponentAdapter registerComponentImplementation(Object componentKey, Class
componentImplementation) throws PicoRegistrationException
+ {
+ return delegate.registerComponentImplementation(componentKey,
componentImplementation);
+ }
+
+ public ComponentAdapter registerComponentImplementation(Object componentKey, Class
componentImplementation, Parameter[] parameters) throws PicoRegistrationException
+ {
+ return delegate.registerComponentImplementation(componentKey,
componentImplementation, parameters);
+ }
+
+ public ComponentAdapter registerComponentImplementation(Object componentKey, Class
componentImplementation, List parameters) throws PicoRegistrationException
+ {
+ return delegate.registerComponentImplementation(componentKey,
componentImplementation, parameters);
+ }
+
+ public Collection getComponentAdapters()
+ {
+ return delegate.getComponentAdapters();
+ }
+
+ public List getComponentInstances() throws PicoException
+ {
+ return delegate.getComponentInstances();
+ }
+
+ public PicoContainer getParent()
+ {
+ return delegate.getParent();
+ }
+
+ public ComponentAdapter unregisterComponentByInstance(Object componentInstance)
+ {
+ return delegate.unregisterComponentByInstance(componentInstance);
+ }
+
+/*
+ public void verify() throws PicoVerificationException
+ {
+ delegate.verify();
+ }
+
+ public MutablePicoContainer makeChildContainer()
+ {
+ return delegate.makeChildContainer();
+ }
+
+ public boolean addChildContainer(PicoContainer child)
+ {
+ return delegate.addChildContainer(child);
+ }
+
+ public boolean removeChildContainer(PicoContainer child)
+ {
+ return delegate.removeChildContainer(child);
+ }
+*/
+ public void accept(PicoVisitor visitor)
+ {
+ delegate.accept(visitor);
+ }
+/*
+ protected void accept(ConcurrentPicoContainer.ContainerVisitor visitor)
+ {
+ delegate.accept(visitor);
+ }
+*/
+}
Added:
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/kernel/GateInContainerContext.java
===================================================================
---
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/kernel/GateInContainerContext.java
(rev 0)
+++
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/kernel/GateInContainerContext.java 2011-04-23
20:02:26 UTC (rev 6334)
@@ -0,0 +1,94 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * 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.gatein.api.kernel;
+
+import org.exoplatform.container.ExoContainer;
+import org.exoplatform.container.ExoContainerContext;
+
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class GateInContainerContext
+{
+ private ExoContainerContext delegate;
+
+ public GateInContainerContext()
+ {}
+
+ public GateInContainerContext(ExoContainerContext delegate)
+ {
+ this.delegate = delegate;
+ }
+
+ public GateInContainer getContainer()
+ {
+ return GateInContainer.wrap(delegate.getContainer());
+ }
+
+ public String getPortalContainerName()
+ {
+ return delegate.getPortalContainerName();
+ }
+
+ public String getRestContextName()
+ {
+ return delegate.getRestContextName();
+ }
+
+ public String getRealmName()
+ {
+ return delegate.getRealmName();
+ }
+
+ public Object getSetting(String settingName)
+ {
+ return delegate.getSetting(settingName);
+ }
+
+ public String getName()
+ {
+ return delegate.getName();
+ }
+
+ public void setName(String name)
+ {
+ delegate.setName(name);
+ }
+
+ public Set<String> getAttributeNames()
+ {
+ return delegate.getAttributeNames();
+ }
+
+ public Object getAttribute(String name)
+ {
+ return delegate.getAttribute(name);
+ }
+
+ public void setAttribute(String name, Object value)
+ {
+ delegate.setAttribute(name, value);
+ }
+}
Added:
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/kernel/PortalContainer.java
===================================================================
---
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/kernel/PortalContainer.java
(rev 0)
+++
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/kernel/PortalContainer.java 2011-04-23
20:02:26 UTC (rev 6334)
@@ -0,0 +1,126 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * 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.gatein.api.kernel;
+
+import org.exoplatform.container.SessionContainer;
+import org.exoplatform.container.SessionManager;
+import org.exoplatform.container.xml.PortalContainerInfo;
+
+import javax.servlet.ServletContext;
+import java.util.List;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class PortalContainer extends
GateInContainer<org.exoplatform.container.PortalContainer>
+{
+ public PortalContainer()
+ {}
+
+ public PortalContainer(org.exoplatform.container.PortalContainer delegate)
+ {
+ super(delegate);
+ }
+
+ public ClassLoader getWebAppClassLoader(ServletContext context)
+ {
+ return delegate.getWebAppClassLoader(context);
+ }
+
+ public ClassLoader getPortalClassLoader()
+ {
+ return delegate.getPortalClassLoader();
+ }
+
+ public ServletContext getPortalContext()
+ {
+ return delegate.getPortalContext();
+ }
+/*
+ public void registerContext(ServletContext context)
+ {
+ delegate.registerContext(context);
+ }
+
+ public void unregisterContext(ServletContext context)
+ {
+ delegate.unregisterContext(context);
+ }
+*/
+
+ public String getName()
+ {
+ return delegate.getName();
+ }
+
+ public String getConfigurationXML()
+ {
+ return delegate.getConfigurationXML();
+ }
+
+ public SessionContainer createSessionContainer(String id, String owner)
+ {
+ return delegate.createSessionContainer(id, owner);
+ }
+
+ public void removeSessionContainer(String sessionID)
+ {
+ delegate.removeSessionContainer(sessionID);
+ }
+
+ public List<SessionContainer> getLiveSessions()
+ {
+ return delegate.getLiveSessions();
+ }
+
+ public SessionManager getSessionManager()
+ {
+ return delegate.getSessionManager();
+ }
+
+ public PortalContainerInfo getPortalContainerInfo()
+ {
+ return delegate.getPortalContainerInfo();
+ }
+
+ public String getRestContextName()
+ {
+ return delegate.getRestContextName();
+ }
+
+ public String getRealmName()
+ {
+ return delegate.getRealmName();
+ }
+
+ public Object getSetting(String settingName)
+ {
+ return delegate.getSetting(settingName);
+ }
+
+ public boolean isStarted()
+ {
+ return delegate.isStarted();
+ }
+
+}
Added:
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/kernel/RootContainer.java
===================================================================
---
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/kernel/RootContainer.java
(rev 0)
+++
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/kernel/RootContainer.java 2011-04-23
20:02:26 UTC (rev 6334)
@@ -0,0 +1,97 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * 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.gatein.api.kernel;
+
+import org.exoplatform.container.monitor.jvm.J2EEServerInfo;
+import org.exoplatform.container.monitor.jvm.OperatingSystemInfo;
+
+import javax.servlet.ServletContext;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class RootContainer extends
GateInContainer<org.exoplatform.container.RootContainer>
+{
+ public RootContainer()
+ {}
+
+ public RootContainer(org.exoplatform.container.RootContainer delegate)
+ {
+ super(delegate);
+ }
+
+ public OperatingSystemInfo getOSEnvironment()
+ {
+ return delegate.getOSEnvironment();
+ }
+
+ public boolean isPortalContainerConfigAware()
+ {
+ return delegate.isPortalContainerConfigAware();
+ }
+
+ public J2EEServerInfo getServerEnvironment()
+ {
+ return delegate.getServerEnvironment();
+ }
+/*
+ public PortalContainer getPortalContainer(String name)
+ {
+ return new PortalContainer(delegate.getPortalContainer(name));
+ }
+
+ public void registerPortalContainer(ServletContext context)
+ {
+ delegate.registerPortalContainer(context);
+ }
+
+ public void createPortalContainers()
+ {
+ delegate.createPortalContainers();
+ }
+
+ public void createPortalContainer(ServletContext context)
+ {
+ delegate.createPortalContainer(context);
+ }
+
+ public void removePortalContainer(ServletContext servletContext)
+ {
+ delegate.removePortalContainer(servletContext);
+ }
+*/
+ public String getConfigurationXML()
+ {
+ return delegate.getConfigurationXML();
+ }
+
+ public void addInitTask(ServletContext context,
org.exoplatform.container.RootContainer.PortalContainerInitTask task)
+ {
+ delegate.addInitTask(context, task);
+ }
+
+ public void addInitTask(ServletContext context,
org.exoplatform.container.RootContainer.PortalContainerInitTask task, String
portalContainer)
+ {
+ delegate.addInitTask(context, task, portalContainer);
+ }
+}
Added:
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/portlet/InputRenderParameters.java
===================================================================
---
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/portlet/InputRenderParameters.java
(rev 0)
+++
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/portlet/InputRenderParameters.java 2011-04-23
20:02:26 UTC (rev 6334)
@@ -0,0 +1,30 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * 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.gatein.api.portlet;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class InputRenderParameters
+{
+}
Added:
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/portlet/OutputRenderParameters.java
===================================================================
---
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/portlet/OutputRenderParameters.java
(rev 0)
+++
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/portlet/OutputRenderParameters.java 2011-04-23
20:02:26 UTC (rev 6334)
@@ -0,0 +1,30 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * 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.gatein.api.portlet;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class OutputRenderParameters
+{
+}
Added:
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/security/ConversationState.java
===================================================================
---
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/security/ConversationState.java
(rev 0)
+++
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/security/ConversationState.java 2011-04-23
20:02:26 UTC (rev 6334)
@@ -0,0 +1,68 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * 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.gatein.api.security;
+
+import org.exoplatform.services.security.Identity;
+
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class ConversationState
+{
+ private org.exoplatform.services.security.ConversationState delegate;
+
+ public ConversationState()
+ {}
+
+ public ConversationState(org.exoplatform.services.security.ConversationState
delegate)
+ {
+ this.delegate = delegate;
+ }
+
+ public Identity getIdentity()
+ {
+ return delegate.getIdentity();
+ }
+
+ public void setAttribute(String name, Object value)
+ {
+ delegate.setAttribute(name, value);
+ }
+
+ public Object getAttribute(String name)
+ {
+ return delegate.getAttribute(name);
+ }
+
+ public Set<String> getAttributeNames()
+ {
+ return delegate.getAttributeNames();
+ }
+
+ public void removeAttribute(String name)
+ {
+ delegate.removeAttribute(name);
+ }
+}
Added:
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/util/Availability.java
===================================================================
---
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/util/Availability.java
(rev 0)
+++
sandbox/cdi_support/gatein-api/trunk/src/main/java/org/gatein/api/util/Availability.java 2011-04-23
20:02:26 UTC (rev 6334)
@@ -0,0 +1,52 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2010, Red Hat Middleware, LLC, and individual
+ * contributors as indicated by the @authors tag. See the
+ * copyright.txt in the distribution for a full listing of
+ * individual contributors.
+ *
+ * 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.gatein.api.util;
+
+import org.jboss.interceptor.util.proxy.TargetInstanceProxy;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class Availability
+{
+ /**
+ * Use this method instead of testing object for null.
+ * This will also work when gatein-cdi is used to inject dependencies.
+ * In that case a proxy object is created at injection time, and performs a delegate
lookup on every method call.
+ * A delegate may or may not be available inside a current method - it may be looked
up via ThreadLocals.
+ *
+ * If this method returns false you should assume <em>o</em> is null.
+ *
+ * @param o object to test for availability
+ * @return true if object is available, false otherwise
+ */
+ public static boolean isObjectAvailable(Object o)
+ {
+ if (o instanceof TargetInstanceProxy == false)
+ {
+ return o != null;
+ }
+
+ return ((TargetInstanceProxy) o).getTargetInstance() != null;
+ }
+}
\ No newline at end of file