From 067c112f4ebfc267ce7b1dd5499e83b97bbc7a7a Mon Sep 17 00:00:00 2001 From: Carlos Sierra Date: Tue, 17 Nov 2015 12:59:47 +0100 Subject: [PATCH 1/7] Correct imports --- maven/blade.jsf.portlet.ds/pom.xml | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/maven/blade.jsf.portlet.ds/pom.xml b/maven/blade.jsf.portlet.ds/pom.xml index bfb96d1..6aa802d 100644 --- a/maven/blade.jsf.portlet.ds/pom.xml +++ b/maven/blade.jsf.portlet.ds/pom.xml @@ -40,6 +40,11 @@ org.osgi.compendium provided + + org.osgi + org.osgi.core + 6.0.0 + @@ -54,7 +59,7 @@ true {maven-resources} blade.portlet - javax.portlet;version="[2.0,3)",javax.servlet;version="[2.5,4)" + javax.portlet;version="[2.0,3)",javax.servlet;version="[2.5,4)",com.liferay.portlet.model,com.liferay.staging.portlet.data.handler,com.liferay.portlet.exportimport.lar,org.osgi.framework,org.osgi.framework.wiring <_dsannotations>* From f97c013a53ab8c45bafeaabbb76e5535d7e3c4eb Mon Sep 17 00:00:00 2001 From: Carlos Sierra Date: Wed, 18 Nov 2015 12:44:12 +0100 Subject: [PATCH 2/7] =?UTF-8?q?OJO=20que=20no=20s=C3=A9=20lo=20que=20estoy?= =?UTF-8?q?=20haciendo?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- maven/blade.jsf.portlet.ds/pom.xml | 39 ++++++++++++++++++- .../main/java/blade/portlet/JSFPortletDS.java | 3 +- .../main/resources/WEB-INF/faces-config.xml | 9 +++++ .../src/main/resources/WEB-INF/web.xml | 6 +-- 4 files changed, 52 insertions(+), 5 deletions(-) create mode 100644 maven/blade.jsf.portlet.ds/src/main/resources/WEB-INF/faces-config.xml diff --git a/maven/blade.jsf.portlet.ds/pom.xml b/maven/blade.jsf.portlet.ds/pom.xml index 6aa802d..a0f524d 100644 --- a/maven/blade.jsf.portlet.ds/pom.xml +++ b/maven/blade.jsf.portlet.ds/pom.xml @@ -25,6 +25,16 @@ com.sun.faces jsf-impl + + com.liferay.portal + util-bridges + 7.0.0-SNAPSHOT + + + com.liferay.portal + util-java + 7.0.0-SNAPSHOT + javax.portlet portlet-api @@ -59,7 +69,34 @@ true {maven-resources} blade.portlet - javax.portlet;version="[2.0,3)",javax.servlet;version="[2.5,4)",com.liferay.portlet.model,com.liferay.staging.portlet.data.handler,com.liferay.portlet.exportimport.lar,org.osgi.framework,org.osgi.framework.wiring + + javax.naming, + javax.portlet;version="[2.0,3)", + javax.portlet.filter;version="[2.0,3)", + javax.servlet;version="[2.5,4)", + javax.servlet.http;version="[2.5,4)", + javax.servlet.jsp, + javax.el, + javax.el.*, + javax.management, + javax.management.*, + javax.xml, + javax.xml.*, + com.liferay.portal.model, + com.liferay.staging.portlet.data.handler, + com.liferay.portlet.exportimport.lar, + com.liferay.portal.kernel.log, + com.liferay.portal.kernel.servlet.filters.invoker, + com.liferay.portal.kernel.servlet, + com.liferay.portal.kernel.portlet, + com.sun.el, + org.w3c.dom, + org.w3c.dom.*, + org.xml.sax, + org.xml.sax.*, + org.osgi.* + + /blade-portlet <_dsannotations>* diff --git a/maven/blade.jsf.portlet.ds/src/main/java/blade/portlet/JSFPortletDS.java b/maven/blade.jsf.portlet.ds/src/main/java/blade/portlet/JSFPortletDS.java index b8e86ab..c376be9 100644 --- a/maven/blade.jsf.portlet.ds/src/main/java/blade/portlet/JSFPortletDS.java +++ b/maven/blade.jsf.portlet.ds/src/main/java/blade/portlet/JSFPortletDS.java @@ -15,6 +15,7 @@ */ package blade.portlet; +import org.osgi.framework.BundleContext; import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; @@ -35,7 +36,7 @@ public class JSFPortletDS extends GenericFacesPortlet { @Activate - public void activate() { + public void activate(BundleContext bundleContext) { System.err.println("!@#$ activated " + this); } } \ No newline at end of file diff --git a/maven/blade.jsf.portlet.ds/src/main/resources/WEB-INF/faces-config.xml b/maven/blade.jsf.portlet.ds/src/main/resources/WEB-INF/faces-config.xml new file mode 100644 index 0000000..87c1f85 --- /dev/null +++ b/maven/blade.jsf.portlet.ds/src/main/resources/WEB-INF/faces-config.xml @@ -0,0 +1,9 @@ + + + + \ No newline at end of file diff --git a/maven/blade.jsf.portlet.ds/src/main/resources/WEB-INF/web.xml b/maven/blade.jsf.portlet.ds/src/main/resources/WEB-INF/web.xml index 01b993d..6b4fc4b 100644 --- a/maven/blade.jsf.portlet.ds/src/main/resources/WEB-INF/web.xml +++ b/maven/blade.jsf.portlet.ds/src/main/resources/WEB-INF/web.xml @@ -11,9 +11,9 @@ true --> - - com.sun.faces.config.ConfigureListener - + + + Faces Servlet From ae148b320122d27150e2524bd4c597eb4aa6cde1 Mon Sep 17 00:00:00 2001 From: Juan G Date: Thu, 10 Dec 2015 12:59:44 +0100 Subject: [PATCH 3/7] WIP + ServletContext example --- maven/blade.jsf.portlet.ds/pom.xml | 11 ++- .../src/main/resources/WEB-INF/web.xml | 6 +- .../blade.listener.servlet.portlet.ds/pom.xml | 87 +++++++++++++++++++ .../listener/ExampleContextListener.java | 39 +++++++++ .../portlet/ListenerServletPortletDS.java | 42 +++++++++ .../java/blade/servlet/ExampleServlet.java | 21 +++++ .../src/main/resources/WEB-INF/web.xml | 19 ++++ maven/pom.xml | 4 +- 8 files changed, 220 insertions(+), 9 deletions(-) create mode 100644 maven/blade.listener.servlet.portlet.ds/pom.xml create mode 100644 maven/blade.listener.servlet.portlet.ds/src/main/java/blade/listener/ExampleContextListener.java create mode 100644 maven/blade.listener.servlet.portlet.ds/src/main/java/blade/portlet/ListenerServletPortletDS.java create mode 100644 maven/blade.listener.servlet.portlet.ds/src/main/java/blade/servlet/ExampleServlet.java create mode 100644 maven/blade.listener.servlet.portlet.ds/src/main/resources/WEB-INF/web.xml diff --git a/maven/blade.jsf.portlet.ds/pom.xml b/maven/blade.jsf.portlet.ds/pom.xml index a0f524d..e0bf58d 100644 --- a/maven/blade.jsf.portlet.ds/pom.xml +++ b/maven/blade.jsf.portlet.ds/pom.xml @@ -25,7 +25,7 @@ com.sun.faces jsf-impl - + javax.portlet portlet-api @@ -53,7 +53,7 @@ org.osgi org.osgi.core - 6.0.0 + provided @@ -70,18 +70,21 @@ {maven-resources} blade.portlet + javax.faces.* javax.naming, javax.portlet;version="[2.0,3)", javax.portlet.filter;version="[2.0,3)", javax.servlet;version="[2.5,4)", javax.servlet.http;version="[2.5,4)", javax.servlet.jsp, + javax.servlet.jsp.*, javax.el, javax.el.*, javax.management, javax.management.*, javax.xml, javax.xml.*, + javax.naming.*, com.liferay.portal.model, com.liferay.staging.portlet.data.handler, com.liferay.portlet.exportimport.lar, @@ -96,7 +99,7 @@ org.xml.sax.*, org.osgi.* - /blade-portlet + /blade-jsf-portlet <_dsannotations>* diff --git a/maven/blade.jsf.portlet.ds/src/main/resources/WEB-INF/web.xml b/maven/blade.jsf.portlet.ds/src/main/resources/WEB-INF/web.xml index 6b4fc4b..01b993d 100644 --- a/maven/blade.jsf.portlet.ds/src/main/resources/WEB-INF/web.xml +++ b/maven/blade.jsf.portlet.ds/src/main/resources/WEB-INF/web.xml @@ -11,9 +11,9 @@ true --> - - - + + com.sun.faces.config.ConfigureListener + Faces Servlet diff --git a/maven/blade.listener.servlet.portlet.ds/pom.xml b/maven/blade.listener.servlet.portlet.ds/pom.xml new file mode 100644 index 0000000..89e9a00 --- /dev/null +++ b/maven/blade.listener.servlet.portlet.ds/pom.xml @@ -0,0 +1,87 @@ + + + 4.0.0 + blade.listener.servlet.portlet.ds + Listener Servlet DS + bundle + + + blade + blade.maven + 1.0.0-SNAPSHOT + + + + + javax.portlet + portlet-api + provided + + + javax.servlet + servlet-api + provided + + + org.osgi + org.osgi.compendium + provided + + + org.osgi + org.osgi.core + provided + + + + + + + org.apache.felix + maven-bundle-plugin + true + + + *;scope=compile|runtime;groupId=!org.osgi + true + {maven-resources} + blade.portlet + + javax.portlet;version="[2.0,3)", + javax.portlet.filter;version="[2.0,3)", + javax.servlet;version="[2.5,4)", + javax.servlet.http;version="[2.5,4)", + javax.servlet.jsp, + javax.servlet.jsp.*, + javax.el, + javax.el.*, + javax.management, + javax.management.*, + javax.xml, + javax.xml.*, + javax.naming, + javax.naming.*, + com.liferay.portal.model, + com.liferay.staging.portlet.data.handler, + com.liferay.portlet.exportimport.lar, + com.liferay.portal.kernel.log, + com.liferay.portal.kernel.servlet.filters.invoker, + com.liferay.portal.kernel.servlet, + com.liferay.portal.kernel.portlet, + com.sun.el, + org.w3c.dom, + org.w3c.dom.*, + org.xml.sax, + org.xml.sax.*, + org.osgi.* + + /blade-listener-servlet-portlet + <_dsannotations>* + + + + + + + diff --git a/maven/blade.listener.servlet.portlet.ds/src/main/java/blade/listener/ExampleContextListener.java b/maven/blade.listener.servlet.portlet.ds/src/main/java/blade/listener/ExampleContextListener.java new file mode 100644 index 0000000..c285ca1 --- /dev/null +++ b/maven/blade.listener.servlet.portlet.ds/src/main/java/blade/listener/ExampleContextListener.java @@ -0,0 +1,39 @@ +package blade.listener; + +import javax.servlet.ServletContext; +import javax.servlet.ServletContextEvent; +import javax.servlet.ServletContextListener; +import javax.servlet.ServletRequestEvent; +import javax.servlet.ServletRequestListener; + +public class ExampleContextListener implements ServletContextListener,ServletRequestListener { + + @Override + public void contextInitialized(ServletContextEvent sce) { + System.err.println("Context initialized"); + + ServletContext servletContext = sce.getServletContext(); + + servletContext.setAttribute("contextAttribute", "Listener passed"); + + } + + @Override + public void contextDestroyed(ServletContextEvent sce) { + // TODO Auto-generated method stub + + } + + @Override + public void requestDestroyed(ServletRequestEvent sre) { + // TODO Auto-generated method stub + + } + + @Override + public void requestInitialized(ServletRequestEvent sre) { + // TODO Auto-generated method stub + + } + +} diff --git a/maven/blade.listener.servlet.portlet.ds/src/main/java/blade/portlet/ListenerServletPortletDS.java b/maven/blade.listener.servlet.portlet.ds/src/main/java/blade/portlet/ListenerServletPortletDS.java new file mode 100644 index 0000000..8a75a75 --- /dev/null +++ b/maven/blade.listener.servlet.portlet.ds/src/main/java/blade/portlet/ListenerServletPortletDS.java @@ -0,0 +1,42 @@ +/** + * Copyright 2000-present Liferay, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package blade.portlet; + +import org.osgi.framework.BundleContext; +import org.osgi.service.component.annotations.Activate; +import org.osgi.service.component.annotations.Component; + +import javax.portlet.GenericPortlet; +import javax.portlet.Portlet; + +@Component( + immediate = true, + property = { + "com.liferay.portlet.display-category=category.sample", + "com.liferay.portlet.instanceable=true", + "javax.portlet.display-name=Listener Servlet Portlet DS", + "javax.portlet.init-param.view-template=", + "javax.portlet.security-role-ref=power-user,user" + }, + service = Portlet.class +) +public class ListenerServletPortletDS extends GenericPortlet { + + @Activate + public void activate(BundleContext bundleContext) { + System.err.println("!@#$ activated " + this); + } +} \ No newline at end of file diff --git a/maven/blade.listener.servlet.portlet.ds/src/main/java/blade/servlet/ExampleServlet.java b/maven/blade.listener.servlet.portlet.ds/src/main/java/blade/servlet/ExampleServlet.java new file mode 100644 index 0000000..2340809 --- /dev/null +++ b/maven/blade.listener.servlet.portlet.ds/src/main/java/blade/servlet/ExampleServlet.java @@ -0,0 +1,21 @@ +package blade.servlet; + +import javax.servlet.ServletContext; +import javax.servlet.ServletException; +import javax.servlet.http.HttpServlet; + +public class ExampleServlet extends HttpServlet { + + @Override + public void init() throws ServletException { + + super.init(); + + ServletContext servletContext = getServletContext(); + + String contextAttributeValue = (String) servletContext.getAttribute("contextAttribute"); + + System.err.println("Context attribute value: " + contextAttributeValue); + } + +} diff --git a/maven/blade.listener.servlet.portlet.ds/src/main/resources/WEB-INF/web.xml b/maven/blade.listener.servlet.portlet.ds/src/main/resources/WEB-INF/web.xml new file mode 100644 index 0000000..a54a4da --- /dev/null +++ b/maven/blade.listener.servlet.portlet.ds/src/main/resources/WEB-INF/web.xml @@ -0,0 +1,19 @@ + + + + + + blade.listener.ExampleContextListener + + + + ExampleServlet + blade.servlet.ExampleServlet + 1 + + + ExampleServlet + *.xhtml + + diff --git a/maven/pom.xml b/maven/pom.xml index acdce62..423a084 100644 --- a/maven/pom.xml +++ b/maven/pom.xml @@ -12,7 +12,7 @@ 7.0.0-SNAPSHOT - 2.2.6 + 2.2.12 @@ -52,7 +52,7 @@ com.liferay.faces liferay-faces-bridge-impl - 4.2.0-beta + 4.2.6-ga7-SNAPSHOT com.liferay.portal From 22a597214bc377dd6793c4eef63b3df568f8c1e3 Mon Sep 17 00:00:00 2001 From: Carlos Sierra Date: Fri, 11 Dec 2015 13:35:01 +0100 Subject: [PATCH 4/7] use new JSFPortlet interface --- maven/blade.jsf.portlet.ds/pom.xml | 9 ++++++++- .../src/main/java/blade/portlet/JSFPortletDS.java | 5 +++-- maven/blade.listener.servlet.portlet.ds/pom.xml | 7 +++++++ .../java/blade/portlet/ListenerServletPortletDS.java | 5 +++-- maven/pom.xml | 4 ++-- 5 files changed, 23 insertions(+), 7 deletions(-) diff --git a/maven/blade.jsf.portlet.ds/pom.xml b/maven/blade.jsf.portlet.ds/pom.xml index e0bf58d..51fa05b 100644 --- a/maven/blade.jsf.portlet.ds/pom.xml +++ b/maven/blade.jsf.portlet.ds/pom.xml @@ -55,6 +55,12 @@ org.osgi.core provided + + com.liferay + com.liferay.portal.jsf.portlet.tracker + 1.0.0 + provided + @@ -88,6 +94,7 @@ com.liferay.portal.model, com.liferay.staging.portlet.data.handler, com.liferay.portlet.exportimport.lar, + com.liferay.portal.jsf.portlet.tracker, com.liferay.portal.kernel.log, com.liferay.portal.kernel.servlet.filters.invoker, com.liferay.portal.kernel.servlet, @@ -107,4 +114,4 @@ - + \ No newline at end of file diff --git a/maven/blade.jsf.portlet.ds/src/main/java/blade/portlet/JSFPortletDS.java b/maven/blade.jsf.portlet.ds/src/main/java/blade/portlet/JSFPortletDS.java index c376be9..66bb207 100644 --- a/maven/blade.jsf.portlet.ds/src/main/java/blade/portlet/JSFPortletDS.java +++ b/maven/blade.jsf.portlet.ds/src/main/java/blade/portlet/JSFPortletDS.java @@ -15,6 +15,7 @@ */ package blade.portlet; +import com.liferay.portal.jsf.portlet.tracker.JSFPortlet; import org.osgi.framework.BundleContext; import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; @@ -31,9 +32,9 @@ "javax.portlet.init-param.view-template=", "javax.portlet.security-role-ref=power-user,user" }, - service = Portlet.class + service = JSFPortlet.class ) -public class JSFPortletDS extends GenericFacesPortlet { +public class JSFPortletDS extends GenericFacesPortlet implements JSFPortlet { @Activate public void activate(BundleContext bundleContext) { diff --git a/maven/blade.listener.servlet.portlet.ds/pom.xml b/maven/blade.listener.servlet.portlet.ds/pom.xml index 89e9a00..405657e 100644 --- a/maven/blade.listener.servlet.portlet.ds/pom.xml +++ b/maven/blade.listener.servlet.portlet.ds/pom.xml @@ -33,6 +33,12 @@ org.osgi.core provided + + com.liferay + com.liferay.portal.jsf.portlet.tracker + 1.0.0 + provided + @@ -65,6 +71,7 @@ com.liferay.portal.model, com.liferay.staging.portlet.data.handler, com.liferay.portlet.exportimport.lar, + com.liferay.portal.jsf.portlet.tracker, com.liferay.portal.kernel.log, com.liferay.portal.kernel.servlet.filters.invoker, com.liferay.portal.kernel.servlet, diff --git a/maven/blade.listener.servlet.portlet.ds/src/main/java/blade/portlet/ListenerServletPortletDS.java b/maven/blade.listener.servlet.portlet.ds/src/main/java/blade/portlet/ListenerServletPortletDS.java index 8a75a75..c997e3f 100644 --- a/maven/blade.listener.servlet.portlet.ds/src/main/java/blade/portlet/ListenerServletPortletDS.java +++ b/maven/blade.listener.servlet.portlet.ds/src/main/java/blade/portlet/ListenerServletPortletDS.java @@ -15,6 +15,7 @@ */ package blade.portlet; +import com.liferay.portal.jsf.portlet.tracker.JSFPortlet; import org.osgi.framework.BundleContext; import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; @@ -31,9 +32,9 @@ "javax.portlet.init-param.view-template=", "javax.portlet.security-role-ref=power-user,user" }, - service = Portlet.class + service = JSFPortlet.class ) -public class ListenerServletPortletDS extends GenericPortlet { +public class ListenerServletPortletDS extends GenericPortlet implements JSFPortlet { @Activate public void activate(BundleContext bundleContext) { diff --git a/maven/pom.xml b/maven/pom.xml index 423a084..8a85edb 100644 --- a/maven/pom.xml +++ b/maven/pom.xml @@ -52,7 +52,7 @@ com.liferay.faces liferay-faces-bridge-impl - 4.2.6-ga7-SNAPSHOT + 4.2.5-ga6 com.liferay.portal @@ -153,4 +153,4 @@ blade.hook.jsp - + \ No newline at end of file From 7f24bc05fce36eada2ec55367ed2fe8de6012466 Mon Sep 17 00:00:00 2001 From: Carlos Sierra Date: Mon, 14 Dec 2015 12:35:20 +0100 Subject: [PATCH 5/7] these are needed --- maven/blade.jsf.portlet.ds/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/maven/blade.jsf.portlet.ds/pom.xml b/maven/blade.jsf.portlet.ds/pom.xml index 51fa05b..f89b7da 100644 --- a/maven/blade.jsf.portlet.ds/pom.xml +++ b/maven/blade.jsf.portlet.ds/pom.xml @@ -25,7 +25,7 @@ com.sun.faces jsf-impl - + javax.portlet portlet-api From 1d60c21afe9377eb982aa2287cc7e496e528fbc9 Mon Sep 17 00:00:00 2001 From: Carlos Sierra Date: Mon, 14 Dec 2015 12:35:53 +0100 Subject: [PATCH 6/7] make Servlet-Context-Name match Web-ContextPath This allows the portlet to reuse the existing context created by the Wab-Extender --- maven/blade.jsf.portlet.ds/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/maven/blade.jsf.portlet.ds/pom.xml b/maven/blade.jsf.portlet.ds/pom.xml index f89b7da..52742f6 100644 --- a/maven/blade.jsf.portlet.ds/pom.xml +++ b/maven/blade.jsf.portlet.ds/pom.xml @@ -106,6 +106,7 @@ org.xml.sax.*, org.osgi.* + blade-jsf-portlet /blade-jsf-portlet <_dsannotations>* From 98d6700dfa35aa617ef4c643a79b69c900c6d010 Mon Sep 17 00:00:00 2001 From: Carlos Sierra Date: Mon, 14 Dec 2015 12:37:02 +0100 Subject: [PATCH 7/7] No longer need JSFPortlet We can just wait for the servlet context created for our bundle --- .../src/main/java/blade/portlet/JSFPortletDS.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/maven/blade.jsf.portlet.ds/src/main/java/blade/portlet/JSFPortletDS.java b/maven/blade.jsf.portlet.ds/src/main/java/blade/portlet/JSFPortletDS.java index 66bb207..5938a0f 100644 --- a/maven/blade.jsf.portlet.ds/src/main/java/blade/portlet/JSFPortletDS.java +++ b/maven/blade.jsf.portlet.ds/src/main/java/blade/portlet/JSFPortletDS.java @@ -15,13 +15,14 @@ */ package blade.portlet; -import com.liferay.portal.jsf.portlet.tracker.JSFPortlet; import org.osgi.framework.BundleContext; import org.osgi.service.component.annotations.Activate; import org.osgi.service.component.annotations.Component; +import org.osgi.service.component.annotations.Reference; import javax.portlet.Portlet; import javax.portlet.faces.GenericFacesPortlet; +import javax.servlet.ServletContext; @Component( immediate = true, @@ -32,12 +33,18 @@ "javax.portlet.init-param.view-template=", "javax.portlet.security-role-ref=power-user,user" }, - service = JSFPortlet.class + service = Portlet.class ) -public class JSFPortletDS extends GenericFacesPortlet implements JSFPortlet { +public class JSFPortletDS extends GenericFacesPortlet { @Activate public void activate(BundleContext bundleContext) { System.err.println("!@#$ activated " + this); } + + @Reference(target="(osgi.web.symbolicname=blade.jsf.portlet.ds)") + protected void setServletContext(ServletContext servletContext) { + //wait for the servlet context + } + } \ No newline at end of file