blob: e7f6536ebb0cf8ce1131153aaa59ca95c8dc6bc8 [file] [log] [blame]
Richard S. Hall29a4fbc2006-02-03 12:54:52 +00001/*
2 * Copyright 2006 The Apache Software Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 *
16 */
17package org.apache.felix.moduleloader;
18
19import java.net.URL;
20
21import org.apache.felix.framework.Logger;
22
23public class ModuleImpl implements IModule
24{
25 private Logger m_logger = null;
26 private String m_id = null;
27 private IContentLoader m_contentLoader = null;
28
29 ModuleImpl(Logger logger, String id)
30 {
31 m_logger = logger;
32 m_id = id;
33 }
34
35 public String getId()
36 {
37 return m_id;
38 }
39
40 public IContentLoader getContentLoader()
41 {
42 return m_contentLoader;
43 }
44
45 protected void setContentLoader(IContentLoader contentLoader)
46 {
47 m_contentLoader = contentLoader;
48 }
49
50 public Class getClass(String name)
51 {
52 try
53 {
54 return m_contentLoader.getSearchPolicy().findClass(name);
55 }
56 catch (ClassNotFoundException ex)
57 {
58 m_logger.log(
59 Logger.LOG_WARNING,
60 ex.getMessage(),
61 ex);
62 }
63 return null;
64 }
65
66 public URL getResource(String name)
67 {
68 try
69 {
70 return m_contentLoader.getSearchPolicy().findResource(name);
71 }
72 catch (ResourceNotFoundException ex)
73 {
74 m_logger.log(
75 Logger.LOG_WARNING,
76 ex.getMessage(),
77 ex);
78 }
79 return null;
80 }
81
82 public String toString()
83 {
84 return m_id;
85 }
86}