blob: 0b1d056669b5db2db11a414051490367f43807a9 [file] [log] [blame]
Richard S. Hall930fecc2005-08-16 18:33:34 +00001/*
2 * Copyright 2005 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.osgi.framework;
18
19import java.io.IOException;
20import java.io.InputStream;
21import java.net.URL;
22import java.util.Dictionary;
23import java.util.Enumeration;
24
25import org.osgi.framework.*;
26
27class BundleImpl implements Bundle
28{
29 private Felix m_felix = null;
30 private BundleInfo m_info = null;
31
32 protected BundleImpl(Felix felix, BundleInfo info)
33 {
34 m_felix = felix;
35 m_info = info;
36 }
37
38 Felix getFelix() // package protected
39 {
40 return m_felix;
41 }
42
43 BundleInfo getInfo() // package protected
44 {
45 return m_info;
46 }
47
48 void setInfo(BundleInfo info) // package protected
49 {
50 m_info = info;
51 }
52
53 public long getBundleId()
54 {
55 return m_info.getBundleId();
56 }
57
58 public Dictionary getHeaders()
59 {
60 return m_felix.getBundleHeaders(this);
61 }
62
63 public String getLocation()
64 {
65 return m_felix.getBundleLocation(this);
66 }
67
68 /**
69 * Returns a URL to a named resource in the bundle.
70 *
71 * @return a URL to named resource, or null if not found.
72 **/
73 public URL getResource(String name)
74 {
75 return m_felix.getBundleResource(this, name);
76 }
77
78 /**
79 * Returns an array of service references corresponding to
80 * the bundle's registered services.
81 *
82 * @return an array of service references or null.
83 **/
84 public ServiceReference[] getRegisteredServices()
85 {
86 return m_felix.getBundleRegisteredServices(this);
87 }
88
89 public ServiceReference[] getServicesInUse()
90 {
91 return m_felix.getBundleServicesInUse(this);
92 }
93
94 public int getState()
95 {
96 return m_info.getState();
97 }
98
99 public boolean hasPermission(Object obj)
100 {
101 return m_felix.bundleHasPermission(this, obj);
102 }
103
104 public void start() throws BundleException
105 {
106 m_felix.startBundle(this, true);
107 }
108
109 public void update() throws BundleException
110 {
111 update(null);
112 }
113
114 public void update(InputStream is) throws BundleException
115 {
116 m_felix.updateBundle(this, is);
117 }
118
119 public void stop() throws BundleException
120 {
121 m_felix.stopBundle(this, true);
122 }
123
124 public void uninstall() throws BundleException
125 {
126 m_felix.uninstallBundle(this);
127 }
128
129 public String toString()
130 {
131 return "[" + getBundleId() +"]";
132 }
133
134 //
135 // PLACE FOLLOWING METHODS INTO PROPER LOCATION ONCE IMPLEMENTED.
136 //
137
138 public Dictionary getHeaders(String locale)
139 {
140 // TODO: Implement Bundle.getHeaders()
141 return null;
142 }
143
144 public String getSymbolicName()
145 {
146 // TODO: Implement Bundle.getSymbolicName()
147 return null;
148 }
149
150 public Class loadClass(String name) throws ClassNotFoundException
151 {
152 // TODO: Implement Bundle.loadClass()
153 return null;
154 }
155
156 public Enumeration getResources(String name) throws IOException
157 {
158 // TODO: Implement Bundle.getResources()
159 return null;
160 }
161
162 public Enumeration getEntryPaths(String path)
163 {
164 // TODO: Implement Bundle.getEntryPaths()
165 return null;
166 }
167
168 public URL getEntry(String name)
169 {
170 // TODO: Implement Bundle.getEntry()
171 return null;
172 }
173
174 public long getLastModified()
175 {
176 // TODO: Implement Bundle.getLastModified()
177 return 0;
178 }
179
180 public Enumeration findEntries(String path, String filePattern, boolean recurse)
181 {
182 // TODO: Implement Bundle.findEntries()
183 return null;
184 }
185}