[jboss-cvs] jboss-seam/src/ioc/org/jboss/seam/ioc/microcontainer ...
Ales Justin
ajustin at redhat.com
Tue Mar 13 12:52:20 EDT 2007
User: alesj
Date: 07/03/13 12:52:20
Modified: src/ioc/org/jboss/seam/ioc/microcontainer
JMXNotificationComponentMBean.java
JMXNotificationComponent.java
Added: src/ioc/org/jboss/seam/ioc/microcontainer
KernelLocator.java PojoNotificationComponent.java
Log:
Notification component abstraction - Pojo notification.
Revision Changes Path
1.2 +1 -1 jboss-seam/src/ioc/org/jboss/seam/ioc/microcontainer/JMXNotificationComponentMBean.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: JMXNotificationComponentMBean.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/ioc/org/jboss/seam/ioc/microcontainer/JMXNotificationComponentMBean.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- JMXNotificationComponentMBean.java 6 Mar 2007 00:17:14 -0000 1.1
+++ JMXNotificationComponentMBean.java 13 Mar 2007 16:52:20 -0000 1.2
@@ -23,5 +23,5 @@
public interface JMXNotificationComponentMBean
{
- void destroy();
+ void removeComponents() throws Throwable;
}
1.2 +9 -4 jboss-seam/src/ioc/org/jboss/seam/ioc/microcontainer/JMXNotificationComponent.java
(In the diff below, changes in quantity of whitespace are not shown.)
Index: JMXNotificationComponent.java
===================================================================
RCS file: /cvsroot/jboss/jboss-seam/src/ioc/org/jboss/seam/ioc/microcontainer/JMXNotificationComponent.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -b -r1.1 -r1.2
--- JMXNotificationComponent.java 6 Mar 2007 00:17:14 -0000 1.1
+++ JMXNotificationComponent.java 13 Mar 2007 16:52:20 -0000 1.2
@@ -30,6 +30,7 @@
import org.jboss.seam.Component;
import static org.jboss.seam.InterceptionType.NEVER;
import org.jboss.seam.annotations.Install;
+import static org.jboss.seam.annotations.Install.FRAMEWORK;
import org.jboss.seam.annotations.Intercept;
import org.jboss.seam.annotations.Startup;
import org.jboss.system.ServiceControllerMBean;
@@ -42,8 +43,8 @@
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
*/
@Intercept(NEVER)
- at Install(false)
@Startup
+ at Install(value = false, precedence = FRAMEWORK)
public class JMXNotificationComponent extends ControllerNotificationComponent implements JMXNotificationComponentMBean, Serializable
{
/**
@@ -55,7 +56,7 @@
protected ObjectName createObjectName(Component component) throws Exception
{
- return new ObjectName("seam:name=" + getClass().getSimpleName() + "." + component.getName());
+ return new ObjectName("seam:service=" + getClass().getSimpleName() + "." + component.getName());
}
protected void notifyController(Component component) throws Throwable
@@ -70,6 +71,11 @@
objectName = null;
}
+ public void removeComponents() throws Throwable
+ {
+ clearNotification();
+ }
+
protected void handleJMXRegistration(boolean register) throws Exception
{
MBeanServer server = MBeanServerLocator.locateJBoss();
@@ -82,12 +88,11 @@
// we want it to be installed
serviceController.start(objectName);
}
- else
+ else if (objectName != null)
{
// destroy it
serviceController.destroy(objectName);
serviceController.remove(objectName);
- server.unregisterMBean(objectName);
}
}
1.1 date: 2007/03/13 16:52:20; author: alesj; state: Exp;jboss-seam/src/ioc/org/jboss/seam/ioc/microcontainer/KernelLocator.java
Index: KernelLocator.java
===================================================================
/*
* 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.seam.ioc.microcontainer;
import org.jboss.kernel.Kernel;
import org.jboss.seam.log.LogProvider;
import org.jboss.seam.log.Logging;
/**
* Kernel instance holder.
*
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
*/
public class KernelLocator
{
private static KernelLocator instance;
private static LogProvider log = Logging.getLogProvider(KernelLocator.class);
private Kernel kernel;
private KernelLocator() {}
public static KernelLocator getInstance()
{
if (instance == null)
{
if (log.isDebugEnabled())
{
log.debug("Instantiating new KernelLocator.");
}
instance = new KernelLocator();
}
return instance;
}
public Kernel getKernel()
{
return kernel;
}
public void setKernel(Kernel kernel)
{
if (log.isDebugEnabled())
{
log.debug("Setting the current Kernel instance: " + kernel);
}
this.kernel = kernel;
}
}
1.1 date: 2007/03/13 16:52:20; author: alesj; state: Exp;jboss-seam/src/ioc/org/jboss/seam/ioc/microcontainer/PojoNotificationComponent.java
Index: PojoNotificationComponent.java
===================================================================
/*
* 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.seam.ioc.microcontainer;
import java.io.Serializable;
import org.jboss.beans.metadata.plugins.AbstractBeanMetaData;
import org.jboss.kernel.Kernel;
import org.jboss.kernel.spi.dependency.KernelController;
import org.jboss.seam.Component;
import org.jboss.seam.InterceptionType;
import org.jboss.seam.annotations.Install;
import org.jboss.seam.annotations.Intercept;
import org.jboss.seam.annotations.Startup;
/**
* Notifies Seam components in current underlying Microcontainer Controller.
* It adds component to the underlying controller with PojoNotificationComponent.<component_name> name.
* Other Seam components need to depend on this name.
*
* @author <a href="mailto:ales.justin at jboss.com">Ales Justin</a>
*/
@Intercept(InterceptionType.NEVER)
@Startup
@Install(value = false, precedence = Install.FRAMEWORK)
public class PojoNotificationComponent extends ControllerNotificationComponent implements Serializable
{
/**
* The serialVersionUID
*/
private static final long serialVersionUID = 1L;
private String componentName;
protected Kernel getKernel()
{
Kernel kernel = KernelLocator.getInstance().getKernel();
if (kernel == null)
throw new IllegalArgumentException("Kernel instance is null, add KernelLocator to -beans.xml!");
return kernel;
}
protected void notifyController(Component component) throws Throwable
{
Class<PojoNotificationComponent> clazz = PojoNotificationComponent.class;
componentName = clazz.getSimpleName() + "." + component.getName();
KernelController controller = getKernel().getController();
AbstractBeanMetaData beanMetaData = new AbstractBeanMetaData(componentName, clazz.getName());
controller.install(beanMetaData, this);
}
protected void clearNotification() throws Throwable
{
KernelController controller = getKernel().getController();
controller.uninstall(componentName);
componentName = null;
}
}
More information about the jboss-cvs-commits
mailing list