[jboss-cvs] JBossAS SVN: r65835 - in projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins: bootstrap/basic and 2 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Thu Oct 4 08:08:53 EDT 2007
Author: alesj
Date: 2007-10-04 08:08:53 -0400 (Thu, 04 Oct 2007)
New Revision: 65835
Added:
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/registry/BeanKernelRegistryEntry.java
Modified:
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/AbstractKernelObject.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/bootstrap/basic/BasicKernelInitializer.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/registry/AbstractKernelBus.java
projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/registry/basic/BasicKernelBus.java
Log:
Moving KernelBus lookup to Controller.getInstalledContext.
Adding BeanInfo aware KernelRegistryEntry for Kernel objects.
Removing empty constructors.
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/AbstractKernelObject.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/AbstractKernelObject.java 2007-10-04 11:08:45 UTC (rev 65834)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/AbstractKernelObject.java 2007-10-04 12:08:53 UTC (rev 65835)
@@ -40,13 +40,6 @@
/** The kernel */
protected Kernel kernel;
- /**
- * Create a new abstract kernel object
- */
- public AbstractKernelObject()
- {
- }
-
public Kernel getKernel()
{
Kernel.checkAccess();
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/bootstrap/basic/BasicKernelInitializer.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/bootstrap/basic/BasicKernelInitializer.java 2007-10-04 11:08:45 UTC (rev 65834)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/bootstrap/basic/BasicKernelInitializer.java 2007-10-04 12:08:53 UTC (rev 65835)
@@ -21,9 +21,11 @@
*/
package org.jboss.kernel.plugins.bootstrap.basic;
+import org.jboss.beans.info.spi.BeanInfo;
import org.jboss.kernel.Kernel;
import org.jboss.kernel.plugins.bootstrap.AbstractKernelInitializer;
-import org.jboss.kernel.plugins.registry.AbstractKernelRegistryEntry;
+import org.jboss.kernel.plugins.registry.BeanKernelRegistryEntry;
+import org.jboss.kernel.spi.config.KernelConfig;
import org.jboss.kernel.spi.config.KernelConfigurator;
import org.jboss.kernel.spi.dependency.KernelController;
import org.jboss.kernel.spi.event.KernelEventManager;
@@ -68,12 +70,6 @@
eventManager.setKernel(kernel);
kernel.setEventManager(eventManager);
- KernelBus bus = createKernelBus(kernel);
- if (trace)
- log.trace("Using Bus: " + bus);
- bus.setKernel(kernel);
- kernel.setBus(bus);
-
KernelConfigurator configurator = createKernelConfigurator(kernel);
if (trace)
log.trace("Using Configurator: " + configurator);
@@ -86,6 +82,12 @@
controller.setKernel(kernel);
kernel.setController(controller);
+ KernelBus bus = createKernelBus(kernel);
+ if (trace)
+ log.trace("Using Bus: " + bus);
+ bus.setKernel(kernel);
+ kernel.setBus(bus);
+
// Register everything
register(kernel, KernelConstants.KERNEL_CONFIG_NAME, kernel.getConfig());
register(kernel, KernelConstants.KERNEL_INITIALIZER_NAME, this);
@@ -220,10 +222,8 @@
*/
protected KernelRegistryEntry createKernelRegistryEntry(Kernel kernel, Object object) throws Throwable
{
- // @TODO add beaninfo to registry entry?
- // KernelConfig config = kernel.getConfig();
- // BeanInfoFactory factory = config.getDefaultBeanInfoFactory();
- // BeanInfo info = factory.getBeanInfo(object.getClass());
- return new AbstractKernelRegistryEntry(object);
+ KernelConfig config = kernel.getConfig();
+ BeanInfo info = config.getBeanInfo(object.getClass());
+ return new BeanKernelRegistryEntry(object, info);
}
}
Modified: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/registry/AbstractKernelBus.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/registry/AbstractKernelBus.java 2007-10-04 11:08:45 UTC (rev 65834)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/registry/AbstractKernelBus.java 2007-10-04 12:08:53 UTC (rev 65835)
@@ -23,32 +23,23 @@
import org.jboss.kernel.Kernel;
import org.jboss.kernel.plugins.AbstractKernelObject;
+import org.jboss.kernel.spi.dependency.KernelController;
import org.jboss.kernel.spi.registry.KernelBus;
-import org.jboss.kernel.spi.registry.KernelRegistry;
/**
* Abstract Kernel bus.
*
* @author <a href="adrian at jboss.com">Adrian Brock</a>
- * @version $Revision$
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
*/
public abstract class AbstractKernelBus extends AbstractKernelObject implements KernelBus
{
- /** The registry */
- protected KernelRegistry registry;
+ /** The controller */
+ protected KernelController controller;
- /**
- * Create an abstract kernel bus
- *
- * @throws Exception for any error
- */
- public AbstractKernelBus() throws Exception
- {
- }
-
public void setKernel(Kernel kernel) throws Throwable
{
super.setKernel(kernel);
- registry = kernel.getRegistry();
+ controller = kernel.getController();
}
}
Added: projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/registry/BeanKernelRegistryEntry.java
===================================================================
--- projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/registry/BeanKernelRegistryEntry.java (rev 0)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/registry/BeanKernelRegistryEntry.java 2007-10-04 12:08:53 UTC (rev 65835)
@@ -0,0 +1,59 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.kernel.plugins.registry;
+
+import org.jboss.beans.info.spi.BeanInfo;
+import org.jboss.dependency.spi.dispatch.AttributeDispatchContext;
+
+/**
+ * Bean Kernel registry entry.
+ *
+ * @author <a href="ales.justin at jboss.com">Ales Justin</a>
+ */
+public class BeanKernelRegistryEntry extends AbstractKernelRegistryEntry implements AttributeDispatchContext
+{
+ private BeanInfo beanInfo;
+
+ public BeanKernelRegistryEntry(Object target, BeanInfo beanInfo)
+ {
+ super(target);
+ if (beanInfo == null)
+ throw new IllegalArgumentException("Null bean info.");
+ this.beanInfo = beanInfo;
+ }
+
+ public BeanKernelRegistryEntry(Object name, Object target, BeanInfo beanInfo)
+ {
+ super(name, target);
+ this.beanInfo = beanInfo;
+ }
+
+ public Object get(String name) throws Throwable
+ {
+ return beanInfo.getProperty(target, name);
+ }
+
+ public void set(String name, Object value) throws Throwable
+ {
+ beanInfo.setProperty(target, name, value);
+ }
+}
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-10-04 11:08:45 UTC (rev 65834)
+++ projects/microcontainer/trunk/kernel/src/main/org/jboss/kernel/plugins/registry/basic/BasicKernelBus.java 2007-10-04 12:08:53 UTC (rev 65835)
@@ -21,10 +21,10 @@
*/
package org.jboss.kernel.plugins.registry.basic;
+import org.jboss.dependency.spi.ControllerContext;
import org.jboss.dependency.spi.dispatch.AttributeDispatchContext;
import org.jboss.dependency.spi.dispatch.InvokeDispatchContext;
import org.jboss.kernel.plugins.registry.AbstractKernelBus;
-import org.jboss.kernel.spi.registry.KernelRegistryEntry;
/**
* Basic Kernel bus.
@@ -35,15 +35,6 @@
public class BasicKernelBus extends AbstractKernelBus
{
/**
- * Create a new basic bus
- *
- * @throws Exception for any error
- */
- public BasicKernelBus() throws Exception
- {
- }
-
- /**
* Execute dispatch.
*
* @param <T> exact context type
@@ -55,11 +46,11 @@
*/
protected <T> Object execute(Object name, Class<T> clazz, Dispatcher<T> dispatcher) throws Throwable
{
- KernelRegistryEntry entry = registry.getEntry(name);
+ ControllerContext context = controller.getInstalledContext(name);
// entry is not null by KernelRegistry.getEntry contract
- if (clazz.isAssignableFrom(entry.getClass()) == false)
- throw new IllegalArgumentException("Cannot execute " + dispatcher + " on non " + clazz.getSimpleName() + " entry: " + entry);
- return dispatcher.dispatch(clazz.cast(entry));
+ if (clazz.isAssignableFrom(context.getClass()) == false)
+ throw new IllegalArgumentException("Cannot execute " + dispatcher + " on non " + clazz.getSimpleName() + " context: " + context);
+ return dispatcher.dispatch(clazz.cast(context));
}
public Object get(Object name, final String getter) throws Throwable
@@ -123,7 +114,7 @@
*
* @param context the context
* @throws Throwable for any error
- * @return
+ * @return dispatch's invocation result
*/
Object dispatch(T context) throws Throwable;
}
More information about the jboss-cvs-commits
mailing list