[jboss-cvs] JBossAS SVN: r65508 - trunk/profileservice/src/main/org/jboss/profileservice/management.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Sep 20 14:07:37 EDT 2007
Author: alesj
Date: 2007-09-20 14:07:37 -0400 (Thu, 20 Sep 2007)
New Revision: 65508
Added:
trunk/profileservice/src/main/org/jboss/profileservice/management/KernelBusRuntimeComponentDispatcher.java
Log:
ManagedOperation invocation over KernelBus.
Added: trunk/profileservice/src/main/org/jboss/profileservice/management/KernelBusRuntimeComponentDispatcher.java
===================================================================
--- trunk/profileservice/src/main/org/jboss/profileservice/management/KernelBusRuntimeComponentDispatcher.java (rev 0)
+++ trunk/profileservice/src/main/org/jboss/profileservice/management/KernelBusRuntimeComponentDispatcher.java 2007-09-20 18:07:37 UTC (rev 65508)
@@ -0,0 +1,103 @@
+/*
+* 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;
+
+/**
+ * Microcontainer KernelBus runtime component dispatcher.
+ *
+ * @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
+ */
+public class KernelBusRuntimeComponentDispatcher {}
+/*
+ implements RuntimeComponentDispatcher
+{
+ private KernelBus bus;
+ private MetaDataNameProvider provider;
+
+ @Constructor
+ public KernelBusRuntimeComponentDispatcher(@Inject(bean= KernelConstants.KERNEL_BUS_NAME) KernelBus bus)
+ {
+ if (bus == null)
+ throw new IllegalArgumentException("Null kernel bus.");
+ this.bus = bus;
+ this.provider = new BasicMetaDataNameProvider();
+ }
+
+ public Object dispatch(Serializable attachment, String methodName, MetaValue... param)
+ {
+ Object name = provider.getRuntimeComponentName(attachment);
+ try
+ {
+ return bus.invoke(name, new InvokeMetaValueJoinpoint(methodName, param));
+ }
+ catch (Throwable t)
+ {
+ throw new RuntimeException(t);
+ }
+ }
+
+ public MetaDataNameProvider getNameProvider()
+ {
+ return provider;
+ }
+
+ public void setProvider(MetaDataNameProvider provider)
+ {
+ this.provider = provider;
+ }
+
+ private static class InvokeMetaValueJoinpoint extends InvokeKernelRegistryEntryJoinpoint
+ {
+ public InvokeMetaValueJoinpoint(String string, MetaValue... param)
+ {
+ super(string, toArguments(param), toSignature(param));
+ }
+
+ private static Object value(MetaValue value)
+ {
+ if (value instanceof SimpleValue == false)
+ throw new IllegalArgumentException("Cannot get value from non Simple value: " + value);
+ return ((SimpleValue)value).getValue();
+ }
+
+ private static Object[] toArguments(MetaValue... param)
+ {
+ Object[] args = new Object[param.length];
+ for(int i=0; i < param.length; i++)
+ {
+ args[i] = value(param[i]);
+ }
+ return param;
+ }
+
+ private static String[] toSignature(MetaValue... param)
+ {
+ String[] signature = new String[param.length];
+ for(int i=0; i < param.length; i++)
+ {
+ signature[i] = param[i].getMetaType().getClassName();
+ }
+ return signature;
+ }
+ }
+}
+*/
More information about the jboss-cvs-commits
mailing list