geronimo-scm mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gr...@apache.org
Subject cvs commit: incubator-geronimo/modules/core/src/java/org/apache/geronimo/management NotificationType.java State.java StateManageable.java
Date Wed, 20 Aug 2003 07:13:10 GMT
gregw       2003/08/20 00:13:10

  Added:       modules/core/src/java/org/apache/geronimo/management
                        NotificationType.java State.java
                        StateManageable.java
  Log:
  Moved jsr77 model classes back to core module
  
  Revision  Changes    Path
  1.1                  incubator-geronimo/modules/core/src/java/org/apache/geronimo/management/NotificationType.java
  
  Index: NotificationType.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, 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 "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", 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 (INCLUDING, 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.geronimo.management;
  
  import javax.management.Notification;
  import javax.management.NotificationFilter;
  
  /**
   * Static constants class which contains all of the J2EE notification types from the
   * J2EE management specification.
   *
   * @version $Revision: 1.1 $ $Date: 2003/08/20 07:13:09 $
   */
  public final class NotificationType {
      private NotificationType() {
      }
  
      /**
       * A new managed object was created.
       */
      public static final String OBJECT_CREATED = "j2ee.object.created";
  
      /**
       * A managed object was deleted
       */
      public static final String OBJECT_DELETED = "j2ee.object.deleted";
  
      /**
       * A state manageable object entered the starting state
       */
      public static final String STATE_STARTING = "j2ee.state.starting";
  
      /**
       * A state manageable object entered the running state
       */
      public static final String STATE_RUNNING = "j2ee.state.running";
  
      /**
       * A state manageable object entered the stopping state
       */
      public static final String STATE_STOPPING = "j2ee.state.stopping";
  
      /**
       * A state manageable object entered the stopped state.
       */
      public static final String STATE_STOPPED = "j2ee.state.stopped";
  
      /**
       * A state manageable object entered the failed state
       */
      public static final String STATE_FAILED = "j2ee.state.failed";
  
      /**
       * An attribute has change value
       */
      public static final String ATTRIBUTE_CHANGED = "j2ee.attribute.changed";
  
      /**
       * An array containg all of the know J2EE notification types
       */
      public static final String[] TYPES = new String[]{
          OBJECT_CREATED, OBJECT_DELETED,
          STATE_STARTING, STATE_RUNNING, STATE_STOPPING, STATE_STOPPED, STATE_FAILED,
          ATTRIBUTE_CHANGED
      };
  
      /**
       * A notification filter which lets all J2EE notifications pass
       */
      public static final NotificationFilter NOTIFICATION_FILTER = new J2EENotificationFilter();
  
      private static final class J2EENotificationFilter implements NotificationFilter {
          private J2EENotificationFilter() {
          }
  
          public boolean isNotificationEnabled(Notification notification) {
              String type = notification.getType();
              for (int i = 0; i < TYPES.length; i++) {
                  if(TYPES[i].equals(type)) {
                      return true;
                  }
              }
              return false;
          }
      };
  }
  
  
  
  1.1                  incubator-geronimo/modules/core/src/java/org/apache/geronimo/management/State.java
  
  Index: State.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, 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 "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", 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 (INCLUDING, 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.geronimo.management;
  
  /**
   * This class contains a type safe enumeration of the states from the J2EE Management specification.
   *
   * @version $Revision: 1.1 $ $Date: 2003/08/20 07:13:09 $
   */
  public final class State {
      public static final int STARTING_INDEX = 0;
      public static final int RUNNING_INDEX = 1;
      public static final int STOPPING_INDEX = 2;
      public static final int STOPPED_INDEX = 3;
      public static final int FAILED_INDEX = 4;
  
      public static final State STARTING = new State("starting", STARTING_INDEX, NotificationType.STATE_STARTING);
      public static final State RUNNING = new State("running", RUNNING_INDEX, NotificationType.STATE_RUNNING);
      public static final State STOPPING = new State("stopping", STOPPING_INDEX, NotificationType.STATE_STOPPING);
      public static final State STOPPED = new State("stopped", STOPPED_INDEX, NotificationType.STATE_STOPPED);
      public static final State FAILED = new State("failed", FAILED_INDEX, NotificationType.STATE_FAILED);
  
      private static final State[] fromInt = {STARTING, RUNNING, STOPPING, STOPPED, FAILED};
  
      /**
       * Get a State from an int index
       * @param index int index of the state
       * @return The State instance or null if no such State.
       */
      public static State fromInt(int index) {
          if (index < 0 || index >= fromInt.length) {
              return null;
          }
          return fromInt[index];
      }
  
      /**
       * The user readable name of this state from the J2EE Management specification
       */
      private final String name;
  
      /**
       * The state index from the J2EE Management specification
       */
      private final int index;
  
      /**
       * Type value to be broadcasted on entering this state.
       */
      private final String eventTypeValue;
  
      private State(String name, int index, String anEventTypeValue) {
          this.name = name;
          this.index = index;
          eventTypeValue = anEventTypeValue;
      }
  
      /**
       * Gets the integer value of this state as specified in the J2EE Management specification
       * @return
       */
      public int toInt() {
          return index;
      }
  
      /**
       * Gets the event type that should be send after changeing to this state.
       * @return the event type that should be sent after a transistion to this state
       */
      public String getEventTypeValue() {
          return eventTypeValue;
      }
  
      public String toString() {
          return name;
      }
  }
  
  
  
  1.1                  incubator-geronimo/modules/core/src/java/org/apache/geronimo/management/StateManageable.java
  
  Index: StateManageable.java
  ===================================================================
  /* ====================================================================
   * The Apache Software License, Version 1.1
   *
   * Copyright (c) 2003 The Apache Software Foundation.  All rights
   * reserved.
   *
   * Redistribution and use in source and binary forms, with or without
   * modification, 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 "Apache" and "Apache Software Foundation" and
   *    "Apache Geronimo" must not be used to endorse or promote products
   *    derived from this software without prior written permission. For
   *    written permission, please contact apache@apache.org.
   *
   * 5. Products derived from this software may not be called "Apache",
   *    "Apache Geronimo", 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 (INCLUDING, 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.geronimo.management;
  
  
  /**
   * A Java interface the meets the J2EE Management specification for a state manageable object.
   *
   * @version $Revision: 1.1 $ $Date: 2003/08/20 07:13:09 $
   */
  public interface StateManageable {
      /**
       * Gets the state of this component as an int.
       * The int return is required by the JSR77 specification.
       * @see #getStateInstance to obtain the State instance
       * @return the current state of this component
       */
      int getState();
  
      /**
       * Gets the state of this component as a State instance.
       * @return the current state of this component
       */
      State getStateInstance();
  
      /**
       * Gets the start time of this component
       * @return time in milliseonds since epoch that this component was started.
       */
      long getStartTime();
  
  
      /**
       * Transitions the component to the starting state.  This method has access to the
       * container.
       *
       * Normally a component uses this to cache data from other components. The other components
will
       * have been created at this stage, but not necessairly started and may not be ready
to have methods
       * invoked on them.
       *
       * @throws java.lang.Exception if a problem occurs during the transition
       * @throws java.lang.IllegalStateException if this interceptor is not in the stopped
or failed state
       */
      void start() throws Exception, IllegalStateException;
  
      /**
       * Transitions the component to the starting state.  This method has access to the
       * container.
       *
       * If this Component is a Container, then startRecursive is called on all child Components
       * that are in the STOPPED or FAILED state.
       * Normally a component uses this to cache data from other components. The other components
will
       * have been created at this stage, but not necessairly started and may not be ready
to have methods
       * invoked on them.
       *
       * @throws java.lang.Exception if a problem occurs during the transition
       * @throws java.lang.IllegalStateException if this interceptor is not in the STOPPED
or FAILED state
       */
      void startRecursive() throws Exception, IllegalStateException;
  
      /**
       * Transitions the component to the stopping state.  This method has access to the
       * container.
       *
       * If this is Component is a Container, then all its child components must be in the
       * STOPPED or FAILED State.
       *
       * Normally a component uses this to drop references to data cached in the start method.
       * The other components will not necessairly have been stopped at this stage and may
not be ready
       * to have methods invoked on them.
       *
       * @throws java.lang.Exception if a problem occurs during the transition
       * @throws java.lang.IllegalStateException if this interceptor is not in the STOPPED
or FAILED state
       */
      void stop() throws Exception, IllegalStateException;
  
  }
  
  
  

Mime
View raw message