[jboss-svn-commits] JBL Code SVN: r21337 - in labs/jbossesb/trunk: product/docs and 22 other directories.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Mon Aug 4 07:55:23 EDT 2008


Author: kevin.conner at jboss.com
Date: 2008-08-04 07:55:23 -0400 (Mon, 04 Aug 2008)
New Revision: 21337

Added:
   labs/jbossesb/trunk/product/rosetta/aop/
   labs/jbossesb/trunk/product/rosetta/aop/java/
   labs/jbossesb/trunk/product/rosetta/aop/java/org/
   labs/jbossesb/trunk/product/rosetta/aop/java/org/jboss/
   labs/jbossesb/trunk/product/rosetta/aop/java/org/jboss/internal/
   labs/jbossesb/trunk/product/rosetta/aop/java/org/jboss/internal/soa/
   labs/jbossesb/trunk/product/rosetta/aop/java/org/jboss/internal/soa/esb/
   labs/jbossesb/trunk/product/rosetta/aop/java/org/jboss/internal/soa/esb/services/
   labs/jbossesb/trunk/product/rosetta/aop/java/org/jboss/internal/soa/esb/services/registry/
   labs/jbossesb/trunk/product/rosetta/aop/java/org/jboss/internal/soa/esb/services/registry/aspect/
   labs/jbossesb/trunk/product/rosetta/aop/java/org/jboss/internal/soa/esb/services/registry/aspect/ScoutAspect.java
   labs/jbossesb/trunk/product/rosetta/aop/resources/
   labs/jbossesb/trunk/product/rosetta/aop/resources/META-INF/
   labs/jbossesb/trunk/product/rosetta/aop/resources/META-INF/jboss-aop.xml
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/CachingRegistryInterceptor.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/InVMRegistryInterceptor.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/services/registry/AbstractRegistryInterceptor.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/services/registry/RegistryInterceptor.java
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/services/registry/InVMRegistryInterceptorUnitTest.java
Removed:
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/InVMRegistry.java
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/services/registry/InVMRegistryUnitTest.java
Modified:
   labs/jbossesb/trunk/product/build-distr.xml
   labs/jbossesb/trunk/product/docs/ServicesGuide.odt
   labs/jbossesb/trunk/product/install/conf/jbossesb-properties.xml
   labs/jbossesb/trunk/product/rosetta/build.xml
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/JAXRRegistryImpl.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/common/Configuration.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/common/Environment.java
   labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/services/registry/RegistryFactory.java
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/services/registry/MockRegistry.java
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/services/registry/MockRegistryUnitTest.java
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/jbossesb-properties-01.xml
   labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/jbossesb-properties.xml
   labs/jbossesb/trunk/product/services/smooks/src/test/java/org/jboss/soa/esb/smooks/jbossesb-properties.xml
   labs/jbossesb/trunk/qa/junit/resources/server/jbossesb-properties.xml
Log:
Rework registry, add interceptors, reduce scout impact: JBESB-1675

Modified: labs/jbossesb/trunk/product/build-distr.xml
===================================================================
--- labs/jbossesb/trunk/product/build-distr.xml	2008-08-04 10:31:05 UTC (rev 21336)
+++ labs/jbossesb/trunk/product/build-distr.xml	2008-08-04 11:55:23 UTC (rev 21337)
@@ -9,6 +9,7 @@
 
     <property name="build.dir" value="build"/>
     <property name="lib.dir" value="build/lib"/>
+    <property name="aoplib.dir" value="build/aoplib"/>
     <property name="lib.ext.dir" value="lib/ext"/>
     <property name="services.dir" value="services"/>
     <property name="build.lib.dir" value="${build.dir}/jbossesb/lib"/>
@@ -83,6 +84,8 @@
             <fileset dir="${installation.files.dir}/jUDDI-registry">
                 <include name="juddi-ds.xml"/>
             </fileset>
+            <!-- We use AOP on scout to get around an issue -->
+            <fileset dir="${build.dir}" includes="rosetta.aop"/>
         </copy>
 
         <mkdir dir="${build.dir}/jbossesb.sar/juddi-sql"/>
@@ -96,8 +99,11 @@
         <copy todir="${build.dir}/jbossesb.sar/lib">
             <fileset dir="${lib.ext.dir}" includes="jbossts-common.jar"/>
             <fileset dir="${build.lib.dir}" includes="jbossesb*.jar"/>
+            <!-- We use AOP on scout to get around an issue, use the modified jar for now
+            <fileset dir="${lib.dir}" includes="scout-*.jar"/>
+            -->
             <!-- scout -->
-            <fileset dir="${lib.dir}" includes="scout-*.jar"/>
+            <fileset dir="${aoplib.dir}" includes="scout-*.jar"/>
             <!-- xbean for reading/marchalling xml for configuration, and scout -->
             <fileset dir="${lib.dir}" includes="xbean*.jar"/>
             <fileset dir="${lib.dir}" includes="xmlpublic-*.jar,stax-api-*.jar"/>

Modified: labs/jbossesb/trunk/product/docs/ServicesGuide.odt
===================================================================
(Binary files differ)

Modified: labs/jbossesb/trunk/product/install/conf/jbossesb-properties.xml
===================================================================
--- labs/jbossesb/trunk/product/install/conf/jbossesb-properties.xml	2008-08-04 10:31:05 UTC (rev 21336)
+++ labs/jbossesb/trunk/product/install/conf/jbossesb-properties.xml	2008-08-04 11:55:23 UTC (rev 21337)
@@ -46,6 +46,12 @@
     	<property name="org.jboss.soa.esb.registry.password" value="password"/>
     	<!-- the following parameter is scout specific to set the type of communication between scout and the UDDI (embedded, rmi, soap) -->
     	<property name="org.jboss.soa.esb.scout.proxy.transportClass" value="org.apache.ws.scout.transport.LocalTransport"/>
+        <!-- specify the interceptors, in order -->
+        <property name="org.jboss.soa.esb.registry.interceptors"
+                value="org.jboss.internal.soa.esb.services.registry.InVMRegistryInterceptor, org.jboss.internal.soa.esb.services.registry.CachingRegistryInterceptor"/>
+        <!-- The following properties modify the cache interceptor behaviour -->
+        <property name="org.jboss.soa.esb.registry.cache.maxSize" value="100"/>
+        <property name="org.jboss.soa.esb.registry.cache.validityPeriod" value="600000"/>
     </properties>
     <properties name="transports" depends="core">
     	<property name="org.jboss.soa.esb.mail.smtp.host" value="localhost"/>

Added: labs/jbossesb/trunk/product/rosetta/aop/java/org/jboss/internal/soa/esb/services/registry/aspect/ScoutAspect.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/aop/java/org/jboss/internal/soa/esb/services/registry/aspect/ScoutAspect.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/aop/java/org/jboss/internal/soa/esb/services/registry/aspect/ScoutAspect.java	2008-08-04 11:55:23 UTC (rev 21337)
@@ -0,0 +1,59 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and individual contributors as indicated
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.internal.soa.esb.services.registry.aspect;
+
+import javax.xml.registry.LifeCycleManager;
+import javax.xml.registry.infomodel.Service;
+
+import org.apache.ws.scout.registry.BusinessQueryManagerImpl;
+import org.apache.ws.scout.registry.infomodel.ServiceImpl;
+import org.jboss.aop.joinpoint.MethodCalledByMethodInvocation;
+
+/**
+ * Aspect used to prevent scout from loading the complete service
+ * graph for the registry just to return a binding.
+ * 
+ * @author <a href='mailto:Kevin.Conner at jboss.com'>Kevin Conner</a>
+ */
+public class ScoutAspect
+{
+    public Object getRegistryObject(final MethodCalledByMethodInvocation invocation)
+        throws Throwable
+    {
+        final BusinessQueryManagerImpl bqmImpl = (BusinessQueryManagerImpl)invocation.getCallingObject() ;
+        final Object[] args = invocation.getArguments() ;
+        final String id = (String)args[0] ;
+        final String objectType = (String)args[1] ;
+        
+        if (LifeCycleManager.SERVICE.equals(objectType))
+        {
+            final LifeCycleManager lcm = bqmImpl.getRegistryService().getBusinessLifeCycleManager() ;
+            final Service service = new ServiceImpl(lcm);
+            service.setKey(lcm.createKey(id));
+            return service ;
+        }
+        else
+        {
+            return invocation.invokeNext() ;
+        }
+    }
+}


Property changes on: labs/jbossesb/trunk/product/rosetta/aop/java/org/jboss/internal/soa/esb/services/registry/aspect/ScoutAspect.java
___________________________________________________________________
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native

Added: labs/jbossesb/trunk/product/rosetta/aop/resources/META-INF/jboss-aop.xml
===================================================================
--- labs/jbossesb/trunk/product/rosetta/aop/resources/META-INF/jboss-aop.xml	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/aop/resources/META-INF/jboss-aop.xml	2008-08-04 11:55:23 UTC (rev 21337)
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE aop PUBLIC
+   "-//JBoss//DTD JBOSS AOP 1.0//EN"
+   "http://labs.jboss.com/portal/jbossaop/dtd/jboss-aop_1_0.dtd">
+
+<aop>
+   <aspect class="org.jboss.internal.soa.esb.services.registry.aspect.ScoutAspect" scope="PER_VM"/>
+   
+   <bind pointcut="withincode(* org.apache.ws.scout.registry.BusinessQueryManagerImpl->findServiceBindings(..)) AND call(* org.apache.ws.scout.registry.BusinessQueryManagerImpl->getRegistryObject(..))">
+      <advice name="getRegistryObject" aspect="org.jboss.internal.soa.esb.services.registry.aspect.ScoutAspect"/>
+   </bind>
+</aop>
+


Property changes on: labs/jbossesb/trunk/product/rosetta/aop/resources/META-INF/jboss-aop.xml
___________________________________________________________________
Name: svn:mime-type
   + text/xml
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native

Modified: labs/jbossesb/trunk/product/rosetta/build.xml
===================================================================
--- labs/jbossesb/trunk/product/rosetta/build.xml	2008-08-04 10:31:05 UTC (rev 21336)
+++ labs/jbossesb/trunk/product/rosetta/build.xml	2008-08-04 11:55:23 UTC (rev 21337)
@@ -4,12 +4,15 @@
 	<property name="org.jboss.esb.rosetta.jar.name" value="jbossesb-rosetta"/>
 	<property name="org.jboss.esb.rosetta.distrib.dir" location="${org.jboss.esb.internal.dest}/jbossesb"/>
 	<property name="org.jboss.esb.rosetta.classes.dir" location="${org.jboss.esb.internal.dest}/classes/rosetta"/>
+    <property name="org.jboss.esb.rosetta.aop.classes.dir" location="${org.jboss.esb.rosetta.classes.dir}-aop"/>
+    <property name="org.jboss.esb.rosetta.aopc.classes.dir" location="${org.jboss.esb.rosetta.classes.dir}-aopc"/>
     <property name="org.jboss.esb.rosetta.src.dir" location="src"/>
 	<property name="org.jboss.esb.root.dir" location="../"/>
 	<property name="gendir" location="${org.jboss.esb.internal.dest}/schema-model" />
     <property environment="env"/>
 
-    <property name="org.jboss.esb.lib.dir" location="${org.jboss.esb.root.dir}/build/lib"/>
+    <property name="org.jboss.esb.lib.dir" location="${org.jboss.esb.internal.dest}/lib"/>
+    <property name="org.jboss.esb.aoplib.dir" location="${org.jboss.esb.internal.dest}/aoplib"/>
 	<property name="org.jboss.esb.ext.lib.dir" location="${org.jboss.esb.root.dir}/lib/ext"/>
 	
 	<path id="org.jboss.esb.rosetta.base.classpath">
@@ -30,6 +33,9 @@
         <mkdir dir="${org.jboss.esb.rosetta.classes.dir}"/>
         <mkdir dir="${org.jboss.esb.rosetta.distrib.dir}"/>
     	<mkdir dir="${org.jboss.esb.rosetta.distrib.dir}/lib"/>
+        <!-- aop dirs -->
+        <mkdir dir="${org.jboss.esb.rosetta.aop.classes.dir}"/>
+        <mkdir dir="${org.jboss.esb.aoplib.dir}"/>
     </target>
 
     <target name="clean" description="Remove classes directory">
@@ -37,7 +43,7 @@
     	<delete dir="${org.jboss.esb.rosetta.classes.dir}"/>
     </target>
 
-    <target name="org.jboss.esb.rosetta.compile" depends="generate-config-model, org.jboss.esb.rosetta.internal.compile">
+    <target name="org.jboss.esb.rosetta.compile" depends="generate-config-model, org.jboss.esb.rosetta.internal.compile, aop">
         <ant inheritAll="true" dir="tests" target="org.jboss.esb.rosetta.tests.compile"/>
     </target>
 
@@ -159,6 +165,39 @@
 
 	<property name="coverage.dir" location="${org.jboss.esb.internal.dest}/tests/coverage"/>
 
+    <path id="aop-classpath">
+        <fileset dir="${org.jboss.esb.lib.dir}" includes="jboss-aop-*.jar, javassist-*.jar, jbossall-client-*.jar, xbean-*.jar"/>
+        <fileset dir="${org.jboss.esb.ext.lib.dir}" includes="trove.jar"/>
+    </path>
 
+    <target name="aop" depends="aop-jar">
+        <taskdef name="aopc" classname="org.jboss.aop.ant.AopC" classpathref="aop-classpath"/>
 
+        <delete dir="${org.jboss.esb.rosetta.aopc.classes.dir}" quiet="true"/>
+        <mkdir dir="${org.jboss.esb.rosetta.aopc.classes.dir}"/>
+
+        <unzip src="${org.jboss.esb.lib.dir}/scout-1.0rc1.jar" dest="${org.jboss.esb.rosetta.aopc.classes.dir}"/>
+        <aopc compilerclasspathref="aop-classpath">
+            <classpath path="${org.jboss.esb.rosetta.aopc.classes.dir}"/>
+            <src path="${org.jboss.esb.rosetta.aopc.classes.dir}"/>
+            <include name="org/apache/ws/scout/registry/BusinessQueryManagerImpl.class"/>
+
+            <aoppath path="aop/resources/META-INF/jboss-aop.xml"/>
+            <aopclasspath path="${org.jboss.esb.rosetta.aop.classes.dir}"/>
+        </aopc>
+        <zip destfile="${org.jboss.esb.aoplib.dir}/scout-1.0rc1.aop.jar" basedir="${org.jboss.esb.rosetta.aopc.classes.dir}"/>
+    </target>
+
+    <target name="aop-jar" depends="aop-compile">
+        <jar destfile="${org.jboss.esb.internal.dest}/rosetta.aop">
+            <fileset dir="${org.jboss.esb.rosetta.aop.classes.dir}"/>
+            <fileset dir="aop/resources"/>
+        </jar>
+    </target>
+
+    <target name="aop-compile">
+        <javac srcdir="aop/java" destdir="${org.jboss.esb.rosetta.aop.classes.dir}"
+            debug="${org.jboss.esb.debug}" optimize="${org.jboss.esb.optimize}"
+            classpathref="org.jboss.esb.rosetta.base.classpath"/>
+    </target>
 </project>

Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/CachingRegistryInterceptor.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/CachingRegistryInterceptor.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/CachingRegistryInterceptor.java	2008-08-04 11:55:23 UTC (rev 21337)
@@ -0,0 +1,265 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.internal.soa.esb.services.registry;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.commons.collections.map.LRUMap;
+import org.apache.log4j.Logger;
+import org.jboss.soa.esb.Service;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.common.Configuration;
+import org.jboss.soa.esb.services.registry.AbstractRegistryInterceptor;
+import org.jboss.soa.esb.services.registry.RegistryException;
+import org.jboss.soa.esb.services.registry.ServiceNotFoundException;
+
+/**
+ * Caching registry interceptor.
+ *
+ * @author <a href='mailto:Kevin.Conner at jboss.com'>Kevin Conner</a>
+ */
+public class CachingRegistryInterceptor extends AbstractRegistryInterceptor
+{
+    /**
+     * The logger for the registry cache
+     */
+    private static final Logger LOGGER = Logger.getLogger(CachingRegistryInterceptor.class) ;
+    
+    /**
+     * The default service cache size.
+     */
+    private static final int DEFAULT_MAX_CACHE_SIZE = 100 ;
+    /**
+     * The default cache validity period.
+     */
+    private static final long DEFAULT_VALIDITY_PERIOD = (10*60*1000L) ;
+    
+    /**
+     * The maximum number of services stored in the cache.
+     */
+    private static final int MAX_CACHE_SIZE ;
+    /**
+     * The validity period of the entry.
+     */
+    private static final long VALIDITY_PERIOD ;
+    
+    /**
+     * The LRU map for the cached services.
+     */
+    private final LRUMap serviceInfoMap = new LRUMap(MAX_CACHE_SIZE) ;
+
+    public List<String> findAllServices() throws RegistryException
+    {
+        // Do not cache, go direct to the registry
+        return getRegistry().findAllServices() ;
+    }
+
+    public List<String> findServices(final String category)
+            throws RegistryException
+    {
+        // Do not cache, go direct to the registry
+        return getRegistry().findServices(category) ;
+    }
+
+    public EPR findEPR(final String category, final String name)
+            throws RegistryException, ServiceNotFoundException
+    {
+        final List<EPR> eprs = findEPRs(category, name) ;
+        return eprs.get(0) ;
+    }
+
+    public List<EPR> findEPRs(final String category, final String name)
+            throws RegistryException, ServiceNotFoundException
+    {
+        final Service service = new Service(category, name) ;
+        return Collections.unmodifiableList(getEPRs(service)) ;
+    }
+
+    public void registerEPR(final String category, final String name,
+            final String serviceDescription, final EPR epr, final String eprDescription)
+            throws RegistryException
+    {
+        final Service service = new Service(category, name) ;
+        synchronized(this)
+        {
+            getRegistry().registerEPR(category, name, serviceDescription, epr, eprDescription) ;
+            final List<EPR> eprs = getCurrentEPRs(service) ;
+            if (eprs != null)
+            {
+                eprs.add(epr) ;
+            }
+        }
+    }
+
+    public void unRegisterEPR(final String category, final String name,
+            final EPR epr) throws RegistryException, ServiceNotFoundException
+    {
+        final Service service = new Service(category, name) ;
+        synchronized(this)
+        {
+            final List<EPR> eprs = getCurrentEPRs(service) ;
+            if ((eprs != null) && eprs.remove(epr) && (eprs.size() == 0))
+            {
+                serviceInfoMap.remove(service) ;
+                if (LOGGER.isInfoEnabled())
+                {
+                    LOGGER.debug("Cache removing service " + service) ;
+                }
+            }
+            getRegistry().unRegisterEPR(category, name, epr) ;
+        }
+    }
+
+    public void unRegisterService(final String category, final String name)
+            throws RegistryException, ServiceNotFoundException
+    {
+        final Service service = new Service(category, name) ;
+        synchronized(this)
+        {
+            serviceInfoMap.remove(service) ;
+            if (LOGGER.isInfoEnabled())
+            {
+                LOGGER.debug("Cache removing service " + service) ;
+            }
+            getRegistry().unRegisterService(category, name) ;
+        }
+    }
+
+    private synchronized List<EPR> getEPRs(final Service service)
+        throws RegistryException, ServiceNotFoundException
+    {
+        final List<EPR> eprs = getCurrentEPRs(service) ;
+        if (eprs != null)
+        {
+            return eprs ;
+        }
+        else
+        {
+            final List<EPR> currentEPRs = getRegistry().findEPRs(service.getCategory(), service.getName()) ;
+            final List<EPR> copyEPRs = new ArrayList<EPR>(currentEPRs) ;
+            final ServiceInfo serviceInfo = new ServiceInfo(copyEPRs) ;
+            serviceInfoMap.put(service, serviceInfo) ;
+            if (LOGGER.isInfoEnabled())
+            {
+                LOGGER.debug("Cache reloaded for service " + service) ;
+            }
+            return copyEPRs ;
+        }
+    }
+    
+    private synchronized List<EPR> getCurrentEPRs(final Service service)
+    {
+        final ServiceInfo serviceInfo = (ServiceInfo)serviceInfoMap.get(service) ;
+        if (serviceInfo != null)
+        {
+            final boolean infoEnabled = LOGGER.isInfoEnabled() ;
+            if (serviceInfo.isValid())
+            {
+                if (infoEnabled)
+                {
+                    LOGGER.debug("Cache hit for service " + service) ;
+                }
+                return serviceInfo.getEPRs() ;
+            }
+            else
+            {
+                if (infoEnabled)
+                {
+                    LOGGER.debug("Cache expiry for service " + service) ;
+                }
+                serviceInfoMap.remove(service) ;
+            }
+        }
+        return null ;
+    }
+    
+    private static class ServiceInfo
+    {
+        private final long expiryTime ;
+        
+        private List<EPR> eprs ;
+        
+        private ServiceInfo(final List<EPR> eprs)
+        {
+            this.eprs = eprs ;
+            if (VALIDITY_PERIOD > 0)
+            {
+                expiryTime = System.currentTimeMillis() + VALIDITY_PERIOD ;
+            }
+            else
+            {
+                expiryTime = Long.MAX_VALUE ;
+            }
+        }
+        
+        boolean isValid()
+        {
+            return System.currentTimeMillis() < expiryTime ;
+        }
+        
+        List<EPR> getEPRs()
+        {
+            return eprs ;
+        }
+    }
+
+    static
+    {
+        final String maxCacheSizeVal = Configuration.getRegistryCacheMaxSize() ;
+        int maxCacheSize = DEFAULT_MAX_CACHE_SIZE ;
+        if (maxCacheSizeVal != null)
+        {
+            try
+            {
+                maxCacheSize = Integer.parseInt(maxCacheSizeVal) ;
+            }
+            catch (final NumberFormatException nfe)
+            {
+                // fallback to default
+                LOGGER.warn("Failed to parse maximum cache size, falling back to default", nfe) ;
+            }
+        }
+
+        final String validityPeriodVal = Configuration.getRegistryCacheValidityPeriod() ;
+        long validityPeriod = DEFAULT_VALIDITY_PERIOD ;
+        if (validityPeriodVal != null)
+        {
+            try
+            {
+                validityPeriod = Long.parseLong(validityPeriodVal) ;
+            }
+            catch (final NumberFormatException nfe)
+            {
+                // fallback to default
+                LOGGER.warn("Failed to parse validity period, falling back to default", nfe) ;
+            }
+        }
+        VALIDITY_PERIOD = validityPeriod ;
+        MAX_CACHE_SIZE = maxCacheSize ;
+        
+        if (LOGGER.isDebugEnabled())
+        {
+            LOGGER.debug("Registry cache validity period: " + VALIDITY_PERIOD) ;
+            LOGGER.debug("Registry cache maximum size: " + MAX_CACHE_SIZE) ;
+        }
+    }
+}


Property changes on: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/CachingRegistryInterceptor.java
___________________________________________________________________
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native

Deleted: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/InVMRegistry.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/InVMRegistry.java	2008-08-04 10:31:05 UTC (rev 21336)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/InVMRegistry.java	2008-08-04 11:55:23 UTC (rev 21337)
@@ -1,158 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA  02110-1301, USA.
- *
- * (C) 2005-2006, JBoss Inc.
- */
-package org.jboss.internal.soa.esb.services.registry;
-
-import org.jboss.internal.soa.esb.couriers.InVMCourier;
-import org.jboss.soa.esb.Service;
-import org.jboss.soa.esb.addressing.EPR;
-import org.jboss.soa.esb.addressing.eprs.InVMEpr;
-import org.jboss.soa.esb.couriers.CourierFactory;
-import org.jboss.soa.esb.services.registry.Registry;
-import org.jboss.soa.esb.services.registry.RegistryException;
-import org.jboss.soa.esb.services.registry.ServiceNotFoundException;
-
-import java.util.*;
-import java.util.concurrent.ConcurrentHashMap;
-
-/**
- * In VM registry.
- *
- * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
- */
-public class InVMRegistry implements Registry {
-
-    private Map<Service, List<RegsitryEntry>> regEntries = new ConcurrentHashMap<Service, List<RegsitryEntry>>();
-
-    public void registerEPR(String serviceCategoryName, String serviceName, String serviceDescription, EPR epr, String eprDescription) throws RegistryException {
-        if(serviceCategoryName == null) {
-            serviceCategoryName = "";
-        }
-        Service service = new Service(serviceCategoryName, serviceName);
-        RegsitryEntry regEntry = new RegsitryEntry(service, serviceDescription, epr, eprDescription);
-        List<RegsitryEntry> serviceEntries = getServiceEntries(service);
-
-        serviceEntries.add(regEntry);
-    }
-
-    public void unRegisterService(String category, String serviceName) throws RegistryException, ServiceNotFoundException {
-        unRegisterInVMService(category, serviceName);
-    }
-
-    protected boolean unRegisterInVMService(String category, String serviceName) throws RegistryException, ServiceNotFoundException {
-        if(category == null) {
-            category = "";
-        }
-        _unRegisterEPR(category, serviceName, null);
-        return (regEntries.remove(new Service(category, serviceName)) != null);
-    }
-
-    public void unRegisterEPR(String serviceCategoryName, String serviceName, EPR epr) throws RegistryException, ServiceNotFoundException {
-        _unRegisterEPR(serviceCategoryName, serviceName, epr);
-    }
-
-    private void _unRegisterEPR(String serviceCategoryName, String serviceName, EPR epr) {
-        if(serviceCategoryName == null) {
-            serviceCategoryName = "";
-        }
-        Service service = new Service(serviceCategoryName, serviceName);
-        List<RegsitryEntry> serviceEntries = getServiceEntries(service);
-        Iterator<RegsitryEntry> iterator = serviceEntries.iterator();
-
-        while (iterator.hasNext()) {
-            RegsitryEntry regsitryEntry =  iterator.next();
-
-            if(epr == null || regsitryEntry.getEpr().getAddr().getAddress().equals(epr.getAddr().getAddress())) {
-                if(regsitryEntry.getEpr() instanceof InVMEpr) {
-                    InVMCourier courier = CourierFactory.getInstance().getInVMCourier((InVMEpr)regsitryEntry.getEpr());
-                    if(courier != null) {
-                        courier.setActive(false);
-                    }
-                }
-
-                iterator.remove();
-            }
-        }
-    }
-
-    public List<String> findAllServices() throws RegistryException {
-        return findServices(null);
-    }
-
-    public List<String> findServices(String serviceCategoryName) throws RegistryException {
-        Iterator<Service> iterator = regEntries.keySet().iterator();
-        List<String> services = new ArrayList<String>();
-
-        while (iterator.hasNext()) {
-            Service service =  iterator.next();
-            if(serviceCategoryName == null || service.getCategory().equals(serviceCategoryName)) {
-                services.add(service.getName());
-            }
-        }
-
-        return services;
-    }
-
-    public List<EPR> findEPRs(String serviceCategoryName, String serviceName) throws RegistryException, ServiceNotFoundException {
-        if(serviceCategoryName == null) {
-            serviceCategoryName = "";
-        }
-        List<EPR> eprs = new ArrayList<EPR>();
-        Service service = new Service(serviceCategoryName, serviceName);
-        List<RegsitryEntry> serviceEntries = getServiceEntries(service);
-
-        for (RegsitryEntry serviceEntry : serviceEntries) {
-            eprs.add(serviceEntry.getEpr());
-        }
-
-        return eprs;
-    }
-
-    public EPR findEPR(String serviceCategoryName, String serviceName) throws RegistryException, ServiceNotFoundException {
-        if(serviceCategoryName == null) {
-            serviceCategoryName = "";
-        }
-        List<EPR> eprs = findEPRs(serviceCategoryName, serviceName);
-
-        if(!eprs.isEmpty()) {
-            return eprs.get(0);
-        } else {
-            return null;
-        }
-    }
-
-    private synchronized List<RegsitryEntry> getServiceEntries(Service service) {
-        List<RegsitryEntry> serviceEntries = null; // = regEntries.get(service);
-        Set<Map.Entry<Service, List<RegsitryEntry>>> entries = regEntries.entrySet();
-
-        for (Map.Entry<Service, List<RegsitryEntry>> entry : entries) {
-            if(entry.getKey().equals(service)) {
-                serviceEntries = entry.getValue();
-                break;
-            }
-        }
-
-        if(serviceEntries == null) {
-            serviceEntries = new ArrayList<RegsitryEntry>();
-            regEntries.put(service, serviceEntries);
-        }
-
-        return serviceEntries;
-    }
-}

Copied: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/InVMRegistryInterceptor.java (from rev 21320, labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/InVMRegistry.java)
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/InVMRegistryInterceptor.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/InVMRegistryInterceptor.java	2008-08-04 11:55:23 UTC (rev 21337)
@@ -0,0 +1,190 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.internal.soa.esb.services.registry;
+
+import org.jboss.internal.soa.esb.couriers.InVMCourier;
+import org.jboss.soa.esb.Service;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.addressing.eprs.InVMEpr;
+import org.jboss.soa.esb.couriers.CourierFactory;
+import org.jboss.soa.esb.services.registry.AbstractRegistryInterceptor;
+import org.jboss.soa.esb.services.registry.RegistryException;
+import org.jboss.soa.esb.services.registry.ServiceNotFoundException;
+
+import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
+
+/**
+ * In VM registry.
+ *
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class InVMRegistryInterceptor extends AbstractRegistryInterceptor {
+
+    private Map<Service, List<RegsitryEntry>> regEntries = new ConcurrentHashMap<Service, List<RegsitryEntry>>();
+    
+    public void registerEPR(String serviceCategoryName, String serviceName, String serviceDescription, EPR epr, String eprDescription) throws RegistryException {
+        if (epr instanceof InVMEpr) {
+            Service service = new Service(serviceCategoryName, serviceName);
+            RegsitryEntry regEntry = new RegsitryEntry(service, serviceDescription, epr, eprDescription);
+            List<RegsitryEntry> serviceEntries = getServiceEntries(service);
+    
+            serviceEntries.add(regEntry);
+        } else {
+            getRegistry().registerEPR(serviceCategoryName, serviceName, serviceDescription, epr, eprDescription) ;
+        }
+    }
+
+    public void unRegisterService(String category, String serviceName) throws RegistryException, ServiceNotFoundException {
+        final boolean entryRemoved = unRegisterInVMService(category, serviceName);
+        try {
+            getRegistry().unRegisterService(category, serviceName) ;
+        } catch (final ServiceNotFoundException snfe) {
+            if (!entryRemoved) {
+                throw snfe ;
+            }
+        }
+    }
+
+    protected boolean unRegisterInVMService(String category, String serviceName) throws RegistryException, ServiceNotFoundException {
+        if (isValidService(category, serviceName)) {
+            _unRegisterEPR(category, serviceName, null);
+            return (regEntries.remove(new Service(category, serviceName)) != null);
+        } else {
+            return false ;
+        }
+    }
+
+    public void unRegisterEPR(String serviceCategoryName, String serviceName, EPR epr) throws RegistryException, ServiceNotFoundException {
+        if (epr instanceof InVMEpr) {
+            _unRegisterEPR(serviceCategoryName, serviceName, epr);
+        } else {
+            getRegistry().unRegisterEPR(serviceCategoryName, serviceName, epr) ;
+        }
+    }
+
+    private void _unRegisterEPR(String serviceCategoryName, String serviceName, EPR epr) {
+        Service service = new Service(serviceCategoryName, serviceName);
+        List<RegsitryEntry> serviceEntries = getServiceEntries(service);
+        Iterator<RegsitryEntry> iterator = serviceEntries.iterator();
+
+        while (iterator.hasNext()) {
+            RegsitryEntry regsitryEntry =  iterator.next();
+
+            if(epr == null || regsitryEntry.getEpr().getAddr().getAddress().equals(epr.getAddr().getAddress())) {
+                if(regsitryEntry.getEpr() instanceof InVMEpr) {
+                    InVMCourier courier = CourierFactory.getInstance().getInVMCourier((InVMEpr)regsitryEntry.getEpr());
+                    if(courier != null) {
+                        courier.setActive(false);
+                    }
+                }
+
+                iterator.remove();
+            }
+        }
+    }
+
+    public List<String> findAllServices() throws RegistryException {
+        final List<String> services = findInVMServices(null);
+        services.addAll(getRegistry().findAllServices()) ;
+        return services ;
+    }
+
+    public List<String> findServices(String serviceCategoryName) throws RegistryException {
+        final List<String> services = findInVMServices(serviceCategoryName);
+        services.addAll(getRegistry().findServices(serviceCategoryName)) ;
+        return services ;
+    }
+    
+    private List<String> findInVMServices(String serviceCategoryName) throws RegistryException {
+        Iterator<Service> iterator = regEntries.keySet().iterator();
+        List<String> services = new ArrayList<String>();
+
+        while (iterator.hasNext()) {
+            Service service =  iterator.next();
+            if(serviceCategoryName == null || service.getCategory().equals(serviceCategoryName)) {
+                services.add(service.getName());
+            }
+        }
+
+        return services;
+    }
+
+    public List<EPR> findEPRs(String serviceCategoryName, String serviceName) throws RegistryException, ServiceNotFoundException {
+        List<EPR> eprs = findInVMEPRs(serviceCategoryName, serviceName) ;
+        if (eprs.size() == 0) {
+            return getRegistry().findEPRs(serviceCategoryName, serviceName) ;
+        } else {
+            try {
+                eprs.addAll(getRegistry().findEPRs(serviceCategoryName, serviceName)) ;
+            } catch (final ServiceNotFoundException snfe) {
+                // do nothing, we already have some EPRs.
+            }
+        }
+        return eprs;
+    }
+
+    public EPR findEPR(String serviceCategoryName, String serviceName) throws RegistryException, ServiceNotFoundException {
+        List<EPR> eprs = findInVMEPRs(serviceCategoryName, serviceName);
+
+        if(!eprs.isEmpty()) {
+            return eprs.get(0);
+        } else {
+            return getRegistry().findEPR(serviceCategoryName, serviceName);
+        }
+    }
+    
+    private List<EPR> findInVMEPRs(String serviceCategoryName, String serviceName) throws RegistryException, ServiceNotFoundException {
+        List<EPR> eprs = new ArrayList<EPR>();
+        if (isValidService(serviceCategoryName, serviceName)) {
+            Service service = new Service(serviceCategoryName, serviceName);
+            List<RegsitryEntry> serviceEntries = getServiceEntries(service);
+    
+            for (RegsitryEntry serviceEntry : serviceEntries) {
+                eprs.add(serviceEntry.getEpr());
+            }
+        }
+        return eprs ;
+    }
+
+    private synchronized List<RegsitryEntry> getServiceEntries(Service service) {
+        List<RegsitryEntry> serviceEntries = null; // = regEntries.get(service);
+        Set<Map.Entry<Service, List<RegsitryEntry>>> entries = regEntries.entrySet();
+
+        for (Map.Entry<Service, List<RegsitryEntry>> entry : entries) {
+            if(entry.getKey().equals(service)) {
+                serviceEntries = entry.getValue();
+                break;
+            }
+        }
+
+        if(serviceEntries == null) {
+            serviceEntries = new ArrayList<RegsitryEntry>();
+            regEntries.put(service, serviceEntries);
+        }
+
+        return serviceEntries;
+    }
+    
+    private boolean isValidService(final String category, final String name) {
+       return ((category != null) && (category.length() > 0) &&
+           (name != null) && (name.length() > 0)) ;
+    }
+}

Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/JAXRRegistryImpl.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/JAXRRegistryImpl.java	2008-08-04 10:31:05 UTC (rev 21336)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/internal/soa/esb/services/registry/JAXRRegistryImpl.java	2008-08-04 11:55:23 UTC (rev 21337)
@@ -56,7 +56,7 @@
 import org.jboss.soa.esb.UnmarshalException;
 import org.jboss.soa.esb.ConfigurationException;
 import org.jboss.soa.esb.addressing.EPR;
-import org.jboss.soa.esb.addressing.eprs.InVMEpr;
+import org.jboss.soa.esb.services.registry.Registry;
 import org.jboss.soa.esb.services.registry.RegistryException;
 import org.jboss.soa.esb.services.registry.ServiceNotFoundException;
 /**
@@ -66,7 +66,7 @@
  *
  * @author Kurt Stam
  */
-public class JAXRRegistryImpl extends InVMRegistry 
+public class JAXRRegistryImpl implements Registry
 {
 	private static Logger logger = Logger.getLogger(JAXRRegistryImpl.class);
     private JAXRConnectionFactory jaxrConnectionFactory;
@@ -109,25 +109,13 @@
 	 */
 	@SuppressWarnings("unchecked")
     public void unRegisterService(String category, String serviceName) throws RegistryException, ServiceNotFoundException{
-        // Make sure it's unregistered from the InVMRegistry...
-        boolean unregisteredFromInVMReg = false;
-
-        if(!isEmptyServiceName(category, serviceName)) {
-            unregisteredFromInVMReg = unRegisterInVMService(category, serviceName);
-        }
-
         //    first find the ServiceBindings for this service
         Connection connection = jaxrConnectionFactory.getConnection();
         Service service = null;
         try {
             service = findService(category, serviceName);
             if (service==null) {
-                if(unregisteredFromInVMReg) {
-                    // It's OK... it was unregistered from the InVMRegistry
-                    return;
-                } else {
-                    throw new ServiceNotFoundException("No such EPR found for service with name = " + serviceName);
-                }
+                throw new ServiceNotFoundException("No such EPR found for service with name = " + serviceName);
             }
             RegistryService rs = connection.getRegistryService();
             BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
@@ -146,99 +134,90 @@
 	public void registerEPR(String category, String serviceName, String serviceDescription, EPR epr, String eprDescription) 
 		throws RegistryException
 	{
-        if(epr instanceof InVMEpr) {
-            // Only register these EPRs in memory...
-            super.registerEPR(category, serviceName, serviceDescription, epr, eprDescription);
-        } else {
-            Connection connection = jaxrConnectionFactory.getConnection();
-            try {
-                //Find the service
-                Service service = findService(category,serviceName);
-                if (service==null) {
-                    logger.log(Level.DEBUG, "Service " + serviceName + " does not yet exist, creating now..");
-                    service = registerService(category, serviceName, serviceDescription);
-                }
+        Connection connection = jaxrConnectionFactory.getConnection();
+        try {
+            //Find the service
+            Service service = findService(category,serviceName);
+            if (service==null) {
+                logger.log(Level.DEBUG, "Service " + serviceName + " does not yet exist, creating now..");
+                service = registerService(category, serviceName, serviceDescription);
+            }
 
-                RegistryService rs = connection.getRegistryService();
-                BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
-                BusinessQueryManager bqm = rs.getBusinessQueryManager();
-                ServiceBinding serviceBinding = blm.createServiceBinding();
-                serviceBinding.setDescription(blm.createInternationalString(eprDescription));
-                String xml = EPRHelper.toXMLString(epr);
-                serviceBinding.setAccessURI(xml);
+            RegistryService rs = connection.getRegistryService();
+            BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
+            BusinessQueryManager bqm = rs.getBusinessQueryManager();
+            ServiceBinding serviceBinding = blm.createServiceBinding();
+            serviceBinding.setDescription(blm.createInternationalString(eprDescription));
+            String xml = EPRHelper.toXMLString(epr);
+            serviceBinding.setAccessURI(xml);
 
-                ArrayList<ServiceBinding> serviceBindings = new ArrayList<ServiceBinding>();
-                serviceBindings.add(serviceBinding);
-                service.addServiceBindings(serviceBindings);
-                Collection<String> findQualifiers = new ArrayList<String>();
-                findQualifiers.add(FindQualifier.AND_ALL_KEYS);
-                findQualifiers.add(FindQualifier.SORT_BY_NAME_DESC);
-                ClassificationScheme cScheme = bqm.findClassificationSchemeByName(findQualifiers, "org.jboss.soa.esb.:category");
-                Classification classification = blm.createClassification(cScheme, "category", category);
-                service.addClassification(classification);
+            ArrayList<ServiceBinding> serviceBindings = new ArrayList<ServiceBinding>();
+            serviceBindings.add(serviceBinding);
+            service.addServiceBindings(serviceBindings);
+            Collection<String> findQualifiers = new ArrayList<String>();
+            findQualifiers.add(FindQualifier.AND_ALL_KEYS);
+            findQualifiers.add(FindQualifier.SORT_BY_NAME_DESC);
+            ClassificationScheme cScheme = bqm.findClassificationSchemeByName(findQualifiers, "org.jboss.soa.esb.:category");
+            Classification classification = blm.createClassification(cScheme, "category", category);
+            service.addClassification(classification);
 
-                saveRegistryObject(serviceBinding, jaxrConnectionFactory);
-            } catch (JAXRException je) {
-                throw new RegistryException(je.getLocalizedMessage(), je);
-            } catch (MarshalException me) {
-                throw new RegistryException(me.getLocalizedMessage(), me);
-            } finally {
-                jaxrConnectionFactory.closeConnection(connection);
-            }
+            saveRegistryObject(serviceBinding, jaxrConnectionFactory);
+        } catch (JAXRException je) {
+            throw new RegistryException(je.getLocalizedMessage(), je);
+        } catch (MarshalException me) {
+            throw new RegistryException(me.getLocalizedMessage(), me);
+        } finally {
+            jaxrConnectionFactory.closeConnection(connection);
         }
     }
 	/** 
 	 * Remove an EPR from the Registry
 	 */
 	public void unRegisterEPR(String category, String serviceName, EPR toBeDeletedEPR) throws RegistryException, ServiceNotFoundException{
-        if(toBeDeletedEPR instanceof InVMEpr) {
-            super.unRegisterEPR(category, serviceName, toBeDeletedEPR);
-        } else {
-            //first find the ServiceBindings for this service
-            Connection connection = jaxrConnectionFactory.getConnection();
-            Service service = null;
-            try {
-                service = findService(category, serviceName);
-                if (service==null) {
-                    throw new ServiceNotFoundException("No such Service found for service with category= "
-                            + category + " and name = " + serviceName);
-                }
-                Collection serviceBindings = findServiceBindings(service);
-                service.addServiceBindings(serviceBindings);
-                for (Iterator i=serviceBindings.iterator();i.hasNext();){
-                    ServiceBinding serviceBinding = (ServiceBinding) i.next();
-                    String eprXML = serviceBinding.getAccessURI().trim();
-                    // for backwards compatibility still have the decoder if
-                    // unmarchalling fails
+        //first find the ServiceBindings for this service
+        Connection connection = jaxrConnectionFactory.getConnection();
+        Service service = null;
+        try {
+            service = findService(category, serviceName);
+            if (service==null) {
+                throw new ServiceNotFoundException("No such Service found for service with category= "
+                        + category + " and name = " + serviceName);
+            }
+            Collection serviceBindings = findServiceBindings(service);
+            service.addServiceBindings(serviceBindings);
+            for (Iterator i=serviceBindings.iterator();i.hasNext();){
+                ServiceBinding serviceBinding = (ServiceBinding) i.next();
+                String eprXML = serviceBinding.getAccessURI().trim();
+                // for backwards compatibility still have the decoder if
+                // unmarchalling fails
+                try {
+                    EPR epr = EPRHelper.fromXMLString(eprXML);
+                } catch (UnmarshalException unme) {
                     try {
-                        EPR epr = EPRHelper.fromXMLString(eprXML);
-                    } catch (UnmarshalException unme) {
-                        try {
-                            eprXML = URLDecoder.decode(eprXML, "UTF-8").trim();
-                        } catch (UnsupportedEncodingException ue) {
-                            logger.error(unme.getMessage(), unme);
-                            logger.error(ue.getMessage(), ue);
-                        }
+                        eprXML = URLDecoder.decode(eprXML, "UTF-8").trim();
+                    } catch (UnsupportedEncodingException ue) {
+                        logger.error(unme.getMessage(), unme);
+                        logger.error(ue.getMessage(), ue);
                     }
-                    String toBeDeletedEPRXml = EPRHelper.toXMLString(toBeDeletedEPR).trim();
-                    if (eprXML.equals(toBeDeletedEPRXml)) {
-                        RegistryService rs = connection.getRegistryService();
-                        BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
-                        Collection<Key> serviceBindingKeys = new ArrayList<Key>();
-                        serviceBindingKeys.add(serviceBinding.getKey());
-                        blm.deleteServiceBindings(serviceBindingKeys);
-                        return;
-                    }
                 }
-                throw new RegistryException("No such EPR found for service with name = "
-                        + serviceName + " and EPR=" + toBeDeletedEPR);
-            } catch (JAXRException je) {
-                throw new RegistryException(je.getLocalizedMessage(), je);
-            } catch (MarshalException me) {
-                throw new RegistryException(me.getLocalizedMessage(), me);
-            } finally {
-                jaxrConnectionFactory.closeConnection(connection);
+                String toBeDeletedEPRXml = EPRHelper.toXMLString(toBeDeletedEPR).trim();
+                if (eprXML.equals(toBeDeletedEPRXml)) {
+                    RegistryService rs = connection.getRegistryService();
+                    BusinessLifeCycleManager blm = rs.getBusinessLifeCycleManager();
+                    Collection<Key> serviceBindingKeys = new ArrayList<Key>();
+                    serviceBindingKeys.add(serviceBinding.getKey());
+                    blm.deleteServiceBindings(serviceBindingKeys);
+                    return;
+                }
             }
+            throw new RegistryException("No such EPR found for service with name = "
+                    + serviceName + " and EPR=" + toBeDeletedEPR);
+        } catch (JAXRException je) {
+            throw new RegistryException(je.getLocalizedMessage(), je);
+        } catch (MarshalException me) {
+            throw new RegistryException(me.getLocalizedMessage(), me);
+        } finally {
+            jaxrConnectionFactory.closeConnection(connection);
         }
     }
 	
@@ -249,10 +228,6 @@
 	public List<String> findAllServices() throws RegistryException
 	{
 		List<String> serviceNames = new ArrayList<String>();
-
-        // Add the invm Services at the front of the list...
-        serviceNames.addAll(super.findAllServices());
-
 		try {
 			Collection services = getJBossESBOrganization().getServices();
 			for (Iterator i=services.iterator();i.hasNext();) {
@@ -273,11 +248,6 @@
 	{
 		List<String>serviceNames = new ArrayList<String>();
 
-        if(category != null && !category.trim().equals("")) {
-            // Add the invm Services at the front of the list...
-            serviceNames.addAll(super.findServices(category));
-        }
-
         try {
 			Collection<Service>services = findServicesForCategory(category);
 			for (Iterator<Service> i=services.iterator();i.hasNext();) {
@@ -297,20 +267,11 @@
 	{
 		List<EPR> eprs = new ArrayList<EPR>();
 
-        if(!isEmptyServiceName(category, serviceName)) {
-            // Add the invm EPRs at the front of the list...
-            eprs.addAll(super.findEPRs(category, serviceName));
-        }
-
         Connection connection = jaxrConnectionFactory.getConnection();
 		try {
 			Service service = findService(category, serviceName);
 			if (service==null){
-                if(eprs.isEmpty()) {
-                    throw new ServiceNotFoundException("Could not find service with category=" + category + " and serviceName=" + serviceName);
-                } else {
-                    return eprs;
-                }
+                throw new ServiceNotFoundException("Could not find service with category=" + category + " and serviceName=" + serviceName);
 			}
 			// Get registry service and business query manager
 			Collection<ServiceBinding> serviceBindings = findServiceBindings(service);
@@ -351,45 +312,38 @@
 	 */
 	public EPR findEPR(String category, String serviceName) throws RegistryException, ServiceNotFoundException
 	{
-        EPR epr = null;
-
-        if(!isEmptyServiceName(category, serviceName)) {
-            epr = super.findEPR(category, serviceName);
-        }
-
-        if(epr == null) {
-            Connection connection = jaxrConnectionFactory.getConnection();
-            try {
-                Service service = findService(category, serviceName);
-                if (service==null){
-                    throw new ServiceNotFoundException("Could not find service with category=" + category + " and serviceName=" + serviceName);
-                }
-                // Get registry service and business query manager
-                Collection<ServiceBinding> serviceBindings = findServiceBindings(service);
-                if (serviceBindings.iterator().hasNext()) {
-                    ServiceBinding serviceBinding = (ServiceBinding) serviceBindings.iterator().next();
-                    String eprXML = serviceBinding.getAccessURI();
-                    // for backwards compatibility still have the decoder if
-                    // unmarchalling fails
+        EPR epr = null ;
+        Connection connection = jaxrConnectionFactory.getConnection();
+        try {
+            Service service = findService(category, serviceName);
+            if (service==null){
+                throw new ServiceNotFoundException("Could not find service with category=" + category + " and serviceName=" + serviceName);
+            }
+            // Get registry service and business query manager
+            Collection<ServiceBinding> serviceBindings = findServiceBindings(service);
+            if (serviceBindings.iterator().hasNext()) {
+                ServiceBinding serviceBinding = (ServiceBinding) serviceBindings.iterator().next();
+                String eprXML = serviceBinding.getAccessURI();
+                // for backwards compatibility still have the decoder if
+                // unmarchalling fails
+                try {
+                    epr = EPRHelper.fromXMLString(eprXML);
+                } catch (UnmarshalException unme) {
                     try {
+                        eprXML = URLDecoder.decode(eprXML, "UTF-8");
                         epr = EPRHelper.fromXMLString(eprXML);
-                    } catch (UnmarshalException unme) {
-                        try {
-                            eprXML = URLDecoder.decode(eprXML, "UTF-8");
-                            epr = EPRHelper.fromXMLString(eprXML);
-                        } catch (UnsupportedEncodingException ue) {
-                            logger.error(ue.getMessage(), ue);
-                            throw new UnmarshalException(ue.getMessage(), ue);
-                        }
+                    } catch (UnsupportedEncodingException ue) {
+                        logger.error(ue.getMessage(), ue);
+                        throw new UnmarshalException(ue.getMessage(), ue);
                     }
                 }
-            } catch (JAXRException je) {
-                throw new RegistryException(je.getLocalizedMessage(), je);
-            } catch (UnmarshalException me) {
-                throw new RegistryException(me.getLocalizedMessage(), me);
-            } finally {
-                jaxrConnectionFactory.closeConnection(connection);
             }
+        } catch (JAXRException je) {
+            throw new RegistryException(je.getLocalizedMessage(), je);
+        } catch (UnmarshalException me) {
+            throw new RegistryException(me.getLocalizedMessage(), me);
+        } finally {
+            jaxrConnectionFactory.closeConnection(connection);
         }
         
         return epr;
@@ -721,11 +675,6 @@
 			jaxrConnectionFactory.closeConnection(connection);
 		}
 	}
-
-    private boolean isEmptyServiceName(String category, String serviceName) {
-        // This registry impl allows Service names (name and/or category) to be empty (which seems a bit risky!!)
-        return (category == null || serviceName == null || category.trim().equals("") || serviceName.trim().equals(""));
-    }
 }
 
 	

Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/common/Configuration.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/common/Configuration.java	2008-08-04 10:31:05 UTC (rev 21336)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/common/Configuration.java	2008-08-04 11:55:23 UTC (rev 21337)
@@ -30,6 +30,7 @@
 import javax.naming.NamingException;
 
 import org.apache.log4j.Logger;
+import org.jboss.internal.soa.esb.services.registry.InVMRegistryInterceptor;
 import org.jboss.soa.esb.ConfigurationException;
 import org.jboss.soa.esb.helpers.KeyValuePair;
 import org.jboss.soa.esb.helpers.NamingContextException;
@@ -73,7 +74,10 @@
 			new KeyValuePair(Environment.MSG_STORE_DB_POOL_TEST_TABLE,  getStorePoolTestTable()),
 			new KeyValuePair(Environment.MSG_STORE_DB_POOL_TIMEOUT_MILLIS,getStorePoolTimeoutMillis()),
 			new KeyValuePair(Environment.MSG_STORE_DB_CONN_MANAGER		,getStoreDBConnectionManager()),
-			new KeyValuePair(Environment.MSG_STORE_DB_DATASOURCE_NAME	,getStoreDBDatasourceName())
+			new KeyValuePair(Environment.MSG_STORE_DB_DATASOURCE_NAME	,getStoreDBDatasourceName()),
+			new KeyValuePair(Environment.REGISTRY_INTERCEPTORS			,getRegistryInterceptors()),
+			new KeyValuePair(Environment.REGISTRY_CACHE_MAX_SIZE		,getRegistryCacheMaxSize()),
+			new KeyValuePair(Environment.REGISTRY_CACHE_VALIDITY_PERIOD	,getRegistryCacheValidityPeriod())
 	};
 
 	public static String dump()
@@ -336,6 +340,35 @@
 		return ModulePropertyManager.getPropertyManager(ModulePropertyManager.DBSTORE_MODULE).getProperty(Environment.MSG_STORE_JCR_ROOT_NODE_PATH);
 	}
 	
+    /**
+     * Get the registry interceptor class names
+     * @return Registry interceptor Class names.
+     */
+    public static String getRegistryInterceptors()
+    {
+        // If nothing is specified then we default to the InVM interceptor
+        return ModulePropertyManager.getPropertyManager(ModulePropertyManager.REGISTRY_MODULE).getProperty(Environment.REGISTRY_INTERCEPTORS,
+            InVMRegistryInterceptor.class.getName());
+    }
+    
+    /**
+     * Get the maximum cache size for the caching registry.
+     * @return The maximum cache size.
+     */
+    public static String getRegistryCacheMaxSize()
+    {
+        return ModulePropertyManager.getPropertyManager(ModulePropertyManager.REGISTRY_MODULE).getProperty(Environment.REGISTRY_CACHE_MAX_SIZE) ;
+    }
+    
+    /**
+     * Get the validity period for the caching registry.
+     * @return The cache validity period.
+     */
+    public static String getRegistryCacheValidityPeriod()
+    {
+        return ModulePropertyManager.getPropertyManager(ModulePropertyManager.REGISTRY_MODULE).getProperty(Environment.REGISTRY_CACHE_VALIDITY_PERIOD) ;
+    }
+    
 	/**
 	 * Construct a naming context based on the connection details outlined
 	 * in the named configuration module/section.

Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/common/Environment.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/common/Environment.java	2008-08-04 10:31:05 UTC (rev 21336)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/common/Environment.java	2008-08-04 11:55:23 UTC (rev 21337)
@@ -120,6 +120,19 @@
      * Property that holds the max number of rows the UDDI should return on searches.
      */
     public static final String REGISTRY_UDDI_MAX_ROWS          = "org.jboss.soa.esb.registry.uddi.maxRows";
+    
+    /**
+     * The Registry interceptor class names.
+     */
+    public static final String REGISTRY_INTERCEPTORS = "org.jboss.soa.esb.registry.interceptors";
+    /**
+     * The maximum cache size for the registry.
+     */
+    public static final String REGISTRY_CACHE_MAX_SIZE = "org.jboss.soa.esb.registry.cache.maxSize";
+    /**
+     * The cache validity period.
+     */
+    public static final String REGISTRY_CACHE_VALIDITY_PERIOD = "org.jboss.soa.esb.registry.cache.validityPeriod";
 	/*
 	 * Some default values.
 	 */

Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/services/registry/AbstractRegistryInterceptor.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/services/registry/AbstractRegistryInterceptor.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/services/registry/AbstractRegistryInterceptor.java	2008-08-04 11:55:23 UTC (rev 21337)
@@ -0,0 +1,59 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.soa.esb.services.registry;
+
+/**
+ * An abstract registry interceptor for managing the registry assignment.
+ * 
+ * @author <a href='mailto:Kevin.Conner at jboss.com'>Kevin Conner</a>
+ */
+public abstract class AbstractRegistryInterceptor implements RegistryInterceptor
+{
+    /**
+     * The next registry or interceptor in the chain.
+     */
+    private Registry registry ;
+    
+    /**
+     * Initialise the registry or interceptor that is next in the chain.
+     * @param registry The next entry in the chain or null if dismantling.
+     */
+    public synchronized void setRegistry(final Registry registry)
+    {
+        this.registry = registry ;
+    }
+    
+    /**
+     * Get the next registry or interceptor in the chain.
+     * @return The next registry or interceptor in the chain.
+     * @throws RegistryException If the chain has been dismantled.
+     */
+    protected synchronized Registry getRegistry()
+        throws RegistryException
+    {
+        if (registry == null)
+        {
+           throw new RegistryException("Registry has been reconfigured and is no longer valid") ;
+        }
+        return registry ;
+    }
+}


Property changes on: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/services/registry/AbstractRegistryInterceptor.java
___________________________________________________________________
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native

Modified: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/services/registry/RegistryFactory.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/services/registry/RegistryFactory.java	2008-08-04 10:31:05 UTC (rev 21336)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/services/registry/RegistryFactory.java	2008-08-04 11:55:23 UTC (rev 21337)
@@ -21,8 +21,11 @@
  */
 package org.jboss.soa.esb.services.registry;
 
+import java.util.List;
+
 import org.apache.log4j.Level;
 import org.apache.log4j.Logger;
+import org.jboss.soa.esb.addressing.EPR;
 import org.jboss.soa.esb.common.Configuration;
 import org.jboss.soa.esb.util.ClassUtil;
 
@@ -37,6 +40,14 @@
 	private static Logger logger = Logger.getLogger(RegistryFactory.class);
 
    private static Registry singleton;
+   /**
+    * The current registry implementation.
+    */
+   private static Registry currentRegistry ;
+   /**
+    * The interceptors applied to the registry.
+    */
+   private static RegistryInterceptor[] interceptors ;
 
    /**
     * Set the singleton. Any existing instance will be overwritten.
@@ -46,10 +57,11 @@
    
    public static synchronized void setRegistry(Registry registry)
    {
-      singleton = registry;
+      currentRegistry = registry;
+      singleton = configureInterceptors(registry) ;
    }
 
-   /**
+/**
     * Get the singleton.
     * 
     * @return the singleton or <code>null</code> if one has not been created.
@@ -71,8 +83,8 @@
         if (singleton != null) {
             return singleton;
         }
-
-        return createRegistry();
+        setRegistry(createRegistry());
+        return singleton ;
     }
 
     /**
@@ -85,8 +97,8 @@
     public static synchronized Registry createRegistry()
            throws RegistryException
    {
-        if (singleton != null)
-            return singleton;
+      if (currentRegistry != null)
+         return currentRegistry;
         
       Registry registry = null;
       String className = Configuration.getRegistryImplementationClass();
@@ -106,14 +118,142 @@
       }
       catch (Exception e)
       {
-         e.printStackTrace();
-
          throw new RegistryException("Invocation exception. "
                + e.getLocalizedMessage(), e);
       }
 
-      singleton = registry;
+      currentRegistry = registry;
       
       return registry;
    }
+   
+   /**
+    * Configure the interceptors around the registry
+    * @return The intercepted registry.
+    */
+   private static Registry configureInterceptors(final Registry registry)
+   {
+      if (interceptors != null)
+      {
+         final int numInterceptors = interceptors.length ;
+         for(int count = 0 ; count < numInterceptors ; count++)
+         {
+            interceptors[count].setRegistry(null) ;
+         }
+         interceptors = null ;
+      }
+      
+      if (registry == null)
+      {
+          return null ;
+      }
+      
+      final String registryInterceptorConfig = Configuration.getRegistryInterceptors() ;
+      final String[] registryInterceptorNames = (registryInterceptorConfig == null ? null : registryInterceptorConfig.split(",")) ;
+      final int numInterceptors = (registryInterceptorNames == null ? 0 : registryInterceptorNames.length) ;
+      final RegistryInterceptor[] registryInterceptors = new RegistryInterceptor[numInterceptors + 1] ;
+      
+      Registry current = registry ;
+      try
+      {
+          for(int count = numInterceptors ; count > 0 ; count--)
+          {
+              final Class interceptorClass ;
+              try
+              {
+                  interceptorClass = ClassUtil.forName(registryInterceptorNames[count-1].trim(), RegistryFactory.class) ;
+              }
+              catch (final ClassNotFoundException cnfe)
+              {
+                  throw new RegistryException("Failed to instantiate registry interceptor, disabling all interceptors", cnfe) ;
+              }
+              if (!RegistryInterceptor.class.isAssignableFrom(interceptorClass))
+              {
+                  throw new RegistryException("Registry interceptor does not implement RegistryInterceptor interface: " + interceptorClass.getName()) ;
+              }
+              final Object interceptor ;
+              try
+              {
+                  interceptor = interceptorClass.newInstance() ;
+              }
+              catch (final Throwable th)
+              {
+                  throw new RegistryException("Failed to instantiate registry interceptor", th) ;
+              }
+              final RegistryInterceptor registryInterceptor = (RegistryInterceptor)interceptor ;
+              registryInterceptor.setRegistry(current) ;
+              registryInterceptors[count] = registryInterceptor ;
+              current = registryInterceptor ;
+          }
+      }
+      catch (final RegistryException re)
+      {
+          for(int count = 1 ; count <= numInterceptors ; count++)
+          {
+              final RegistryInterceptor interceptor = registryInterceptors[count] ;
+              if (interceptor != null)
+              {
+                  interceptor.setRegistry(null) ;
+              }
+          }
+          logger.error("Failed to create registry interceptors, falling back to registry implementation", re) ;
+          return registry ;
+      }
+      final HeadRegistryInterceptor headInterceptor = new HeadRegistryInterceptor() ;
+      headInterceptor.setRegistry(current) ;
+      registryInterceptors[0] = headInterceptor ;
+      interceptors = registryInterceptors ;
+      return headInterceptor ;
+   }
+   
+   /**
+    * Registry Interceptor that throws an exception if a registry is used after it has been disabled.
+    * @author <a href='Kevin.Conner at jboss.com'>Kevin Conner</a>
+    */
+   private static final class HeadRegistryInterceptor extends AbstractRegistryInterceptor
+   {
+      public List<String> findAllServices() throws RegistryException
+      {
+         return getRegistry().findAllServices() ;
+      }
+
+      public EPR findEPR(final String serviceCategoryName, final String serviceName)
+         throws RegistryException, ServiceNotFoundException
+      {
+         return getRegistry().findEPR(serviceCategoryName, serviceName) ;
+      }
+
+      public List<EPR> findEPRs(final String serviceCategoryName, final String serviceName)
+         throws RegistryException, ServiceNotFoundException
+      {
+         return getRegistry().findEPRs(serviceCategoryName, serviceName) ;
+      }
+
+      public List<String> findServices(final String serviceCategoryName)
+         throws RegistryException
+      {
+         return getRegistry().findServices(serviceCategoryName) ;
+      }
+
+      public void registerEPR(final String serviceCategoryName, final String serviceName,
+         final String serviceDescription, final EPR epr, final String eprDescription)
+         throws RegistryException
+      {
+          getRegistry().registerEPR(serviceCategoryName, serviceName,
+            serviceDescription, epr, eprDescription) ;
+      }
+
+      public void unRegisterEPR(final String serviceCategoryName, final String serviceName,
+         final EPR epr)
+         throws RegistryException, ServiceNotFoundException
+      {
+          getRegistry().unRegisterEPR(serviceCategoryName, serviceName, epr) ;
+      }
+
+      public void unRegisterService(final String category, final String serviceName)
+         throws RegistryException, ServiceNotFoundException
+      {
+          getRegistry().unRegisterService(category, serviceName) ;
+      }
+   }
 }

Added: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/services/registry/RegistryInterceptor.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/services/registry/RegistryInterceptor.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/services/registry/RegistryInterceptor.java	2008-08-04 11:55:23 UTC (rev 21337)
@@ -0,0 +1,38 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.soa.esb.services.registry;
+
+/**
+ * Interface implemented by interceptors added to the underlying registry.
+ * 
+ * These interceptors will provide additional functionality such as caching, InVm etc.
+ *
+ * @author <a href='mailto:Kevin.Conner at jboss.com'>Kevin Conner</a>
+ */
+public interface RegistryInterceptor extends Registry 
+{
+    /**
+     * Initialise the registry or interceptor that is next in the chain.
+     * @param registry The next entry in the chain or null if dismantling.
+     */
+    public void setRegistry(final Registry registry) ;
+}


Property changes on: labs/jbossesb/trunk/product/rosetta/src/org/jboss/soa/esb/services/registry/RegistryInterceptor.java
___________________________________________________________________
Name: svn:keywords
   + Rev Date
Name: svn:eol-style
   + native

Copied: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/services/registry/InVMRegistryInterceptorUnitTest.java (from rev 21320, labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/services/registry/InVMRegistryUnitTest.java)
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/services/registry/InVMRegistryInterceptorUnitTest.java	                        (rev 0)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/services/registry/InVMRegistryInterceptorUnitTest.java	2008-08-04 11:55:23 UTC (rev 21337)
@@ -0,0 +1,71 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2006, JBoss Inc., and others contributors as indicated
+ * by the @authors tag. All rights reserved.
+ * See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ * This copyrighted material is made available to anyone wishing to use,
+ * modify, copy, or redistribute it subject to the terms and conditions
+ * of the GNU Lesser General Public License, v. 2.1.
+ * This program is distributed in the hope that it will be useful, but WITHOUT A
+ * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+ * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
+ * You should have received a copy of the GNU Lesser General Public License,
+ * v.2.1 along with this distribution; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
+ * MA  02110-1301, USA.
+ *
+ * (C) 2005-2006, JBoss Inc.
+ */
+package org.jboss.internal.soa.esb.services.registry;
+
+import junit.framework.TestCase;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.addressing.eprs.InVMEpr;
+import org.jboss.soa.esb.services.registry.RegistryException;
+import org.jboss.soa.esb.services.registry.ServiceNotFoundException;
+
+import java.net.URI;
+
+/**
+ * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
+ */
+public class InVMRegistryInterceptorUnitTest extends TestCase {
+
+    public void test() throws ServiceNotFoundException, RegistryException {
+        InVMRegistryInterceptor reg = new InVMRegistryInterceptor();
+        reg.setRegistry(new MockRegistry()) ;
+
+        try {
+            reg.findEPR("x", "y");
+            fail("Expected ServiceNotFoundException") ;
+        } catch (final ServiceNotFoundException snfe) {
+        }
+
+        reg.registerEPR("x", "y", "blah", new InVMEpr(new EPR(URI.create("x://123"))), "blah");
+        assertEquals(1, reg.findEPRs("x", "y").size());
+        assertEquals("x://123", reg.findEPR("x", "y").getAddr().getAddress());
+
+        reg.registerEPR("x", "y", "blah", new InVMEpr(new EPR(URI.create("x://1234"))), "blah");
+        assertEquals(2, reg.findEPRs("x", "y").size());
+
+        reg.registerEPR("a", "z", "blah", new InVMEpr(new EPR(URI.create("x://12345"))), "blah");
+        assertEquals(2, reg.findEPRs("x", "y").size());
+        assertEquals(1, reg.findEPRs("a", "z").size());
+
+        assertEquals(2, reg.findAllServices().size());
+        assertEquals(1, reg.findServices("x").size());
+
+        // unreg using a valid service, but unregistred EPR... make sure nothing changes...
+        reg.unRegisterEPR("a", "z", new InVMEpr(new EPR(URI.create("x://1"))));
+        assertEquals(1, reg.findEPRs("a", "z").size());
+        // unreg using a valid service + registred EPR... make sure EPR is removed...
+        reg.unRegisterEPR("a", "z", new InVMEpr(new EPR(URI.create("x://12345"))));
+        assertEquals(0, reg.findEPRs("a", "z").size());
+
+        // unreg all for the service
+        assertEquals(2, reg.findEPRs("x", "y").size());
+        reg.unRegisterService("x", "y");
+        assertEquals(0, reg.findEPRs("x", "y").size());
+    }
+}

Deleted: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/services/registry/InVMRegistryUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/services/registry/InVMRegistryUnitTest.java	2008-08-04 10:31:05 UTC (rev 21336)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/services/registry/InVMRegistryUnitTest.java	2008-08-04 11:55:23 UTC (rev 21337)
@@ -1,65 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source
- * Copyright 2006, JBoss Inc., and others contributors as indicated
- * by the @authors tag. All rights reserved.
- * See the copyright.txt in the distribution for a
- * full listing of individual contributors.
- * This copyrighted material is made available to anyone wishing to use,
- * modify, copy, or redistribute it subject to the terms and conditions
- * of the GNU Lesser General Public License, v. 2.1.
- * This program is distributed in the hope that it will be useful, but WITHOUT A
- * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
- * PARTICULAR PURPOSE.  See the GNU Lesser General Public License for more details.
- * You should have received a copy of the GNU Lesser General Public License,
- * v.2.1 along with this distribution; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
- * MA  02110-1301, USA.
- *
- * (C) 2005-2006, JBoss Inc.
- */
-package org.jboss.internal.soa.esb.services.registry;
-
-import junit.framework.TestCase;
-import org.jboss.soa.esb.addressing.EPR;
-import org.jboss.soa.esb.services.registry.RegistryException;
-import org.jboss.soa.esb.services.registry.ServiceNotFoundException;
-
-import java.net.URI;
-
-/**
- * @author <a href="mailto:tom.fennelly at jboss.com">tom.fennelly at jboss.com</a>
- */
-public class InVMRegistryUnitTest extends TestCase {
-
-    public void test() throws ServiceNotFoundException, RegistryException {
-        InVMRegistry reg = new InVMRegistry();
-
-        assertNull(reg.findEPR("x", "y"));
-
-        reg.registerEPR("x", "y", "blah", new EPR(URI.create("x://123")), "blah");
-        assertEquals(1, reg.findEPRs("x", "y").size());
-        assertEquals("x://123", reg.findEPR("x", "y").getAddr().getAddress());
-
-        reg.registerEPR("x", "y", "blah", new EPR(URI.create("x://1234")), "blah");
-        assertEquals(2, reg.findEPRs("x", "y").size());
-
-        reg.registerEPR("a", "z", "blah", new EPR(URI.create("x://12345")), "blah");
-        assertEquals(2, reg.findEPRs("x", "y").size());
-        assertEquals(1, reg.findEPRs("a", "z").size());
-
-        assertEquals(2, reg.findAllServices().size());
-        assertEquals(1, reg.findServices("x").size());
-
-        // unreg using a valid service, but unregistred EPR... make sure nothing changes...
-        reg.unRegisterEPR("a", "z", new EPR(URI.create("x://1")));
-        assertEquals(1, reg.findEPRs("a", "z").size());
-        // unreg using a valid service + registred EPR... make sure EPR is removed...
-        reg.unRegisterEPR("a", "z", new EPR(URI.create("x://12345")));
-        assertEquals(0, reg.findEPRs("a", "z").size());
-
-        // unreg all for the service
-        assertEquals(2, reg.findEPRs("x", "y").size());
-        reg.unRegisterService("x", "y");
-        assertEquals(0, reg.findEPRs("x", "y").size());
-    }
-}

Modified: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/services/registry/MockRegistry.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/services/registry/MockRegistry.java	2008-08-04 10:31:05 UTC (rev 21336)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/services/registry/MockRegistry.java	2008-08-04 11:55:23 UTC (rev 21337)
@@ -33,6 +33,7 @@
 import org.jboss.soa.esb.common.ModulePropertyManager;
 import org.jboss.soa.esb.services.registry.Registry;
 import org.jboss.soa.esb.services.registry.RegistryException;
+import org.jboss.soa.esb.services.registry.ServiceNotFoundException;
 
 import com.arjuna.common.util.propertyservice.PropertyManager;
 
@@ -132,18 +133,18 @@
     /* (non-Javadoc)
       * @see org.jboss.soa.esb.services.registry.Registry#unRegisterService(java.lang.String, java.lang.String)
       */
-    public void unRegisterService(String category, String serviceName) throws RegistryException {
+    public void unRegisterService(String category, String serviceName) throws RegistryException, ServiceNotFoundException {
         unRegisterEPR(category, serviceName, null);
     }
 
     /* (non-Javadoc)
       * @see org.jboss.soa.esb.services.registry.Registry#unRegisterEPR(java.lang.String, java.lang.String, org.jboss.soa.esb.addressing.EPR)
       */
-    public void unRegisterEPR(String serviceCategoryName, String serviceName, EPR epr) throws RegistryException {
+    public void unRegisterEPR(String serviceCategoryName, String serviceName, EPR epr) throws RegistryException, ServiceNotFoundException {
         int indexOf = repository.indexOf(new RepositoryEntry(serviceCategoryName, serviceName, null, epr, null));
 
         if (indexOf == -1) {
-            throw new RegistryException("Registry entry [" + serviceCategoryName + "][" + serviceName + "] not found.");
+            throw new ServiceNotFoundException("Registry entry [" + serviceCategoryName + "][" + serviceName + "] not found.");
         }
         repository.remove(indexOf);
     }
@@ -191,13 +192,13 @@
       * @see org.jboss.soa.esb.services.registry.Registry#findEPR(java.lang.String, java.lang.String)
       */
     public EPR findEPR(String serviceCategoryName, String serviceName)
-            throws RegistryException {
+            throws RegistryException, ServiceNotFoundException {
         for (RepositoryEntry entry : repository) {
             if (serviceCategoryName.equals(entry.serviceCategoryName) && serviceName.equals(entry.serviceName)) {
                 return entry.epr;
             }
         }
-        return null;
+        throw new ServiceNotFoundException("Registry entry [" + serviceCategoryName + "][" + serviceName + "] not found.");
     }
 
     public static class RepositoryEntry {

Modified: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/services/registry/MockRegistryUnitTest.java
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/services/registry/MockRegistryUnitTest.java	2008-08-04 10:31:05 UTC (rev 21336)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/internal/soa/esb/services/registry/MockRegistryUnitTest.java	2008-08-04 11:55:23 UTC (rev 21337)
@@ -28,9 +28,8 @@
 
 import org.jboss.soa.esb.addressing.EPR;
 import org.jboss.soa.esb.common.Environment;
-import org.jboss.soa.esb.services.registry.Registry;
 import org.jboss.soa.esb.services.registry.RegistryException;
-import org.jboss.soa.esb.services.registry.RegistryFactory;
+import org.jboss.soa.esb.services.registry.ServiceNotFoundException;
 
 /**
  * MockRegistry Unit Test.
@@ -43,14 +42,12 @@
 		
 		MockRegistry.install();
 		assertEquals(MockRegistry.class.getName(), MockRegistry.regPropManager.getProperty(Environment.REGISTRY_IMPEMENTATION_CLASS));
-		Registry registry = RegistryFactory.getRegistry();
-		assertTrue(registry instanceof MockRegistry);
 		
 		MockRegistry.uninstall();
 		assertNotSame(MockRegistry.class.getName(), MockRegistry.regPropManager.getProperty(Environment.REGISTRY_IMPEMENTATION_CLASS));
 	}
 
-	public void test_features() throws RegistryException {
+	public void test_features() throws RegistryException, ServiceNotFoundException {
 		MockRegistry registry = new MockRegistry();
 		EPR epr = new EPR();
 		List<String> services = new ArrayList<String>();
@@ -81,7 +78,7 @@
 		try {
 			registry.unRegisterService("cat2", "cat1-service2");
 			fail("Expected RegistryException for unknown service.");
-		} catch(RegistryException e) {
+		} catch(ServiceNotFoundException e) {
 			//OK
 		}
 		

Modified: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/jbossesb-properties-01.xml
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/jbossesb-properties-01.xml	2008-08-04 10:31:05 UTC (rev 21336)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/listeners/jbossesb-properties-01.xml	2008-08-04 11:55:23 UTC (rev 21337)
@@ -46,6 +46,12 @@
     	<property name="org.jboss.soa.esb.registry.password" value="password"/>
     	<!-- the following parameter is scout specific to set the type of communication between scout and the UDDI (embedded, rmi, soap) -->
     	<property name="org.jboss.soa.esb.scout.proxy.transportClass" value="org.apache.ws.scout.transport.LocalTransport"/>
+        <!-- specify the interceptors, in order -->
+        <property name="org.jboss.soa.esb.registry.interceptors"
+                value="org.jboss.internal.soa.esb.services.registry.InVMRegistryInterceptor, org.jboss.internal.soa.esb.services.registry.CachingRegistryInterceptor"/>
+        <!-- The following properties modify the cache interceptor behaviour -->
+        <property name="org.jboss.soa.esb.registry.cache.maxSize" value="100"/>
+        <property name="org.jboss.soa.esb.registry.cache.validityPeriod" value="600000"/>
     </properties>
     <properties name="transports" depends="core">
     	<property name="org.jboss.soa.esb.mail.smtp.host" value="localhost"/>

Modified: labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/jbossesb-properties.xml
===================================================================
--- labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/jbossesb-properties.xml	2008-08-04 10:31:05 UTC (rev 21336)
+++ labs/jbossesb/trunk/product/rosetta/tests/src/org/jboss/soa/esb/testutils/jbossesb-properties.xml	2008-08-04 11:55:23 UTC (rev 21337)
@@ -46,6 +46,12 @@
     	<property name="org.jboss.soa.esb.registry.password" value="password"/>
     	<!-- the following parameter is scout specific to set the type of communication between scout and the UDDI (embedded, rmi, soap) -->
     	<property name="org.jboss.soa.esb.scout.proxy.transportClass" value="org.apache.ws.scout.transport.LocalTransport"/>
+        <!-- specify the interceptors, in order -->
+        <property name="org.jboss.soa.esb.registry.interceptors"
+                value="org.jboss.internal.soa.esb.services.registry.InVMRegistryInterceptor, org.jboss.internal.soa.esb.services.registry.CachingRegistryInterceptor"/>
+        <!-- The following properties modify the cache interceptor behaviour -->
+        <property name="org.jboss.soa.esb.registry.cache.maxSize" value="100"/>
+        <property name="org.jboss.soa.esb.registry.cache.validityPeriod" value="600000"/>
     </properties>
     <properties name="transports" depends="core">
     	<property name="org.jboss.soa.esb.mail.smtp.host" value="localhost"/>

Modified: labs/jbossesb/trunk/product/services/smooks/src/test/java/org/jboss/soa/esb/smooks/jbossesb-properties.xml
===================================================================
--- labs/jbossesb/trunk/product/services/smooks/src/test/java/org/jboss/soa/esb/smooks/jbossesb-properties.xml	2008-08-04 10:31:05 UTC (rev 21336)
+++ labs/jbossesb/trunk/product/services/smooks/src/test/java/org/jboss/soa/esb/smooks/jbossesb-properties.xml	2008-08-04 11:55:23 UTC (rev 21337)
@@ -46,6 +46,12 @@
     	<property name="org.jboss.soa.esb.registry.password" value="password"/>
     	<!-- the following parameter is scout specific to set the type of communication between scout and the UDDI (embedded, rmi, soap) -->
     	<property name="org.jboss.soa.esb.scout.proxy.transportClass" value="org.apache.ws.scout.transport.LocalTransport"/>
+        <!-- specify the interceptors, in order -->
+        <property name="org.jboss.soa.esb.registry.interceptors"
+                value="org.jboss.internal.soa.esb.services.registry.InVMRegistryInterceptor, org.jboss.internal.soa.esb.services.registry.CachingRegistryInterceptor"/>
+        <!-- The following properties modify the cache interceptor behaviour -->
+        <property name="org.jboss.soa.esb.registry.cache.maxSize" value="100"/>
+        <property name="org.jboss.soa.esb.registry.cache.validityPeriod" value="600000"/>
     </properties>
     <properties name="transports" depends="core">
     	<property name="org.jboss.soa.esb.mail.smtp.host" value="localhost"/>

Modified: labs/jbossesb/trunk/qa/junit/resources/server/jbossesb-properties.xml
===================================================================
--- labs/jbossesb/trunk/qa/junit/resources/server/jbossesb-properties.xml	2008-08-04 10:31:05 UTC (rev 21336)
+++ labs/jbossesb/trunk/qa/junit/resources/server/jbossesb-properties.xml	2008-08-04 11:55:23 UTC (rev 21337)
@@ -51,6 +51,12 @@
     	<!-- the following parameter is scout specific to set the type of communication between scout and the UDDI (embedded, rmi, soap) -->
     	<property name="org.jboss.soa.esb.scout.proxy.transportClass" 
     		value="org.apache.ws.scout.transport.RMITransport"/>
+        <!-- specify the interceptors, in order -->
+        <property name="org.jboss.soa.esb.registry.interceptors"
+                value="org.jboss.internal.soa.esb.services.registry.InVMRegistryInterceptor, org.jboss.internal.soa.esb.services.registry.CachingRegistryInterceptor"/>
+        <!-- The following properties modify the cache interceptor behaviour -->
+        <property name="org.jboss.soa.esb.registry.cache.maxSize" value="100"/>
+        <property name="org.jboss.soa.esb.registry.cache.validityPeriod" value="600000"/>
     </properties>
     <properties name="transports" depends="core">
     	<property name="org.jboss.soa.esb.mail.smtp.host" value="localhost"/>




More information about the jboss-svn-commits mailing list