mcconnell 2004/01/13 10:39:38
Modified: merlin/kernel/api/src/java/org/apache/avalon/merlin
Kernel.java
merlin/kernel/api/src/java/org/apache/avalon/merlin/event
KernelEventListener.java
Added: merlin/kernel/api/src/java/org/apache/avalon/merlin
KernelError.java
merlin/kernel/api/src/java/org/apache/avalon/merlin/event
KernelStateEvent.java
Log:
A support for kernel events so that we can seperate out the jmx management content
to an independent facility.
Revision Changes Path
1.2 +25 -1
avalon/merlin/kernel/api/src/java/org/apache/avalon/merlin/Kernel.java
Index: Kernel.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/kernel/api/src/java/org/apache/avalon/merlin/Kernel.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- Kernel.java 8 Dec 2003 15:37:12 -0000 1.1
+++ Kernel.java 13 Jan 2004 18:39:38 -0000 1.2
@@ -50,6 +50,7 @@
package org.apache.avalon.merlin;
+import org.apache.avalon.merlin.event.KernelEventListener;
import org.apache.avalon.activation.appliance.Appliance;
import org.apache.avalon.activation.appliance.Block;
@@ -63,6 +64,29 @@
*/
public interface Kernel extends KernelController
{
+ static final int INITIALIZING = 0;
+ static final int INITIALIZED = 1;
+ static final int STARTING = 2;
+ static final int ASSEMBLY = 3;
+ static final int DEPLOYMENT = 4;
+ static final int STARTED = 5;
+ static final int STOPPING = 6;
+ static final int DECOMMISSIONING = 7;
+ static final int DISSASSEMBLY = 8;
+ static final int STOPPED = 9;
+
+ /**
+ * Add a kernel listener.
+ * @param listener the kernel listener to be added
+ */
+ void addKernelEventListener( KernelEventListener listener );
+
+ /**
+ * Remove a kernel listener.
+ * @param listener the kernel listener to be removed
+ */
+ void removeKernelEventListener( KernelEventListener listener );
+
/**
* Return the root block.
* @return the root application containment block
1.1
avalon/merlin/kernel/api/src/java/org/apache/avalon/merlin/KernelError.java
Index: KernelError.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Jakarta", "Apache Avalon", "Avalon Framework" and
"Apache Software Foundation" must not be used to endorse or promote
products derived from this software without prior written
permission. For written permission, please contact [EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation. For more information on the
Apache Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.avalon.merlin;
import org.apache.avalon.framework.CascadingError;
/**
* Exception to indicate that there was a kernel error.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Avalon Development Team</a>
* @version $Revision: 1.1 $ $Date: 2004/01/13 18:39:38 $
*/
public class KernelError
extends CascadingError
{
/**
* Construct a new <code>KernelError</code> instance.
*
* @param message The detail message for this exception.
*/
public KernelError( final String message )
{
this( message, null );
}
/**
* Construct a new <code>KernelError</code> instance.
*
* @param message The detail message for this exception.
* @param throwable the root cause of the exception
*/
public KernelError( final String message, final Throwable throwable )
{
super( message, throwable );
}
}
1.3 +2 -9
avalon/merlin/kernel/api/src/java/org/apache/avalon/merlin/event/KernelEventListener.java
Index: KernelEventListener.java
===================================================================
RCS file:
/home/cvs/avalon/merlin/kernel/api/src/java/org/apache/avalon/merlin/event/KernelEventListener.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- KernelEventListener.java 13 Jan 2004 11:41:31 -0000 1.2
+++ KernelEventListener.java 13 Jan 2004 18:39:38 -0000 1.3
@@ -66,13 +66,6 @@
*
* @param event the kernel event
*/
- void started( KernelEvent event );
-
- /**
- * Notify the listener that the kernel has started.
- *
- * @param event the kernel event
- */
- void stopped( KernelEvent event );
+ void stateChanged( KernelStateEvent event );
}
1.1
avalon/merlin/kernel/api/src/java/org/apache/avalon/merlin/event/KernelStateEvent.java
Index: KernelStateEvent.java
===================================================================
/*
============================================================================
The Apache Software License, Version 1.1
============================================================================
Copyright (C) 1999-2002 The Apache Software Foundation. All rights reserved.
Redistribution and use in source and binary forms, with or without modifica-
tion, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
3. The end-user documentation included with the redistribution, if any, must
include the following acknowledgment: "This product includes software
developed by the Apache Software Foundation (http://www.apache.org/)."
Alternately, this acknowledgment may appear in the software itself, if
and wherever such third-party acknowledgments normally appear.
4. The names "Jakarta", "Apache Avalon", "Avalon Framework" and
"Apache Software Foundation" must not be used to endorse or promote
products derived from this software without prior written
permission. For written permission, please contact [EMAIL PROTECTED]
5. Products derived from this software may not be called "Apache", nor may
"Apache" appear in their name, without prior written permission of the
Apache Software Foundation.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
APACHE SOFTWARE FOUNDATION OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLU-
DING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This software consists of voluntary contributions made by many individuals
on behalf of the Apache Software Foundation. For more information on the
Apache Software Foundation, please see <http://www.apache.org/>.
*/
package org.apache.avalon.merlin.event;
import java.util.EventObject;
import org.apache.avalon.merlin.Kernel;
/**
* A event raised by a kernel signaling a state change.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Stephen McConnell</a>
* @version $Revision: 1.1 $ $Date: 2004/01/13 18:39:38 $
*/
public class KernelStateEvent extends KernelEvent
{
private final int m_from;
private final int m_to;
/**
* Create a CompositionEvent event.
*
* @param kernel the kernel instance raising the event
* @param from the old state value
* @param to the new state value
*/
public KernelStateEvent( final Kernel kernel, int from, int to )
{
super( kernel );
m_from = from;
m_to = to;
}
/**
* Return the initial state before the transition.
*
* @return the source kernel
*/
public int getInitialState()
{
return m_from;
}
/**
* Return the state by the transition.
*
* @return the source kernel
*/
public int getCurrentState()
{
return m_to;
}
public String toString()
{
return "kernel-event: ["
+ getKernel()
+ " (" + getInitialState()
+ "/" + getCurrentState()
+ ")]";
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]