[teiid-commits] teiid SVN: r960 - in trunk: server/src/main/java/com/metamatrix/common/messaging/jgroups and 7 other directories.

teiid-commits at lists.jboss.org teiid-commits at lists.jboss.org
Sun May 17 07:59:59 EDT 2009


Author: shawkins
Date: 2009-05-17 07:59:58 -0400 (Sun, 17 May 2009)
New Revision: 960

Added:
   trunk/server/src/main/java/com/metamatrix/platform/registry/RegistryBinding.java
   trunk/server/src/main/java/com/metamatrix/platform/service/controller/ServiceData.java
Modified:
   trunk/common-internal/src/main/java/com/metamatrix/platform/admin/api/runtime/ServiceData.java
   trunk/server/src/main/java/com/metamatrix/common/messaging/jgroups/JGroupsMessageBus.java
   trunk/server/src/main/java/com/metamatrix/common/messaging/jgroups/RemoteProxy.java
   trunk/server/src/main/java/com/metamatrix/platform/registry/ClusteredRegistryState.java
   trunk/server/src/main/java/com/metamatrix/platform/registry/HostControllerRegistryBinding.java
   trunk/server/src/main/java/com/metamatrix/platform/registry/ProcessMonitor.java
   trunk/server/src/main/java/com/metamatrix/platform/registry/ProcessRegistryBinding.java
   trunk/server/src/main/java/com/metamatrix/platform/registry/ServiceRegistryBinding.java
   trunk/server/src/main/java/com/metamatrix/platform/service/api/ServiceInterface.java
   trunk/server/src/main/java/com/metamatrix/platform/service/controller/AbstractService.java
   trunk/server/src/main/java/com/metamatrix/platform/vm/controller/ProcessController.java
   trunk/server/src/test/java/com/metamatrix/admin/server/FakeCacheAdmin.java
   trunk/server/src/test/java/com/metamatrix/admin/server/FakeConfigurationService.java
   trunk/server/src/test/java/com/metamatrix/admin/server/FakeQueryService.java
   trunk/server/src/test/java/com/metamatrix/admin/server/FakeServerSessionService.java
   trunk/server/src/test/java/com/metamatrix/admin/server/TestServerMonitoringAdminImpl.java
   trunk/server/src/test/java/com/metamatrix/platform/registry/FakeRegistryUtil.java
   trunk/server/src/test/java/com/metamatrix/platform/registry/TestServiceRegistryBinding.java
   trunk/server/src/test/java/com/metamatrix/platform/service/controller/FakeService.java
Log:
TEIID-601 various fixes for better behavior when a process is killed

Modified: trunk/common-internal/src/main/java/com/metamatrix/platform/admin/api/runtime/ServiceData.java
===================================================================
--- trunk/common-internal/src/main/java/com/metamatrix/platform/admin/api/runtime/ServiceData.java	2009-05-17 00:02:22 UTC (rev 959)
+++ trunk/common-internal/src/main/java/com/metamatrix/platform/admin/api/runtime/ServiceData.java	2009-05-17 11:59:58 UTC (rev 960)
@@ -25,6 +25,7 @@
 import java.util.Collection;
 import java.util.Date;
 
+import com.metamatrix.api.exception.ExceptionHolder;
 import com.metamatrix.common.config.api.ComponentDefnID;
 import com.metamatrix.platform.service.api.ServiceID;
 
@@ -57,7 +58,7 @@
     private Collection queueNames;
     
     /** initialization Exception */
-    private Throwable initError;
+    private ExceptionHolder initError;
 
     /**
      * Create new ServiceRegistryInstance
@@ -91,7 +92,9 @@
         this.currentState = state;
         this.stateChangeTime = time;
         this.essential = essential;
-        this.initError = initError;
+        if (initError != null) {
+        	this.initError = new ExceptionHolder(initError);
+        }
         computeHashCode();
     }
 
@@ -128,7 +131,10 @@
     }
     
     public Throwable getInitError() {
-        return this.initError;
+    	if (this.initError != null) {
+    		return this.initError.getException();
+    	}
+        return null;
     }
     
     public boolean isEssential() {

Modified: trunk/server/src/main/java/com/metamatrix/common/messaging/jgroups/JGroupsMessageBus.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/messaging/jgroups/JGroupsMessageBus.java	2009-05-17 00:02:22 UTC (rev 959)
+++ trunk/server/src/main/java/com/metamatrix/common/messaging/jgroups/JGroupsMessageBus.java	2009-05-17 11:59:58 UTC (rev 960)
@@ -145,7 +145,11 @@
 					throw new RemoteMessagingException(PlatformPlugin.Util.getString("JGroupsMessageBus.noResponse")); //$NON-NLS-1$
 				}
 	
-				return rsp_list.getFirst();
+				Object result = rsp_list.getFirst();
+				if (result instanceof Throwable) {
+					throw (Throwable)result;
+				}
+				return result;
 			}
 		});
 	}

Modified: trunk/server/src/main/java/com/metamatrix/common/messaging/jgroups/RemoteProxy.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/common/messaging/jgroups/RemoteProxy.java	2009-05-17 00:02:22 UTC (rev 959)
+++ trunk/server/src/main/java/com/metamatrix/common/messaging/jgroups/RemoteProxy.java	2009-05-17 11:59:58 UTC (rev 960)
@@ -54,9 +54,9 @@
 					throw e.getTargetException();
 				}
 			}
-			throw new ServiceNotFoundException();
+			throw new ServiceNotFoundException(PlatformPlugin.Util.getString("RemoteProxy.localCallFailed", methodName, classId)); //$NON-NLS-1$
 		} catch (Throwable t) {
-			LogManager.logWarning(LogCommonConstants.CTX_PROXY, t, PlatformPlugin.Util.getString("RemoteProxy.localCallFailed", methodName, classId));
+			LogManager.logWarning(LogCommonConstants.CTX_PROXY, t, PlatformPlugin.Util.getString("RemoteProxy.localCallFailed", methodName, classId)); //$NON-NLS-1$
 			throw t;
 		}
 	}		

Modified: trunk/server/src/main/java/com/metamatrix/platform/registry/ClusteredRegistryState.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/registry/ClusteredRegistryState.java	2009-05-17 00:02:22 UTC (rev 959)
+++ trunk/server/src/main/java/com/metamatrix/platform/registry/ClusteredRegistryState.java	2009-05-17 11:59:58 UTC (rev 960)
@@ -65,6 +65,7 @@
 	
 	private Cache addProcessNode(String hostName, String processName) throws CacheNodeNotFoundException {
 		Cache hostNode = getHostNode(hostName);
+		hostNode.removeChild(processName.toUpperCase());
 		Cache n =  hostNode.addChild(processName.toUpperCase());
 		n.put(NAME, processName);
 		return n;

Modified: trunk/server/src/main/java/com/metamatrix/platform/registry/HostControllerRegistryBinding.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/registry/HostControllerRegistryBinding.java	2009-05-17 00:02:22 UTC (rev 959)
+++ trunk/server/src/main/java/com/metamatrix/platform/registry/HostControllerRegistryBinding.java	2009-05-17 11:59:58 UTC (rev 960)
@@ -1,66 +1,35 @@
 package com.metamatrix.platform.registry;
 
-import java.io.Serializable;
 import java.util.Properties;
 
 import com.metamatrix.common.messaging.MessageBus;
 import com.metamatrix.server.HostManagement;
-import com.metamatrix.server.ResourceFinder;
 
-public class HostControllerRegistryBinding implements Serializable {
+public class HostControllerRegistryBinding extends RegistryBinding<HostManagement> {
 
-	private transient HostManagement hostController;
-    private transient MessageBus messageBus;
-    
-    /** remote reference */
-    private Object hostControllerStub;    
-    
-    private String hostName;
-    
     private Properties hostProperties;
     
-    
     public HostControllerRegistryBinding(String hostName, Properties properties, HostManagement controller, MessageBus bus) {
-    	this.messageBus = bus;	
-    	this.hostName = hostName;
+    	super(controller, hostName, bus);
     	this.hostProperties = properties;
-    	setHostController(controller);
     }
     
-    public String getHostName() {
-    	return this.hostName;
-    }
-    
-	private synchronized void setHostController(HostManagement controller) {
-		this.hostController = controller;
-    	if (this.hostControllerStub != null) {
-    		this.messageBus.unExport(hostControllerStub);
-    		hostControllerStub = null;
-    	}
-        if (controller != null) {
-            this.hostControllerStub = this.messageBus.export(controller, controller.getClass().getInterfaces());
-		}
-	}    
-	
-    public synchronized HostManagement getHostController() {
-    	if (this.hostController != null) {
-    		return hostController;
-    	}
-    	if (this.hostControllerStub == null) {
+    @Override
+    public synchronized HostManagement getBindObject() {
+    	HostManagement bindObject = super.getBindObject();
+    	if (bindObject == null) {
     		throw new IllegalStateException("Cannot locate host controller.  It may need to be started or restarted if jgroups properties have changed"); //$NON-NLS-1$
     	}
-    	// when exported to the remote, use remote's message bus instance.
-    	MessageBus bus = this.messageBus;
-    	if(bus == null) {
-    		bus = ResourceFinder.getMessageBus();
-    	}
-    	this.hostController = (HostManagement)bus.getRPCProxy(this.hostControllerStub);
-    	return this.hostController;
-    }	
-    
+    	return bindObject;
+    }
+        
     public Properties getProperties() {
     	Properties p =  new Properties();
     	p.putAll(this.hostProperties);
     	return p;
     }
+    
+    public HostManagement getHostController() {
+    	return getBindObject();
+    }
 }

Modified: trunk/server/src/main/java/com/metamatrix/platform/registry/ProcessMonitor.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/registry/ProcessMonitor.java	2009-05-17 00:02:22 UTC (rev 959)
+++ trunk/server/src/main/java/com/metamatrix/platform/registry/ProcessMonitor.java	2009-05-17 11:59:58 UTC (rev 960)
@@ -30,13 +30,12 @@
 import com.google.inject.Singleton;
 import com.google.inject.name.Named;
 import com.metamatrix.common.log.LogManager;
+import com.metamatrix.common.messaging.RemoteMessagingException;
 import com.metamatrix.common.util.LogCommonConstants;
 import com.metamatrix.core.MetaMatrixRuntimeException;
 import com.metamatrix.platform.registry.ClusteredRegistryState.CacheNodeNotFoundException;
 import com.metamatrix.platform.service.api.ServiceID;
-import com.metamatrix.platform.service.api.ServiceInterface;
 import com.metamatrix.platform.service.api.exception.ServiceException;
-import com.metamatrix.platform.service.api.exception.ServiceStateException;
 import com.metamatrix.platform.vm.api.controller.ProcessManagement;
 import com.metamatrix.platform.vm.controller.ServerEvents;
 import com.metamatrix.server.Configuration;
@@ -91,20 +90,15 @@
 
     			for (ProcessRegistryBinding binding: vmBindings) {
                     ProcessManagement vm = binding.getProcessController();
-                    boolean alive = binding.isAlive();
-	                
                     try {
 	                    vm.ping();
 	                    binding.setAlive(true);
 	                } catch (ServiceException e) {
 	                	// mark as not alive, then no services will be pinged from this vm
 	                	binding.setAlive(false);
+	                } catch (RemoteMessagingException e) {
+	                	binding.setAlive(false);
 	                }
-	                
-	                // if the vmstate changed then, update the registry.
-	                if (alive != binding.isAlive()) {
-	                	processUpdated(binding);
-	                }
 	            }
     		}
     	}, POLLING_INTERVAL_DEFAULT, POLLING_INTERVAL_DEFAULT);
@@ -117,16 +111,8 @@
         		List<ServiceRegistryBinding> bindings = registry.getServiceBindings(hostName, processName);
                 for (ServiceRegistryBinding binding:bindings) {
 
-                	ServiceInterface si = binding.getService();
-                	try {
-            			// when service in stopped state; this will be null
-            			// if shut down there will not be a binding for it.
-            			if(si != null) {
-            				binding.getService().checkState();
-            			}
-    				} catch (ServiceStateException e) {
-    					// OK to throw up, service will capture the error to logs.
-    				}
+    				// the state of the service changed, then update the cache.
+    				binding.checkState();
     				
     				// the state of the service changed, then update the cache.
     				if (binding.isDirty()) {

Modified: trunk/server/src/main/java/com/metamatrix/platform/registry/ProcessRegistryBinding.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/registry/ProcessRegistryBinding.java	2009-05-17 00:02:22 UTC (rev 959)
+++ trunk/server/src/main/java/com/metamatrix/platform/registry/ProcessRegistryBinding.java	2009-05-17 11:59:58 UTC (rev 960)
@@ -22,93 +22,35 @@
 
 package com.metamatrix.platform.registry;
 
-import java.io.Serializable;
-
 import com.metamatrix.common.config.api.VMComponentDefn;
 import com.metamatrix.common.messaging.MessageBus;
 import com.metamatrix.platform.vm.api.controller.ProcessManagement;
-import com.metamatrix.server.ResourceFinder;
 
 /**
  * This class is a container for ServiceRegistryBinding objects for
  * all the services running in this VM
  */
-public class ProcessRegistryBinding implements Serializable {
+public class ProcessRegistryBinding extends RegistryBinding<ProcessManagement> {
 
-    /** Host that this VM belongs to. */
-    private String hostName;
-
     /** Name of vm */
     private String processName;
     
     private boolean alive;
     
-    private long startTime = System.currentTimeMillis();
-
-    /**
-     * Local reference to VMController, this is transient to prevent it from
-     * being sent to other vm's. Remote vm's must use the stub to access vmController
-     */
-    private transient ProcessManagement processController;
-
-    /** Remote reference to VMController */
-    private Object vmControllerStub;
-
     /** defines vm in configuration */
     // TODO: this is part of configuration, this should be removed from here..
     private VMComponentDefn vmComponent;
-
-    private transient MessageBus messageBus;
     
     public ProcessRegistryBinding(String hostName, String processName, VMComponentDefn deployedComponent, ProcessManagement vmController, MessageBus bus) {
-    	this.hostName = hostName;
+    	super(vmController, hostName, bus);
     	this.processName = processName;
         this.vmComponent = deployedComponent;
-        this.processController = vmController;
-        this.messageBus = bus;
-        this.vmControllerStub = getStub(vmController);
     }
 
-    private Object getStub(ProcessManagement controller) {
-        if (controller == null) {
-            return null;
-        }
-        return this.messageBus.export(controller, new Class[] {ProcessManagement.class});
-    }
-
-    /**
-     * Return reference for VMController.
-     * If VMController is running in this VM then return local reference.
-     * Else return remote reference.
-     *
-     * @return VMController reference
-     */
-    public synchronized ProcessManagement getProcessController() {
-
-        // if vmController is null then this must be a remote vm so return the stub.
-        if (this.processController != null) {
-            return processController;
-        }
-        if (this.vmControllerStub == null) {
-        	return null;
-        }
-    	// when exported to the remote, use remote's message bus instance.
-    	MessageBus bus = this.messageBus;
-    	if(bus == null) {
-    		bus = ResourceFinder.getMessageBus();
-    	}        
-        processController = (ProcessManagement)bus.getRPCProxy(this.vmControllerStub);
-        return processController;
-    }
-
     public VMComponentDefn getDeployedComponent() {
        return this.vmComponent;
     }
 
-    public String getHostName() {
-    	return hostName;
-    }
-
     public String getProcessName() {
     	return processName;
     }
@@ -126,15 +68,11 @@
     }
 
     public String toString() {
-        return "Process<" +this.hostName+"|"+ this.processName + ">"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+        return "Process<" +this.getHostName()+"|"+ this.processName + ">"; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
     }
     
-    public long getStartTime() {
-		return startTime;
-	}
-    
-    public void setStartTime(long startTime) {
-		this.startTime = startTime;
-	}
+    public ProcessManagement getProcessController() {
+    	return getBindObject();
+    }
 }
 

Added: trunk/server/src/main/java/com/metamatrix/platform/registry/RegistryBinding.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/registry/RegistryBinding.java	                        (rev 0)
+++ trunk/server/src/main/java/com/metamatrix/platform/registry/RegistryBinding.java	2009-05-17 11:59:58 UTC (rev 960)
@@ -0,0 +1,97 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library 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 library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.platform.registry;
+
+import java.io.Serializable;
+
+import com.metamatrix.common.messaging.MessageBus;
+import com.metamatrix.server.ResourceFinder;
+
+/**
+ * This class is a container for ServiceRegistryBinding objects for
+ * all the services running in this VM
+ */
+public class RegistryBinding<T> implements Serializable {
+
+    private String hostName;
+    private long startTime = System.currentTimeMillis();
+    private Object stub;
+    private transient boolean local;
+    private transient T bindObject;
+    private transient MessageBus messageBus;
+    
+    public RegistryBinding(T bindObject, String hostName,
+			MessageBus messageBus) {
+		this.bindObject = bindObject;
+    	this.hostName = hostName;
+		this.messageBus = messageBus;
+		if (this.bindObject != null) {
+			this.stub = this.messageBus.export(this.bindObject, this.bindObject.getClass().getInterfaces());
+		}
+		this.local = true;
+	}
+
+    public synchronized T getBindObject() {
+    	if (this.bindObject != null) {
+    		return bindObject;
+    	}
+    	if (this.stub == null) {
+    		return null;
+    	}
+    	// when exported to the remote, use remote's message bus instance.
+    	this.bindObject = (T)this.getMessageBus().getRPCProxy(this.stub);
+    	return this.bindObject;
+    }
+    
+    public synchronized void invalidateBindObject() {
+		this.bindObject = null;
+    	if (this.stub != null) {
+    		this.getMessageBus().unExport(stub);
+    		this.stub = null;
+    	}
+    }
+
+    public String getHostName() {
+    	return hostName;
+    }
+
+    public long getStartTime() {
+		return startTime;
+	}
+    
+    public void setStartTime(long startTime) {
+		this.startTime = startTime;
+	}
+    
+    public boolean isLocal() {
+		return local;
+	}
+
+	private MessageBus getMessageBus() {
+		if (this.messageBus == null) {
+			this.messageBus = ResourceFinder.getMessageBus();
+		}
+		return messageBus;
+	}
+}
+


Property changes on: trunk/server/src/main/java/com/metamatrix/platform/registry/RegistryBinding.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: trunk/server/src/main/java/com/metamatrix/platform/registry/ServiceRegistryBinding.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/registry/ServiceRegistryBinding.java	2009-05-17 00:02:22 UTC (rev 959)
+++ trunk/server/src/main/java/com/metamatrix/platform/registry/ServiceRegistryBinding.java	2009-05-17 11:59:58 UTC (rev 960)
@@ -22,7 +22,6 @@
 
 package com.metamatrix.platform.registry;
 
-import java.io.Serializable;
 import java.lang.reflect.InvocationHandler;
 import java.lang.reflect.InvocationTargetException;
 import java.lang.reflect.Method;
@@ -35,17 +34,21 @@
 import com.metamatrix.common.config.api.DeployedComponent;
 import com.metamatrix.common.messaging.MessageBus;
 import com.metamatrix.common.queue.WorkerPoolStats;
+import com.metamatrix.platform.service.ServiceMessages;
+import com.metamatrix.platform.service.ServicePlugin;
 import com.metamatrix.platform.service.api.ServiceID;
 import com.metamatrix.platform.service.api.ServiceInterface;
 import com.metamatrix.platform.service.api.ServiceState;
-import com.metamatrix.server.ResourceFinder;
+import com.metamatrix.platform.service.api.exception.ServiceException;
+import com.metamatrix.platform.service.api.exception.ServiceStateException;
+import com.metamatrix.platform.service.controller.ServiceData;
 
-public class ServiceRegistryBinding implements Serializable {
+public class ServiceRegistryBinding extends RegistryBinding<ServiceInterface> {
 
-    private final class StateAwareProxy implements InvocationHandler {
+    public final static class StateAwareProxy implements InvocationHandler {
 		private final ServiceInterface proxiedService;
 
-		private StateAwareProxy(ServiceInterface proxiedService) {
+		public StateAwareProxy(ServiceInterface proxiedService) {
 			this.proxiedService = proxiedService;
 		}
 
@@ -61,97 +64,46 @@
 		    } catch (InvocationTargetException err) {
 		        throw err.getTargetException();
 		    }
-		    
-		    ServiceRegistryBinding.this.setInitException(proxiedService.getInitException());
-		    ServiceRegistryBinding.this.updateState(proxiedService.getCurrentState());
 		    return returnObj;
 		}
 	}
-
-	/** Identifies service for purpose of looking up in registry */
-    private ServiceID serviceID;
-
-    /** local reference to service, made transient so it will not be sent to remote registries */
-    private transient ServiceInterface service;
     
-    /** remote reference */
-    private Object serviceStub;
-    
-    /** type of service */
-    private String serviceType;
+    private ServiceData serviceData;
 
-    /** component type */
-    private String componentType;
-
-    /** Name of deployed service */
-    private String deployedName;
-
-    /** Name of host this service is running on */
-    private String hostName;
-
-    /** Instance name */
-    private String instanceName;
-
-    /**
-     * Current state of service, this is updated by the service framework
-     * whenever the state changes
-     */
-    private int currentState;
-
-    /** Time of the last state change */
-    private Date stateChangeTime;
-
     /** indicates if service is an essential service */
     private boolean essential;
 
     /** defines service in configuration */
     private DeployedComponent deployedComponent;
 
-//    /** identifies psc this service belongs to. */
-//    private ProductServiceConfigID pscID;
-
     /** collection of queue names for service */
     private Collection queueNames;
     
-    /** Exception during initialization */
-    private Throwable initException;
+    public ServiceRegistryBinding(ServiceID serviceID, ServiceInterface si, String serviceType, String instanceName,
+            String componentType, String deployedName,
+            String hostName, DeployedComponent deployedComponent,
+            int state, Date time, boolean essential, MessageBus bus) {
+    	super(si, hostName, bus);
+    	this.serviceData = new ServiceData(ServiceState.STATE_NOT_INITIALIZED);
+    	this.serviceData.setId(serviceID);
+    	this.serviceData.setServiceType(serviceType);
+    	this.serviceData.setInstanceName(instanceName);
+        this.deployedComponent = deployedComponent;
+        this.essential = essential;
+    }
     
-    private transient MessageBus messageBus;
-    
-    private transient boolean dirty;
-    
     /**
      * Create new ServiceRegistryInstance
-     *
-     * @param serviceID Identifies service
-     * @param service ServiceInstance
-     * @param serviceType
-     * @param instanceName Instance name of service
-     * @param componenetType
-     * @param deployedName
-     * @param hostName
-     * @param state
-     * @param time
-     * @param essential, true indicates service is an essential service and cannot be shutdown if there are no other similiar services running.
      */
-    public ServiceRegistryBinding(ServiceID serviceID, ServiceInterface si, String serviceType, String instanceName,
-                                  String componentType, String deployedName,
-                                  String hostName, DeployedComponent deployedComponent,
-                                  int state, Date time, boolean essential, MessageBus bus) {
-
-        this.serviceID = serviceID;
-        this.serviceType = serviceType;
-        this.instanceName = instanceName;
-        this.componentType = componentType;
-        this.deployedName = deployedName;
-        this.hostName = hostName;
+    public ServiceRegistryBinding(ServiceInterface si, String hostName,
+			DeployedComponent deployedComponent, boolean essential,
+			MessageBus bus) {
+    	super((ServiceInterface) Proxy.newProxyInstance(Thread
+				.currentThread().getContextClassLoader(), si.getClass().getInterfaces(),
+				new StateAwareProxy(si)), hostName, bus);
+    	this.serviceData = si.getServiceData();
         this.deployedComponent = deployedComponent;
-        this.currentState = state;
-        this.stateChangeTime = time;
         this.essential = essential;
-        this.messageBus = bus;
-        this.setService(si);
-        
     }
 
     /**
@@ -159,61 +111,36 @@
      * @return ServiceID
      */
     public ServiceID getServiceID() {
-        return this.serviceID;
+        return this.serviceData.getId();
     }
 
-    /**
-     * Return reference to service
-     * If service is local then return local reference
-     * Else return stub
-     */
-    public synchronized ServiceInterface getService() {
-    	if (this.service != null) {
-    		return service;
-    	}
-    	if (this.serviceStub == null) {
-    		return null;
-    	}
-    	// when exported to the remote, use remote's message bus instance.
-    	MessageBus bus = this.messageBus;
-    	if(bus == null) {
-    		bus = ResourceFinder.getMessageBus();
-    	}
-    	this.service = (ServiceInterface)bus.getRPCProxy(this.serviceStub);
-    	return this.service;
-    }
-    
     public String getServiceType() {
-        return this.serviceType;
+        return this.serviceData.getServiceType();
     }
 
     public String getInstanceName() {
-        return this.instanceName;
+        return this.serviceData.getInstanceName();
     }
 
-    public String getComponentType() {
-        return this.componentType;
-    }
-
     public String getDeployedName() {
-        return this.deployedName;
+        return this.serviceData.getInstanceName();
     }
 
-    public String getHostName() {
-        return this.hostName;
-    }
-    
     public String getProcessName() {
-        return this.serviceID.getProcessName();
+        return this.getServiceID().getProcessName();
     }
 
     public int getCurrentState() {
-        return this.currentState;
+        return this.serviceData.getState();
     }
 
     public Date getStateChangeTime() {
-        return this.stateChangeTime;
+        return this.serviceData.getStateChangeTime();
     }
+    
+    public Throwable getInitException() {
+        return this.serviceData.getInitException();
+    }
 
     public boolean isEssential() {
         return essential;
@@ -223,37 +150,42 @@
         return this.deployedComponent;
     }
 
-//    public ProductServiceConfigID getPscID() {
-//        return this.pscID;
-//    }
-
     public boolean isServiceBad() {
-        return (currentState == ServiceState.STATE_CLOSED ||
-                currentState == ServiceState.STATE_FAILED ||
-                currentState == ServiceState.STATE_INIT_FAILED);
+        return (getCurrentState() == ServiceState.STATE_CLOSED ||
+                getCurrentState() == ServiceState.STATE_FAILED ||
+                getCurrentState() == ServiceState.STATE_INIT_FAILED);
     }
 
     public Collection getQueueNames() {
-    	if (this.queueNames == null) {
-    		this.queueNames = buildQueueNames(this.service);
+    	try {
+	    	if (this.queueNames == null) {
+	    		this.queueNames = buildQueueNames(getBindObject());
+	    	}
+    	} catch (ServiceException e) {
+    		markServiceAsBad();
+    		throw e;
     	}
         return this.queueNames;
     }
-
-    public Throwable getInitException() {
-        return this.initException;
-    }
     
-    public void setInitException(Throwable t) {
-        this.initException = t;
+    public void checkState() {
+    	//handle a stale process entry
+    	if (!this.isLocal()) {
+    		markServiceAsBad();
+    		return;
+    	}
+    	ServiceInterface bindObject = getBindObject();
+    	if (bindObject != null) {
+    		try {
+    			bindObject.checkState();
+    		} catch (ServiceException e) {
+    			
+    		}
+    	}
     }
     
     public void updateState(int state) {
-    	if (this.currentState != state) {
-	        this.currentState = state;
-	        this.stateChangeTime = new Date();
-	        this.dirty = true;
-    	}
+    	this.serviceData.updateState(state);
     }
    
     private Collection buildQueueNames(ServiceInterface si) {
@@ -273,54 +205,40 @@
     }
 
     public String toString() {
-
         StringBuffer b = new StringBuffer("ServiceRegistryBinding: "); //$NON-NLS-1$
-        b.append("\n\tserviceID: " + serviceID); //$NON-NLS-1$
-        b.append("\n\tserviceType: " + serviceType); //$NON-NLS-1$
-        b.append("\n\tinstanceName: " + instanceName); //$NON-NLS-1$
-        b.append("\n\thostName: " + hostName); //$NON-NLS-1$
-//        b.append("\n\tpscName: " + pscID); //$NON-NLS-1$
+        b.append("\n\tserviceID: " + getServiceID()); //$NON-NLS-1$
+        b.append("\n\tserviceType: " + getServiceType()); //$NON-NLS-1$
+        b.append("\n\tinstanceName: " + getInstanceName()); //$NON-NLS-1$
+        b.append("\n\thostName: " + getHostName()); //$NON-NLS-1$
         b.append("\n\tDeployedComponent: " + deployedComponent); //$NON-NLS-1$
-        b.append("\n\tcurrentState: " + currentState); //$NON-NLS-1$
+        b.append("\n\tcurrentState: " + getCurrentState()); //$NON-NLS-1$
         b.append("\n\tessential: " + (essential?"true":"false")); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
-
-        try {
-            b.append("\n\tserviceStub className = " + serviceStub.getClass().getName()); //$NON-NLS-1$
-        } catch (Exception e) {
-            b.append("\n\tserviceStub className = null"); //$NON-NLS-1$
-        }
         return b.toString();
     }
 
-	private synchronized void setService(ServiceInterface service) {
-		this.service = service;
-    	if (this.serviceStub != null) {
-    		this.messageBus.unExport(serviceStub);
-    		serviceStub = null;
-    	}
-        if (service != null) {
-            this.serviceStub = this.messageBus.export(service, service.getClass().getInterfaces());
-			this.service = (ServiceInterface) Proxy.newProxyInstance(Thread
-					.currentThread().getContextClassLoader(), service.getClass().getInterfaces(),
-					new StateAwareProxy(service));
-		}
-	}
-	
 	public boolean isActive() {
-		return (this.currentState == ServiceState.STATE_OPEN || this.currentState == ServiceState.STATE_DATA_SOURCE_UNAVAILABLE);		
+		return (this.getCurrentState() == ServiceState.STATE_OPEN || this.getCurrentState() == ServiceState.STATE_DATA_SOURCE_UNAVAILABLE);		
 	}
 	
 	public void markServiceAsBad() {
-		setService(null);
+		invalidateBindObject();
 		updateState(ServiceState.STATE_FAILED);
 	}
-
+	
+	public ServiceInterface getService() {
+		ServiceInterface result = getBindObject();
+		if (result == null) {
+	        throw new ServiceStateException(ServiceMessages.SERVICE_0012, ServicePlugin.Util.getString(ServiceMessages.SERVICE_0012, this.serviceData.getInstanceName(), this.serviceData.getId()));
+		}
+		return result;
+	}
+	
 	public void setDirty(boolean dirty) {
-		this.dirty = dirty;
+		this.serviceData.setDirty(dirty);
 	}
 
 	public boolean isDirty() {
-		return dirty;
+		return this.serviceData.isDirty();
 	}
-}
 
+}

Modified: trunk/server/src/main/java/com/metamatrix/platform/service/api/ServiceInterface.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/service/api/ServiceInterface.java	2009-05-17 00:02:22 UTC (rev 959)
+++ trunk/server/src/main/java/com/metamatrix/platform/service/api/ServiceInterface.java	2009-05-17 11:59:58 UTC (rev 960)
@@ -29,6 +29,7 @@
 import com.metamatrix.common.comm.ClientServiceRegistry;
 import com.metamatrix.common.config.api.DeployedComponentID;
 import com.metamatrix.common.queue.WorkerPoolStats;
+import com.metamatrix.platform.service.controller.ServiceData;
 
 public interface ServiceInterface {
 
@@ -129,4 +130,6 @@
      * There are reflective based calls on this
      */    
     void updateState(int state);
+    
+    ServiceData getServiceData();
 }

Modified: trunk/server/src/main/java/com/metamatrix/platform/service/controller/AbstractService.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/service/controller/AbstractService.java	2009-05-17 00:02:22 UTC (rev 959)
+++ trunk/server/src/main/java/com/metamatrix/platform/service/controller/AbstractService.java	2009-05-17 11:59:58 UTC (rev 960)
@@ -58,38 +58,13 @@
 //public abstract class AbstractService extends UnicastRemoteObject implements ServiceInterface, EventObjectListener {
 public abstract class AbstractService implements ServiceInterface, EventObjectListener {
 
-    // current state, default to not initialized.
-    private int state = ServiceState.STATE_NOT_INITIALIZED;
-
-    // Service type, used to look up in registry.
-    private String serviceType;
-
-    // Instance name
-    private String instanceName;
-
-    // ID of service
-	private ServiceID id;
-    
-    // ID of this deployed component
-    private DeployedComponentID deployedComponentID;
-
-    // properties used to initialize service
+    private ServiceData data = new ServiceData(ServiceState.STATE_NOT_INITIALIZED);
     private Properties props;
 
-    // time service was initialized
-    private Date startTime;
-
-    // time current state was set
-    private Date stateChangeTime;
-
-    private Throwable initException = null;
-    
-    /**
+	/**
      * Default constructor.
-     * Set stateChangedTime
      */
     public AbstractService() {
-        stateChangeTime = new Date();
     }
 
     //--------------------------------------------------------------
@@ -115,19 +90,14 @@
             throw new ServiceException(ServiceMessages.SERVICE_0001, ServicePlugin.Util.getString(ServiceMessages.SERVICE_0001));
         }
 
-        this.id = id;
-        this.deployedComponentID = deployedComponentID;
         this.props = props;
 
-        serviceType = props.getProperty(ServicePropertyNames.COMPONENT_TYPE_NAME);
-        instanceName = props.getProperty(ServicePropertyNames.INSTANCE_NAME);
-
-        if (serviceType == null || serviceType.trim().length() == 0) {
+        if (data.getServiceType() == null || data.getServiceType().trim().length() == 0) {
             throw new ServiceException(ServiceMessages.SERVICE_0002, ServicePlugin.Util.getString(ServiceMessages.SERVICE_0002, ServicePropertyNames.COMPONENT_TYPE_NAME ));
         }
 
-        logMessagePrivate(ServicePlugin.Util.getString(ServiceMessages.MSG_SERVICE_0001, instanceName));
-        logMessagePrivate(ServicePlugin.Util.getString(ServiceMessages.MSG_SERVICE_0002, instanceName, System.getProperty("java.class.path"))); //$NON-NLS-1$
+        logMessagePrivate(ServicePlugin.Util.getString(ServiceMessages.MSG_SERVICE_0001, data.getInstanceName()));
+        logMessagePrivate(ServicePlugin.Util.getString(ServiceMessages.MSG_SERVICE_0002, data.getInstanceName(), System.getProperty("java.class.path"))); //$NON-NLS-1$
 
         try {
             Properties resourceProps = CurrentConfiguration.getInstance().getResourceProperties(getResourceName());
@@ -136,25 +106,20 @@
             }
 
             logServiceProperties(this.props);
-            logMessagePrivate(ServicePlugin.Util.getString(ServiceMessages.MSG_SERVICE_0003, instanceName));
+            logMessagePrivate(ServicePlugin.Util.getString(ServiceMessages.MSG_SERVICE_0003, data.getInstanceName()));
 
             // Initialize!
-            logMessagePrivate(ServicePlugin.Util.getString(ServiceMessages.MSG_SERVICE_0004, serviceType));
+            logMessagePrivate(ServicePlugin.Util.getString(ServiceMessages.MSG_SERVICE_0004, data.getServiceType()));
             initService(this.props);
             registerForEvents();
             logMessagePrivate(ServicePlugin.Util.getString(ServiceMessages.MSG_SERVICE_0005, getServiceType()));
 
-            startTime = new Date();
+            data.setStartTime(new Date());
             markAsOpen();
-            setInitException(null);
-            return;
-
         } catch (Throwable e) {
             setInitException(e);
             throw new ServiceException(e, ServiceMessages.SERVICE_0004, ServicePlugin.Util.getString(ServiceMessages.SERVICE_0004, getServiceType()) );
-        } finally {
-            // Cleanup!
-        }
+        } 
     }
 
     /**
@@ -163,7 +128,7 @@
      * @return String representing type of service.
      */
     public final String getServiceType() {
-        return serviceType;
+        return data.getServiceType();
     }
 
     /**
@@ -177,7 +142,7 @@
      * @return int representing current state.
      */
     public final int getCurrentState() {
-        return state;
+        return data.getState();
     }
 
     /**
@@ -186,7 +151,7 @@
      * @return Date representing time of state change.
      */
     public final Date getStateChangeTime() {
-        return this.stateChangeTime;
+        return this.data.getStateChangeTime();
     }
 
     /**
@@ -195,20 +160,10 @@
      * @return ServiceID
      */
     public final ServiceID getID() {
-        return this.id;
+        return this.data.getId();
     }
 
     /**
-     * Return DepoloyedComponentID of this service.
-     * 
-     * @return deployedComponentID
-     */
-    public final DeployedComponentID getDeployedComponentID() {
-        return this.deployedComponentID;
-    }
-
-
-    /**
      * This method will gracefully shutdown the service.
      * Sub classes of AbstractService class should implement
      * unregisterForEvents(), closeService(), waitForServiceToClear() and
@@ -217,7 +172,7 @@
      */
     public final void die() {
         try {
-            logMessagePrivate(ServicePlugin.Util.getString(ServiceMessages.MSG_SERVICE_0006, this.id));
+            logMessagePrivate(ServicePlugin.Util.getString(ServiceMessages.MSG_SERVICE_0006, this.data.getId()));
             markAsClosed();
             unregisterForEvents();
             closeService();
@@ -241,7 +196,7 @@
                 markAsClosed();
                 unregisterForEvents();
             }
-            this.initException = null;
+            this.data.setInitException(null);
             killService();
         } catch (Exception e) {
             throw new ServiceException(e, ServiceMessages.SERVICE_0005, ServicePlugin.Util.getString(ServiceMessages.SERVICE_0005, getServiceType()));
@@ -255,7 +210,7 @@
      * @return Properties
      */
     public final Properties getProperties() {
-        return props;
+        return this.props;
     }
 
     /**
@@ -264,7 +219,7 @@
      * @return Date containing time service started.
      */
     public final Date getStartTime() {
-        return startTime;
+        return data.getStartTime();
     }
 
     /**
@@ -273,14 +228,14 @@
      * @return String Host name
      */
     public final String getHostname() {
-        return this.id.getHostName();
+        return this.data.getId().getHostName();
     }
 
     /**
      * @see com.metamatrix.platform.service.api.ServiceInterface#getProcessName()
      */
 	public final String getProcessName(){
-		return this.id.getProcessName();
+		return this.data.getId().getProcessName();
 	}
 	
     /**
@@ -289,7 +244,7 @@
      * @return String instance name
      */
     public final String getInstanceName() {
-        return this.instanceName;
+        return this.data.getInstanceName();
     }
 
 
@@ -311,23 +266,23 @@
 
     public void checkState() throws ServiceStateException {
 
-        if (state == ServiceState.STATE_OPEN) {
+        if (data.getState() == ServiceState.STATE_OPEN) {
             return;
         }
 
-        if (state == ServiceState.STATE_NOT_INITIALIZED) {
-            throw new ServiceNotInitializedException(ServiceMessages.SERVICE_0009, ServicePlugin.Util.getString(ServiceMessages.SERVICE_0009, this.getServiceName(), id));
+        if (data.getState() == ServiceState.STATE_NOT_INITIALIZED) {
+            throw new ServiceNotInitializedException(ServiceMessages.SERVICE_0009, ServicePlugin.Util.getString(ServiceMessages.SERVICE_0009, this.getServiceName(), data.getId()));
         }
 
-        if (state == ServiceState.STATE_CLOSED) {
-            throw new ServiceClosedException(ServiceMessages.SERVICE_0010, ServicePlugin.Util.getString(ServiceMessages.SERVICE_0010, this.getServiceName(), id));
+        if (data.getState() == ServiceState.STATE_CLOSED) {
+            throw new ServiceClosedException(ServiceMessages.SERVICE_0010, ServicePlugin.Util.getString(ServiceMessages.SERVICE_0010, this.getServiceName(), data.getId()));
         }
 
-        if (state == ServiceState.STATE_DATA_SOURCE_UNAVAILABLE) {
-            throw new ServiceClosedException(ServiceMessages.SERVICE_0069, ServicePlugin.Util.getString(ServiceMessages.SERVICE_0069, this.getServiceName(), id));
+        if (data.getState() == ServiceState.STATE_DATA_SOURCE_UNAVAILABLE) {
+            throw new ServiceClosedException(ServiceMessages.SERVICE_0069, ServicePlugin.Util.getString(ServiceMessages.SERVICE_0069, this.getServiceName(), data.getId()));
         }
 
-        throw new ServiceStateException(ServiceMessages.SERVICE_0012, ServicePlugin.Util.getString(ServiceMessages.SERVICE_0012, this.getServiceName(), id));
+        throw new ServiceStateException(ServiceMessages.SERVICE_0012, ServicePlugin.Util.getString(ServiceMessages.SERVICE_0012, this.getServiceName(), data.getId()));
     }
 
     /**
@@ -348,21 +303,21 @@
      * Return true if service has been initialized.
      */
     public final boolean isInitialized() {
-        return state != ServiceState.STATE_NOT_INITIALIZED;
+        return data.getState() != ServiceState.STATE_NOT_INITIALIZED;
     }
 
     /**
      * Return true if service is open
      */
     public final boolean isOpen() {
-        return state == ServiceState.STATE_OPEN;
+        return data.getState() == ServiceState.STATE_OPEN;
     }
 
     /**
      * Return true if service is closed.
      */
     public final boolean isClosed() {
-        return state == ServiceState.STATE_CLOSED;
+        return data.getState() == ServiceState.STATE_CLOSED;
     }
 
 
@@ -403,7 +358,7 @@
     * the resource name will probably be defined as a static variable called RESOURCE_NAME.
     */
     protected String getResourceName() {
-        return serviceType;
+        return data.getServiceType();
     }
 
     /**
@@ -566,7 +521,6 @@
     '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'
     };
 
-    
     /**
      * Update state and stateChangedTime with new state;
      * If newState == state then do nothing.
@@ -574,10 +528,7 @@
      * @param int new state of service
      */
     public synchronized void updateState(int newState) {
-        if (state != newState) {
-            state = newState;
-            stateChangeTime = new Date();
-        }
+        data.updateState(newState);
     }
 
     /**
@@ -586,21 +537,26 @@
      * @param Throwable 
      *      */
     public void setInitException(Throwable error) {
-    	this.initException = error;
+    	this.data.setInitException(error);
     	if (error != null) {
-    		state = ServiceState.STATE_INIT_FAILED;
+    		data.updateState(ServiceState.STATE_INIT_FAILED);
     	}
     }
 
     public Throwable getInitException() {
-    	return this.initException;
+    	return this.data.getInitException();
     }
     
     /**
      * Return name of service (instance name)
      */
     protected String getServiceName() {
-        return instanceName;
+        return data.getInstanceName();
     }
     
+    @Override
+    public ServiceData getServiceData() {
+    	return data;
+    }
+    
 }

Added: trunk/server/src/main/java/com/metamatrix/platform/service/controller/ServiceData.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/service/controller/ServiceData.java	                        (rev 0)
+++ trunk/server/src/main/java/com/metamatrix/platform/service/controller/ServiceData.java	2009-05-17 11:59:58 UTC (rev 960)
@@ -0,0 +1,118 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * See the COPYRIGHT.txt file distributed with this work for information
+ * regarding copyright ownership.  Some portions may be licensed
+ * to Red Hat, Inc. under one or more contributor license agreements.
+ * 
+ * This library 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 library 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 library; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+ * 02110-1301 USA.
+ */
+
+package com.metamatrix.platform.service.controller;
+
+import java.io.Serializable;
+import java.util.Date;
+
+import com.metamatrix.platform.service.api.ServiceID;
+
+public class ServiceData implements Serializable {
+	private int state;
+	private String serviceType;
+	private String instanceName;
+	private ServiceID id;
+	private Date startTime;
+	private Date stateChangeTime = new Date();
+	private Throwable initException;
+	private transient boolean dirty;
+
+	public ServiceData(int state) {
+		this.state = state;
+	}
+
+	public int getState() {
+		return state;
+	}
+
+	public String getServiceType() {
+		return serviceType;
+	}
+
+	public void setServiceType(String serviceType) {
+		this.serviceType = serviceType;
+	}
+
+	public String getInstanceName() {
+		return instanceName;
+	}
+
+	public void setInstanceName(String instanceName) {
+		this.instanceName = instanceName;
+	}
+
+	public ServiceID getId() {
+		return id;
+	}
+
+	public void setId(ServiceID id) {
+		this.id = id;
+	}
+
+	public Date getStartTime() {
+		return startTime;
+	}
+
+	void setStartTime(Date startTime) {
+		this.startTime = startTime;
+	}
+
+	public Date getStateChangeTime() {
+		return stateChangeTime;
+	}
+
+	void setStateChangeTime(Date stateChangeTime) {
+		this.stateChangeTime = stateChangeTime;
+	}
+
+	public Throwable getInitException() {
+		return initException;
+	}
+
+	void setInitException(Throwable initException) {
+		this.initException = initException;
+	}
+	
+	public boolean isDirty() {
+		return dirty;
+	}
+	
+	public void setDirty(boolean dirty) {
+		this.dirty = dirty;
+	}
+	
+    /**
+     * Update state and stateChangedTime with new state;
+     * If newState == state then do nothing.
+     *
+     * @param int new state of service
+     */
+    public synchronized void updateState(int newState) {
+        if (state != newState) {
+        	this.state = newState;
+    		this.dirty = true;
+            setStateChangeTime(new Date());
+        }
+    }
+
+}
\ No newline at end of file


Property changes on: trunk/server/src/main/java/com/metamatrix/platform/service/controller/ServiceData.java
___________________________________________________________________
Name: svn:mime-type
   + text/plain

Modified: trunk/server/src/main/java/com/metamatrix/platform/vm/controller/ProcessController.java
===================================================================
--- trunk/server/src/main/java/com/metamatrix/platform/vm/controller/ProcessController.java	2009-05-17 00:02:22 UTC (rev 959)
+++ trunk/server/src/main/java/com/metamatrix/platform/vm/controller/ProcessController.java	2009-05-17 11:59:58 UTC (rev 960)
@@ -100,6 +100,7 @@
 import com.metamatrix.platform.service.api.ServiceInterface;
 import com.metamatrix.platform.service.api.ServiceState;
 import com.metamatrix.platform.service.api.exception.ServiceException;
+import com.metamatrix.platform.service.controller.ServiceData;
 import com.metamatrix.platform.service.controller.ServicePropertyNames;
 import com.metamatrix.platform.util.ErrorMessageKeys;
 import com.metamatrix.platform.util.LogMessageKeys;
@@ -202,7 +203,7 @@
         this.clientServices.registerClientService(ConfigurationAdminAPI.class, wrapAdminService(ConfigurationAdminAPI.class, ConfigurationAdminAPIImpl.getInstance(this.registry)), PlatformAdminConstants.CTX_CONFIGURATION_ADMIN_API);
         this.clientServices.registerClientService(RuntimeStateAdminAPI.class, wrapAdminService(RuntimeStateAdminAPI.class, RuntimeStateAdminAPIImpl.getInstance(this.registry, hostManagement)), PlatformAdminConstants.CTX_RUNTIME_STATE_ADMIN_API);
         this.clientServices.registerClientService(AuthorizationAdminAPI.class, wrapAdminService(AuthorizationAdminAPI.class, AuthorizationAdminAPIImpl.getInstance()), PlatformAdminConstants.CTX_AUTHORIZATION_ADMIN_API);
-        this.clientServices.registerClientService(ExtensionSourceAdminAPI.class, wrapAdminService(ExtensionSourceAdminAPI.class, ExtensionSourceAdminAPIImpl.getInstance()), PlatformAdminConstants.CTX_ADMIN_API);
+        this.clientServices.registerClientService(ExtensionSourceAdminAPI.class, wrapAdminService(ExtensionSourceAdminAPI.class, ExtensionSourceAdminAPIImpl.getInstance()), PlatformAdminConstants.CTX_EXTENSION_SOURCE_ADMIN_API);
         this.clientServices.registerClientService(RuntimeMetadataAdminAPI.class, wrapAdminService(RuntimeMetadataAdminAPI.class, RuntimeMetadataAdminAPIImpl.getInstance()), PlatformAdminConstants.CTX_RUNTIME_METADATA_ADMIN_API);
     }	
     
@@ -727,16 +728,19 @@
         	}
         	
             serviceInstanceName = serviceProps.getProperty(ServicePropertyNames.INSTANCE_NAME);
-            String componentType = serviceProps.getProperty(ServicePropertyNames.COMPONENT_TYPE_NAME);
             String serviceType = serviceProps.getProperty(ServicePropertyNames.SERVICE_NAME);
-            String routingID = serviceProps.getProperty(ServicePropertyNames.SERVICE_ROUTING_ID);
             boolean essential = PropertiesUtils.getBooleanProperty(serviceProps, ServicePropertyNames.SERVICE_ESSENTIAL, false);
 
             // Create an instance of serviceClass
             final ServiceInterface service  = (ServiceInterface) Thread.currentThread().getContextClassLoader().loadClass(serviceClass).newInstance();
 
+            ServiceData serviceData = service.getServiceData();
+            serviceData.setId(serviceID);
+            serviceData.setServiceType(serviceProps.getProperty(ServicePropertyNames.COMPONENT_TYPE_NAME));
+            serviceData.setInstanceName(serviceProps.getProperty(ServicePropertyNames.INSTANCE_NAME));
+
             // Create ServiceRegistryBinding and register
-            final ServiceRegistryBinding binding = new ServiceRegistryBinding(serviceID, service, routingID,serviceInstanceName, componentType, serviceInstanceName,host.getFullName(), deployedComponent,  service.getCurrentState(), service.getStateChangeTime(),essential, this.messageBus);
+            final ServiceRegistryBinding binding = new ServiceRegistryBinding(service, host.getFullName(), deployedComponent, essential, this.messageBus);
             
             logMessage(PlatformPlugin.Util.getString("ServiceController.0",serviceInstanceName)); //$NON-NLS-1$
             
@@ -746,7 +750,8 @@
             final Object[] param1 = new Object[] { serviceID };
             DeployedComponentID deployedComponentID = (DeployedComponentID) deployedComponent.getID();
             logMessage(PlatformPlugin.Util.getString("ServiceController.1",param1)); //$NON-NLS-1$
-            binding.getService().init(serviceID, deployedComponentID, serviceProps, serverListenerRegistry); 
+            
+            service.init(serviceID, deployedComponentID, serviceProps, serverListenerRegistry); 
             logMessage(PlatformPlugin.Util.getString("ServiceController.2",param1)); //$NON-NLS-1$
             logMessage(PlatformPlugin.Util.getString("ServiceController.3",param1)); //$NON-NLS-1$                
                                

Modified: trunk/server/src/test/java/com/metamatrix/admin/server/FakeCacheAdmin.java
===================================================================
--- trunk/server/src/test/java/com/metamatrix/admin/server/FakeCacheAdmin.java	2009-05-17 00:02:22 UTC (rev 959)
+++ trunk/server/src/test/java/com/metamatrix/admin/server/FakeCacheAdmin.java	2009-05-17 11:59:58 UTC (rev 960)
@@ -40,6 +40,7 @@
 import com.metamatrix.platform.service.api.CacheAdmin;
 import com.metamatrix.platform.service.api.ServiceID;
 import com.metamatrix.platform.service.api.ServiceInterface;
+import com.metamatrix.platform.service.controller.ServiceData;
 
 
 public class FakeCacheAdmin implements CacheAdmin, ServiceInterface {
@@ -153,5 +154,10 @@
 	public Throwable getInitException() {
 		return null;
 	}
+	
+	@Override
+	public ServiceData getServiceData() {
+		return null;
+	}
 
 }

Modified: trunk/server/src/test/java/com/metamatrix/admin/server/FakeConfigurationService.java
===================================================================
--- trunk/server/src/test/java/com/metamatrix/admin/server/FakeConfigurationService.java	2009-05-17 00:02:22 UTC (rev 959)
+++ trunk/server/src/test/java/com/metamatrix/admin/server/FakeConfigurationService.java	2009-05-17 11:59:58 UTC (rev 960)
@@ -74,6 +74,7 @@
 import com.metamatrix.platform.PlatformPlugin;
 import com.metamatrix.platform.config.api.service.ConfigurationServiceInterface;
 import com.metamatrix.platform.service.api.ServiceID;
+import com.metamatrix.platform.service.controller.ServiceData;
 
 public class FakeConfigurationService implements ConfigurationServiceInterface {
 
@@ -786,5 +787,10 @@
 	public Throwable getInitException() {
 		return null;
 	}
+	
+	@Override
+	public ServiceData getServiceData() {
+		return null;
+	}
 
 }

Modified: trunk/server/src/test/java/com/metamatrix/admin/server/FakeQueryService.java
===================================================================
--- trunk/server/src/test/java/com/metamatrix/admin/server/FakeQueryService.java	2009-05-17 00:02:22 UTC (rev 959)
+++ trunk/server/src/test/java/com/metamatrix/admin/server/FakeQueryService.java	2009-05-17 11:59:58 UTC (rev 960)
@@ -49,6 +49,7 @@
 import com.metamatrix.platform.security.api.MetaMatrixSessionID;
 import com.metamatrix.platform.security.api.SessionToken;
 import com.metamatrix.platform.service.api.ServiceID;
+import com.metamatrix.platform.service.controller.ServiceData;
 import com.metamatrix.server.query.service.QueryServiceInterface;
 import com.metamatrix.server.serverapi.RequestInfo;
 
@@ -289,5 +290,10 @@
 	public void terminateTransaction(Xid transactionId) throws AdminException {
 		
 	}
+	
+	@Override
+	public ServiceData getServiceData() {
+		return null;
+	}
 
 }

Modified: trunk/server/src/test/java/com/metamatrix/admin/server/FakeServerSessionService.java
===================================================================
--- trunk/server/src/test/java/com/metamatrix/admin/server/FakeServerSessionService.java	2009-05-17 00:02:22 UTC (rev 959)
+++ trunk/server/src/test/java/com/metamatrix/admin/server/FakeServerSessionService.java	2009-05-17 11:59:58 UTC (rev 960)
@@ -44,6 +44,7 @@
 import com.metamatrix.platform.security.api.MetaMatrixSessionInfo;
 import com.metamatrix.platform.security.api.service.SessionServiceInterface;
 import com.metamatrix.platform.service.api.ServiceID;
+import com.metamatrix.platform.service.controller.ServiceData;
 import com.metamatrix.platform.util.ProductInfoConstants;
 
 public class FakeServerSessionService implements SessionServiceInterface {
@@ -264,5 +265,10 @@
 	public Throwable getInitException() {
 		return null;
 	}
+	
+	@Override
+	public ServiceData getServiceData() {
+		return null;
+	}
 
 }

Modified: trunk/server/src/test/java/com/metamatrix/admin/server/TestServerMonitoringAdminImpl.java
===================================================================
--- trunk/server/src/test/java/com/metamatrix/admin/server/TestServerMonitoringAdminImpl.java	2009-05-17 00:02:22 UTC (rev 959)
+++ trunk/server/src/test/java/com/metamatrix/admin/server/TestServerMonitoringAdminImpl.java	2009-05-17 11:59:58 UTC (rev 960)
@@ -47,7 +47,6 @@
 import com.metamatrix.admin.objects.MMService;
 import com.metamatrix.admin.objects.MMSession;
 import com.metamatrix.admin.objects.MMSystem;
-import com.metamatrix.common.config.api.ServiceComponentDefn;
 import com.metamatrix.common.config.api.SharedResource;
 import com.metamatrix.platform.registry.ClusteredRegistryState;
 import com.metamatrix.platform.registry.FakeRegistryUtil;

Modified: trunk/server/src/test/java/com/metamatrix/platform/registry/FakeRegistryUtil.java
===================================================================
--- trunk/server/src/test/java/com/metamatrix/platform/registry/FakeRegistryUtil.java	2009-05-17 00:02:22 UTC (rev 959)
+++ trunk/server/src/test/java/com/metamatrix/platform/registry/FakeRegistryUtil.java	2009-05-17 11:59:58 UTC (rev 960)
@@ -128,7 +128,7 @@
 		BasicDeployedComponent deployedComponent = new BasicDeployedComponent(deployedComponentID1, Configuration.NEXT_STARTUP_ID, vm.getDeployedComponent().getHostID(), (VMComponentDefnID)vm.getDeployedComponent().getID(), connectorBindingID1, ConnectorBindingType.CONNECTOR_TYPE_ID);
 		deployedComponent.setDescription(name); 
 		
-	    return new ServiceRegistryBinding(sid, new FakeCacheAdmin(sid), type,"instance-"+id, null, name, vm.getHostName(), deployedComponent,  ServiceState.STATE_OPEN, new Date(), false, new NoOpMessageBus());	 //$NON-NLS-1$
+	    return new ServiceRegistryBinding(sid, new FakeCacheAdmin(sid), type,name, null, name, vm.getHostName(), deployedComponent,  ServiceState.STATE_OPEN, new Date(), false, new NoOpMessageBus());	 //$NON-NLS-1$
 	}
 	
 	static HostControllerRegistryBinding buildHostRegistryBinding(String name) {

Modified: trunk/server/src/test/java/com/metamatrix/platform/registry/TestServiceRegistryBinding.java
===================================================================
--- trunk/server/src/test/java/com/metamatrix/platform/registry/TestServiceRegistryBinding.java	2009-05-17 00:02:22 UTC (rev 959)
+++ trunk/server/src/test/java/com/metamatrix/platform/registry/TestServiceRegistryBinding.java	2009-05-17 11:59:58 UTC (rev 960)
@@ -22,20 +22,15 @@
 
 package com.metamatrix.platform.registry;
 
-import java.util.Date;
+import java.lang.reflect.Proxy;
 import java.util.Properties;
 
 import junit.framework.TestCase;
 
-import com.metamatrix.admin.server.FakeConfiguration;
-import com.metamatrix.common.config.api.DeployedComponent;
-import com.metamatrix.common.messaging.NoOpMessageBus;
-import com.metamatrix.platform.service.api.ServiceID;
 import com.metamatrix.platform.service.api.ServiceInterface;
 import com.metamatrix.platform.service.api.ServiceState;
 import com.metamatrix.platform.service.api.exception.ServiceClosedException;
 import com.metamatrix.platform.service.controller.AbstractService;
-import com.metamatrix.server.query.service.QueryService;
 
 public class TestServiceRegistryBinding extends TestCase {
 
@@ -74,24 +69,21 @@
 	public void testStateCheckingProxy() throws Exception {
 		FakeServiceImpl service = new FakeServiceImpl();
 		
-    	ProcessRegistryBinding vmBinding2  = FakeRegistryUtil.buildVMRegistryBinding("2.2.2.2", "process2");             //$NON-NLS-1$ //$NON-NLS-2$ 
-    	ServiceID sid1 = new ServiceID(5, vmBinding2.getHostName(), vmBinding2.getProcessName());
-    	ServiceRegistryBinding binding = new ServiceRegistryBinding(sid1, service, QueryService.SERVICE_NAME,
-                                                                    "dqp2", "QueryService", //$NON-NLS-1$ //$NON-NLS-2$
-                                                                    "dqp2", "2.2.2.2",(DeployedComponent)new FakeConfiguration().deployedComponents.get(4),  //$NON-NLS-1$ //$NON-NLS-2$ 
-                                                                    ServiceState.STATE_CLOSED,
-                                                                    new Date(),  
-                                                                    false, new NoOpMessageBus()); 
+    	FakeServiceInterface fakeServiceInterface = (FakeServiceInterface) Proxy
+				.newProxyInstance(Thread.currentThread()
+						.getContextClassLoader(),
+						new Class[] { FakeServiceInterface.class },
+						new ServiceRegistryBinding.StateAwareProxy(service));
 		
-		assertEquals(1, ((FakeServiceInterface)binding.getService()).doSomething(1));
+		assertEquals(1, fakeServiceInterface.doSomething(1));
 
 		service.die();
 		
 		//ensure that check state is not called through the proxy
-		((FakeServiceInterface)binding.getService()).die();
+		fakeServiceInterface.die();
 		
 		try {
-			((FakeServiceInterface)binding.getService()).doSomething(1);
+			fakeServiceInterface.doSomething(1);
 			fail("expected exception"); //$NON-NLS-1$
 		} catch (ServiceClosedException e) {
 			//expected

Modified: trunk/server/src/test/java/com/metamatrix/platform/service/controller/FakeService.java
===================================================================
--- trunk/server/src/test/java/com/metamatrix/platform/service/controller/FakeService.java	2009-05-17 00:02:22 UTC (rev 959)
+++ trunk/server/src/test/java/com/metamatrix/platform/service/controller/FakeService.java	2009-05-17 11:59:58 UTC (rev 960)
@@ -111,4 +111,8 @@
 	public Throwable getInitException() {
 		return null;
 	}
+	@Override
+	public ServiceData getServiceData() {
+		return null;
+	}
 }




More information about the teiid-commits mailing list