= JBoss =
Application server that implements the Java Platform, Enterprise Edition (Java EE) [[http://en.wikipedia.org/wiki/Jboss]].
== Message driven bean (JBoss) ==
A message-driven bean is an enterprise bean that allows J2EE applications to process messages asynchronously.
[[https://access.redhat.com/site/documentation/en-US/JBoss_Enterprise_Application_Platform/5/html/Messaging_User_Guide/ch05s13.html#table-MDB_JCA_Spec_Properties]]
=== Annotations, MDB Properties Provided by the JCA Specification ===
||'''Name'''||'''Type'''||'''Default value'''||'''Remarks'''||
||destination||java.lang.String||none||This property is Mandatory The JNDI name of the Queue or Topic.||
||destinationType||java.lang.String||none||The type of destination valid values are javax.jms.Queue or javax.jms.Topic||
||messageSelector||java.lang.String||none||The message selector of the subscription||
||acknowledgeMode||int||AUTO_ACKNOWLEDGE||The type of acknowledgement when not using transacted jms - valid values AUTO_ ACKNOWLEDGE or DUPS_OK_ ACKNOWLEDGE||
||clientID||java.lang.String|| || The client id of the connection||
||subscriptionDurability||String||NonDurable||Whether topic subscriptions are durable. Valid values are Durable orNonDurable||
||subscriptionName||String||none||The subscription name of the topic subscription||
=== MDB Properties Provided as JBoss Extensions ===
||Name||Type||Default value||Remarks||
||isTopic||boolean||false||Sets the destinationType||
||providerAdapterJNDI||java.lang.String||DefaultJMSProvider||The JNDI name of the JMS provider.||
||user||java.lang.String||none||The user ID used to connect to the JMS server||
||pass||java.lang.String||none||The password of the user||
||maxMessages||int||1||Read this number of messages before delivering messages to the MDB. Each message is delivered individually on the same thread in an attempt to avoid context excessive context switching||
||minSession||int||1||The minimum number of JMS sessions that are available to concurrently deliver messages to this mdb||
||maxSession||int||15||The maximum number of JMS sessions that are available to concurrently deliver messages to this mdb||
||reconnectInterval||long||10 seconds||The length of time in seconds between attempts to (re-)connect to the JMS provider||
||keepAlive||long||60 seconds||The length of time in milliseconds that sessions over the minimum are kept alive||
||sessionTransacted||boolean||true||Whether the sessions are transacted||
||useDLQ||boolean||true||Whether to use a Dead Letter Queue (DLQ) handler.||
||dLQJNDIName||java.lang.String||queue/DLQ||The JNDI name of the DLQ||
||dLQHandler||java.lang.String||org.jboss.resource.adapter.jms.inflow.dlq.GenericDLQHandler||The org.jboss.resource. adapter.jms.inflow. DLQHandler implementation class name.||
||dLQUser||java.lang.String||none||The user id used to make the dlq connection to the JMS server||
||dLQPassword||java.lang.String||none||The password of the dLQUser||
||dLQClientID||java.lang.String||none||The client id of the DLQ connection||
||dLQMaxResent||int||5||The maximum number of times a message is redelivered before it is sent to the DLQ.||
||redeliverUnspecified||boolean||true||Whether to attempt to redeliver a message in an unspecified transaction context||
||transactionTimeout||int||Default is the timeout set for the resource manager||Time in seconds for the transaction timeout||
||DeliveryActive||boolean||true||Whether the MDB should make the subscription at initial deployment or wait for start() or stopDelivery() on the corresponding MBean. You can set this to false if you want to prevent messages from being delivered to the MDB (which is still starting) during server start up. ||
== Timers annotations ==
Creating Calendar-Based Timer Expressions
[[http://docs.oracle.com/cd/E19226-01/820-7627/giqlk/index.html]]
Examples:
* Every five minutes, '''@Schedule(minute = "*/5" , hour="*")'''
* Every twenty minutes from 5 to 21, '''@Schedule(minute="*/20" , hour = "5-21")'''
* At one AM, '''@Schedule(hour = "1")'''
* At two AM and five PM, '''@Schedule(hour = "2,17")'''
== JAAS security JBoss AS7 ==
JAAS (Java Authentication and Authorization Service).
Read [[http://amatya.net/blog/implementing-security-with-jaas-in-jboss-as-7/]]
=== Basic authentication Web application ===
Add user and roles:
* /opt/jboss-as-7.1.1.Final/bin/add-user.sh -a userx passx # add user userx
* Files /opt/jboss-as-7.1.1.Final/standalone/application-users.properties and /opt/jboss-as-7.1.1.Final/domain/application-users.properties changed
* vi /opt/jboss-as-7.1.1.Final/standalone/application-roles.properties # add primary role
* userx=AppXYZUser # in application-roles.properties
Edit web.xml file for the web application:
{{{#!highlight xml
HtmlAuth
application security constraints
/*
GET
POST
AppXYZUser
BASIC
ApplicationRealm
AppXYZUser
}}}
Edit jboss-web.xml
{{{#!highlight xml
/AppContextRoot
java:/jaas/other
}}}
== Forms login ==
The following input fields are posted when a login is attempted:
* j_security_check
* j_username
* j_password
In web.xml:
{{{#!highlight xml
FORM
AppRealm
/login.html
/error.html
}}}
== JDBC authentication ==
For this setup the password is in plain text !
It must be improved in order to use hash like MD5 or SHA1.
Create tables on a PostgreSQL server:
* psql -U userx -W -d databasex -h 192.168.1.1
* \c databasex
* create table users (username varchar(128) NOT NULL,password varchar(128) NOT NULL );
* create table roles (username varchar(128) NOT NULL,role varchar(128) NOT NULL );
* insert into users (username,password) values('userx1','12345678');
* insert into roles (username,role) values('userx1','User');
* insert into roles (username,role) values('userx1','UserManager');
* grant all privileges on database dldserver to dldserver;
* alter table users owner to userx;
* alter table roles owner to userx;
Add security domain to standalone-full.xml:
{{{#!highlight xml
}}}
Alter jboss-web.xml:
{{{#!highlight xml
java:/jaas/jdbcRealm
}}}
== Compression JBoss AS 7 ==
[[http://docs.jboss.org/jbossweb/7.0.x/sysprops.html]]
* org.apache.coyote.http11.Http11Protocol.COMPRESSION: force
* org.apache.coyote.http11.Http11Protocol.COMPRESSION_MIME_TYPES: text/javascript,text/xml,text/html,text/plain,text/css
== Clear transactions ==
* service jboss stop
* cd /opt/jboss/standalone/data/tx-object-store
* rm * -rf
* service jboss start