[jboss-cvs] JBossAS SVN: r65493 - in projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel: plugins/dispatch and 2 other directories.

jboss-cvs-commits at lists.jboss.org jboss-cvs-commits at lists.jboss.org
Thu Sep 20 09:56:42 EDT 2007


Author: alesj
Date: 2007-09-20 09:56:42 -0400 (Thu, 20 Sep 2007)
New Revision: 65493

Added:
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dispatch/
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dispatch/AttributeKernelRegistryEntryJoinpoint.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dispatch/InvokeKernelRegistryEntryJoinpoint.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/registry/KernelRegistryEntryJoinpoint.java
Modified:
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/registry/basic/BasicKernelBus.java
   projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/registry/KernelBus.java
Log:
Updating KernelBus with Invoke/AttributeDispatchContext concept.

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dispatch/AttributeKernelRegistryEntryJoinpoint.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dispatch/AttributeKernelRegistryEntryJoinpoint.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dispatch/AttributeKernelRegistryEntryJoinpoint.java	2007-09-20 13:56:42 UTC (rev 65493)
@@ -0,0 +1,65 @@
+/*
+* 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.kernel.plugins.dispatch;
+
+import org.jboss.dependency.spi.dispatch.AttributeDispatchContext;
+import org.jboss.kernel.spi.registry.KernelRegistryEntry;
+import org.jboss.kernel.spi.registry.KernelRegistryEntryJoinpoint;
+import org.jboss.util.JBossObject;
+
+/**
+ * Attribute kernel registry entry joinpoint.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class AttributeKernelRegistryEntryJoinpoint extends JBossObject implements KernelRegistryEntryJoinpoint
+{
+   private String getterName;
+   private AttributeDispatchContext context;
+
+   public AttributeKernelRegistryEntryJoinpoint(String getterName)
+   {
+      this.getterName = getterName;
+   }
+
+   public boolean applyEntry(KernelRegistryEntry entry)
+   {
+      if (entry instanceof AttributeDispatchContext)
+      {
+         context = (AttributeDispatchContext)entry;
+         return true;
+      }
+      return false;
+   }
+
+   public Object dispatch() throws Throwable
+   {
+      if (context == null)
+         throw new IllegalArgumentException("Cannot dispatch null context.");
+      return context.get(getterName);
+   }
+
+   public String toHumanReadableString()
+   {
+      return getterName + "," + context;
+   }
+}

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dispatch/InvokeKernelRegistryEntryJoinpoint.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dispatch/InvokeKernelRegistryEntryJoinpoint.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/dispatch/InvokeKernelRegistryEntryJoinpoint.java	2007-09-20 13:56:42 UTC (rev 65493)
@@ -0,0 +1,69 @@
+/*
+* 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.kernel.plugins.dispatch;
+
+import org.jboss.kernel.spi.registry.KernelRegistryEntryJoinpoint;
+import org.jboss.kernel.spi.registry.KernelRegistryEntry;
+import org.jboss.dependency.spi.dispatch.InvokeDispatchContext;
+import org.jboss.util.JBossObject;
+
+/**
+ * Invoke kernel registry entry joinpoint.
+ * 
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class InvokeKernelRegistryEntryJoinpoint extends JBossObject implements KernelRegistryEntryJoinpoint
+{
+   private String methodName;
+   private Object[] args;
+   private String[] signature;
+   private InvokeDispatchContext context;
+
+   public InvokeKernelRegistryEntryJoinpoint(String methodName, Object[] args, String[] signature)
+   {
+      this.methodName = methodName;
+      this.args = args;
+      this.signature = signature;
+   }
+
+   public boolean applyEntry(KernelRegistryEntry entry)
+   {
+      if (entry instanceof InvokeDispatchContext)
+      {
+         context = (InvokeDispatchContext)entry;
+         return true;
+      }
+      return false;
+   }
+
+   public Object dispatch() throws Throwable
+   {
+      if (context == null)
+         throw new IllegalArgumentException("Cannot dispatch null context.");
+      return context.invoke(methodName, args, signature);
+   }
+
+   public String toHumanReadableString()
+   {
+      return methodName + "," + context;
+   }
+}

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/registry/basic/BasicKernelBus.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/registry/basic/BasicKernelBus.java	2007-09-20 13:53:03 UTC (rev 65492)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/registry/basic/BasicKernelBus.java	2007-09-20 13:56:42 UTC (rev 65493)
@@ -24,6 +24,7 @@
 import org.jboss.joinpoint.spi.TargettedJoinpoint;
 import org.jboss.kernel.plugins.registry.AbstractKernelBus;
 import org.jboss.kernel.spi.registry.KernelRegistryEntry;
+import org.jboss.kernel.spi.registry.KernelRegistryEntryJoinpoint;
 
 /**
  * Basic Kernel bus.
@@ -49,4 +50,12 @@
       joinPoint.setTarget(target);
       return joinPoint.dispatch();
    }
+
+   public Object invoke(Object name, KernelRegistryEntryJoinpoint joinPoint) throws Throwable
+   {
+      KernelRegistryEntry entry = registry.getEntry(name);
+      if (joinPoint.applyEntry(entry) == false)
+         throw new IllegalArgumentException("Cannot apply joinpoint " + joinPoint + " to entry " + entry);
+      return joinPoint.dispatch();
+   }
 }

Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/registry/KernelBus.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/registry/KernelBus.java	2007-09-20 13:53:03 UTC (rev 65492)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/registry/KernelBus.java	2007-09-20 13:56:42 UTC (rev 65493)
@@ -44,4 +44,14 @@
     * @throws Throwable for any error
     */
    Object invoke(Object name, TargettedJoinpoint joinPoint) throws Throwable;
+
+   /**
+    * Invoke an operation
+    *
+    * @param name the name of the object
+    * @param joinPoint the join point
+    * @return the result
+    * @throws Throwable for any error
+    */
+   Object invoke(Object name, KernelRegistryEntryJoinpoint joinPoint) throws Throwable;
 }

Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/registry/KernelRegistryEntryJoinpoint.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/registry/KernelRegistryEntryJoinpoint.java	                        (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/spi/registry/KernelRegistryEntryJoinpoint.java	2007-09-20 13:56:42 UTC (rev 65493)
@@ -0,0 +1,42 @@
+/*
+* 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.kernel.spi.registry;
+
+import org.jboss.joinpoint.spi.Joinpoint;
+
+/**
+ * A join point with a kernel registry entry
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public interface KernelRegistryEntryJoinpoint extends Joinpoint
+{
+   /**
+    * Apply the entry.
+    * Return false if the entry cannot be applied
+    * to joinpoint.
+    *
+    * @return false if entry cannot be applied to instance 
+    * @param entry the entry
+    */
+   boolean applyEntry(KernelRegistryEntry entry);
+}




More information about the jboss-cvs-commits mailing list