01: /*****************************************************************************
02: * Java Plug-in Framework (JPF)
03: * Copyright (C) 2004-2007 Dmitry Olshansky
04: *
05: * This library is free software; you can redistribute it and/or
06: * modify it under the terms of the GNU Lesser General Public
07: * License as published by the Free Software Foundation; either
08: * version 2.1 of the License, or (at your option) any later version.
09: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library; if not, write to the Free Software
17: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18: *****************************************************************************/package org.java.plugin;
19:
20: import java.net.URL;
21:
22: import org.java.plugin.registry.Identity;
23: import org.java.plugin.util.ExtendedProperties;
24:
25: /**
26: * This interface is intended to establish correspondence between relative path
27: * and absolute URL in context of plug-in or plug-in fragment.
28: *
29: * @see org.java.plugin.ObjectFactory#createPathResolver()
30: *
31: * @version $Id$
32: */
33: public interface PathResolver {
34: /**
35: * Configures this resolver instance. Usually this method is called from
36: * {@link ObjectFactory object factory} implementation.
37: * @param config path resolver configuration data
38: * @throws Exception if any error has occurred
39: */
40: void configure(ExtendedProperties config) throws Exception;
41:
42: /**
43: * Registers "home" URL for given plug-in element.
44: * @param idt plug-in element
45: * @param url "home" URL for a given plug-in element
46: */
47: void registerContext(Identity idt, URL url);
48:
49: /**
50: * Unregisters plug-in element from this path resolver.
51: * @param id plug-in element identifier
52: */
53: void unregisterContext(String id);
54:
55: /**
56: * Returns URL of {@link #registerContext(Identity, URL) registered} plug-in
57: * element context. If context for plug-in element with given ID not
58: * registered, this method should throw an {@link IllegalArgumentException}.
59: * In other words, this method shouldn't return <code>null</code>.
60: * @param id plug-in element identifier
61: * @return registered context "home" location
62: */
63: URL getRegisteredContext(String id);
64:
65: /**
66: * @param id plug-in element identifier
67: * @return <code>true</code> if context for plug-in element with given ID
68: * registered
69: */
70: boolean isContextRegistered(String id);
71:
72: /**
73: * Should resolve given path to URL for a given identity.
74: * @param identity plug-in element for which to resolve path
75: * @param path path to be resolved
76: * @return resolved absolute URL
77: */
78: URL resolvePath(Identity identity, String path);
79: }
|