What this book covers Chapter 1, Getting Started, introduces the installation process of GateIn, using either a source code or the binary package.. Chapter 5, Securing Portal Contents,
Trang 3GateIn Cookbook
Copyright © 2012 Packt Publishing
All rights reserved No part of this book may be reproduced, stored in a retrieval system, or transmitted in any form or by any means, without the prior written permission of the publisher, except in the case of brief quotations embedded in critical articles or reviews
Every effort has been made in the preparation of this book to ensure the accuracy of the information presented However, the information contained in this book is sold without warranty, either express or implied Neither the authors, nor Packt Publishing, and its dealers and distributors will be held liable for any damages caused or alleged to be caused directly or indirectly by this book
Packt Publishing has endeavored to provide trademark information about all of the companies and products mentioned in this book by the appropriate use of capitals However, Packt Publishing cannot guarantee the accuracy of this information
First published: November 2012
Trang 4Proofreader Martin Diver
Indexer Monica Ajmera
Production Coordinator Arvindkumar Gupta Cover Work
Arvindkumar Gupta
Trang 5About the Authors
Ken Finnigan is a Senior Software Engineer at Red Hat and Technical Lead of the JBoss Portlet Bridge project and a member of the GateIn Development team As a Consultant and Engineer he has over 15 years of development experience with enterprises throughout the world using technologies that include Java EE frameworks (JSF, CDI, EJB3, Hibernate, Seam), Java testing frameworks (Arquillian, JUnit, TestNG), Maven, Ant, Arquillian, and a variety of others In his spare time he is a Committer for Apache DeltaSpike, JBoss Seam 3, ShrinkWrap, and Arquillian
I would like to thank my wife, Erin, and my family for all their support and
understanding through the entire book development process
Luca Stancapiano is a Consultant Expert in Java EE technologies since 2000 He started contributing to the JBoss Community at an early stage in his career He contributed initially to Hibernate, JBoss AS, JBoss Portal, and JBoss Cache, and more recently to projects such as Seam, GateIn, ExoJCR, ModeShape, and Infinispan
In 2005 he became a JBoss Advanced Consultant, and in 2006 he became the Project Leader
I would like to thank the GateIn community team for their participation
and Packt's team for the opportunity to write this book, and Monica for
moral support
Trang 6Piergiorgio Lucidi is an open source ECM Specialist at Sourcesense Sourcesense is a European open source systems integrator providing consultancy, support, and services around key open source technologies.
He works as Software Engineer, and he has 8 years of experience in the areas of Enterprise Content Management (ECM), system integrations, web, and mobile applications He is an expert in integrating ECM solutions in web and portal applications
He contributes as PMC member, Project Leader, and Committer at the Apache Software Foundation for the project Apache ManifoldCF; he also contributes on ECM connectors such
as CMIS, Alfresco, and ElasticSearch He is a Project Leader and Committer of the JBoss Community, and he contributes to some of the projects of the JBoss Portal platform
He is a Speaker at conferences dedicated to ECM, Java, Spring Framework, and open source products and technologies
He is an Author, Technical Reviewer, and Affiliate Partner at Packt Publishing, for whom he
wrote the technical book Alfresco 3 Web Services As Technical Reviewer, he contributed to both Alfresco 3 Cookbook and Alfresco Share As Affiliate Partner, he writes and publishes
book reviews on his website Open4Dev (http://www.open4dev.com/)
I would like to thank Packt Publishing for giving me this second opportunity
to write a book about a very interesting open source project I would also like
to thank my company Sourcesense for giving me some time to spend on this
project Finally, I would like to thank my girlfriend Barbara, who encouraged
me during the making of this book
Trang 7About the Reviewers
Antoine Herzog started with computers in 1981, with the ZX81, writing machine code for the CPU, and has never stopped programming since then He started programming in Java in
2003 and he started building portals with JBoss Portal in 2005 (version 2.2), and followed on with GateIn He contributes to the project, with debugging, jira, wiki, and forum posts He is very pleased to contribute and help the community to develop and use this nice technology and its associated tools
Since 2006, he works at Sysemo Sarl (www.sysemo.com), his own company, as an Expert in J2EE, JBoss AS, GateIn, JSF, RichFaces, EJB, and Hibernate
He has helped many companies to build their portals, both at management level and the programming level
He also founded www.presta-expert.com He programs and runs this portal website, on a JBoss AS7 platform, with GateIn 3.4.0
Antoine graduated from France's Ecole Nationale Superieure de Techniques Avancées in
1991 (ENSTA, Concours des Mines), where he enjoyed pursuing knowledge of sciences and engineering alongside his self-taught skills
Gurkan Erdogdu is CTO and Co-Founder of MechSoft He has been involved with Java and Java EE technologies since 1999 Gurkan is also very active in the open source world and
is a member of several open source foundations Gurkan is a member of Apache Software Foundation and is a founder of the project Apache OpenWebBeans Gurkan also gives training and special consultancies on Java and Java EE technologies Gurkan holds a BS in Computer Engineering from Middle East Technical University (METU) Gurkan lives in Ankara with his wife and little daughter He can be reached at gurkanerdogdu@yahoo.com
I owe thanks to my parents who provided encouragement, friendship,
wisdom, and patience in my life Without them, it would not have been
Trang 8Rafael Liu has been working with Java for 7 years as a Developer, Architect, and
Consultant Focusing mainly on JEE and middleware solutions from mainstream vendors,
he has worked in many mission-critical systems for the Government of Brazil, defining
infrastructure architecture and doing pre-production support such as load tests, performance analysis, bottleneck diagnosis, and tuning of both applications and JVMs He is currently Technical Account Manager at Red Hat, where he deals with Application Servers, SOA-related middleware solutions, portal, development frameworks, and basically most of the JBoss stack Rafael is an open source enthusiast and a GNU/Linux fan Speaking and writing about Java is one of his passions
Trang 9Support files, eBooks, discount offers and moreYou might want to visit www.PacktPub.com for support files and downloads related to your book
Did you know that Packt offers eBook versions of every book published, with PDF and ePub files available? You can upgrade to the eBook version at www.PacktPub.com and as a print book customer, you are entitled to a discount on the eBook copy Get in touch with us at service@packtpub.com for more details
At www.PacktPub.com, you can also read a collection of free technical articles, sign up for a range of free newsletters and receive exclusive discounts and offers on Packt books and eBooks
http://PacktLib.PacktPub.com
Do you need instant solutions to your IT questions? PacktLib is Packt's online digital book library Here, you can access, read and search across Packt's entire library of books
Why Subscribe?
f Fully searchable across every book published by Packt
f Copy and paste, print and bookmark content
f On demand and accessible via web browser
Free Access for Packt account holders
If you have an account with Packt at www.PacktPub.com, you can use this to access
Trang 10Table of Contents
Preface 1 Chapter 1: Getting Started 7
Introduction 7
Chapter 2: Managing Portal Contents Using the GUI 29
Introduction 29
Chapter 3: Managing Portal Contents Using XML 59
Introduction 59
Chapter 4: Managing Portal Users 89
Introduction 89
Trang 11Table of Contents
Chapter 5: Securing Portal Contents 129
Introduction 129
Chapter 7: Developing Using Components API 193
Chapter 8: Migrating from Existing Portals 227
Introduction 227
Trang 12Chapter 10: Frameworks in a Portal 285
Introduction 285
Chapter 11: Managing Portal Resources with the
Chapter 12: Managing Documents Using External ECM Systems 333
Trang 14Enterprises have websites constructed in different web frameworks and the need for them
to work together cohesively GateIn will provide the solution to effectively integrate them into
a single website GateIn is an open source website framework that does more than a web framework by letting you use your preferred one
This GateIn Cookbook provides solutions whether you're planning to develop a new GateIn portal, migrate a portal, or only need to answer a specific query It is filled with bite-sized recipes for quick and easy problem resolution From the beginning to the end it will guide you through the process of configuring and securing a portal, managing content and resources, and developing applications as you go
Beginning with installation and configuration, the book swiftly moves on to discussing content, users, and security The second half covers all aspects of developing on a portal, such as portlets, gadgets, migration, and integration
The goal of the book is to show GateIn as an open source website framework piece by piece Starting with simple recipes, you will see each step analyzed with code examples and images, before progressing to more advanced recipes
This GateIn Cookbook will help you with a quick approach to building portals
What this book covers
Chapter 1, Getting Started, introduces the installation process of GateIn, using either a source
code or the binary package You will also learn how to configure storage and the email sender Followed by how to set up the development environment for your customization
Chapter 2, Managing Portal Contents Using the GUI, explains how to manage portal contents
using the provided GUI You will learn how to manipulate the core contents of the portal, starting with portal instances and continuing on to pages and portlets You will then see how
to configure the navigation tree of the portal and how to use dashboards
Trang 15Chapter 3, Managing Portal Contents Using XML, explores the same portal contents discussed
in the previous chapter but shows how to manage everything through XML configuration It will then guide you through implementing a separate portal instance with its own EAR
Chapter 4, Managing Portal Users, introduces how to manage users and and how to
setup an external LDAP store for managing authorities It will show you how to extend and customize the default provider of the user profile and how to configure a Single Sign On (SSO) mechanism with some SSO providers
Chapter 5, Securing Portal Contents, discusses how to configure portal security with Tomcat
and JBoss, and explores all the JAAS modules available in GateIn You will also learn how to set different roles and permissions for any portal contents
Chapter 6, Developing Portlets, contains all the information you need to start implementing
standard portlets It will also cover the usage of the user locale, public render parameters and events
Chapter 7, Developing Using Components API, introduces WebUI for creating new views
and handling different skins in a portlet You will also learn how to manage JavaScript
and user locales
Chapter 8, Migrating from Existing Portals, explains some methods for migrating existing
portlets You will see how to migrate transactional, authenticated, and JCR-based portlets You will then learn how to import a skin from an existing website
Chapter 9, Managing Gadgets, demonstrates how to import, remove, and create gadgets, and
how to categorize them in the portal You will see how to expose a gadget as a portlet and how
to set user preferences
Chapter 10, Frameworks in a Portal, includes an overview of the framework that you can
use to implement portlets You will learn how to implement a portlet using JSF 2, jQuery, and RichFaces 4
Chapter 11, Managing Portal Resources with the Management Component, covers how to
manage portal contents using the REST API and Command Line Interfaces (CLI)
Chapter 12, Managing Documents Using External ECM Systems, explores how to implement
portlets for integrating some ECM systems such as any CMIS-compliant repository, JBoss ModeShape, Apache JackRabbit, and Alfresco You will also see how to implement portlets using Spring WebScripts in Alfresco
What you need for this book
In Chapter 1, Getting Started, you will see all the required components for building and
executing GateIn In summary, you should have:
Trang 163
f Java Development Kit (JDK) 1.6
f Eclipse IDE
f Apache Subversion (latest version)
f Apache Maven (latest version)
f GateIn Portal 3.2.0 and beyond
Who this book is for
This book is for anyone who needs to administer or develop applications on GateIn Java and RESTful architecture skills are suggested but not needed
Conventions
In this book, you will find a number of styles of text that distinguish between different kinds of information Here are some examples of these styles, and an explanation of their meaning.Code words in text are shown as follows: "We can include other contexts through the use of the include directive."
A block of code is set as follows:
<object type=
"org.exoplatform.services.organization.impl.NewUserConfig$JoinGroup"> <field name="groupId">
Trang 17New terms and important words are shown in bold Words that you see on the screen, in menus or dialog boxes for example, appear in the text like this: "clicking the Next button moves you to the next screen"
Warnings or important notes appear in a box like this
Tips and tricks appear like this
Reader feedback
Feedback from our readers is always welcome Let us know what you think about this book—what you liked or may have disliked Reader feedback is important for us to develop titles that you really get the most out of
To send us general feedback, simply send an e-mail to feedback@packtpub.com, and mention the book title through the subject of your message
If there is a topic that you have expertise in and you are interested in either writing or
contributing to a book, see our author guide on www.packtpub.com/authors
Customer support
Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase
Downloading the example code
You can download the example code files for all Packt books you have purchased from your account at http://www.packtpub.com If you purchased this book elsewhere, you can visit http://www.packtpub.com/support and register to have the files e-mailed directly
to you
Trang 18Piracy of copyright material on the Internet is an ongoing problem across all media At Packt,
we take the protection of our copyright and licenses very seriously If you come across any illegal copies of our works, in any form, on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy
Please contact us at copyright@packtpub.com with a link to the suspected pirated material
We appreciate your help in protecting our authors, and our ability to bring you valuable content
Questions
You can contact us at questions@packtpub.com if you are having a problem with any aspect of the book, and we will do our best to address it
Trang 20Getting Started
In this chapter we will cover:
f Installing GateIn from binary package
f Building and installing GateIn from the source code
f Configuring the content storage
f Configuring GateIn to send e-mails
f Running GateIn on your machine
f Setting up the development environment
At the end of the chapter, you will understand what the architecture of GateIn is and how to configure and run a portal instance on your machine
GateIn is a portal framework dedicated to implementing highly customizable portal
solutions with a powerful set of components based on well-known and adopted open source technologies and standards based on the Java web technologies
Trang 21Getting Started
Installing GateIn from a binary package
GateIn is released through different bundles that differ for the included application server These bundles are dedicated to the following application servers—JBoss AS 5.x, JBoss AS 6.x, JBoss AS 7.x, Tomcat 6.x, Tomcat 7.x, and Jetty 6.x
In this recipe, we will see which are the required packages you need to download before starting a GateIn instance
Getting ready
A pre-requisite for running GateIn is the availability of the Java Development Kit (JDK), which must be updated to the latest revision of version 1.6 Depending on your operating system, please be sure to correctly add the JDK binaries' path to the classpath of your machine In order to verify the Java version actually installed on your machine, you can run the following command line:
java –version
It will return an output similar to the following:
java version "1.6.0_29"
Java(TM) SE Runtime Environment (build 1.6.0_29-b11-402-10M3527)
Java HotSpot(TM) 64-Bit Server VM (build 20.4-b02-402, mixed mode)
If you don't find in the output the string Server VM, but you find the string Client VM in the place of Server VM, this means that the JDK is not installed on your machine In this case, you can download the JDK 1.6 for your operating system at http://www.oracle.com/technetwork/java/javase/downloads/jdk-6u31-download-1501634.html
How to do it
1 As introduced before, GateIn can be installed using different packages, so now you can download your preferred bundle depending on which application server you need
to use for your installation
2 Typically, the right application server can be chosen by thinking about what you need for your software architecture Let's assume that you need to deploy GateIn together with other standard Java EE applications that need explicit support for middleware components such as DataSource, Enterprise Java Bean (EJB), Java Message Service (JMS), or an Enterprise Service Bus (ESB) You would then probably want to use the JBoss AS bundle JBoss AS is completely focused on middleware support having the availability of a total J2EE-compliant application server Otherwise, if you only need to
Trang 22The difference between the various bundles is related to application server-specific
configuration files and directories, with some added artifacts For example, the JBoss 6.x directory structure consists of the following folders:
The Tomcat bundle also has a further execution script compared to the JBoss bundle, but
we will see how to run a GateIn instance for all the different application servers later in the chapter, in another recipe
Trang 23Getting Started
See also
f The Building and installing GateIn from the source code recipe
f The Running GateIn on your machine recipe
Building and installing GateIn from the
source code
Another way to install GateIn is by getting the source code from the JBoss SVN repository and then compiling it to generate the build artifacts as you found in the binary package
The goal of building GateIn from the source code is to have the possibility to freely customize
it Another useful reason for building from source is that you simply want to contribute to the project and test your fixes before applying the patch on the issue tracker
Notice that this book is based on GateIn 3.2.0, which has its source code
based on the SVN repository From GateIn 3.3.x the source code is based on
a GitHub repository For more information about how to build from GitHub, please see https://github.com/gatein/gatein-portal
Getting ready
Let's first see if you have installed in your machine the following needed components:
f Java Development Kit (JDK) 1.6
f Subversion client (SVN)
f Apache Maven 3.x
Let's check your environment for the see following required tools:
1 You can test and install JDK 1.6 following the Getting ready section of the Installing
GateIn from a binary package recipe.
2 To test if the SVN client is installed in your machine run the following command line:
Trang 24Chapter 1
11
If the svn command is not found in the scope of your operating system, then you can install it by following the instructions available on the official website, depending on your operating system, at http://subversion.apache.org/packages.html
3 Once the SVN client is installed, the next step is to test if Apache Maven is installed
on your machine, by running the following command line:
Default locale: it_IT, platform encoding: MacRoman
OS name: "mac os x", version: "10.6.8", arch: "x86_64", family:
"mac"
If the mvn command is not found in your machine then it could mean either of the following two things:
You have to configure the PATH environment variable
You have to install Apache Maven from scratch
We are going to assume that maven is not installed In this way, we will describe both the cases:
Download the Apache Maven binary at http://maven.apache.org/download.html
Extract the binary package and follow the specific instructions that are described in the web page according to your operating system
Notice that you have to set two environment variables to allow Maven to work
correctly, so please be sure to set the PATH and M2 variables before continuing For instance, for a Linux-based operating system, you should have a snippet in your profile configuration file similar to the following:
export M2_HOME="/Users/piergiorgiolucidi/tools/apache-maven-3.0.4" export M2=$M2_HOME/bin
Trang 252 Once you have finished the download, you will find a new subfolder
gatein-portal-3.2.0 in the folder where you have executed the command that contains all the source code of the project
3 Now we are ready to build the project using Apache Maven For this step, we have some parameters to set:
Which type of bundle you have
Whether the build process must download the application server distribution
The path of the root folder of your application server distributions (if you have
an existing distribution package)
The name of the folder related to the application server distribution to use for building
4 Let's assume that you want to build GateIn with the Tomcat 6 bundle and, considering that the Tomcat distribution is stored in the /Applications/Apache Tomcat/apache-tomcat-6.0.32 folder, you have to execute the following command line from the root folder of the project that contains the main pom.xml file:
mvn clean install -DskipTests -Ppkg-tomcat -Dexo.projects.
directory.dependencies=/Applications/Apache Tomcat -Dexo.projects app.tomcat.version=apache-tomcat-6.0.32
Upon completion, you should see the following output:
Trang 26be removed for each submodule of the project
The install phase will start the complete Maven lifecycle executing all the phases up to install The details of this execution process are as follows:
So if you want to contribute to the project or you are customizing the product for your needs, you will probably want to remove this parameter This is because if you want to be sure that your own implementation correctly works with all the other modules included in GateIn, you probably want to execute all the tests included in the project
See also
f The Installing GateIn from a binary package recipe
f The Running GateIn on your machine recipe
f The Setting up the development environment recipe
Configuring the content storage
By default, GateIn is configured to use the Hypersonic SQL database and a relative folder in the bundle to manage the content storage This type of setting is only useful for running a product demo without specifying any parameter, but this is not the suggested way to set up the platform for a production environment
Trang 27Getting Started
For production system environments, you should configure GateIn for using external DBMS and using a file system with good I/O performance to prevent bottlenecks during reading and writing operations on contents and search indexes
We are going to configure the components that manage content storage in GateIn:
f exoJCR: This is an open-source implementation of the Java Content Repository (JCR) specification provided by the eXo Community It is used internally by GateIn to manage all the content data related to portals, pages, portlets, and metadata
f PicketLink IDM: This is an open-source project that can be embedded in any standard Java EE application and allows managing user identities by storing the information in a database It also supports many ways to negotiate credentials and Single Sign On (SSO) mechanisms
Let's first configure exoJCR, which is the component responsible for the content storage in the portal This component consists of two physical storage elements:
Carry out the following steps to configure the content storage:
1 Locate the following properties inside the configuration file:
gatein.jcr.datasource.driver
Trang 28 gatein.jcr.datasource.username=sa
gatein.jcr.datasource.password=
The above parameters will configure your HSQL database in a folder in your file system As you can see, the parameter named gatein.db.data.dir, used for the value of the parameter gatein.jcr.datasource.url, allows you to set a specific folder that will contain all the content storage dedicated to the GateIn instance.These parameters allow you to set the typical settings for a JDBC connection, so for example, if you need to configure Oracle DBMS for the JCR database, you should have
a similar configuration to the following:
gatein.jcr.datasource.driver=oracle.jdbc.OracleDriver
gatein.jcr.datasource.url=jdbc:oracle:thin:@<HOST>:<PORT
>:gateInJcr
gatein.jcr.datasource.username=<ORACLE USERNAME>
gatein.jcr.datasource.password=<ORACLE USER PASSWORD>
2 You or your DBA must create the database schema and the user above in your DBMS instance before running GateIn The user credentials used by GateIn must have all the necessary permissions to manage tables and rows in the database instance Notice that the default encoding for the database needed by GateIn is latin1, so be sure to set this parameter in your DBMS configuration
3 Remember to copy the database JDBC driver (packaged as a JAR) to the library folder of your application server In this way, GateIn can correctly use the existing database instance
For Tomcat, you can copy the JDBC driver in this folder:
Trang 29Getting Started
4 Now that we have configured the database for the JCR component, we can continue configuring the JCR file system location This section allows you to set a specific file system dedicated to store all the binaries and search indexes files managed by GateIn The default properties' values relating to the file system configuration are as follows:
of GateIn Here, you can change the default configuration for contents and search indexes as needed for your architecture
5 Configure another database schema dedicated to the identity manager
6 The built-in properties' values for the database JDBC connection of the identity management are the following:
gatein.idm.datasource.driver=org.hsqldb.jdbcDriver
gatein.idm.datasource.url=jdbc:hsqldb:file:${gatein.db.data.dir}/data/jdbcidm_${name}
When the application server runs for the first time, GateIn will automatically create all the needed data structures in the database and inside the file system
Trang 30The value for the JDBC URL must follow your specific DBMS conventions to locate the database instance remotely via JDBC.
The username and password are related to a specific users credentials that GateIn must use to access and manipulate contents in the database
There's more
You also have the possibility to configure contents and indexes to increase performance during searching or creating contents This is done by changing locations to machines with better hardware for both of the components
A typical approach is to dedicate the local file system storage to the Apache Lucene indexes (gatein.jcr.index.data.dir) and a high-performance storage location for contents, setting a different value for the gatein.jcr.storage.data.dir property
Apache Lucene is an open-source text-search engine library used in many Enterprise products to create and manage content indexes It supports execution of queries based on the Lucene Query Language, which is a very powerful query language that can search contents by ranking, phrase, and exact match Lucene is licensed under Apache Software License Version 2.0
For more information about Lucene, you can visit the project website at http://lucene.apache.org/
MySQL example configuration
In order to configure MySQL for the database storage of GateIn, you should edit the
configuration file in a similar way for JCR, following the related conventions:
gatein.jcr.datasource.driver=com.mysql.jdbc.Driver
gatein.jcr.datasource.url=jdbc:mysql://<HOST>:<PORT>/gateInJcr
Trang 31Getting Started
gatein.jcr.datasource.username=<MYSQL USERNAME>
gatein.jcr.datasource.password=<MYSQL USER PASSWORD>
For the identity manager you should have the following:
gatein.idm.datasource.driver=com.mysql.jdbc.Driver
gatein.idm.datasource.url=jdbc:mysql://<HOST>:<PORT>/gateInIdmgatein.idm.datasource.username=<MYSQL USERNAME>
gatein.idm.datasource.password=<MYSQL USER PASSWORD>
Finally, remember to copy the MySQL JDBC driver library into the application server library folder in order to make the driver class available to GateIn
See also
f The Configuring GateIn to send e-mails recipe
f The Running GateIn on your machine recipe
Configuring GateIn to send e-mails
GateIn includes notification features that send e-mails to users when a specific action is performed on the portal, for instance the forgot password feature There is another snippet to change in the configuration file to enable GateIn to send e-mails
These are the usual properties required to configure an SMTP server in your local network
Getting ready
Locate the configuration file as described in the previous recipe
How to do it
Carry out the following steps in order to configure GateIn to send e-mails:
1 Locate in the e-mail section of the configuration file the following snippet:
gatein.email.smtp.username=
gatein.email.smtp.password=
gatein.email.smtp.host=smtp.gmail.com
Trang 32f Socket factory port
f Socket factory class
Username and password are the values that identify the e-mail account that you want to use in GateIn
Host and port are used to set your SMTP server endpoint address
EnableTls and Auth are used to set the needed authentication mechanism to process any operation
Socket factory parameters are specifically used for instancing secure connections on your SMTP server In this case, be sure to have correctly installed any security library needed to process the SSL specific request
See also
f The Configuring the content storage recipe
f The Running GateIn on your machine recipe
Trang 33Getting Started
Running GateIn on your machine
Let's assume that you have correctly configured GateIn as shown in the previous recipes or are using the default settings found in the standard binary package Now we are going to run GateIn for the first time
Getting ready
Locate the bin folder of your application server; this is the location where the start/stop script
is stored in your machine Here are the details for the scripts in different application servers:
f If you are using Tomcat then you have a specific script gatein.sh, for Windows gatein.bat, provided in the binary folder <TOMCAT_HOME>/bin
f For JBoss AS 6 you can use the standard run.sh script available in this folder
<JBOSS6_HOME>/bin
f JBoss AS 7 requires using the script standalone.sh stored here
<JBOSS7_HOME/bin>
How to do it
Supposing that we are using Linux as the operating system, we would follow these steps:
1 To start GateIn using Tomcat use the following command line from the current bin folder:
Trang 34For each specific application server you must follow the correct procedure to use the
dedicated script file to start and stop the portal instance
There's more…
We will take a look at how to start GateIn with different versions of JBoss application servers
Starting GateIn with JBoss AS 6 instance
If you are using GateIn with JBoss AS 6, you have to use the following command line:
nohup /run.sh &
Trang 35Starting GateIn with JBoss AS 7 instance
Otherwise, if you are using JBoss AS 7 use the following command line:
nohup /standalone.sh &
The log file can be viewed in this way:
tail –f nohup.out
To stop the JBoss 7 instance run the following command:
./jboss-cli.sh –connect command=:shutdown
See also
f The Configuring the content storage recipe
f The Configuring GateIn to send e-mails recipe
Setting up the development environment
GateIn is developed using the Apache Maven lifecycle process and this guarantees that the project can be used with any standard development environment
In this recipe, we will learn how to import the GateIn project in Eclipse IDE (you can use any other IDE that supports Maven) You will also see how to install JBoss tools in Eclipse to add support for developing standard portlets and all Java EE components provided by JBoss
Trang 36Chapter 1
23
How to do it
Set up your development environment following these steps:
1 Launch Eclipse and create a new workspace dedicated to GateIn
2 Click on Help | Eclipse Marketplace
3 Search jboss tools and click on the Go button
4 Locate the JBoss Tools version required for your specific Eclipse version and click on the Install button
Trang 37Getting Started
5 In the Confirm Selected Features window, select all the items and click on the Next button
Trang 38Chapter 1
25
6 In the Install Details window, click on the Next button
7 In the Review Licenses window, read and accept the terms of the license
agreements and click on the Finish button
8 Wait for the installation process of JBoss tools to complete Once the installation is finished, restart Eclipse
Trang 39Getting Started
9 After the restart, you should see the overview of what you can do with JBoss tools with a similar tab in your Eclipse environment:
10 Right-click on the Package Explorer tab and select Import
11 Browse the Maven category and select Existing Maven Projects and press the Next button
Trang 40Chapter 1
27
12 Insert as Root Directory the GateIn source root folder that you have created in the previous recipe
13 Click on the Next button and then click on Finish
14 Be sure at the end of the import process to update the project configuration of all the Maven modules—in the Package Explorer window select all the modules, right-click, then select Maven | Update Project Configuration and finally click on OK