all: several fixes proposed by DT (Andreas KRAFT)

# README 2017-09-27
This directory contains additional changes DT made to the om2m source
files.
The bases for the changes is the Orange distribution from 31.08.2017.

##
org.eclipse.om2m.commons/src/main/java/org/eclipse/om2m/commons/utils/Util.java
- Moved static configuration of date format to local methods.

##
org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/notifier/Notifier.java
- Moved static configuration of "NB_OF_FAILED_NOTIFS_BEFORE_DELETION" to
local methods.

##
org.eclipse.om2m.persistence.mongodb/src/main/java/org/eclipse/om2m/persistence/mongodb/Activator.java
- corrected wrong registration of DBService service.

##
org.eclipse.om2m.persistence.mongodb/src/main/java/org/eclipse/om2m/persistence/mongodb/DBServiceImpl.java
- Changed DB URL to use the "org.eclipse.om2m.dbUrl" environment
variable.

##
org.eclipse.om2m.webapp.resourcesbrowser.json/src/main/java/org/eclipse/om2m/webapp/resourcesbrowser/json/Activator.java
- Fixed wrong redirection.
- Made statics instance local.

##
./org.eclipse.om2m.webapp.resourcesbrowser.json/src/main/java/org/eclipse/om2m/webapp/resourcesbrowser/json/WelcomeServlet.java
- Fixed wrong redirection.
- Made statics instance local.

##
org.eclipse.om2m.webapp.resourcesbrowser.xml/src/main/java/org/eclipse/om2m/webapp/resourcesbrowser/xml/Activator.java
- Fixed wrong redirection.
- Made statics instance local.

##
org.eclipse.om2m.webapp.resourcesbrowser.xml/src/main/java/org/eclipse/om2m/webapp/resourcesbrowser/xml/WelcomeServlet.java
- Fixed wrong redirection.
- Made statics instance local.

##
org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/flexcontainer/FlexContainerXMLValidator.java
- Moved static configuration of
"FLEXCONTAINER_XSD_FOLDER_PROPERTY_VALUE" to localmethods. 

##
org.eclipse.om2m.commons/src/main/java/org/eclipse/om2m/commons/constants/Constants.java
- Changed type of class to interface
Usage: From now on, just inherite this interface and use the members.
They are initialized whenever the derived class is instantiated.
- Made all members non-static

##
org.eclipse.om2m.commons/src/main/java/org/eclipse/om2m/commons/resource/ResponsePrimitive.java
- Now inherits from Constants

##
org.eclipse.om2m.commons/src/main/java/org/eclipse/om2m/commons/utils/UriUtil.java
- Now inherits from Constants

##
org.eclipse.om2m.commons/src/main/java/org/eclipse/om2m/commons/utils/Util.java
- Removed statics

##
org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/announcer/Announcer.java
- Now inherits from Constants

##
org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/AccessControlPolicyController.java
- Uses new Pattern interface

##
org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/AEAnncController.java
- Uses new Pattern interface

##
org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/AEController.java
- Uses new Pattern interface

##
org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/ContainerController.java
- Uses new Pattern clainterfacess

##
org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/ContentInstanceController.java
- Uses new Pattern interface

##
org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/DiscoveryController.java
- Uses new Pattern interface

##
org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/DynamicAuthorizationConsultationController.java
- Uses new Pattern interface

##
org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/DynamicAuthorizationConsultationController.java
- Uses new Pattern interface

##
org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/FlexContainerAnncController.java
- Uses new Pattern interface

##
org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/FlexContainerController.java
- Uses new Pattern interface
- Changed static XML encoding to take (non-static) configuration into
account (for payload encoding)

##
org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/GroupController.java
- Uses new Pattern interface

##
org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/NodeController.java
- Uses new Pattern interface

##
org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/PollingChannelController.java
- Uses new Pattern interface

##
org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/RemoteCSEController.java
- Uses new Pattern interface

##
org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/SubscriptionController.java
- Uses new Pattern interface

##
org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/CSEInitializer.java
- Moved static configuration of date format to local methods.

##
org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/flexcontainer/FlexContainerXMLValidator.java
- Removed/changed static initialization.

##
org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/nblocking/NonBlockingWorker.java
- Uses new Pattern interface

##
org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/notifier/Notifier.java
- Changed static configurations

##
org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/redirector/Redirector.java
- Changed static determination of content format

##
org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/router/Patterns.java
- Changed static setting of Patterns. Now an interface class.

##
org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/router/Router.java
- Uses new Pattern interface
- Changed static determination of content format

##
org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/urimapper/UriMapper.java
- Uses new Pattern interface

##
org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/util/GroupUtil.java
- Uses new Pattern interface

##
org.eclipse.om2m.binding.http/src/main/java/org/eclipse/om2m/binding/http/Activator.java
- Changed static configurations

##
org.eclipse.om2m.binding.http/src/main/java/org/eclipse/om2m/binding/http/RestHttpServlet.java
- Changed static configurations
- Changed static determination of content format (already included in
last patch)

##
org.eclipse.om2m.sdt/org.eclipse.om2m.sdt.home.applications/org.eclipse.om2m.sdt.home.monitoring/src/main/java/org/eclipse/om2m/sdt/home/monitoring/Activator.java
- Changed static configurations


Conflicts:
	org.eclipse.om2m.commons/src/main/java/org/eclipse/om2m/commons/constants/Constants.java
	org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/notifier/Notifier.java
	org.eclipse.om2m.persistence.mongodb/src/main/java/org/eclipse/om2m/persistence/mongodb/DBServiceImpl.java

Signed-off-by: BOLLE Sebastien <sebastien.bolle@orange.com>
Signed-off-by: BONNARDEL Gregory <gbonnardel.ext@orange.com>
diff --git a/org.eclipse.om2m.binding.http/src/main/java/org/eclipse/om2m/binding/http/Activator.java b/org.eclipse.om2m.binding.http/src/main/java/org/eclipse/om2m/binding/http/Activator.java
index e993640..fdeb17f 100644
--- a/org.eclipse.om2m.binding.http/src/main/java/org/eclipse/om2m/binding/http/Activator.java
+++ b/org.eclipse.om2m.binding.http/src/main/java/org/eclipse/om2m/binding/http/Activator.java
@@ -41,7 +41,7 @@
     /** CSE service tracker */

     private ServiceTracker<Object, Object> cseServiceTracker;

     /** Csebase listening context */

-    protected static final String CSE_BASE_CONTEXT = System.getProperty("org.eclipse.om2m.cseBaseContext","/om2m");

+    protected final String CSE_BASE_CONTEXT = System.getProperty("org.eclipse.om2m.cseBaseContext","/om2m");

 

     @Override

     public void start(BundleContext bundleContext) throws Exception {

@@ -68,7 +68,9 @@
                 HttpService httpService = (HttpService) this.context.getService(reference);

                 try {

                     LOGGER.info("Register "+CSE_BASE_CONTEXT+" context");

-                    httpService.registerServlet(CSE_BASE_CONTEXT, new RestHttpServlet(), null,null);

+                    RestHttpServlet servlet = new RestHttpServlet();

+                    servlet.CSE_BASE_CONTEXT = CSE_BASE_CONTEXT;

+                    httpService.registerServlet(CSE_BASE_CONTEXT, servlet, null,null);

                 } catch (Exception e) {

                     LOGGER.error("Error registering CseServlet",e);

                 }

diff --git a/org.eclipse.om2m.binding.http/src/main/java/org/eclipse/om2m/binding/http/RestHttpServlet.java b/org.eclipse.om2m.binding.http/src/main/java/org/eclipse/om2m/binding/http/RestHttpServlet.java
index a5fe637..edc4e1f 100644
--- a/org.eclipse.om2m.binding.http/src/main/java/org/eclipse/om2m/binding/http/RestHttpServlet.java
+++ b/org.eclipse.om2m.binding.http/src/main/java/org/eclipse/om2m/binding/http/RestHttpServlet.java
@@ -63,6 +63,8 @@
 	private static final long serialVersionUID = 1L;
 	/** Discovered CSE service */
 	private static CseService cse;
+	
+	protected String CSE_BASE_CONTEXT = "";
 
 	/**
 	 * Converts a {@link HttpServletRequest} to a {@link RequestIndication} and uses it to invoke the SCL service.
@@ -79,8 +81,8 @@
 
 		// Remove the context (ex: '/api')
 		String targetID = uri ;
-		if (Activator.CSE_BASE_CONTEXT.length() > 1 && uri.length() > Activator.CSE_BASE_CONTEXT.length()){
-			targetID = uri.substring(Activator.CSE_BASE_CONTEXT.length());
+		if (CSE_BASE_CONTEXT.length() > 1 && uri.length() > CSE_BASE_CONTEXT.length()){
+			targetID = uri.substring(CSE_BASE_CONTEXT.length());
 		}
 		
 		if(targetID.startsWith("/~")){
diff --git a/org.eclipse.om2m.commons/src/main/java/org/eclipse/om2m/commons/constants/Constants.java b/org.eclipse.om2m.commons/src/main/java/org/eclipse/om2m/commons/constants/Constants.java
index 8f0d5f9..b82a165 100644
--- a/org.eclipse.om2m.commons/src/main/java/org/eclipse/om2m/commons/constants/Constants.java
+++ b/org.eclipse.om2m.commons/src/main/java/org/eclipse/om2m/commons/constants/Constants.java
@@ -1,100 +1,97 @@
-/*******************************************************************************
- * Copyright (c) 2013-2016 LAAS-CNRS (www.laas.fr)
- * 7 Colonel Roche 31077 Toulouse - France
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- *     Thierry Monteil : Project manager, technical co-manager
- *     Mahdi Ben Alaya : Technical co-manager
- *     Samir Medjiah : Technical co-manager
- *     Khalil Drira : Strategy expert
- *     Guillaume Garzone : Developer
- *     François Aïssaoui : Developer
- *
- * New contributors :
- *******************************************************************************/
-package org.eclipse.om2m.commons.constants;
-
-import java.math.BigInteger;
-
-/**
- * Initializes platform properties
- */
-public class Constants {
-	//CseBase resource properties
-    /** CSE Type */
-    public static final String CSE_TYPE = System.getProperty("org.eclipse.om2m.cseType","IN-CSE");
-    /** CseBase id. */
-    public static final String CSE_ID = System.getProperty("org.eclipse.om2m.cseBaseId","in-cse");
-    /** CseBase name. */
-    public static final String CSE_NAME = System.getProperty("org.eclipse.om2m.cseBaseName", "in-name");
-   
-    /** Default admin access right profile */
-    public static final String ADMIN_PROFILE_ID = "acp_admin";
-    /** Default admin requesting entity. (username/password) */
-    public static final String ADMIN_REQUESTING_ENTITY = System.getProperty("org.eclipse.om2m.adminRequestingEntity","admin:admin");
-    /** Default guest access right profile */
-    public static final String GUEST_PROFILE_ID = "ACP_GUEST";
-    /** Default guest requesting entity. (username/password) */
-    public static final String GUEST_REQUESTING_ENTITY = System.getProperty("org.eclipse.om2m.guestRequestingEntity","guest:guest");
-    /** Default resources expiration time. */
-    public static final long EXPIRATION_TIME = 999999999;
-    //CseBase communication properties
-    /** CseBase default communication protocol. */
-    public static final String CSE_DEFAULT_PROTOCOL = System.getProperty("org.eclipse.om2m.cseBaseProtocol.default","http");
-    /** CseBase ip address. */
-    public static final String CSE_IP = System.getProperty("org.eclipse.om2m.cseBaseAddress","127.0.0.1");
-    /** CseBase listening port. */
-    public static final int CSE_PORT = Integer.parseInt(System.getProperty("org.eclipse.equinox.http.jetty.http.port","8080"));
-    /** CseBase coap port. */
-    public static final int COAP_PORT = Integer.parseInt(System.getProperty("org.eclipse.om2m.coap.port","5684"));
-    /** listening context. Not oneM2M compliant */
-    @Deprecated
-    public static final String CSE_CONTEXT = System.getProperty("org.eclipse.om2m.cseBaseContext","/api");
-    /** M2M Service Provider identifier */
-    public static final String M2M_SP_ID = System.getProperty("org.eclipse.om2m.m2mSpId", "om2m.org");
-    
-    //The following properties are required only for ASN or MN to perform authentication on a remote IN or MN
-    /** Connect to the remote CSE (if not IN) */
-    public static final boolean CSE_AUTHENTICATION = Boolean.valueOf(System.getProperty("org.eclipse.om2m.cseAuthentication", "true"));
-    /** Remote Cse Id. (Required only for MN or ASN)*/
-    public static final String REMOTE_CSE_ID = System.getProperty("org.eclipse.om2m.remoteCseId","in-cse");
-    /** Remote Cse ip address. (Required only for MN or ASN)*/
-    public static final String REMOTE_CSE_IP = System.getProperty("org.eclipse.om2m.remoteCseAddress","127.0.0.1");
-    /** Remote Cse listening port. (Required only for MN or ASN)*/
-    public static final int REMOTE_CSE_PORT = Integer.parseInt(System.getProperty("org.eclipse.om2m.remoteCsePort","8080"));
-    /** Remote Cse listening port. (Required only for MN or ASN)*/
-    public static final int REMOTE_CSE_COAP_PORT = Integer.parseInt(System.getProperty("org.eclipse.om2m.remoteCseCoapPort","5683"));
-    /** Remote Cse listening context. */
-    public static final String REMOTE_CSE_CONTEXT = System.getProperty("org.eclipse.om2m.remoteCseContext","/api");
-    /** Remote Cse Name */
-    public static final String REMOTE_CSE_NAME = System.getProperty("org.eclipse.om2m.remoteCseName", "in-name");
-    
-    // Default values for container creation
-    /** Default ContentInstances collection maximum number of instance. */
-    public static final BigInteger MAX_NBR_OF_INSTANCES = new BigInteger(System.getProperty("org.eclipse.om2m.maxNrOfInstances","10"));
-    /** Default max byte size for a container */
-    public static final BigInteger MAX_BYTE_SIZE = new BigInteger(System.getProperty("org.eclipse.om2m.maxByteSize", "10000"));
-    
-    // Regular expressions
-    /** Regular expression for ID of resources */
-    public static final String ID_REGEXPR = "^[A-Za-z0-9_-]*$" ;
-	/** Prefix separator for IDs */
-	public static final String PREFIX_SEPERATOR = System.getProperty("org.eclipse.om2m.resource.idseparator", "-");
-	
-	// Non blocking supported boolean
-	public static final boolean NON_BLOCKING_SUPPORTED = Boolean.parseBoolean(System.getProperty("org.eclipse.om2m.nonblocking", "true"));
-
-	public static final String SP_RELATIVE_URI_SEPARATOR = "~";
-	public static final String ABSOLUTE_URI_SEPARATOR = "_";
-	
-	public static final Integer MAX_THREAD_POOL_SIZE = Integer.valueOf(System.getProperty("org.eclipse.om2m.maxThreadPoolSize", "50"));
-
-	// The MimeMediaType to use to serialize a notification
-	public static final String NOTIFICATION_MMT = System.getProperty("org.eclipse.om2m.notification.mmt", MimeMediaType.XML);
-	
+/*******************************************************************************

+ * Copyright (c) 2013-2016 LAAS-CNRS (www.laas.fr)

+ * 7 Colonel Roche 31077 Toulouse - France

+ *

+ * All rights reserved. This program and the accompanying materials

+ * are made available under the terms of the Eclipse Public License v1.0

+ * which accompanies this distribution, and is available at

+ * http://www.eclipse.org/legal/epl-v10.html

+ *

+ * Initial Contributors:

+ *     Thierry Monteil : Project manager, technical co-manager

+ *     Mahdi Ben Alaya : Technical co-manager

+ *     Samir Medjiah : Technical co-manager

+ *     Khalil Drira : Strategy expert

+ *     Guillaume Garzone : Developer

+ *     François Aïssaoui : Developer

+ *

+ * New contributors :

+ *******************************************************************************/

+package org.eclipse.om2m.commons.constants;

+

+import java.math.BigInteger;

+

+/**

+ * Initializes platform properties

+ */

+public interface Constants {

+	//CseBase resource properties

+    /** CSE Type */

+    public final String CSE_TYPE = System.getProperty("org.eclipse.om2m.cseType","IN-CSE");

+    /** CseBase id. */

+    public final String CSE_ID = System.getProperty("org.eclipse.om2m.cseBaseId","in-cse");

+    /** CseBase name. */

+    public final String CSE_NAME = System.getProperty("org.eclipse.om2m.cseBaseName", "in-name");

+   

+    /** Default admin access right profile */

+    public final String ADMIN_PROFILE_ID = "acp_admin";

+    /** Default admin requesting entity. (username/password) */

+    public final String ADMIN_REQUESTING_ENTITY = System.getProperty("org.eclipse.om2m.adminRequestingEntity","admin:admin");

+    /** Default guest access right profile */

+    public final String GUEST_PROFILE_ID = "ACP_GUEST";

+    /** Default guest requesting entity. (username/password) */

+    public final String GUEST_REQUESTING_ENTITY = System.getProperty("org.eclipse.om2m.guestRequestingEntity","guest:guest");

+    /** Default resources expiration time. */

+    public final long EXPIRATION_TIME = 999999999;

+    //CseBase communication properties

+    /** CseBase default communication protocol. */

+    public final String CSE_DEFAULT_PROTOCOL = System.getProperty("org.eclipse.om2m.cseBaseProtocol.default","http");

+    /** CseBase ip address. */

+    public final String CSE_IP = System.getProperty("org.eclipse.om2m.cseBaseAddress","127.0.0.1");

+    /** CseBase listening port. */

+    public final int CSE_PORT = Integer.parseInt(System.getProperty("org.eclipse.equinox.http.jetty.http.port","8080"));

+    /** CseBase coap port. */

+    public final int COAP_PORT = Integer.parseInt(System.getProperty("org.eclipse.om2m.coap.port","5684"));

+    /** listening context. Not oneM2M compliant */

+    @Deprecated

+    public final String CSE_CONTEXT = System.getProperty("org.eclipse.om2m.cseBaseContext","/api");

+    /** M2M Service Provider identifier */

+    public final String M2M_SP_ID = System.getProperty("org.eclipse.om2m.m2mSpId", "om2m.org");

+    

+    //The following properties are required only for ASN or MN to perform authentication on a remote IN or MN

+    /** Connect to the remote CSE (if not IN) */

+    public final boolean CSE_AUTHENTICATION = Boolean.valueOf(System.getProperty("org.eclipse.om2m.cseAuthentication", "true"));

+    /** Remote Cse Id. (Required only for MN or ASN)*/

+    public final String REMOTE_CSE_ID = System.getProperty("org.eclipse.om2m.remoteCseId","in-cse");

+    /** Remote Cse ip address. (Required only for MN or ASN)*/

+    public final String REMOTE_CSE_IP = System.getProperty("org.eclipse.om2m.remoteCseAddress","127.0.0.1");

+    /** Remote Cse listening port. (Required only for MN or ASN)*/

+    public final int REMOTE_CSE_PORT = Integer.parseInt(System.getProperty("org.eclipse.om2m.remoteCsePort","8080"));

+    /** Remote Cse listening port. (Required only for MN or ASN)*/

+    public final int REMOTE_CSE_COAP_PORT = Integer.parseInt(System.getProperty("org.eclipse.om2m.remoteCseCoapPort","5683"));

+    /** Remote Cse listening context. */

+    public final String REMOTE_CSE_CONTEXT = System.getProperty("org.eclipse.om2m.remoteCseContext","/api");

+    /** Remote Cse Name */

+    public final String REMOTE_CSE_NAME = System.getProperty("org.eclipse.om2m.remoteCseName", "in-name");

+    

+    // Default values for container creation

+    /** Default ContentInstances collection maximum number of instance. */

+    public final BigInteger MAX_NBR_OF_INSTANCES = new BigInteger(System.getProperty("org.eclipse.om2m.maxNrOfInstances","10"));

+    /** Default max byte size for a container */

+    public final BigInteger MAX_BYTE_SIZE = new BigInteger(System.getProperty("org.eclipse.om2m.maxByteSize", "10000"));

+    

+    // Regular expressions

+    /** Regular expression for ID of resources */

+    public final String ID_REGEXPR = "^[A-Za-z0-9_-]*$" ;

+	/** Prefix separator for IDs */

+	public final String PREFIX_SEPERATOR = System.getProperty("org.eclipse.om2m.resource.idseparator", "-");

+	

+	// Non blocking supported boolean

+	public final boolean NON_BLOCKING_SUPPORTED = Boolean.parseBoolean(System.getProperty("org.eclipse.om2m.nonblocking", "true"));

+

+	public final String SP_RELATIVE_URI_SEPARATOR = "~";

+	public final String ABSOLUTE_URI_SEPARATOR = "_";

+	

+	public final Integer MAX_THREAD_POOL_SIZE = Integer.valueOf(System.getProperty("org.eclipse.om2m.maxThreadPoolSize", "50"));

+	

 }
\ No newline at end of file
diff --git a/org.eclipse.om2m.commons/src/main/java/org/eclipse/om2m/commons/resource/ResponsePrimitive.java b/org.eclipse.om2m.commons/src/main/java/org/eclipse/om2m/commons/resource/ResponsePrimitive.java
index 74b1cc5..646078c 100644
--- a/org.eclipse.om2m.commons/src/main/java/org/eclipse/om2m/commons/resource/ResponsePrimitive.java
+++ b/org.eclipse.om2m.commons/src/main/java/org/eclipse/om2m/commons/resource/ResponsePrimitive.java
@@ -70,7 +70,7 @@
  */
 @XmlAccessorType(XmlAccessType.FIELD)
 @XmlRootElement(name = ShortName.RESPONSE_PRIMITIVE)
-public class ResponsePrimitive {
+public class ResponsePrimitive implements Constants {
 
 	@XmlElement(required = true, name = ShortName.RESPONSE_STATUS_CODE)
 	protected BigInteger responseStatusCode;
diff --git a/org.eclipse.om2m.commons/src/main/java/org/eclipse/om2m/commons/utils/UriUtil.java b/org.eclipse.om2m.commons/src/main/java/org/eclipse/om2m/commons/utils/UriUtil.java
index 514716a..dc3e774 100644
--- a/org.eclipse.om2m.commons/src/main/java/org/eclipse/om2m/commons/utils/UriUtil.java
+++ b/org.eclipse.om2m.commons/src/main/java/org/eclipse/om2m/commons/utils/UriUtil.java
@@ -25,7 +25,7 @@
  * Uri util methods to check uri relativity. 
  *
  */
-public class UriUtil {
+public class UriUtil implements Constants {
 
 	private UriUtil(){}
 
diff --git a/org.eclipse.om2m.commons/src/main/java/org/eclipse/om2m/commons/utils/Util.java b/org.eclipse.om2m.commons/src/main/java/org/eclipse/om2m/commons/utils/Util.java
index 64eaf65..d2eabaa 100644
--- a/org.eclipse.om2m.commons/src/main/java/org/eclipse/om2m/commons/utils/Util.java
+++ b/org.eclipse.om2m.commons/src/main/java/org/eclipse/om2m/commons/utils/Util.java
@@ -38,8 +38,7 @@
  */
 public class Util {
 	
-	protected static String dateFormat = System.getProperty("org.eclipse.om2m.date.format", "yyyyMMdd'T'HHmmss");
-//	protected static String dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZ";
+
 
 	/** Private consctructor */
 	private Util() {}
@@ -60,6 +59,8 @@
 		 * @return
 		 */
 		public static String now() {
+			String dateFormat = System.getProperty("org.eclipse.om2m.date.format", "yyyyMMdd'T'HHmmss");
+//			String dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZ";
 			return new SimpleDateFormat(dateFormat).format(new Date()).toString();
 		}
 		
@@ -69,7 +70,10 @@
 	     * @return false if the expirationTime attribute is out of date otherwise true
 	     */
 	    public static boolean checkExpirationTime(String expirationTime) {
-	        DateFormat df=new SimpleDateFormat(dateFormat);
+			String dateFormat = System.getProperty("org.eclipse.om2m.date.format", "yyyyMMdd'T'HHmmss");
+//			String dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZ";
+
+			DateFormat df=new SimpleDateFormat(dateFormat);
 	        Date expDate;
 	        try {
 	            expDate = df.parse(expirationTime);
@@ -111,10 +115,13 @@
 	     * @return
 	     */
 	    public static String getDefaultExpirationTime(){
-	    	Calendar cal = Calendar.getInstance();
-	    	cal.setTime(new Date());
-	    	cal.add(Calendar.YEAR, 1);
-	    	return new SimpleDateFormat(dateFormat).format(cal.getTime());
+	    		String dateFormat = System.getProperty("org.eclipse.om2m.date.format", "yyyyMMdd'T'HHmmss");
+//			String dateFormat = "yyyy-MM-dd'T'HH:mm:ss.SSSZZZZ";
+	
+		    	Calendar cal = Calendar.getInstance();
+		    	cal.setTime(new Date());
+		    	cal.add(Calendar.YEAR, 1);
+		    	return new SimpleDateFormat(dateFormat).format(cal.getTime());
 	    }
 	}
 	
diff --git a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/CSEInitializer.java b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/CSEInitializer.java
index e437dc8..8520b2f 100644
--- a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/CSEInitializer.java
+++ b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/CSEInitializer.java
@@ -60,7 +60,7 @@
  * Initializer for CSE entity
  *
  */
-public class CSEInitializer {
+public class CSEInitializer implements Constants {
 
 	/** Logger */
 	private static final Log LOGGER = LogFactory.getLog(CSEInitializer.class);
@@ -384,7 +384,7 @@
 		if (Constants.REMOTE_CSE_CONTEXT.length() > 1) {
 			remotePoa += "/" + Constants.REMOTE_CSE_CONTEXT;
 		}
-		remotePoa += "/" + Constants.REMOTE_CSE_ID + "/" + Constants.REMOTE_CSE_NAME + "/" + Constants.CSE_NAME;
+		remotePoa += "/" + REMOTE_CSE_ID + "/" + REMOTE_CSE_NAME + "/" + CSE_NAME;
 		request.setTo(remotePoa);
 		request.setResultContent(ResultContent.NOTHING);
 		LOGGER.info("Sending unregistration request");
diff --git a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/announcer/Announcer.java b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/announcer/Announcer.java
index 7cb479e..878ef15 100644
--- a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/announcer/Announcer.java
+++ b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/announcer/Announcer.java
@@ -53,7 +53,7 @@
  *

  */

 

-public class Announcer {

+public class Announcer implements Constants {

 	/** Logger */

 	private static Log LOGGER = LogFactory.getLog(Announcer.class);

 

diff --git a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/AEAnncController.java b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/AEAnncController.java
index 13c8c4e..652562e 100644
--- a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/AEAnncController.java
+++ b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/AEAnncController.java
@@ -65,9 +65,10 @@
 		 */

 

 		ResponsePrimitive response = new ResponsePrimitive(request);

+		Patterns patterns = new Patterns();

 

 		// Get the DAO of the parent

-		DAO<ResourceEntity> dao = (DAO<ResourceEntity>) Patterns.getDAO(request.getTargetId(), dbs);

+		DAO<ResourceEntity> dao = (DAO<ResourceEntity>) patterns.getDAO(request.getTargetId(), dbs);

 		if (dao == null) {

 			throw new ResourceNotFoundException("Cannot find parent resource");

 		}

@@ -280,8 +281,8 @@
 		aeAnncEntity.setParentID(parentEntity.getResourceID());

 		aeAnncEntity.setResourceType(BigInteger.valueOf(ResourceType.AE_ANNC));

 		if (aeAnnc.getName() != null) {

-			if (!Patterns.checkResourceName(aeAnnc.getName())) {

-				throw new BadRequestException("Name provided is incorrect. Must be:" + Patterns.ID_STRING);

+			if (!patterns.checkResourceName(aeAnnc.getName())) {

+				throw new BadRequestException("Name provided is incorrect. Must be:" + patterns.ID_STRING);

 			}

 			aeAnncEntity.setName(aeAnnc.getName());

 		} else {

diff --git a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/AEController.java b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/AEController.java
index fa3cee0..5fc212b 100644
--- a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/AEController.java
+++ b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/AEController.java
@@ -88,9 +88,10 @@
 		 */
 
 		ResponsePrimitive response = new ResponsePrimitive(request);
+		Patterns patterns = new Patterns();
 
 		// Get the DAO of the parent
-		DAO<ResourceEntity> dao = (DAO<ResourceEntity>) Patterns.getDAO(request.getTargetId(), dbs);
+		DAO<ResourceEntity> dao = (DAO<ResourceEntity>) patterns.getDAO(request.getTargetId(), dbs);
 		if (dao == null){
 			throw new ResourceNotFoundException("Cannot find parent resource");
 		}
@@ -305,8 +306,8 @@
 		
 		aeEntity.setResourceType(BigInteger.valueOf(ResourceType.AE));
 		if (ae.getName() != null){
-			if (!Patterns.checkResourceName(ae.getName())){
-				throw new BadRequestException("Name provided is incorrect. Must be:" + Patterns.ID_STRING);
+			if (!patterns.checkResourceName(ae.getName())){
+				throw new BadRequestException("Name provided is incorrect. Must be:" + patterns.ID_STRING);
 			}
 			aeEntity.setName(ae.getName());
 		} else {
diff --git a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/AccessControlPolicyController.java b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/AccessControlPolicyController.java
index 7bc349b..ef09f52 100644
--- a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/AccessControlPolicyController.java
+++ b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/AccessControlPolicyController.java
@@ -83,9 +83,10 @@
 	@Override
 	public ResponsePrimitive doCreate(RequestPrimitive request) {
 		ResponsePrimitive response = new ResponsePrimitive(request);
+		Patterns patterns = new Patterns();
 
 		// Get the DAO of the parent
-		DAO<ResourceEntity> dao = (DAO<ResourceEntity>) Patterns.getDAO(request.getTargetId(), dbs);
+		DAO<ResourceEntity> dao = (DAO<ResourceEntity>) patterns.getDAO(request.getTargetId(), dbs);
 		if (dao == null){
 			throw new ResourceNotFoundException("Cannot find parent resource");
 		}
@@ -174,8 +175,8 @@
 		String generatedId = generateId();
 		// Creating the corresponding entity
 		if (acp.getName() != null){
-			if (!Patterns.checkResourceName(acp.getName())){
-				throw new BadRequestException("Name provided is incorrect. Must be:" + Patterns.ID_STRING);
+			if (!patterns.checkResourceName(acp.getName())){
+				throw new BadRequestException("Name provided is incorrect. Must be:" + patterns.ID_STRING);
 			}
 			acpEntity.setName(acp.getName());
 		} else {
diff --git a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/ContainerController.java b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/ContainerController.java
index bc13630..319bd5e 100644
--- a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/ContainerController.java
+++ b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/ContainerController.java
@@ -90,9 +90,10 @@
 		 * 
 		 */
 		ResponsePrimitive response = new ResponsePrimitive(request);
+		Patterns patterns = new Patterns();
 
 		// get the dao of the parent
-		DAO<ResourceEntity> dao = (DAO<ResourceEntity>) Patterns.getDAO(request.getTargetId(), dbs);
+		DAO<ResourceEntity> dao = (DAO<ResourceEntity>) patterns.getDAO(request.getTargetId(), dbs);
 		if (dao == null){
 			throw new ResourceNotFoundException("Cannot find parent resource");
 		}
@@ -197,8 +198,8 @@
 		String generatedId = generateId("", "");
 		// set name if present and without any conflict
 		if (container.getName() != null){
-			if (!Patterns.checkResourceName(container.getName())){
-				throw new BadRequestException("Name provided is incorrect. Must be:" + Patterns.ID_STRING);
+			if (!patterns.checkResourceName(container.getName())){
+				throw new BadRequestException("Name provided is incorrect. Must be:" + patterns.ID_STRING);
 			}
 			containerEntity.setName(container.getName());
 		} else {
diff --git a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/ContentInstanceController.java b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/ContentInstanceController.java
index 7386b23..61c4cbc 100644
--- a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/ContentInstanceController.java
+++ b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/ContentInstanceController.java
@@ -88,9 +88,10 @@
 		 */
 		// create the response
 		ResponsePrimitive response = new ResponsePrimitive(request);
+		Patterns patterns = new Patterns();
 
 		// get the dao of the parent
-		DAO<?> dao = (DAO<?>) Patterns.getDAO(request.getTargetId(), dbs);
+		DAO<?> dao = (DAO<?>) patterns.getDAO(request.getTargetId(), dbs);
 		if (dao == null) {
 			throw new ResourceNotFoundException("Cannot find parent resource");
 		}
@@ -173,8 +174,8 @@
 		cinEntity.setResourceID("/" + Constants.CSE_ID + "/" + ShortName.CIN + Constants.PREFIX_SEPERATOR + generatedId);
 		// check & set resource name if present
 		if (cin.getName() != null){
-			if (!Patterns.checkResourceName(cin.getName())){
-				throw new BadRequestException("Name provided is incorrect. Must be:" + Patterns.ID_STRING);
+			if (!patterns.checkResourceName(cin.getName())){
+				throw new BadRequestException("Name provided is incorrect. Must be:" + patterns.ID_STRING);
 			}
 			cinEntity.setName(cin.getName());
 		} else {
@@ -295,6 +296,9 @@
 	public ResponsePrimitive doDelete(RequestPrimitive request) {
 		// create the response primitive
 		ResponsePrimitive response = new ResponsePrimitive(request);
+		Patterns patterns = new Patterns();
+
+		
 		// get the database service
 		DBService dbs = PersistenceService.getInstance().getDbService();
 		DBTransaction transaction = dbs.getDbTransaction();
@@ -314,7 +318,7 @@
 
 		UriMapper.deleteUri(cin.getHierarchicalURI());
 		
-		DAO<?> dao = (DAO<?>) Patterns.getDAO(cin.getParentID(), dbs);
+		DAO<?> dao = (DAO<?>) patterns.getDAO(cin.getParentID(), dbs);
 		ResourceEntity parentEntity = (ResourceEntity)dao.find(transaction, cin.getParentID());
 		ContainerEntity container = (ContainerEntity) parentEntity;
 
diff --git a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/DiscoveryController.java b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/DiscoveryController.java
index 878c3ea..d586897 100644
--- a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/DiscoveryController.java
+++ b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/DiscoveryController.java
@@ -79,9 +79,10 @@
 	public ResponsePrimitive doRetrieve(RequestPrimitive request) {
 		// Create the response
 		ResponsePrimitive response = new ResponsePrimitive(request);
+		Patterns patterns = new Patterns();
 
 		// Get the DAO of the parent
-		DAO<?> dao = (DAO<?>) Patterns.getDAO(request.getTargetId(), dbs);
+		DAO<?> dao = (DAO<?>) patterns.getDAO(request.getTargetId(), dbs);
 		if (dao == null){
 			throw new ResourceNotFoundException("Root resource not found for discovery");
 		}
@@ -158,7 +159,7 @@
 			}
 			
 			// check acp
-			DAO<?> currentDao = (DAO<?>) Patterns.getDAO(uriEntity.getNonHierarchicalUri(), dbs);
+			DAO<?> currentDao = (DAO<?>) patterns.getDAO(uriEntity.getNonHierarchicalUri(), dbs);
 			ResourceEntity currentResourceEntity = (ResourceEntity) currentDao.find(transaction, uriEntity.getNonHierarchicalUri());
 			if (currentResourceEntity != null) {
 				List<AccessControlPolicyEntity> acps = getAcpsFromEntity(currentResourceEntity);
diff --git a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/DynamicAuthorizationConsultationController.java b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/DynamicAuthorizationConsultationController.java
index cc0cced..0eacfb5 100644
--- a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/DynamicAuthorizationConsultationController.java
+++ b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/DynamicAuthorizationConsultationController.java
@@ -44,9 +44,10 @@
 	@Override

 	public ResponsePrimitive doCreate(RequestPrimitive request) {

 		ResponsePrimitive response = new ResponsePrimitive(request);

+		Patterns patterns = new Patterns();

 

 		// Get the DAO of the parent

-		DAO<ResourceEntity> dao = (DAO<ResourceEntity>) Patterns.getDAO(request.getTargetId(), dbs);

+		DAO<ResourceEntity> dao = (DAO<ResourceEntity>) patterns.getDAO(request.getTargetId(), dbs);

 		if (dao == null) {

 			throw new ResourceNotFoundException("Cannot find parent resource");

 		}

@@ -162,8 +163,8 @@
 		String generatedId = generateId("", "");

 		// set name if present and without any conflict

 		if (dac.getName() != null) {

-			if (!Patterns.checkResourceName(dac.getName())) {

-				throw new BadRequestException("Name provided is incorrect. Must be:" + Patterns.ID_STRING);

+			if (!patterns.checkResourceName(dac.getName())) {

+				throw new BadRequestException("Name provided is incorrect. Must be:" + patterns.ID_STRING);

 			}

 			dacEntity.setName(dac.getName());

 		} else {

diff --git a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/FlexContainerAnncController.java b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/FlexContainerAnncController.java
index 9086224..a119217 100644
--- a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/FlexContainerAnncController.java
+++ b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/FlexContainerAnncController.java
@@ -69,9 +69,10 @@
 		 * 

 		 */

 		ResponsePrimitive response = new ResponsePrimitive(request);

+		Patterns patterns = new Patterns();

 

 		// get the dao of the parent

-		DAO<ResourceEntity> dao = (DAO<ResourceEntity>) Patterns.getDAO(request.getTargetId(), dbs);

+		DAO<ResourceEntity> dao = (DAO<ResourceEntity>) patterns.getDAO(request.getTargetId(), dbs);

 		if (dao == null) {

 			throw new ResourceNotFoundException("Cannot find parent resource");

 		}

@@ -186,8 +187,8 @@
 		String generatedId = generateId("", "");

 		// set name if present and without any conflict

 		if (flexContainerAnnc.getName() != null) {

-			if (!Patterns.checkResourceName(flexContainerAnnc.getName())) {

-				throw new BadRequestException("Name provided is incorrect. Must be:" + Patterns.ID_STRING);

+			if (!patterns.checkResourceName(flexContainerAnnc.getName())) {

+				throw new BadRequestException("Name provided is incorrect. Must be:" + patterns.ID_STRING);

 			}

 			flexContainerAnncEntity.setName(flexContainerAnnc.getName());

 		} else {

diff --git a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/FlexContainerController.java b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/FlexContainerController.java
index 73f9d7e..04b16fa 100644
--- a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/FlexContainerController.java
+++ b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/FlexContainerController.java
@@ -76,11 +76,12 @@
 		 */
 		
 		String contentFormat = System.getProperty("org.eclipse.om2m.registration.contentFormat", MimeMediaType.XML);
+		Patterns patterns = new Patterns();
 
 		ResponsePrimitive response = new ResponsePrimitive(request);
 
 		// get the dao of the parent
-		DAO<ResourceEntity> dao = (DAO<ResourceEntity>) Patterns.getDAO(request.getTargetId(), dbs);
+		DAO<ResourceEntity> dao = (DAO<ResourceEntity>) patterns.getDAO(request.getTargetId(), dbs);
 		if (dao == null) {
 			throw new ResourceNotFoundException("Cannot find parent resource");
 		}
@@ -227,8 +228,8 @@
 		String generatedId = generateId("", "");
 		// set name if present and without any conflict
 		if (flexContainer.getName() != null) {
-			if (!Patterns.checkResourceName(flexContainer.getName())) {
-				throw new BadRequestException("Name provided is incorrect. Must be:" + Patterns.ID_STRING);
+			if (!patterns.checkResourceName(flexContainer.getName())) {
+				throw new BadRequestException("Name provided is incorrect. Must be:" + patterns.ID_STRING);
 			}
 			flexContainerEntity.setName(flexContainer.getName());
 		} else {
diff --git a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/GroupController.java b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/GroupController.java
index 6331561..20272d9 100644
--- a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/GroupController.java
+++ b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/GroupController.java
@@ -92,9 +92,10 @@
 	@Override
 	public ResponsePrimitive doCreate(RequestPrimitive request) {
 		ResponsePrimitive response = new ResponsePrimitive(request);
+		Patterns patterns = new Patterns();
 
 		// Get the DAO of the parent
-		DAO<ResourceEntity> dao = (DAO<ResourceEntity>) Patterns.getDAO(request.getTargetId(), dbs);
+		DAO<ResourceEntity> dao = (DAO<ResourceEntity>) patterns.getDAO(request.getTargetId(), dbs);
 		if (dao == null){
 			throw new ResourceNotFoundException("Cannot find parent resource");
 		}
@@ -248,8 +249,8 @@
 		groupEntity.setResourceType(ResourceType.GROUP);
 		
 		if (group.getName() != null){
-			if (!Patterns.checkResourceName(group.getName())){
-				throw new BadRequestException("Name provided is incorrect. Must be:" + Patterns.ID_STRING);
+			if (!patterns.checkResourceName(group.getName())){
+				throw new BadRequestException("Name provided is incorrect. Must be:" + patterns.ID_STRING);
 			}
 			groupEntity.setName(group.getName());
 		} else {
diff --git a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/LatestOldestController.java b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/LatestOldestController.java
index e1738e9..8d7b9ab 100644
--- a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/LatestOldestController.java
+++ b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/LatestOldestController.java
@@ -108,6 +108,8 @@
 	public ResponsePrimitive doDelete(RequestPrimitive request) {
 		// Creating the response primitive
 		ResponsePrimitive response = new ResponsePrimitive(request);
+		Patterns patterns = new Patterns();
+
 
 		// Check existence of the resource
 		ContainerEntity containerEntity = dbs.getDAOFactory().getContainerDAO().find(transaction, request.getTargetId());
@@ -136,7 +138,7 @@
 			break;
 		}
 		UriMapper.deleteUri(cinEntity.getHierarchicalURI());
-		DAO<?> dao = (DAO<?>) Patterns.getDAO(cinEntity.getParentID(), dbs);
+		DAO<?> dao = (DAO<?>) patterns.getDAO(cinEntity.getParentID(), dbs);
 		ResourceEntity parentEntity = (ResourceEntity)dao.find(transaction, cinEntity.getParentID());
 
 		ContainerEntity container = (ContainerEntity) parentEntity;
diff --git a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/NodeController.java b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/NodeController.java
index 142112a..b77ab2c 100644
--- a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/NodeController.java
+++ b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/NodeController.java
@@ -77,8 +77,10 @@
 		 */
 
 		ResponsePrimitive response = new ResponsePrimitive(request);
+		Patterns patterns = new Patterns();
+
 		// retrieve the parent
-		DAO<ResourceEntity> dao = (DAO<ResourceEntity>) Patterns.getDAO(request.getTargetId(), dbs);
+		DAO<ResourceEntity> dao = (DAO<ResourceEntity>) patterns.getDAO(request.getTargetId(), dbs);
 		if (dao == null){
 			throw new ResourceNotFoundException("Cannot find parent resource");
 		}
@@ -161,8 +163,8 @@
 		nodeEntity.setResourceType(ResourceType.NODE);
 	
 		if (node.getName() != null){
-			if (!Patterns.checkResourceName(node.getName())){
-				throw new BadRequestException("Name provided is incorrect. Must be:" + Patterns.ID_STRING);
+			if (!patterns.checkResourceName(node.getName())){
+				throw new BadRequestException("Name provided is incorrect. Must be:" + patterns.ID_STRING);
 			}
 			nodeEntity.setName(node.getName());
 		} else {
diff --git a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/PollingChannelController.java b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/PollingChannelController.java
index 0713f80..b45af7f 100644
--- a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/PollingChannelController.java
+++ b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/PollingChannelController.java
@@ -59,8 +59,9 @@
 	@Override
 	public ResponsePrimitive doCreate(RequestPrimitive request) {
 		ResponsePrimitive response = new ResponsePrimitive(request);
+		Patterns patterns = new Patterns();
 
-		DAO<ResourceEntity> dao = (DAO<ResourceEntity>) Patterns.getDAO(request.getTargetId(), dbs);
+		DAO<ResourceEntity> dao = (DAO<ResourceEntity>) patterns.getDAO(request.getTargetId(), dbs);
 		if (dao == null){
 			throw new ResourceNotFoundException("Cannot find parent resource");
 		}
@@ -149,8 +150,8 @@
 		String generatedId = generateId();
 		pollingChannelEntity.setResourceID("/" + Constants.CSE_ID + "/" + ShortName.PCH + Constants.PREFIX_SEPERATOR + generatedId);
 		if (pollingChannel.getName() != null){
-			if (!Patterns.checkResourceName(pollingChannel.getName())){
-				throw new BadRequestException("Name provided is incorrect. Must be:" + Patterns.ID_STRING);
+			if (!patterns.checkResourceName(pollingChannel.getName())){
+				throw new BadRequestException("Name provided is incorrect. Must be:" + patterns.ID_STRING);
 			}
 			pollingChannelEntity.setName(pollingChannel.getName());
 		} else {
diff --git a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/RemoteCSEController.java b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/RemoteCSEController.java
index 3a25c91..ecaafe7 100644
--- a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/RemoteCSEController.java
+++ b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/RemoteCSEController.java
@@ -98,9 +98,10 @@
 		 */
 
 		ResponsePrimitive response = new ResponsePrimitive(request);
+		Patterns patterns = new Patterns();
 
 		// get the dao of the parent
-		DAO<ResourceEntity> dao = (DAO<ResourceEntity>) Patterns.getDAO(request.getTargetId(), dbs);
+		DAO<ResourceEntity> dao = (DAO<ResourceEntity>) patterns.getDAO(request.getTargetId(), dbs);
 		if (dao == null){
 			throw new ResourceNotFoundException("Cannot find parent resource");
 		}
@@ -246,8 +247,8 @@
 		remoteCseEntity.setResourceID("/" + Constants.CSE_ID + "/" + ShortName.REMOTE_CSE + Constants.PREFIX_SEPERATOR + generatedId);
 		// set name if present and without any conflict
 		if (remoteCse.getName() != null){
-			if (!Patterns.checkResourceName(remoteCse.getName())){
-				throw new BadRequestException("Name provided is incorrect. Must be:" + Patterns.ID_STRING);
+			if (!patterns.checkResourceName(remoteCse.getName())){
+				throw new BadRequestException("Name provided is incorrect. Must be:" + patterns.ID_STRING);
 			}
 			remoteCseEntity.setName(remoteCse.getName());
 		} else {
diff --git a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/SubscriptionController.java b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/SubscriptionController.java
index 3e3e9d0..bd49ddf 100644
--- a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/SubscriptionController.java
+++ b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/controller/SubscriptionController.java
@@ -67,9 +67,10 @@
 	@Override
 	public ResponsePrimitive doCreate(RequestPrimitive request) {
 		ResponsePrimitive response = new ResponsePrimitive(request);
+		Patterns patterns = new Patterns();
 
 		// Get the DAO of the parent
-		DAO<ResourceEntity> dao = (DAO<ResourceEntity>) Patterns.getDAO(request.getTargetId(), dbs);
+		DAO<ResourceEntity> dao = (DAO<ResourceEntity>) patterns.getDAO(request.getTargetId(), dbs);
 		if (dao == null){
 			throw new ResourceNotFoundException("Cannot find parent resource");
 		}
@@ -277,8 +278,8 @@
 		subscriptionEntity.setNbOfFailedNotifications(new Integer(0));
 
 		if (subscription.getName() != null){
-			if (!Patterns.checkResourceName(subscription.getName())){
-				throw new BadRequestException("Name provided is incorrect. Must be:" + Patterns.ID_STRING);
+			if (!patterns.checkResourceName(subscription.getName())){
+				throw new BadRequestException("Name provided is incorrect. Must be:" + patterns.ID_STRING);
 			}
 			subscriptionEntity.setName(subscription.getName());
 		} else {
diff --git a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/flexcontainer/FlexContainerXMLValidator.java b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/flexcontainer/FlexContainerXMLValidator.java
index 6e1b6c6..e74dbed 100644
--- a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/flexcontainer/FlexContainerXMLValidator.java
+++ b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/flexcontainer/FlexContainerXMLValidator.java
@@ -40,18 +40,6 @@
 	/** FLEXCONTAINER XSD FOLDER PROPERTY NAME */

 	private static final String FLEXCONTAINER_XSD_FOLDER_PROPERTY_NAME = "org.eclipse.om2m.flexcontainer.xsd.folder";

 

-	/** FLEXCONTAINER XSD FOLDER PROPERTY VALUE */

-	private static String FLEXCONTAINER_XSD_FOLDER_PROPERTY_VALUE = System

-			.getProperty(FLEXCONTAINER_XSD_FOLDER_PROPERTY_NAME, null);

-

-	static {

-		// ensure there is a / at the end

-		if (FLEXCONTAINER_XSD_FOLDER_PROPERTY_VALUE != null) {

-			if (!FLEXCONTAINER_XSD_FOLDER_PROPERTY_VALUE.endsWith("/")) {

-				FLEXCONTAINER_XSD_FOLDER_PROPERTY_VALUE += "/";

-			}

-		}

-	}

 

 	/**

 	 * Validate XML payload based on the ContainerDefinition value. This method

@@ -70,6 +58,16 @@
 		// need to perform a post validation due to the fact we need

 		// to know the value of the containerDefinition.

 

+		/** FLEXCONTAINER XSD FOLDER PROPERTY VALUE */

+		String FLEXCONTAINER_XSD_FOLDER_PROPERTY_VALUE = System.getProperty(FLEXCONTAINER_XSD_FOLDER_PROPERTY_NAME, null);

+

+		// ensure there is a / at the end

+		if (FLEXCONTAINER_XSD_FOLDER_PROPERTY_VALUE != null) {

+			if (!FLEXCONTAINER_XSD_FOLDER_PROPERTY_VALUE.endsWith("/")) {

+				FLEXCONTAINER_XSD_FOLDER_PROPERTY_VALUE += "/";

+			}

+		}

+

 		if (FLEXCONTAINER_XSD_FOLDER_PROPERTY_VALUE == null) {

 			// nothing to do as there is no XSD file.

 			LOGGER.warn("No XSD folder set.");

diff --git a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/nblocking/NonBlockingWorker.java b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/nblocking/NonBlockingWorker.java
index c95104c..24b8232 100644
--- a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/nblocking/NonBlockingWorker.java
+++ b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/nblocking/NonBlockingWorker.java
@@ -60,6 +60,8 @@
 		DBService dbs = PersistenceService.getInstance().getDbService();
 		DBTransaction transaction = dbs.getDbTransaction();
 		transaction.open();
+		Patterns patterns = new Patterns();
+
 		
 		RequestEntity managedRequest = dbs.getDAOFactory().getRequestEntityDAO().
 				find(transaction, requestIdentifier);
@@ -68,7 +70,7 @@
 		request.getResponseTypeInfo().setResponseType(ResponseType.BLOCKING_REQUEST);
 		
 		// Case of retargeting, changing the request status to forwarded
-		if(!Patterns.match(Patterns.NON_RETARGETING_PATTERN, request.getTo())){
+		if(!patterns.match(patterns.NON_RETARGETING_PATTERN, request.getTo())){
 			managedRequest.setRequestStatus(RequestStatus.FORWARDED);
 			managedRequest.setStateTag(managedRequest.getStateTag().add(BigInteger.valueOf(1)));
 			dbs.getDAOFactory().getRequestEntityDAO().update(transaction, managedRequest);
diff --git a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/notifier/Notifier.java b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/notifier/Notifier.java
index 4a909c2..10dab77 100644
--- a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/notifier/Notifier.java
+++ b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/notifier/Notifier.java
@@ -1,356 +1,355 @@
-/*******************************************************************************
- * Copyright (c) 2013-2016 LAAS-CNRS (www.laas.fr)
- * 7 Colonel Roche 31077 Toulouse - France
- *
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Initial Contributors:
- *     Thierry Monteil : Project manager, technical co-manager
- *     Mahdi Ben Alaya : Technical co-manager
- *     Samir Medjiah : Technical co-manager
- *     Khalil Drira : Strategy expert
- *     Guillaume Garzone : Developer
- *     François Aïssaoui : Developer
- *
- * New contributors :
- *******************************************************************************/
-package org.eclipse.om2m.core.notifier;
-
-import java.math.BigInteger;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.eclipse.om2m.commons.constants.Constants;
-import org.eclipse.om2m.commons.constants.MimeMediaType;
-import org.eclipse.om2m.commons.constants.NotificationContentType;
-import org.eclipse.om2m.commons.constants.Operation;
-import org.eclipse.om2m.commons.constants.ResourceStatus;
-import org.eclipse.om2m.commons.constants.ResourceType;
-import org.eclipse.om2m.commons.constants.ResponseStatusCode;
-import org.eclipse.om2m.commons.constants.ResultContent;
-import org.eclipse.om2m.commons.entities.AccessControlPolicyEntity;
-import org.eclipse.om2m.commons.entities.AeEntity;
-import org.eclipse.om2m.commons.entities.CSEBaseEntity;
-import org.eclipse.om2m.commons.entities.ContainerEntity;
-import org.eclipse.om2m.commons.entities.GroupEntity;
-import org.eclipse.om2m.commons.entities.MgmtObjEntity;
-import org.eclipse.om2m.commons.entities.RemoteCSEEntity;
-import org.eclipse.om2m.commons.entities.ResourceEntity;
-import org.eclipse.om2m.commons.entities.ScheduleEntity;
-import org.eclipse.om2m.commons.entities.SubscriptionEntity;
-import org.eclipse.om2m.commons.exceptions.Om2mException;
-import org.eclipse.om2m.commons.resource.Notification;
-import org.eclipse.om2m.commons.resource.Notification.NotificationEvent;
-import org.eclipse.om2m.commons.resource.Notification.NotificationEvent.Representation;
-import org.eclipse.om2m.commons.resource.RequestPrimitive;
-import org.eclipse.om2m.commons.resource.Resource;
-import org.eclipse.om2m.commons.resource.ResponsePrimitive;
-import org.eclipse.om2m.core.comm.RestClient;
-import org.eclipse.om2m.core.datamapper.DataMapperSelector;
-import org.eclipse.om2m.core.entitymapper.EntityMapper;
-import org.eclipse.om2m.core.entitymapper.EntityMapperFactory;
-import org.eclipse.om2m.core.persistence.PersistenceService;
-import org.eclipse.om2m.core.router.Patterns;
-import org.eclipse.om2m.core.router.Router;
-import org.eclipse.om2m.core.thread.CoreExecutor;
-import org.eclipse.om2m.core.urimapper.UriMapper;
-import org.eclipse.om2m.persistence.service.DAO;
-import org.eclipse.om2m.persistence.service.DBService;
-import org.eclipse.om2m.persistence.service.DBTransaction;
-
-/**
- * Notifies subscribers when a change occurs on a resource according to their subscriptions.
- */
-public class Notifier {
-	/** Logger */
-	private static Log LOGGER = LogFactory.getLog(Notifier.class);
-	
-	private static final Integer NB_OF_FAILED_NOTIFS_BEFORE_DELETION = Integer.valueOf(System.getProperty("org.eclipse.om2m.subscriptions.nbOfFailedNotificationsBeforeDeletion", "5"));
-
-	/**
-	 * Finds all resource subscribers and notifies them.
-	 * @param statusCode - Notification status code
-	 * @param resource - Notification resource
-	 */
-	public static void notify(List<SubscriptionEntity> listSubscription, ResourceEntity resource, int resourceStatus) {
-
-		notify(listSubscription, resource, null, resourceStatus);
-	}
-	
-	/**
-	 * Find all resource subscrivers and notifies them.
-	 * @param listSubscription
-	 * @param resource
-	 * @param modifiedOnlyResource
-	 * @param resourceStatus
-	 */
-	public static void notify(List<SubscriptionEntity> listSubscription, ResourceEntity resource, Resource modifiedOnlyResource, int resourceStatus) {
-		if (listSubscription != null){
-			for(SubscriptionEntity sub : listSubscription){
-				NotificationWorker worker = new NotificationWorker(sub, resourceStatus, resource, modifiedOnlyResource);
-				CoreExecutor.postThread(worker);
-			}
-		}
-	}
-
-	/**
-	 * Used in DELETE procedure when a resource is deleted. It notifies the subscribed resource
-	 * and the parent resource subscribed entities. 
-	 * @param listSubs
-	 * @param resourceDeleted
-	 */
-	public static void notifyDeletion(List<SubscriptionEntity> listSubs, ResourceEntity resourceDeleted){
-		List<SubscriptionEntity> parentSubscriptions = getParentSubscriptions(resourceDeleted);
-		if(parentSubscriptions != null){
-			notify(parentSubscriptions, resourceDeleted, ResourceStatus.CHILD_DELETED);			
-		}
-		if(listSubs != null){
-			notify(listSubs, resourceDeleted, ResourceStatus.DELETED);			
-		}
-	}
-
-	public static void performVerificationRequest(RequestPrimitive request,
-			SubscriptionEntity subscriptionEntity) {
-		String notificationPayloadContentType = subscriptionEntity.getNotificationPayloadContentType();
-		for(String uri : subscriptionEntity.getNotificationURI()){
-			if(!uri.equals(request.getFrom())){
-				Notification notification = new Notification();
-				notification.setCreator(subscriptionEntity.getCreator());
-				notification.setVerificationRequest(true);
-				notification.setSubscriptionReference(subscriptionEntity.getHierarchicalURI());
-				notification.setSubscriptionDeletion(false);
-				RequestPrimitive notifRequest = new RequestPrimitive();
-				if (!MimeMediaType.OBJ.equals(notificationPayloadContentType)) {
-					notifRequest.setContent(DataMapperSelector.getDataMapperList().get(notificationPayloadContentType).objToString(notification));
-				} else {
-					notifRequest.setContent(notification);
-				}
-				notifRequest.setFrom("/" + Constants.CSE_ID);
-				notifRequest.setTo(uri);
-				notifRequest.setOperation(Operation.NOTIFY);
-				notifRequest.setRequestContentType(notificationPayloadContentType);
-				notifRequest.setReturnContentType(notificationPayloadContentType);
-				ResponsePrimitive resp = notify(notifRequest, uri);
-				if(resp.getResponseStatusCode().equals(ResponseStatusCode.TARGET_NOT_REACHABLE)){
-					throw new Om2mException("Error during the verification request", 
-							ResponseStatusCode.SUBSCRIPTION_VERIFICATION_INITIATION_FAILED);
-				}
-				if(resp.getResponseStatusCode().equals(ResponseStatusCode.SUBSCRIPTION_CREATOR_HAS_NO_PRIVILEGE)
-						|| resp.getResponseStatusCode().equals(ResponseStatusCode.SUBSCRIPTION_HOST_HAS_NO_PRIVILEGE)){
-					throw new Om2mException(resp.getResponseStatusCode());
-				}
-			}
-		}
-	}
-
-	public static ResponsePrimitive notify(RequestPrimitive request, String contact){
-		// Check whether the subscription contact is protocol-dependent or not.
-		LOGGER.info("Sending notify request to: " + contact);
-		if(contact.matches(".*://.*")){ 
-			// Contact = protocol-dependent -> direct notification using the rest client.
-			request.setTo(contact);
-			return RestClient.sendRequest(request);
-		}else{
-			request.setTargetId(contact);
-			request.setFrom(Constants.ADMIN_REQUESTING_ENTITY);
-			LOGGER.info("Sending notify request...");
-			return new Router().doRequest(request);
-		}
-	}
-
-	/**
-	 * Used to retrieve the subscription list of the parent resource
-	 * @param resource 
-	 * @return
-	 */
-	private static List<SubscriptionEntity> getParentSubscriptions(
-			ResourceEntity resourceDeleted) {
-		List<SubscriptionEntity> result;
-		// Get parent id
-		String[] ids = resourceDeleted.getHierarchicalURI().split("/");
-		String parentHierarchicalId = resourceDeleted.getHierarchicalURI().replace("/" + ids[ids.length - 1], "");
-		String parentId = UriMapper.getNonHierarchicalUri(parentHierarchicalId);
-		// get parent entity
-		DBService dbs = PersistenceService.getInstance().getDbService();
-
-		DAO<?> dao = Patterns.getDAO(parentId, dbs);
-		DBTransaction transaction = dbs.getDbTransaction();
-		transaction.open();
-		ResourceEntity parentEntity = (ResourceEntity) dao.find(transaction, parentId);
-		// get the sub list from parent
-		switch(parentEntity.getResourceType().intValue()){
-		case ResourceType.ACCESS_CONTROL_POLICY:
-			AccessControlPolicyEntity acp = (AccessControlPolicyEntity) parentEntity;
-			result = acp.getChildSubscriptions();
-			break;
-		case ResourceType.AE:
-			AeEntity ae = (AeEntity) parentEntity;
-			result = ae.getSubscriptions();
-			break;
-		case ResourceType.CONTAINER:
-			ContainerEntity cnt = (ContainerEntity) parentEntity;
-			result = cnt.getSubscriptions();
-			break;
-		case ResourceType.CSE_BASE:
-			CSEBaseEntity csb = (CSEBaseEntity) parentEntity;
-			result = csb.getSubscriptions();
-			break;
-		case ResourceType.GROUP:
-			GroupEntity group = (GroupEntity) parentEntity;
-			result = group.getSubscriptions();
-			break;
-		case ResourceType.REMOTE_CSE:
-			RemoteCSEEntity csr = (RemoteCSEEntity) parentEntity;
-			result = csr.getSubscriptions();
-			break;
-		case ResourceType.SCHEDULE:
-			ScheduleEntity schedule = (ScheduleEntity) parentEntity;
-			result = schedule.getSubscriptions();
-			break;
-		default:
-			result = new ArrayList<SubscriptionEntity>();
-		}
-		transaction.close();
-		return result;
-	}
-
-	/**
-	 * Worker that perform the notification task for a subscription
-	 *
-	 */
-	static class NotificationWorker implements Runnable {
-		/** resource status of the notification */
-		private int resourceStatus;
-		/** the subscription to handle */
-		private SubscriptionEntity sub;
-		/** the resource to be sent */
-		private ResourceEntity resource;
-		/** the resource to be sent - modified attribute */
-		private Resource modifiedOnlyResource;
-
-		public NotificationWorker(SubscriptionEntity sub, int resourceStatus, ResourceEntity resource, Resource modifiedOnlyResource) {
-			this.resourceStatus = resourceStatus;
-			this.sub = sub;
-			this.resource = resource;
-			this.modifiedOnlyResource = modifiedOnlyResource;
-		}
-
-		@SuppressWarnings("unchecked")
-		@Override
-		public void run() {
-			final RequestPrimitive request = new RequestPrimitive();
-			Notification notification = new Notification();
-			NotificationEvent notifEvent = new NotificationEvent();
-			notification.setNotificationEvent(notifEvent);
-
-			// Set attributes of notification object
-			notifEvent.setResourceStatus(BigInteger.valueOf(resourceStatus));
-			notification.setCreator(sub.getCreator());
-
-			// Set request parameters
-			request.setOperation(Operation.NOTIFY);
-			request.setFrom("/" + Constants.CSE_ID);
-
-			if(resourceStatus == ResourceStatus.DELETED){
-				notification.setSubscriptionDeletion(true);
-			} else {
-				notification.setSubscriptionDeletion(false);
-			}
-
-			notification.setSubscriptionReference(sub.getResourceID());
-
-			// Get the representation of the content
-			Resource serializableResource;
-			EntityMapper mapper ;
-			if (sub.getNotificationContentType() != null){
-				if (resource.getResourceType().equals(ResourceType.MGMT_OBJ)) {
-					mapper = EntityMapperFactory.getMapperForMgmtObj((MgmtObjEntity) resource);
-				} else {
-					mapper = EntityMapperFactory.
-							getMapperFromResourceType(resource.getResourceType().intValue());
-				}
-				if(sub.getNotificationContentType().equals(NotificationContentType.MODIFIED_ATTRIBUTES)){
-					Representation representation = new Representation();
-					if (modifiedOnlyResource != null) {
-						// Gregory BONNARDEL - 26 Avril 2016
-						// as all Controllers have not been modified
-						// for modified controllers, use the resource provided by the controller
-						representation.setResource(modifiedOnlyResource);
-					} else {
-						// for non modified controllers, send the ResourceEntity 
-						// but it is not compliant with the specs
-						serializableResource  = (Resource) mapper
-								.mapEntityToResource(resource, ResultContent.ATTRIBUTES, 0, 0);
-						representation.setResource(serializableResource);
-					}
-					notification.getNotificationEvent().setRepresentation(representation);
-					request.setRequestContentType(sub.getNotificationPayloadContentType());
-				} else if(sub.getNotificationContentType().equals(NotificationContentType.WHOLE_RESOURCE)){
-					serializableResource = (Resource) mapper.mapEntityToResource(resource, ResultContent.ATTRIBUTES, 0, 0);
-					Representation representation = new Representation();
-					representation.setResource(serializableResource);
-					notification.getNotificationEvent().setRepresentation(representation);
-					request.setRequestContentType(sub.getNotificationPayloadContentType());
-				} 
-			} 
-			// Set the content
-			request.setContent(DataMapperSelector.getDataMapperList().get(sub.getNotificationPayloadContentType()).objToString(notification));
-			// For each notification URI: send the notify request
-			for(final String uri : sub.getNotificationURI()){
-				CoreExecutor.postThread(new Runnable(){
-					public void run() {
-						ResponsePrimitive response = Notifier.notify(request, uri);  
-						if (ResponseStatusCode.OK.equals(response.getResponseStatusCode())) {
-							// notify ok
-							updateSubscription(sub.getResourceID(), 0);
-							LOGGER.debug("notify OK for subscription " + sub.getResourceID());
-						} else {
-							// notify KO
-							Integer nbOfFailed = sub.getNbOfFailedNotifications();
-							if (nbOfFailed == null) {
-								nbOfFailed = 0;
-							}
-							if (nbOfFailed > NB_OF_FAILED_NOTIFS_BEFORE_DELETION) {
-								// delete notification
-								deleteSubscription(sub.getResourceID());
-								LOGGER.error("Reach the limit of failed notifs --> delete subscription " + sub.getResourceID());
-							} else {
-								updateSubscription(sub.getResourceID(), nbOfFailed+1);
-								LOGGER.warn("unable to notify, increase failed notifs(" + nbOfFailed +") for subscription " + sub.getResourceID());
-							}
-						}
-					};
-				});
-			}
-		}
-	}
-	
-	private static void deleteSubscription(String resourceId) {
-		DBService dbs = PersistenceService.getInstance().getDbService();
-		DBTransaction dbTransaction = dbs.getDbTransaction();
-		dbTransaction.open();
-		SubscriptionEntity subscriptionEntityToBeDeleted = dbs.getDAOFactory().getSubsciptionDAO().find(dbTransaction, resourceId);
-		dbs.getDAOFactory().getSubsciptionDAO().delete(dbTransaction, subscriptionEntityToBeDeleted);
-		dbTransaction.commit();
-		dbTransaction.close();
-	}
-	
-	private static void updateSubscription(String resourceId, Integer nbOfFailedNotification) {
-		DBService dbs = PersistenceService.getInstance().getDbService();
-		DBTransaction dbTransaction = dbs.getDbTransaction();
-		dbTransaction.open();
-		SubscriptionEntity subscriptionEntityToBeUpdated = dbs.getDAOFactory().getSubsciptionDAO().find(dbTransaction, resourceId);
-		subscriptionEntityToBeUpdated.setNbOfFailedNotifications(nbOfFailedNotification);
-		dbs.getDAOFactory().getSubsciptionDAO().update(dbTransaction, subscriptionEntityToBeUpdated);
-		dbTransaction.commit();
-		dbTransaction.close();
-	}
-
-}
+/*******************************************************************************

+ * Copyright (c) 2013-2016 LAAS-CNRS (www.laas.fr)

+ * 7 Colonel Roche 31077 Toulouse - France

+ *

+ * All rights reserved. This program and the accompanying materials

+ * are made available under the terms of the Eclipse Public License v1.0

+ * which accompanies this distribution, and is available at

+ * http://www.eclipse.org/legal/epl-v10.html

+ *

+ * Initial Contributors:

+ *     Thierry Monteil : Project manager, technical co-manager

+ *     Mahdi Ben Alaya : Technical co-manager

+ *     Samir Medjiah : Technical co-manager

+ *     Khalil Drira : Strategy expert

+ *     Guillaume Garzone : Developer

+ *     François Aïssaoui : Developer

+ *

+ * New contributors :

+ *******************************************************************************/

+package org.eclipse.om2m.core.notifier;

+

+import java.math.BigInteger;

+import java.util.ArrayList;

+import java.util.List;

+

+import org.apache.commons.logging.Log;

+import org.apache.commons.logging.LogFactory;

+import org.eclipse.om2m.commons.constants.Constants;

+import org.eclipse.om2m.commons.constants.MimeMediaType;

+import org.eclipse.om2m.commons.constants.NotificationContentType;

+import org.eclipse.om2m.commons.constants.Operation;

+import org.eclipse.om2m.commons.constants.ResourceStatus;

+import org.eclipse.om2m.commons.constants.ResourceType;

+import org.eclipse.om2m.commons.constants.ResponseStatusCode;

+import org.eclipse.om2m.commons.constants.ResultContent;

+import org.eclipse.om2m.commons.entities.AccessControlPolicyEntity;

+import org.eclipse.om2m.commons.entities.AeEntity;

+import org.eclipse.om2m.commons.entities.CSEBaseEntity;

+import org.eclipse.om2m.commons.entities.ContainerEntity;

+import org.eclipse.om2m.commons.entities.GroupEntity;

+import org.eclipse.om2m.commons.entities.MgmtObjEntity;

+import org.eclipse.om2m.commons.entities.RemoteCSEEntity;

+import org.eclipse.om2m.commons.entities.ResourceEntity;

+import org.eclipse.om2m.commons.entities.ScheduleEntity;

+import org.eclipse.om2m.commons.entities.SubscriptionEntity;

+import org.eclipse.om2m.commons.exceptions.Om2mException;

+import org.eclipse.om2m.commons.resource.Notification;

+import org.eclipse.om2m.commons.resource.Notification.NotificationEvent;

+import org.eclipse.om2m.commons.resource.Notification.NotificationEvent.Representation;

+import org.eclipse.om2m.commons.resource.RequestPrimitive;

+import org.eclipse.om2m.commons.resource.Resource;

+import org.eclipse.om2m.commons.resource.ResponsePrimitive;

+import org.eclipse.om2m.core.comm.RestClient;

+import org.eclipse.om2m.core.datamapper.DataMapperSelector;

+import org.eclipse.om2m.core.entitymapper.EntityMapper;

+import org.eclipse.om2m.core.entitymapper.EntityMapperFactory;

+import org.eclipse.om2m.core.persistence.PersistenceService;

+import org.eclipse.om2m.core.router.Patterns;

+import org.eclipse.om2m.core.router.Router;

+import org.eclipse.om2m.core.thread.CoreExecutor;

+import org.eclipse.om2m.core.urimapper.UriMapper;

+import org.eclipse.om2m.persistence.service.DAO;

+import org.eclipse.om2m.persistence.service.DBService;

+import org.eclipse.om2m.persistence.service.DBTransaction;

+

+/**

+ * Notifies subscribers when a change occurs on a resource according to their subscriptions.

+ */

+public class Notifier {

+	/** Logger */

+	private static Log LOGGER = LogFactory.getLog(Notifier.class);

+	

+	/**

+	 * Finds all resource subscribers and notifies them.

+	 * @param statusCode - Notification status code

+	 * @param resource - Notification resource

+	 */

+	public static void notify(List<SubscriptionEntity> listSubscription, ResourceEntity resource, int resourceStatus) {

+		notify(listSubscription, resource, null, resourceStatus);

+	}

+	

+	/**

+	 * Find all resource subscrivers and notifies them.

+	 * @param listSubscription

+	 * @param resource

+	 * @param modifiedOnlyResource

+	 * @param resourceStatus

+	 */

+	public static void notify(List<SubscriptionEntity> listSubscription, ResourceEntity resource, Resource modifiedOnlyResource, int resourceStatus) {

+		if (listSubscription != null){

+			for(SubscriptionEntity sub : listSubscription){

+				NotificationWorker worker = new NotificationWorker(sub, resourceStatus, resource, modifiedOnlyResource);

+				CoreExecutor.postThread(worker);

+			}

+		}

+	}

+

+	/**

+	 * Used in DELETE procedure when a resource is deleted. It notifies the subscribed resource

+	 * and the parent resource subscribed entities. 

+	 * @param listSubs

+	 * @param resourceDeleted

+	 */

+	public static void notifyDeletion(List<SubscriptionEntity> listSubs, ResourceEntity resourceDeleted){

+		List<SubscriptionEntity> parentSubscriptions = getParentSubscriptions(resourceDeleted);

+		if(parentSubscriptions != null){

+			notify(parentSubscriptions, resourceDeleted, ResourceStatus.CHILD_DELETED);			

+		}

+		if(listSubs != null){

+			notify(listSubs, resourceDeleted, ResourceStatus.DELETED);			

+		}

+	}

+

+	public static void performVerificationRequest(RequestPrimitive request,

+			SubscriptionEntity subscriptionEntity) {

+		String notificationPayloadContentType = subscriptionEntity.getNotificationPayloadContentType();

+		for(String uri : subscriptionEntity.getNotificationURI()){

+			if(!uri.equals(request.getFrom())){

+				Notification notification = new Notification();

+				notification.setCreator(subscriptionEntity.getCreator());

+				notification.setVerificationRequest(true);

+				notification.setSubscriptionReference(subscriptionEntity.getHierarchicalURI());

+				notification.setSubscriptionDeletion(false);

+				RequestPrimitive notifRequest = new RequestPrimitive();

+				if (!MimeMediaType.OBJ.equals(notificationPayloadContentType)) {

+					notifRequest.setContent(DataMapperSelector.getDataMapperList().get(notificationPayloadContentType).objToString(notification));

+				} else {

+					notifRequest.setContent(notification);

+				}

+				notifRequest.setFrom("/" + Constants.CSE_ID);

+				notifRequest.setTo(uri);

+				notifRequest.setOperation(Operation.NOTIFY);

+				notifRequest.setRequestContentType(notificationPayloadContentType);

+				notifRequest.setReturnContentType(notificationPayloadContentType);

+				ResponsePrimitive resp = notify(notifRequest, uri);

+				if(resp.getResponseStatusCode().equals(ResponseStatusCode.TARGET_NOT_REACHABLE)){

+					throw new Om2mException("Error during the verification request", 

+							ResponseStatusCode.SUBSCRIPTION_VERIFICATION_INITIATION_FAILED);

+				}

+				if(resp.getResponseStatusCode().equals(ResponseStatusCode.SUBSCRIPTION_CREATOR_HAS_NO_PRIVILEGE)

+						|| resp.getResponseStatusCode().equals(ResponseStatusCode.SUBSCRIPTION_HOST_HAS_NO_PRIVILEGE)){

+					throw new Om2mException(resp.getResponseStatusCode());

+				}

+			}

+		}

+	}

+

+	public static ResponsePrimitive notify(RequestPrimitive request, String contact){

+		// Check whether the subscription contact is protocol-dependent or not.

+		LOGGER.info("Sending notify request to: " + contact);

+		if(contact.matches(".*://.*")){ 

+			// Contact = protocol-dependent -> direct notification using the rest client.

+			request.setTo(contact);

+			return RestClient.sendRequest(request);

+		}else{

+			request.setTargetId(contact);

+			request.setFrom(Constants.ADMIN_REQUESTING_ENTITY);

+			LOGGER.info("Sending notify request...");

+			return new Router().doRequest(request);

+		}

+	}

+

+	/**

+	 * Used to retrieve the subscription list of the parent resource

+	 * @param resource 

+	 * @return

+	 */

+	private static List<SubscriptionEntity> getParentSubscriptions(

+			ResourceEntity resourceDeleted) {

+		List<SubscriptionEntity> result;

+		// Get parent id

+		String[] ids = resourceDeleted.getHierarchicalURI().split("/");

+		String parentHierarchicalId = resourceDeleted.getHierarchicalURI().replace("/" + ids[ids.length - 1], "");

+		String parentId = UriMapper.getNonHierarchicalUri(parentHierarchicalId);

+		// get parent entity

+		DBService dbs = PersistenceService.getInstance().getDbService();

+		Patterns patterns = new Patterns();

+

+

+		DAO<?> dao = patterns.getDAO(parentId, dbs);

+		DBTransaction transaction = dbs.getDbTransaction();

+		transaction.open();

+		ResourceEntity parentEntity = (ResourceEntity) dao.find(transaction, parentId);

+		// get the sub list from parent

+		switch(parentEntity.getResourceType().intValue()){

+		case ResourceType.ACCESS_CONTROL_POLICY:

+			AccessControlPolicyEntity acp = (AccessControlPolicyEntity) parentEntity;

+			result = acp.getChildSubscriptions();

+			break;

+		case ResourceType.AE:

+			AeEntity ae = (AeEntity) parentEntity;

+			result = ae.getSubscriptions();

+			break;

+		case ResourceType.CONTAINER:

+			ContainerEntity cnt = (ContainerEntity) parentEntity;

+			result = cnt.getSubscriptions();

+			break;

+		case ResourceType.CSE_BASE:

+			CSEBaseEntity csb = (CSEBaseEntity) parentEntity;

+			result = csb.getSubscriptions();

+			break;

+		case ResourceType.GROUP:

+			GroupEntity group = (GroupEntity) parentEntity;

+			result = group.getSubscriptions();

+			break;

+		case ResourceType.REMOTE_CSE:

+			RemoteCSEEntity csr = (RemoteCSEEntity) parentEntity;

+			result = csr.getSubscriptions();

+			break;

+		case ResourceType.SCHEDULE:

+			ScheduleEntity schedule = (ScheduleEntity) parentEntity;

+			result = schedule.getSubscriptions();

+			break;

+		default:

+			result = new ArrayList<SubscriptionEntity>();

+		}

+		transaction.close();

+		return result;

+	}

+

+	/**

+	 * Worker that perform the notification task for a subscription

+	 *

+	 */

+	static class NotificationWorker implements Runnable {

+		/** resource status of the notification */

+		private int resourceStatus;

+		/** the subscription to handle */

+		private SubscriptionEntity sub;

+		/** the resource to be sent */

+		private ResourceEntity resource;

+		/** the resource to be sent - modified attribute */

+		private Resource modifiedOnlyResource;

+

+		public NotificationWorker(SubscriptionEntity sub, int resourceStatus, ResourceEntity resource, Resource modifiedOnlyResource) {

+			this.resourceStatus = resourceStatus;

+			this.sub = sub;

+			this.resource = resource;

+			this.modifiedOnlyResource = modifiedOnlyResource;

+		}

+

+		@SuppressWarnings("unchecked")

+		@Override

+		public void run() {

+			final Integer NB_OF_FAILED_NOTIFS_BEFORE_DELETION = Integer.valueOf(System.getProperty("org.eclipse.om2m.subscriptions.nbOfFailedNotificationsBeforeDeletion", "5"));

+

+			final RequestPrimitive request = new RequestPrimitive();

+			Notification notification = new Notification();

+			NotificationEvent notifEvent = new NotificationEvent();

+			notification.setNotificationEvent(notifEvent);

+

+			// Set attributes of notification object

+			notifEvent.setResourceStatus(BigInteger.valueOf(resourceStatus));

+			notification.setCreator(sub.getCreator());

+

+			// Set request parameters

+			request.setOperation(Operation.NOTIFY);

+			request.setFrom("/" + Constants.CSE_ID);

+

+			if(resourceStatus == ResourceStatus.DELETED){

+				notification.setSubscriptionDeletion(true);

+			} else {

+				notification.setSubscriptionDeletion(false);

+			}

+

+			notification.setSubscriptionReference(sub.getResourceID());

+

+			// Get the representation of the content

+			Resource serializableResource;

+			EntityMapper mapper ;

+			if (sub.getNotificationContentType() != null){

+				if (resource.getResourceType().equals(ResourceType.MGMT_OBJ)) {

+					mapper = EntityMapperFactory.getMapperForMgmtObj((MgmtObjEntity) resource);

+				} else {

+					mapper = EntityMapperFactory.

+							getMapperFromResourceType(resource.getResourceType().intValue());

+				}

+				if(sub.getNotificationContentType().equals(NotificationContentType.MODIFIED_ATTRIBUTES)){

+					Representation representation = new Representation();

+					if (modifiedOnlyResource != null) {

+						// Gregory BONNARDEL - 26 Avril 2016

+						// as all Controllers have not been modified

+						// for modified controllers, use the resource provided by the controller

+						representation.setResource(modifiedOnlyResource);

+					} else {

+						// for non modified controllers, send the ResourceEntity 

+						// but it is not compliant with the specs

+						serializableResource  = (Resource) mapper

+								.mapEntityToResource(resource, ResultContent.ATTRIBUTES, 0, 0);

+						representation.setResource(serializableResource);

+					}

+					notification.getNotificationEvent().setRepresentation(representation);

+					request.setRequestContentType(sub.getNotificationPayloadContentType());

+				} else if(sub.getNotificationContentType().equals(NotificationContentType.WHOLE_RESOURCE)){

+					serializableResource = (Resource) mapper.mapEntityToResource(resource, ResultContent.ATTRIBUTES, 0, 0);

+					Representation representation = new Representation();

+					representation.setResource(serializableResource);

+					notification.getNotificationEvent().setRepresentation(representation);

+					request.setRequestContentType(sub.getNotificationPayloadContentType());

+				} 

+			} 

+			// Set the content

+			request.setContent(DataMapperSelector.getDataMapperList().get(sub.getNotificationPayloadContentType()).objToString(notification));

+			// For each notification URI: send the notify request

+			for(final String uri : sub.getNotificationURI()){

+				CoreExecutor.postThread(new Runnable(){

+					public void run() {

+						ResponsePrimitive response = Notifier.notify(request, uri);  

+						if (ResponseStatusCode.OK.equals(response.getResponseStatusCode())) {

+							// notify ok

+							updateSubscription(sub.getResourceID(), 0);

+							LOGGER.debug("notify OK for subscription " + sub.getResourceID());

+						} else {

+							// notify KO

+							Integer nbOfFailed = sub.getNbOfFailedNotifications();

+							if (nbOfFailed == null) {

+								nbOfFailed = 0;

+							}

+							if (nbOfFailed > NB_OF_FAILED_NOTIFS_BEFORE_DELETION) {

+								// delete notification

+								deleteSubscription(sub.getResourceID());

+								LOGGER.error("Reach the limit of failed notifs --> delete subscription " + sub.getResourceID());

+							} else {

+								updateSubscription(sub.getResourceID(), nbOfFailed+1);

+								LOGGER.warn("unable to notify, increase failed notifs(" + nbOfFailed +") for subscription " + sub.getResourceID());

+							}

+						}

+					};

+				});

+			}

+		}

+	}

+	

+	private static void deleteSubscription(String resourceId) {

+		DBService dbs = PersistenceService.getInstance().getDbService();

+		DBTransaction dbTransaction = dbs.getDbTransaction();

+		dbTransaction.open();

+		SubscriptionEntity subscriptionEntityToBeDeleted = dbs.getDAOFactory().getSubsciptionDAO().find(dbTransaction, resourceId);

+		dbs.getDAOFactory().getSubsciptionDAO().delete(dbTransaction, subscriptionEntityToBeDeleted);

+		dbTransaction.commit();

+		dbTransaction.close();

+	}

+	

+	private static void updateSubscription(String resourceId, Integer nbOfFailedNotification) {

+		DBService dbs = PersistenceService.getInstance().getDbService();

+		DBTransaction dbTransaction = dbs.getDbTransaction();

+		dbTransaction.open();

+		SubscriptionEntity subscriptionEntityToBeUpdated = dbs.getDAOFactory().getSubsciptionDAO().find(dbTransaction, resourceId);

+		subscriptionEntityToBeUpdated.setNbOfFailedNotifications(nbOfFailedNotification);

+		dbs.getDAOFactory().getSubsciptionDAO().update(dbTransaction, subscriptionEntityToBeUpdated);

+		dbTransaction.commit();

+		dbTransaction.close();

+	}

+

+}

diff --git a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/redirector/Redirector.java b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/redirector/Redirector.java
index 2e7b34d..68c06ce 100644
--- a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/redirector/Redirector.java
+++ b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/redirector/Redirector.java
@@ -51,7 +51,7 @@
  * {@link RemoteCSE} children.

  *

  */

-public class Redirector {

+public class Redirector implements Constants {

 

 	private static Log LOGGER = LogFactory.getLog(Redirector.class);

 

diff --git a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/router/Patterns.java b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/router/Patterns.java
index ed6c75d..d2fe46f 100644
--- a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/router/Patterns.java
+++ b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/router/Patterns.java
@@ -32,18 +32,18 @@
  * Patterns used as regular expressions and conditions
  *
  */
-public class Patterns {
+public class Patterns implements Constants {
 	
 	/** All short name for filtering */
-	private static final String ALL_SHORT_NAMES = ShortName.ACP+"|"+ShortName.AE+"|"+ShortName.CNT+
+	public final String ALL_SHORT_NAMES = ShortName.ACP+"|"+ShortName.AE+"|"+ShortName.CNT+
 			"|"+ShortName.CIN + "|" + ShortName.REMOTE_CSE + "|" + ShortName.LATEST + "|" + ShortName.OLDEST +
 			"|" + ShortName.GROUP + "|" + ShortName.FANOUTPOINT + "|" + ShortName.SUB + "|" + ShortName.PCH + 
 			"|" + ShortName.POLLING_CHANNEL_URI + "|" + ShortName.REQ + "|" + ShortName.NODE +
 			"|" + ShortName.ANI + "|" + ShortName.ANDI + "|" + ShortName.FCNT + "|" + ShortName.DAC;
 	
-	private static final String NON_HIERARCHICAL_ID = "(" + Constants.PREFIX_SEPERATOR +"(\\b\\w+\\b)?)" ;
+	public final String NON_HIERARCHICAL_ID = "(" + Constants.PREFIX_SEPERATOR +"(\\b\\w+\\b)?)" ;
 	
-	public static final Pattern UNAUTHORIZED_NAMES = Pattern.compile(ShortName.ACP + NON_HIERARCHICAL_ID + "?|" + 
+	public final Pattern UNAUTHORIZED_NAMES = Pattern.compile(ShortName.ACP + NON_HIERARCHICAL_ID + "?|" + 
 					ShortName.AE + NON_HIERARCHICAL_ID + "?|" + ShortName.CNT + NON_HIERARCHICAL_ID + "?|" +
 					ShortName.CIN + NON_HIERARCHICAL_ID + "?|" + ShortName.REMOTE_CSE + NON_HIERARCHICAL_ID + "?|" +
 					ShortName.LATEST + NON_HIERARCHICAL_ID + "?|" + ShortName.OLDEST + NON_HIERARCHICAL_ID + "?|" +
@@ -52,60 +52,60 @@
 					"?|" + ShortName.REQ + "?|" + ShortName.NODE + "?|" + ShortName.FCNT + "?|" + ShortName.DAC + "?");
 	
 	/** Main id string */
-	public static final String ID_STRING = "([A-Za-z0-9_\\-~#]|\\.)+";
+	public final String ID_STRING = "([A-Za-z0-9_\\-~#]|\\.)+";
 	
 	/** Main id pattern */
-	public static final Pattern ID_PATTERN = Pattern.compile(ID_STRING);
+	public final Pattern ID_PATTERN = Pattern.compile(ID_STRING);
 	
     /** CseBase resource uri pattern. */
-    public static final Pattern CSE_BASE_PATTERN= Pattern.compile("/" + Constants.CSE_ID);
+    public final Pattern CSE_BASE_PATTERN= Pattern.compile("/" + Constants.CSE_ID);
     
     /** AccessControlPolicy uri pattern MAY BE NOT COMPLETE */
-    public static final Pattern ACP_PATTERN = Pattern.compile(CSE_BASE_PATTERN + "/" + ShortName.ACP + Constants.PREFIX_SEPERATOR + ID_STRING );
+    public final Pattern ACP_PATTERN = Pattern.compile(CSE_BASE_PATTERN + "/" + ShortName.ACP + Constants.PREFIX_SEPERATOR + ID_STRING );
     
-    public static final Pattern AE_PATTERN = Pattern.compile(CSE_BASE_PATTERN + "/" + "(C|S)" + ID_STRING);
+    public final Pattern AE_PATTERN = Pattern.compile(CSE_BASE_PATTERN + "/" + "(C|S)" + ID_STRING);
     
-    public static final Pattern AEANNC_PATTERN = Pattern.compile(CSE_BASE_PATTERN + "/" + ShortName.AE_ANNC + ID_STRING);
+    public final Pattern AEANNC_PATTERN = Pattern.compile(CSE_BASE_PATTERN + "/" + ShortName.AE_ANNC + ID_STRING);
     
-    public static final Pattern CONTAINER_PATTERN = Pattern.compile(CSE_BASE_PATTERN + "/" + ShortName.CNT + Constants.PREFIX_SEPERATOR + ID_STRING);
+    public final Pattern CONTAINER_PATTERN = Pattern.compile(CSE_BASE_PATTERN + "/" + ShortName.CNT + Constants.PREFIX_SEPERATOR + ID_STRING);
     
-    public static final Pattern DYNAMIC_AUTHORIZATION_CONSULTATION_PATTERN = Pattern.compile(CSE_BASE_PATTERN + "/" + ShortName.DAC + Constants.PREFIX_SEPERATOR + ID_STRING);
+    public final Pattern DYNAMIC_AUTHORIZATION_CONSULTATION_PATTERN = Pattern.compile(CSE_BASE_PATTERN + "/" + ShortName.DAC + Constants.PREFIX_SEPERATOR + ID_STRING);
 
-    public static final Pattern FLEXCONTAINER_PATTERN = Pattern.compile(CSE_BASE_PATTERN + "/" + ShortName.FCNT + Constants.PREFIX_SEPERATOR + ID_STRING);
+    public final Pattern FLEXCONTAINER_PATTERN = Pattern.compile(CSE_BASE_PATTERN + "/" + ShortName.FCNT + Constants.PREFIX_SEPERATOR + ID_STRING);
     
-    public static final Pattern FLEXCONTAINER_ANNC_PATTERN = Pattern.compile(CSE_BASE_PATTERN + "/" + ShortName.FCNTA + Constants.PREFIX_SEPERATOR + ID_STRING);
+    public final Pattern FLEXCONTAINER_ANNC_PATTERN = Pattern.compile(CSE_BASE_PATTERN + "/" + ShortName.FCNTA + Constants.PREFIX_SEPERATOR + ID_STRING);
 
-    public static final Pattern CONTENTINSTANCE_PATTERN = Pattern.compile(CSE_BASE_PATTERN + "/" + ShortName.CIN + Constants.PREFIX_SEPERATOR + ID_STRING);
+    public final Pattern CONTENTINSTANCE_PATTERN = Pattern.compile(CSE_BASE_PATTERN + "/" + ShortName.CIN + Constants.PREFIX_SEPERATOR + ID_STRING);
     
-    public static final Pattern REMOTE_CSE_PATTERN = Pattern.compile(CSE_BASE_PATTERN + "/" + ShortName.REMOTE_CSE + Constants.PREFIX_SEPERATOR + ID_STRING);
+    public final Pattern REMOTE_CSE_PATTERN = Pattern.compile(CSE_BASE_PATTERN + "/" + ShortName.REMOTE_CSE + Constants.PREFIX_SEPERATOR + ID_STRING);
     
-    public static final Pattern GROUP_PATTERN = Pattern.compile(CSE_BASE_PATTERN + "/" + ShortName.GROUP + Constants.PREFIX_SEPERATOR + ID_STRING);
+    public final Pattern GROUP_PATTERN = Pattern.compile(CSE_BASE_PATTERN + "/" + ShortName.GROUP + Constants.PREFIX_SEPERATOR + ID_STRING);
     
-    public static final Pattern SUBSCRIPTION_PATTERN = Pattern.compile(CSE_BASE_PATTERN + "/" + ShortName.SUB + Constants.PREFIX_SEPERATOR + ID_STRING);
+    public final Pattern SUBSCRIPTION_PATTERN = Pattern.compile(CSE_BASE_PATTERN + "/" + ShortName.SUB + Constants.PREFIX_SEPERATOR + ID_STRING);
     
-    public static final Pattern POLLING_CHANNEL_PATTERN = Pattern.compile(CSE_BASE_PATTERN + "/" + ShortName.PCH + Constants.PREFIX_SEPERATOR + ID_STRING);
+    public final Pattern POLLING_CHANNEL_PATTERN = Pattern.compile(CSE_BASE_PATTERN + "/" + ShortName.PCH + Constants.PREFIX_SEPERATOR + ID_STRING);
     
-    public static final Pattern POLLING_CHANNEL_URI_PATTERN = Pattern.compile(CSE_BASE_PATTERN + "/" + ShortName.POLLING_CHANNEL_URI + Constants.PREFIX_SEPERATOR + ID_STRING);
+    public final Pattern POLLING_CHANNEL_URI_PATTERN = Pattern.compile(CSE_BASE_PATTERN + "/" + ShortName.POLLING_CHANNEL_URI + Constants.PREFIX_SEPERATOR + ID_STRING);
     
-    public static final Pattern REQUEST_PATTERN = Pattern.compile(CSE_BASE_PATTERN + "/" + ShortName.REQ + Constants.PREFIX_SEPERATOR + ID_STRING);
+    public final Pattern REQUEST_PATTERN = Pattern.compile(CSE_BASE_PATTERN + "/" + ShortName.REQ + Constants.PREFIX_SEPERATOR + ID_STRING);
     
-    public static final Pattern NON_RETARGETING_PATTERN = Pattern.compile("/" + Constants.CSE_ID + "(/("+ID_STRING+")?)*"); 
+    public final Pattern NON_RETARGETING_PATTERN = Pattern.compile("/" + Constants.CSE_ID + "(/("+ID_STRING+")?)*"); 
     
-    public static final String FANOUT_POINT_MATCH = "/" + ShortName.FANOUTPOINT ;
+    public final String FANOUT_POINT_MATCH = "/" + ShortName.FANOUTPOINT ;
     
-    public static final Pattern NODE_PATTERN = Pattern.compile(CSE_BASE_PATTERN + "/" + ShortName.NODE + Constants.PREFIX_SEPERATOR + ID_STRING);
+    public final Pattern NODE_PATTERN = Pattern.compile(CSE_BASE_PATTERN + "/" + ShortName.NODE + Constants.PREFIX_SEPERATOR + ID_STRING);
 
-    public static final Pattern AREA_NW_INFO_PATTERN = Pattern.compile(CSE_BASE_PATTERN + "/" + ShortName.ANI + Constants.PREFIX_SEPERATOR + ID_STRING);
+    public final Pattern AREA_NW_INFO_PATTERN = Pattern.compile(CSE_BASE_PATTERN + "/" + ShortName.ANI + Constants.PREFIX_SEPERATOR + ID_STRING);
 
-	public static final Pattern AREA_NWK_DEVICE_INFO_PATTERN = Pattern.compile(CSE_BASE_PATTERN + "/" + ShortName.ANDI + Constants.PREFIX_SEPERATOR + ID_STRING);
+	public final Pattern AREA_NWK_DEVICE_INFO_PATTERN = Pattern.compile(CSE_BASE_PATTERN + "/" + ShortName.ANDI + Constants.PREFIX_SEPERATOR + ID_STRING);
 
     /** Non-hierarchical URI pattern */
-    public static final Pattern NON_HIERARCHICAL_PATTERN = Pattern.compile(
+    public final Pattern NON_HIERARCHICAL_PATTERN = Pattern.compile(
     		"(" + CSE_BASE_PATTERN + "/(" + ALL_SHORT_NAMES + ")" + Constants.PREFIX_SEPERATOR + ID_STRING + ")|(" + CSE_BASE_PATTERN+ ")|" +
     		AE_PATTERN.pattern()); 
     
     /** Hierarchical URI Pattern */
-    public static final Pattern HIERARCHICAL_PATTERN = Pattern.compile(
+    public final Pattern HIERARCHICAL_PATTERN = Pattern.compile(
     		CSE_BASE_PATTERN + "(/" + Constants.CSE_NAME + "(/"+ ID_PATTERN +")*)?"
     		);
     
@@ -115,7 +115,7 @@
 	 * @param uri - resource uri
 	 * @return true if matched, otherwise false.
 	 */
-	public static boolean match(Pattern pattern, String uri) {
+	public boolean match(Pattern pattern, String uri) {
 	    // Match uri with pattern
 	    Matcher m = pattern.matcher(uri);
 	    if (!m.matches()){
@@ -130,7 +130,7 @@
 	 * @param db database service
 	 * @return DAO corresponding to the resource, null if not found
 	 */
-	public static DAO<?> getDAO(String uri, DBService db){
+	public DAO<?> getDAO(String uri, DBService db){
 		if (match(CSE_BASE_PATTERN, uri)){
 			return db.getDAOFactory().getCSEBaseDAO();
 		}
@@ -184,7 +184,7 @@
 	 * @param resourceName
 	 * @return
 	 */
-	public static boolean checkResourceName(String resourceName){
+	public boolean checkResourceName(String resourceName){
 		return match(ID_PATTERN, resourceName);
 	}
 }
diff --git a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/router/Router.java b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/router/Router.java
index 991e156..fbea2be 100644
--- a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/router/Router.java
+++ b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/router/Router.java
@@ -85,6 +85,7 @@
 
 		LOGGER.info("Received request in Router: " + request.toString());
 		ResponsePrimitive response = new ResponsePrimitive(request);
+		Patterns patterns = new Patterns();
 		
 		String contentFormat = System.getProperty("org.eclipse.om2m.registration.contentFormat", MimeMediaType.XML);
 
@@ -169,7 +170,7 @@
 			getQueryStringFromTargetId(request);
 
 			// Redirection case
-			if (!Patterns.match(Patterns.NON_RETARGETING_PATTERN, request.getTargetId())){
+			if (!patterns.match(patterns.NON_RETARGETING_PATTERN, request.getTargetId())){
 				LOGGER.info("Request targeting another CSE, forwarding to Redirector: " + request.getTo());
 				return Redirector.retarget(request);
 			}
@@ -177,21 +178,21 @@
 
 			Controller controller = null ; 
 			// Case of hierarchical URI, retrieve the non-hierarchical URI of the resource
-			if (Patterns.match(Patterns.HIERARCHICAL_PATTERN, request.getTargetId())){
-				if(request.getTargetId().contains(Patterns.FANOUT_POINT_MATCH + "/")){
-					int foptIndex = request.getTargetId().indexOf(Patterns.FANOUT_POINT_MATCH);
+			if (patterns.match(patterns.HIERARCHICAL_PATTERN, request.getTargetId())){
+				if(request.getTargetId().contains(patterns.FANOUT_POINT_MATCH + "/")){
+					int foptIndex = request.getTargetId().indexOf(patterns.FANOUT_POINT_MATCH);
 					String uri = request.getTargetId().substring(0, foptIndex);
 					String suffix = request.getTargetId()
 							.substring(
-									foptIndex + Patterns.FANOUT_POINT_MATCH.length(), 
+									foptIndex + patterns.FANOUT_POINT_MATCH.length(), 
 									request.getTargetId().length()
 									);
 					controller = new FanOutPointController(suffix);
 					request.setTargetId(uri);
 					LOGGER.info("Fan Out request received: [grp uri: " + uri + ", suffix: " + suffix + "]");
-				} if (request.getTargetId().endsWith(Patterns.FANOUT_POINT_MATCH)) {
+				} if (request.getTargetId().endsWith(patterns.FANOUT_POINT_MATCH)) {
 					controller = new FanOutPointController();
-					request.setTargetId(request.getTargetId().replaceAll(Patterns.FANOUT_POINT_MATCH, ""));
+					request.setTargetId(request.getTargetId().replaceAll(patterns.FANOUT_POINT_MATCH, ""));
 					LOGGER.info("Fan Out request received: [grp uri: " + request.getTargetId()+ "]");
 				} 
 				if(request.getTargetId().endsWith("/" + ShortName.LATEST)){
@@ -276,53 +277,54 @@
 	 * @return The matched resource controller otherwise null
 	 */
 	protected Controller getResourceControllerFromURI(String uri){
+		Patterns patterns = new Patterns();
 		// Match the resource controller with an uri pattern and return it, otherwise return null
-		if (Patterns.match(Patterns.CSE_BASE_PATTERN, uri)){
+		if (patterns.match(patterns.CSE_BASE_PATTERN, uri)){
 			return new CSEBaseController();
 		}
-		if (Patterns.match(Patterns.AE_PATTERN, uri)){
+		if (patterns.match(patterns.AE_PATTERN, uri)){
 			return new AEController();
 		}
-		if (Patterns.match(Patterns.AEANNC_PATTERN, uri)){
+		if (patterns.match(patterns.AEANNC_PATTERN, uri)){
 			return new AEAnncController();
 		}
-		if (Patterns.match(Patterns.ACP_PATTERN, uri)){
+		if (patterns.match(patterns.ACP_PATTERN, uri)){
 			return new AccessControlPolicyController();
 		}
-		if (Patterns.match(Patterns.CONTAINER_PATTERN, uri)){
+		if (patterns.match(patterns.CONTAINER_PATTERN, uri)){
 			return new ContainerController();
 		}
-		if (Patterns.match(Patterns.DYNAMIC_AUTHORIZATION_CONSULTATION_PATTERN, uri)){
+		if (patterns.match(patterns.DYNAMIC_AUTHORIZATION_CONSULTATION_PATTERN, uri)){
 			return new DynamicAuthorizationConsultationController();
 		}
-		if(Patterns.match(Patterns.FLEXCONTAINER_PATTERN, uri)) {
+		if (patterns.match(patterns.FLEXCONTAINER_PATTERN, uri)) {
 			return new FlexContainerController();
 		}
-		if(Patterns.match(Patterns.FLEXCONTAINER_ANNC_PATTERN, uri)) {
+		if (patterns.match(patterns.FLEXCONTAINER_ANNC_PATTERN, uri)) {
 			return new FlexContainerAnncController();
 		}
-		if (Patterns.match(Patterns.CONTENTINSTANCE_PATTERN, uri)) {
+		if (patterns.match(patterns.CONTENTINSTANCE_PATTERN, uri)) {
 			return new ContentInstanceController();
 		}
-		if (Patterns.match(Patterns.REMOTE_CSE_PATTERN, uri)) {
+		if (patterns.match(patterns.REMOTE_CSE_PATTERN, uri)) {
 			return new RemoteCSEController();
 		}
-		if(Patterns.match(Patterns.GROUP_PATTERN, uri)){
+		if (patterns.match(patterns.GROUP_PATTERN, uri)){
 			return new GroupController();
 		}
-		if (Patterns.match(Patterns.NODE_PATTERN, uri)) {
+		if (patterns.match(patterns.NODE_PATTERN, uri)) {
 			return new NodeController();
 		}
-		if(Patterns.match(Patterns.SUBSCRIPTION_PATTERN, uri)){
+		if (patterns.match(patterns.SUBSCRIPTION_PATTERN, uri)){
 			return new SubscriptionController();
 		}
-		if(Patterns.match(Patterns.POLLING_CHANNEL_PATTERN, uri)){
+		if (patterns.match(patterns.POLLING_CHANNEL_PATTERN, uri)){
 			return new PollingChannelController();
 		}
-		if(Patterns.match(Patterns.POLLING_CHANNEL_URI_PATTERN, uri)){
+		if (patterns.match(patterns.POLLING_CHANNEL_URI_PATTERN, uri)){
 			return new PollingChannelUriController();
 		}
-		if(Patterns.match(Patterns.REQUEST_PATTERN, uri)){
+		if (patterns.match(patterns.REQUEST_PATTERN, uri)){
 			return new RequestController();
 		}
 		return null;
diff --git a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/urimapper/UriMapper.java b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/urimapper/UriMapper.java
index 667e0a7..dab0ad0 100644
--- a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/urimapper/UriMapper.java
+++ b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/urimapper/UriMapper.java
@@ -46,7 +46,9 @@
 		}
 		
 		String spRelativeUri = UriUtil.toSpRelativeUri(uri);
-		if (Patterns.match(Patterns.NON_HIERARCHICAL_PATTERN, spRelativeUri)){
+		Patterns patterns = new Patterns();
+
+		if (patterns.match(patterns.NON_HIERARCHICAL_PATTERN, spRelativeUri)){
 			return spRelativeUri;
 		}
 		DBService dbs = PersistenceService.getInstance().getDbService();
diff --git a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/util/GroupUtil.java b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/util/GroupUtil.java
index 9471ec6..5100e72 100644
--- a/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/util/GroupUtil.java
+++ b/org.eclipse.om2m.core/src/main/java/org/eclipse/om2m/core/util/GroupUtil.java
@@ -53,6 +53,8 @@
 			DBService dbs = PersistenceService.getInstance().getDbService();
 			DBTransaction transaction = dbs.getDbTransaction();
 			transaction.open();
+			Patterns patterns = new Patterns();
+
 			List<String> result = new ArrayList<String>();
 			// for each member of the group
 			for(String memberUri : group.getMemberIDs()){
@@ -62,7 +64,7 @@
 					throw new MemberNonFoundException("Member not found: " + memberUri);
 				}
 				
-				DAO<ResourceEntity> dao = (DAO<ResourceEntity>) Patterns.getDAO(nonHierarchicalUri, dbs);
+				DAO<ResourceEntity> dao = (DAO<ResourceEntity>) patterns.getDAO(nonHierarchicalUri, dbs);
 				if(dao == null){
 					transaction.close();
 					throw new MemberNonFoundException("Member not found: " + memberUri);
diff --git a/org.eclipse.om2m.persistence.mongodb/src/main/java/org/eclipse/om2m/persistence/mongodb/DBServiceImpl.java b/org.eclipse.om2m.persistence.mongodb/src/main/java/org/eclipse/om2m/persistence/mongodb/DBServiceImpl.java
index af7eea8..28fe36a 100644
--- a/org.eclipse.om2m.persistence.mongodb/src/main/java/org/eclipse/om2m/persistence/mongodb/DBServiceImpl.java
+++ b/org.eclipse.om2m.persistence.mongodb/src/main/java/org/eclipse/om2m/persistence/mongodb/DBServiceImpl.java
@@ -1,10 +1,3 @@
-/*******************************************************************************

- * Copyright (c) 2014, 2016 Orange.

- * All rights reserved. This program and the accompanying materials

- * are made available under the terms of the Eclipse Public License v1.0

- * which accompanies this distribution, and is available at

- * http://www.eclipse.org/legal/epl-v10.html

- *******************************************************************************/

 package org.eclipse.om2m.persistence.mongodb;

 

 import org.apache.commons.logging.Log;

@@ -58,7 +51,8 @@
 	}

 

 	protected void init() {

-		MongoClient mongoClient = new MongoClient(DBConstants.DB_URL);

+		LOGGER.info("mongoDB URL=" + System.getProperty("org.eclipse.om2m.dbUrl", "jdbc:mongo://cloud1/default"));

+		MongoClient mongoClient = new MongoClient(System.getProperty("org.eclipse.om2m.dbUrl", "jdbc:mongo://cloud1/default"));

 		LOGGER.info("mongoDB client=" + mongoClient);

 

 		MongoDatabase database = mongoClient.getDatabase("mydb_" + Constants.CSE_NAME);

@@ -93,6 +87,7 @@
 						new IndexOptions().unique(true)/*.weights(doc)*/);

 			} catch (Exception e) {

 				e.printStackTrace();

+				LOGGER.error("Can't delete all ", e); //dgo

 			}

 

 			announceCollection.deleteMany(new Document());

diff --git a/org.eclipse.om2m.sdt/org.eclipse.om2m.sdt.home.applications/org.eclipse.om2m.sdt.home.monitoring/src/main/java/org/eclipse/om2m/sdt/home/monitoring/Activator.java b/org.eclipse.om2m.sdt/org.eclipse.om2m.sdt.home.applications/org.eclipse.om2m.sdt.home.monitoring/src/main/java/org/eclipse/om2m/sdt/home/monitoring/Activator.java
index f08e23c..0d850c8 100644
--- a/org.eclipse.om2m.sdt/org.eclipse.om2m.sdt.home.applications/org.eclipse.om2m.sdt.home.monitoring/src/main/java/org/eclipse/om2m/sdt/home/monitoring/Activator.java
+++ b/org.eclipse.om2m.sdt/org.eclipse.om2m.sdt.home.applications/org.eclipse.om2m.sdt.home.monitoring/src/main/java/org/eclipse/om2m/sdt/home/monitoring/Activator.java
@@ -32,10 +32,10 @@
 import org.osgi.util.tracker.ServiceTracker;
 
 
-public class Activator implements BundleActivator, ManagedService {
+public class Activator implements BundleActivator , ManagedService {
 	/** logger */
 	private static Log LOGGER = LogFactory.getLog(Activator.class);
-	public static String globalContext = System.getProperty("org.eclipse.om2m.globalContext","");
+	public String globalContext = System.getProperty("org.eclipse.om2m.globalContext","");
 	public static String uiContext = /*System.getProperty("org.eclipse.om2m.webInterfaceContext","/")*/"";
 	public static String sep ="/";
 	public static String CAMERAURL ="";
diff --git a/org.eclipse.om2m.webapp.resourcesbrowser.json/src/main/java/org/eclipse/om2m/webapp/resourcesbrowser/json/Activator.java b/org.eclipse.om2m.webapp.resourcesbrowser.json/src/main/java/org/eclipse/om2m/webapp/resourcesbrowser/json/Activator.java
index 128e075..9a9121d 100644
--- a/org.eclipse.om2m.webapp.resourcesbrowser.json/src/main/java/org/eclipse/om2m/webapp/resourcesbrowser/json/Activator.java
+++ b/org.eclipse.om2m.webapp.resourcesbrowser.json/src/main/java/org/eclipse/om2m/webapp/resourcesbrowser/json/Activator.java
@@ -30,9 +30,10 @@
 public class Activator implements BundleActivator {

 	/** logger */

 	private static Log LOGGER = LogFactory.getLog(Activator.class);

-	public static String globalContext = System.getProperty("org.eclipse.om2m.globalContext","");

-	public static String uiContext = System.getProperty("org.eclipse.om2m.webInterfaceContext","/");

-	public static String sep ="/";

+	public String globalContext = System.getProperty("org.eclipse.om2m.globalContext","");

+	private Activator _this = this; //dgo

+	public String uiContext = System.getProperty("org.eclipse.om2m.webInterfaceContext","/webpage");

+	public String sep ="/";

 	/** HTTP service tracker */

 	private ServiceTracker<Object, Object> httpServiceTracker;

 	

@@ -46,10 +47,8 @@
 	      public void removedService(ServiceReference<Object> reference, Object service) {

 			LOGGER.info("HttpService removed");

 	        try {

-//				LOGGER.info("Unregister "+uiContext+sep+" http context");

-//	        	((HttpService) service).unregister(uiContext+sep);

-				LOGGER.info("Unregister "+uiContext+" http context");

-	           ((HttpService) service).unregister(uiContext);

+	        		LOGGER.info("Unregister "+uiContext+" http context"); 

+	        		((HttpService) service).unregister(uiContext);

 	        } catch (IllegalArgumentException e) {

 		        LOGGER.error("Error unregistring webapp servlet",e);

 	        }

@@ -59,12 +58,9 @@
 			LOGGER.info("HttpService discovered");

 	        HttpService httpService = (HttpService) context.getService(reference);

 	        try{

-			LOGGER.info("Register "+uiContext+" http context");

-	          httpService.registerServlet(uiContext, new WelcomeServlet(), null, null);

-			  httpService.registerResources(uiContext+sep+"welcome", "/webapps", null);

-//			  LOGGER.info("Register "+uiContext+sep+" http context");

-//			  httpService.registerServlet(uiContext+sep, new WelcomeServlet(), null, null);

-//			  httpService.registerResources(uiContext+sep+"welcome", uiContext+sep+"webapps", null);

+	        	LOGGER.info("Register "+uiContext+" http context"); 

+	        	httpService.registerServlet(uiContext, new WelcomeServlet(_this), null, null);

+	        	httpService.registerResources(uiContext+sep+"welcome", "/webapps", null);

 	        } catch (Exception e) {

 	          LOGGER.error("Error registring webapp servlet",e);

 	        }

@@ -76,6 +72,12 @@
 	

 	@Override

 	public void stop(BundleContext context) throws Exception {

+		String uiContext = System.getProperty("org.eclipse.om2m.webInterfaceContext","/webpage");

+		if(httpServiceTracker != null){ 

+			((HttpService)httpServiceTracker.getService()).unregister(uiContext); 

+			httpServiceTracker.close();

+			httpServiceTracker = null;

+		}

 	}

 }

 

diff --git a/org.eclipse.om2m.webapp.resourcesbrowser.json/src/main/java/org/eclipse/om2m/webapp/resourcesbrowser/json/WelcomeServlet.java b/org.eclipse.om2m.webapp.resourcesbrowser.json/src/main/java/org/eclipse/om2m/webapp/resourcesbrowser/json/WelcomeServlet.java
index 2f1ff64..d42c2d3 100644
--- a/org.eclipse.om2m.webapp.resourcesbrowser.json/src/main/java/org/eclipse/om2m/webapp/resourcesbrowser/json/WelcomeServlet.java
+++ b/org.eclipse.om2m.webapp.resourcesbrowser.json/src/main/java/org/eclipse/om2m/webapp/resourcesbrowser/json/WelcomeServlet.java
@@ -26,13 +26,20 @@
 import javax.servlet.http.HttpServletRequest;

 import javax.servlet.http.HttpServletResponse;

 

+

 public class WelcomeServlet extends HttpServlet {

     /** Serial Version UID */

     private static final long serialVersionUID = 1L;

-    @Override

+    private Activator activator = null;

+    

+    public WelcomeServlet(Activator _a) {

+		this.activator = _a;

+	}

+    

+	@Override

     protected void service(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException {

-    	String cseBaseContext = (System.getProperty("org.eclipse.om2m.cseBaseContext", "/om2m").equals("/") ?

-    			"/~":System.getProperty("org.eclipse.om2m.cseBaseContext", "/om2m") + "/");

-    	httpServletResponse.sendRedirect(Activator.globalContext+Activator.uiContext+Activator.sep+"welcome/index.html?context="+System.getProperty("org.eclipse.om2m.globalContext","")+cseBaseContext+"&"+"cseId="+System.getProperty("org.eclipse.om2m.cseBaseId", "in-cse"));

+		String cseBaseContext = (System.getProperty("org.eclipse.om2m.cseBaseContext", "/om2m").equals("/") ?

+    			"/~":System.getProperty("org.eclipse.om2m.cseBaseContext", "/om2m") + "/~");

+		httpServletResponse.sendRedirect(this.activator.globalContext+activator.uiContext+activator.sep+"welcome/index.html?context="+System.getProperty("org.eclipse.om2m.globalContext","")+cseBaseContext+"&"+"cseId="+System.getProperty("org.eclipse.om2m.cseBaseId", "in-cse")); //dgo

     }

 }

diff --git a/org.eclipse.om2m.webapp.resourcesbrowser.xml/src/main/java/org/eclipse/om2m/webapp/resourcesbrowser/xml/Activator.java b/org.eclipse.om2m.webapp.resourcesbrowser.xml/src/main/java/org/eclipse/om2m/webapp/resourcesbrowser/xml/Activator.java
index 0e1e0f8..7690192 100644
--- a/org.eclipse.om2m.webapp.resourcesbrowser.xml/src/main/java/org/eclipse/om2m/webapp/resourcesbrowser/xml/Activator.java
+++ b/org.eclipse.om2m.webapp.resourcesbrowser.xml/src/main/java/org/eclipse/om2m/webapp/resourcesbrowser/xml/Activator.java
@@ -33,9 +33,10 @@
 public class Activator implements BundleActivator {

 	/** logger */

 	private static Log LOGGER = LogFactory.getLog(Activator.class);

-	public static String globalContext = System.getProperty("org.eclipse.om2m.globalContext","");

-	public static String uiContext = System.getProperty("org.eclipse.om2m.webInterfaceContext","/");

-	public static String sep ="/";

+	public String globalContext = System.getProperty("org.eclipse.om2m.globalContext","");

+	private Activator _this = this; //dgo

+	public String uiContext = System.getProperty("org.eclipse.om2m.webInterfaceContext","/webpage");

+	public String sep ="/";

 	/** HTTP service tracker */

 	private ServiceTracker<Object, Object> httpServiceTracker;

 	

@@ -49,10 +50,8 @@
 	      public void removedService(ServiceReference<Object> reference, Object service) {

 			LOGGER.info("HttpService removed");

 	        try {

-//				LOGGER.info("Unregister "+uiContext+sep+" http context");

-//	        	((HttpService) service).unregister(uiContext+sep);

-				LOGGER.info("Unregister "+uiContext+" http context");

-	           ((HttpService) service).unregister(uiContext);

+	        		LOGGER.info("Unregister "+uiContext+" http context");

+	        		((HttpService) service).unregister(uiContext);

 	        } catch (IllegalArgumentException e) {

 		        LOGGER.error("Error unregistring webapp servlet",e);

 	        }

@@ -63,11 +62,8 @@
 	        HttpService httpService = (HttpService) context.getService(reference);

 	        try{

 			LOGGER.info("Register "+uiContext+" http context");

-	          httpService.registerServlet(uiContext, new WelcomeServlet(), null, null);

+	          httpService.registerServlet(uiContext, new WelcomeServlet(_this), null, null);

 			  httpService.registerResources(uiContext+sep+"welcome", "/webapps", null);

-//			  LOGGER.info("Register "+uiContext+sep+" http context");

-//			  httpService.registerServlet(uiContext+sep, new WelcomeServlet(), null, null);

-//			  httpService.registerResources(uiContext+sep+"welcome", uiContext+sep+"webapps", null);

 	        } catch (Exception e) {

 	          LOGGER.error("Error registring webapp servlet",e);

 	        }

@@ -79,6 +75,11 @@
 	

 	@Override

 	public void stop(BundleContext context) throws Exception {

+		if(httpServiceTracker != null){ //dgo

+			((HttpService)httpServiceTracker.getService()).unregister(uiContext); //dgo

+			httpServiceTracker.close(); //dgo

+			httpServiceTracker = null; //dgo

+		}

 	}

 }

 

diff --git a/org.eclipse.om2m.webapp.resourcesbrowser.xml/src/main/java/org/eclipse/om2m/webapp/resourcesbrowser/xml/WelcomeServlet.java b/org.eclipse.om2m.webapp.resourcesbrowser.xml/src/main/java/org/eclipse/om2m/webapp/resourcesbrowser/xml/WelcomeServlet.java
index 85cc7aa..63f855a 100644
--- a/org.eclipse.om2m.webapp.resourcesbrowser.xml/src/main/java/org/eclipse/om2m/webapp/resourcesbrowser/xml/WelcomeServlet.java
+++ b/org.eclipse.om2m.webapp.resourcesbrowser.xml/src/main/java/org/eclipse/om2m/webapp/resourcesbrowser/xml/WelcomeServlet.java
@@ -31,10 +31,16 @@
 public class WelcomeServlet extends HttpServlet {

     /** Serial Version UID */

     private static final long serialVersionUID = 1L;

-    @Override

+    private Activator activator = null;

+    

+    public WelcomeServlet(Activator _a) { 

+    		this.activator = _a;

+	} 

+    

+	@Override

     protected void service(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse) throws ServletException, IOException {

-    	String cseBaseContext = (System.getProperty("org.eclipse.om2m.cseBaseContext", "/om2m").equals("/") ?

+		String cseBaseContext = (System.getProperty("org.eclipse.om2m.cseBaseContext", "/om2m").equals("/") ?

     			"/~":System.getProperty("org.eclipse.om2m.cseBaseContext", "/om2m") + "/");

-    	httpServletResponse.sendRedirect(Activator.globalContext+Activator.uiContext+Activator.sep+"welcome/index.html?context="+System.getProperty("org.eclipse.om2m.globalContext","")+cseBaseContext+"&"+"cseId="+System.getProperty("org.eclipse.om2m.cseBaseId", "in-cse"));

+		httpServletResponse.sendRedirect(activator.globalContext+activator.uiContext+activator.sep+"welcome/index.html?context="+System.getProperty("org.eclipse.om2m.globalContext","")+cseBaseContext+"&"+"cseId="+System.getProperty("org.eclipse.om2m.cseBaseId", "in-cse"));

     }

 }