Author: julien(a)jboss.com
Date: 2008-02-19 16:16:51 -0500 (Tue, 19 Feb 2008)
New Revision: 10034
Added:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedObject.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedObjectStatus.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/portal/admin/
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/portal/admin/ui/
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/portal/admin/ui/AdminPortlet.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/KernelObject.java
modules/portlet/trunk/test/src/test/resources/simple-portal-war/WEB-INF/portlet.xml
modules/portlet/trunk/test/src/test/resources/simple-portal-war/demo/admin.jsp
Modified:
modules/portlet/trunk/build/pom.xml
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedPortletApplication.java
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedPortletContainer.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/KernelPortletApplication.java
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/KernelPortletContainer.java
modules/portlet/trunk/test/src/test/build.xml
Log:
- start to build small UI for displaying managed container object status, need to add life
cycle change
Modified: modules/portlet/trunk/build/pom.xml
===================================================================
--- modules/portlet/trunk/build/pom.xml 2008-02-19 18:37:25 UTC (rev 10033)
+++ modules/portlet/trunk/build/pom.xml 2008-02-19 21:16:51 UTC (rev 10034)
@@ -39,7 +39,7 @@
<version.javassist>3.6-beta</version.javassist>
<version.jboss-remoting>2.2.1.GA</version.jboss-remoting>
<version.jboss.portal.common>1.2.0-Beta1</version.jboss.portal.common>
- <version.jboss.portal.web>1.2.0-Beta1</version.jboss.portal.web>
+ <version.jboss.portal.web>1.2.0-SNAPSHOT</version.jboss.portal.web>
<version.jboss.unit>1.2.0-Beta1</version.jboss.unit>
<version.log4j>1.2.14</version.log4j>
<version.apache.commons-logging>1.1.1</version.apache.commons-logging>
Added:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedObject.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedObject.java
(rev 0)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedObject.java 2008-02-19
21:16:51 UTC (rev 10034)
@@ -0,0 +1,38 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, 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.jboss.portal.portlet.container.managed;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public interface ManagedObject
+{
+
+ ManagedObjectStatus getStatus();
+
+ void managedStart() throws Exception;
+
+ void managedStop();
+
+}
Added:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedObjectStatus.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedObjectStatus.java
(rev 0)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedObjectStatus.java 2008-02-19
21:16:51 UTC (rev 10034)
@@ -0,0 +1,34 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, 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.jboss.portal.portlet.container.managed;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public enum ManagedObjectStatus
+{
+
+ STOPPED, STARTED, FAILED
+
+}
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedPortletApplication.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedPortletApplication.java 2008-02-19
18:37:25 UTC (rev 10033)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedPortletApplication.java 2008-02-19
21:16:51 UTC (rev 10034)
@@ -28,17 +28,14 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
*/
-public interface ManagedPortletApplication
+public interface ManagedPortletApplication extends ManagedObject
{
String getId();
- void managedStart() throws Exception;
-
- void managedStop();
-
Collection<? extends ManagedPortletContainer> getManagedPortletContainers();
ManagedPortletContainer getManagedPortletContainer(String portletContainerId);
+
}
Modified:
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedPortletContainer.java
===================================================================
---
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedPortletContainer.java 2008-02-19
18:37:25 UTC (rev 10033)
+++
modules/portlet/trunk/portlet/src/main/java/org/jboss/portal/portlet/container/managed/ManagedPortletContainer.java 2008-02-19
21:16:51 UTC (rev 10034)
@@ -28,7 +28,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
*/
-public interface ManagedPortletContainer
+public interface ManagedPortletContainer extends ManagedObject
{
String getId();
@@ -37,8 +37,4 @@
ManagedPortletApplication getManagedPortletApplication();
- void managedStart() throws Exception;
-
- void managedStop();
-
}
Added:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/portal/admin/ui/AdminPortlet.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/portal/admin/ui/AdminPortlet.java
(rev 0)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/portal/admin/ui/AdminPortlet.java 2008-02-19
21:16:51 UTC (rev 10034)
@@ -0,0 +1,66 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, 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.jboss.portal.portlet.portal.admin.ui;
+
+import org.jboss.portal.portlet.container.managed.PortletApplicationRegistry;
+import org.jboss.portal.portlet.container.managed.ManagedPortletApplication;
+import org.jboss.portal.portlet.container.managed.ManagedPortletContainer;
+
+import javax.portlet.GenericPortlet;
+import javax.portlet.RenderRequest;
+import javax.portlet.RenderResponse;
+import javax.portlet.PortletException;
+import java.io.IOException;
+import java.io.PrintWriter;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class AdminPortlet extends GenericPortlet
+{
+
+ protected void doView(RenderRequest req, RenderResponse resp) throws PortletException,
IOException
+ {
+
+ resp.setContentType("text/html");
+
+ PrintWriter writer = resp.getWriter();
+
+ // Use an alias
+ PortletApplicationRegistry registry =
(PortletApplicationRegistry)getPortletContext().getAttribute("PortletApplicationDeployer");
+
+ for (ManagedPortletApplication application :
registry.getManagedPortletApplications())
+ {
+ writer.print("<ul><li>Application " + application.getId()
+ " " + application.getStatus() + "</li><ul>");
+ for (ManagedPortletContainer container :
application.getManagedPortletContainers())
+ {
+ writer.print("<li>Container " + container.getId() + "
" + container.getStatus() + "</li>");
+ }
+ writer.print("</ul></ul>");
+ }
+
+ writer.close();
+
+ }
+}
Added:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/KernelObject.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/KernelObject.java
(rev 0)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/KernelObject.java 2008-02-19
21:16:51 UTC (rev 10034)
@@ -0,0 +1,125 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2008, 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.jboss.portal.portlet.test;
+
+import org.jboss.kernel.spi.dependency.KernelControllerContextAware;
+import org.jboss.kernel.spi.dependency.KernelControllerContext;
+import org.jboss.dependency.spi.ControllerState;
+import org.jboss.portal.portlet.container.managed.ManagedObject;
+import org.jboss.portal.portlet.container.managed.ManagedObjectStatus;
+
+import java.lang.reflect.UndeclaredThrowableException;
+
+/**
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 630 $
+ */
+public class KernelObject implements ManagedObject, KernelControllerContextAware
+{
+
+ /** . */
+ private KernelControllerContext controllerContext;
+
+ public final void setKernelControllerContext(KernelControllerContext
controllerContext) throws Exception
+ {
+ this.controllerContext = controllerContext;
+ }
+
+ public final void unsetKernelControllerContext(KernelControllerContext
controllerContext) throws Exception
+ {
+ this.controllerContext = null;
+ }
+
+ public final ManagedObjectStatus getStatus()
+ {
+ ControllerState state = controllerContext.getState();
+
+ //
+ if (state == ControllerState.INSTALLED)
+ {
+ return ManagedObjectStatus.STARTED;
+ }
+ else if (state == ControllerState.ERROR)
+ {
+ return ManagedObjectStatus.FAILED;
+ }
+ else
+ {
+ return ManagedObjectStatus.STOPPED;
+ }
+ }
+
+ public final void managedStart() throws Exception
+ {
+ controllerStart();
+ }
+
+ public final void managedStop()
+ {
+ controllerStop();
+ }
+
+ protected final void controllerStart() throws Exception
+ {
+ if (controllerContext == null)
+ {
+ throw new IllegalStateException("No under the controller of the
kernel");
+ }
+
+ //
+ try
+ {
+ controllerContext.getController().change(controllerContext,
ControllerState.INSTALLED);
+ }
+ catch (Throwable throwable)
+ {
+ if (throwable instanceof Exception)
+ {
+ throw ((Exception)throwable);
+ }
+ if (throwable instanceof Error)
+ {
+ throw ((Error)throwable);
+ }
+ throw new UndeclaredThrowableException(throwable);
+ }
+ }
+
+ protected final void controllerStop()
+ {
+ if (controllerContext == null)
+ {
+ throw new IllegalStateException("No under the controller of the
kernel");
+ }
+
+ //
+ try
+ {
+ controllerContext.getController().change(controllerContext,
ControllerState.CREATE);
+ }
+ catch (Throwable throwable)
+ {
+ throwable.printStackTrace();
+ }
+ }
+}
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/KernelPortletApplication.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/KernelPortletApplication.java 2008-02-19
18:37:25 UTC (rev 10033)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/KernelPortletApplication.java 2008-02-19
21:16:51 UTC (rev 10034)
@@ -27,7 +27,6 @@
import org.jboss.portal.portlet.container.managed.ManagedPortletApplication;
import org.jboss.portal.portlet.container.managed.ManagedPortletContainer;
import org.jboss.portal.web.WebApp;
-import org.jboss.portal.common.NotYetImplemented;
import javax.servlet.ServletContext;
import java.util.Map;
@@ -38,7 +37,7 @@
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
*/
-public class KernelPortletApplication implements PortletApplicationContext,
ManagedPortletApplication
+public class KernelPortletApplication extends KernelObject implements
PortletApplicationContext, ManagedPortletApplication
{
/** . */
@@ -104,12 +103,12 @@
public void invokeStart() throws Exception
{
- throw new NotYetImplemented();
+ controllerStart();
}
public void invokeStop()
{
- throw new NotYetImplemented();
+ controllerStop();
}
//
@@ -119,16 +118,6 @@
return portletApplication.getId();
}
- public void managedStart() throws Exception
- {
- throw new NotYetImplemented();
- }
-
- public void managedStop()
- {
- throw new NotYetImplemented();
- }
-
public Collection<? extends ManagedPortletContainer>
getManagedPortletContainers()
{
return kernelPortletContainers.values();
Modified:
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/KernelPortletContainer.java
===================================================================
---
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/KernelPortletContainer.java 2008-02-19
18:37:25 UTC (rev 10033)
+++
modules/portlet/trunk/test/src/main/java/org/jboss/portal/portlet/test/KernelPortletContainer.java 2008-02-19
21:16:51 UTC (rev 10034)
@@ -27,13 +27,12 @@
import org.jboss.portal.portlet.container.managed.ManagedPortletContainer;
import org.jboss.portal.portlet.container.managed.ManagedPortletApplication;
import org.jboss.portal.portlet.info.PortletInfo;
-import org.jboss.portal.common.NotYetImplemented;
/**
* @author <a href="mailto:julien@jboss.org">Julien Viet</a>
* @version $Revision: 630 $
*/
-public class KernelPortletContainer implements PortletContainerContext,
ManagedPortletContainer
+public class KernelPortletContainer extends KernelObject implements
PortletContainerContext, ManagedPortletContainer
{
/** . */
@@ -74,12 +73,12 @@
public void invokeStart() throws Exception
{
- throw new NotYetImplemented();
+ controllerStart();
}
public void invokeStop()
{
- throw new NotYetImplemented();
+ controllerStop();
}
//
@@ -98,14 +97,4 @@
{
return portletContainer.getInfo();
}
-
- public void managedStart() throws Exception
- {
- throw new NotYetImplemented();
- }
-
- public void managedStop()
- {
- throw new NotYetImplemented();
- }
}
Modified: modules/portlet/trunk/test/src/test/build.xml
===================================================================
--- modules/portlet/trunk/test/src/test/build.xml 2008-02-19 18:37:25 UTC (rev 10033)
+++ modules/portlet/trunk/test/src/test/build.xml 2008-02-19 21:16:51 UTC (rev 10034)
@@ -721,7 +721,7 @@
<jar jarfile="${target}/portlet-test-lib.jar">
- <fileset dir="${target}/classes"
excludes="org/jboss/portal/portlet/portal/**,org/jboss/portal/simple/**"/>
+ <fileset dir="${target}/classes"
excludes="org/jboss/portal/portlet/portal/samples/**"/>
</jar>
<copy todir="${test.temp.dir}/simple-portal-war">
Added:
modules/portlet/trunk/test/src/test/resources/simple-portal-war/WEB-INF/portlet.xml
===================================================================
--- modules/portlet/trunk/test/src/test/resources/simple-portal-war/WEB-INF/portlet.xml
(rev 0)
+++
modules/portlet/trunk/test/src/test/resources/simple-portal-war/WEB-INF/portlet.xml 2008-02-19
21:16:51 UTC (rev 10034)
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ ~ JBoss, a division of Red Hat ~
+ ~ Copyright 2008, 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. ~
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-->
+<portlet-app
xmlns="http://java.sun.com/xml/ns/portlet/portlet-app_2_0.xsd"
+
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"
+ version="2.0">
+ <portlet>
+ <description>Administration Portlet</description>
+ <portlet-name>AdminPortlet</portlet-name>
+ <display-name>Admin Portlet</display-name>
+
<portlet-class>org.jboss.portal.portlet.portal.admin.ui.AdminPortlet</portlet-class>
+ <supports>
+ <mime-type>text/html</mime-type>
+ <portlet-mode>VIEW</portlet-mode>
+ </supports>
+ <portlet-info>
+ <title>Admin Portlet</title>
+ <keywords>admin</keywords>
+ </portlet-info>
+ </portlet>
+
+</portlet-app>
+
Added: modules/portlet/trunk/test/src/test/resources/simple-portal-war/demo/admin.jsp
===================================================================
--- modules/portlet/trunk/test/src/test/resources/simple-portal-war/demo/admin.jsp
(rev 0)
+++
modules/portlet/trunk/test/src/test/resources/simple-portal-war/demo/admin.jsp 2008-02-19
21:16:51 UTC (rev 10034)
@@ -0,0 +1,14 @@
+<%@ page contentType="text/html" %>
+<%@ page language="java" %>
+<%@ taglib prefix="jbp" tagdir="/WEB-INF/tags/portal" %>
+<%@ taglib uri="/WEB-INF/portal.tld" prefix="portal" %>
+<%@ page isELIgnored="false" %>
+
+<%@ include file="/layouts/header.jsp" %>
+
+<portal:page>
+
+ <jbp:portlet name="AdminPortlet"
applicationName="simple-portal"/>
+
+</portal:page>
+<%@ include file="/layouts/footer.jsp" %>
\ No newline at end of file