[jboss-cvs] JBossAS SVN: r65488 - in trunk: profileservice/src/main/org/jboss/profileservice/management and 4 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Sep 20 07:59:57 EDT 2007


Author: alesj
Date: 2007-09-20 07:59:57 -0400 (Thu, 20 Sep 2007)
New Revision: 65488

Added:
   trunk/profileservice/src/main/org/jboss/profileservice/management/BasicMetaDataNameProvider.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/ControllerRuntimeComponentDispatcher.java
   trunk/system/src/main/org/jboss/deployers/spi/management/MetaDataNameProvider.java
   trunk/system/src/main/org/jboss/deployers/spi/management/RuntimeComponentDispatcher.java
Modified:
   trunk/connector/src/main/org/jboss/resource/connectionmanager/JBossManagedConnectionPool.java
   trunk/connector/src/main/org/jboss/resource/connectionmanager/JBossManagedConnectionPoolMBean.java
   trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
   trunk/profileservice/src/main/org/jboss/profileservice/remoting/ProfileServiceInvocationHandler.java
   trunk/profileservice/src/main/org/jboss/profileservice/remoting/ProxyFactory.java
   trunk/profileservice/src/resources/profileservice-beans.xml
   trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java
Log:
ManagedOperation invocation via ManagementViewImpl.

Modified: trunk/connector/src/main/org/jboss/resource/connectionmanager/JBossManagedConnectionPool.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/connectionmanager/JBossManagedConnectionPool.java	2007-09-20 11:12:31 UTC (rev 65487)
+++ trunk/connector/src/main/org/jboss/resource/connectionmanager/JBossManagedConnectionPool.java	2007-09-20 11:59:57 UTC (rev 65488)
@@ -112,7 +112,7 @@
    @ManagementOperation(description="Obtain a formatted statistics report",
          impact=Impact.ReadOnly,
          params={@ManagementParameter(name="formatClassName",description="The StatisticsFormatter class name")})
-   public Object listFormatttedSubPoolStatistics(String formatClassName)
+   public Object listFormattedSubPoolStatistics(String formatClassName)
    {
       final JBossStatistics stats = (JBossStatistics)listStatistics();
       final ClassLoader cl = Thread.currentThread().getContextClassLoader();
@@ -139,7 +139,7 @@
    public Object listFormattedSubPoolStatistics()
    {
       
-      Object formatted = listFormatttedSubPoolStatistics(statisticsFormatter);
+      Object formatted = listFormattedSubPoolStatistics(statisticsFormatter);
       return formatted;  
    }
    

Modified: trunk/connector/src/main/org/jboss/resource/connectionmanager/JBossManagedConnectionPoolMBean.java
===================================================================
--- trunk/connector/src/main/org/jboss/resource/connectionmanager/JBossManagedConnectionPoolMBean.java	2007-09-20 11:12:31 UTC (rev 65487)
+++ trunk/connector/src/main/org/jboss/resource/connectionmanager/JBossManagedConnectionPoolMBean.java	2007-09-20 11:59:57 UTC (rev 65488)
@@ -200,7 +200,7 @@
     * 
     * @return the formatted statistics.
     */
-   Object listFormatttedSubPoolStatistics(String formatter);
+   Object listFormattedSubPoolStatistics(String formatter);
    
    /**
     * Get the class name of the current statistics formatter

Added: trunk/profileservice/src/main/org/jboss/profileservice/management/BasicMetaDataNameProvider.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/BasicMetaDataNameProvider.java	                        (rev 0)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/BasicMetaDataNameProvider.java	2007-09-20 11:59:57 UTC (rev 65488)
@@ -0,0 +1,51 @@
+/*
+* 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.profileservice.management;
+
+import java.io.Serializable;
+
+import org.jboss.deployers.spi.management.MetaDataNameProvider;
+import org.jboss.beans.metadata.spi.BeanMetaData;
+import org.jboss.system.metadata.ServiceMetaData;
+
+/**
+ * Simple name provider.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class BasicMetaDataNameProvider implements MetaDataNameProvider
+{
+   public Object getRuntimeComponentName(Serializable attachment)
+   {
+      if (attachment instanceof BeanMetaData)
+      {
+         BeanMetaData beanMetaData = (BeanMetaData)attachment;
+         return beanMetaData.getName();
+      }
+      else if (attachment instanceof ServiceMetaData)
+      {
+         ServiceMetaData serviceMetaData = (ServiceMetaData)attachment;
+         return serviceMetaData.getObjectName().getCanonicalName();
+      }
+      throw new IllegalArgumentException("Cannot handle attachment of type: " + attachment.getClass());
+   }
+}

Added: trunk/profileservice/src/main/org/jboss/profileservice/management/ControllerRuntimeComponentDispatcher.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/ControllerRuntimeComponentDispatcher.java	                        (rev 0)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/ControllerRuntimeComponentDispatcher.java	2007-09-20 11:59:57 UTC (rev 65488)
@@ -0,0 +1,104 @@
+/*
+* 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.profileservice.management;
+
+import java.io.Serializable;
+
+import org.jboss.deployers.spi.management.RuntimeComponentDispatcher;
+import org.jboss.deployers.spi.management.MetaDataNameProvider;
+import org.jboss.dependency.spi.Controller;
+import org.jboss.dependency.spi.ControllerContext;
+import org.jboss.dependency.spi.dispatch.InvokeDispatchContext;
+import org.jboss.metatype.api.values.MetaValue;
+import org.jboss.metatype.api.values.SimpleValue;
+import org.jboss.beans.metadata.plugins.annotations.Constructor;
+import org.jboss.beans.metadata.plugins.annotations.Inject;
+import org.jboss.kernel.plugins.bootstrap.basic.KernelConstants;
+
+/**
+ * Microcontainer Controller runtime component dispatcher.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class ControllerRuntimeComponentDispatcher implements RuntimeComponentDispatcher
+{
+   private Controller controller;
+   private MetaDataNameProvider provider;
+
+   @Constructor
+   public ControllerRuntimeComponentDispatcher(@Inject(bean= KernelConstants.KERNEL_CONTROLLER_NAME) Controller controller)
+   {
+      if (controller == null)
+         throw new IllegalArgumentException("Null controller.");
+      this.controller = controller;
+      this.provider = new BasicMetaDataNameProvider();
+   }
+
+   public Object dispatch(Serializable attachment, String methodName, MetaValue... param)
+   {
+      Object name = provider.getRuntimeComponentName(attachment);
+      ControllerContext context = controller.getInstalledContext(name);
+      if (context != null)
+      {
+         if (context instanceof InvokeDispatchContext)
+         {
+            InvokeDispatchContext dispatchContext = (InvokeDispatchContext)context;
+            Object[] args = new Object[param.length];
+            String[] signature = new String[param.length];
+            for(int i=0; i < param.length; i++)
+            {
+               args[i] = value(param[i]);
+               signature[i] = param[i].getMetaType().getClassName();
+            }
+            try
+            {
+               return dispatchContext.invoke(methodName, args, signature);
+            }
+            catch (Throwable t)
+            {
+               throw new RuntimeException(t);
+            }
+         }
+         else
+            throw new IllegalArgumentException("Context is not invoke dispatchable: " + context);
+      }
+      else
+         throw new IllegalArgumentException("No such installed context: " + attachment);
+   }
+
+   private Object value(MetaValue value)
+   {
+      if (value instanceof SimpleValue == false)
+         throw new IllegalArgumentException("Cannot get value from non Simple value: " + value);
+      return ((SimpleValue)value).getValue();
+   }
+
+   public MetaDataNameProvider getNameProvider()
+   {
+      return provider;
+   }
+
+   public void setProvider(MetaDataNameProvider provider)
+   {
+      this.provider = provider;
+   }
+}

Modified: trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java	2007-09-20 11:12:31 UTC (rev 65487)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/ManagementViewImpl.java	2007-09-20 11:59:57 UTC (rev 65488)
@@ -36,8 +36,6 @@
 
 import org.jboss.aop.Dispatcher;
 import org.jboss.aop.advice.Interceptor;
-import org.jboss.aop.joinpoint.Invocation;
-import org.jboss.aop.joinpoint.InvocationResponse;
 import org.jboss.aspects.remoting.InvokeRemoteInterceptor;
 import org.jboss.aspects.remoting.MergeMetaDataInterceptor;
 import org.jboss.aspects.remoting.Remoting;
@@ -47,16 +45,18 @@
 import org.jboss.deployers.spi.management.DeploymentTemplate;
 import org.jboss.deployers.spi.management.DeploymentTemplateInfo;
 import org.jboss.deployers.spi.management.ManagementView;
+import org.jboss.deployers.spi.management.RuntimeComponentDispatcher;
 import org.jboss.deployers.vfs.spi.client.VFSDeployment;
 import org.jboss.deployers.vfs.spi.client.VFSDeploymentFactory;
 import org.jboss.logging.Logger;
 import org.jboss.managed.api.ComponentType;
 import org.jboss.managed.api.ManagedComponent;
 import org.jboss.managed.api.ManagedDeployment;
+import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
 import org.jboss.managed.api.ManagedObject;
 import org.jboss.managed.api.ManagedOperation;
+import org.jboss.managed.api.ManagedParameter;
 import org.jboss.managed.api.ManagedProperty;
-import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
 import org.jboss.managed.api.annotation.ManagementComponent;
 import org.jboss.managed.api.annotation.ManagementObject;
 import org.jboss.managed.api.annotation.ManagementObjectID;
@@ -68,6 +68,7 @@
 import org.jboss.metatype.api.types.MetaType;
 import org.jboss.metatype.api.values.ArrayValue;
 import org.jboss.metatype.api.values.GenericValue;
+import org.jboss.metatype.api.values.MetaValue;
 import org.jboss.metatype.api.values.SimpleValue;
 import org.jboss.profileservice.spi.AttachmentsSerializer;
 import org.jboss.profileservice.spi.NoSuchDeploymentException;
@@ -125,8 +126,8 @@
     * matching ManagedObject.
     */
    private Map<String, ManagedObject> runtimeMOs = new HashMap<String, ManagedObject>();
-   /** A map of the ManagedOperation to runtime component */
-   private Map<ManagedOperation, Object> opMap = new HashMap<ManagedOperation, Object>();
+   /** The dispatcher */
+   private RuntimeComponentDispatcher dispatcher;
 
    public ManagementViewImpl()
    {
@@ -374,6 +375,11 @@
       return this.getClass().getName();
    }
 
+   public void setDispatcher(RuntimeComponentDispatcher dispatcher)
+   {
+      this.dispatcher = dispatcher;
+   }
+
    /**
     * Get the names of the deployment in the profile.
     * @param key - the profile containing the deployment
@@ -641,30 +647,6 @@
       }
    }
 
-   /**
-    * Handle ManagedOperation invocations
-    * 
-    * @param inv - the remoting invocation information
-    * @return
-    * @throws Throwable
-    */
-   public InvocationResponse invoke(Invocation inv)
-      throws Throwable
-   {
-      Object oid = inv.getMetaData(Dispatcher.DISPATCHER, Dispatcher.OID);
-      log.debug("Invocation for: "+oid);
-      ManagedOperation op = (ManagedOperation) Dispatcher.singleton.getRegistered(oid);
-      if (op == null)
-         throw new IllegalStateException("No ManagedOperation found for: "+oid);
-      // TODO: Get the runtime component
-      Object target = opMap.get(op);
-      if (target == null)
-         throw new IllegalStateException("No target found for op: "+op);
-      // Dispatch the operation...
-      InvocationResponse response = new InvocationResponse();
-      return response;
-   }
-
    protected void checkForReferences(String key, ManagedObject mo)
    {
       Set<ManagedProperty> referers =  unresolvedRefs.get(key);
@@ -700,7 +682,7 @@
          props.putAll(runtimeProps);
       if (runtimeOps != null)
       {
-         runtimeOps = createOperationProxies(runtimeOps);
+         runtimeOps = createOperationProxies(runtimeMO, runtimeOps);
          ops.addAll(runtimeOps);
       }
 
@@ -712,13 +694,17 @@
    /**
     * TODO: An aspect that performs the operation dispatch is still needed
     * 
+    * @param mo
     * @param ops
     * @return
     * @throws Exception
     */
-   protected Set<ManagedOperation> createOperationProxies(Set<ManagedOperation> ops)
+   protected Set<ManagedOperation> createOperationProxies(ManagedObject mo, Set<ManagedOperation> ops)
       throws Exception
    {
+      if (dispatcher == null)
+         throw new IllegalArgumentException("Missing RuntimeComponentDispatcher.");
+
       ClassLoader loader = getClass().getClassLoader();
       ArrayList<Interceptor> interceptors = new ArrayList<Interceptor>();
       interceptors.add(SecurityClientInterceptor.singleton);
@@ -731,12 +717,10 @@
       for (ManagedOperation op : ops)
       {
          String dispatchName = "ProfileService.ManagedOperation@"+System.identityHashCode(op);
-         Dispatcher.singleton.registerTarget(dispatchName, op);
+         Dispatcher.singleton.registerTarget(dispatchName, new ManagedOperationDelegate(op, mo.getAttachment()));
          ManagedOperation opProxy = (ManagedOperation) Remoting.createRemoteProxy(dispatchName,
                loader, ifaces, locator, interceptors, "ProfileService");
          opProxies.add(opProxy);
-         // TODO: Need a map from the op to the runtime component
-         opMap.put(op, null);
       }
       return opProxies;
    }
@@ -744,8 +728,52 @@
    private ManagedDeployment getManagedDeployment(Deployment ctx)
       throws Exception
    {
-      ManagedDeployment md = mainDeployer.getManagedDeployment(ctx.getName());
-      return md;
+      return mainDeployer.getManagedDeployment(ctx.getName());
    }
 
+   public class ManagedOperationDelegate implements ManagedOperation
+   {
+      private ManagedOperation delegate;
+      private Serializable attachment;
+
+      public ManagedOperationDelegate(ManagedOperation delegate, Serializable attachment)
+      {
+         if (delegate == null)
+            throw new IllegalArgumentException("Null delegate.");
+         this.delegate = delegate;
+         if (attachment == null)
+            throw new IllegalArgumentException("No attachment target for op: " + delegate);
+         this.attachment = attachment;
+      }
+
+      public Object invoke(MetaValue... metaValues)
+      {
+         return dispatcher.dispatch(attachment, delegate.getName(), metaValues);
+      }
+
+      public String getDescription()
+      {
+         return delegate.getDescription();
+      }
+
+      public String getName()
+      {
+         return delegate.getName();
+      }
+
+      public Impact getImpact()
+      {
+         return delegate.getImpact();
+      }
+
+      public MetaType getReturnType()
+      {
+         return delegate.getReturnType();
+      }
+
+      public ManagedParameter[] getParameters()
+      {
+         return delegate.getParameters();
+      }
+   }
 }

Modified: trunk/profileservice/src/main/org/jboss/profileservice/remoting/ProfileServiceInvocationHandler.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/remoting/ProfileServiceInvocationHandler.java	2007-09-20 11:12:31 UTC (rev 65487)
+++ trunk/profileservice/src/main/org/jboss/profileservice/remoting/ProfileServiceInvocationHandler.java	2007-09-20 11:59:57 UTC (rev 65488)
@@ -21,13 +21,10 @@
  */
 package org.jboss.profileservice.remoting;
 
-import org.jboss.aop.Dispatcher;
 import org.jboss.aop.joinpoint.InvocationResponse;
-import org.jboss.aop.proxy.Proxy;
 import org.jboss.aspects.remoting.AOPRemotingInvocationHandler;
 import org.jboss.deployers.spi.management.ManagementView;
 import org.jboss.logging.Logger;
-import org.jboss.managed.api.ManagedOperation;
 import org.jboss.profileservice.management.ManagementViewImpl;
 import org.jboss.remoting.InvocationRequest;
 import org.jboss.remoting.ServerInvocationHandler;
@@ -69,15 +66,7 @@
    public Object invoke(InvocationRequest invocation)
       throws Throwable
    {
-      org.jboss.aop.joinpoint.Invocation inv =(org.jboss.aop.joinpoint.Invocation)invocation.getParameter();
-      Object oid = inv.getMetaData(Dispatcher.DISPATCHER, Dispatcher.OID);
-
-      InvocationResponse value = null;
-      if (oid.toString().startsWith("ProfileService.ManagedOperation@"))
-         value = mgtView.invoke(inv);
-      else
-         value = (InvocationResponse) super.invoke(invocation);
-
+      InvocationResponse value = (InvocationResponse) super.invoke(invocation);
       if( value.getResponse() instanceof ManagementView )
       {
          // Replace the ManagementView with its proxy

Modified: trunk/profileservice/src/main/org/jboss/profileservice/remoting/ProxyFactory.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/remoting/ProxyFactory.java	2007-09-20 11:12:31 UTC (rev 65487)
+++ trunk/profileservice/src/main/org/jboss/profileservice/remoting/ProxyFactory.java	2007-09-20 11:59:57 UTC (rev 65488)
@@ -129,8 +129,7 @@
       interceptors.add(MergeMetaDataInterceptor.singleton);
       interceptors.add(InvokeRemoteInterceptor.singleton);
 
-      psProxy = Remoting.createRemoteProxy(dispatchName, loader, ifaces, locator,
-            interceptors, "ProfileService");
+      psProxy = Remoting.createRemoteProxy(dispatchName, loader, ifaces, locator, interceptors, "ProfileService");
       InitialContext ctx = new InitialContext();
       Util.bind(ctx, jndiName, psProxy);
       log.debug("Bound ProfileService proxy");
@@ -139,8 +138,7 @@
       Class[] mvIfaces = {ManagementView.class};
       String mvDispatchName = dispatchName+".ManagementView";
       Dispatcher.singleton.registerTarget(mvDispatchName, mgtView);
-      mgtViewProxy = Remoting.createRemoteProxy(mvDispatchName, loader, mvIfaces, locator,
-            interceptors, "ProfileService");
+      mgtViewProxy = Remoting.createRemoteProxy(mvDispatchName, loader, mvIfaces, locator, interceptors, "ProfileService");
       log.debug("Created ManagementView proxy");
    }
 

Modified: trunk/profileservice/src/resources/profileservice-beans.xml
===================================================================
--- trunk/profileservice/src/resources/profileservice-beans.xml	2007-09-20 11:12:31 UTC (rev 65487)
+++ trunk/profileservice/src/resources/profileservice-beans.xml	2007-09-20 11:59:57 UTC (rev 65488)
@@ -32,7 +32,13 @@
         <property name="managementViewProxy"><inject bean="ProfileServiceProxyFactory" property="managementViewProxy"/></property>
         <property name="viewManager"><inject bean="ManagementView"/></property>
     </bean>
-    
+
+    <bean name="RuntimeComponentDispatcher" class="org.jboss.profileservice.management.ControllerRuntimeComponentDispatcher">
+       <constructor>
+          <parameter><inject bean="jboss.kernel:service=KernelController"/></parameter>
+       </constructor>
+    </bean>
+
     <!-- The ManagementView plugin -->
     <bean name="ManagementView" class="org.jboss.profileservice.management.ManagementViewImpl">
         <install bean="ProfileService" method="setViewManager">
@@ -49,6 +55,7 @@
         <property name="profileService"><inject bean="ProfileService"/></property>
         <property name="serializer"><inject bean="JavaSerializationAttachmentsSerializer"/></property>
         <property name="locator"><inject bean="ConnectorMBean" property="invokerLocator"/></property>
+        <property name="dispatcher"><inject bean="RuntimeComponentDispatcher"/></property>
         
         <!-- Accept any implementor of DeploymentTemplate -->
         <incallback method="addTemplate"/>

Added: trunk/system/src/main/org/jboss/deployers/spi/management/MetaDataNameProvider.java
===================================================================
--- trunk/system/src/main/org/jboss/deployers/spi/management/MetaDataNameProvider.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/deployers/spi/management/MetaDataNameProvider.java	2007-09-20 11:59:57 UTC (rev 65488)
@@ -0,0 +1,40 @@
+/*
+* 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.deployers.spi.management;
+
+import java.io.Serializable;
+
+/**
+ * Extracts name of runtime component from attachment.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface MetaDataNameProvider
+{
+   /**
+    * Extract name from attachment.
+    *
+     * @param attachment the attachment
+    * @return runtime component's name
+    */
+   Object getRuntimeComponentName(Serializable attachment);
+}

Added: trunk/system/src/main/org/jboss/deployers/spi/management/RuntimeComponentDispatcher.java
===================================================================
--- trunk/system/src/main/org/jboss/deployers/spi/management/RuntimeComponentDispatcher.java	                        (rev 0)
+++ trunk/system/src/main/org/jboss/deployers/spi/management/RuntimeComponentDispatcher.java	2007-09-20 11:59:57 UTC (rev 65488)
@@ -0,0 +1,52 @@
+/*
+* 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.deployers.spi.management;
+
+import java.io.Serializable;
+
+import org.jboss.metatype.api.values.MetaValue;
+
+/**
+ * Dispatches ManagedOperation invocation to runtime component
+ * associated with attachment.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface RuntimeComponentDispatcher
+{
+   /**
+    * Dispatch ManagedOperation invocation
+    * with param parameters to coresponding attachment.
+    *
+    * @param attachment the attachment
+    * @param methodName the methodName
+    * @param param the parameters
+    * @return runtime component's response
+    */
+   Object dispatch(Serializable attachment, String methodName, MetaValue... param);
+
+   /**
+    * Get the name provider - extracts name from attachment instance.
+    * @return
+    */
+   MetaDataNameProvider getNameProvider();
+}

Modified: trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java	2007-09-20 11:12:31 UTC (rev 65487)
+++ trunk/testsuite/src/main/org/jboss/test/profileservice/test/ProfileServiceUnitTestCase.java	2007-09-20 11:59:57 UTC (rev 65488)
@@ -25,23 +25,19 @@
 import java.util.HashSet;
 import java.util.Map;
 import java.util.Set;
-
 import javax.naming.InitialContext;
 
 import junit.framework.Test;
 import junit.framework.TestSuite;
-
 import org.jboss.deployers.spi.management.DeploymentTemplateInfo;
 import org.jboss.deployers.spi.management.ManagementView;
 import org.jboss.managed.api.ComponentType;
 import org.jboss.managed.api.ManagedComponent;
 import org.jboss.managed.api.ManagedDeployment;
+import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
 import org.jboss.managed.api.ManagedObject;
 import org.jboss.managed.api.ManagedOperation;
 import org.jboss.managed.api.ManagedProperty;
-import org.jboss.managed.api.ManagedDeployment.DeploymentPhase;
-import org.jboss.metatype.api.types.CompositeMetaType;
-import org.jboss.metatype.api.values.CompositeValueSupport;
 import org.jboss.metatype.api.values.GenericValue;
 import org.jboss.metatype.api.values.MetaValue;
 import org.jboss.metatype.api.values.SimpleValueSupport;
@@ -79,6 +75,7 @@
       suite.addTest(new ProfileServiceUnitTestCase("testDataSourceDeploymentType"));
       suite.addTest(new ProfileServiceUnitTestCase("testListDataSourceComponents"));
       suite.addTest(new ProfileServiceUnitTestCase("testUpdateDefaultDS"));
+      suite.addTest(new ProfileServiceUnitTestCase("testDefaultDSOps"));
       suite.addTest(new ProfileServiceUnitTestCase("testAddDataSource"));
       suite.addTest(new ProfileServiceUnitTestCase("testRemoveDataSource"));
       return suite;
@@ -336,17 +333,20 @@
       log.info("DefaultDS ops: "+ops);
       assertNotNull("Set<ManagedOperation>", ops);
       assertTrue("Set<ManagedOperation> > 0", ops.size() > 0);
-      ManagedOperation listFormatttedSubPoolStatistics = null;
+      ManagedOperation listFormattedSubPoolStatistics = null;
       for (ManagedOperation op : ops)
       {
-         if (op.getName().equals("listFormatttedSubPoolStatistics"))
-            listFormatttedSubPoolStatistics = op;
+         if (op.getName().equals("listFormattedSubPoolStatistics"))
+         {
+            listFormattedSubPoolStatistics = op;
+            break;
+         }
       }
-      assertNotNull("listFormatttedSubPoolStatistics", listFormatttedSubPoolStatistics);
+      assertNotNull("listFormattedSubPoolStatistics", listFormattedSubPoolStatistics);
       MetaValue[] params = {};
       // TODO: JBAS-4678 this should not be null
-      Object result = listFormatttedSubPoolStatistics.invoke(params);
-      log.info("listFormatttedSubPoolStatistics.invoke: "+result);
+      Object result = listFormattedSubPoolStatistics.invoke(params);
+      log.info("listFormattedSubPoolStatistics.invoke: "+result);
    }
 
    /**
@@ -373,8 +373,7 @@
       ManagedProperty password = props.get("password");
       password.setValue("");
       
-      mgtView.applyTemplate(DeploymentPhase.APPLICATION,
-            "testHqldbDS", dsInfo);
+      mgtView.applyTemplate(DeploymentPhase.APPLICATION, "testHqldbDS", dsInfo);
       mgtView.process();
    }
 
@@ -419,8 +418,7 @@
     * @return the matching ManagedComponent if found, null otherwise
     * @throws Exception
     */
-   protected ManagedComponent getManagedComponent(ManagementView mgtView,
-         ComponentType type, String name)
+   protected ManagedComponent getManagedComponent(ManagementView mgtView, ComponentType type, String name)
       throws Exception
    {
       Set<ManagedComponent> comps = mgtView.getComponentsForType(type);
@@ -431,6 +429,7 @@
         if( cname.endsWith(name) )
         {
            mc = comp;
+           break;
         }
       }
       return mc;




More information about the jboss-cvs-commits mailing list