PageRenderTime 10ms CodeModel.GetById 2ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 0ms

/razpub/src/com/razie/pub/events/RazResource.java

http://razpub.googlecode.com/
Java | 52 lines | 22 code | 9 blank | 21 comment | 0 complexity | 79ab2d28bd660e4ebb80fd3e9472fa64 MD5 | raw file
 1/**
 2 * Razvan's public code. Copyright 2008 based on Apache license (share alike) see LICENSE.txt for
 3 * details.
 4 */
 5package com.razie.pub.events;
 6
 7import java.util.HashMap;
 8import java.util.Map;
 9
10import razie.base.ActionItem;
11
12/**
13 * a resource in this environment - registered in the naming system
14 * 
15 * resources are: database connections, JMS destinations, god knows what exactly
16 * 
17 * @version $Revision: 1.63 $
18 */
19public interface RazResource {
20    public static final String     sCLASS = "Resource.razie";
21    public static final ActionItem META   = new ActionItem(sCLASS, "/public/pics/IceAgeScrat.png");
22
23    public String getResName();
24
25    /**
26     * environments manage and must be able to locate resources. To use resources, you need access
27     * to a resource locator which is hooked up to a resource manager.
28     * 
29     * @version $Revision: 1.63 $
30     * @author $Author: davidx $
31     * @since $Date: 2005/04/01 16:22:12 $
32     */
33    public interface RazResourceLocator {
34        public RazResource locate(String name);
35
36        public void register(String name, RazResource res);
37    }
38
39    /** stupid default resource manager */
40    public static class RazResourceManager implements RazResourceLocator {
41        Map<String, RazResource> resources = new HashMap<String, RazResource>();
42
43        // TODO 3- change this to simply find the smart asset resource...
44        public RazResource locate(String name) {
45            return resources.get(name);
46        }
47
48        public void register(String name, RazResource res) {
49            resources.put(name, res);
50        }
51    }
52}