Top Banner
JBoss AS Because Seam was written by those at JBoss, naturally JBoss is the application server that Seam works best with. Seam, however, is not limited to working only with JBoss. You can use Seam on any application server that supports EJB3. (You can actually use it with pre-EJB3-supported servers, as I discuss in Chapter 9). This appendix focuses on JBoss 4.0. What Is JBoss? When people reference JBoss, they are usually referring to JBoss Application Server. However, there are multiple products from the JBoss group, Seam being one of them. JBoss as a company was started by Marc Fleury but was bought by Red Hat in early 2006. This is a good move for all of us in that it should help keep JBoss open source for at least the time being. And that free word is what makes it such a great application server for developers to learn on. You can download it locally without any restrictions on licensing. Downloading JBoss Before using JBoss, you obviously need to download and install it. You can download the latest JBoss production Application Server instance (4.0.x) from http://labs.jboss.com/ portal/jbossas/download. From this page, follow these steps: 1. Click the Downloads button. This takes you to the labs.jboss.com download page. 2. Choose the latest JBoss link labeled Run Installer for the latest production instance. The installer is necessary because without it you will not have EJB3 sup- port on your application server. 307 APPENDIX A
44

JBoss AS - Springer978-1-4302-0385-8/1.pdf · JBoss AS B ecause Seam was written by those at JBoss, naturally JBoss is the application server that Seam works best with. Seam, however,

Feb 01, 2020

Download

Documents

dariahiddleston
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: JBoss AS - Springer978-1-4302-0385-8/1.pdf · JBoss AS B ecause Seam was written by those at JBoss, naturally JBoss is the application server that Seam works best with. Seam, however,

JBoss AS

Because Seam was written by those at JBoss, naturally JBoss is the application serverthat Seam works best with. Seam, however, is not limited to working only with JBoss.You can use Seam on any application server that supports EJB3. (You can actually use itwith pre-EJB3-supported servers, as I discuss in Chapter 9). This appendix focuses onJBoss 4.0.

What Is JBoss?When people reference JBoss, they are usually referring to JBoss Application Server.However, there are multiple products from the JBoss group, Seam being one of them.JBoss as a company was started by Marc Fleury but was bought by Red Hat in early2006. This is a good move for all of us in that it should help keep JBoss open source forat least the time being. And that free word is what makes it such a great applicationserver for developers to learn on. You can download it locally without any restrictionson licensing.

Downloading JBossBefore using JBoss, you obviously need to download and install it. You can download thelatest JBoss production Application Server instance (4.0.x) from http://labs.jboss.com/portal/jbossas/download.

From this page, follow these steps:

1. Click the Downloads button. This takes you to the labs.jboss.com download page.

2. Choose the latest JBoss link labeled Run Installer for the latest productioninstance. The installer is necessary because without it you will not have EJB3 sup-port on your application server.

307

A P P E N D I X A

Page 2: JBoss AS - Springer978-1-4302-0385-8/1.pdf · JBoss AS B ecause Seam was written by those at JBoss, naturally JBoss is the application server that Seam works best with. Seam, however,

■Note At the time of this writing, the regular JBoss 4.0 was not compatible with Seam; the problem was with the EJB3 version bundled with it. A newer version had to be downloaded and installed afterward.However, to make life easier, there is a bundled download called the JEMS Installer that can be down-loaded. The rest of the instructions on the installation are the same with either download.

Installing JBossNow that you have the installer downloaded, create the directory structure you want toinstall it to, and for the sake of ease just copy the downloaded file to that location. On thecommand line, type in the following:

java –jar <name_of_installer_jar>

Now, follow these steps:

1. The first screen asks you to select which language you want, as shown in Figure A-1.Select English (the default). Then click OK.

Figure A-1. Language selection screen

2. Click the OK button for this screen as well. Note that it may take some time for theinstallation to progress. Do not worry—it will be working.

3. The next page welcomes you to the install. Click Next.

4. Read the release notes and then click Next again.

5. The next page is the terms and conditions page, shown in Figure A-2. Click theradio button labeled I Accept The Terms of This License Agreement and thenclick Next.

APPENDIX A ■ JBOSS AS308

Page 3: JBoss AS - Springer978-1-4302-0385-8/1.pdf · JBoss AS B ecause Seam was written by those at JBoss, naturally JBoss is the application server that Seam works best with. Seam, however,

Figure A-2. The license agreement screen

6. Now select the path you want to install JBoss to and click Next.

7. The screen in Figure A-3 is one of the most important screens to pay attention tofor our installation. On this screen you can choose whether to install EJB3. If youdo not install EJB3, you will have ClassNotFound exceptions for the EJBs. Select theejb3 option and click Next.

Figure A-3. The selection screen for choosing the type of installation

APPENDIX A ■ JBOSS AS 309

Page 4: JBoss AS - Springer978-1-4302-0385-8/1.pdf · JBoss AS B ecause Seam was written by those at JBoss, naturally JBoss is the application server that Seam works best with. Seam, however,

8. Now you are asked what packages you want to install. By default, all packages areselected. I suggest just keeping all of them installed. Then click Next.

9. The next screen asks you to choose a name. You can choose any name you want.However, if you choose anything but default, you will have to specify that namewhen you start up the server.

10. Next is the DataSource Configuration screen. Just keep HSQLDB selected andclick Next.

11. The following screen deals with deployment isolation. Just keep the EnableDeployment Isolation/Call By Value check box unselected and click Next.

12. For the JMX security, you can type in a customized username and password if youlike. The password is required, so type something in and write it down for futurereference.

13. The final screen enables you to review everything you have chosen to install.Click Next to begin the actual installation. After the installation is complete, the screen progression window will indicate Finished, as in Figure A-4.

Figure A-4. This screen notifies you that the installation is complete.

14. Click Next again, and you will receive confirmation of installation and of the loca-tion of the uninstaller, as shown in Figure A-5.

APPENDIX A ■ JBOSS AS310

Page 5: JBoss AS - Springer978-1-4302-0385-8/1.pdf · JBoss AS B ecause Seam was written by those at JBoss, naturally JBoss is the application server that Seam works best with. Seam, however,

Figure A-5. The final screen showing the location of the uninstaller

Your JBoss Application Server should now be installed and ready to run. Make sure toremember where you installed it. In this book, I will refer to that path as <JBoss_Path>.

Using JBossNow that JBoss is installed, I will explain how to use it—including how to start it andwhere to locate some files that you may find useful. This section, however, is notintended to provide comprehensive coverage of JBoss. There is often more than one wayto do something, and I will be covering what I feel is the easiest and simplest method.

■Note If you want to learn more about JBoss, check out http://www.jboss.org.

Running JBoss

Running JBoss is straightforward, and the program is ready to go after the installation.The location of the run files is <JBoss_Path>/bin. Note that the installer did not installbased on whether the operating system was Microsoft Windows or Unix, so the run filesexist for both in the bin directory:

APPENDIX A ■ JBOSS AS 311

Page 6: JBoss AS - Springer978-1-4302-0385-8/1.pdf · JBoss AS B ecause Seam was written by those at JBoss, naturally JBoss is the application server that Seam works best with. Seam, however,

• run.bat is the executable if you are running a Windows-based system.

• run.sh is the executable if you are running a Unix-based system (including Apple).

■Note If you decided during the setup to select anything other than default, you will have to run the start-up with the command switch -c <name>, where <name> is the name you chose.

Deploying JBoss

Deploying is also an easy process. All you have to do is copy your WAR, EAR, RAR, or SARto the <JBoss_Path>/server/<name>/deploy/ directory. I will refer to this directory as thedeployment directory in the future.

Adding a Data Source

A data source gives you the ability to define a database connection outside the confines of the application. Not only does this define a source for the database, but italso runs in a pooled data source. Pooled data sources provide a better way to run adatabase, because they allow connections to be read and they maximize the numberof connections going to the database. You can then access this data source via the Java Naming and Directory Interface (JNDI). Using the JNDI allows us to not have to hard-code anything in our code that relates directly to the database except the JNDIlookup name.

Creating the datasource.xml File

To set up the data source, create a data source XML file. The name of the file is unimportant; just make sure that the suffix is .xml. You will then place the file into the deployment directory, an example of this file is in Listing A-1.

APPENDIX A ■ JBOSS AS312

Page 7: JBoss AS - Springer978-1-4302-0385-8/1.pdf · JBoss AS B ecause Seam was written by those at JBoss, naturally JBoss is the application server that Seam works best with. Seam, however,

Listing A-1. An Example of a Data Source

<?xml version="1.0" encoding="UTF-8"?>

<datasources>

<local-tx-datasource>

<jndi-name>GarageSaleDS</jndi-name>

<connection-url>jdbc:mysql://localhost/garageSaleDb</connection-url>

<driver-class>com.mysql.jdbc.Driver</driver-class>

<user-name>root</user-name>

<password>password</password>

<min-pool-size>5</min-pool-size>

<max-pool-size>20</max-pool-size>

<idle-timeout-minutes>0</idle-timeout-minutes>

<track-statements/>

</local-tx-datasource>

</datasources>

Table A-1 explains the parameters defined in Listing A-1.

Table A-1. Definitions of the JNDI Parameters

Parameter Name Definition

jndi-name The name you are going to be using to reference the data source inyour application configurations.

connection-url The database-specific URL to the server. In this case, we are calling aserver on the same box, with a database schema called garageSaleDb.

driver-class The driver you are using for your database. In this case, we are using aMySQL driver.

user-name The username that is defined to access this data source. In general, do not use the root username.

password The password for the corresponding username.

min-pool-size The starting pool size for the number of database connections to beallowed.

max-pool-size The maximum number of database connections allowed by this pool.

idle-timeout-minutes The amount of time before the connection times out.

track-statements A Boolean (true/false) that has the data source monitor for unclosedStatements or ResultSets.

APPENDIX A ■ JBOSS AS 313

Page 8: JBoss AS - Springer978-1-4302-0385-8/1.pdf · JBoss AS B ecause Seam was written by those at JBoss, naturally JBoss is the application server that Seam works best with. Seam, however,

Adding the Library JAR File

So now that you have your data source connection defined, you need to add the necessary JAR file for it. In the preceding case we were using MySQL, so we had to add a MySQL JAR file. Copy the JAR file to <JBoss_Path>/server/<name>/lib/. In reality, youcould use any database (including Hypersonic SQL Database, or HSQLDB), but for the examples in the book I have used MySQL. MySQL can be downloaded fromhttp://www.mysql.org/downloads/mysql/5.0.html#downloads. It is a fairly straightforwardinstallation. If you want further information, you can consult Pro MySQL by MichaelKruckenberg and Jay Pipes (Apress, 2005). After setting this up, restart JBoss and checkthe console for any visible errors. Your JBoss database should be configured.

Locating and Configuring Log Files

So by now you should have JBoss configured to use EJB3 and should have a data sourceadded. You are ready to start running the system. However, first I want to give you someunderstanding of the log file and some of the configuration file locations.

The log files are located at <JBoss_Path>/server/<name>/log/server.log. The loggeris set to rolling appending—so as the server is running, you will notice more files with a numerical appending. The logger in JBoss uses Log4J as its logger of choice.Consequently, these generated log files have a log4j.xml file associated with them. The log4j.xml file is located at <JBoss_Path>/server/<name>/conf/log4j.xml.

■Note If you need help understanding Log4J, consult the Log4J website at http://logging.apache.org/log4j/docs/.

There are multiple configuration files in the <JBoss_Path>/server/<name>/conf and<JBoss_Path>/server/<name>/default directories.

At this point, you should have JBoss Application Server installed and ready to use.

APPENDIX A ■ JBOSS AS314

Page 9: JBoss AS - Springer978-1-4302-0385-8/1.pdf · JBoss AS B ecause Seam was written by those at JBoss, naturally JBoss is the application server that Seam works best with. Seam, however,

JBoss IDE

One of the keys to any development is an environment to develop in. Integrateddevelopment environments (IDEs) have been around for Java for a while now, and aremuch improved since the early days. There are a wide variety of IDEs to choose from:IntelliJ, NetBeans, and Eclipse.

Eclipse has become one of the standard IDEs for Java development. There are twomain reasons for this. First, it’s free. Second, it is easy to develop plug-ins for Eclipse andthere is a large community of developers creating plug-ins for it. These plug-ins can beused to access Subversion version control, create Hibernate files, access databases,and more.

JBoss has created its own set of plug-ins for Eclipse. These plug-ins allow us to useHibernate reverse engineering, jBPM creation, and other items. In fact, JBoss has anEclipse + JBoss IDE download for Microsoft Windows.

This appendix covers how to download and install this IDE.To download the JBoss IDE, go to http://labs.jboss.com/portal/jbosside/download/

index.html. Then select the Beta-2-Bundle, as shown in Figure B-1.After the download is complete, you will have a zip file to install. To extract the zip,

right-click on the zip and select Extract All, as shown in Figure B-2.That is all you will need. After the zip file is extracted into the Eclipse folder, you can

double-click eclipse.exe to run Eclipse.

■Note When extracting a zip file, often people will open the zip in Microsoft Windows Explorer and justdrag and drop the contents. However, if you do that for this zip, the extraction will fail. So use the extractor.

I would suggest either using this installation or installing the plug-ins separately.Doing so makes various aspects of development easier in this book. We will use thisinstallation for our development in Chapter 10.

315

A P P E N D I X B

Page 10: JBoss AS - Springer978-1-4302-0385-8/1.pdf · JBoss AS B ecause Seam was written by those at JBoss, naturally JBoss is the application server that Seam works best with. Seam, however,

Figure B-1. The website for downloading the JBoss IDE

Figure B-2. Extracting the JBoss IDE

APPENDIX B ■ JBOSS IDE316

Page 11: JBoss AS - Springer978-1-4302-0385-8/1.pdf · JBoss AS B ecause Seam was written by those at JBoss, naturally JBoss is the application server that Seam works best with. Seam, however,

Final Thoughts

My goal with this book was far reaching from the get-go, and I hope it has set you onthe right track in creating your Seam application. From the beginning, I realized that thetarget audience would range from the relatively new to the relatively experienced, so myhope was to create ever-increasing complex pages. Because JSF and EJB3 are relativelynew to developers, and almost no developers have used them in a production environ-ment, I definitely wanted to cover those two topics separately. If you still need moreinformation, there are many books available to choose from.

When I first started using Seam, I have to admit I was a bit skeptical. I am a bigTapestry and Spring fan. I find the melding of the two very useful. However, the factremains that standards are standards for a reason, and many major companies will stickto using JSF and EJB3 for that reason. Whether those two are the best tools for the job isdebatable. Personally, I believe EJB3 has come a long way and I am happy with it.Although JSF is a bit more debatable, compared to frameworks we have had to usebefore, its strides are major. The question then comes to Seam. In my opinion Seam, is a great tool in the right hands, and could be disastrous in the wrong hands.

Let’s start off by asking when you should use Seam. I would say most definitely if youever are going to use EJB3 + JSF, Seam is a no-brainer. The next question then becomes, to what extent do you use Seam? Just the fact that I can manage my HttpSession objectswith annotations and not have to worry about putting managed beans inside the faces-config.xml is a bonus in itself. After that, it is really up to the user and the needs of the project. Seam is labeled as an agile web application development application, and some try to compare it to Ruby. And if you look at all the initial effort in writing aSeam application, you may laugh at that—and quite frankly so do I to an extent. Ruby provides a flexible and fast way to put web applications on the Web. And if you need a simple CRUD application with some minor tweaks to the presentation tier, thensomething like Trails would be more along your scope. What Seam provides for is agileenterprise-level development. This is something that is sorely lacking. While developingthese examples and writing this book, it was easy to identify many jobs I have been atwhere this would have saved me time in plumbing code.

317

Page 12: JBoss AS - Springer978-1-4302-0385-8/1.pdf · JBoss AS B ecause Seam was written by those at JBoss, naturally JBoss is the application server that Seam works best with. Seam, however,

My favorite TV series, Joss Whedon’s Buffy the Vampire Slayer, always started outwith, “In every generation a slayer is born.” For us nerds I would say, “In every generationa framework is born.” Clearly Struts was that framework for the start of this century, andSpring moved in for the next few years. What is going to be the framework of choice in2007 and beyond? No one knows yet, but JSF and EJB3 with the backing of Sun and appli-cation vendors will definitely be hanging around. I believe Seam and its core idea to glueframeworks together seamlessly will be a concept that is going to be around and beabundantly useful for years to come.

FINAL THOUGHTS318

Page 13: JBoss AS - Springer978-1-4302-0385-8/1.pdf · JBoss AS B ecause Seam was written by those at JBoss, naturally JBoss is the application server that Seam works best with. Seam, however,

SYMBOLS# character, expression language, 74

Aa: tag prefix, Ajax4jsf, 254ACID properties, transactions, 114Action class, Struts, 27

displaying dynamic data, 28HttpServletRequest attribute, 27HttpServletResponse attribute, 27listing and viewing pages, 37logging in, 34purpose of, 185requesting and saving data, 32

action component, jBPM page flow, 219action events, JSF, 65ActionForm object, Struts, 27ActionMapping object, Struts, 27activation, SFSB life cycle, 97, 99actor assignment

creating tasks, jBPM processdefinitions, 210–211

actor component, workflows, 194actors, jBPM, 189, 210add operation, entity manager, 111Add page

Garage Sale application, 79–81validation on JSF pages, 156

admin roletesting for user having admin role, 263

Ajax (Asynchronous JavaScript and XML),240–257

Ajax4jsf in Seam, 250–255defining Ajax4jsf filter, 251downloading and configuring

Ajax4jsf, 251dynamic validations, 252tags creating dynamic validations,

254JMS messaging using Ajax, 255–257

configuring JMS listeners, 255–256using JMS listeners, 257

Seam remoting using Ajax, 240–250Ajax remoting call, 242–245Ajax remoting call with parameters,

245–247batch remote calls, 247conversation ID, 248debugging, 249excluding objects on method call, 250getComponentName command, 247hiding/changing the loading

message, 248Java data types for Seam remoting,

248remote configuring of Seam, 241

aliases, JPQL, 113annotations

annotations on POJOs, 20collections, 107–110creating SLSBs, 95data model, 147ejb-jar.xml (EJB descriptors) and, 89entity bean annotations, 104–106Hibernate annotations, 154interceptors and, 135Java 5, 12, 14JSRs for Java 5 release, 12life cycle annotations, SLSBs, 96–97page-level annotations, 263reasons for using Seam, 6Seam architecture, 132starting/ending tasks, 207TestNG component, 288transforming complex objects into

POJOs, 14XML configurations in EJB3, 88

annotations, list of@AssertFalse, Hibernate, 154@AssertTrue, Hibernate, 154@Begin, 170@BeginTask, 211@Column, 106@Configuration, 292

Index

319

Page 14: JBoss AS - Springer978-1-4302-0385-8/1.pdf · JBoss AS B ecause Seam was written by those at JBoss, naturally JBoss is the application server that Seam works best with. Seam, however,

@Conversational, 169@Create, 7@CreateProcess, 203@DataModel, 149@DataModelSelection, 149@EJB, 120@Email, Hibernate, 154@EmailChecks, 157@End, 171@EndTask, 209@Entity, 102@Factory, 149@Future, Hibernate, 154@GeneratedValue, 105@Id, 105@IfInvalid, 151, 155@In, 128, 133, 134@Interceptors, 127@JndiName, 127@JoinColumn, 108@Length, Hibernate, 154@Lob, 106@Local, 95@Logger, 144@ManyToMany, 108@ManyToOne, 107@Max, Hibernate, 154@MessageDriven, 101@Min, Hibernate, 154@Name, 7, 127@NotNull, Hibernate, 154@OneToMany, 108@OneToOne, 108@Out, 128, 133@Past, Hibernate, 154@Pattern, Hibernate, 154@Permission, 263@Permissions, 263@PersitenceContext, 110@PostConstruct, 96@PreDestroy, 96@Range, Hibernate, 154@Remote, 95@Remove, 100@RequestParameter, 161@Resource, 119@Restrict, 263@ResumeProcess, 204@Role, 181

@Roles, 181@Scope, 136, 148@Size, Hibernate, 154@StartTask, 209@Stateful, 100@Stateless, 8, 28@SuppressWarnings, 113@Table, 104@Test, 292@TransactionAttribute, 117@TransactionManagement, 118@Transient, 106@UniqueConstraint, 105@Valid, Hibernate, 151, 154@WebRemote, 245

Ant (Apache Ant)configuration, packaging EAR file, 91creating WAR files for Faces, 57–58

API specificationJSF background, 48

Application context, 164description, 138Seam contexts, 136Servlet context compared, 164stateful session beans, 164

application data, Drools rule engine, 264application descriptors see

application.xml fileapplication servers

deploying web resources to, 57JBoss AS, 307–314

application.xml fileconfiguring EJB3s for deployment,

89–90configuring jBPM with Seam, 197modified with jBPM JAR file, 197packaging into EAR file, 91–92web configuration for, 147

applicationsGarage Sale application, 41invokeApplication method, 294ticketing system application, 44–45Travel Reservations application, 42–44

Apply Request Values phase, JSF, 70applyRequestValues method, 294architecture

see also Seam architectureJSF, 59–68MVC, 9–11

■INDEX320

Page 15: JBoss AS - Springer978-1-4302-0385-8/1.pdf · JBoss AS B ecause Seam was written by those at JBoss, naturally JBoss is the application server that Seam works best with. Seam, however,

three-tier architecture, 2–4Java EE architecture, 3, 4

arguments, varargs, 18@AssertFalse annotation, Hibernate, 154assertObjects tag

using Drools in jBPM, 266@AssertTrue annotation, Hibernate, 154asynchronous processing

Ajax, 240–257Ajax4jsf in Seam, 250–255JMS messaging using Ajax, 255–257message-driven beans and Seam, 101,

184Seam remoting using Ajax, 240–250

atomicity, transactions, 115authentication

AuthenticationProvider class, 259–260authenticatorAction component, 260component-level, 263creating login/logout, 260–262implementing, 258–262logging in, 34page-level, 263ProviderAuthenticator component, 260SeamSecurityManager component, 262,

263version 1.1.0 of Seam, 258

AuthenticationException exception, 260AuthenticationProvider class, 259Authenticator component, 262authenticatorAction component, 260AUTO generated value

@GeneratedValue, 106autoboxing, Java 5, 17

JSRs for Java 5 release, 12

Bbacking beans

see also managed beanscore areas of JSF, 63data model events, JSF, 65description, 50eliminating the need for, 162entity beans (EBs), 184event listener methods, 63faces-config.xml file, 50GarageSaleAction backing bean, 79Hello World example, 50JSF pages calling business logic, 121

reasons for using JSF, 5Seam replacement for, 63Update Model Values phase, JSF, 71uses of, JSF, 185

batch processingSeam remoting using Ajax, 247

BEA WebLogicJSF implementations, 49

bean-managed transactions see BMTsbeforeRedirect property, @EndTask, 209@Begin annotation

beginning long-running conversations,170

join/nested parameters, type property,175

multiple @Begin methods forconversation, 171

starting page flow, 220begin parameter, type property

conversationPropagation tag, Seam, 174@BeginTask annotation

resuming tasks, 211bijection

annotation for Seam to perform, 127contexts injectable into POJOs, 183entity beans (EBs), 184interceptors and, 134message-driven beans (MDBs), 184Seam architecture, 132–134where to use, 133with stateless session beans, 134

Blob data type, @Lob, 106BMTs (bean-managed transactions),

117–119@Resource, 119@TransactionManagement, 118bean- or container-managed, 115commits, 119rollbacks, 118, 119setRollbackOnly method, 118UserTransaction interface, 118

Boolean data typeJava data types for seam remoting, 248

browser settingsselecting languages, 231

buildchecking Java version, 13

bundlesdefining multiple bundle names, 230

■INDEX 321

Finditfasterathttp://superindex.apress.com

/

Page 16: JBoss AS - Springer978-1-4302-0385-8/1.pdf · JBoss AS B ecause Seam was written by those at JBoss, naturally JBoss is the application server that Seam works best with. Seam, however,

language bundles, 223, 224–231message bundles, 228resource bundles, 223, 230

business logic tier see business tierbusiness process, 187business process code

jBPM Graphical Process Designer,303–305

Business Process context, 136, 138, 187business process tools

jBPM (JBoss Business ProcessManagement), 188–221

components for creating processdefinitions, 192–196

page flow creation in Seam, 220–221page flow definitions, 213–220process definition creation in Seam,

197–213process definitions, 189–196

purpose of, 187business tier

benefits of using Seam framework, 2calling validator from, 154–155description, 3MVC architecture, 9reasons for using Seam, 6Seam integration with EJB3, 140stateful session beans, 97–101stateless session beans, 93–97three-tier architecture, 2–4using transactions inside EJBs, 115why use SBs for business tier, 92

Button component, JSF, 73

Cc: tag prefix, 264

see also JSTL tag librariescalendar component, JSF, 51callback method

Ajax remoting call, 244using JMS listeners, 257

castingfind method signature, 112Java Persistence Query Language, 113

casting errors, generics, 15changeProcessDefinition method, 213Check box component, JSF, 73Check box list component, JSF, 73

classescontents of WAR files, 58creating test classes, 291

classes tagcreating WAR file for Faces via Ant, 58

click eventsaction events, JSF, 65

Clob data type, @Lob, 106CMTs (container-managed transactions),

116–117@TransactionAttribute, 117bean- or container-managed, 115commits, 116, 117EJB3 types of transactions, 116rollbacks, 116, 117setRollbackOnly method, 117

Codehaus’s Trails, 282collections

annotations, 107–110iterating through collections, 15

@Column annotationentity beans, 106

column tag, html, 72commandLink tag, JSF, 173, 174commits

bean-managed transactions, 119container-managed transactions, 116,

117compiled classes

contents of WAR files, 58Component label component, JSF, 73Component object

Seam integration with EJB3, 140component-level authentication, 263components

configuring faces-config.xml file, 56configuring web.xml file for Faces, 53getComponentName command, 247jBPM Business Process component,

189–213jBPM page flow component, 213–221Process Validations phase, JSF, 70

components, JSF, 71–74component layout, 72–73standard JSF components, 73–74

components, Seam, 141–157actors, 210Authenticator component, 262authenticatorAction component, 260

■INDEX322

Page 17: JBoss AS - Springer978-1-4302-0385-8/1.pdf · JBoss AS B ecause Seam was written by those at JBoss, naturally JBoss is the application server that Seam works best with. Seam, however,

component-level authentication, 263data model, 147–151

JSF presentation tier, 150–151POJO, 148–150

debug mode, 144–147logging, 143–144login component, 261optional component configurations,

282–284additions to faces-config.xml,

282–284additions to web.xml file, 284

page-level authentication, 263ProviderAuthenticator component, 260Seam configuration options, 141–143

JNDI name, 142Seam interceptor, 142

SeamSecurityManager component, 262SecurityConfiguration component, 262switching process definitions, 211using Drools in Seam components, 265using HTTP specific code in, 285using for internationalization, 234validation, 151–157

calling validator from business tier,154–155

schema generation, 157validation mechanism in Seam, 152validation on domain model, 153–154validation on JSF pages, 155–156

WorkingMemory Drools component,265

components.xml fileconfiguring Drools, 265configuring jBPM with Seam, 198configuring JMS listeners, 255configuring page flow with Seam, 220configuring ProviderAuthenticator, 260configuring SeamSecurityManager, 262configuring SecurityConfiguration, 262configuring XML in EJB3 container,

271–272creating themes, 234defining language bundles with Seam,

230jBPM process definition XML defined

in, 198managed persistence context, 283reference to resource bundle in, 230

running Seam inside Java EE container,279

turning on debugging, 249Concurrency Utilities

JSRs for Java 5 release, 12conditional statements

JSF expression language (EL), 75configuration

Ajax4jsf, 251creating Hibernate configuration file,

296–299Drools rule engine, 265configuring log files, JBoss AS, 314

@Configuration annotationusing TestNG component, 292

configuration, Seam, 123–126adding JAR files, 125adding properties file, 126configuration options, 141–143

JNDI name, 142Seam interceptor, 142

configuring server for Seam, 20embedded configuration files, 274finalizing setup, 126optional component configurations,

282–284additions to faces-config.xml,

282–284additions to web.xml file, 284

optional environmental configurations,269–282

running Seam in embedded EJB3container, 270–275

running Seam with Hibernate,275–282

remote configuring of Seam, 241running Seam with Hibernate

inside Java EE container, 278–280updating XML files, 124–125

connection scriptsentity beans and database persistence,

89connection-url parameter

creating datasource.xml file, 313consistency, transactions, 115container-managed transactions see CMTscontext demarcation, entity beans, 184

■INDEX 323

Finditfasterathttp://superindex.apress.com

/

Page 18: JBoss AS - Springer978-1-4302-0385-8/1.pdf · JBoss AS B ecause Seam was written by those at JBoss, naturally JBoss is the application server that Seam works best with. Seam, however,

context parametersadding to web.xml file for state saving,

124configuring web.xml file for Faces, 53,

54turning on Seam debugging, 146

contextssee also Seam contexts@Role annotation, 181@Roles annotation, 181accessing contexts, 182Business Process context, 187contexts injectable into POJOs, 183conversation ID, 248inaccessible contexts, 183message-driven beans and, 184POJOs, 181priority order for looking up contexts,

183servlet contexts, 24–25

HttpSession context, 24Servlet context, 24ServletRequest context, 24

where contexts live, 182which business object to use with, 184

Contexts class, 182Continue link

using Session context, 163controller, MVC architecture, 9controller classes, Tapestry, 10Conversation context, 166–180

additional configuration, 172benefits of, 167description, 137entity beans (EBs), 184how it works, 167–172JSF integration with conversations,

172–180links with long-running

conversations, 173–175performing workspace management,

175–179redirecting long-running

conversation, 179multiple sessions, 166Seam contexts, 136Seam debugging, 180stateful session beans (SFSBs), 185Travel Reservations application, 166

conversation IDSeam remoting using Ajax, 248

@Conversational annotationConversationInterceptor, 169creating long-running conversations,

169ConversationEntry objects

properties, 177conversationId parameter, JSF param tag

links with long-running conversations,173

ConversationInterceptor@Conversational annotation, 169middle of long-running conversations,

171conversationList component, Seam, 177conversationList.xhtml file, 176conversationPropagation tag, Seam

links with long-running conversations,174

type property, 174conversations

@Begin annotation, 170@End annotation, 171adding conversationId to URL of

requests made, 172description, 168end conversation component, jBPM

page flows, 220GET requests, 168JSF integration with conversations,

172–180links with long-running

conversations, 173–175performing workspace management,

175–179redirecting long-running

conversation, 179long-running conversations, 168,

169–172creating, 169normal propagation of conversation,

173–174other propagations of conversation,

174–175maintaining long-running

conversation, 172nested conversations, 168purpose of, 169

■INDEX324

Page 19: JBoss AS - Springer978-1-4302-0385-8/1.pdf · JBoss AS B ecause Seam was written by those at JBoss, naturally JBoss is the application server that Seam works best with. Seam, however,

Seam debugging, 180short-term conversations, 168starting page flow, 220starting/ending tasks, 209switching workspaces, 178temporary conversations, 168viewing lists of conversations, 175–178workspaces, 172

convertDateTime converter, 63convertDateTime tag, JSF, 63converters, JSF, 63cookieEnabled property, ThemeSelector

object, 235cookies

setting Seam to remember locale via,231

core objectsreference to resource bundle in

components.xml, 230core taglib references, 72

Ajax4jsf creating dynamic validations,254

commandLink tag, JSF, 173, 174convertDateTime tag, JSF, 63facet tag, JSF, 72, 73validateLongRange tag, JSF, 62, 71view tag, JSF, 72, 80, 82

country codeLocale object, java.util, 224setting up language bundles, 225

@Create annotationHello World example, 7

create parameter, @In, 134@CreateProcess annotation, 203createType method

Ajax remoting call with parameters, 246CRUD-based examples

Garage Sale application, 41CSS (cascading style sheets)

themes, 234currency

setting up language bundles, 225current property

ConversationEntry object, 178

Ddata

displaying dynamic data, 26, 28–30requesting and saving data, 26, 30–34

data model, Seam components, 147–151JSF presentation tier, 150–151POJO, 148–150

data model events, JSF, 65data source

adding JBoss data source, 312–314configuring jboss-beans.xml file, 272

data source descriptor see persistence.xmlfile

Data table component, JSF, 73data tier

entity beans (EBs), 102–110Hibernate, 102Java Data Objects (JDO), 102

data typesJava data types for Seam remoting, 248

database diagramticketing system application, 44Travel Reservations application, 42

databasesHibernate Console reverse engineering

database, 294persistence.xml (data source

descriptor), 88transaction processing, 115–119

@DataModel annotationretrieving/editing list using SFSB, 149

DataModel objectPage context, 166retrieving/editing list using SFSB, 148

@DataModelSelection annotationretrieving/editing list using SFSB, 149

DataModelSelection objectretrieving/editing list using SFSB, 148

DataSource Configuration screeninstalling JBoss AS, 310

datasource.xml filecreating JBoss data source, 312–313

dataTable tag, html, 72displaying list of addresses, 150List page, Garage Sale application, 82viewing lists of conversations, 177viewing tasks, 204

date components, JSF, 51Date data type

Java data types for Seam remoting, 248dates

converting into displayable items, 63determining style for dates, 63inputDate tag, Tomahawk, 81

■INDEX 325

Finditfasterathttp://superindex.apress.com

/

Page 20: JBoss AS - Springer978-1-4302-0385-8/1.pdf · JBoss AS B ecause Seam was written by those at JBoss, naturally JBoss is the application server that Seam works best with. Seam, however,

dateStyledetermining style for dates, 63

debug method, 144debug mode, Seam components, 144–147debugging

logging with Seam, 143, 144Seam debugging conversations, 180Seam remoting using Ajax, 249web.xml code turning on, 146

Decimal Arithmetic EnhancementJSRs for Java 5 release, 11

decision component, jBPM page flows,219

decision component, workflows, 195decisions

Drools rules built into jBPM decision,266

decorate tag, SeamAjax4jsf creating dynamic validations,

255default theme

creating themes, 235delegated implementation

renderer, JSF, 62Delete action

deleting item from list using SFSB, 149delete operation

operations on entity manager, 111dependency injection

see also bijectionIoC (inversion of control), 132

deployment directory, JBoss, 312deployment isolation

installing JBoss AS, 310description property

ConversationEntry object, 178design

jBPM Graphical Process Designer,303–305

developmentintegration testing, 292–294JBoss IDE, 315testing, 288–294

TestNG component, 288–292unit testing, 288

direct implementationrenderer, JSF, 62

directory structurefile structure of EAR, EJB3, and WAR

directories, 126

dirty reads, 115display page

Session context object, 163displayable select property

ConversationEntry object, 178displaying dynamic data

presentation implementation patterns,26, 28–30

Doc (document)types of web services, 238

domain modelvalidation on, 153–154

downloadsAjax4jsf, 251EJB3 (Enterprise JavaBeans 3), 271Java 5, 12–13JBoss AS, 307JBoss IDE, 315MyFaces, 51MySQL, 314Seam, 123Tomahawk JAR files, 52

driver-class parametercreating datasource.xml file, 313

Drools filessecurity-rules.drl file, 262

Drools rule engine, 264–267application data, 264configuring Drools, 265facts, 264if-then constructs, 264rule, 265rule base, 265Seam security model, 262using Drools in jBPM, 266using Drools in Seam components, 265working memory, 264, 265WorkingMemory component, 265

Drop-down list component, JSF, 73durability, transactions, 115DynaForm, Struts

requesting and saving data, 32dynamic data, displaying, 26, 28–30dynamic permissions

page-level annotations, security, 263dynamic validations

Ajax4jsf in Seam, 252

■INDEX326

Page 21: JBoss AS - Springer978-1-4302-0385-8/1.pdf · JBoss AS B ecause Seam was written by those at JBoss, naturally JBoss is the application server that Seam works best with. Seam, however,

EEAR (Enterprise ARchive) file

adding security rules file to deployedEAR, 262

application descriptors(application.xml), 90

description, 88, 89file structure of EAR directory, 126

ear tagpackaging EAR file, 92

EB domain objectsreasons for using Seam, 6

EBs see entity beansEclipse, 315Edit action

retrieving/editing list using SFSB, 148edit method

action events, 65EJB 2 (Enterprise JavaBeans 2)

history of EJB3, 86Java Naming and Directory Interface, 88

@EJB annotationcalling EJBs, 120

EJB descriptors see ejb-jar.xml fileEJB model

history of EJB3, 86ejb-jar.xml file

adding jboss-seam.jar file, 125configuring EJB3s for deployment, 89creating JAR package for EJB, 91with SeamInterceptor object, 142

EJB2 (Enterprise JavaBeans 2)concerns addressed in EJB3, 1

EJB3 (Enterprise JavaBeans 3), 85–120calling EJBs, 119–120configuring EJB3s for deployment,

88–92application descriptors

(application.xml), 89–90creating JAR package for EJB, 91creating XML files, 88–90data source descriptor

(persistence.xml), 88–89EJB descriptors (ejb-jar.xml), 89packaging, 90–92packaging EAR file, 91–92

downloading, 271entity beans (EBs), 102–110

basics of, 102–104

collections annotations, 107–110entity bean annotations, 104–106

EntityManager object, 110–114Java Persistence Query Language,

113–114operations on entity manager,

111–113persistence context, 110–111

file structure of EJB3 directory, 126history of, 86–88installing JBoss AS, 309Java Persistence Query Language,

113–114message-driven beans, 101–102reasons for JBoss Seam, 2reasons for using, 5reasons for using Seam, 5Seam environment requirements, 6Seam integration with EJB3, 140session beans, 92–101

stateful session beans, 97–101stateless session beans, 93–97

testing EJBs, 120transactions, 114–119

bean-managed transactions, 117–119container-managed transactions,

116–117transaction processing, 115–119types of transactions, 116, 117

using TestNG component, 288validation, 151

EJB3 containerconfiguring XML in, 271–273

components.xml file, 271–272jboss-beans.xml file, 272–273

packaging WAR files, 273–275embedded configuration files, 274library directory, 273

running Seam in embedded EJB3container, 270–275

packaging new container, 271–275using JBoss EJB3, 271

why use SBs for business tier, 92EJB3 JAR

creating JAR package for EJB, 91packaging into EAR file, 91–92packaging WAR files, 273

■INDEX 327

Finditfasterathttp://superindex.apress.com

/

Page 22: JBoss AS - Springer978-1-4302-0385-8/1.pdf · JBoss AS B ecause Seam was written by those at JBoss, naturally JBoss is the application server that Seam works best with. Seam, however,

EJBscalling, 119–120creating JAR package for EJB, 91using term EJB generically, 86using transactions inside EJBs, 115

EL see JSF expression language@Email annotation, Hibernate, 154@EmailChecks annotation

schema generation, 157embedded configuration files

packaging WAR files, 274embedded server

running Seam in embedded EJB3container, 270

@End annotationending long-running conversations, 171multiple @End methods for

conversation, 171end conversation component, jBPM page

flows, 220end parameter, type property

conversationPropagation tag, Seam, 174end state component, workflows

components for creating processdefinitions, 196

creating workflows, jBPM, 192@EndTask annotation, 209enhanced for loop, Java 5, 16Enterprise ARchive file see EAR fileEnterprise JavaBeans 3 see EJB3@Entity annotation

entity beans, 102using JavaBeans and Hibernate, 276

entity beans (EBs), 102–110adding fields to entity beans, 111annotations, 104–106backing beans, 184basics of entity beans, 102–104collections annotations, 107–110Conversation context and, 168database persistence, 88default binding, 184entity bean annotations, 104–106entity bean with NotNull validations,

153Hibernate and, 102history of EJB3, 87negative connotations with EJB2, 1persistence, 184

POJOs, 184referencing other EBs, 107–110removing fields from entity beans, 111stateless session bean example, 128updating fields on entity beans, 112uses of, 184using JavaBeans and Hibernate, 276where to use bijection, 133

Entity Manager see EntityManager objectEntityManager object, 110–114

@PersitenceContext annotation, 110changing persistence context, 150description, 102factories creating, 110injecting entity managers into SBs, 110Java Persistence Query Language,

113–114managed persistence context, 283method-level modifications on SLSBs,

128operations on entity manager, 111–113

add, 111delete, 111update, 112

persistence context, 110–111using JavaBeans and Hibernate, 277using TestNG component, 291

enumerated types, Java 5, 17enumerations

JSRs for Java 5 release, 12Enums data type

Java data types for Seam remoting, 248enums, Java 5, 17environments, JBoss IDE, 315environments, Seam

environment requirements, 6optional environmental configurations,

269–282running Seam in embedded EJB3

container, 270–275running Seam with Hibernate, 275–282

Event context, 165description, 137JavaBeans, 185Seam contexts, 135

event listener methodsbacking beans, 63

■INDEX328

Page 23: JBoss AS - Springer978-1-4302-0385-8/1.pdf · JBoss AS B ecause Seam was written by those at JBoss, naturally JBoss is the application server that Seam works best with. Seam, however,

event parameterAjax4jsf creating dynamic validations,

255events, JSF, 64–66

action events, 65data model events, 65major difference between Seam and JSF,

64phase events, 66value-change events, 65

examplessample applications, 40–45

expression language see JSF expressionlanguage

externalizing datainternationalization, 223

Ff: tag prefix, 72

see also core taglib references<f:view> component

Hello World example, 8facelets

conversationList.xhtml file, 176using themes, 236XML support for, 240

Faces see JSF (JavaServer Faces)faces-config.xml file

action events, 65adding setting of state-saving method,

125additions to, 282–284after adding Seam phase listener, 124configuring XML files for Faces, 54–56description, 50Hello World example, 50JSF pages calling business logic, 121navigation rules, 76running Seam inside Java EE container,

279selecting languages using locale

definitions from, 233setting expression language resolver,

284facet tag, JSF, 72, 73@Factory annotation

retrieving/editing list using SFSB, 149facts, Drools rule engine, 264

fileset tagcreating WAR file for Faces via Ant, 58

filtersconfiguring web.xml file for Faces, 53defining Ajax4jsf filter, 251filter addition for web.xml file, 284

find methodmethod signature, 112

flights.xhtml pageviewing lists of conversations, 176

flushMode parameter, @StartTask, 209for loop, Java 5, 16–17for loops, Java 5

JSRs for Java 5 release, 12foreign keys

@ManyToMany annotation, 108@ManyToOne annotation, 107@OneToMany annotation, 108@OneToOne annotation, 108

fork component, workflows, 195form tag, html

Add page, Garage Sale application, 80Formatted output component, JSF, 73frameworks

see also Seam frameworkJSF (JavaServer Faces), 11MVC architecture, 10–11servlets and frameworks, 25Spring MVC, 10Struts, 10Tapestry, 10web services, 238

from-action tag, navigation rules, 78from-view-id tag, navigation rules, 76, 78front controller

configuring web.xml file for Faces, 54full value

determining style for dates, 64@Future annotation, Hibernate, 154

GGarage Sale application, 41

Add page, 79–81validation on JSF pages, 156

JSF (JavaServer Faces), 78–83creation of pages and backing beans,

79List page, 81–83Seam debugging, 146using TestNG component, 288

■INDEX 329

Finditfasterathttp://superindex.apress.com

/

Page 24: JBoss AS - Springer978-1-4302-0385-8/1.pdf · JBoss AS B ecause Seam was written by those at JBoss, naturally JBoss is the application server that Seam works best with. Seam, however,

garageSale bean, 79GarageSaleAction backing bean, 79garbage collection

@PreDestroy annotation, 96@GeneratedValue annotation

entity beans (EBs), 105Generic Types

JSRs for Java 5 release, 11generics, Java 5, 15–16

find method signature, 112GET requests

conversations, 168MVC architecture, 9

getComponentName commandSeam remoting using Ajax, 247

getOutputText methodHello World example, 7

getProcessDefinitions methodswitching process definitions, 213

getServletContext methodServlet object, 24

getSession methodcreating HttpSession objects, 24

getters@Transient annotation, 106

getViewId method, 294global navigation rules, 76GNU licence agreement screen

installing JBoss AS, 309graphical process design

jBPM Graphical Process Designer,303–305

greetingsreferencing components inside

properties file, 228setting up language bundles, 225

Grid panel component, JSF, 73Group panel component, JSF, 73

Hh: tag prefix, 72

see also html taglib referenceshasPermision function, 263hasRole function, 263Hello World example

backing bean for, 50faces-config.xml file, 50JBoss Seam, 7–8JSF (JavaServer Faces), 49–51JSF Page with Hello World output, 50

Hibernate@Valid annotation, 151creating configuration file, 296–299entity beans and, 102entity beans and database persistence,

89generating Hibernate code, 299Hibernate Console with Seam, 294–302history of EJB3, 87Java Persistence Query Language, 113JBoss plug-ins for Eclipse, 315running Seam with Hibernate, 275–282

configuration changes, 278–280configuring components.xml, 279configuring faces-config.xml, 279configuring hibernate.cfg.xml, 278configuring web.xml, 280inside Java EE container, 278–281outside Java EE container, 281packaging WAR file, 280using JavaBeans and Hibernate,

276–278session, 161

Hibernate annotations, 154Ajax4jsf creating dynamic validations,

252Hibernate Code Generation window, 299Hibernate validator

Ajax4jsf creating dynamic validations,252, 255

calling from business tier, 154validation mechanism in Seam, 151

hibernate.cfg.xml filecreating, 296–299generating Hibernate code, 299jBPM specific configuration files, 198running Seam inside Java EE container,

278Hidden field component, JSF, 74href output

links with long-running conversations,173

HTML filescontents of WAR files, 58

html taglib references, 72Ajax4jsf creating dynamic validations,

254column tag, 72dataTable tag, 72, 82form tag, 80

■INDEX330

Page 25: JBoss AS - Springer978-1-4302-0385-8/1.pdf · JBoss AS B ecause Seam was written by those at JBoss, naturally JBoss is the application server that Seam works best with. Seam, however,

messages tag, 156outputLink tag, 173outputText tag, 73panelGrid tag, 80

HtmlDataTableList page, Garage Sale application, 81

HTTP-specific contextsusing in Seam components, 285

HttpServlet objectimplementation of Servlet interface, 24Session context, 159

HttpServletRequest attributeAction class, Struts, 27

HttpServletRequest classHttpServlet object and, 24web frameworks and, 10

HttpServletResponse attributeAction class, Struts, 27

HttpServletResponse classHttpServlet object and, 24web frameworks and, 10

HttpSession context, 24invalidate method, 25

HttpSession datadestroying, 25life cycle of SFSBs, 100

HttpSession interfaceHttpSession context, 24

HttpSession objectsHttpServlet object and, 24logging in, 34, 36long-running conversations, 168stateful session beans, 185

Hyperlink component, JSF, 74

IIBM WebSphere

JSF implementations, 49@Id annotation

entity beans (EBs), 105IDENTITY generated value

@GeneratedValue annotation, 106IDEs

Eclipse, 315JBoss IDE, 315

idle-timeout-minutes parametercreating datasource.xml file, 313

if tag, JSTL, 264if-then constructs

Drools rule engine, 264

@IfInvalid annotation, 151, 155ifNotBegunOutcome property

redirecting long-running conversation,180

ifOutcome property, @EndTask, 209Image component, JSF, 74immediate property, UIComponent

Apply Request Values phase, JSF, 70implementation patterns, 25–40

displaying dynamic data, 28–30listing and viewing pages, 37–40logging in, 34–37presentation implementation patterns,

26requesting and saving data, 30–34Seam, 28Struts, 27

importsstatic imports, Java 5, 19

@In annotationaccessing contexts, 182actor assignment, 211bijection with stateless session beans,

134method-level modifications on SLSBs,

128parameters, 134where to use bijection, 133

index.xhtml pageredirecting long-running conversation,

180initial parameters

configuring web.xml file for Faces, 53injection, dependency, 132, 133

see also bijectionInline message component, JSF, 74inputCalendar component

using Tomahawk for JSF components,52

inputDate componentusing Tomahawk for JSF components,

52inputDate tag, Tomahawk

Add page, Garage Sale application, 81installed property

configuring components.xml file, 272installing JBoss AS, 308–311instantiation of objects

why use SBs for business tier, 92integration testing, 292–294

■INDEX 331

Finditfasterathttp://superindex.apress.com

/

Page 26: JBoss AS - Springer978-1-4302-0385-8/1.pdf · JBoss AS B ecause Seam was written by those at JBoss, naturally JBoss is the application server that Seam works best with. Seam, however,

interceptor classeswrapping calls to interceptor, 135

interceptorsannotations and, 135bijection and, 134Seam architecture, 134Seam configuration options, 142Seam integration with EJB3, 140

@Interceptors annotationexample of SLSB class, 127Seam configuration options, 141, 142

internationalization, 223–234language bundles, 223, 224–231

using with Seam, 226–231page-level lookup of

internationalization files, 226selecting languages, 231–234

manually selecting language, 231using locale definitions from faces-

config.xml, 233using Seam components for, 234with JSF alone, 226–227with JSF and Seam, 228–231

invalidate methoddestroying HttpSession data, 25

inversion of control (IoC), 132see also bijection

Invoke Application phase, JSF, 71invoke application phase, Page context,

166invokeApplication method, 294IoC (inversion of control), 132

see also bijectionisDebugEnabled property

logging with Seam, 143isolation

ACID properties of transactions, 115deployment isolation, JBoss AS, 310

JJAR (Java ARchive) files

adding library JAR file, 314adding Seam JAR files, 125configuration of web frameworks, 51configuring jBPM with Seam, 197creating JAR package for EJB, 91installing Tomahawk JAR files, 52module tag, 90packaging into EAR file, 91–92

packaging WAR files, 273Seam debugging, 146

Java 1.5.0 see Java 5Java 5, 11–20

annotations (metadata), 14autoboxing, 17downloading, 12–13enhancements, 14–20enums, 17for loop, 16–17generics, 15–16JSRs for Java 5 release, 11language features, 14–20Seam environment requirements, 6static imports, 19varargs, 18–19

Java 5 Software Development Kit, 13Java API for XML Processing (JAXP), 12Java ARchive files see JAR filesJava community

JSF specification, 2Java Community Process see JCPJava Data Objects (JDO), 102Java EE (Java Enterprise Edition)

running Seam with Hibernateinside Java EE container, 278–281outside Java EE container, 281

three-tier Java EE architecture, 3Java Management Extensions see JMXJava Memory Model and Thread

Specification, 12Java Message Service see JMSJava Naming and Directory Interface see

JNDIJava objects

POJOs (plain old Java objects), 20Java Persistence Query Language see JPQLJava Platform Profiling Architecture, 12Java SASL specification, 12Java Specification Request (JSR), 11Java Transaction API (JTA)

referencing non-JTA data, 89Java web applications see web

applicationsJavaBeans

Conversation context and, 168default binding, 185running Seam with Hibernate using,

276–278

■INDEX332

Page 27: JBoss AS - Springer978-1-4302-0385-8/1.pdf · JBoss AS B ecause Seam was written by those at JBoss, naturally JBoss is the application server that Seam works best with. Seam, however,

Stateless context, 161uses of, 185

Javadoc tag, annotations, 14JavaScript

excluding objects on method call, 250Java data types for Seam remoting, 248remote configuring of Seam, 241turning on debugging, 249

JavaServer Faces see JSFjavax.persistence.* package, 104javax.servlet package, 23JAXP (Java API for XML Processing), 12JBoss, 307, 311JBoss AS (JBoss Application Server),

307–314adding data source, 312–314

creating datasource.xml file, 312–313adding library JAR file, 314deploying JBoss, 312downloading, 307installing, 308–311locating and configuring log files, 314running JBoss, 311

JBoss IDE, 315JBoss Seam see SeamJBoss Seam framework see Seam

frameworkjboss-beans.xml file

configuring XML in EJB3 container,272–273

jBPM (JBoss Business ProcessManagement), 188–221

actors requirement, 189components for creating process

definitions, 192–196configuring with Seam, 197–202description, 188, 189Drools rules built into jBPM decision,

266Drools rules built into jBPM task node,

267how jBPM works, 190jBPM specific configuration files, 198

hibernate.cfg.xml file, 198jBPM tokens, 206page flow creation in Seam, 220–221

configuring page flow with Seam, 220starting page flow, 220

page flow definitions, 213–220

brief description, 188components for creating page flow,

217–220process definition creation in Seam,

197–213configuring jBPM with Seam,

197–202creating process definition, 203–204creating tasks, 207–211resuming tasks, 211switching process definitions,

211–213viewing tasks, 204–207

process definitions, 189–196brief description, 188components for creating, 192–196

running with Seam or EJB3, 187tasks requirement, 189using Drools in jBPM, 266using jBPM for ticketing system,

190–192when to use, 189workflow requirement, 189workflows, creating, 191–192

jBPM Graphical Process Designer,303–305

page flow graphical interface, 306process definition graphical interface,

304jbpm.cfg.xml file, 202JCP (Java Community Process)

JSF background, 48reasons for using JSF, 2, 4servlet specification, 23

JDBC Rowset Implementations, 12JDK 5.0 (Java 5 Software Development Kit)

downloading Java 5, 13JDO (Java Data Objects)

creating data tier, 102JEMS (JBoss Enterprise Middleware Suite)

Drools rules engine, 264JMS (Java Message Service)

configuring JMS listeners, 255–256JMS messaging using Ajax, 255–257message-driven beans, 101using JMS listeners, 257

JMX (Java Management Extensions)JSRs for Java 5 release, 11, 12security, installing JBoss AS, 310

■INDEX 333

Finditfasterathttp://superindex.apress.com

/

Page 28: JBoss AS - Springer978-1-4302-0385-8/1.pdf · JBoss AS B ecause Seam was written by those at JBoss, naturally JBoss is the application server that Seam works best with. Seam, however,

JNDI (Java Naming and DirectoryInterface)

creating datasource.xml file, 313EJB 2.x specification, 88entity beans and database persistence,

89parameters, 313

JNDI nameSeam configuration options, 142specifying JNDI name, 127

jndi-name parametercreating datasource.xml file, 313

@JndiName annotationexample of SLSB class, 127Seam configuration options, 141, 142

jndiName propertyconfiguring jboss-beans.xml file, 273

jndiPattern, JBossconfiguring components.xml file, 272Seam configuration options, 142

join component, workflows, 196join parameter, type property

conversationPropagation tag, Seam,174, 175

@JoinColumn annotation@ManyToOne annotation, 108

JPQL (Java Persistence Query Language),113–114

@SuppressWarnings annotation, 113parameter to EntityManager object, 113

JSF (JavaServer Faces), 47–83Ajax4jsf in Seam, 250–255architecture, 59–68background, 48–49backing beans, 50, 63components, 71–74

component layout, 72–73date/calendar components, 51standard components, 73–74UI component and renderer, 61–62using Tomahawk, 51–52

configuring XML files, 52–56faces-config.xml file, 54–56web.xml file, 53–54

converters, 63converting dates/numbers into

displayable items, 63core taglib references, 72creating WAR (Web ARchive) files, 57–58

description, 11events, 64–66expression language see JSF expression

language<f:view> component, 8Faces form component, 73faces-config.xml file, 50Garage Sale application, 78–83

creation of pages and backing beans,79

Hello World example, 49–51html taglib references, 72implementations, 49integration with conversations, 172–180

links with long-runningconversations, 173–175

performing workspace management,175–179

redirecting long-runningconversation, 179

internationalization with JSF alone,226–227

internationalization with JSF and Seam,228–231

Java community and, 2JSP pages, 59life cycle see JSF life cyclelisteners, 64–66maintaining long-running

conversation, 172managed beans, 67–68messages, 66MyFaces, 10navigation, 67

Invoke Application phase, 71page flow, JSF, 76

need to include JSF files indeployments, 51

page flow, 76–78pages see JSF pagesPOJOs (plain old Java objects), 59presentation tier, 150–151rapid application development for, 59reasons for JBoss Seam, 2reasons for using, 4reasons for using Seam, 5Seam environment requirements, 6tag library, 62tags, 254

■INDEX334

Page 29: JBoss AS - Springer978-1-4302-0385-8/1.pdf · JBoss AS B ecause Seam was written by those at JBoss, naturally JBoss is the application server that Seam works best with. Seam, however,

UI component and renderer, 61–62using in non JSF server environment, 51validator, 62web frameworks and, 10

JSF expression language (EL), 74–75conditional statements, 75defining objects inside tag libraries, 74indicating start of expression language,

74setting expression language resolver,

284JSF life cycle, 68–71

Apply Request Values phase, 70Invoke Application phase, 71phase events, JSF, 66Process Validations phase, 70Render Response phase, 71Restore View phase, 69Update Model Values phase, 71

JSF pages@IfInvalid annotation, 151, 155calling business logic, 121expression language, 74Hello World example, 7Hello World output, 50referencing component or bean, 127Seam architecture, 141stateless session bean example, 130validation on JSF pages, 155–156

JSP pagesAdd page, Garage Sale application,

79–81displaying list of addresses, 150JSF architecture, 59List page, Garage Sale application,

81–83login.jsp file, 260Restore View phase, JSF, 69validation on JSF pages, 155

JSP tag library, 147JSR (Java Specification Request), 11JSTL tag library

see also Seam tag libraryif tag, 264page-level authentication, 263

JTA (Java Transaction API)referencing non-JTA data, 89

JVM (Java Virtual Machine)Monitoring and Management

Specification for, 12

Llanguage bundles, 224–231

defining multiple bundle names, 230internationalization, 223

with JSF alone, 226–227with JSF and Seam, 229

language files, 226properties file, 225setting up, 225using with Seam, 226–231

language codeLocale object, java.util, 224setting up language bundles, 225

language filesusing language bundles, 226

Language selection screeninstalling JBoss AS, 308

languages, selecting, 231–234manually selecting, 231using locale definitions, faces-

config.xml, 233large object data types, @Lob, 106lastDatetime property

ConversationEntry object, 178@Length annotation, Hibernate, 154

Ajax4jsf creating dynamic validations,252

lib tagcreating WAR file for Faces via Ant, 58

library directorypackaging WAR files, 273

library filesadding library JAR file, 314contents of WAR files, 58

licence agreement screen, JBoss AS, 309Lifecyle class

Seam integration with MVC, 139Link action component, JSF, 74link tag, Seam

links with long-running conversations,173

linkslinks with long-running conversations,

173–175List box component, JSF, 74List page

Garage Sale application, 81–83ListDataModel

data model events, JSF, 66

■INDEX 335

Finditfasterathttp://superindex.apress.com

/

Page 30: JBoss AS - Springer978-1-4302-0385-8/1.pdf · JBoss AS B ecause Seam was written by those at JBoss, naturally JBoss is the application server that Seam works best with. Seam, however,

listenersadding to servlet request life cycle in

web.xml, 125backing beans, 5configuring JMS listeners, 255–256configuring web.xml file for Faces, 53,

54description, 64JSF, 64–66Seam integration with MVC, 139SeamExtendedManagedPersistence

PhaseListener, 283SeamExtendedManagedPersistence

PortletPhaseListener, 283SeamPhaseListener, 282SeamPortletListener, 283using JMS listeners, 257

listing and viewing pagespresentation implementation patterns,

26, 37–40lists, generics, 15loading message

hiding/changing, 248@Lob annotation

entity beans (EBs), 106@Local annotation

creating SLSBs, 95Locale object, java.util, 224

country code, 224internationalization with JSF alone, 227language code, 224variant code, 224

localesinternationalization with JSF and Seam,

228setting Seam to remember locale via

cookie, 231LocaleSelector

selecting languages, 231localization

converting dates/numbers intodisplayable items, 63

log4j.xml filelocating and configuring log files, 314

LogFactorylogging by using LogFactory, 143

@Logger annotationlogging with Seam, 144

logginglocating and configuring log files, 314logging using LogFactory, 143Seam components, 143–144using Session context, 163which logger to use, 143

logging inpresentation implementation patterns,

26, 34–37login component

implementing authentication, 260–262login method, LoginAction class

implementing authentication, 262login.jsp file

creating login/logout, 260LoginAction class

calling ProviderAuthentication, 261LoginAction code, 210logout method, LoginAction class

implementing authentication, 262long value

determining style for dates, 64long-running conversations, 168, 169–172

beginning, 169creating, 169creating links with, 173–175ending, 171middle of, 170normal propagation of conversation,

173–174other propagations of conversation,

174–175redirecting, 179

loopsenhanced for loop, 16

Mmanaged beans

see also backing beansconfiguring faces-config.xml, 56JSF architecture, 67–68

managed persistence context, 283MANDATORY transaction, EJB3, 116@ManyToMany annotation

entity beans (EBs), 108@ManyToOne annotation

entity beans (EBs), 107mappedBy property, @OneToMany, 108Maps data type

Java data types for seam remoting, 248

■INDEX336

Page 31: JBoss AS - Springer978-1-4302-0385-8/1.pdf · JBoss AS B ecause Seam was written by those at JBoss, naturally JBoss is the application server that Seam works best with. Seam, however,

@Max annotation, Hibernate, 154max-pool-size parameter

creating datasource.xml file, 313MDBs see message-driven beansmedium value

determining style for dates, 64message bundles

defining language bundles with Seam,230

internationalization with JSF alone, 227Message list component, JSF, 74message-driven beans (MDBs), 101–102

contexts and, 184uses of, 184

@MessageDriven annotation, 101messages

hiding/changing the loading message,248

interval to check for any messages, 256wait time on server for messages, 256

messages tag, htmlvalidation on JSF pages, 156

messages, JSF, 66metadata see annotationsMetadata Facility

JSRs for Java 5 release, 12method signatures

find method, 112varargs, 18

methods, JavaScriptexcluding objects on method call, 250linking topics with methods, 257

@Min annotation, Hibernate, 154model

MVC architecture, 9updateModelValues method, 294

module tags, EAR file, 90modules, EAR file, 89monetary display

setting up language bundles, 225Monitoring and Management

Specification for JVM, 12Multiline text area component, JSF, 74Multiselect list box component, JSF, 74MVC (Model-View-Controller)

architecture, 9–11controller, 9frameworks, 10–11JSF framework, 11

model, 9MyFaces, 10Seam integration with MVC, 139Spring MVC, 10Struts, 10Tapestry, 10view, 9

MyFacesdate/calendar components for JSF, 52downloading, 51JSF framework, 10JSF implementations, 49

MySQL, downloading, 314

N@Name annotation

example of SLSB class, 127Hello World example, 7where to use bijection, 133

name propertyAjax4jsf creating dynamic validations,

253name/value pairs

property files, 224namespaces

XML namespaces, 230defining themes with, 235

navigation diagramticketing system application, 45

navigation rulesfaces-config.xml file, 76

configuring, 56from action tag, 78from-view-id tag, 76, 78global navigation rules, 76same name returns, 77

navigation, JSF see under JSFnested conversations, 168nested parameter, type property

conversationPropagation tag, Seam,174, 175

Network Transfer Format for JavaArchives, 12

NEVER transaction, EJB3, 116no-conversation-id property

redirecting long-running conversation,179

■INDEX 337

Finditfasterathttp://superindex.apress.com

/

Page 32: JBoss AS - Springer978-1-4302-0385-8/1.pdf · JBoss AS B ecause Seam was written by those at JBoss, naturally JBoss is the application server that Seam works best with. Seam, however,

nodesbringing nodes back together, 196deciding which task nodes to go to, 195joining two states together, 196task node component, workflows, 193tasks component, workflows, 193

non-jta-data-source configuration option,89

none parameter, type propertyconversationPropagation tag, Seam, 174

@NotNull annotation, Hibernate, 154Ajax4jsf creating dynamic validations,

252NotNull validations

entity bean with, 153NOT_SUPPORTED transaction, EJB3, 116numbers

converting into displayable items, 63

Oobject instantiation

why use SBs for business tier, 92OGNL (Object-Graph Navigation

Language)reasons for using Seam, 11

onblur eventAjax4jsf creating dynamic validations,

252, 255onChange events

value-change events, JSF, 65@OneToMany annotation

entity beans (EBs), 108@OneToOne annotation

entity beans (EBs), 108operations on entity manager, 111–113

add, 111delete, 111update, 112

@Out annotationbijection with stateless session beans,

134customizing property name, 163defining context scope, 136method-level modifications on SLSBs,

128parameters, 133where to use bijection, 133

outjection see bijection

outPanel tag, AjaxAjax4jsf creating dynamic validations,

255Output text component, JSF, 74outputLink tag, html

links with long-running conversations,173

outputText methodHello World example, 8

outputText tag, html, 73

Ppackages

javax.servlet package, 23packaging

configuring EJB3s for deployment,90–92

creating JAR package for EJB, 91packaging EAR file, 91–92

page component, jBPM page flows, 218Page context, 165–166

conversation ID, 248description, 137invoke application phase, 166scoping objects, 166Seam contexts, 135state, 165stateful session beans, 185

page flow definitions, jBPM, 213–220components for creating page flow,

217–220action, 219decision, 219end conversation, 220page, 218redirect, 219start page, 218start state, 217

configuring page flow with Seam, 220description, 188page flow creation in Seam, 220–221purpose of, 213starting page flow, 220when not to use, 214when to use, 213

page flow graphical interfacejBPM Graphical Process Designer, 306

page flow, JSF, 76–78navigation, JSF, 76

■INDEX338

Page 33: JBoss AS - Springer978-1-4302-0385-8/1.pdf · JBoss AS B ecause Seam was written by those at JBoss, naturally JBoss is the application server that Seam works best with. Seam, however,

page-level annotations, Seam security, 263page-level authentication, 263pageflow parameter, @Begin

starting page flow, 220pages

display page of Session context object,163

hiding/changing the loading message,248

internationalization, 223–234listing and viewing pages, 26, 37–40navigation, JSF, 67page component, page flows, 218page-level lookup of

internationalization files, 226performing partial page updates, 250start page component, page flows, 218themes, 234

pages.xml fileredirecting long-running conversation,

179viewing lists of conversations, 175

panelGrid tag, htmlAdd page, Garage Sale application, 80

passivation, SFSB life cycle, 97, 98password parameter

creating datasource.xml file, 313password property

Ajax4jsf creating dynamic validations,253

passwordsexcluding objects on method call, 250

@Past annotation, Hibernate, 154@Pattern annotation, Hibernate, 154patterns

implementation patterns used in Seam,25–40

presentation implementation patterns,26

@Permission annotation, 263permissions

authentication of permissions/rules forusers, 262

dynamic permissions, 263hasPermision function, 263static permissions, 263

@Permissions annotation, 263

persistence@Transient annotation, 106adding record to database, 111changing persistence context, 149configuring jboss-beans.xml file, 272entity beans, 184EntityManager object, 110–111jBPM specific configuration files, 202managed persistence context, 283removing records from SLSB, 111setting context for binding instance of

POJO, 148SFSB life cycle, 97stateful session beans, 185updating fields on entity beans, 112when to use Session context, 164

persistence tier, 3benefits of using Seam framework, 2three-tier architecture, 2–4

persistence.xml (data source descriptor)configuring EJB3s for deployment,

88–89configuring jboss-beans.xml file, 273creating JAR package for EJB, 91managed persistence context, 283

@PersitenceContext annotationchanging persistence context, 149EntityManager object, 110

phase events, JSF, 66phase listeners, Seam

faces-config.xml file after adding, 124managed persistence context, 283SeamExtendedManagedPersistence

PhaseListener object, 283SeamExtendedManagedPersistence

PortletPhaseListener object, 283SeamPhaseListener object, 282SeamPortletListener object, 283

plain old Java objects see POJOsplug-ins

JBoss plug-ins for Eclipse, 315plumbing code

Seam eliminating, 122POJOs (plain old Java objects), 20

annotated as Session context, 164annotations (metadata), 14, 20contexts, 181contexts injectable into POJOs, 183entity beans, 102, 184

■INDEX 339

Finditfasterathttp://superindex.apress.com

/

Page 34: JBoss AS - Springer978-1-4302-0385-8/1.pdf · JBoss AS B ecause Seam was written by those at JBoss, naturally JBoss is the application server that Seam works best with. Seam, however,

JSF architecture, 59JSF background, 49message-driven beans, 102running Seam with Hibernate, 275Seam architecture, 132Seam components data model, 148–150Seam integration with EJB3, 140setting context for binding instance of,

148three-tier Java EE architecture with

Seam, 4transforming complex objects into, 14why use SBs for business tier, 92

pollInterval variable, JMS listeners, 256pollTimeOut variable, JMS listeners, 256pooledTaskInstanceList token, jBPM, 206pooling

displaying pooled tasks, 205SFSB life cycle, 97SLSB life cycle, 93

life cycle annotations, 96why use SBs for business tier, 92

portals, 284portlet support, Seam, 284PortletPhaseListener

configuring portlet environment, 285portlets, 285POST requests, MVC architecture, 9post-then-redirect, JSF

maintaining long-runningconversation, 172

postbacksRestore View phase, JSF, 70

@PostConstruct annotationSLSB life cycle, 96

@PreDestroy annotationSLSB life cycle, 96

presentation implementation patterns, 26displaying dynamic data, 26, 28–30listing and viewing pages, 26, 37–40logging in, 26, 34–37requesting and saving data, 26, 30–34

presentation tierbenefits of using Seam framework, 2description, 3Hello World example, 8JSF fundamentals, 47–83JSF presentation tier, 150–151MVC architecture, 9

reasons for using JSF, 4reasons for using Seam, 6three-tier architecture, 2–4UI component and renderer, JSF, 61why use SBs for business tier, 92

primary keys, @Id annotation, 105primitives, autoboxing, 17printable theme

creating themes, 235process definition graphical interface

jBPM Graphical Process Designer, 304process definitions, jBPM, 189–196

changeProcessDefinition method, 213components for creating, 192–196

actors, 194decision, 195end state, 196fork, 195join, 196start state, 192state, 195task nodes, 193tasks, 193transitions, 193

configuring jBPM with Seam, 197–202creating tasks, 207–211

actor assignment, 210–211description, 188

getProcessDefinitions method, 213jBPM requirement for workflow, 189

process definition creation in Seam,197–213

creating process definition, 203–204resuming tasks, 211switching process definitions, 211–213tokens, 188viewing tasks, 204–207

process designjBPM Graphical Process Designer,

303–305Process Validations phase, JSF, 70processes

creating workflows, jBPM, 192dynamic switching of processes, 188waiting for come back from external

system, 195processTroubleTickets method, 257processValidations method, 294

■INDEX340

Page 35: JBoss AS - Springer978-1-4302-0385-8/1.pdf · JBoss AS B ecause Seam was written by those at JBoss, naturally JBoss is the application server that Seam works best with. Seam, however,

properties fileadding Seam.properties file, 126configuring JMS listeners, 255internationalization with JSF alone, 226,

227referencing components inside, 228setting up language bundles, 225

property filescreating themes, 234internationalization with JSF alone, 227resource and language bundles, 224setting up language bundles, 225

ProviderAuthenticator componentimplementing authentication, 260LoginAction class calling, 261

Qqueries

Java Persistence Query Language,113–114

RRAD (rapid application development)

JSF (JavaServer Faces), 59Radio button list component, JSF, 74@Range annotation, Hibernate, 154redirect component, jBPM page flows, 219relationships

@ManyToMany annotation, 108@ManyToOne annotation, 107@OneToMany annotation, 108@OneToOne annotation, 108

@Remote annotationcreating SLSBs, 95

remoting see Seam remoting using Ajax@Remove annotation

life cycle of SFSBs, 100@Remove annotation

ending long-running conversations, 171Render Response phase, JSF, 71renderer, JSF, 61–62

delegated/direct implementations, 62renderers

configuring faces-config.xml file, 56renderResponse method, 294request cycle, Event context, 165requesting and saving data

presentation implementation patterns,26, 30–34

@RequestParameter annotationstateless JavaBean, 161

requestsadding conversationId to URL of, 172applyRequestValues method, 294HttpServletRequest class, 24JSF background, 49requesting and saving data, 26, 30–34

required parameter, @In, 133required parameter, @Out, 133REQUIRED transaction, EJB3, 116, 117REQUIRES_NEW transaction, EJB3, 116reRender parameter

Ajax4jsf creating dynamic validations,255

@Resource annotationbean-managed transactions, 119

resource bundles, 224externalizing content, 223reference to resource bundle in

components.xml, 230responses

HttpServletResponse class, 24renderResponse method, 294

REST (REpresentational State Transfer)REST in Seam, 239types of web services, 238

Restore View phase, JSF, 69@Restrict annotation, 263@ResumeProcess annotation, 204reverse engineering database

Hibernate Console, 294JBoss plug-ins for Eclipse, 315

RMI (Remote Method Invocation)Event context objects, 165

@Role annotationusing contexts for POJOs, 181

roleshasRole function, 263implementing authentication, 260Seam security model, 258testing for user having admin role, 263

@Roles annotationusing contexts for POJOs, 181

rollbacksbean-managed transactions, 118, 119container-managed transactions, 116,

117

■INDEX 341

Finditfasterathttp://superindex.apress.com

/

Page 36: JBoss AS - Springer978-1-4302-0385-8/1.pdf · JBoss AS B ecause Seam was written by those at JBoss, naturally JBoss is the application server that Seam works best with. Seam, however,

RPC (Remote Procedure Call)types of web services, 238

rule base, Drools rule engine, 265rules, 262rules engines, Drools, 264–267run files

running JBoss, 311

Ss: tag prefix, 150SalesManagerAction class

using TestNG component, 288same name returns

navigation rules, 77sample applications, 40–45

Garage Sale application, 41ticketing system application, 44–45Travel Reservations application, 42–44

SASL specification, Java, 12saving data

requesting and saving data, 26, 30–34SBs see session beansschema generation

validation, Seam components, 157scope

@Role annotation, 181@Roles annotation, 181defining context scope, 136Page context, 166

@Scope annotationdefining context scope, 136retrieving/editing list using SFSB, 148using contexts for POJOs, 181

scope parameter, @In, 133scope parameter, @Out, 133Seam, 121–157

Ajax4jsf in Seam, 250–255architecture see Seam architecturecomponents see components, Seamconfiguring Seam see configuration,

Seamcontexts see Seam contextsdescription, 1, 122downloading, 123eliminating plumbing code, 122environment see environments, Seamexample of SLSB class, 127full life-cycle call with Seam, 139framework see Seam framework

Hello World example, 7–8Hibernate Console with Seam, 294–302implementation patterns see

implementation patternsinterceptor see interceptorsJBoss AS (Application Server), 307–314jBPM (JBoss Business Process

Management), 188–221jBPM Graphical Process Designer,

303–305JMS messaging using Ajax, 255–257language bundles, using with Seam,

226–231internationalization with JSF and

Seam, 228–231method-level modifications on SLSBs,

128performing partial page updates, 250phase listeners see phase listeners,

Seamportlet support, 284reasons for using Seam, 5remoting see Seam remoting using AjaxREST in Seam, 239running Seam in embedded EJB3

container, 270–275packaging new container, 271–275using JBoss EJB3, 271

running Seam with Hibernate, 275–282inside Java EE container, 278–281outside Java EE container, 281using JavaBeans and Hibernate,

276–278security see Seam securitysetting Seam to remember locale via

cookie, 231stateless session bean example, 126–131tag library see Seam tag librarytesting, 288–294

integration testing, 292–294TestNG component, 288–292unit testing, 288

web services supported, 239web.xml turning on debugging, 146wrapping calls to interceptor, 135

Seam architecture, 131–141annotations, 132bijection, 132–134interceptors, 134

■INDEX342

Page 37: JBoss AS - Springer978-1-4302-0385-8/1.pdf · JBoss AS B ecause Seam was written by those at JBoss, naturally JBoss is the application server that Seam works best with. Seam, however,

inversion of control (IoC), 132JSF pages, 141POJOs, 132Seam integration with EJB3, 140Seam integration with MVC, 139three-tier architecture, 138–140

Seam contexts, 135–138Application context, 136, 138, 164Business Process context, 136, 138, 187Conversation context, 136, 137, 166–180defining context scope, 136Event context, 135, 137, 165Page context, 135, 137, 165–166Seam integration with MVC, 139Session context, 136, 138, 161–164Stateless context, 135, 137, 160–161

Seam framework@Stateless annotation, 28benefits of using Seam framework, 2displaying dynamic data, 30event listeners difference to JSF, 64listing and viewing pages, 39logging in, 36message-driven beans and, 101requesting and saving data, 33three-tier architecture with Seam, 3three-tier Java EE architecture with

Seam, 4web frameworks, 28

Seam remoting using Ajax, 240–250Ajax remoting call, 242–245Ajax remoting call with parameters,

245–247batch remote calls, 247conversation ID, 248debugging, 249excluding objects on method call, 250getComponentName command, 247hiding/changing the loading message,

248Java data types for Seam remoting, 248remote configuring of Seam, 241

Seam security, 258–264adding security rules file to deployed

EAR, 262authentication in version 1.1.0 of Seam,

258Drools rule engine, 262excluding objects on method call, 250

implementing authentication, 258–262AuthenticationProvider class,

259–260Authenticator component, 262authenticatorAction component, 260component-level authentication, 263creating login/logout, 260–262login component, 261page-level annotations, 263page-level authentication, 263ProviderAuthenticator component,

260roles, 258SeamSecurityManager component, 262,

263SecurityConfiguration component, 262

Seam tag libraryAjax4jsf creating dynamic validations,

254conversationId tag, 173conversationPropagation tag, 174hasPermision function, 263hasRole function, 263link tag, 173page-level authentication, 263using to display list of addresses, 150validateAll tag, 156

SeamExtendedManagedPersistencePhaseListener, 283

SeamExtendedManagedPersistencePortletPhaseListener, 283, 285

SeamInterceptor objectSeam configuration options, 142Seam integration with EJB3, 140

SeamListener objectadding listeners to servlet request life

cycle, 125Seam integration with MVC, 139

SeamPhaseListener objectphase listeners, 282Seam integration with MVC, 139

SeamPortletListener objectphase listeners, 283

SeamRemotingServlet objectremote configuring of Seam, 241

SeamSecurityManager component, 262,263

SeamSpacePermissions packageexample of security-rules.drl file, 263

■INDEX 343

Finditfasterathttp://superindex.apress.com

/

Page 38: JBoss AS - Springer978-1-4302-0385-8/1.pdf · JBoss AS B ecause Seam was written by those at JBoss, naturally JBoss is the application server that Seam works best with. Seam, however,

SeamTest classintegration testing, 293

Secret field component, JSF, 74security see Seam securitysecurity-rules.drl file

adding security rules file to deployedEAR, 262

SEQUENCE generated value@GeneratedValue annotation, 105, 106

serializable objectscontexts in servlets, 24–25

serversconfiguring server for Seam, 20JBoss AS, 307–314

Servlet class file, 23Servlet context, 24

Application context compared, 164ServletContext interface, 24

Servlet interfaceimplementation of, 23

servlet mappingconfiguring web.xml file for Faces, 53

Servlet object, 23getServletContext method, 24

Servlet specificationJSF background, 48web frameworks and, 10

ServletContext interface, 24ServletContext objects

HttpServlet object and, 24ServletRequest context, 24ServletRequest interfaceservlets, 23–25

adding listeners to servlet request lifecycle, 125

configuring web.xml file for Faces, 53contexts in servlets, 24–25

HttpSession context, 24Servlet context, 24ServletRequest context, 24

frameworks and, 25JCP servlet specification, 23SeamRemotingServlet, 241web applications and, 23

session beans (SBs), 92–101@Local annotation, 95@PostConstruct annotation, 96@PreDestroy annotation, 96@Remote annotation, 95

@Remove annotation, 100@Stateful annotation, 100@Stateless annotation, 95bean- or container-managed, 115injecting entity managers into SBs, 110stateful session beans, 97–101stateless session beans, 93–97why use SBs for business tier, 92

Session context, 161–164description, 138display page of Session context object,

163HttpServlet object, 159Seam contexts, 136setting context for binding instance of

POJO, 148Stateless class with, 162when to use, 164

Session objectAjax remoting call, 244using JavaBeans and Hibernate, 277

sessions, 161Conversation context, 166

setRollbackOnly methodbean-managed transactions, 118container-managed transactions, 117

SFSBs see stateful session beansshopping cart

life cycle of SFSBs, 99@Stateful annotation, 100

short valuedetermining style for dates, 64

short-term conversations, 168@Size annotation, Hibernate, 154SLSBs see stateless session beansSOAP (Simple Object Access Protocol)

types of web services, 238specifications

JSRs for Java 5 release, 11Spring

history of EJB3, 87Spring framework

web services, 238Spring MVC, 10start page component, jBPM page flows,

218start state component, jBPM page flows,

217start state component, workflows, 192

■INDEX344

Page 39: JBoss AS - Springer978-1-4302-0385-8/1.pdf · JBoss AS B ecause Seam was written by those at JBoss, naturally JBoss is the application server that Seam works best with. Seam, however,

startDatetime propertyConversationEntry object, 178

@StartTask annotation, 209state

adding context parameters to web.xmlfile, 124

adding setting of state-saving method,125

end state component, workflows, 196Page context, 165start state component, page flows, 217start state component, workflows, 192

state component, workflows, 195@Stateful annotation

life cycle of SFSBs, 100retrieving/editing list using SFSB, 148

stateful session beans (SFSBs), 97–101@PersitenceContext annotation, 111activation, 97, 99Application context, 164changing persistence context, 149default binding, 185Delete action, 149Edit action, 148how Conversation context works, 168HttpSession objects, 185life cycle of SFSBs, 97–101long-running conversations, 172negative connotations with EJB2, 1passivation, 97, 98retrieving/editing list, 148uses of, 185

@Stateless annotationcreating SLSBs, 95making JavaBean an EJB3 object, 8Seam framework, 28

Stateless classwith Session context object, 162

Stateless context, 160–161description, 137entity beans, 184JavaBean, 161Seam contexts, 135stateless session beans, 184

stateless session beans (SLSBs), 93–97@PersitenceContext annotation, 110@Stateless annotation, 28bijection with SLSBs, 134calling validator from business tier, 155

creating SLSBs, 95default binding, 184example of SLSB class, 127life cycle annotations, 96–97life cycle of SLSBs, 93method-level modifications by Seam,

128removing records from SLSB, 111Seam example, 126–131Session context, 162uses of, 184

static imports, Java 5, 19JSRs for Java 5 release, 12

static permissionspage-level annotations, security, 263

String data typeJava data types for seam remoting, 248

Struts, 27Action class, 27

displaying dynamic data, 28listing and viewing pages, 37logging in, 34requesting and saving data, 32

ActionForm object, 27ActionMapping object, 27component layout, 72description, 10DynaForm, requesting and saving data,

32JSF background, 49web frameworks and, 10

subscribe method, Seam.Remotingusing JMS listeners, 257

Sun Microsystemshistory of EJB3, 86

support tag, AjaxAjax4jsf creating dynamic validations,

255SUPPORTS transaction, EJB3, 116@SuppressWarnings annotation

Java Persistence Query Language, 113Switcher object, 178switching workspaces, 178

Tt: tag prefix, 81

see also tomahawk taglib references@Table annotation

entity beans, 104

■INDEX 345

Finditfasterathttp://superindex.apress.com

/

Page 40: JBoss AS - Springer978-1-4302-0385-8/1.pdf · JBoss AS B ecause Seam was written by those at JBoss, naturally JBoss is the application server that Seam works best with. Seam, however,

TABLE generated value@GeneratedValue annotation, 106

tag librariesEL defining objects inside tag libraries,

74Hello World example, 8JSF (JavaServer Faces), 62JSF pages, 5page-level authentication, 263

tag library (taglib) inputs, 72tag library, JSP, 147tag library, Seam see Seam tag librarytag library URIs

configuring web.xml file for Faces, 53tags

Ajax4jsf creating dynamic validations,254

classes tag, 58column tag, html, 72commandLink tag, JSF, 173, 174conversationId tag, Seam, 173conversationPropagation tag, Seam, 174convertDateTime tag, JSF, 63dataTable tag, html, 72, 82ear tag, 92f: prefixed tags see core taglib referencesfacet tag, JSF, 72, 73fileset tag, 58form tag, html, 80from-view-id tag, 76h: prefixed tags see html taglib

referencesinputDate tag, Tomahawk, 81lib tag, 58link tag, Seam, 173messages tag, html, 156module tags, 90outputLink tag, html, 173outputText tag, html, 73panelGrid tag, html, 80t: prefixed tags see tomahawk taglib

referencesvalidateAll tag, Seam, 156validateLongRange tag, JSF, 62, 71view tag, JSF, 72, 80, 82webinf tag, 58

Tapestry, 10targetEntity property, @OneToMany, 108

task nodescreating workflows, jBPM, 192Drools rules built into jBPM task node,

267task nodes component, workflows, 193taskIdParameter parameter, @StartTask,

209taskInstanceList token, jBPM, 206taskInstanceListForType token, jBPM, 206tasks

annotations starting/ending tasks, 207creating tasks, 207–211

actor assignment, 210–211description, 189displaying pooled tasks, 205how jBPM works, 190jBPM requirement for, 189resuming tasks, 211viewing tasks, 204–207

pooledTaskInstanceList token, 206taskInstanceList token, 206taskInstanceListForType token, 206

workflows and, 189tasks component, workflows

components for creating processdefinitions, 193

defining actors for tasks using actor ID,194

defining actors for tasks using pooledactors, 194

templateshotels.xhtml with dynamic template,

236themes, 234, 236

temporary conversations, 168@Test annotation

using TestNG component, 292testing, 288–294

creating test classes, 291integration testing, 292–294running Seam in embedded EJB3

container, 270testing EJBs, 120TestNG component, 288–292unit testing, 288

TestNG component, 288–292integration testing, 292

Text field component, JSF, 74text-only theme, 235

■INDEX346

Page 41: JBoss AS - Springer978-1-4302-0385-8/1.pdf · JBoss AS B ecause Seam was written by those at JBoss, naturally JBoss is the application server that Seam works best with. Seam, however,

themes, 234–237creating themes, 234–235default theme, 234defining themes with XML namespaces,

235printable theme, 235selecting themes, 236text-only theme, 235using themes, 236

themeSelector component, 236ThemeSelector object, 234three-tier architecture, 2–4

Java EE architecture, 3, 4Seam architecture, 138–140Seam integration with EJB3, 140Seam integration with MVC, 139with Seam, 3, 4

ticketing system application, 44–45configuring jBPM with Seam, 197creating process definition, 203displaying pooled tasks, 205generating Hibernate code, 299Hibernate Console reverse engineering

database, 295processTroubleTickets method, 257switching process definitions, 211–213using jBPM for ticketing system,

190–192viewing tasks, 204

tokens, jBPM, 206pooledTaskInstanceList token, 206process definitions, 188taskInstanceList token, 206taskInstanceListForType token, 206

tokens, workflowscreating process definition, 203creating workflows, jBPM, 192task node component, 193tasks component, 193

Tomahawk, 52tomahawk taglib references

inputDate tag, tomahawk, 81Tomcat

running Seam in embedded EJB3container, 270

toolsHibernate Console, 294–302jBPM Graphical Process Designer,

303–305

topicsconfiguring JMS listeners, 255linking topics with methods, 257using JMS listeners, 257

@TransactionAttribute annotationcontainer-managed transactions, 117

@TransactionManagement annotationbean-managed transactions, 118

transactions, 114–119ACID properties, 114atomicity, 115bean-managed, 117–119container-managed, 116–117consistency, 115description, 114dirty reads, 115durability, 115EJB3 types of, 116

default type, 117MANDATORY, 116NEVER, 116NOT_SUPPORTED, 116REQUIRED, 116, 117REQUIRES_NEW, 116SUPPORTS, 116

isolation, 115transaction processing, 115–119using TestNG component, 290using transactions inside EJBs, 115why use SBs for business tier, 92

@Transient annotationentity beans, 106

transition property, @EndTask, 209transitions

Drools rules built into jBPM decision,266

transitions component, workflows, 193Travel Reservations application, 42–44

Conversation context, 166Hibernate Console reverse engineering

database, 294using themes, 236

try ... catchbean-managed transactions, 119

type propertyconversationPropagation tag, Seam, 174

type safetytypesafe enums, 17

■INDEX 347

Finditfasterathttp://superindex.apress.com

/

Page 42: JBoss AS - Springer978-1-4302-0385-8/1.pdf · JBoss AS B ecause Seam was written by those at JBoss, naturally JBoss is the application server that Seam works best with. Seam, however,

UUI component, JSF, 61–62UIComponent objects

Apply Request Values phase, JSF, 70UIViewRoot component

Restore View phase, JSF, 70Unicode Supplementary Character

Support, 12uninstaller, JBoss AS, 310@UniqueConstraint annotation

entity beans, 105unit testing, 288Update Model Values phase, JSF, 71update operation, entity manager, 112updateModelValues method, 294URLs (uniform resource locators)

adding conversationId for requestsmade, 172

configuring web.xml file for Faces, 54connection-url parameter, 313

user flow diagramTravel Reservations application, 44

user-name parametercreating datasource.xml file, 313

UserTransaction interfacebean-managed transactions, 118

V@Valid annotation, Hibernate, 154

calling validator from business tier, 155validation mechanism in Seam, 151

validateAll tag, SeamAjax4jsf creating dynamic validations,

255validation on JSF pages, 156

validateLongRange tag, JSF, 62, 71validations

@IfInvalid annotation, 151, 155Ajax4jsf creating dynamic validations,

252annotation for Seam to perform, 127entity bean with NotNull validations,

153entity beans, 184Hibernate validation framework, 151Process Validations phase, JSF, 70processValidations method, 294

Seam components, 151–157calling validator from business tier,

154–155schema generation, 157validation mechanism in Seam, 152validation on domain model, 153–154validation on JSF pages, 155–156

validator, JSF, 62calling validator from business tier,

154–155value parameter, @In, 134value parameter, @Out, 134value-change events, JSF, 65varargs, Java 5, 18–19variables

static imports, 19variant code

Locale object, java.util, 224versions

checking Java version, 12view tag, JSF

Add page, Garage Sale application, 80core taglib references, 72List page, Garage Sale application, 82

viewing pageslisting and viewing pages, 26, 37–40

viewsgetViewId method, 294MVC architecture, 9Restore View phase, JSF, 69

WWAR (Web ARchive) files

contents of, 58creating for Faces, 57–58

compiling via Ant, 57–58defining different name, 90file structure of WAR directory, 126packaging EJB3 container, 271, 273–275packaging into EAR file, 91–92Seam with Hibernate inside Java EE

container, 278, 280WAR file example, 57

web application designMVC architecture, 9–11

web applicationsfundamental component of, 23implementation patterns used in Seam,

25–40

■INDEX348

Page 43: JBoss AS - Springer978-1-4302-0385-8/1.pdf · JBoss AS B ecause Seam was written by those at JBoss, naturally JBoss is the application server that Seam works best with. Seam, however,

message-driven beans, 184presentation implementation patterns,

26rapid application development, 59sample applications, 40–45

Garage Sale application, 41ticketing system application, 44–45Travel Reservations application,

42–44servlets, 23–25

Web ARchive files see WAR (Web ARchive)files

web contextsmodule tag, 90

web frameworksconfiguration of, 51description, 10JavaServer Faces, 11message-driven beans, 101MVC architecture, 10–11Seam, 28Spring MVC, 10Struts, 10, 27Tapestry, 10validator, 62

web pages see pagesweb request

sessions, 161web resources

deploying to application servers, 57web services, 237–240

REST in Seam, 239SOAP, 238types of, 238

WEB-INF directoryconfiguring XML files for Faces, 53creating WAR file for Faces via Ant, 58creating WAR files for Faces, 57

web.xml fileadding context parameter for state

saving, 124adding listener to servlet request life

cycle, 125additions to, 284Ajax4jsf configuration, 251configuration for, 147configuring JMS listeners, 255configuring XML files for Faces, 53–54creating WAR file for Faces via Ant, 58

creating WAR files for Faces, 57filter addition for, 284maintaining long-running

conversation, 172running Seam inside Java EE container,

280SeamRemotingServlet, 241turning on Seam debugging, 146

webinf tagcreating WAR file for Faces via Ant, 58

WebLogic, BEAJSF implementations, 49

@WebRemote annotationAjax remoting call, 245excluding objects on method call, 250

websitesmultiple sessions, 166

WebSphere, IBMJSF implementations, 49

workflows, jBPMcomponents for creating process

definitions, 192–196actors, 194decision, 195end state, 196fork, 195join, 196start state, 192state, 195task nodes, 193tasks, 193transitions, 193

creating, 191–192how jBPM works, 190jBPM requirement for, 189switching process definitions, 211–213tasks and, 189

working memory, Drools rule engine, 264,265

workspaces, 172JSF integration with conversations,

175–179switching workspaces, 178viewing lists of conversations, 175–178

XXML files/configuration files

ActionForm object, Struts, 27annotations (metadata), 14

■INDEX 349

Finditfasterathttp://superindex.apress.com

/

Page 44: JBoss AS - Springer978-1-4302-0385-8/1.pdf · JBoss AS B ecause Seam was written by those at JBoss, naturally JBoss is the application server that Seam works best with. Seam, however,

configuring EJB3s for deployment,88–90

application descriptors(application.xml), 89–90

data source descriptor(persistence.xml), 88–89

EJB descriptors (ejb-jar.xml), 89configuring XML files for Faces, 52, 56

faces-config.xml, 54–56web.xml, 53–54

configuring XML in EJB3 container,271–273

components.xml, 271–272jboss-beans.xml, 272–273

contents of WAR files, 58creating datasource.xml, 312–313creating WAR file for Faces via Ant, 58creating workflows, jBPM, 191–192EJB3 annotations, 88jBPM Graphical Process Designer, 303jbpm.cfg.xml, 202log4j.xml, 314pages.xml file, 175, 179reference to resource bundle in

components.xml, 230running Seam inside Java EE container

configuring components.xml, 279configuring faces-config.xml, 279configuring hibernate.cfg.xml, 278configuring web.xml, 280

switching process definitions, 212updating, Seam configuration, 124–125

XML namespaces, 230defining themes with namespaces, 235

XML responseREST in Seam, 239

xmlns tagcore objects, 230XML namespaces, 230

■INDEX350 ■INDEX350