Author: mstruk
Date: 2011-04-23 16:10:49 -0400 (Sat, 23 Apr 2011)
New Revision: 6335
Added:
sandbox/cdi_support/cdi/trunk/api/
sandbox/cdi_support/cdi/trunk/api/pom.xml
sandbox/cdi_support/cdi/trunk/api/src/
sandbox/cdi_support/cdi/trunk/api/src/main/
sandbox/cdi_support/cdi/trunk/api/src/main/java/
sandbox/cdi_support/cdi/trunk/api/src/main/java/org/
sandbox/cdi_support/cdi/trunk/api/src/main/java/org/gatein/
sandbox/cdi_support/cdi/trunk/api/src/main/java/org/gatein/cdi/
sandbox/cdi_support/cdi/trunk/api/src/main/java/org/gatein/cdi/api/
sandbox/cdi_support/cdi/trunk/api/src/main/java/org/gatein/cdi/api/annotations/
sandbox/cdi_support/cdi/trunk/api/src/main/java/org/gatein/cdi/api/annotations/PortalContainerScope.java
sandbox/cdi_support/cdi/trunk/api/src/main/java/org/gatein/cdi/api/annotations/RootContainerScope.java
sandbox/cdi_support/cdi/trunk/docs/
sandbox/cdi_support/cdi/trunk/docs/reference/
sandbox/cdi_support/cdi/trunk/docs/reference/pom.xml
sandbox/cdi_support/cdi/trunk/docs/reference/src/
sandbox/cdi_support/cdi/trunk/docs/reference/src/main/
sandbox/cdi_support/cdi/trunk/docs/reference/src/main/docbook/
sandbox/cdi_support/cdi/trunk/docs/reference/src/main/docbook/en-US/
sandbox/cdi_support/cdi/trunk/docs/reference/src/main/docbook/en-US/general.xml
sandbox/cdi_support/cdi/trunk/docs/reference/src/main/docbook/en-US/master.xml
sandbox/cdi_support/cdi/trunk/examples/
sandbox/cdi_support/cdi/trunk/examples/portlet/
sandbox/cdi_support/cdi/trunk/examples/portlet/pom.xml
sandbox/cdi_support/cdi/trunk/examples/portlet/src/
sandbox/cdi_support/cdi/trunk/examples/portlet/src/main/
sandbox/cdi_support/cdi/trunk/examples/portlet/src/main/java/
sandbox/cdi_support/cdi/trunk/examples/portlet/src/main/java/org/
sandbox/cdi_support/cdi/trunk/examples/portlet/src/main/java/org/gatein/
sandbox/cdi_support/cdi/trunk/examples/portlet/src/main/java/org/gatein/cdi/
sandbox/cdi_support/cdi/trunk/examples/portlet/src/main/java/org/gatein/cdi/examples/
sandbox/cdi_support/cdi/trunk/examples/portlet/src/main/java/org/gatein/cdi/examples/portlet/
sandbox/cdi_support/cdi/trunk/examples/portlet/src/main/java/org/gatein/cdi/examples/portlet/RequestProcessor.java
sandbox/cdi_support/cdi/trunk/examples/portlet/src/main/java/org/gatein/cdi/examples/portlet/SimplePortlet.java
sandbox/cdi_support/cdi/trunk/examples/portlet/src/main/java/org/gatein/cdi/examples/portlet/TestServlet.java
sandbox/cdi_support/cdi/trunk/examples/portlet/src/main/resources/
sandbox/cdi_support/cdi/trunk/examples/portlet/src/main/webapp/
sandbox/cdi_support/cdi/trunk/examples/portlet/src/main/webapp/WEB-INF/
sandbox/cdi_support/cdi/trunk/examples/portlet/src/main/webapp/WEB-INF/beans.xml
sandbox/cdi_support/cdi/trunk/examples/portlet/src/main/webapp/WEB-INF/portlet.xml
sandbox/cdi_support/cdi/trunk/examples/portlet/src/main/webapp/WEB-INF/web.xml
sandbox/cdi_support/cdi/trunk/examples/traceextension/
sandbox/cdi_support/cdi/trunk/examples/traceextension/pom.xml
sandbox/cdi_support/cdi/trunk/examples/traceextension/src/
sandbox/cdi_support/cdi/trunk/examples/traceextension/src/main/
sandbox/cdi_support/cdi/trunk/examples/traceextension/src/main/java/
sandbox/cdi_support/cdi/trunk/examples/traceextension/src/main/java/org/
sandbox/cdi_support/cdi/trunk/examples/traceextension/src/main/java/org/gatein/
sandbox/cdi_support/cdi/trunk/examples/traceextension/src/main/java/org/gatein/cdi/
sandbox/cdi_support/cdi/trunk/examples/traceextension/src/main/java/org/gatein/cdi/examples/
sandbox/cdi_support/cdi/trunk/examples/traceextension/src/main/java/org/gatein/cdi/examples/traceextension/
sandbox/cdi_support/cdi/trunk/examples/traceextension/src/main/java/org/gatein/cdi/examples/traceextension/TraceExtension.java
sandbox/cdi_support/cdi/trunk/examples/traceextension/src/main/resources/
sandbox/cdi_support/cdi/trunk/examples/traceextension/src/main/resources/META-INF/
sandbox/cdi_support/cdi/trunk/examples/traceextension/src/main/resources/META-INF/beans.xml
sandbox/cdi_support/cdi/trunk/examples/traceextension/src/main/resources/META-INF/services/
sandbox/cdi_support/cdi/trunk/examples/traceextension/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
sandbox/cdi_support/cdi/trunk/impl/
sandbox/cdi_support/cdi/trunk/impl/pom.xml
sandbox/cdi_support/cdi/trunk/impl/src/
sandbox/cdi_support/cdi/trunk/impl/src/main/
sandbox/cdi_support/cdi/trunk/impl/src/main/java/
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/cdi/
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/cdi/impl/
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/cdi/impl/GateInExtension.java
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/cdi/impl/OrganizationServiceExtension.java
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/cdi/impl/annotations/
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/cdi/impl/annotations/GateInServiceLiteral.java
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/cdi/impl/annotations/OrganizationServiceSession.java
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/cdi/impl/inject/
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/cdi/impl/inject/GateInServiceProducerBean.java
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/cdi/impl/inject/GateInServiceProxy.java
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/cdi/impl/inject/GenericProxy.java
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/cdi/impl/inject/GenericTLProxy.java
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/cdi/impl/inject/OrganizationServiceInterceptor.java
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/cdi/impl/inject/OrganizationServiceProducers.java
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/cdi/impl/producers/
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/cdi/impl/producers/ProducersBean.java
sandbox/cdi_support/cdi/trunk/impl/src/main/resources/
sandbox/cdi_support/cdi/trunk/impl/src/main/resources/META-INF/
sandbox/cdi_support/cdi/trunk/impl/src/main/resources/META-INF/beans.xml
sandbox/cdi_support/cdi/trunk/impl/src/main/resources/META-INF/services/
sandbox/cdi_support/cdi/trunk/impl/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
sandbox/cdi_support/cdi/trunk/pom.xml
sandbox/cdi_support/cdi/trunk/readme.txt
Log:
CDI support for portlets - Implementation of CDI standard extensions with producers,
custom injection proxies, and example servlet, and portlet
Added: sandbox/cdi_support/cdi/trunk/api/pom.xml
===================================================================
--- sandbox/cdi_support/cdi/trunk/api/pom.xml (rev 0)
+++ sandbox/cdi_support/cdi/trunk/api/pom.xml 2011-04-23 20:10:49 UTC (rev 6335)
@@ -0,0 +1,18 @@
+<?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.cdi</groupId>
+ <artifactId>gatein-cdi-parent</artifactId>
+ <version>1.0.0-Alpha01-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>gatein-cdi</artifactId>
+ <name>GateIn CDI :: API</name>
+
+ <packaging>jar</packaging>
+
+</project>
Added:
sandbox/cdi_support/cdi/trunk/api/src/main/java/org/gatein/cdi/api/annotations/PortalContainerScope.java
===================================================================
---
sandbox/cdi_support/cdi/trunk/api/src/main/java/org/gatein/cdi/api/annotations/PortalContainerScope.java
(rev 0)
+++
sandbox/cdi_support/cdi/trunk/api/src/main/java/org/gatein/cdi/api/annotations/PortalContainerScope.java 2011-04-23
20:10:49 UTC (rev 6335)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * 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.cdi.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 PortalContainerScope
+{
+}
\ No newline at end of file
Added:
sandbox/cdi_support/cdi/trunk/api/src/main/java/org/gatein/cdi/api/annotations/RootContainerScope.java
===================================================================
---
sandbox/cdi_support/cdi/trunk/api/src/main/java/org/gatein/cdi/api/annotations/RootContainerScope.java
(rev 0)
+++
sandbox/cdi_support/cdi/trunk/api/src/main/java/org/gatein/cdi/api/annotations/RootContainerScope.java 2011-04-23
20:10:49 UTC (rev 6335)
@@ -0,0 +1,38 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * 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.cdi.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 RootContainerScope
+{
+}
\ No newline at end of file
Added: sandbox/cdi_support/cdi/trunk/docs/reference/pom.xml
===================================================================
--- sandbox/cdi_support/cdi/trunk/docs/reference/pom.xml (rev 0)
+++ sandbox/cdi_support/cdi/trunk/docs/reference/pom.xml 2011-04-23 20:10:49 UTC (rev
6335)
@@ -0,0 +1,93 @@
+<?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.cdi</groupId>
+ <artifactId>gatein-cdi-parent</artifactId>
+ <version>Alpha01-</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>gatein-cdi-reference-guide</artifactId>
+ <name>GateIn CDI :: Reference Guide</name>
+ <packaging>jdocbook</packaging>
+ <description>Reference Guide for GateIn CDI Module</description>
+
+ <properties>
+ <mpjdocbook.version>2.2.0</mpjdocbook.version>
+ <pdf.name>${project.artifactId}.pdf</pdf.name>
+ </properties>
+
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.jboss.maven.plugins</groupId>
+ <artifactId>maven-jdocbook-plugin</artifactId>
+ <version>${mpjdocbook.version}</version>
+ <extensions>true</extensions>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jbossorg-docbook-xslt</artifactId>
+ <version>1.1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss</groupId>
+ <artifactId>jbossorg-jdocbook-style</artifactId>
+ <version>1.1.0</version>
+ <type>jdocbook-style</type>
+ </dependency>
+ </dependencies>
+
+ <configuration>
+ <sourceDirectory>src/main/docbook</sourceDirectory>
+ <sourceDocumentName>master.xml</sourceDocumentName>
+ <masterTranslation>en-US</masterTranslation>
+ <imageResource>
+ <directory>${pom.basedir}/src/main/docbook/en-US</directory>
+ <includes>
+ <include>images/*.png</include>
+ <include>images/*.jpg</include>
+ </includes>
+ </imageResource>
+ <formats>
+ <format>
+ <formatName>pdf</formatName>
+ <stylesheetResource>classpath://xslt/org/jboss/pdf.xsl</stylesheetResource>
+ <finalName>${pdf.name}</finalName>
+ </format>
+ <format>
+ <formatName>html</formatName>
+ <stylesheetResource>classpath://xslt/org/jboss/xhtml.xsl</stylesheetResource>
+ <finalName>index.html</finalName>
+ </format>
+ <format>
+ <formatName>html_single</formatName>
+ <stylesheetResource>classpath://xslt/org/jboss/xhtml-single.xsl</stylesheetResource>
+ <finalName>index.html</finalName>
+ </format>
+ </formats>
+ <options>
+ <xincludeSupported>true</xincludeSupported>
+ <xmlTransformerType>saxon</xmlTransformerType>
+ <docbookVersion>1.72.0</docbookVersion>
+ <transformerParameters>
+ <property>
+ <name>javax.xml.parsers.DocumentBuilderFactory</name>
+ <value>org.apache.xerces.jaxp.DocumentBuilderFactoryImpl</value>
+ </property>
+ <property>
+ <name>javax.xml.parsers.SAXParserFactory</name>
+ <value>org.apache.xerces.jaxp.SAXParserFactoryImpl</value>
+ </property>
+ </transformerParameters>
+ <localeSeparator>-</localeSeparator>
+ </options>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Added: sandbox/cdi_support/cdi/trunk/docs/reference/src/main/docbook/en-US/general.xml
===================================================================
--- sandbox/cdi_support/cdi/trunk/docs/reference/src/main/docbook/en-US/general.xml
(rev 0)
+++
sandbox/cdi_support/cdi/trunk/docs/reference/src/main/docbook/en-US/general.xml 2011-04-23
20:10:49 UTC (rev 6335)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
"http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd">
+
+<chapter id="general">
+
+ <title>GateIn CDI General</title>
+
+ <para>TODO
+ </para>
+
+</chapter>
Added: sandbox/cdi_support/cdi/trunk/docs/reference/src/main/docbook/en-US/master.xml
===================================================================
--- sandbox/cdi_support/cdi/trunk/docs/reference/src/main/docbook/en-US/master.xml
(rev 0)
+++
sandbox/cdi_support/cdi/trunk/docs/reference/src/main/docbook/en-US/master.xml 2011-04-23
20:10:49 UTC (rev 6335)
@@ -0,0 +1,11 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN"
+ "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" []>
+<book lang="en">
+
+ <toc />
+
+ <title>GateIn CDI Reference Guide</title>
+ <xi:include href="general.xml"
xmlns:xi="http://www.w3.org/2001/XInclude" />
+
+</book>
Added: sandbox/cdi_support/cdi/trunk/examples/portlet/pom.xml
===================================================================
--- sandbox/cdi_support/cdi/trunk/examples/portlet/pom.xml (rev
0)
+++ sandbox/cdi_support/cdi/trunk/examples/portlet/pom.xml 2011-04-23 20:10:49 UTC (rev
6335)
@@ -0,0 +1,74 @@
+<?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.cdi</groupId>
+ <artifactId>gatein-cdi-parent</artifactId>
+ <version>1.0.0-Alpha01-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>gatein-cdi-example-portlet</artifactId>
+ <name>GateIn CDI :: Examples :: Portlet</name>
+
+ <packaging>war</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.gatein.cdi</groupId>
+ <artifactId>gatein-cdi</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.cdi</groupId>
+ <artifactId>gatein-cdi-impl</artifactId>
+ <scope>runtime</scope>
+ <exclusions>
+ <exclusion>
+ <groupId>javassist</groupId>
+ <artifactId>javassist</artifactId>
+ </exclusion>
+ </exclusions>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.api</groupId>
+ <artifactId>gatein-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <!--dependency>
+ <groupId>org.gatein.cdi</groupId>
+ <artifactId>gatein-cdi-example-traceextension</artifactId>
+ <scope>runtime</scope>
+ <version>${project.version}</version>
+ </dependency-->
+ <dependency>
+ <groupId>javax.portlet</groupId>
+ <artifactId>portlet-api</artifactId>
+ <version>2.0</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.kernel</groupId>
+ <artifactId>exo.kernel.container</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.kernel</groupId>
+ <artifactId>exo.kernel.component.cache</artifactId>
+ <version>2.2.1-GA</version>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.enterprise</groupId>
+ <artifactId>cdi-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+</project>
Added:
sandbox/cdi_support/cdi/trunk/examples/portlet/src/main/java/org/gatein/cdi/examples/portlet/RequestProcessor.java
===================================================================
---
sandbox/cdi_support/cdi/trunk/examples/portlet/src/main/java/org/gatein/cdi/examples/portlet/RequestProcessor.java
(rev 0)
+++
sandbox/cdi_support/cdi/trunk/examples/portlet/src/main/java/org/gatein/cdi/examples/portlet/RequestProcessor.java 2011-04-23
20:10:49 UTC (rev 6335)
@@ -0,0 +1,49 @@
+/*
+ * 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.cdi.examples.portlet;
+
+import javax.enterprise.context.RequestScoped;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+@RequestScoped
+public class RequestProcessor
+{
+ private String query;
+
+ public String getQuery()
+ {
+ return query;
+ }
+
+ public void setQuery(String query)
+ {
+ this.query = query;
+ }
+
+ public String toString()
+ {
+ return super.toString() + " [query:" + query + "]";
+ }
+}
Added:
sandbox/cdi_support/cdi/trunk/examples/portlet/src/main/java/org/gatein/cdi/examples/portlet/SimplePortlet.java
===================================================================
---
sandbox/cdi_support/cdi/trunk/examples/portlet/src/main/java/org/gatein/cdi/examples/portlet/SimplePortlet.java
(rev 0)
+++
sandbox/cdi_support/cdi/trunk/examples/portlet/src/main/java/org/gatein/cdi/examples/portlet/SimplePortlet.java 2011-04-23
20:10:49 UTC (rev 6335)
@@ -0,0 +1,116 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2011, Red Hat, Inc., and individual contributors
+ * 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.cdi.examples.portlet;
+
+import org.exoplatform.container.configuration.ConfigurationManager;
+import org.exoplatform.services.cache.CacheService;
+import org.exoplatform.services.organization.OrganizationService;
+import org.exoplatform.services.organization.UserHandler;
+import org.gatein.api.app.PortalRequestContext;
+import org.gatein.api.app.WebuiRequestContext;
+import org.gatein.api.kernel.PortalContainer;
+import org.gatein.cdi.api.annotations.PortalContainerScope;
+import org.gatein.cdi.api.annotations.RootContainerScope;
+
+import javax.inject.Inject;
+import javax.portlet.GenericPortlet;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class SimplePortlet extends GenericPortlet
+{
+ private static final Logger log = Logger.getLogger(SimplePortlet.class.getName());
+
+ @Inject
+ @RootContainerScope
+ ConfigurationManager rootMgr;
+
+ @Inject
+ @PortalContainerScope
+ ConfigurationManager confMgr;
+
+ @Inject
+ CacheService cacheService;
+
+ @Inject
+ WebuiRequestContext reqContext;
+
+ @Inject
+ PortalRequestContext preqContext;
+
+ @Inject
+ PortalContainer currentContainer;
+
+ @Inject
+ OrganizationService organizationSvc;
+
+ @Inject
+ UserHandler userHandler;
+
+ public SimplePortlet() {
+ super();
+ }
+
+ public void doView(RenderRequest request, RenderResponse response) throws IOException
+ {
+ PrintWriter writer = response.getWriter();
+ writer.write("<h2>SimplePortlet Injected fields: </h2>");
+ writer.write("<ul>");
+ try
+ {
+ writer.write("<li><em>Root ConfigurationManager:
</em>" + rootMgr + "</li>");
+ writer.write("<li><em>Portal ConfigurationManager:
</em>" + confMgr + "</li>");
+ writer.write("<li><em>CacheService : </em>" +
cacheService + "</li>");
+
+ writer.write("<li><em>WebuiRequestContext: </em>" +
reqContext + "</li>");
+ writer.write("<li><em>request: </em>" +
reqContext.getRequest() + "</li>");
+
+ writer.write("<li><em>PortalRequestContext: </em>" +
preqContext + "</li>");
+ writer.write("<li><em>request: </em>" +
preqContext.getRequest() + "</li>");
+
+ writer.write("<li><em>PortalContainer: </em>" +
currentContainer + "</li>");
+ writer.write("<li><em>portalContainer component instances:
</em>" + currentContainer.getComponentInstances() + "</li>");
+
+ writer.write("<li><em>OrganizationService: </em>" +
organizationSvc + "</li>");
+ writer.write("<li><em>root user: </em>" +
organizationSvc.getUserHandler().findUserByName("root") +
"</li>");
+
+ writer.write("<li><em>UserHandler: </em>" +
userHandler + "</li>");
+ writer.write("<li><em>root user: </em>" +
userHandler.findUserByName("root") + "</li>");
+ }
+ catch(Exception ex)
+ {
+ log.log(Level.SEVERE, "Exception while generating response: ", ex);
+ }
+ finally
+ {
+ writer.write("<ul>");
+ writer.close();
+ }
+ }
+}
\ No newline at end of file
Added:
sandbox/cdi_support/cdi/trunk/examples/portlet/src/main/java/org/gatein/cdi/examples/portlet/TestServlet.java
===================================================================
---
sandbox/cdi_support/cdi/trunk/examples/portlet/src/main/java/org/gatein/cdi/examples/portlet/TestServlet.java
(rev 0)
+++
sandbox/cdi_support/cdi/trunk/examples/portlet/src/main/java/org/gatein/cdi/examples/portlet/TestServlet.java 2011-04-23
20:10:49 UTC (rev 6335)
@@ -0,0 +1,125 @@
+/*
+ * JBoss, a division of Red Hat
+ * Copyright 2011, 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.cdi.examples.portlet;
+
+import org.exoplatform.container.configuration.ConfigurationManager;
+import org.gatein.api.app.PortalRequestContext;
+import org.gatein.api.app.WebuiRequestContext;
+import org.gatein.api.kernel.PortalContainer;
+import org.gatein.api.util.Availability;
+import org.gatein.cdi.api.annotations.RootContainerScope;
+
+import javax.inject.Inject;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.net.MalformedURLException;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class TestServlet extends HttpServlet
+{
+ private static final Logger log = Logger.getLogger(TestServlet.class.getName());
+
+ @Inject
+ @RootContainerScope
+ ConfigurationManager rootMgr;
+
+ @Inject
+ RequestProcessor reqProc;
+
+ @Inject
+ WebuiRequestContext reqContext;
+
+ @Inject
+ PortalRequestContext portalReqCtx;
+
+ @Inject
+ PortalContainer currentContainer;
+
+ public TestServlet()
+ {
+ log.fine("TestServlet instantiated");
+ }
+
+ @Override
+ public void init() throws ServletException
+ {
+ log.info("Injected fields at servlet init():");
+ log.info(" - Root ConfigurationManager: " + rootMgr);
+ //log.info(" - Managed object packaged with the servlet: " + reqProc);
+ log.info(" - WebuiRequestContext: " + reqContext);
+ log.info(" - PortalRequestContext: " + portalReqCtx);
+ log.info(" - PortalContainer: " + currentContainer);
+ log.info("CDI TestServlet initialized:
http://localhost:8080/"
+ + getServletContextName() + "/" + getServletName());
+ }
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws
ServletException, IOException
+ {
+ PrintWriter out = resp.getWriter();
+ out.println("<html><body>");
+ out.println("<h2>CDI TestServlet</h2>");
+ out.println("<ul>");
+ out.println("<li><em>Root ConfigurationManager: </em>"
+ rootMgr + "</li>");
+ out.println("<li><em>Managed object packaged with the servlet:
</em>" + reqProc + "</li>");
+ out.println("<li><em>WebuiRequestContext: </em>" +
reqContext + "</li>");
+
+ try {
+ boolean available = Availability.isObjectAvailable(reqContext);
+ out.println("<li><em>reqContext available? </em>" +
available + "</li>");
+ if (available)
+ out.println("<li><em>reqContext.getRequest():
</em>" + reqContext.getRequest() + "</li>");
+ }
+ catch (Exception ex)
+ {
+ log.log(Level.SEVERE, "Exception while testing Availability: ", ex);
+ }
+
+ out.println("<li><em>PortalRequestContext: </em>" +
portalReqCtx + "</li>");
+ out.println("<li><em>PortalContainer: </em>" +
currentContainer + "</li>");
+ out.println("</ul>");
+ out.println("</body></html>");
+ out.close();
+ }
+
+ public String getServletContextName()
+ {
+ try
+ {
+ String [] parsed =
this.getServletContext().getResource("/").toExternalForm().split("/");
+ return parsed[parsed.length-1];
+ }
+ catch(Exception ex)
+ {
+ throw new RuntimeException("Failed to determine ServletContext name:
", ex);
+ }
+ }
+}
Added: sandbox/cdi_support/cdi/trunk/examples/portlet/src/main/webapp/WEB-INF/beans.xml
===================================================================
--- sandbox/cdi_support/cdi/trunk/examples/portlet/src/main/webapp/WEB-INF/beans.xml
(rev 0)
+++
sandbox/cdi_support/cdi/trunk/examples/portlet/src/main/webapp/WEB-INF/beans.xml 2011-04-23
20:10:49 UTC (rev 6335)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ The contents of this file is permitted to be empty.
+ The schema definition is provided for your convenience.
+-->
+<beans
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+
http://java.sun.com/xml/ns/javaee
+
http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
+</beans>
Added: sandbox/cdi_support/cdi/trunk/examples/portlet/src/main/webapp/WEB-INF/portlet.xml
===================================================================
--- sandbox/cdi_support/cdi/trunk/examples/portlet/src/main/webapp/WEB-INF/portlet.xml
(rev 0)
+++
sandbox/cdi_support/cdi/trunk/examples/portlet/src/main/webapp/WEB-INF/portlet.xml 2011-04-23
20:10:49 UTC (rev 6335)
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<portlet-app
xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
+version="2.0"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/portlet/portlet-app_2...
+
http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd">
+
+ <portlet>
+ <portlet-name>SimplePortlet</portlet-name>
+ <portlet-class>
+ org.gatein.cdi.examples.portlet.SimplePortlet
+ </portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ </supports>
+ <portlet-info>
+ <title>Simple CDI Supported Portlet</title>
+ </portlet-info>
+ </portlet>
+</portlet-app>
\ No newline at end of file
Added: sandbox/cdi_support/cdi/trunk/examples/portlet/src/main/webapp/WEB-INF/web.xml
===================================================================
--- sandbox/cdi_support/cdi/trunk/examples/portlet/src/main/webapp/WEB-INF/web.xml
(rev 0)
+++
sandbox/cdi_support/cdi/trunk/examples/portlet/src/main/webapp/WEB-INF/web.xml 2011-04-23
20:10:49 UTC (rev 6335)
@@ -0,0 +1,18 @@
+<?xml version="1.0"?>
+<web-app version="2.5"
+
xmlns="http://java.sun.com/xml/ns/javaee"
+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
+
+
+ <servlet>
+ <servlet-name>TestServlet</servlet-name>
+
<servlet-class>org.gatein.cdi.examples.portlet.TestServlet</servlet-class>
+ <load-on-startup>0</load-on-startup>
+ </servlet>
+
+ <servlet-mapping>
+ <servlet-name>TestServlet</servlet-name>
+ <url-pattern>/TestServlet</url-pattern>
+ </servlet-mapping>
+</web-app>
Added: sandbox/cdi_support/cdi/trunk/examples/traceextension/pom.xml
===================================================================
--- sandbox/cdi_support/cdi/trunk/examples/traceextension/pom.xml
(rev 0)
+++ sandbox/cdi_support/cdi/trunk/examples/traceextension/pom.xml 2011-04-23 20:10:49 UTC
(rev 6335)
@@ -0,0 +1,35 @@
+<?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.cdi</groupId>
+ <artifactId>gatein-cdi-parent</artifactId>
+ <version>1.0.0-Alpha01-SNAPSHOT</version>
+ <relativePath>../../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>gatein-cdi-example-traceextension</artifactId>
+ <name>GateIn CDI :: Examples :: Trace Extension</name>
+
+ <dependencies>
+ <dependency>
+ <groupId>javax.enterprise</groupId>
+ <artifactId>cdi-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>weld-core</artifactId>
+ <version>1.0.2-SNAPSHOT</version>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+
+</project>
Added:
sandbox/cdi_support/cdi/trunk/examples/traceextension/src/main/java/org/gatein/cdi/examples/traceextension/TraceExtension.java
===================================================================
---
sandbox/cdi_support/cdi/trunk/examples/traceextension/src/main/java/org/gatein/cdi/examples/traceextension/TraceExtension.java
(rev 0)
+++
sandbox/cdi_support/cdi/trunk/examples/traceextension/src/main/java/org/gatein/cdi/examples/traceextension/TraceExtension.java 2011-04-23
20:10:49 UTC (rev 6335)
@@ -0,0 +1,217 @@
+package org.gatein.cdi.examples.traceextension;
+
+import org.jboss.weld.bean.NewBean;
+import org.jboss.weld.manager.BeanManagerImpl;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.AfterBeanDiscovery;
+import javax.enterprise.inject.spi.AfterDeploymentValidation;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.BeforeBeanDiscovery;
+import javax.enterprise.inject.spi.BeforeShutdown;
+import javax.enterprise.inject.spi.Extension;
+import javax.enterprise.inject.spi.ProcessAnnotatedType;
+import javax.enterprise.inject.spi.ProcessBean;
+import javax.enterprise.inject.spi.ProcessInjectionTarget;
+import javax.enterprise.inject.spi.ProcessManagedBean;
+import javax.enterprise.inject.spi.ProcessProducer;
+import javax.enterprise.inject.spi.ProcessProducerField;
+import javax.enterprise.inject.spi.ProcessProducerMethod;
+import javax.enterprise.inject.spi.ProcessSessionBean;
+import java.util.List;
+import java.util.logging.Logger;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class TraceExtension implements Extension
+{
+ private static Logger log = Logger.getLogger(TraceExtension.class.getName());
+
+ public TraceExtension ()
+ {
+ log.info("TraceExtension loaded");
+ }
+
+ private BeanManagerImpl getBeanManagerImpl(BeanManager beanManager)
+ {
+ if (beanManager instanceof BeanManagerImpl == false)
+ throw new RuntimeException("TraceExtension only works on Weld!");
+
+ return (BeanManagerImpl) beanManager;
+ }
+
+ /*
+ * Startup / initialization phases
+ */
+ public void beforeBeanDiscovery(@Observes BeforeBeanDiscovery event, BeanManager
beanManager)
+ {
+ log.info("beforeBeanDiscovery: ");
+ BeanManagerImpl manager = getBeanManagerImpl(beanManager);
+ List<Bean<?>> beans = manager.getBeans();
+ for (Bean<?> bean : beans)
+ {
+ if (bean instanceof NewBean)
+ continue;
+ log.info(" (1) " + bean.getBeanClass() + " " +
bean.getTypes());
+ }
+ }
+
+ public void afterBeanDiscovery(@Observes AfterBeanDiscovery event, BeanManager
beanManager)
+ {
+ log.info("afterBeanDiscovery: ");
+ BeanManagerImpl mgr = getBeanManagerImpl(beanManager);
+ List<Bean<?>> beans = mgr.getBeans();
+ for (Bean<?> bean : beans)
+ {
+ if (bean instanceof NewBean)
+ continue;
+ log.info(" (2) " + bean.getBeanClass() + " " +
bean.getTypes());
+ }
+ }
+
+ public void afterDeploymentValidation(@Observes AfterDeploymentValidation event,
BeanManager beanManager)
+ {
+ log.info("afterDeploymentValidation: ");
+ BeanManagerImpl mgr = getBeanManagerImpl(beanManager);
+ List<Bean<?>> beans = mgr.getBeans();
+ for (Bean<?> bean : beans)
+ {
+ if (bean instanceof NewBean)
+ continue;
+ log.info(" (3) " + bean.getBeanClass() + " " +
bean.getTypes());
+ }
+ }
+
+
+ /*
+ * Shutdown phase
+ */
+ public void beforeShutdown(@Observes BeforeShutdown event)
+ {
+ log.info("beforeShutdown");
+ }
+
+
+
+ /*
+ * Initialization events
+ */
+ public void processAnnotatedType(@Observes ProcessAnnotatedType event)
+ {
+ log.info(" (*) processAnnotatedType: ");
+ log.info(" baseType: " +
event.getAnnotatedType().getBaseType());
+ log.info(" class: " +
event.getAnnotatedType().getJavaClass());
+ log.info(" types: " +
event.getAnnotatedType().getTypeClosure());
+ log.info(" annotations: " +
event.getAnnotatedType().getAnnotations());
+
+ //event.setAnnotatedType( decorate( event.getAnnotatedType() ) );
+ }
+
+ public void processInjectionTarget(@Observes ProcessInjectionTarget event)
+ {
+ log.info(" (*) processInjectionTarget: ");
+ log.info(" annotatedType: " + event.getAnnotatedType());
+ log.info(" injectionTarget: " + event.getInjectionTarget());
+ log.info(" injectionPoints: " +
event.getInjectionTarget().getInjectionPoints());
+
+ //event.setInjectionTarget(decorate(event.getInjectionTarget()));
+ }
+
+ public void processProducer(@Observes ProcessProducer event)
+ {
+ log.info(" (*) processProducer: ");
+ log.info(" producer: " + event.getProducer());
+ log.info(" injectionPoints: " +
event.getProducer().getInjectionPoints());
+
+ //event.setProducer(decorate(event.getProducer()));
+ }
+
+ public void processBean(@Observes ProcessBean event)
+ {
+ log.info(" (*) processBean: " + event.getBean());
+ log.info(" beanClass: " + event.getBean().getBeanClass());
+ log.info(" name: " + event.getBean().getName());
+ log.info(" qualifiers: " +
event.getBean().getQualifiers());
+ log.info(" scope: " + event.getBean().getScope());
+ log.info(" injectionPoints: " +
event.getBean().getInjectionPoints());
+ log.info(" stereotypes: " +
event.getBean().getStereotypes());
+ log.info(" types: " + event.getBean().getTypes());
+ log.info(" isAlternative: " +
event.getBean().isAlternative());
+ log.info(" isNullable: " + event.getBean().isNullable());
+ log.info("");
+ log.info(" annotated: " + event.getAnnotated());
+ log.info(" baseType: " +
event.getAnnotated().getBaseType());
+ log.info(" typeClosure: " +
event.getAnnotated().getTypeClosure());
+ log.info(" annotations: " +
event.getAnnotated().getAnnotations());
+ }
+
+ public void processSessionBean(@Observes ProcessSessionBean event)
+ {
+ log.info(" (*) processSessionBean: " + event.getEjbName());
+ }
+
+ public void processManagedBean(@Observes ProcessManagedBean event)
+ {
+ log.info(" (*) processManagedBean: " + event.getBean());
+ log.info(" beanClass: " + event.getBean().getBeanClass());
+ log.info(" name: " + event.getBean().getName());
+ log.info(" qualifiers: " +
event.getBean().getQualifiers());
+ log.info(" scope: " + event.getBean().getScope());
+ log.info(" injectionPoints: " +
event.getBean().getInjectionPoints());
+ log.info(" stereotypes: " +
event.getBean().getStereotypes());
+ log.info(" types: " + event.getBean().getTypes());
+ log.info(" isAlternative: " +
event.getBean().isAlternative());
+ log.info(" isNullable: " + event.getBean().isNullable());
+ log.info("");
+ log.info(" annotated: " + event.getAnnotated());
+ log.info(" baseType: " +
event.getAnnotated().getBaseType());
+ log.info(" typeClosure: " +
event.getAnnotated().getTypeClosure());
+ log.info(" annotations: " +
event.getAnnotated().getAnnotations());
+ log.info("");
+ log.info(" annotatedBeanClass: " + event.getAnnotatedBeanClass());
+ }
+
+ public void processProducerMethod(@Observes ProcessProducerMethod event)
+ {
+ log.info(" (*) processProducerMethod: ");
+ log.info(" bean: " + event.getBean());
+ log.info(" beanClass: " +
event.getBean().getBeanClass());
+ log.info(" name: " +
event.getBean().getName());
+ log.info(" qualifiers: " +
event.getBean().getQualifiers());
+ log.info(" scope: " +
event.getBean().getScope());
+ log.info(" injectionPoints: " +
event.getBean().getInjectionPoints());
+ log.info(" stereotypes: " +
event.getBean().getStereotypes());
+ log.info(" types: " +
event.getBean().getTypes());
+ log.info(" isAlternative: " +
event.getBean().isAlternative());
+ log.info(" isNullable: " +
event.getBean().isNullable());
+ log.info("");
+ log.info(" annotated: " + event.getAnnotated());
+ log.info(" baseType: " +
event.getAnnotated().getBaseType());
+ log.info(" typeClosure: " +
event.getAnnotated().getTypeClosure());
+ log.info(" annotations: " +
event.getAnnotated().getAnnotations());
+ log.info("");
+ log.info(" annotatedProducerMethod: " +
event.getAnnotatedProducerMethod());
+ log.info(" baseType: " +
event.getAnnotatedProducerMethod().getBaseType());
+ log.info(" declaringType: " +
event.getAnnotatedProducerMethod().getDeclaringType());
+ log.info(" typeClosure: " +
event.getAnnotatedProducerMethod().getTypeClosure());
+ log.info(" annotations: " +
event.getAnnotatedProducerMethod().getAnnotations());
+ log.info(" parameters: " +
event.getAnnotatedProducerMethod().getParameters());
+ log.info(" javaMember: " +
event.getAnnotatedProducerMethod().getJavaMember());
+
+// log.info("");
+// log.info(" annotatedDisposedParameter: " +
event.getAnnotatedDisposedParameter());
+// log.info(" baseType: " +
event.getAnnotatedDisposedParameter().getBaseType());
+// log.info(" annotations: " +
event.getAnnotatedDisposedParameter().getAnnotations());
+// log.info(" typeClosure: " +
event.getAnnotatedDisposedParameter().getTypeClosure());
+// log.info(" declaringCallable: " +
event.getAnnotatedDisposedParameter().getDeclaringCallable());
+// log.info(" position: " +
event.getAnnotatedDisposedParameter().getPosition());
+
+ }
+
+ public void processProducerField(@Observes ProcessProducerField event)
+ {
+ log.info(" (*) processProducerField: " +
event.getAnnotatedProducerField());
+ }
+}
Added:
sandbox/cdi_support/cdi/trunk/examples/traceextension/src/main/resources/META-INF/beans.xml
===================================================================
---
sandbox/cdi_support/cdi/trunk/examples/traceextension/src/main/resources/META-INF/beans.xml
(rev 0)
+++
sandbox/cdi_support/cdi/trunk/examples/traceextension/src/main/resources/META-INF/beans.xml 2011-04-23
20:10:49 UTC (rev 6335)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ The contents of this file is permitted to be empty.
+ The schema definition is provided for your convenience.
+-->
+<beans
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+
http://java.sun.com/xml/ns/javaee
+
http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
+</beans>
Added:
sandbox/cdi_support/cdi/trunk/examples/traceextension/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
===================================================================
---
sandbox/cdi_support/cdi/trunk/examples/traceextension/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
(rev 0)
+++
sandbox/cdi_support/cdi/trunk/examples/traceextension/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension 2011-04-23
20:10:49 UTC (rev 6335)
@@ -0,0 +1 @@
+org.gatein.cdi.examples.traceextension.TraceExtension
\ No newline at end of file
Added: sandbox/cdi_support/cdi/trunk/impl/pom.xml
===================================================================
--- sandbox/cdi_support/cdi/trunk/impl/pom.xml (rev 0)
+++ sandbox/cdi_support/cdi/trunk/impl/pom.xml 2011-04-23 20:10:49 UTC (rev 6335)
@@ -0,0 +1,70 @@
+<?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.cdi</groupId>
+ <artifactId>gatein-cdi-parent</artifactId>
+ <version>1.0.0-Alpha01-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>gatein-cdi-impl</artifactId>
+ <name>GateIn CDI :: Impl</name>
+
+ <packaging>jar</packaging>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.gatein.api</groupId>
+ <artifactId>gatein-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.cdi</groupId>
+ <artifactId>gatein-cdi</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <!-- Weld implementation - we use BeanManagerImpl directly -->
+ <dependency>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>weld-core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <!--dependency>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>weld-extensions</artifactId>
+ </dependency-->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.kernel</groupId>
+ <artifactId>exo.kernel.container</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.webui.core</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.webui.portal</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.core</groupId>
+ <artifactId>exo.core.component.organization.api</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ <dependency> <!-- TODO TODO: remove this -->
+ <groupId>org.jboss.web</groupId>
+ <artifactId>jbossweb</artifactId>
+ <scope>provided</scope>
+ </dependency>
+ </dependencies>
+</project>
Added:
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/cdi/impl/GateInExtension.java
===================================================================
---
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/cdi/impl/GateInExtension.java
(rev 0)
+++
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/cdi/impl/GateInExtension.java 2011-04-23
20:10:49 UTC (rev 6335)
@@ -0,0 +1,200 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * 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.cdi.impl;
+
+import org.gatein.cdi.api.annotations.PortalContainerScope;
+import org.gatein.cdi.api.annotations.RootContainerScope;
+import org.gatein.cdi.impl.annotations.GateInServiceLiteral;
+import org.gatein.cdi.impl.inject.GateInServiceProducerBean;
+import org.jboss.weld.bean.NewBean;
+import org.jboss.weld.manager.BeanManagerImpl;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.AfterBeanDiscovery;
+import javax.enterprise.inject.spi.Annotated;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.Decorator;
+import javax.enterprise.inject.spi.Extension;
+import javax.enterprise.inject.spi.InjectionPoint;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.logging.Logger;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class GateInExtension implements Extension
+{
+ private static final String GATEIN_API_PACKAGE_PREFIX = "org.gatein.api.";
+
+ private static Logger log = Logger.getLogger(GateInExtension.class.getName());
+
+ private Set<String> supportedTypes;
+
+ /*
+ * Keep in mind that Extension is proxied so there may be another proxy instance
created
+ */
+ public GateInExtension()
+ {
+ supportedTypes = new HashSet<String>();
+
supportedTypes.add("org.exoplatform.container.configuration.ConfigurationManager");
+ supportedTypes.add("org.exoplatform.services.cache.CacheService");
+
//supportedTypes.add("org.exoplatform.services.organization.OrganizationService");
+ }
+
+ public void afterBeanDiscovery(@Observes AfterBeanDiscovery event, BeanManager
beanManager)
+ {
+ if (beanManager instanceof BeanManagerImpl == false)
+ throw new RuntimeException("GateInExtension requires Weld for CDI!");
+
+ Set<String> newlyAdded = new HashSet<String>();
+
+ BeanManagerImpl mgr = (BeanManagerImpl) beanManager;
+
+ List<Bean<?>> beans = mgr.getBeans();
+ for (Bean<?> bean : beans)
+ {
+ if (bean instanceof NewBean)
+ continue;
+
+ Set<InjectionPoint> ijs = bean.getInjectionPoints();
+ for (InjectionPoint ij: ijs)
+ {
+ Annotation[] anns = ij.getQualifiers().toArray(new Annotation[0]);
+ String newlyAddedKey = getAnnotatedTypeKey(ij.getType(), anns);
+ Set<Bean<?>> resolvedBeans = beanManager.getBeans(ij.getType(),
anns);
+ if (!newlyAdded.contains(newlyAddedKey)
+ && !isInjectionPointSatisfied(ij, resolvedBeans, mgr)
+ && isInjectionProvidedByGateIn(ij)
+ && checkAnnotations(ij))
+ {
+
+ registerProducer(beanManager, event, ij);
+ newlyAdded.add(newlyAddedKey);
+ }
+ }
+ log.fine(bean.getBeanClass() + " " + bean.getTypes());
+ }
+ log.info("GateInExtension initialized.");
+ }
+
+ private String getAnnotatedTypeKey(Type type, Annotation[] annotations)
+ {
+ return type.toString() + "-" + new
TreeSet(Arrays.asList(annotations)).toString();
+ }
+
+ protected boolean checkAnnotations(InjectionPoint ij)
+ {
+ Annotated annotated = ij.getAnnotated();
+ Annotation rootAnn = annotated.getAnnotation(RootContainerScope.class);
+ Annotation portalAnn = annotated.getAnnotation(PortalContainerScope.class);
+
+ if (rootAnn != null && portalAnn != null)
+ throw new RuntimeException("Can't have both @RootContainerScope and
@PortalContainerScope on injection point: " + ij);
+
+ return true;
+ }
+
+ protected boolean isInjectionPointSatisfied(InjectionPoint ij, Set<?>
resolvedBeans, BeanManagerImpl beanManager)
+ {
+ if (ij.getBean() instanceof Decorator<?>)
+ {
+ //if
(beanManager.getEnabledClasses().getDecorators().contains(ij.getBean().getBeanClass()))
+ if
(beanManager.getEnabledDecoratorClasses().contains(ij.getBean().getBeanClass()))
+ {
+ return resolvedBeans.size() > 0;
+ }
+ else
+ {
+ return true;
+ }
+ }
+ else
+ {
+ return resolvedBeans.size() > 0;
+ }
+ }
+
+ protected boolean isInjectionProvidedByGateIn(InjectionPoint ij)
+ {
+ Annotated annotated = ij.getAnnotated();
+ Set<Annotation> annSet = annotated.getAnnotations();
+ if (annSet.contains(GateInServiceLiteral.INSTANCE))
+ return true;
+
+ Set<Type> types = annotated.getTypeClosure();
+ for (Type type: types)
+ {
+ if (type instanceof Class)
+ {
+ String className = ((Class) type).getName();
+ if (className.startsWith(GATEIN_API_PACKAGE_PREFIX))
+ {
+ if (className.endsWith(".PortalRequestContext")
+ || className.endsWith(".WebuiRequestContext")
+ || className.endsWith(".PortletRequestContext")
+ || className.endsWith(".RootContainer")
+ || className.endsWith(".PortalContainer")
+ || className.endsWith(".RootContainer"))
+ return false;
+ else
+ return true;
+ }
+ if (className.endsWith(".OrganizationService")
+ || className.endsWith(".UserHandler"))
+ {
+ return false;
+ }
+
+ // TODO: FIXME: This is a temporary measure
+ if (getSupportedTypes().contains(className))
+ return true;
+ }
+
+ }
+ return false;
+ }
+
+ protected Set<Type> getTypes(InjectionPoint ij)
+ {
+ Set<Type> types = new HashSet<Type>();
+ types.add(ij.getType());
+ return types;
+ }
+
+ protected void registerProducer(final BeanManager manager, final AfterBeanDiscovery
event, final InjectionPoint ij)
+ {
+ event.addBean(new GateInServiceProducerBean(manager, ij.getType(), getTypes(ij),
ij.getQualifiers()));
+ }
+
+ protected Set<String> getSupportedTypes()
+ {
+ return supportedTypes;
+ }
+}
\ No newline at end of file
Added:
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/cdi/impl/OrganizationServiceExtension.java
===================================================================
---
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/cdi/impl/OrganizationServiceExtension.java
(rev 0)
+++
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/cdi/impl/OrganizationServiceExtension.java 2011-04-23
20:10:49 UTC (rev 6335)
@@ -0,0 +1,79 @@
+/*
+ * 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.cdi.impl;
+
+import org.gatein.cdi.impl.annotations.OrganizationServiceSession;
+import org.jboss.weld.bean.NewBean;
+import org.jboss.weld.manager.BeanManagerImpl;
+
+import javax.enterprise.event.Observes;
+import javax.enterprise.inject.spi.AfterBeanDiscovery;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.BeforeBeanDiscovery;
+import javax.enterprise.inject.spi.Extension;
+import javax.enterprise.inject.spi.InjectionPoint;
+import java.lang.annotation.Annotation;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class OrganizationServiceExtension implements Extension
+{
+ public void afterBeanDiscovery(@Observes AfterBeanDiscovery event, BeanManager
beanManager)
+ {
+/*
+ if (beanManager instanceof BeanManagerImpl == false)
+ throw new RuntimeException("GateInExtension requires Weld for CDI!");
+
+ BeanManagerImpl mgr = (BeanManagerImpl) beanManager;
+ mgr.
+ List<Bean<?>> beans = mgr.getBeans();
+ for (Bean<?> bean : beans)
+ {
+ if (bean instanceof NewBean)
+ continue;
+
+ Set<InjectionPoint> ijs = bean.getInjectionPoints();
+ for (InjectionPoint ij: ijs)
+ {
+ if (isInOrganizationServiceDomain(ij.getType()))
+ {
+ bean.
+ }
+ Annotation[] anns = ij.getQualifiers().toArray(new Annotation[0]);
+ Set<Bean<?>> resolvedBeans = beanManager.getBeans(ij.getType(),
anns);
+ if (!isInjectionPointSatisfied(ij, resolvedBeans, mgr)
+ && isInjectionProvidedByGateIn(ij)
+ && checkAnnotations(ij))
+ {
+
+ registerProducer(beanManager, event, ij);
+ }
+ }
+ }
+*/
+ }
+}
Added:
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/cdi/impl/annotations/GateInServiceLiteral.java
===================================================================
---
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/cdi/impl/annotations/GateInServiceLiteral.java
(rev 0)
+++
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/cdi/impl/annotations/GateInServiceLiteral.java 2011-04-23
20:10:49 UTC (rev 6335)
@@ -0,0 +1,35 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * 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.cdi.impl.annotations;
+
+import org.gatein.api.annotations.GateInService;
+import javax.enterprise.util.AnnotationLiteral;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class GateInServiceLiteral extends AnnotationLiteral<GateInService>
implements GateInService
+{
+ public static final GateInService INSTANCE = new GateInServiceLiteral();
+
+ private GateInServiceLiteral() {}
+}
Added:
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/cdi/impl/annotations/OrganizationServiceSession.java
===================================================================
---
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/cdi/impl/annotations/OrganizationServiceSession.java
(rev 0)
+++
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/cdi/impl/annotations/OrganizationServiceSession.java 2011-04-23
20:10:49 UTC (rev 6335)
@@ -0,0 +1,41 @@
+/*
+ * 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.cdi.impl.annotations;
+
+import javax.interceptor.InterceptorBinding;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Inherited;
+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>
+ */
+@Inherited
+@InterceptorBinding
+(a)Target({ElementType.TYPE, ElementType.METHOD})
+(a)Retention(RetentionPolicy.RUNTIME)
+public @interface OrganizationServiceSession
+{
+}
Added:
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/cdi/impl/inject/GateInServiceProducerBean.java
===================================================================
---
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/cdi/impl/inject/GateInServiceProducerBean.java
(rev 0)
+++
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/cdi/impl/inject/GateInServiceProducerBean.java 2011-04-23
20:10:49 UTC (rev 6335)
@@ -0,0 +1,193 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * 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.cdi.impl.inject;
+
+import org.exoplatform.container.ExoContainer;
+import org.exoplatform.container.ExoContainerContext;
+import org.exoplatform.container.RootContainer;
+import org.gatein.cdi.api.annotations.PortalContainerScope;
+import org.gatein.cdi.api.annotations.RootContainerScope;
+import org.jboss.weld.literal.AnyLiteral;
+import org.jboss.weld.literal.DefaultLiteral;
+
+import javax.enterprise.context.Dependent;
+import javax.enterprise.context.spi.Context;
+import javax.enterprise.context.spi.CreationalContext;
+import javax.enterprise.inject.Any;
+import javax.enterprise.inject.Default;
+import javax.enterprise.inject.spi.Annotated;
+import javax.enterprise.inject.spi.Bean;
+import javax.enterprise.inject.spi.BeanManager;
+import javax.enterprise.inject.spi.InjectionPoint;
+import java.lang.annotation.Annotation;
+import java.lang.reflect.Type;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class GateInServiceProducerBean implements Bean
+{
+ private Class beanClass;
+ private Set<Type> types;
+ private BeanManager beanManager;
+ private Set<Annotation> qualifiers;
+
+ public GateInServiceProducerBean(BeanManager manager, Type beanClass, Set<Type>
types, Set<Annotation> qualifiers)
+ {
+ beanManager = manager;
+ this.beanClass = (Class) beanClass;
+ this.types = types;
+ this.qualifiers = new HashSet<Annotation>(qualifiers);
+
+ boolean anyFound = false;
+ boolean defaultFound = false;
+ for (Annotation a: qualifiers)
+ {
+ if (a instanceof Any)
+ anyFound = true;
+ else if (a instanceof Default)
+ defaultFound = true;
+ }
+ if (!defaultFound)
+ this.qualifiers.add(DefaultLiteral.INSTANCE);
+ if (!anyFound)
+ this.qualifiers.add(AnyLiteral.INSTANCE);
+
+ this.qualifiers = Collections.unmodifiableSet(this.qualifiers);
+ }
+
+ public Set<Type> getTypes()
+ {
+ return types;
+ }
+
+ public Set<Annotation> getQualifiers()
+ {
+ return qualifiers;
+ }
+
+ public Class<? extends Annotation> getScope()
+ {
+ return Dependent.class;
+ }
+
+ public String getName()
+ {
+ return null;
+ }
+
+ public Set<Class<? extends Annotation>> getStereotypes()
+ {
+ return Collections.emptySet();
+ }
+
+ public Class<?> getBeanClass()
+ {
+ return beanClass;
+ }
+
+ public boolean isAlternative()
+ {
+ return false;
+ }
+
+ public boolean isNullable()
+ {
+ return true;
+ }
+
+ public Set<InjectionPoint> getInjectionPoints()
+ {
+ return Collections.emptySet();
+ }
+
+ public Object create(CreationalContext creationalContext)
+ {
+ // return null if RootContainer is not yet available
+ //ExoContainer container = ExoContainerContext.getCurrentContainerIfPresent();
+ //if (container == null)
+ // return null;
+
+ Context ctx = beanManager.getContext(Dependent.class);
+ Bean<InjectionPoint> ipBean = (Bean<InjectionPoint>)
beanManager.getBeans(InjectionPoint.class).iterator().next();
+ CreationalContext ipCC = beanManager.createCreationalContext(ipBean);
+ InjectionPoint ip = ctx.get(ipBean, ipCC);
+ Annotated annotated = ip.getAnnotated();
+ Set<Annotation> anns = annotated.getAnnotations();
+ Type type = ip.getType();
+
+ if (useProxy(type, anns))
+ return GateInServiceProxy.createProxy(this, (Class) type, anns);
+
+ return lookupService(type, anns);
+ }
+
+ private boolean useProxy(Type type, Set<Annotation> anns)
+ {
+ // use proxy if RootContainer is not yet available
+ return ExoContainerContext.getCurrentContainerIfPresent() == null;
+ }
+
+ public Object lookupService(Type type, Set<Annotation> anns)
+ {
+ if (containsAnnotation(anns, RootContainerScope.class))
+ {
+ // do a service lookup using RootContainer
+ if (type instanceof Class)
+ return RootContainer.getInstance().getComponentInstanceOfType((Class) type);
+ else
+ return RootContainer.getInstance().getComponentInstance(type);
+ }
+ else
+ {
+ ExoContainer container = ExoContainerContext.getCurrentContainerIfPresent();
+ if (container == null)
+ return null;
+ // don't do RootContainer lookup if PortalContainerScope is requested but is
not available
+ if (container instanceof RootContainer &&
anns.contains(PortalContainerScope.class))
+ return null;
+
+ if (type instanceof Class)
+ return container.getComponentInstanceOfType((Class) type);
+ else
+ return container.getComponentInstance(type);
+ }
+ }
+
+ private boolean containsAnnotation(Set<Annotation> anns, Class<?>
annClass)
+ {
+ for (Annotation ann: anns)
+ {
+ if (ann.annotationType().isAssignableFrom(annClass))
+ return true;
+ }
+ return false;
+ }
+
+ public void destroy(Object service, CreationalContext creationalContext)
+ {
+ System.out.println("destroy(): " + service);
+ }
+}
\ No newline at end of file
Added:
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/cdi/impl/inject/GateInServiceProxy.java
===================================================================
---
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/cdi/impl/inject/GateInServiceProxy.java
(rev 0)
+++
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/cdi/impl/inject/GateInServiceProxy.java 2011-04-23
20:10:49 UTC (rev 6335)
@@ -0,0 +1,75 @@
+/*
+ * 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.cdi.impl.inject;
+
+import org.exoplatform.container.ExoContainerContext;
+
+import java.lang.annotation.Annotation;
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+import java.lang.reflect.Proxy;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class GateInServiceProxy implements InvocationHandler
+{
+ private GateInServiceProducerBean producer;
+ private Class type;
+ private Set<Annotation> anns;
+
+ private GateInServiceProxy(GateInServiceProducerBean producer, Class type,
Set<Annotation> anns)
+ {
+ this.producer = producer;
+ this.type = type;
+ this.anns = anns;
+ }
+
+ public static Object createProxy(GateInServiceProducerBean producer, Class type,
Set<Annotation> anns)
+ {
+ return Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
+ getInterfaces(type),
+ new GateInServiceProxy(producer, type, anns));
+ }
+
+ private static Class<Object>[] getInterfaces(Class type)
+ {
+ return new Class[] {type};
+ }
+
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
+ {
+ Object service = producer.lookupService(type, anns);
+ if (service == null)
+ {
+ if (method.getDeclaringClass() == Object.class &&
"toString".equals(method.getName()))
+ return "-- No delegate (current container: " +
ExoContainerContext.getCurrentContainerIfPresent() + ") --";
+
+ throw new IllegalStateException("Proxy operation failed to lookup delegate:
" + type + " (current container: "
+ + ExoContainerContext.getCurrentContainerIfPresent() + ")");
+ }
+ return method.invoke(service, args);
+ }
+
+}
Added:
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/cdi/impl/inject/GenericProxy.java
===================================================================
---
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/cdi/impl/inject/GenericProxy.java
(rev 0)
+++
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/cdi/impl/inject/GenericProxy.java 2011-04-23
20:10:49 UTC (rev 6335)
@@ -0,0 +1,51 @@
+/*
+ * 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.cdi.impl.inject;
+
+import java.lang.reflect.InvocationHandler;
+import java.lang.reflect.Method;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public abstract class GenericProxy<T> implements InvocationHandler
+{
+ protected abstract T produceDelegate();
+
+ protected abstract Class<T> getType();
+
+ protected abstract T getDelegate();
+
+ public Object invoke(Object proxy, Method method, Object[] args) throws Throwable
+ {
+ T delegate = getDelegate();
+ if (delegate == null)
+ {
+ if (method.getDeclaringClass() == Object.class &&
"toString".equals(method.getName()))
+ return "-- No delegate (type: " + getType() + ") --";
+
+ throw new IllegalStateException("Proxy operation failed to lookup delegate:
" + getType());
+ }
+ return method.invoke(delegate, args);
+ }
+}
Added:
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/cdi/impl/inject/GenericTLProxy.java
===================================================================
---
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/cdi/impl/inject/GenericTLProxy.java
(rev 0)
+++
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/cdi/impl/inject/GenericTLProxy.java 2011-04-23
20:10:49 UTC (rev 6335)
@@ -0,0 +1,48 @@
+/*
+ * 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.cdi.impl.inject;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public abstract class GenericTLProxy<T> extends GenericProxy<T>
+{
+ private ThreadLocal<T> tl = new ThreadLocal<T>();
+
+ protected T getDelegate()
+ {
+ T delegate = tl.get();
+
+ if (delegate != null)
+ return delegate;
+
+ delegate = produceDelegate();
+ tl.set(delegate);
+ return delegate;
+ }
+
+ public void clear()
+ {
+ tl.remove();
+ }
+}
Added:
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/cdi/impl/inject/OrganizationServiceInterceptor.java
===================================================================
---
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/cdi/impl/inject/OrganizationServiceInterceptor.java
(rev 0)
+++
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/cdi/impl/inject/OrganizationServiceInterceptor.java 2011-04-23
20:10:49 UTC (rev 6335)
@@ -0,0 +1,57 @@
+/*
+ * 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.cdi.impl.inject;
+
+import org.gatein.cdi.impl.annotations.OrganizationServiceSession;
+
+import javax.interceptor.AroundInvoke;
+import javax.interceptor.Interceptor;
+import javax.interceptor.InvocationContext;
+import java.lang.reflect.Proxy;
+
+/**
+ * Experimental stuff
+ *
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+@OrganizationServiceSession
+@Interceptor
+public class OrganizationServiceInterceptor
+{
+
+ @AroundInvoke
+ public Object manageOrganizationServiceSession(InvocationContext ctx) throws
Exception
+ {
+ Object ret = ctx.proceed();
+ Object target = ctx.getTarget();
+ if (Proxy.isProxyClass(target.getClass()))
+ {
+ Object ih = Proxy.getInvocationHandler(target);
+ if (ih instanceof GenericTLProxy)
+ {
+ ((GenericTLProxy) ih).clear();
+ }
+ }
+ return ret;
+ }
+}
Added:
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/cdi/impl/inject/OrganizationServiceProducers.java
===================================================================
---
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/cdi/impl/inject/OrganizationServiceProducers.java
(rev 0)
+++
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/cdi/impl/inject/OrganizationServiceProducers.java 2011-04-23
20:10:49 UTC (rev 6335)
@@ -0,0 +1,148 @@
+/*
+ * 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.cdi.impl.inject;
+
+import org.exoplatform.services.organization.GroupHandler;
+import org.exoplatform.services.organization.MembershipHandler;
+import org.exoplatform.services.organization.MembershipTypeHandler;
+import org.exoplatform.services.organization.OrganizationService;
+import org.exoplatform.services.organization.UserHandler;
+import org.exoplatform.services.organization.UserProfileHandler;
+
+import javax.enterprise.inject.Produces;
+import java.lang.reflect.Proxy;
+
+/**
+ * Experimental stuff
+ *
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class OrganizationServiceProducers
+{
+ //@Produces
+ public UserHandler produceUserHandler(final OrganizationService service)
+ {
+ return (UserHandler)
Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
+ new Class[] {UserHandler.class},
+ new GenericTLProxy<UserHandler>() {
+
+ @Override
+ protected UserHandler produceDelegate()
+ {
+ return service.getUserHandler();
+ }
+
+ @Override
+ protected Class getType()
+ {
+ return UserHandler.class;
+ }
+ });
+
+ }
+
+ //@Produces
+ public UserProfileHandler produceUserProfileHandler(final OrganizationService
service)
+ {
+ return (UserProfileHandler)
Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
+ new Class[] {UserProfileHandler.class},
+ new GenericTLProxy<UserProfileHandler>() {
+
+ @Override
+ protected UserProfileHandler produceDelegate()
+ {
+ return service.getUserProfileHandler();
+ }
+
+ @Override
+ protected Class getType()
+ {
+ return UserProfileHandler.class;
+ }
+ });
+ }
+
+ //@Produces
+ public GroupHandler produceGroupHandler(final OrganizationService service)
+ {
+ return (GroupHandler)
Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
+ new Class[] {GroupHandler.class},
+ new GenericTLProxy<GroupHandler>() {
+
+ @Override
+ protected GroupHandler produceDelegate()
+ {
+ return service.getGroupHandler();
+ }
+
+ @Override
+ protected Class getType()
+ {
+ return GroupHandler.class;
+ }
+ });
+ }
+
+ //@Produces
+ public MembershipTypeHandler produceMembershipTypeHandler(final OrganizationService
service)
+ {
+ return (MembershipTypeHandler)
Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
+ new Class[] {MembershipTypeHandler.class},
+ new GenericTLProxy<MembershipTypeHandler>() {
+
+ @Override
+ protected MembershipTypeHandler produceDelegate()
+ {
+ return service.getMembershipTypeHandler();
+ }
+
+ @Override
+ protected Class getType()
+ {
+ return MembershipTypeHandler.class;
+ }
+ });
+ }
+
+ //@Produces
+ public MembershipHandler produceMembershipHandler(final OrganizationService service)
+ {
+ return (MembershipHandler)
Proxy.newProxyInstance(Thread.currentThread().getContextClassLoader(),
+ new Class[] {MembershipHandler.class},
+ new GenericTLProxy<MembershipHandler>() {
+
+ @Override
+ protected MembershipHandler produceDelegate()
+ {
+ return service.getMembershipHandler();
+ }
+
+ @Override
+ protected Class getType()
+ {
+ return MembershipHandler.class;
+ }
+ });
+ }
+
+}
Added:
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/cdi/impl/producers/ProducersBean.java
===================================================================
---
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/cdi/impl/producers/ProducersBean.java
(rev 0)
+++
sandbox/cdi_support/cdi/trunk/impl/src/main/java/org/gatein/cdi/impl/producers/ProducersBean.java 2011-04-23
20:10:49 UTC (rev 6335)
@@ -0,0 +1,173 @@
+/*
+ * 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.cdi.impl.producers;
+
+import org.exoplatform.container.ExoContainer;
+import org.exoplatform.container.ExoContainerContext;
+import org.exoplatform.services.organization.OrganizationService;
+import org.exoplatform.services.organization.UserHandler;
+import org.gatein.api.app.PortalRequestContext;
+import org.gatein.api.app.PortletRequestContext;
+import org.gatein.api.app.WebuiRequestContext;
+import org.gatein.api.kernel.GateInContainer;
+import org.gatein.api.kernel.PortalContainer;
+import org.gatein.api.kernel.RootContainer;
+import org.gatein.cdi.api.annotations.PortalContainerScope;
+import org.gatein.cdi.api.annotations.RootContainerScope;
+import org.gatein.cdi.api.proxyproducer.ProxyProducer;
+
+import javax.enterprise.inject.spi.InjectionPoint;
+import java.lang.annotation.Annotation;
+import java.util.Set;
+
+/**
+ * @author <a href="mailto:mstrukel@redhat.com">Marko Strukelj</a>
+ */
+public class ProducersBean
+{
+ @ProxyProducer
+ public WebuiRequestContext produceWebuiRequestContext()
+ {
+ org.exoplatform.webui.application.WebuiRequestContext
+ webuiReqContext =
org.exoplatform.webui.application.WebuiRequestContext.getCurrentInstance();
+
+ return WebuiRequestContext.wrap(webuiReqContext);
+ }
+/*
+ @ProxyProducer
+ public PortalRequestContext producePortalRequestContext(WebuiRequestContext current)
+ {
+ if(current instanceof TargetInstanceProxy)
+ {
+ current = (WebuiRequestContext)
((TargetInstanceProxy)current).getTargetInstance();
+ }
+ if (current instanceof PortalRequestContext)
+ return (PortalRequestContext) current;
+
+ return null;
+ }
+
+ @ProxyProducer
+ public PortletRequestContext producePortletRequestContext(WebuiRequestContext
current)
+ {
+ if(current instanceof TargetInstanceProxy)
+ {
+ current = (WebuiRequestContext)
((TargetInstanceProxy)current).getTargetInstance();
+ }
+ if (current instanceof PortletRequestContext)
+ return (PortletRequestContext) current;
+
+ return null;
+ }
+*/
+ @ProxyProducer
+ public PortalRequestContext producePortalRequestContext()
+ {
+ WebuiRequestContext current = produceWebuiRequestContext();
+ if (current instanceof PortalRequestContext)
+ return (PortalRequestContext) current;
+
+ return null;
+ }
+
+ @ProxyProducer
+ public PortletRequestContext producePortletRequestContext()
+ {
+ WebuiRequestContext current = produceWebuiRequestContext();
+ if (current instanceof PortletRequestContext)
+ return (PortletRequestContext) current;
+
+ return null;
+ }
+
+ @ProxyProducer
+ public GateInContainer produceCurrentContainer()
+ {
+ ExoContainer current = ExoContainerContext.getCurrentContainerIfPresent();
+ if (current == null)
+ return null;
+
+ return GateInContainer.wrap(current);
+ }
+
+ @ProxyProducer
+ public RootContainer produceRootContainer()
+ {
+ GateInContainer current = produceCurrentContainer();
+ if (current instanceof RootContainer)
+ return (RootContainer) current;
+
+ return null;
+ }
+
+ @ProxyProducer
+ public PortalContainer producePortalContainer()
+ {
+ GateInContainer current = produceCurrentContainer();
+ if (current instanceof PortalContainer)
+ return (PortalContainer) current;
+
+ return null;
+ }
+
+ @ProxyProducer
+ public OrganizationService produceOrganizationService(InjectionPoint ij)
+ {
+ return (OrganizationService) lookupService(OrganizationService.class, ij);
+ }
+
+ @ProxyProducer
+ public UserHandler produceUserHandler(InjectionPoint ij)
+ {
+ OrganizationService orgSvc = produceOrganizationService(ij);
+ return orgSvc.getUserHandler();
+ }
+
+ protected Object lookupService(Object type, InjectionPoint ij)
+ {
+ Set<Annotation> anns = ij.getAnnotated().getAnnotations();
+ if (anns.contains(RootContainerScope.class))
+ {
+ // do a service lookup using RootContainer
+ if (type instanceof Class)
+ return
org.exoplatform.container.RootContainer.getInstance().getComponentInstanceOfType((Class)
type);
+ else
+ return
org.exoplatform.container.RootContainer.getInstance().getComponentInstance(type);
+ }
+ else
+ {
+ ExoContainer container = ExoContainerContext.getCurrentContainerIfPresent();
+ if (container == null)
+ return null;
+ // don't do RootContainer lookup if PortalContainerScope is requested but is
not available
+ if (container instanceof org.exoplatform.container.RootContainer &&
anns.contains(PortalContainerScope.class))
+ return null;
+
+ if (type instanceof Class)
+ return container.getComponentInstanceOfType((Class) type);
+ else
+ return container.getComponentInstance(type);
+ }
+
+ }
+}
Added: sandbox/cdi_support/cdi/trunk/impl/src/main/resources/META-INF/beans.xml
===================================================================
--- sandbox/cdi_support/cdi/trunk/impl/src/main/resources/META-INF/beans.xml
(rev 0)
+++ sandbox/cdi_support/cdi/trunk/impl/src/main/resources/META-INF/beans.xml 2011-04-23
20:10:49 UTC (rev 6335)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ The contents of this file is permitted to be empty.
+ The schema definition is provided for your convenience.
+-->
+<beans
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+ xsi:schemaLocation="
+
http://java.sun.com/xml/ns/javaee
+
http://java.sun.com/xml/ns/javaee/beans_1_0.xsd">
+</beans>
Added:
sandbox/cdi_support/cdi/trunk/impl/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
===================================================================
---
sandbox/cdi_support/cdi/trunk/impl/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension
(rev 0)
+++
sandbox/cdi_support/cdi/trunk/impl/src/main/resources/META-INF/services/javax.enterprise.inject.spi.Extension 2011-04-23
20:10:49 UTC (rev 6335)
@@ -0,0 +1,2 @@
+org.gatein.cdi.impl.GateInExtension
+org.gatein.cdi.impl.proxyproducer.ProxyProducerExtension
\ No newline at end of file
Added: sandbox/cdi_support/cdi/trunk/pom.xml
===================================================================
--- sandbox/cdi_support/cdi/trunk/pom.xml (rev 0)
+++ sandbox/cdi_support/cdi/trunk/pom.xml 2011-04-23 20:10:49 UTC (rev 6335)
@@ -0,0 +1,110 @@
+<?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.jboss.weld</groupId>
+ <artifactId>weld-parent</artifactId>
+ <version>9</version>
+ </parent>
+
+ <groupId>org.gatein.cdi</groupId>
+ <artifactId>gatein-cdi-parent</artifactId>
+ <name>GateIn CDI</name>
+ <version>1.0.0-Alpha01-SNAPSHOT</version>
+
+ <packaging>pom</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>
+ <org.gatein.wci.version>2.1.0-Beta02</org.gatein.wci.version>
+ <org.gatein.pc.version>2.3.0-Beta02-SNAPSHOT</org.gatein.pc.version>
+ </properties>
+
+ <modules>
+ <module>api</module>
+ <module>impl</module>
+ <!--module>docs/reference</module-->
+ <module>examples/portlet</module>
+ <!--module>examples/traceextension</module-->
+ <!--module>examples/bridgehello</module-->
+ </modules>
+
+ <dependencyManagement>
+ <dependencies>
+ <dependency>
+ <groupId>org.gatein.api</groupId>
+ <artifactId>gatein-api</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.cdi</groupId>
+ <artifactId>gatein-cdi</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.gatein.cdi</groupId>
+ <artifactId>gatein-cdi-impl</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>weld-core</artifactId>
+ <version>1.0.1-CR1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.weld</groupId>
+ <artifactId>weld-extensions</artifactId>
+ <version>1.0.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.enterprise</groupId>
+ <artifactId>cdi-api</artifactId>
+ <version>1.0-SNAPSHOT</version>
+ </dependency>
+ <dependency>
+ <groupId>javax.inject</groupId>
+ <artifactId>javax.inject</artifactId>
+ <version>1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.5.0</version>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.web</groupId>
+ <artifactId>jbossweb</artifactId>
+ <version>3.0.0-beta-6</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.container</artifactId>
+ <version>${org.exoplatform.kernel.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.exoplatform.portal</groupId>
+ <artifactId>exo.portal.webui.core</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.core</groupId>
+ <artifactId>exo.core.component.organization.api</artifactId>
+ <version>${org.exoplatform.core.version}</version>
+ </dependency>
+ </dependencies>
+ </dependencyManagement>
+</project>
Added: sandbox/cdi_support/cdi/trunk/readme.txt
===================================================================
--- sandbox/cdi_support/cdi/trunk/readme.txt (rev 0)
+++ sandbox/cdi_support/cdi/trunk/readme.txt 2011-04-23 20:10:49 UTC (rev 6335)
@@ -0,0 +1,4 @@
+Gatein CDI Integration
+======================
+
+TODO