Richard S. Hall | 930fecc | 2005-08-16 18:33:34 +0000 | [diff] [blame^] | 1 | /* |
| 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 | */ |
| 17 | package org.apache.osgi.framework.cache; |
| 18 | |
| 19 | import java.io.File; |
| 20 | import java.util.Map; |
| 21 | |
| 22 | import org.osgi.framework.BundleActivator; |
| 23 | |
| 24 | /** |
| 25 | * <p> |
| 26 | * This interface represents an individual cached bundle in the |
| 27 | * bundle cache. Felix uses this interface to access all information |
| 28 | * about the associated bundle's cached information. Classes that implement |
| 29 | * this interface will be related to a specific implementation of the |
| 30 | * <tt>BundleCache</tt> interface. |
| 31 | * </p> |
| 32 | * @see org.apache.osgi.framework.BundleCache |
| 33 | **/ |
| 34 | public interface BundleArchive |
| 35 | { |
| 36 | /** |
| 37 | * <p> |
| 38 | * Returns the identifier of the bundle associated with this archive. |
| 39 | * </p> |
| 40 | * @return the identifier of the bundle associated with this archive. |
| 41 | **/ |
| 42 | public long getId(); |
| 43 | |
| 44 | /** |
| 45 | * <p> |
| 46 | * Returns the location string of the bundle associated with this archive. |
| 47 | * </p> |
| 48 | * @return the location string of the bundle associated with this archive. |
| 49 | * @throws java.lang.Exception if any error occurs. |
| 50 | **/ |
| 51 | public String getLocation() |
| 52 | throws Exception; |
| 53 | |
| 54 | /** |
| 55 | * <p> |
| 56 | * Returns the persistent state of the bundle associated with the archive; |
| 57 | * this value will be either <tt>Bundle.INSTALLED</tt> or <tt>Bundle.ACTIVE</tt>. |
| 58 | * </p> |
| 59 | * @return the persistent state of the bundle associated with this archive. |
| 60 | * @throws java.lang.Exception if any error occurs. |
| 61 | **/ |
| 62 | public int getPersistentState() |
| 63 | throws Exception; |
| 64 | |
| 65 | /** |
| 66 | * <p> |
| 67 | * Sets the persistent state of the bundle associated with this archive; |
| 68 | * this value will be either <tt>Bundle.INSTALLED</tt> or <tt>Bundle.ACTIVE</tt>. |
| 69 | * </p> |
| 70 | * @param state the new bundle state to write to the archive. |
| 71 | * @throws java.lang.Exception if any error occurs. |
| 72 | **/ |
| 73 | public void setPersistentState(int state) |
| 74 | throws Exception; |
| 75 | |
| 76 | /** |
| 77 | * <p> |
| 78 | * Returns the start level of the bundle associated with this archive. |
| 79 | * </p> |
| 80 | * @return the start level of the bundle associated with this archive. |
| 81 | * @throws java.lang.Exception if any error occurs. |
| 82 | **/ |
| 83 | public int getStartLevel() |
| 84 | throws Exception; |
| 85 | |
| 86 | /** |
| 87 | * <p> |
| 88 | * Sets the start level of the bundle associated with this archive. |
| 89 | * </p> |
| 90 | * @param level the new bundle start level to write to the archive. |
| 91 | * @throws java.lang.Exception if any error occurs. |
| 92 | **/ |
| 93 | public void setStartLevel(int level) |
| 94 | throws Exception; |
| 95 | |
| 96 | /** |
| 97 | * <p> |
| 98 | * Returns an appropriate data file for the bundle associated with the |
| 99 | * archive using the supplied file name. |
| 100 | * </p> |
| 101 | * @return a <tt>File</tt> corresponding to the requested data file for |
| 102 | * the bundle associated with this archive. |
| 103 | * @throws java.lang.Exception if any error occurs. |
| 104 | **/ |
| 105 | public File getDataFile(String fileName) |
| 106 | throws Exception; |
| 107 | |
| 108 | /** |
| 109 | * <p> |
| 110 | * Returns the persistent bundle activator of the bundle associated with |
| 111 | * this archive; this is a non-standard OSGi method that is only called |
| 112 | * when Felix is running in non-strict OSGi mode. |
| 113 | * </p> |
| 114 | * @param loader the class loader to use when trying to instantiate |
| 115 | * the bundle activator. |
| 116 | * @return the persistent bundle activator of the bundle associated with |
| 117 | * this archive. |
| 118 | * @throws java.lang.Exception if any error occurs. |
| 119 | **/ |
| 120 | public BundleActivator getActivator(ClassLoader loader) |
| 121 | throws Exception; |
| 122 | |
| 123 | /** |
| 124 | * <p> |
| 125 | * Sets the persistent bundle activator of the bundle associated with |
| 126 | * this archive; this is a non-standard OSGi method that is only called |
| 127 | * when Felix is running in non-strict OSGi mode. |
| 128 | * </p> |
| 129 | * @param obj the new persistent bundle activator to write to the archive. |
| 130 | * @throws java.lang.Exception if any error occurs. |
| 131 | **/ |
| 132 | public void setActivator(Object obj) |
| 133 | throws Exception; |
| 134 | |
| 135 | /** |
| 136 | * <p> |
| 137 | * Returns the number of revisions of the bundle associated with the |
| 138 | * archive. When a bundle is updated, the previous version of the bundle |
| 139 | * is maintained along with the new revision until old revisions are |
| 140 | * purged. The revision count reflects how many revisions of the bundle |
| 141 | * are currently available in the cache. |
| 142 | * </p> |
| 143 | * @return the number of revisions of the bundle associated with this archive. |
| 144 | * @throws java.lang.Exception if any error occurs. |
| 145 | **/ |
| 146 | public int getRevisionCount() |
| 147 | throws Exception; |
| 148 | |
| 149 | /** |
| 150 | * <p> |
| 151 | * Returns the main attributes of the JAR file manifest header of the |
| 152 | * specified revision of the bundle associated with this archive. The |
| 153 | * returned map should be case insensitive. |
| 154 | * </p> |
| 155 | * @param revision the specified revision. |
| 156 | * @return the case-insensitive JAR file manifest header of the specified |
| 157 | * revision of the bundle associated with this archive. |
| 158 | * @throws java.lang.Exception if any error occurs. |
| 159 | **/ |
| 160 | public Map getManifestHeader(int revision) |
| 161 | throws Exception; |
| 162 | |
| 163 | /** |
| 164 | * <p> |
| 165 | * Returns an array of <tt>String</tt>s that represent the class path of |
| 166 | * the specified revision of the bundle associated with this archive. |
| 167 | * Currently, these values are restricted to absolute paths in the file |
| 168 | * system, but this may be lifted in the future (perhaps they should be |
| 169 | * <tt>ResourceSource</tt>s from the Module Loader. |
| 170 | * </p> |
| 171 | * @param revision the specified revision. |
| 172 | * @return a <tt>String</tt> array of the absolute path names that |
| 173 | * comprise the class path of the specified revision of the |
| 174 | * bundle associated with this archive. |
| 175 | * @throws java.lang.Exception if any error occurs. |
| 176 | **/ |
| 177 | public String[] getClassPath(int revision) |
| 178 | throws Exception; |
| 179 | |
| 180 | /** |
| 181 | * <p> |
| 182 | * Returns the absolute file path for the specified native library of the |
| 183 | * specified revision of the bundle associated with this archive. |
| 184 | * </p> |
| 185 | * @param revision the specified revision. |
| 186 | * @param libName the name of the library. |
| 187 | * @return a <tt>String</tt> that contains the absolute path name to |
| 188 | * the requested native library of the specified revision of the |
| 189 | * bundle associated with this archive. |
| 190 | * @throws java.lang.Exception if any error occurs. |
| 191 | **/ |
| 192 | public String findLibrary(int revision, String libName) |
| 193 | throws Exception; |
| 194 | } |