gvsig-tools / org.gvsig.tools / library / trunk / org.gvsig.tools / org.gvsig.tools.lib / src / main / java / org / gvsig / tools / library / Library.java @ 1340
History | View | Annotate | Download (3.65 KB)
1 |
/**
|
---|---|
2 |
* gvSIG. Desktop Geographic Information System.
|
3 |
*
|
4 |
* Copyright (C) 2007-2013 gvSIG Association.
|
5 |
*
|
6 |
* This program is free software; you can redistribute it and/or modify it under
|
7 |
* the terms of the GNU General Public License as published by the Free Software
|
8 |
* Foundation; either version 2 of the License, or (at your option) any later
|
9 |
* version.
|
10 |
*
|
11 |
* This program is distributed in the hope that it will be useful, but WITHOUT
|
12 |
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
13 |
* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
|
14 |
* details.
|
15 |
*
|
16 |
* You should have received a copy of the GNU General Public License along with
|
17 |
* this program; if not, write to the Free Software Foundation, Inc., 51
|
18 |
* Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
19 |
*
|
20 |
* For any additional information, do not hesitate to contact us at info AT
|
21 |
* gvsig.com, or visit our website www.gvsig.com.
|
22 |
*/
|
23 |
/*
|
24 |
* AUTHORS (In addition to CIT):
|
25 |
* 2008 {DiSiD Technologies} {Create a base Locator implementation}
|
26 |
*/
|
27 |
package org.gvsig.tools.library; |
28 |
|
29 |
import java.util.Collection; |
30 |
import java.util.Set; |
31 |
|
32 |
/**
|
33 |
* Library initialization and registration.
|
34 |
*
|
35 |
* @author <a href="mailto:cordin@disid.com">C?sar Ordi?ana</a>
|
36 |
*/
|
37 |
public interface Library { |
38 |
|
39 |
/**
|
40 |
* Constant definitions for library types.
|
41 |
*
|
42 |
* @author gvSIG team
|
43 |
*/
|
44 |
public static interface TYPE { |
45 |
|
46 |
public static final String API = "api"; |
47 |
public static final String IMPL = "impl"; |
48 |
public static final String SERVICE = "service"; |
49 |
} |
50 |
|
51 |
public interface Required { |
52 |
|
53 |
public Class getLibraryClass(); |
54 |
|
55 |
public Library getLibrary(Set<Library> pool); |
56 |
|
57 |
public String getType(); |
58 |
} |
59 |
|
60 |
/**
|
61 |
* Performs all the initializations of the library, only related to himself:
|
62 |
* register implementation classes through the Locator, start services, etc.
|
63 |
*
|
64 |
* @throws LibraryException if there is an error while performing the
|
65 |
* initialization of the library
|
66 |
*/
|
67 |
void initialize() throws LibraryException; |
68 |
|
69 |
/**
|
70 |
* Performs all the initializations or validations related to the library
|
71 |
* dependencies, as getting references to objects through other libraries
|
72 |
* Locators.
|
73 |
*
|
74 |
* @throws LibraryException if there is an error while loading an
|
75 |
* implementation of the library
|
76 |
*/
|
77 |
void postInitialize() throws LibraryException; |
78 |
|
79 |
/**
|
80 |
* Returns the {@link Library} class this library is related to.
|
81 |
*
|
82 |
* @return the {@link Library} class this library is related to
|
83 |
*/
|
84 |
public Class getLibrary(); |
85 |
|
86 |
/**
|
87 |
* Returns the type of the Library.
|
88 |
*
|
89 |
* @see TYPE.
|
90 |
* @return
|
91 |
*/
|
92 |
public String getType(); |
93 |
|
94 |
/**
|
95 |
* Returns a Set of required libraries and their types.
|
96 |
*
|
97 |
* @return a Set of required libraries
|
98 |
*/
|
99 |
public Set<Required> getRequireds(); |
100 |
|
101 |
/**
|
102 |
* Returns if a given library is required.
|
103 |
*
|
104 |
* @param lib the library to check if it is required
|
105 |
* @return if is required
|
106 |
*/
|
107 |
public boolean isRequired(Library lib); |
108 |
|
109 |
/**
|
110 |
* Returns if a given library class is required.
|
111 |
*
|
112 |
* @param libClass the library Class to check if it is required
|
113 |
* @return if is required
|
114 |
*/
|
115 |
public boolean isRequired(Class libClass); |
116 |
|
117 |
/**
|
118 |
* Returns a priority number to range this implementation in case multiple
|
119 |
* ones are within the libraries initialization.
|
120 |
*
|
121 |
* @return a priority number, 0 by default.
|
122 |
*/
|
123 |
public int getPriority(); |
124 |
|
125 |
public void doRegistration(); |
126 |
|
127 |
public void require(Class library); |
128 |
|
129 |
public void require(Collection<Required> libraries); |
130 |
} |