Skip to content
Draft
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
29 changes: 29 additions & 0 deletions appserver/admingui/hello-world/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Hello World Admin Console Plugin

This is an example plugin that demonstrates how to create Jakarta Faces (JSF) pages in the GlassFish Admin Console.

## Features

- Creates a "Hello World" navigation item in the admin console sidebar
- Displays a JSF page with content from a CDI bean
- Demonstrates modern Jakarta Faces integration with the legacy admin console

## Files

- `HelloWorldConsolePlugin.java` - HK2 service that registers the plugin. Needed to register the integration points in `console-config.xml`
- `console-config.xml` - Plugin configuration defining integration points. Adds `helloWorldNavNode.jsf` to the sidebar
- `helloWorldNavNode.jsf` - Navigation node for the sidebar, opens `hello.xhtml`
- `hello.xhtml` - Main JSF page displayed when clicking the navigation item
- `HelloWorldBean.java` - CDI bean that provides the message content

## Usage

1. Build GlassFish with this plugin included
2. Start GlassFish domain
3. Access the admin console at http://localhost:4848
4. Look for "Hello World" in the sidebar navigation
5. Click it to see the JSF page

## Tutorial

See the [Creating JSF Pages in GlassFish Admin Console](https://github.com/eclipse-ee4j/glassfish/wiki/admin-console-faces-tutorial.adoc) tutorial in GlassFish Wiki for a complete step-by-step tutorial on creating similar plugins.
103 changes: 103 additions & 0 deletions appserver/admingui/hello-world/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright (c) 2024 Contributors to the Eclipse Foundation

This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
http://www.eclipse.org/legal/epl-2.0.

This Source Code may also be made available under the following Secondary
Licenses when the conditions for such availability set forth in the
Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
version 2 with the GNU Classpath Exception, which is available at
https://www.gnu.org/software/classpath/license.html.

SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0

-->

<!--
Maven POM for Hello World Admin Console Plugin.
This demonstrates the minimal configuration needed for a JSF-enabled
Admin Console plugin. Key aspects:
1. PACKAGING: glassfish-jar creates an OSGi-compatible JAR
2. PARENT: inherits from admingui parent for consistent configuration
3. DEPENDENCIES: Only CDI and console-common are needed for basic JSF integration
4. DEV PROFILE: Enables automatic copying to distribution during development
The plugin architecture allows this JAR to be:
- Included directly in the admin WAR (current approach)
- Deployed as a separate OSGi bundle (alternative approach)
- Loaded dynamically at runtime via plugin discovery
-->
<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<!--
Inherit from admingui parent POM for consistent build configuration.
This provides common dependencies, plugin versions, and build settings.
-->
<parent>
<groupId>org.glassfish.main.admingui</groupId>
<artifactId>admingui</artifactId>
<version>7.1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>console-hello-world-plugin</artifactId>
<!--
glassfish-jar packaging creates OSGi-compatible JAR with proper manifest.
This allows the plugin to work in both embedded and OSGi deployment modes.
-->
<packaging>glassfish-jar</packaging>

<name>Admin Console Hello World Plugin</name>
<description>Hello World plugin example for GlassFish Admin Console</description>

<dependencies>
<!--
CDI API for dependency injection and bean management.
Scope 'provided' because the runtime environment supplies this.
Enables @Named, @RequestScoped, @Inject annotations.
-->
<dependency>
<groupId>jakarta.enterprise</groupId>
<artifactId>jakarta.enterprise.cdi-api</artifactId>
<scope>provided</scope>
</dependency>
<!--
Console common module provides base classes and utilities.
Not strictly required for basic JSF integration but useful
for more advanced console integration features.
-->
<dependency>
<groupId>org.glassfish.main.admingui</groupId>
<artifactId>console-common</artifactId>
<version>${project.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>

<profiles>
<!--
Development profile for faster iteration during development.
When activated with 'mvn install -Pdev', this profile:
1. Enables copying the built JAR to the GlassFish distribution
2. Allows testing changes without full rebuild/redeploy cycle
3. Copies to the exact location where the admin WAR expects plugins
-->
<profile>
<id>dev</id>
<properties>
<!-- Enable the copy-to-distribution mechanism -->
<copy.modules.to.distribution.skip>false</copy.modules.to.distribution.skip>
<!--
Specify exact destination path for the plugin JAR.
This path is where the admin WAR's classloader will find the plugin.
The path structure matches the admin console's plugin loading mechanism.
-->
<copy.modules.to.distribution.destFile>${basedir}/../../../distributions/glassfish/target/stage/glassfish7/glassfish/lib/install/applications/__admingui/WEB-INF/lib/console-hello-world-plugin-${project.version}.jar</copy.modules.to.distribution.destFile>
</properties>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* Copyright (c) 2024 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
package org.glassfish.helloworld.admingui;

import jakarta.enterprise.context.RequestScoped;
import jakarta.inject.Named;

/**
* CDI backing bean for the Hello World JSF page in GlassFish Admin Console.
* This demonstrates how to create modern Jakarta Faces pages within the legacy
* Admin Console framework. The key aspects:
* 1. Uses CDI (@Named, @RequestScoped) instead of JSF managed beans
* 2. Works seamlessly with the existing console infrastructure
* 3. Can be injected with HK2 services via CDI producers if needed
* 4. Follows standard JSF patterns for data binding and actions
* The bean is automatically discovered by CDI due to the implicit bean archive
* (no beans.xml needed) and made available to JSF via the @Named annotation.
*/
@Named
@RequestScoped
public class HelloWorldBean {

/**
* Returns the main greeting message displayed on the page.
* This method is called via EL expression #{helloWorldBean.message}
* in the XHTML template. The property name follows JavaBean conventions
* (getMessage() -> message property).
* @return the greeting message
*/
public String getMessage() {
return "Hello World from GlassFish Admin Console!";
}

/**
* Returns a description of what this page demonstrates.
* Called via EL expression #{helloWorldBean.description} to show
* additional information about the JSF integration.
* @return the description text
*/
public String getDescription() {
return "This is a JSF page created using Jakarta Faces in the GlassFish Admin Console.";
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright (c) 2024 Contributors to the Eclipse Foundation
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
package org.glassfish.helloworld.admingui;

import java.net.URL;

import org.glassfish.api.admingui.ConsoleProvider;
import org.jvnet.hk2.annotations.Service;

/**
* HK2 service that registers this module as an Admin Console plugin.
* This class serves as the entry point for the plugin system to discover
* and integrate this module with the Admin Console. Key aspects:
* 1. @Service annotation makes this discoverable by HK2 service locator
* 2. ConsoleProvider interface is the contract for console plugins
* 3. getConfiguration() returning null means use default config file location
* 4. The plugin system will look for META-INF/admingui/console-config.xml
* The plugin architecture allows modular extensions to the console without
* modifying core console code. Each plugin can contribute:
* - Navigation nodes (tree items)
* - Integration points (masthead, content areas)
* - Resources (JSF pages, CSS, images)
* - Java components (CDI beans, HK2 services)
* This particular plugin demonstrates the "simplified plugin" approach where
* the plugin JAR is included directly in the admin WAR rather than deployed
* as a separate OSGi bundle.
*/
@Service
public class HelloWorldConsolePlugin implements ConsoleProvider {

/**
* Returns the URL to the plugin configuration file.
* Returning null tells the plugin system to look for the default
* configuration file at META-INF/admingui/console-config.xml within
* this plugin's JAR file.
* Alternative implementations could return a specific URL to a
* configuration file located elsewhere.
* @return null to use default config file location
*/
@Override
public URL getConfiguration() {
return null;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright (c) 2024 Contributors to the Eclipse Foundation
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/

/**
* Hello World plugin for GlassFish Admin Console demonstrating JSF integration.
*/
package org.glassfish.helloworld.admingui;
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

Copyright (c) 2024 Contributors to the Eclipse Foundation

This program and the accompanying materials are made available under the
terms of the Eclipse Public License v. 2.0, which is available at
http://www.eclipse.org/legal/epl-2.0.

This Source Code may also be made available under the following Secondary
Licenses when the conditions for such availability set forth in the
Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
version 2 with the GNU Classpath Exception, which is available at
https://www.gnu.org/software/classpath/license.html.

SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0

-->

<!--
Console plugin configuration file that defines integration points.
This file tells the Admin Console how to integrate this plugin:
1. console-config id="helloworld" - unique identifier for this plugin
2. integration-point - defines where and how to integrate with the console
Integration point types include:
- org.glassfish.admingui:navNode - adds items to navigation tree
- org.glassfish.admingui:mastheadStatusArea - adds content to masthead
- org.glassfish.admingui:loginform - customizes login form
- org.glassfish.admingui:loginimage - customizes login page image
The content attribute points to a JSF-Templating file (.jsf) that defines
the actual UI component to be integrated. These .jsf files use the legacy
JSF-Templating syntax but can reference modern JSF pages (.xhtml).
-->
<console-config id="helloworld">

<!--
Navigation node integration point that adds "Hello World" to the sidebar.
Attributes explained:
- id: unique identifier for this integration point
- type: org.glassfish.admingui:navNode means add to navigation tree
- priority: controls ordering (lower numbers appear first)
- parentId: "tree" means add to root level of navigation tree
- content: path to JSF-Templating file that defines the tree node
The content file (navigation/helloWorldNavNode.jsf) uses JSF-Templating
syntax to create a <sun:treeNode> component that appears in the sidebar.
-->
<integration-point
id="helloworld_nav_node"
type="org.glassfish.admingui:navNode"
priority="100"
parentId="tree"
content="navigation/helloWorldNavNode.jsf"
/>

</console-config>
Loading