User: juha    
  Date: 00/05/29 11:26:32

  Added:       src/main/org/jboss/verifier/event VerificationListener.java
                        VerificationEventGeneratorSupport.java
                        VerificationEventGenerator.java
                        VerificationEventFactory.java
                        VerificationEvent.java
  Log:
  Initial Import.
  
  Revision  Changes    Path
  1.1                  
jboss/src/main/org/jboss/verifier/event/VerificationListener.java
  
  Index: VerificationListener.java
  ===================================================================
  package org.jboss.verifier.event;
  
  /*
   * Class org.jboss.verifier.event.VerificationListener
   * Copyright (C) 2000  Juha Lindfors
   *
   * This program is free software; you can redistribute it and/or
   * modify it under the terms of the GNU General Public License
   * as published by the Free Software Foundation; either version 2
   * of the License, or (at your option) any later version.
   *
   * This program 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 General Public License for more details.
   * 
   * You should have received a copy of the GNU General Public License
   * along with this program; if not, write to the Free Software
   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
   *
   * This package and its source code is available at www.gjt.org
   * $Id: VerificationListener.java,v 1.1 2000/05/29 18:26:31 juha Exp $
   *
   * You can reach the author by sending email to [EMAIL PROTECTED] or
   * directly to [EMAIL PROTECTED]
   */
  
  
  // standard imports
  import java.util.EventListener;
  
  
  // non-standard class dependencies
  
  
  /**
   * Listener for verification events.
   *
   * For more detailed documentation, refer to the
   * <a href="" << INSERT DOC LINK HERE >> </a>
   *
   * @see     << OTHER RELATED CLASSES >>
   *
   * @author    Juha Lindfors
   * @version $Revision: 1.1 $
   * @since     JDK 1.3
   */
  public interface VerificationListener extends EventListener {
  
      public void beanChecked(VerificationEvent event);
      
  }
  
  
  
  
  
  1.1                  
jboss/src/main/org/jboss/verifier/event/VerificationEventGeneratorSupport.java
  
  Index: VerificationEventGeneratorSupport.java
  ===================================================================
  package org.jboss.verifier.event;
  
  /*
   * Class org.jboss.verifier.event.VerificationEventGeneratorSupport
   * Copyright (C) 2000  Juha Lindfors
   *
   * This program is free software; you can redistribute it and/or
   * modify it under the terms of the GNU General Public License
   * as published by the Free Software Foundation; either version 2
   * of the License, or (at your option) any later version.
   *
   * This program 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 General Public License for more details.
   * 
   * You should have received a copy of the GNU General Public License
   * along with this program; if not, write to the Free Software
   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
   *
   * This package and its source code is available at www.gjt.org
   * $Id: VerificationEventGeneratorSupport.java,v 1.1 2000/05/29 18:26:31 juha Exp $
   *
   * You can reach the author by sending email to [EMAIL PROTECTED] or
   * directly to [EMAIL PROTECTED]
   */
  
  
  // standard imports
  import java.util.Enumeration;
  
  
  // non-standard class dependencies
  import org.gjt.lindfors.util.EventGeneratorSupport;
  import org.jboss.verifier.strategy.VerificationContext;
  
  
  /**
   * << DESCRIBE THE CLASS HERE >>
   *
   * For more detailed documentation, refer to the
   * <a href="" << INSERT DOC LINK HERE >> </a>
   *
   * @see     << OTHER RELATED CLASSES >>
   *
   * @author    Juha Lindfors
   * @version $Revision: 1.1 $
   * @since     JDK 1.3
   */
  public class VerificationEventGeneratorSupport extends EventGeneratorSupport {
  
      /*
       * Default constructor
       */
      public VerificationEventGeneratorSupport() {
  
          super();
  
      }
      
      public void addVerificationListener(VerificationListener listener) {
  
          super.addListener(listener);
  
      }
      
      public void removeVerificationListener(VerificationListener listener) {
  
          super.addListener(listener);
  
      }    
      
      
      /*
       * Fires the event to all VerificationListeners. Listeners implements the
       * beanChecked method and can pull the information from the event object
       * and decide how to handle the situation by themselves
       */
      public void fireBeanChecked(VerificationEvent event) {    
              
          Enumeration e = super.getListeners();
  
          while (e.hasMoreElements()) {
              VerificationListener listener = (VerificationListener) e.nextElement();
              listener.beanChecked(event);
          }
      }
      
      
  
  }
  
  
  
  
  1.1                  
jboss/src/main/org/jboss/verifier/event/VerificationEventGenerator.java
  
  Index: VerificationEventGenerator.java
  ===================================================================
  package org.jboss.verifier.event;
  
  /*
   * Class org.jboss.verifier.event.VerificationEventGenerator
   * Copyright (C) 2000  Juha Lindfors
   *
   * This program is free software; you can redistribute it and/or
   * modify it under the terms of the GNU General Public License
   * as published by the Free Software Foundation; either version 2
   * of the License, or (at your option) any later version.
   *
   * This program 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 General Public License for more details.
   * 
   * You should have received a copy of the GNU General Public License
   * along with this program; if not, write to the Free Software
   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
   *
   * This package and its source code is available at www.gjt.org
   * $Id: VerificationEventGenerator.java,v 1.1 2000/05/29 18:26:31 juha Exp $
   *
   * You can reach the author by sending email to [EMAIL PROTECTED] or
   * directly to [EMAIL PROTECTED]
   */
  
  
  // standard imports
  
  
  // non-standard class dependencies
  import org.gjt.lindfors.util.EventGenerator;
  
  
  /**
   * << DESCRIBE THE CLASS HERE >>
   *
   * For more detailed documentation, refer to the
   * <a href="" << INSERT DOC LINK HERE >> </a>
   *
   * @see     << OTHER RELATED CLASSES >>
   *
   * @author    Juha Lindfors
   * @version $Revision: 1.1 $
   * @since     JDK 1.3
   */
  public interface VerificationEventGenerator extends EventGenerator {
  
      abstract void addVerificationListener(VerificationListener listener);
      abstract void removeVerificationListener(VerificationListener listener);
      
      abstract void fireBeanChecked(VerificationEvent event);
  }
      
  
  
  
  
  1.1                  
jboss/src/main/org/jboss/verifier/event/VerificationEventFactory.java
  
  Index: VerificationEventFactory.java
  ===================================================================
  package org.jboss.verifier.event;
  
  /*
   * Class org.jboss.verifier.event.VerificationEventFactory
   * Copyright (C) 2000  Juha Lindfors
   *
   * This program is free software; you can redistribute it and/or
   * modify it under the terms of the GNU General Public License
   * as published by the Free Software Foundation; either version 2
   * of the License, or (at your option) any later version.
   *
   * This program 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 General Public License for more details.
   * 
   * You should have received a copy of the GNU General Public License
   * along with this program; if not, write to the Free Software
   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
   *
   * This package and its source code is available at www.gjt.org
   * $Id: VerificationEventFactory.java,v 1.1 2000/05/29 18:26:31 juha Exp $
   *
   * You can reach the author by sending email to [EMAIL PROTECTED] or
   * directly to [EMAIL PROTECTED]
   */
  
   
  // standard imports
  
  
  // non-standard class dependencies
  import org.jboss.verifier.strategy.VerificationContext;
  import org.jboss.verifier.strategy.EJBVerifier11;
  
  
  /**
   * Factory of verification events.
   * 
   * <p>
   *
   * This should actually be defined as an interface instead of concrete class
   * and provide implementations for this interface returning different types
   * of verification events (for example, a gui might want the event messages
   * to be styled).
   *
   * <p>
   *
   * For more detailed documentation, refer to the
   * <a href="" << INSERT DOC LINK HERE >> </a>
   *
   * @see     << OTHER RELATED CLASSES >>
   *
   * @author    Juha Lindfors
   * @version $Revision: 1.1 $
   * @since     JDK 1.3
   */
  public class VerificationEventFactory {
  
      /*
       * Default constructor.
       */
      public VerificationEventFactory()    {   }
      
      
      public VerificationEvent createSpecViolationEvent(
  
                                      VerificationEventGenerator source,
                                      String section,
                                      String name
                                                        )  {
                       
          VerificationEvent event = new VerificationEvent(source);
  
          
          if (EJBVerifier11.SECTION_6_5_1.equals(section))
              buildNoSessionBeanEvent(event, name);
              
          else if (EJBVerifier11.DTD_EJB_CLASS.equals(section))
              buildEJBClassNotFoundEvent(event, name);
              
  
          return event;                                     
      }
      
      public VerificationEvent createBeanVerifiedEvent(
      
                                      VerificationEventGenerator source,
                                      String name
                                                       )  {
          
          VerificationEvent event = new VerificationEvent(source);
          
          event.setState(VerificationEvent.OK);
          event.setMessage(name + " verified.");
          
          return event;
      }
  
      
  
  /*
   *****************************************************************************
   *****************************************************************************
   *
   *  PRIVATE INSTANCE METHODS
   *
   *****************************************************************************
   *****************************************************************************
   */
  
  
      private void buildNoSessionBeanEvent(VerificationEvent event, String name) {
          
          event.setMessage(SESSION_DOES_NOT_IMPLEMENT_SESSIONBEAN);
          event.setVerbose(SPEC_SECTION_6_5_1);
      }
      
      private void buildEJBClassNotFoundEvent(VerificationEvent event, String name) {
          
          event.setMessage(EJB_CLASS_ELEMENT_NOT_FOUND);
          event.setVerbose(DEPLOYMENT_DTD_EJB_CLASS);
      }
      
      
      
      
      private final static String SESSION_DOES_NOT_IMPLEMENT_SESSIONBEAN =
          "Session bean does not implement the required SessionBean interface.";
          
      private final static String SPEC_SECTION_6_5_1 = 
      
          VerificationContext.VERSION_1_1      + " " +
          "Section 6.5.1"                      + " " +
          "The required SessionBean interface" + " " +
          
          "\n" +
          
          "All session beans must implement the SessionBean interface";
  
          
      private final static String EJB_CLASS_ELEMENT_NOT_FOUND =
          "The enterprise bean's class was not found.";
          
      private final static String DEPLOYMENT_DTD_EJB_CLASS =
      
          VerificationContext.VERSION_1_1     + " " +
          "Section 16.5"                      + " " +
          "Deployment Description DTD"        + " " +
          
          "\n" +
          
          "The ejb-class element contains the fully-qualified name of the " + 
          "enterprise bean's class."                                        +
          
          "\n" +
          
          "Used in: entity and session"                                     +
          
          "\n" +
          
          "Example: <ejb-class>com.wombat.empl.EmployeeServiceBean</ejb-class>";
  
  
  }
  
  
  
  
  
  1.1                  jboss/src/main/org/jboss/verifier/event/VerificationEvent.java
  
  Index: VerificationEvent.java
  ===================================================================
  package org.jboss.verifier.event;
  
  /*
   * Class org.jboss.verifier.event.VerificationEvent
   * Copyright (C) 2000  Juha Lindfors
   *
   * This program is free software; you can redistribute it and/or
   * modify it under the terms of the GNU General Public License
   * as published by the Free Software Foundation; either version 2
   * of the License, or (at your option) any later version.
   *
   * This program 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 General Public License for more details.
   * 
   * You should have received a copy of the GNU General Public License
   * along with this program; if not, write to the Free Software
   * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
   *
   * This package and its source code is available at www.gjt.org
   * $Id: VerificationEvent.java,v 1.1 2000/05/29 18:26:31 juha Exp $
   *
   * You can reach the author by sending email to [EMAIL PROTECTED] or
   * directly to [EMAIL PROTECTED]
   */
  
  
  // standard imports
  import java.util.EventObject;
  
  
  // non-standard class dependencies
  
  
  /**
   * << DESCRIBE THE CLASS HERE >>
   *
   * For more detailed documentation, refer to the
   * <a href="" << INSERT DOC LINK HERE >> </a>
   *
   * @see     << OTHER RELATED CLASSES >>
   *
   * @author    Juha Lindfors
   * @version $Revision: 1.1 $
   * @since     JDK 1.3
   */
  public class VerificationEvent extends EventObject {
  
      public static final String WARNING  = "WARNING";
      public static final String OK       = "OK";
      
      private boolean isOk      = false;
      private boolean isWarning = false;
      
  
      /*
       * Contains a short, one line message for this event.
       */
      private String message = "<undefined>";
  
      /*
       * Contains a more verbose description of this event.
       */
      private String verbose = "";
      
      
      /*
       * Constructor
       */
      public VerificationEvent(VerificationEventGenerator source) {
          super(source);
      }
      
      public void setState(String state) {
          
          if (WARNING.equalsIgnoreCase(state)) {
              isWarning = true;
              isOk      = false;
          }
              
          else if (OK.equalsIgnoreCase(state)) {
              isOk      = true;
              isWarning = false;
          }
              
          else 
              throw new IllegalArgumentException(STATE_NOT_RECOGNIZED + ": " + state);
      }
      
      public boolean isOk() {
          return isOk;
      }
      
      public boolean isWarning() {
          return isWarning;
      }
      
      public void setMessage(String msg) {
          this.message = msg;
      }
      
      public void setVerbose(String msg) {
          this.verbose = msg;
      }
      
      public String getMessage() {
          return message;
      }
      
      public String getVerbose() {
          return verbose;
      }
      
      /*
       * String constants
       */
      private final static String STATE_NOT_RECOGNIZED =
          "Unknown event state";
  
  }
  
  
  
  

Reply via email to