#12 Brought to you by

CONTENTS INCLUDE: n About GlassFish Getting Started with n Downloading and Installing n GlassFish Administration n Daily Administration Tasks GlassFish Application Server v3 n Security n Monitoring and more... By Masoud Kalali Visit refcardz.com

are different in terms of provided services and footprint. The ABOUT GLASSFISH beauty of modularity is the option to install the EE or Web Profile distributions and simply use the update center GlassFish is a Java EE application server hosted at to download/install/uninstall the desired modules. The Web http://glassfish.dev.java.net and is sponsored mainly by Sun Profile distribution does not provide enterprise integration Microsystems. Based on the Java EE reference implementation, services such as JCA and JMS. GlassFish is the first application server to support new specifications and standards. It is distributed under two open DOWNLOADING AND INSTALLING source licenses - GPL v2 with the Classpath exception and CDDL. To download GlassFish visit https://glassfish.dev.java.net/ public/downloadsindex.html and selecting the appropriate What Makes GlassFish Different . JDK 6 (version 1.6.0_13) or a newer version Several unique features differentiate GlassFish v3 from other is required for installation. Supported operating systems on application servers: it’s the first to support Java EE 6 and different architectures Web Profile; modularity based on OSGi; session retention include: Solaris, on application redeploy; support for the latest Web services OpenSolaris, Linux, specification and proven interoperability with Microsoft WCF; AIX, and Windows. easy-to-use administration console and command line; low- Installing GlassFish is overhead, fine grained monitoring, in addition to already as easy as following available monitoring facilities in its administration channels; the automatic and runs dynamic languages and frameworks like RoR using installer’s steps. native containers. For now, those requiring high availability Alternatively, GlassFish clustering and centralized administration with Java EE 5 v3 can be installed applications should consider GlassFish v2. These features are using a zip installer; in the GlassFish v3 roadmap. just download, unzip, Support for GlassFish is available in a community driven mode and go. For the (free) and commercial support provided by . remainder of this www.dzone.com Get More Refcardz! It’s worth noting that to move from community driven support Refcard, assume to commercial support there is no need to re-install. Install GlassFish is installed in Figure 1: GlassFish installation directory structure the Sun Branding and license from the Update Center, enter gf_home. a commercial relationship with Sun Microsystems, and have GlassFish Domains

best of the breed application server along with support from a leading Java EE vendor. GlassFish, like other application servers, uses the concept of domains: entities which define the scope of administration. GlassFish v3 GlassFish v3 is the first application server based on OSGi with full support of Java EE 6 umbrella specification. OSGi and a highly modular architecture turn GlassFish v3 into the most flexible and extensible application server available on the market. It offers many GlassFish v2 features, and many new features and enhancements introduced in different layers - from application server security and stability to developer productivity improvements. Some additional new features include: • Embeddable; dynamically extensible • IPS as main packaging, distribution and updating system • Uses OpenInstaller for installation; optional zip installer • RESTful monitoring interface Web and Enterprise Profiles GlassFish v3 fully supports Java EE 6 and also provides both Web Profile and Java EE distributions. These distributions GlassFish Application Server 3.0

DZone, Inc. | www.dzone.com 2 Getting Started with GlassFish Application Server v3

Each GlassFish v3 installation has its own domain, although The asadmin options are shown in Table 2: support for multiple domains – an existing GlassFish v2 feature Table 2: The asadmin program options - is in the GlassFish v3 roadmap. --host The application server administration listener IP address or host name. GlassFish Directory Structure --port The administration listener port number. The directory structure of GlassFish v3 has changed to cope --user A username in admin realm. admin by default. with new architecture and features. Figure 1 (page1) shows the new directory layout and Table 1 provides descriptions of --passwordfile The password file containing administrator’s password. important directories. --terse Add new type of container to host; for example another dynamic language applications.

All directories in Figure 1 are numbered to ease locating them --interactive If specified, CLI utility will ask for required parameter in an interactive way. in the table and in Figure 2 (page3). --secure If specified, CLI utility will use HTTPs to communicate with administration application to prevent possible security breach. Table 1: Directory structure description Dir Description Not all of these parameters are required for executing a 1 Contains links to asadmin and update center scripts. Directory no. 13 contains Java EE command and only important items are detailed in this related scripts in addition to what is available in this directory. Refcard. 2 GlassFish configuration files. The second mode of using asadmin script is entering the shell 3 This is where new OSGi modules are placed to allow the application server platform to pick them up. and running commands inside the shell. This is a bit faster than

4 OSGi platform used by GlassFish. the first method which needs to run the asadmin utility each

5 OpenInstaller and un-installation related scripts. time a command is invoked. 6 The default directory which GlassFish domains are created in. Domain related CLI To enter the shell and invoke commands, execute the asadmin commands look for target domain inside this directory script without any trailing command or parameter. The 7 Domain start and stop scripts. following example shows the asadmin shell and how to execute 8 Default document root for serving http://IP:PORT/ Another set of files may be included here if required. a command inside it.

9 This is where shared libraries such as JDBC drivers, Apache Commons, etc. are placed. asadmin>help create-domain 10 Stores all logs, including server logs, access logs, and transaction logs. The invoking schema is the same for both methods but 11 Includes domain related configuration files like domain.xml, default-web.xml, key stores, etc. there are some usage differences. The CLI can execute most 12 Deployed applications, ready to be deployed applications and container generated commands against a remote server by providing the address files for deployed applications are stored in these directories. and port number of the administration listener. If not, it will 13 Update center scripts and PKG (5) are located inside these execute the command against the default local server which is directories. 127.0.0.1:4848. 14 Open MQ which is the default MQ implementation of GlassFish is located here. You can get a list of all commands along with a brief GLASSFISH ADMINISTRATION Hot explanation about them by invoking help command. Tip To save the output for later review use the following GlassFish provides multiple administration channels for command: ./asadmin help > path_to_file.txt administration flexibility. JMX/AMX Administration Channel Web Based Administration Console This channel is widely preferred by developers who need to To access the Web Console, point a browser to http://IP_ interact with GlassFish administration and management layer ADDRESS:PORT/. By default the port number is 4848 and the using the Java language. Administration tasks can also be listener listens on all available network interfaces of the server executed by writing Java code using JMX. The GlassFish JMX machine. The default administration credentials are admin with listener listens on port 8686 by default. The username and no password, although one can be provided during installation. password are the same as those for the CLI and Web Console. GlassFish uses a separate Virtual Server for Web Console for Any JMX console can be used, like the JDK’s JConsole or independent configuration. MC4J, to examine the GlassFish JMX MBeans and see what Command Line Administration Console functions are availble. This is the preferred approach for experienced administrators RESTful Administration Channel who choose to use CLI for administration purposes. Some tasks This interface exposes complete GlassFish management like creating/removing/backing up and restoring a domain are and monitoring functionalities through a RESTful interface, only possible using the CLI. The CLI also enables automation where output can be formatted using HTML, JSON or XML. of routine tasks through shell scripts, as well as integration with The root URL for RESTful administration is http://ADMIN_ provisioning tools. The administration CLI is accessible through ADDRESS:ADMIN_PORT/management/domain/, which can the asadmin utility located at gf_home/bin directory. It is accept requests from a browser, tools like curl or wget, or even either a batch file named asadmin.bat for Windows or a shell Java applications using JAX-RS client libraries. Use the POST script named asadmin for Linux and UNIX. method to update the configuration, and use the GET method The asadmin script has two modes. The first, invoking schema, to view the configuration. For example to view the monitoring is more suitable for creating custom scripts or for executing levels, send the following GET request from any web browser: only one command: http://localhost:4848/management/domain/configs/config/server-config/ ./asadmin [ program options] command_name *[[--param] values] monitoring-service/module-monitoring-levels

DZone, Inc. | www.dzone.com 3 Getting Started with GlassFish Application Server v3

To create a new HTTP listener we can POST the following and AMX-enabled tools such command to the server. as jconsole, or by developing simple custom applications curl -X POST -d “web-container=ON” -H “Accept: application/json” http://localhost:4848/management/domain/configs/config/server-config/ to take care of repetitive daily monitoring-service/module-monitoring-levels tasks or automatic response to some events. Figure 3 shows the GlassFish v3 MBeans tree in DAILY ADMINISTRATION TASKS JConsole.

Administration is performed on a day-to-day basis. Some tasks The AMX Beans form a dynamic may be easier using the CLI, others with the Web Console. tree which represents the Figure 3: JMX console showing GlassFish MBeans tree Common Administration Tasks in CLI entire application server and any manageable object inside it. The Table 3 shows the list of common CLI commands. Some are AMX is a dynamic proxy layer on top of JMX MBeans to ease exclusive to CLI, and others are easier to perform this way. interaction with the GlassFish management core. Local commands are marked using an asterisk *.

Table 3: Common CLI Commands SECURITY Command Description

list-commands List local and remote commands. Remote commands are listed if the It is wise to spend time securing the application server instead remote server is up and running. of gazing at the disaster a security leak caused. create-domain* Create a new domain. Passwords Security start-domain* Start the given domain. The administration and master passwords should be changed frequently. Change them using provided CLI commands. stop-domain* Stop the given domain. Table 4 lists the required tasks for overall password security deploy Deploy an application. along with a description and command used to complete that undeploy Undeploy an application. security task.

backup-domain* Create a backup of domain configurations. It does not include deployed Table 4: Security tasks and related commands applications. Task Description and Command restore-domain* Restore the given backup. Change administrator Change the administrator password from time to time using change- password admin-password command. list-domains* List all domains in the default or the given domains directory. Change master Change the default master password from “changeit” to something verify-domain-xml* Command to verify the the domain.xml file. Useful when edited manually. password which else using change-master-password command. protects the key More CLI commands are covered in the Security section store files of this Refcard. There are tens of other commands for Alias of the passwords Passwords required for connection pools are stored in plain text; to used for connection avoid this, use password aliasing. For example: administrating Java EE managed resources and application pools, JMS hosts and create-password-alias Alias_Name so on and use the alias name in the following format instead of the server functionalities. The complete list of commands can be password: viewed by invoking the help command. An example of how ${ALIAS=sample-alias} A complete set of commands for creating, updating, listing and to execute the create-domain command to create a domain deleting aliases is provided. named domain2 is as follows: Do not enter The CLI is typically used to administer multiple servers; to prevent passwords entering clear-text the passwords on the command line, use a create-domain --adminuser admin --adminport 4848 --instanceport 8080 password file containing --domainproperties domain.jmxPort=8686:http.ssl.port=8181 domain2 AS_ADMIN_PASSWORD=${ALIAS=Alias_name} AS_ADMIN_MASTERPASSWORD=${ALIAS=Al_name} Administration Tasks in Web Console and pass it to commands invoked using --passwordfile parameter. And yes, use password aliases here too. The Web Console is suitable for tasks Do not enter The login command is helpful in interactive mode. After successfully where there are several parameters passwords logging into a server, asadmin will store the password and re-use it and attributes involved, or where when a command is invoked on that server. The format is: asadmin login --host HOST_ADDRESS --port ADMIN_PORT the CLI is unavailable. It is very The command will enter the interactive mode and ask for passwords. easy to create JDBC connection Listeners Security (Network Security) pools, JMS destinations, configure Listeners are the interaction channels of the application server listeners and pools, some with the outside world. Both the administration listener and security related configuration, the ORB listener should be protected from un-authorized containers configuration, cluster-wide access. Sometimes securing listeners means binding them configuration and management, and to a specific network interface of the server machine, and so on. The Web Console has a very sometimes it means mutual authentication protection using organized structure to make it easy digital certificates. Table 5 lists the listeners, security measures to find and locate tasks. Figure 2 and how to access them through Web Console. shows a part of the tree based menu Figure 2: Administration console structure of Web administration Configuration node. Table 5: Listeners and Listeners Security Measures console. Listener How to access Security Measures HTTP Listeners Tree>Configuration>Network Listeners should listen on specific Administration Tasks and JMX Console Config> Network Listeners interfaces, not on 0.0.0.0 (all GlassFish v2 can be monitored and managed using JMX- available interfaces).

DZone, Inc. | www.dzone.com 4 Getting Started with GlassFish Application Server v3

HTTP Listeners Tree>Configuration>Network Check off the Security check of interest. To enable monitoring for a service navigate to Config> Protocols box if HTTPS is required for this Tree>Configuration>Monitoring and change the monitoring listener. level of the services and containers of interest. Three levels of ORB Listeners Tree>Configuration>ORB>IIOP Make sure to leave required Listeners listeners active. monitoring are available: Be sure to change the network address to the appropriate one. 1. OFF: No monitoring information is gathered. Use secure listeners if possible. 2. LOW: Cumulative statistics are gathered. 3. HIGH: Detailed statistics are gathered. JMX Listeners Tree>Configuration>Admin Enable security (SSL) if service required. Use only required network addresses. Change When enabled, monitoring affects the overall performance of authentication realm if required. the application server, specifically the observed services. It is better not to use HIGH in a production environment. New users with administration permission can be After changing the monitoring level, GlassFish starts gathering added to admin-realm. To do this, navigate to Tree> monitoring information which can be viewed in the Web Hot Console or other channels. To view the monitoring information, Tip Configuration>Security>Realms>admin-realm and then click on the Manage Users button. Add as many navigate to Tree>Application Server and select the Monitor users as needed. tab. This page shows all gathered statistics for any service with statistics collection enabled. Security Audition For example, the JDBC Connection Pools performance metrics, Auditing is useful for checking logged events and conducting with counts the maximum number of connections, maximum analysis to locate potential problems. Security auditing makes available connections, and more, and various timing factors like it possible to review events like failed logins. The default maximum wait time, and so on. auditing module provided with GlassFish logs all security events in the server.log file. To enable auditing hit Tree>Con CLI and Monitoring figuration>Security>Audit Modules>default and then enable For CLI advocates, the CLI provides thorough monitoring the module by changing the auditOn property’s value to true. capabilities. The CLI offers fine-grained control on which Implementing new auditing modules is as simple as extending performance factors to monitor. Table 6 lists all CLI commands the com.sun.appserv.security.AuditModule class, putting related to monitoring. the implementation in the domain classpath and adding it Table 6: CLI monitoring commands as a new audit module in Tree>Configuration>Security>Au Command Description dit Modules>. After adding the auditing module, it can be get Getting the value for any configuration attribute in the system. View the enabled by changing the appropriate attribute defined, if any. monitoring level of a service or multiple services using this command.

set Setting the value for any configuration attribute in the system. Set the HTTP Access Log monitoring level of a service or multiple services using this command. Storing HTTP access logs can help with reviewing HTTP access monitor Monitoring one or multiple attributes of GlassFish services like transaction, events. Access logs can be enabled in two ways: HTTP Service JMS, JDBC connection pools and so on. The command is very flexible about enables it for all HTTP listeners (Tree>Configuration>HTTP information representation. Service) and Virtual Server level enables HTTP Access Log for Configuration attributes can be accessed using a concept a particular Virtual Server (Tree>Configuration>Virtual Server). called Dotted Names. Dotted names, as the name may imply, is Access logs are stored in a directory named access inside the a hierarchy of attributes representing all servers, services, and logs directory of each domain. managed objects of the GlassFish Application Server in a tree A virtual server, sometimes called a virtual host, which starts with father nodes and comes down to attribute is an object that allows the same physical server leafs. Each level is separated from the adjacent level by a dot. to host multiple Internet domain names. Virtual The following dotted names can further clarify the concept. Hot Servers can use dedicated HTTP listeners and resources.jdbc-connection-pool.DerbyPool.allow-non-component-callers Tip servers.server.server.resource-ref.jdbc/__TimerPool.enabled configurations for authentication realms and default configs.config.server-config.ejb-container.max-pool-size web applications. You can create Virtual Server by navigating to Tree>Configuration>Virtual Server. Now, let’s use these three commands to do some monitoring. asadmin get server.monitoring-service.module-monitoring-levels.* MONITORING Checks the monitoring levels of all services using the wild-card character. Monitoring is an essential part of enterprise applications, asadmin set server.monitoring-service.module-monitoring-levels.jdbc- either in application server services layers or in enterprise connection-pool=HIGH applications themselves. GlassFish provides advanced and This last command set the JDBC connection pools monitoring extensible monitoring capabilities for both applications level to HIGH. deployed in GlassFish and for GlassFish services themselves. asadmin monitor --type jdbcpool --filter sample--pool --filename The monitoring information is accessible though different /opt/out2.csv --interval 5 server channels, including all three administration channels in This monitor command will gather sampling data each 5 addition to the newly included RESTful interface. seconds for a JDBC connection pool named sample-mysql- Web Console and Monitoring pool which is managed by a server instance named server. The To monitor a GlassFish services like JDBC connection pools, command will store the sampling data to a CSV file located at HTTP services and so on, enable monitoring for the services /opt/out2.csv.

DZone, Inc. | www.dzone.com 5 Getting Started with GlassFish Application Server v3

JMX and Monitoring glassfish_portfolio/resources.jsp). In addition, GlassFish JMX enables application server to be monitored directly Enterprise Server subscriptions include Enterprise Manager, from Java source code, and can respond to sampling data which offers tools to “auto-tune” the configuration based on a in an appropriate way. An example would be a swing-based simple set of questions about the deployment environment. monitoring console or integration of GlassFish monitoring Although the JVM uses sophisticated garbage collection into a bigger monitoring console to monitor the entire algorithms, performance and can be tuned by infrastructure from a single console. Another common example changing memory management and garbage collection is monitoring and changing application server configuration in parameters, depending on the deployment environment. a headless way. RESTful Monitoring Interface Tools like VisualVM give a good sense of what is going on the One of the unique features of GlassFish v3 is the RESTful application server. VisualVM is now included in JDK and is monitoring interface that allows virtually any programming accessible using the java_home/bin/visualvm. Installing visual language to access GlassFish monitoring information using a GC plug-in for Visual VM can help with memory tuning. More RESTful interface. information about Visual VM is available at http://visualvm.dev.java.net or JDK documentation. To The RESTful interface represents a hierarchy of GlassFish change the application server’s JVM option navigate to Tree> services, server environment, JVM, deployed applications and Configuration>JVM Settings and select the JVM Options tab. managed resources like JDBC connection pools. To access monitoring information using the RESTful interface, Web Container Performance Tuning send a GET request to http://ADMIN_ADDRESS:ADMIN_ Tuning the Web container will lead to the application server PORT/monitoring/domain/ which will return a list of all child processing Web requests in a more efficient way and will result objects for this node in higher throughput. Some determining factors for Web (monitoring must be container performance are: enabled). Going down • HTTP listener thread pool attributes. • File cache support in HTTP Protocol of each HTTP listener. the hierarchy to get • Disabling the access log. monitoring information • Disabling monitoring. along with a list of Thread pool attributes customization highly depends on the children for any node deployed applications’ characteristics in relation to whether in the hierarchy. For they are memory consumers, process consumers, IO bound example sending a and so on. get request to http:// localhost:4848/ Tuning the Web container is easier by analyzing the monitoring/domain/ statistics driven from monitoring the Web container and server/jvm/memory deployed applications. Web Container configuration is (with JVM monitoring available at Tree>Configuration>Web Container node. enabled) will result in Figure 4: JVM memory monitoring information Listener and protocols configuration are available at an output similar to Figure 4. Tree>Configuration>Network Config>Protocols. The RESTful interface can format the output to JSON or XML EJB Container Performance Tuning when the appropriate trailing parameters are included. For The EJB container can affect performance more than the JSON format include application/json in the URL and for XML Web container if deployed applications use EJBs extensively include application/xml in the URL trail. For example: for business logic processing. Fine-tuning the EJB container curl http://localhost:4848/monitoring/domain/server/jvm/ involves tuning the EJB container thread pool and its cache memory -H “application/xml” size. Although the timer service effects are usually not The RESTful monitoring interface enables developing intensive, for applications with a large number of timers it is monitoring solutions using scripting languages like Perl, recommended to reduce the timer service load by reducing the Python and so on. service precision. For GlassFish Enterprise Server v3 commercial customers, Sun Fine-tuning Message Driven Beans pool affects the overall Microsystems provides a monitoring scripting client, which performance of the system if it is highly dependent on JMS and enable ad-hoc querying using fine-grained probes, similar to message processing. DTrace on Solaris. Decreasing the pool size results in fewer MDBs processing the JMS messages and less overhead on the system. However it PERFORMANCE TUNING will also result in longer wait time for asynchronous tasks and requests. Enterprise application performance is a big concern, and performance tuning is a hurdle which all enterprise application Monitoring the EJB container using GlassFish built- developers are involved with. While Java EE performance in capabilities helps to tune the EJB container. Enable tuning is out of the scope of this refcard, some GlassFish monitoring, let the system work for some time, and then performance tuning information is provided. Additional tuning decide on new values for container attributes. EJB container information is a available through performance whitepapers configuration is accessible through Tree>Configuration>EJB available through Sun (http://www.sun.com/software/products/ Container.

DZone, Inc. | www.dzone.com 6 Getting Started with GlassFish Application Server v3

JDBC Connection Pool Performance Tuning option of installing and configuring the Update Tool for us. JDBC connection pools often cause bottlenecks in Web If we do select this option we can use the updatetool script applications which use JDBC to access a database. Monitoring located in the gf_home/bin to bootstrap it at any time after JDBC connection pools using GlassFish monitoring can the installation. To start the bootstrapping we just need to run give a fair amount of information about whether application ./updatetool or updatetool.bat; it will automatically detect performance is related to JDBC connection pool whether the update center is installed or not and will continue configuration. Usually, maximum wait time, average wait time, accordingly. high watermark and minimum available free connections are Using Update Tool parameters that help us decide whether to further limit the The PKG 5 IPS provides a command line script for using IPS size of the connection pool, or expand it (to prevent requests to install, update, upgrade and remove an application. The processing waits longer than necessary for a connection to script is named pkg and is located inside the gf_home/bin. In become free). addition to the CLI command, there is a very polished GUI Detecting connection leaks is another very helpful feature of named Update Tool which we can run using the updatetool GlassFish JDBC monitoring. Simply scan the monitoring results script available in the same directory. Running the update to determine if there aree JDBC connection leaks. tool will open a GUI similar to Figure 5. This shows what new JMS Server Interaction updates are available for our installed modules, or what new GlassFish supports three different methods for integration modules are available which we many need to install. We can with a JMS broker. A local or embedded broker means use the update tool and IPS to distribute our Web or Enterprise the JMS broker load is on the same machine running the application updates, to create our own update centers, to application server. If the JMS service integration type is set to distribute our GlassFish modules, and even to distribute our REMOTE, processing load is transferred from the application custom applications using IPS. server machine to another machine which only hosts the JMS broker or set of brokers. However, this change only affects JMS-bound applications that rely heavily on messaging. JMS Service configuration is available at Tree>Configuration>Java Message Service.

EMBEDDED GLASSFISH

Embedded GlassFish is available at https://embedded- glassfish.dev.java.net/. The embedded distribution hosts Figure 5: GlassFish Update Tool applications embedded into a larger, single JVM process. For example, use embedded distribution for unit testing. The following sample code shows how to create a server instance, Another good feature of the Update Tool is that it can manage start it, and deploy a Web application into the embedded multiple installation images of different applications and instance. different versions. We just need to register new images using File menu. Server server = new Server.Builder(“emServer”).build(); server.createPort(8080); Like many other applications, the GlassFish Update Tool server.addContainer(new org.glassfish.web.embed.impl. EmbeddedWebContainer()); will notify of available updates through a system tray icon. server.start(); File sampleWar = new File(“sample.war”); To register its system try icon we need to open a command server.getDeployer().deploy(sampleWar); window, navigate to gf_home/updatetool and then execute the

// Insert customer logic here following command.

server.stop(); ./updatetool --register

Using the embedded mode is as simple as the few lines above. It will simply sit in the system tray and let us know when an The embedded mode is useful for unit testing and cases when update for our installed modules is available. Imagine that we Web or enterprise applications run in-process instead of being can update the Hibernate or Spring or any other framework’s hosted in a stand-alone server. libraries automatically and through a notification system.

GLASSFISH UPDATE TOOL ARCHITECTURE

GlassFish v3 is a modular application server, and update GlassFish v3 benefits from a modular architecture based on and distribution mechanisms can benefit from the modular OSGi modularity system for platform and bundle management, architecture. GlassFish v3 uses IPS/PKG(5) for distribution and and HK2 for service layer modularity. The HK2, available at updating. The IPS/PKG(5) is an operating system-independent, http://hk2.dev.java.net, forms the GlassFish micro-kernel and is network-based distribution mechanism for applications, from roughly based on Java Platform Modularity specification. a simple phone book to systems as large as operating systems The whole modularity in the service layer is based on the like OpenSolaris. concept of contracts and contracts providers which are simply Bootstrapping the Update Tool Java interfaces and interface implementations along with some During the installation process installer provides us with the annotations.

DZone, Inc. | www.dzone.com 7 Getting Started with GlassFish Application Server v3

GlassFish can be extended by developing new providers for contracts, and the good news is that a registry of extension information is not required; instead, all of the extension discovery and life cycle management is completely automatic. Extensions are “installed” by simply placing them in the modules directory.

Table 7: GlassFish extensibility points

Extension point Sample use case

CLI Extensibility Add new CLI command; for example a command to start or stop a new type of container.

Web Add a whole new set of pages and nodes to administration console Administration to address new administration requirements like administrating a new Console container. Extensibility

Monitoring Export monitoring information to a specific format or from a specific Extensibility container.

Container Add new type of container to host; for example applications developed by Extensibility another dynamic language. Figure 6: GlassFish architecture from Mars

ABOUT THE AUTHOR RECOMMENDED BOOK Masoud Kalali holds a software engineering degree and has been The complete guide to in- working on software development projects since 1998. He has experience with a variety of technologies (.Net, J2EE, CORBA, stalling and configuring the and COM+) on diverse platforms (Solaris, Linux, and Windows). GlassFish Application Server His experience is in software architecture, design and server side and developing Java EE 5 development. Masoud has several articles in Java.net. He is one of applications to be deployed founder members of NetBeans Dream Team. Masoud’s main area of research and interest includes Web Services and Service Oriented to this server. Architecture along with large scale and high throughput systems’ development and deployment. BUY NOW Blog: http://weblogs.java.net/blog/kalali/ books.dzone.com/books/glassfish Contact: [email protected]

Brought to you by... Professional Cheat Sheets You Can Trust “Exactly what busy developers need: Patterns simple, short, and to the point.” Design By Jason McDonald Inspired James Ward, Adobe Systems by the #8 GoF ndler doesn’t have to Bestseller e a request with the handler CONTENTS INCLUDE: e potential outcome. Upcoming Titles Most Popular Chain of Responsibility, continued n Chain of Responsibility n Multiple objects may handle a request and the ha be a specific object. ements this pattern. When an n Command Use n A set of objects should be able to handl checks to see if the method n Interpreter When determined at runtime. RichFaces Spring Configuration on or if it should be passed up the n Iterator n A request not being handled is an acceptabl Downloadck the process repeats until code to Now n Mediator until there are no more parent Exception handling in some languages impl Agile Software Development jQuery Selectors n Observer exception is thrown in a method the runtime Example n Template Method and more... has a mechanism to handle the excepti Object Behavioral call stack. When passed up the call sta BIRT Windows Powershell handle the exception is encountered or

Visit refcardz.com refcardz.com Visit objects to hand the request to. ABOUT DESIGN PATTERNS Refcardz.com Invoker JSF 2.0 Dependency Injection with EJB 3

This Design Patterns refcard provides a quick reference to the Adobe AIR Netbeans IDE JavaEditor original 23 GangDesign of Patterns: Four. Each (GoF) patternElements design includes ofpatterns, Reusable class as diagrams,listedObject- in COMMAND the book Client Used to construct objects such ConcreteCommand BPM&BPMN Getting Started with Eclipse Oriented Software Command +execute( ) explanation, usage information, and a real world example. Creational Patterns: +execute() Flex 3 Components Very First Steps in Flex that they can be decoupledUsed from to formtheir largeimplementing object reated as an object. This allows system. nally object based relationships such Receiver Structural Patterns: Used to manage algorithms, Encapsulates a request allowing it to be t mes or in variant orders. structures between many disparate objects. DZone, Inc. ISBN-13: 978-1-934238-62-2 the request to be handled in traditio Purpose as queuing and callbacks. object handling the invocation. Behavioral Patterns: ISBN-10: 1-934238-62-7 n You need callback functionality. 1251 NW Maynard relationships, and responsibilities between objects. n Requests need to be handled at variantilitate ti theattern asynchronous the functionality processing to be Deals with object relationships that can Use n A history of requests is needed. When ue for processing without any need Prototype n The invoker should be decoupled from the actual implementationmplements its it particular is Object Scope: C Cary, NC 27513 50795 Deals with class relationships that can be Job queues are widely used to fac be changed at runtime. S Proxy of algorithms. By utilizing the commande pinterface the queue is expecting. Example Decorator Observer executed can be given to a job que Class Scope: S B for the queue to have knowledge of the 888.678.0399 changed at compile time. Facade Singleton invoking. The command object that is enqueued i S C algorithm within the confines of th Abstract Factory DZone communitiesC deliver Factory Method over 6State million pages each month to C B 919.678.0300 Adapter Flyweight Strategy S S B Bridge Interpreter Template Method more than 3.3 millionS softwareB developers,B architects and decision Refcardz Feedback Welcome Builder Iterator Visitor

C B B www.dzone.com Get More Refcarz! Refcarz! More Get www.dzone.com Chain of Mediator B B makers. DZone offersResponsibility something for everyone, including news, Memento [email protected] B Object Behavioral Command B

e $7.95 tutorials, cheatsheets,Composit blogs, feature articles, source code and more. S Sponsorship Opportunities 9 781934 238622 successor

“DZone is a developer’sCHAIN OF RESPONSIBILITY dream,” says PC Magazine. [email protected] <> Handler

Copyright © 2009 DZone, Inc. All rights reserved. No+handlerequest() part of this publication may be reproduced, stored in a retrieval system, or transmitted, in any form or by means electronic, mechanical, Version 1.0

Client photocopying, or otherwise, without prior written permission of the publisher. Reference: ConcreteHandler 2 +handlerequest()

e a request by linking ConcreteHandler 1 | www.dzone.com

+handlerequest()

DZone, Inc. Patterns

Gives more than one object an opportunity to handl receiving objects together.

Purpose Design Design