You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by oa...@apache.org on 2001/12/19 17:40:52 UTC
cvs commit: jakarta-commons-sandbox/services/src/java/org/apache/commons/services EventFactory.java
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: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>