commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From oalex...@apache.org
Subject cvs commit: jakarta-commons-sandbox/services/src/java/org/apache/commons/services EventFactory.java
Date Wed, 19 Dec 2001 16:40:52 GMT
oalexeev    01/12/19 08:40:52

  Added:       services/src/java/org/apache/commons/services
                        EventFactory.java
  Log:
  Add org.apache.commons.pool.BaseKeyedPoolableObjectFactory implementaion to support keyed
pool in EventModule
  
  Revision  Changes    Path
  1.1                  jakarta-commons-sandbox/services/src/java/org/apache/commons/services/EventFactory.java
  
  Index: EventFactory.java
  ===================================================================
  /*
   * Copyright (C) The Apache Software Foundation. All rights reserved.
   *
   * This software is published under the terms of the Apache Software License
   * version 1.1, a copy of which has been included with this distribution in
   * the LICENSE file.
   */
  
  package org.apache.commons.services;
  
  import org.apache.commons.pool.BaseKeyedPoolableObjectFactory;
  
  /** Event factory implementation. Generate events for events pool.
   * 
   *  @version $Id: EventFactory.java,v 1.1 2001/12/19 16:40:52 oalexeev Exp $
   *  @author Oleg V Alexeev
   */
  public class EventFactory extends BaseKeyedPoolableObjectFactory {
  
          protected EventModule eventModule = null;
  
          public EventModule getEventModule() {
                  return eventModule;
          }
  
          public void setEventModule( EventModule eventModule ) {
                  this.eventModule = eventModule;
          }
  
          public Object makeObject(Object key) {
                  EventRegistration eventRegistration = eventModule.getEventRegistration(
(String)key );
                  Event event = null;
  
                  try {
                          Class clazz = Class.forName( eventRegistration.getType() );
                          event = (Event)clazz.newInstance();
                  } catch ( Exception e ) {
                          eventModule.getServiceManager().getLog().error( "Can not create
event of type - '" + eventRegistration.getType() + "'", e );
                          event = new Event();
                  }
                  event.setParentModule( eventModule );
                  event.setEventRegistration( eventRegistration );
                  return event;
          }
  
          public void destroyObject(Object key, Object obj) {
                  ((Event)obj).destroy();
          }
  
  }
  
  

--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message