KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > easybeans > pool > PoolFactory


1 /**
2  * EasyBeans
3  * Copyright (C) 2006 Bull S.A.S.
4  * Contact: easybeans@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * 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 940 2006-07-26 09:05:27Z benoitf $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.easybeans.pool;
27
28 import org.objectweb.easybeans.api.pool.PoolException;
29
30 /**
31  * Allows to call specific methods for each implementation of the pool for each lifecycle on an object.
32  * @param <InstanceType> the type of the object that are managed by the pool
33  * (could be EasyBeansSLSB, etc.)
34  * @param <Clue> a clue which is given to match an instance in the pool
35  * @author Florent Benoitt
36  */

37 public interface PoolFactory<InstanceType, Clue> {
38
39
40     /**
41      * Creates an instance with the given hint.
42      * @param clue a clue given by the Pool. Could be null.
43      * @throws PoolException if instance cannot be created.
44      * @return the created instance.
45      */

46     InstanceType create(Clue clue) throws PoolException;
47
48     /**
49      * Checks if the given object with the given clue is matching.
50      * @param object given object against which the check should be done.
51      * @param clue the object used as clue to check the matching.
52      * @return true if it is matching, else false.
53      */

54     boolean isMatching(InstanceType object, Clue clue);
55
56
57     /**
58      * Validate an instance by giving some statistics.
59      * @param object the instance to validate
60      * @param stats some statistics to help in the validating process.
61      * @return true if the element is valid, else false.
62      */

63     boolean validate(InstanceType object, PoolEntryStatistics stats);
64
65
66     /**
67      * Callback called when object is gonna be removed.
68      * @param object that is being removed from the pool.
69      */

70     void remove(InstanceType object);
71
72 }
73
Popular Tags