Spring Framework

Bean scopes (v3+)


A bean definition in Spring is actually a set of instructions of how to create the bean instance. You can control the scope of the objects created from a particular bean definition through configuration.

Out of the box, the Spring Framework supports five scopes:


  • Two general purpose scopes:


    • Singleton - Scopes a single bean definition to a single object instance per Spring IoC container

    • Prototype - Scopes a single bean definition to any number of object instances

  • And  three web scopes

    • Request - Scopes a single bean definition to the lifecycle of a single HTTP request; that is each and every HTTP request will have its own instance of a bean created off the back of a single bean definition. Only valid in the context of a web-aware Spring ApplicationContext.

    • Session - Scopes a single bean definition to the lifecycle of a HTTP Session. Only valid in the context of a web-aware Spring ApplicationContext.

    • Global Session - Scopes a single bean definition to the lifecycle of a global HTTP Session. Typically only valid when used in a portlet context. Only valid in the context of a web-aware Spring ApplicationContext.




The Singleton scope


When a bean is a singleton, only one shared instance of the bean will be managed, and all requests for beans with an id or ids matching that bean definition will result in that one specific bean instance being returned by the Spring container.

The singletone instance will be stored in a cache of singleton beans, and all requests and references for that bean will result in the cached object being returned.

Please be aware that Spring's concept of a singleton bean is quite different from the comon  Singleton pattern.

  • The scope of the Spring singleton is best described as per container and per bean.

  • The common Singleton pattern hard codes the scope of an object such that one and only one instance of a particular class will ever be created per ClassLoader.

The singleton scope is the default scope in Spring.

To define a bean as a singleton in XML, you would write configuration like so:


<bean id="accountService" class="com.foo.DefaultAccountService"/>

<!-- the following is equivalent, though redundant                -->
<!-- (singleton scope is the default); using spring-beans-2.0.dtd -->
<bean id="accountService" class="com.foo.DefaultAccountService" scope="singleton"/>

<!-- the following is equivalent and preserved for backward compatibility in spring-beans.dtd -->
<bean id="accountService" class="com.foo.DefaultAccountService" singleton="true"/>





The Prototype scope


The non-singleton, prototype scope of bean deployment results in the creation of a new bean instance every time a request for that specific bean is made (that is, it is injected into another bean or it is requested via a programmatic getBean() method call on the container).

As a rule of thumb, you should use the prototype scope for all beans that are stateful, while the singleton scope should be used for stateless beans.

Please note that a DAO would not typically be configured as a prototype, since a typical DAO would not hold any conversational state.

To define a bean as a prototype in XML, you would write configuration like so:

<!-- using spring-beans-2.0.dtd -->
<bean id="accountService" class="com.foo.DefaultAccountService" scope="prototype"/>
<!-- the following is equivalent and preserved for backward compatibility in spring-beans.dtd -->
<bean id="accountService" class="com.foo.DefaultAccountService" singleton="false"/>





Life Cycle of Prototype Bean


There is one quite important thing to be aware of when deploying a bean in the prototype scope. After the container hands it to the client, it has no further knowledge of that prototype instance. This means that destruction lifecycle callbacks will not be called. (One possible way to get the Spring container to release resources used by prototype-scoped beans is through the use of a custom bean post-processor which would hold a reference to the beans that need to be cleaned up.)




Preparing for Web Based Scopes


Web based scopes are namely:
  • request
  • session
  • global session




Web Based Scopes Containers


The web based scopes are only available if you are using a web-aware Spring ApplicationContext, such as XmlWebApplicationContext. If you try using web based scopes with regular Spring IoC containers, such as the XmlBeanFactory or ClassPathXmlApplicationContext, you will get an IllegalStateException complaining about an unknown bean scope.




Using the Spring Web MVC

If you are accessing scoped beans within Spring Web MVC, i.e. within a request that is processed by the Spring DispatcherServlet, or DispatcherPortlet, then no special setup is necessary: DispatcherServlet and DispatcherPortlet already expose all relevant state.




Using the Servlet 2.4+ web container

When using a Servlet 2.4+ web container, with requests processed outside of Spring's DispatcherServlet, you need to add the following javax.servlet.ServletRequestListener to the declarations in your web application's 'web.xml' file.

<web-app>
  ...
  <listener>
    <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class>
  </listener>
  ...
</web-app>





Using the Servlet 2.3- web container


If you are using an older web container (Servlet 2.3), you will need to use the provided javax.servlet.Filter implementation. (The filter mapping depends on the surrounding web application configuration and so you will have to change it as appropriate.)

<web-app>
  ..
  <filter>
    <filter-name>requestContextFilter</filter-name>
    <filter-class>org.springframework.web.filter.RequestContextFilter</filter-class>
  </filter>
  <filter-mapping>
    <filter-name>requestContextFilter</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
  ...




</web-app>





Web-Based Scopes Configuration Summary


DispatcherServlet, RequestContextListener and RequestContextFilter all do exactly the same thing, namely bind the HTTP request object to the Thread that is servicing that request. This makes beans that are request- and session-scoped available further down the call chain.




The Request scope



Prerequisites


First read the section "Preparing for web-based scopes"



Details


Consider the following bean definition:

<bean id="loginAction" class="com.foo.LoginAction" scope="request"/>




With the above bean definition, the Spring container will create a brand new instance of the LoginAction bean for each and every HTTP request. That is, the 'loginAction' bean will be effectively scoped at the HTTP request level. When the request is finished processing, the bean that is scoped to the request will be discarded.




The Session scope



Prerequisites


First read the section "Preparing for web-based scopes"



Details


<bean id="userPreferences" class="com.foo.UserPreferences" scope="session"/>




The Spring container will create a brand new instance of the UserPreferences bean for the lifetime of a single HTTP Session. In other words, the 'userPreferences' bean will be effectively scoped at the HTTP Session level. When the HTTP Session is eventually discarded, the bean that is scoped to that particular HTTP Session will also be discarded.




The Global Session scope



Prerequisites


First read the section "Preparing for web-based scopes"



Details




Consider the following bean definition:

<bean id="userPreferences" class="com.foo.UserPreferences" scope="globalSession"/>


The global session scope is similar to the standard HTTP Session scope, and really only makes sense in the context of portlet-based web applications. The portlet specification defines the notion of a global Session that is shared amongst all of the various portlets. Beans defined at the global session scope are scoped to the lifetime of the global portlet Session.




Scoped Beans As Dependencies


One of the main value-adds of the Spring IoC container is that it manages not only the instantiation of your objects (beans), but also the wiring-up of collaborators (or dependencies). If you want to inject a (for example) HTTP request scoped bean into another bean, you will need to inject an AOP proxy in place of the scoped bean (See the proxy design pattern).


Let's look at the configuration that is required to effect this:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
           http://www.springframework.org/schema/aop
           http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">

    <!-- a HTTP Session-scoped bean exposed as a proxy -->
    <bean id="userPreferences" class="com.foo.UserPreferences" scope="session">
       
          <!-- this next element effects the proxying of the surrounding bean -->
          <aop:scoped-proxy/>
    </bean>

    <!-- a singleton-scoped bean injected with a proxy to the above bean -->
    <bean id="userService" class="com.foo.SimpleUserService">

        <!-- a reference to the proxied 'userPreferences' bean -->
        <property name="userPreferences" ref="userPreferences"/>

    </bean>
</beans>


To create such a proxy, you need only to insert a child <aop:scoped-proxy/> element into a scoped bean definition (you may also need the CGLIB library on your classpath so that the container can effect class-based proxying).

The singleton bean 'userManager' is being injected with a reference to the HTTP Session-scoped bean 'userPreferences'. What we want is a single 'userManager' object, and then, for the lifetime of a HTTP Session, we want to see and use a 'userPreferences' object that is specific to said HTTP Session.

In the case of this example, when a UserManager instance invokes a method on the dependency-injected UserPreferences object, it is really invoking a method on the proxy... the proxy will then fetch the real UserPreferences object from (in this case) the HTTP Session, and delegate the method invocation onto the retrieved real UserPreferences object.




Choosing the type of proxy created


By default, when the Spring container is creating a proxy for a bean that is marked up with the <aop:scoped-proxy/> element, a CGLIB-based class proxy will be created. This means that you need to have the CGLIB library on the classpath of your application.

Note: CGLIB proxies will only intercept public method calls! Do not call non-public methods on such a proxy; they will not be delegated to the scoped target object.

You can choose to have the Spring container create 'standard' JDK interface-based proxies for such scoped beans by specifying 'false' for the value of the 'proxy-target-class' attribute of the <aop:scoped-proxy/> element. Using JDK interface-based proxies does mean that you don't need any additional libraries on your application's classpath to effect such proxying, but it does mean that the class of the scoped bean must implement at least one interface, and all of the collaborators into which the scoped bean is injected must be referencing the bean via one of its interfaces.




Custom scopes


As of Spring 2.0, the bean scoping mechanism in Spring is extensible. This means that you are not limited to just the bean scopes that Spring provides out of the box; you can define your own scopes, or even redefine the existing scopes (although that last one would probably be considered bad practice - please note that you cannot override the built-in singleton and prototype scopes).




Creating your own custom scope


Scopes are defined by the org.springframework.beans.factory.config.Scope interface. This is the interface that you will need to implement in order to integrate your own custom scope(s) into the Spring container. You may wish to look at the Scope implementations that are supplied with the Spring Framework itself for an idea of how to go about implementing your own. The Scope Javadoc explains the main class to implement when you need your own scope in more detail too.

The Scope interface has four methods dealing with getting objects from the scope, removing them from the scope and allowing them to be 'destroyed' if needed.

The first method should return the object from the underlying scope. The session scope implementation for example will return the session-scoped bean (and if it does not exist, return a new instance of the bean, after having bound it to the session for future reference).

Object get(String name, ObjectFactory objectFactory)



The second method should remove the object from the underlying scope. The session scope implementation for example, removes the session-scoped bean from the underlying session. The object should be returned (you are allowed to return null if the object with the specified name wasn't found)

Object remove(String name)



The third method is used to register callbacks the scope should execute when it is destroyed or when the specified object in the scope is destroyed. Please refer to the Javadoc or a Spring scope implementation for more information on destruction callbacks.

void registerDestructionCallback(String name, Runnable destructionCallback)



The last method deals with obtaining the conversation identifier for the underlying scope. This identifier is different for each scope. For a session for example, this can be the session identifier.

String getConversationId()





Using a custom scope

You need to make the Spring container aware of your new scope(s). The central method to register a new Scope with the Spring container is declared on the ConfigurableBeanFactory interface (implemented by most of the concrete BeanFactory implementations that ship with Spring); this central method is displayed below:

void registerScope(String scopeName, Scope scope);



The first argument to the registerScope(..) method is the unique name associated with a scope; examples of such names in the Spring container itself are 'singleton' and 'prototype'. The second argument to the registerScope(..) method is an actual instance of the custom Scope implementation that you wish to register and use.

Let's assume that you have written your own custom Scope implementation, and you have registered it like so:

// note: the ThreadScope class does not ship with the Spring Framework
Scope customScope = new ThreadScope();
beanFactory.registerScope("thread", customScope);



You can then create bean definitions that adhere to the scoping rules of your custom Scope like so:

<bean id="..." class="..." scope="thread"/>



If you have your own custom Scope implementation(s), you are not just limited to only programmatic registration of the custom scope(s). You can also do the Scope registration declaratively, using the CustomScopeConfigurer class.

The declarative registration of custom Scope implementations using the CustomScopeConfigurer class is shown below:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:aop="http://www.springframework.org/schema/aop"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
           http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
           http://www.springframework.org/schema/aop
           http://www.springframework.org/schema/aop/spring-aop-3.0.xsd">

    <bean class="org.springframework.beans.factory.config.CustomScopeConfigurer">
        <property name="scopes">
            <map>
                <entry key="thread">
                    <bean class="com.foo.ThreadScope"/>
                </entry>
            </map>
        </property>
    </bean>

    <bean id="bar" class="x.y.Bar" scope="thread">
        <property name="name" value="Rick"/>
        <aop:scoped-proxy/>
    </bean>

    <bean id="foo" class="x.y.Foo">
        <property name="bar" ref="bar"/>
    </bean>

</beans>

Note: Note that, when placing a <aop:scoped-proxy/> in a FactoryBean implementation, it is the factory bean itself that is scoped, not the object returned from getObject().

Design Patterns

Behavioral Design Patterns

Template method


Defines the program skeleton of an algorithm in a method. This method is called template method

  • The method defers some steps to subclasses
  • It lets one redefine certain steps of an algorithm without changing the algorithm's structure.

  • Subclasses that override the template method implement and/or override one or more of the algorithm steps, differing behaviors while ensuring that the overarching algorithm is still followed.
  • In object-oriented programming, first an abstract (See abstract classsuper-class is defined that provides the basic steps of an algorithm. These steps are implemented using abstract methods. Later on, subclasses change the abstract methods to implement real actions. Thus the general algorithm is saved in one place (the abstract superclass) but the concrete steps may be changed by the subclasses.



User Interface Design Patterns


MVC


MVC is a design pattern that divides an application into three major areas:

  • Model component - Data-model components. For example, if an application deals with Business Data, a model is all the application objects that deals with business data and represents a Business Model of that data.

  • View component - Display media components for the end user. If, for example, the application is a web application, the view may be represented by an "html", "jsp", "jspx", "xhtml" etc.

  • Controller component - Controller components controls an application flow and navigation. For example, a controller may check if a request comes from a login-page, and according to a requested operation may navigate a user to home screen if a login operation was successful, or back to the login-page if a login operation failed.

Dividing an application to three MVC major areas eases the developement of the code, because each of these areas use different application resources, while still making it easy to maintain and manage each area separately. Each area needs to interact with the two other areas, and thus each area provides specific interaction / access / entry points to work with.





Web Design Patterns




Conversation Scope



The Need


Often a user operation consists of multiple requests to the server. Take for example the case of a wizard that spans multiple web pages. Data need to be stored on the server throughout the wizard operation. On the end of the wizard operation, (when a "Save" or "Finish" button is pressed) the data need to be discarded.

This scenario is called a conversation because what actually happens is a conversation between the user (the client) and the server, that starts from the first screen of the wizard (in our example) and ends on the last screen.




The problem


Traditional application servers and web programming languages provide only three scopes for data to be stored in:
  • Application scopeApplication scope is only rarely in use. The data that it stores is shared between all users of a web application.
  • Request scopeRequest scope is in very common use and stores data only for a specific request. All data that is stored in a request scope is discarded at the end of each request (after the response is sent).
  • Session scope - Session scope is also in common use. It stores data throughout a specific session. One may think that a session scope can be used in a conversation, but actually it suffers from a number of issues:
    • Discarding all to a conversation specific data - is a difficult task to do when using a session scope, and thus may cause memory leaks.
    • session is typically shared across all tabs and all windows of a web browser - A session is usually tracked using cookies. Because all windows associated with the same browser share cookies, they are considered to be within the same "session". If two windows are created for the same session then very strange effects can be caused due to the same "backing beans" being used by the two windows.
    • Initializing a new conversation - when a user wants to start a new conversation of the same type it is usually better for the server objects to be initialized, rather than having whatever state they had on the previous pass. This is difficult to achieve in a session scope.




The Solution


There are many frameworks that provide a native use of conversational scopes.
  • Mojarra JSF2
  • Java CDI
  • Spring Custom Bean Scope
  • Apache Orchestra




GRASP Patterns (object-oriented design)


General Responsibility Assignment Software Patterns (or Principles), abbreviated GRASP, consists of guidelines for assigning responsibility to classes and objects in object-oriented design.

The patterns on this category answer some software problem, and in almost every case these problems are common to almost every software development project.

The different patterns and principles used in GRASP are: Controller, Creator, Indirection, Information Expert, High Cohesion, Low Coupling, Polymorphism, Protected Variations, and Pure Fabrication.




Controller (See also: Model–view–controller [MVC])


The Controller pattern assigns the responsibility of dealing with system events to a non-UI class that represents the overall system or a use case scenario.




Creator (See also: Factory pattern)


Responsible for creating an object of class




Indirection (See also: Delegation pattern)


Supports low coupling between two elements by assigning the responsibility of mediation between them to an intermediate object. An example of this is the controller component for mediation between data (model) and its representation (view) in the Model-view-controller pattern.




Information Expert (See also: Information hiding, Expert or Expert Principle)


Used to determine where to delegate responsibilities. These responsibilities include methods, computed fields, and so on.




High Cohesion


This pattern attempts to keep objects appropriately focused, manageable and understandable. Breaking programs into classes and subsystems is an example of activities that increase the cohesive properties of a system.




Low Coupling (See also: Loose coupling)


This pattern dictates how to assign responsibilities to support:
  • Lower dependency between the classes
  • Change in one class having lower impact on other classes
  • Higher reuse potential.




Polymorphism


Responsibility of defining the variation of behaviors are based on the type.




Protected Variations (See also: Delegation pattern)


Protects elements from the variations on other elements (objects, systems, subsystems) by wrapping the focus of instability with an interface and using polymorphism to create various implementations of this interface.




Pure Fabrication (See also: Service [systems architecture])


A Pure Fabrication is a class that is specially made up to achieve low coupling, high cohesion, and the reuse potential thereof derived.

This kind of class is called "Service" in Domain-driven design.




PrettyFaces

Download for JSF2 .x

You can download the latest version from maven central repository: http://search.maven.org/.

  • GroupId: com.ocpsoft
  • ArtifactId: prettyfaces-jsf2

Configure PrettyFaces in web.xml

<filter>
    <filter-name>Pretty Filter</filter-name>
    <filter-class>com.ocpsoft.pretty.PrettyFilter</filter-class>
</filter>

<filter-mapping>
    <filter-name>Pretty Filter</filter-name>
    <url-pattern>/*</url-pattern>
    <dispatcher>FORWARD</dispatcher>
    <dispatcher>REQUEST</dispatcher>
    <dispatcher>ERROR</dispatcher>
</filter-mapping>




PrettyFaces Development Mode

PrettyFaces is capable of reloading its configuration on a regular basis. As the configuration reloading may be a time consuming process for large applications, PrettyFaces reloads its configuration only if the application is executed in development mode.
To enable the development mode, add the following context parameter to your web.xml:
<context-param>
  <param-name>com.ocpsoft.pretty.DEVELOPMENT</param-name>
  <param-value>true</param-value>
</context-param>
If your are using the JSF 2.0 version of PrettyFaces, you typically won't have to explicitly enable the development mode. In this case the development mode is automatically enabled for all project stages except for Production.






Annotation based configuration

Recently PrettyFaces added support to configure URL mappings via annotations. This feature is primarily intended for people who don't want to maintain a separate XML configuration file for the mappings and instead prefer to declare them directly on the affected classes.

Basic setup

PrettyFaces supports configuration via annotations out of the box. Nevertheless it is strongly recommended to manually specify the java packages that contain your annotated classes. In this case the annotation scanner isn't required to scan the complete classpath, which might be a performance problem when you have many dependencies.
You can specify the packages to scan for annotations by adding a comma-separated list of packages to your web.xml:
<context-param>
   <param-name>com.ocpsoft.pretty.BASE_PACKAGES</param-name>
   <param-value>com.example.myapp,com.ocpsoft</param-value>
</context-param>
PrettyFaces will scan these packages recursively. So typically you will only have to add the top-level package of your web application here.
If you don't want to use PrettyFaces annotations at all, you can completely disable the annotation scanning by setting the package configuration parameter to none.
<context-param>
   <param-name>com.ocpsoft.pretty.BASE_PACKAGES</param-name>
   <param-value>none</param-value>
</context-param>
In the default configuration PrettyFaces will only scan for annotations in the /WEB-INF/classes directory of your web application. If you want the JAR files in /WEB-INF/lib to be scanned as well, add the following entry to your web.xml:
<context-param>
   <param-name>com.ocpsoft.pretty.SCAN_LIB_DIRECTORY</param-name>
   <param-value>true</param-value>
</context-param>

JBoss Seam

Preface

Seam is a web application framework.




Seam Successor


Seam Successor is a project called Apache DeltaSpike.




Seam 3

Note: Seam sources on Github (https://github.com/seam) are not updated since September 2012. Active development of Seam 3 has been halted by Red Hat.


Seam 3 provides a set of extensions that can be plugged to a Java application through the CDI programming model. Seam's mission is to provide a fully integrated development platform for building rich internet applications (RIA), standards-based Internet applications tailored for traditional and cloud deployments. Seam 3 is intended to be a more scalable, feature rich set of extensions than Seam 2, which is under maintenance development only.


Seam 2

Seam 2 combines the two frameworks of Enterprise JavaBeans (EJB3) and JavaServer Faces (JSF). However, simple POJOs can be used at the back end. One can turn any EJB3 object or any simple POJO object into a Seam component by just using annotations. Once a component becomes a Seam component, it can be accessed through JSF or through other business-logic components in a unified manner. Thus, one can access any back-end EJB component from the front-end by addressing it by its Seam component name. The beauty of this Java web framework is that it incorporates much-needed identity management features.

Seam 2 introduces the concept of bijection, taken from Spring's dependency injection feature where objects can be in-jected or out-jected to/from assigned variables using the @In and @Out annotations.


The framework also expands the concept of contexts. Each Seam component exists within a context. The default Seam context, a conversation, can span multiple pages and usually spans the whole business flow, from start to finish. The session context captures all actions of a user until he/she logs out or closes the browser - even across multiple uses of the browser back-button.


One can automatically generate a CRUD (create-read-update-delete) web-application from an existing database using the command-line tool seam-gen supplied with the framework.


Seam facilitates WYSIWYG development through the use of JBoss Tools, a set of plug-ins targeted at the open-source Eclipse integrated development environment.


Seam integrates out of the box with the RichFaces and ICEfaces Ajax libraries, as well as with many other Ajax libraries - without the need to write JavaScript code.


Seam also includes a PDF document creator, e-mailing, graph creation, and the creation of Microsoft Excel worksheets.

Microsoft SQL Server Management Studio 10

How To Search for objects (Version 10)

  • In the "Object Explorer" (F8) window select the database to search
  • Open the "Object Explorer Details" (F7) window
  • On the search box enter the search term. It accepts standard wildcard characters.


How To Show Line Numbers (Version 10)

Click "Tools" -> "Options" -> "TextEditor" -> "All Languages"-> "General" -> "Display" -> "Line Numbers" check box.

Apache MyFaces Orchestra

Introduction

Orchestra eases the development of applications that perform a lot of persistence (ie are strongly coupled with a database). It provides the following features:
  • A conversation (aka dialog) scope for beans
  • Conversation-scope persistence contexts. This fixes the dreaded LazyInitializationException or NonUniqueObjectException problems when working with persistent objects.
  • Declarative transaction annotations
  • A "dynaForm" JSF component that helps create forms for editing persistent data.

Supported Web Presentation Frameworks

Orchestra currently supports JSF1.1, JSF1.2 and JSF2.0.

Supported JDKs

Orchestra is JDK 1.5 compatible, because JDK 1.4 has reached its End of Life. For use in JDK 1.4 please use 1.3.1 artifacts.

Dependencies

Orchestra requires Spring 2.x to declare managed beans that will be stored in conversation context.

Highlights

  • Orchestra uses Spring to configure an Orchestra "conversation" scope. You can declare a JSF Managed bean in Spring using this scope, then when that bean is referenced from a JSF EL expression it is automatically created within that conversation scope.

A small JSF example

Here's a quick demonstration of Orchestra's main features:

  • First, we use the Spring Framework to configure a conversation-scoped bean.

<bean name="ballotTopic"
   class="org.apache.myfaces.examples.ballot.backings.BallotTopic"
   scope="conversation.access"/>


We wired the conversational scope to Orchestra, so that the bean named "ballotTopic" will support JSF features - it defines properties, methods and event-listeners as usual managed-beans do.


  • We define a JSF action-method as requiring a transaction with the @Transactional annotation. with this, a commit will be executed at the end of the method. When the conversation needs to be closed again, close it by calling the invalidate method on the current conversational instance.
@Transactional
public String saveAction() {
  topic.setOwner(getVoterDao().getByKey(getBallotState().getVoterId()));
  topicDao.save(topic);
  Conversation.getCurrentInstance().invalidate();
  return "success";
}

The developer keeps on defining DAO's as she is used to do - here is a simple example using the JPA-syntax with an injected EntityManager.
public class VoterDao {
  @PersistenceContext
  private EntityManager entityManager;
  public Voter getByKey(Long id) {
    return entityManager.find(Voter.class, id);
  }
}


Dictionary

7z Compression

7z is a compressed archive file format that supports several different data compression, encryption and pre-processing algorithms.

Apache Xerces

Apache Xerces (Xerces) is a processor for parsing, validating, serializing and manipulating XML documents, written in Java.

API (Application Programming Interface)

See "Application Programming Interface"

Application Programming Interface (API)

An API is a description of the means to communicate with a software. For examples, the accessible methods and fields of a class or object, the web-service request client that is to be sent to a service, the command line arguments of a program, etcetera.

ar Archive

The archiver (as), is a Unix utility that maintains groups of files as a single archive file. It has been largely replaced by tar.

ARJ Compression

ARJ (Archived by Robert Jung) is a software tool for creating high-efficiency compressed file archives. ARJ supports 16-bit32-bit and 64-bit Intel architectures.

Annotation

An annotation is metadata attached to text, image, or other data. In the Java programming language annotations can be used as a metadata in the source code. The compiler may embed the annotations in the class files and thus influence the run-time behavior of an application. It is possible to create meta-annotations out of the existing ones in Java.

Checked Exception

In a programming language a checked exception is a type of exception that is predicted by the programmer, and must be caught and handled by other programmers who use the code written by the former programmer.

See also "Unchecked Exceptions".

CDI (Context and Dependency Injection)

Contexts and Dependency Injection (CDI) (JSR 299) for the Java EE platform is a feature that help to knit together the web tier and the transactional tier of the Java EE platformCDI is a set of services that, used together, make it easy for developers to use enterprise beans along with JavaServer Faces technology in web applications. Designed for use with stateful objectsCDI also has many broader uses, allowing developers a great deal of flexibility to integrate various kinds of components in a loosely coupled but typesafe way.

Client-Side

In programming a client-side is the side that request and receive services. A classic example is a web browser, which is a client-side program that request for web pages from a web server, addressing it through a URL.

Client-side component

client-side component is a software component that runs on the client-side and represents some data and/or logic.

Comma-Seperated-Values Format

See "CSV File Format"

Component (Software)

See "Software Component".

Controller Component

Controller Component is a software component that controls the flow of an application, and in most cases delegates between model component/s and view component/s.

Conversation Scope

The conversation scope holds the state associated with a user of the system for multiple requests to the server, but unlike the session scope, the conversation scope:

  • Is demarcated explicitly by the application
  • holds state associated with a particular web browser tab in a web application (browsers tend to share session info between tabs)
  • Represents a task - a unit of work.

cpio Archive

cpio is a file archiver utility and its associated file format. It is primarily installed on Unix-like computer operating systems. The software utility was originally intended as a tape archiving program.
The use of cpio is mainly by by the RPM Package Manager and in Apple Computer's Installer (pax).

CRUD (CReate, Update, Delete)

CRUD is a shortcut that describes database operations:
  • CR - Create - Insert new rows in the database
  • U - Update existing rows in the database
  • D - Delete rows from the database

CSV File Format

CSV File is a file that holds data in a comma-seperated-values (csv) format. For example, a file that holds student id and student grade
01234567,92
21648754,98
etc...

CSV Format

See "CSV File Format"

Database

database is a collection of data that is organized to model relevant aspects of reality in a way that supports processes requiring this information. Computer programs that deal with data need a way to identify and analyze it, and database eases this process. Lets take for example a computer program for ordering hotel rooms. After modeling the data we can collect it to databases and deal with objects that are closer to reality (room, reservation, guest, person etc...).

Design Pattern

The actual code and building blocks that an application is built from is very dependent on the architects, designers and developers that work on it and do the actual programing. Each of them has its own style, has different experience and attitudes. Nevertheless, applications are always built from the same building blocks and deals with the same issues such as:

  • How to handle resources
  • How to access a data store
  • How to write a web application
  • How to write services
  • and so forth


To answer these issues the Design patterns come to aid. They consist of application and/or code Patterns that give solutions to many of the issues that are raised during the process of development.

There are a lot of design patterns that ranges many development aspects. It is important to get to know, at least some common design patterns, since during development a developer/architect may choose to use and implement them, sometimes without even knowing it.

Dynamic Content

A content that is prepared according to some processing of data. The term dynamic content is often used in web applications, when we want to say that a content of a page or site changes according to some processing that happens on the server side.

Easy Entity Auditing (Envers)

See "Envers"

Enterprise JavaBeans

Enterprise JavaBeans (EJB) is a managed, server-side component architecture for modular construction of enterprise applications. It is a server-side model that encapsulates the business logic of an application. The EJB specification intends to provide a standard way to implement the back-end 'business' code typically found in enterprise applications. Enterprise JavaBeans are intended to handle such common concerns as persistence, transactional integrity, and security in a standard way.

Envers (Easy Entity Auditing)

Announcement: From Hibernate 3.5, Envers is included as a Hibernate core module.

The Envers (Easy Entity Auditing) project aims to enable easy auditing/versioning of persistent classes.

eXtensible Markup Language (XML)

See "XML Format".

Forward

See "URL forwarding".

Getter Method

A Getter Method is a method that conforms to a specific signature, that makes it possible to different frameworks and infrastructure code access it through a Reflection API.

Git

Git is a distributed revision control and source code management (SCM) system with an emphasis on speed. Every Git working directory is a full-fledged repository with complete history and full version tracking capabilities, not dependent on network access or a central server. Git is free software distributed under the terms of the GNU General Public License version 2.

GitHub

GitHub is a web-based hosting service for software development projects that use the Git revision control system. GitHub offers both paid plans for private repositories, and free accounts for open source projects. As of May 2011, GitHub was the most popular code repository site for open source projects.

Google Trends

Google Trends is a public web facility of Google Inc., based on Google Search, that shows how often a particular search-term is entered relative to the total search-volume across various regions of the world, and in various languages.

Global Exceptions

See "Unchecked Exceptions".

GRASP (General Responsibility Assignment Software Patterns)

Consists of guidelines for assigning responsibility to classes and objects in object-oriented design.

HTML (Hyper Text Markup Language)

HTML is a protocol for transferring data between machines, that contains more than text, such as images, links, layouts and more. It is the most used and the dominant protocol for writing web pages.

HTTP (Hyper Text Transfer Protocol)

HTTP is an application protocol for distributed, collaborative, hypermedia information systems. HTTP is the foundation of data communication for the World Wide Web.

Hypertext is structured text that uses logical links (hyperlinks) between nodes containing text. HTTP is the protocol to exchange or transfer hypertext.

Hyperlink

hyperlink is:

  • A reference to data that the reader can directly follow either by clicking or by hovering or that is followed automatically.
  • hyperlink points to a whole document or to a specific element within a document.
  • Hypertext is text with hyperlinks.


Hypermedia

Hypermedia, an extension of the term hypertext, is a medium of information which includes graphics, audio, video, plain text and hyperlinks.

Hypertext

Hypertext is structured text that uses logical links (hyperlinks) between nodes containing text. HTTP is the protocol to exchange or transfer hypertext.

Hyper Text Markup Language (HTML)

See "HTML".

Hyper Text Transfer Protocol (HTTP)

See "HTTP".

Java Beans

Java Beans are instances of a class in the Java language that have getter methods and setter methods, and can be treated as reusable components. The getter methods and setter methods represent properties of a java class and the value of the getter and setter methods represent the bean state. They are usually accessed through the Java Reflection API.

Java EE platform

Java Enterprise Edition Platform (Java EE) is a Java computing platform. It is the nickname for Java advanced technologies.

JavaServer Faces

JavaServer Faces (JSF) is a user interface framework for building Java-based web applications - a framework for developing web applications, and wiring their client-side user interface components with server-side components.

Java Logging APIs

The Java Logging APIs, introduced in package java.util.logging, facilitate software servicing and maintenance by producing log reports.

Java Persistence API (JPA)

The Java Persistence API (JPA) is a Java specification which describes how relational data is managed in applications using the Java Platform.

Persistence in this context is comprised of three areas:
  • The API itself - defined in the javax.persistence package
  • The Java Persistence Query Language (JPQL) - makes queries against entities stored in a relational database. Queries resemble SQL queries in syntax, but operate against entity objects rather than directly with database tables
  • Object/relational metadata.

Java Server Pages

See "JSP".

JAX Conference

The JAX Conference is a Java event for all developers. It welcomes some of the world’s leading Java experts, thinkers and practitioners to share their craft and mastery secrets. It is a deep-dive for the modern Java developer - and it’s FREE for all.

The main concept of the conference is that community is what keeps Java evolving. The JAXConf extends the tradition of collaboration and open access from the internet to a real location - a place to meet and learn learn. JAXConf aims to be the largest free Java gathering anywhere.

JSF (JavaServer Faces)

See "JavaServer Faces"

JXCSS (Java SAX-generating CSS2 parser)

JXCSS is a Java SAX-generating CSS2 parser adapter that is used to instrument or refactor existing CSS stylesheets and also to generate new ones. JXCSS can use any SAC-compliant CSS2 parser. As the parser processes a stylesheet, JXCSS generates SAX events that model the stylesheet's deep structure. JXCSS can be connected to any SAX content handler, such as an XSLT or STX transformation. JXCSS supports several CSS2 parsers: Batik 1.6-1, Steady State 0.9.5 and Flute 1.3.

JBoss

JBoss is a division of Red Hat, Inc., that specializes in writing and supporting open-source middleware software. The JBoss organization profits from a service-based business model. JBoss employs a professional open-source business model where the core developers of projects make a living and offer their services. A network of programmers develops and supports JBoss as an open-source project.

Jolt Awards

The Jolt Awards are awards in the software industry. The Dr. Dobb's Jolt Product Excellence & Productivity Awards are presented annually to showcase products that have "jolted" the industry with their significance and made the task of creating software faster, easier, and more efficient.

JSP (Java Server Pages)

It is a scripting language in the Java Programming Language for developing web pages.

log4j

Apache log4j is a logging library for Java. It is also part of a project which is known as Apache Logging.

Lempel–Ziv–Markov Chain Compression Algorithm (LZMA)

The Lempel–Ziv–Markov chain algorithm (LZMA) is a lossless data compression algorithm. It was first used in the 7z format of the 7-Zip archiver. This algorithm uses a dictionary compression scheme and features a high compression ratio while still maintaining decompression speed similar to other commonly used compression algorithms.

LZMA (Lempel–ziv–markov chain compression algorithm) Compression Algorithm

See "Lempel–Ziv–Markov Chain Compression Algorithm".

Model Component

Model Component is a software component that represent a data model or a piece of it in a software application.

Model-View-Conroller (MVC)

(section: design-patterns)

Model-View-Conroller (MVC) is a user interface design pattern that divides the code into three major areas: Model ComponentsView Components, and Controller Components.

MVC

See "Model-View-Controller".

Office Open XML

Office Open XML (OOXML / OpenXML) is a zipped, XML-based file format for representing spreadsheets, charts, presentations and word processing documents. Starting with Microsoft Office 2007, the Office Open XML file formats have become the default target file format of Microsoft Office.


Object-relational mapping (ORM)

Object-relational mapping (ORM) is a programming technique for manipulating and converting data between some sort of data store (database, xml, xls, csv, flat-file etc...) and the programming-language objects. Frameworks that implement this technique deal with translating the logical representation of the objects into an atomized form that is capable of being stored on the data-store, while somehow preserving the properties of the objects and their relationships so that they can be reloaded as an object when needed.

If this storage and retrieval functionality is implemented, the objects are then said to be persistent.

ORM (Object-relational mapping)

See "Object-relational mapping (ORM)"

OSGI

The OSGi framework implements a dynamic component model, in which applications or components (coming in the form of bundles for deployment) can be remotely installed, started, stopped, updated, and uninstalled without requiring a reboot.

Pack200 Compression

Pack200 (JSR 200) is an HTTP compression method for faster JAR file transfer speeds over the network. Application of this technology includes Java application deployment over Java Web Start.

Persistence

Persistence refers to the ability of managing a state that outlives the process that created it. This can be achieved by storing the state as data in non-volatile storage such as a hard drive or flash memory. E.g. word processors achieve state persistence by saving their documents to files.

POJO (Plain Old Java Object)

POJO is an acronym for Plain Old Java Object. The name is used to emphasize that a given object is an ordinary Java Object, not a special object.

Ideally speaking, a POJO object is only bound by the restrictions forced by the Java Language Specification. However, many frameworks use this term in order to emphasize how simple it is to make a POJO object work with the framework.

RDBMS (Relational Database Management System)

See "Relational Database Management System (RDBMS)"

Red Hat

Red Hat, Inc. company is engaged in providing open-source software products to the enterprise community. Its name is associated to a large extent with its enterprise operating system Red Hat Enterprise Linux and with the open-source enterprise middleware vendor JBoss.

Red Hat creates, maintains, and contributes to many free software projects. As of June 2013, Red Hat is the largest corporate contributor to Linux.

Relational Database Management System (RDBMS)

An RDMS is a database management system that represents the data that is stored in it as tables and relationships between the tables.

Reusable Components

Reusable components are components that conform to a specification and can be access and managed through application frameworks and infrastructure code.

Reflection API

Reflection API is an API that has the ability to introspect into objects and modify them on runtime.

Rendering Engine

A Rendering Engine is an application that displays user-interface data, such as layout, images, graphics, colors and more.

Rich Internet Application (RIA) 

Rich Internet application (RIA) is a web application that has many of the characteristics of desktop application software. It is very common for an RIA to use browser plug-ins, such as Adobe FlashJavaFX, and Microsoft Silverlight. As of September 2012 Google trends shows that plug-ins based frameworks are in the process of being replaced by HTML5/JavaScript based alternatives.

Run-time (Runtime)

Runtime is the phase when the application is already running, in contrast with compile-time (the phase when the application is compiled and/or built [before runtime]).

Scripting Language

A scripting language is a language that is interpreted (rather than compiled) at runtime.

Server-Side

In programming a server-side is the side that hosts services to programs that request for it. A classic example is a web server, which is a server-side program that hosts web pages to web clients, typically addressed through a web-browser.

Server-side component

server-side component is a software component that runs on the server and represents some data and/or logic.

Servlet (Java Servlet)

Servlet is a Java programming language class used to extend the capabilities of a server. Although servlets can respond to any types of requests, they are commonly used to extend the applications hosted by web servers.

Setter Method

Setter Method is a method that conforms to a specific signature, that makes it possible to different frameworks and infrastructure code access it through a Reflection API.

Software Component

A Software Component is a piece of code that has defined activities and is a part of a bigger software application.

Software Framework

See "software infrastructure".

Software Infrastructure

software infrastructure is a collection of software components that together create an infrastructure for one or both of the following:

  • Other frameworks may be plugged to the infrastructure in order to enrich it.
  • Custom application code may be written on top of the infrastructure to supply custom functionality.
A Software Infrastructure is also known as "Software Frameworks" and the two terms are used interchangeably.

Spring Framework

Spring Framework is an open source application framework and inversion of control container for the Java platform.

The core features of the Spring Framework can be used by any Java application, but there are extensions for building web applications on top of the Java EE platform. Although the Spring Framework does not impose any specific programming model, it has become popular in the Java community as an alternative to, replacement for, or even addition to the Enterprise JavaBean (EJB) model.

State

A State is represented by the collection of values of all the properties of an item in focus. The item in focus may be an object, application etc...

Software Component

Component is a piece of code that encapsulates some data and/or logic. E.g.:

  • Server side component - is application code that runs on the server and represents some data and/or logic.
  • Client-side component - is application code that runs on the server and represents some data and/or logic.

Super Class

When we extend a class, the class that is extended is the super-class. That class that extends the super-class is called a sub-class.

Unchecked Exceptions

In programming languages, an unchecked exception is a type of exception that is not predicted by the programmer, and if not properly caught by the programmer it can lead to unpredicted results and usually breaks the program flow and execution.

See also "Checked Exception"

Uniform Resource Identifier (URI)

See URI.

Uniform Resource Locator (URL)

See URL.

URI (Uniform Resource Identifier)

A Uniform Resource Identifier (URI) is a string of characters used to identify a name of a web resource. Such identification enables interaction with representations of the web resource over a network, typically the World Wide Web, using specific protocols. The most common form of URI is the uniform resource locator (URL), frequently referred to informally as a web address.

URL (Uniform Resource Locator)

Uniform Resource Locator (aka. URLWeb Address), is a string that references to a resource. An example of a typical URL would be "http://ejbas.blogspot.com". A URL is technically a type of uniform resource identifier (URI), but in many technical documents and verbal discussions, URL is often used as a synonym for URI, and this is not considered a problem. URLs are commonly used for web pages (http), but can also be used for file transfer (ftp), email (mailto) and many other applications.

URL Forwarding

When a request from the client is being forwarded, it means that the response that the server will send to the client will be rendered as if a different request was made to the server.

When a request is reached on the server, the server has a set of rules that according to them the response is rendered. For example, a request to an HTML page will render a response of that same HTML page on the server. But instead, the server can catch the request and forward it to another URL, and therefore another response will be sent to the client

User Interface Component

See "client-side component".

View Component

View Component is a software component that represent the view part of a software application.

Velocity

Velocity is a java scripting language that is aimed to keep a clean separation between the presentation layer and the other layers of an application.

Web Application

Application that uses the web platform and viewed by end-users on a web browser. A web application uses the HTML web protocol to transfer hypermedia data.

"web.xml" File

A "web.xml" File file is typically a deployment descriptor for the application.

Deployment Descriptor (DD)

A deployment descriptor (DD) refers to a configuration file for an artifact that is deployed to some container/engine.

Web Service

Web Service is a service of an application that is externalized over the web and can be accessed by other applications using the HTTP protocol. For example the REST protocol or SOAP protocol (Which in the background are translated to HTTP [which in the background translated to TCP/IP etc...]). This service, when accessed, invokes the the internal application APIs that are bound to it.

XML Format

An "XML format" is used to transfer information between machines.

XML Schema Binary (XSB)

XML Schema Binary (XSB) is a file format that is used by the Apache XMLBeans Framework. An XSB file contains schema meta information needed to perform tasks such as binding and validation.

xz Compression

xz is a lossless data compression program and file format which incorporates the LZMA2 compression algorithm.