Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use new JSFPortlet interface #2

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 55 additions & 2 deletions maven/blade.jsf.portlet.ds/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,16 @@
<groupId>com.sun.faces</groupId>
<artifactId>jsf-impl</artifactId>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>util-bridges</artifactId>
<version>7.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
<artifactId>util-java</artifactId>
<version>7.0.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>javax.portlet</groupId>
<artifactId>portlet-api</artifactId>
Expand All @@ -40,6 +50,17 @@
<artifactId>org.osgi.compendium</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay</groupId>
<artifactId>com.liferay.portal.jsf.portlet.tracker</artifactId>
<version>1.0.0</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
Expand All @@ -54,12 +75,44 @@
<Embed-Transitive>true</Embed-Transitive>
<Include-Resource>{maven-resources}</Include-Resource>
<Private-Package>blade.portlet</Private-Package>
<Import-Package>javax.portlet;version="[2.0,3)",javax.servlet;version="[2.5,4)"</Import-Package>
<Import-Package>
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,
com.liferay.portal.jsf.portlet.tracker,
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.*
</Import-Package>
<Servlet-Context-Name>blade-jsf-portlet</Servlet-Context-Name>
<Web-ContextPath>/blade-jsf-portlet</Web-ContextPath>
<_dsannotations>*</_dsannotations>
</instructions>
</configuration>
</plugin>
</plugins>
</build>

</project>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,14 @@
*/
package blade.portlet;

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,
Expand All @@ -35,7 +38,13 @@
public class JSFPortletDS extends GenericFacesPortlet {

@Activate
public void 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
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<faces-config
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-facesconfig_2_0.xsd"
version="2.0">

</faces-config>
94 changes: 94 additions & 0 deletions maven/blade.listener.servlet.portlet.ds/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
<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/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>
<artifactId>blade.listener.servlet.portlet.ds</artifactId>
<name>Listener Servlet DS</name>
<packaging>bundle</packaging>

<parent>
<groupId>blade</groupId>
<artifactId>blade.maven</artifactId>
<version>1.0.0-SNAPSHOT</version>
</parent>

<dependencies>
<dependency>
<groupId>javax.portlet</groupId>
<artifactId>portlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>servlet-api</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.compendium</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.liferay</groupId>
<artifactId>com.liferay.portal.jsf.portlet.tracker</artifactId>
<version>1.0.0</version>
<scope>provided</scope>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.felix</groupId>
<artifactId>maven-bundle-plugin</artifactId>
<extensions>true</extensions>
<configuration>
<instructions>
<Embed-Dependency>*;scope=compile|runtime;groupId=!org.osgi</Embed-Dependency>
<Embed-Transitive>true</Embed-Transitive>
<Include-Resource>{maven-resources}</Include-Resource>
<Private-Package>blade.portlet</Private-Package>
<Import-Package>
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.jsf.portlet.tracker,
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.*
</Import-Package>
<Web-ContextPath>/blade-listener-servlet-portlet</Web-ContextPath>
<_dsannotations>*</_dsannotations>
</instructions>
</configuration>
</plugin>
</plugins>
</build>

</project>
Original file line number Diff line number Diff line change
@@ -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

}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/**
* 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 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 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 = JSFPortlet.class
)
public class ListenerServletPortletDS extends GenericPortlet implements JSFPortlet {

@Activate
public void activate(BundleContext bundleContext) {
System.err.println("!@#$ activated " + this);
}
}
Original file line number Diff line number Diff line change
@@ -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);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>

<web-app 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" version="2.5">

<listener>
<listener-class>blade.listener.ExampleContextListener</listener-class>
</listener>

<servlet>
<servlet-name>ExampleServlet</servlet-name>
<servlet-class>blade.servlet.ExampleServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>ExampleServlet</servlet-name>
<url-pattern>*.xhtml</url-pattern>
</servlet-mapping>
</web-app>
6 changes: 3 additions & 3 deletions maven/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@

<properties>
<liferay.version>7.0.0-SNAPSHOT</liferay.version>
<mojarra.version>2.2.6</mojarra.version>
<mojarra.version>2.2.12</mojarra.version>
</properties>

<repositories>
Expand Down Expand Up @@ -52,7 +52,7 @@
<dependency>
<groupId>com.liferay.faces</groupId>
<artifactId>liferay-faces-bridge-impl</artifactId>
<version>4.2.0-beta</version>
<version>4.2.5-ga6</version>
</dependency>
<dependency>
<groupId>com.liferay.portal</groupId>
Expand Down Expand Up @@ -153,4 +153,4 @@
<module>blade.hook.jsp</module>
</modules>

</project>
</project>