01: /**
02: * EasyBeans
03: * Copyright (C) 2006 Bull S.A.S.
04: * Contact: easybeans@ow2.org
05: *
06: * This library is free software; you can redistribute it and/or
07: * modify it under the terms of the GNU Lesser General Public
08: * License as published by the Free Software Foundation; either
09: * version 2.1 of the License, or any later version.
10: *
11: * This library is distributed in the hope that it will be useful,
12: * but WITHOUT ANY WARRANTY; without even the implied warranty of
13: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14: * Lesser General Public License for more details.
15: *
16: * You should have received a copy of the GNU Lesser General Public
17: * License along with this library; if not, write to the Free Software
18: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19: * USA
20: *
21: * --------------------------------------------------------------------------
22: * $Id: PoolFactory.java 1970 2007-10-16 11:49:25Z benoitf $
23: * --------------------------------------------------------------------------
24: */package org.ow2.easybeans.pool;
25:
26: import org.ow2.easybeans.api.pool.PoolException;
27:
28: /**
29: * Allows to call specific methods for each implementation of the pool for each lifecycle on an object.
30: * @param <InstanceType> the type of the object that are managed by the pool
31: * (could be EasyBeansSLSB, etc.)
32: * @param <Clue> a clue which is given to match an instance in the pool
33: * @author Florent Benoitt
34: */
35: public interface PoolFactory<InstanceType, Clue> {
36:
37: /**
38: * Creates an instance with the given hint.
39: * @param clue a clue given by the Pool. Could be null.
40: * @throws PoolException if instance cannot be created.
41: * @return the created instance.
42: */
43: InstanceType create(Clue clue) throws PoolException;
44:
45: /**
46: * Checks if the given object with the given clue is matching.
47: * @param object given object against which the check should be done.
48: * @param clue the object used as clue to check the matching.
49: * @return true if it is matching, else false.
50: */
51: boolean isMatching(InstanceType object, Clue clue);
52:
53: /**
54: * Validate an instance by giving some statistics.
55: * @param object the instance to validate
56: * @param stats some statistics to help in the validating process.
57: * @return true if the element is valid, else false.
58: */
59: boolean validate(InstanceType object, PoolEntryStatistics stats);
60:
61: /**
62: * Callback called when object is gonna be removed.
63: * @param object that is being removed from the pool.
64: */
65: void remove(InstanceType object);
66:
67: }
|