Stuart McCulloch | bb01437 | 2012-06-07 21:57:32 +0000 | [diff] [blame] | 1 | package aQute.lib.osgi; |
| 2 | |
| 3 | import java.nio.charset.*; |
| 4 | import java.util.*; |
| 5 | import java.util.regex.*; |
| 6 | |
| 7 | public interface Constants { |
| 8 | /* |
| 9 | * Defined in OSGi |
| 10 | */ |
| 11 | /** |
| 12 | * @syntax Bundle-ActivationPolicy ::= policy ( ’;’ directive )* policy ::= |
| 13 | * ’lazy’ |
| 14 | */ |
| 15 | String BND_ADDXMLTOTEST = "Bnd-AddXMLToTest"; |
| 16 | String BUNDLE_ACTIVATIONPOLICY = "Bundle-ActivationPolicy"; |
| 17 | String BUNDLE_ACTIVATOR = "Bundle-Activator"; |
| 18 | String BUNDLE_BLUEPRINT = "Bundle-Copyright"; |
| 19 | String BUNDLE_CATEGORY = "Bundle-Category"; |
| 20 | String BUNDLE_CLASSPATH = "Bundle-ClassPath"; |
| 21 | String BUNDLE_CONTACTADDRESS = "Bundle-ContactAddress"; |
| 22 | String BUNDLE_COPYRIGHT = "Bundle-Copyright"; |
| 23 | String BUNDLE_DESCRIPTION = "Bundle-Description"; |
| 24 | String BUNDLE_DOCURL = "Bundle-DocURL"; |
| 25 | String BUNDLE_ICON = "Bundle-Icon"; |
| 26 | String BUNDLE_LICENSE = "Bundle-License"; |
| 27 | String BUNDLE_LOCALIZATION = "Bundle-Localization"; |
| 28 | String BUNDLE_MANIFESTVERSION = "Bundle-ManifestVersion"; |
| 29 | String BUNDLE_NAME = "Bundle-Name"; |
| 30 | String BUNDLE_NATIVECODE = "Bundle-NativeCode"; |
| 31 | String BUNDLE_REQUIREDEXECUTIONENVIRONMENT = "Bundle-RequiredExecutionEnvironment"; |
| 32 | String BUNDLE_SYMBOLICNAME = "Bundle-SymbolicName"; |
| 33 | String BUNDLE_UPDATELOCATION = "Bundle-UpdateLocation"; |
| 34 | String BUNDLE_VENDOR = "Bundle-Vendor"; |
| 35 | String BUNDLE_VERSION = "Bundle-Version"; |
| 36 | String DYNAMICIMPORT_PACKAGE = "DynamicImport-Package"; |
| 37 | String EXPORT_PACKAGE = "Export-Package"; |
| 38 | String EXPORT_SERVICE = "Export-Service"; |
| 39 | String FRAGMENT_HOST = "Fragment-Host"; |
| 40 | String IMPORT_PACKAGE = "Import-Package"; |
| 41 | String IMPORT_SERVICE = "Import-Service"; |
| 42 | String PROVIDE_CAPABILITY = "Provide-Capability"; |
| 43 | String REQUIRE_BUNDLE = "Require-Bundle"; |
| 44 | String REQUIRE_CAPABILITY = "Require-Capability"; |
| 45 | String SERVICE_COMPONENT = "Service-Component"; |
| 46 | |
| 47 | String PRIVATE_PACKAGE = "Private-Package"; |
| 48 | String IGNORE_PACKAGE = "Ignore-Package"; |
| 49 | String INCLUDE_RESOURCE = "Include-Resource"; |
| 50 | String CONDITIONAL_PACKAGE = "Conditional-Package"; |
| 51 | String BND_LASTMODIFIED = "Bnd-LastModified"; |
| 52 | String CREATED_BY = "Created-By"; |
| 53 | String TOOL = "Tool"; |
| 54 | String TESTCASES = "Test-Cases"; |
| 55 | String SIGNATURE_TEST = "-signaturetest"; |
| 56 | |
| 57 | String headers[] = { |
| 58 | BUNDLE_ACTIVATOR, BUNDLE_CONTACTADDRESS, BUNDLE_COPYRIGHT, BUNDLE_DESCRIPTION, |
| 59 | BUNDLE_DOCURL, BUNDLE_LOCALIZATION, BUNDLE_NATIVECODE, BUNDLE_VENDOR, BUNDLE_VERSION, |
| 60 | BUNDLE_LICENSE, BUNDLE_CLASSPATH, SERVICE_COMPONENT, EXPORT_PACKAGE, IMPORT_PACKAGE, |
| 61 | BUNDLE_LOCALIZATION, BUNDLE_MANIFESTVERSION, BUNDLE_NAME, BUNDLE_NATIVECODE, |
| 62 | BUNDLE_REQUIREDEXECUTIONENVIRONMENT, BUNDLE_SYMBOLICNAME, BUNDLE_VERSION, |
| 63 | FRAGMENT_HOST, PRIVATE_PACKAGE, IGNORE_PACKAGE, INCLUDE_RESOURCE, REQUIRE_BUNDLE, |
| 64 | IMPORT_SERVICE, EXPORT_SERVICE, CONDITIONAL_PACKAGE, BND_LASTMODIFIED, TESTCASES, |
Stuart McCulloch | 285034f | 2012-06-12 12:41:16 +0000 | [diff] [blame^] | 65 | SIGNATURE_TEST, REQUIRE_CAPABILITY, PROVIDE_CAPABILITY }; |
Stuart McCulloch | bb01437 | 2012-06-07 21:57:32 +0000 | [diff] [blame] | 66 | |
| 67 | String BUILDPATH = "-buildpath"; |
| 68 | String BUILDPACKAGES = "-buildpackages"; |
| 69 | String BUMPPOLICY = "-bumppolicy"; |
| 70 | String CONDUIT = "-conduit"; |
| 71 | String COMPILER_SOURCE = "-source"; |
| 72 | String COMPILER_TARGET = "-target"; |
| 73 | String DEPENDSON = "-dependson"; |
| 74 | String DEPLOY = "-deploy"; |
| 75 | String DEPLOYREPO = "-deployrepo"; |
Stuart McCulloch | 285034f | 2012-06-12 12:41:16 +0000 | [diff] [blame^] | 76 | String DIGESTS = "-digests"; |
| 77 | String DSANNOTATIONS = "-dsannotations"; |
Stuart McCulloch | bb01437 | 2012-06-07 21:57:32 +0000 | [diff] [blame] | 78 | String DONOTCOPY = "-donotcopy"; |
| 79 | String DEBUG = "-debug"; |
| 80 | String EXPORT_CONTENTS = "-exportcontents"; |
| 81 | String FAIL_OK = "-failok"; |
| 82 | String INCLUDE = "-include"; |
| 83 | String INCLUDERESOURCE = "-includeresource"; |
| 84 | String MAKE = "-make"; |
| 85 | String METATYPE = "-metatype"; |
| 86 | String MANIFEST = "-manifest"; |
| 87 | String SAVEMANIFEST = "-savemanifest"; |
| 88 | String NAMESECTION = "-namesection"; |
| 89 | String NODEFAULTVERSION = "-nodefaultversion"; |
| 90 | String NOEXTRAHEADERS = "-noextraheaders"; |
| 91 | String NOMANIFEST = "-nomanifest"; |
| 92 | String NOUSES = "-nouses"; |
Stuart McCulloch | 285034f | 2012-06-12 12:41:16 +0000 | [diff] [blame^] | 93 | @Deprecated |
| 94 | String NOPE = "-nope"; |
Stuart McCulloch | bb01437 | 2012-06-07 21:57:32 +0000 | [diff] [blame] | 95 | String NOBUNDLES = "-nobundles"; |
| 96 | String PEDANTIC = "-pedantic"; |
| 97 | String PLUGIN = "-plugin"; |
| 98 | String PLUGINPATH = "-pluginpath"; |
| 99 | String POM = "-pom"; |
| 100 | String RELEASEREPO = "-releaserepo"; |
| 101 | String REMOVEHEADERS = "-removeheaders"; |
| 102 | String RESOURCEONLY = "-resourceonly"; |
| 103 | String SOURCES = "-sources"; |
| 104 | String SOURCEPATH = "-sourcepath"; |
| 105 | String SUB = "-sub"; |
| 106 | String RUNPROPERTIES = "-runproperties"; |
| 107 | String RUNSYSTEMPACKAGES = "-runsystempackages"; |
| 108 | String RUNBUNDLES = "-runbundles"; |
| 109 | String RUNPATH = "-runpath"; |
| 110 | String RUNSTORAGE = "-runstorage"; |
| 111 | String RUNBUILDS = "-runbuilds"; |
| 112 | String RUNPATH_MAIN_DIRECTIVE = "main:"; |
| 113 | String RUNPATH_LAUNCHER_DIRECTIVE = "launcher:"; |
| 114 | String RUNVM = "-runvm"; |
| 115 | String RUNTRACE = "-runtrace"; |
| 116 | String RUNFRAMEWORK = "-runframework"; |
| 117 | String RUNTIMEOUT = "-runtimeout"; |
| 118 | String SNAPSHOT = "-snapshot"; |
| 119 | String RUNFRAMEWORK_SERVICES = "services"; |
| 120 | String RUNFRAMEWORK_NONE = "none"; |
| 121 | String REPORTNEWER = "-reportnewer"; |
| 122 | String SIGN = "-sign"; |
| 123 | String TESTPACKAGES = "-testpackages"; |
| 124 | String TESTREPORT = "-testreport"; |
| 125 | String TESTPATH = "-testpath"; |
| 126 | String TESTCONTINUOUS = "-testcontinuous"; |
| 127 | String UNDERTEST = "-undertest"; |
| 128 | String VERBOSE = "-verbose"; |
Stuart McCulloch | 285034f | 2012-06-12 12:41:16 +0000 | [diff] [blame^] | 129 | @Deprecated |
| 130 | String VERSIONPOLICY_IMPL = "-versionpolicy-impl"; |
| 131 | @Deprecated |
| 132 | String VERSIONPOLICY_USES = "-versionpolicy-uses"; |
Stuart McCulloch | bb01437 | 2012-06-07 21:57:32 +0000 | [diff] [blame] | 133 | String PROVIDER_POLICY = "-provider-policy"; |
| 134 | String CONSUMER_POLICY = "-consumer-policy"; |
Stuart McCulloch | 285034f | 2012-06-12 12:41:16 +0000 | [diff] [blame^] | 135 | @Deprecated |
| 136 | String VERSIONPOLICY = "-versionpolicy"; |
Stuart McCulloch | bb01437 | 2012-06-07 21:57:32 +0000 | [diff] [blame] | 137 | String WAB = "-wab"; |
| 138 | String WABLIB = "-wablib"; |
| 139 | String REQUIRE_BND = "-require-bnd"; |
| 140 | |
| 141 | // Deprecated |
| 142 | String CLASSPATH = "-classpath"; |
| 143 | String OUTPUT = "-output"; |
| 144 | |
Stuart McCulloch | 285034f | 2012-06-12 12:41:16 +0000 | [diff] [blame^] | 145 | String options[] = {BUILDPATH, |
Stuart McCulloch | bb01437 | 2012-06-07 21:57:32 +0000 | [diff] [blame] | 146 | BUMPPOLICY, CONDUIT, CLASSPATH, CONSUMER_POLICY, DEPENDSON, DONOTCOPY, EXPORT_CONTENTS, |
| 147 | FAIL_OK, INCLUDE, INCLUDERESOURCE, MAKE, MANIFEST, NOEXTRAHEADERS, NOUSES, NOBUNDLES, |
| 148 | PEDANTIC, PLUGIN, POM, PROVIDER_POLICY, REMOVEHEADERS, RESOURCEONLY, SOURCES, |
| 149 | SOURCEPATH, SOURCES, SOURCEPATH, SUB, RUNBUNDLES, RUNPATH, RUNSYSTEMPACKAGES, |
| 150 | RUNPROPERTIES, REPORTNEWER, UNDERTEST, TESTPATH, TESTPACKAGES, TESTREPORT, VERBOSE, |
| 151 | NOMANIFEST, DEPLOYREPO, RELEASEREPO, SAVEMANIFEST, RUNVM, WAB, WABLIB, RUNFRAMEWORK, |
Stuart McCulloch | 285034f | 2012-06-12 12:41:16 +0000 | [diff] [blame^] | 152 | RUNTRACE, TESTCONTINUOUS, SNAPSHOT, NAMESECTION, DIGESTS, DSANNOTATIONS }; |
Stuart McCulloch | bb01437 | 2012-06-07 21:57:32 +0000 | [diff] [blame] | 153 | |
| 154 | // Ignore bundle specific headers. These bundles do not make |
| 155 | // a lot of sense to inherit |
| 156 | String[] BUNDLE_SPECIFIC_HEADERS = new String[] { |
| 157 | INCLUDE_RESOURCE, BUNDLE_ACTIVATOR, BUNDLE_CLASSPATH, BUNDLE_NAME, BUNDLE_NATIVECODE, |
| 158 | BUNDLE_SYMBOLICNAME, IMPORT_PACKAGE, EXPORT_PACKAGE, DYNAMICIMPORT_PACKAGE, |
| 159 | FRAGMENT_HOST, REQUIRE_BUNDLE, PRIVATE_PACKAGE, EXPORT_CONTENTS, TESTCASES, NOMANIFEST, |
Stuart McCulloch | 285034f | 2012-06-12 12:41:16 +0000 | [diff] [blame^] | 160 | SIGNATURE_TEST, WAB, WABLIB, REQUIRE_CAPABILITY, PROVIDE_CAPABILITY, DSANNOTATIONS, SERVICE_COMPONENT }; |
Stuart McCulloch | bb01437 | 2012-06-07 21:57:32 +0000 | [diff] [blame] | 161 | |
| 162 | char DUPLICATE_MARKER = '~'; |
| 163 | String SPECIFICATION_VERSION = "specification-version"; |
| 164 | String SPLIT_PACKAGE_DIRECTIVE = "-split-package:"; |
| 165 | String IMPORT_DIRECTIVE = "-import:"; |
| 166 | String NO_IMPORT_DIRECTIVE = "-noimport:"; |
| 167 | String REMOVE_ATTRIBUTE_DIRECTIVE = "-remove-attribute:"; |
| 168 | String LIB_DIRECTIVE = "lib:"; |
| 169 | String NOANNOTATIONS = "-noannotations"; |
| 170 | String COMMAND_DIRECTIVE = "command:"; |
| 171 | String USES_DIRECTIVE = "uses:"; |
| 172 | String MANDATORY_DIRECTIVE = "mandatory:"; |
| 173 | String INCLUDE_DIRECTIVE = "include:"; |
| 174 | String PROVIDE_DIRECTIVE = "provide:"; |
| 175 | String EXCLUDE_DIRECTIVE = "exclude:"; |
| 176 | String PRESENCE_DIRECTIVE = "presence:"; |
| 177 | String PRIVATE_DIRECTIVE = "private:"; |
| 178 | String SINGLETON_DIRECTIVE = "singleton:"; |
| 179 | String EXTENSION_DIRECTIVE = "extension:"; |
| 180 | String VISIBILITY_DIRECTIVE = "visibility:"; |
| 181 | String FRAGMENT_ATTACHMENT_DIRECTIVE = "fragment-attachment:"; |
| 182 | String RESOLUTION_DIRECTIVE = "resolution:"; |
| 183 | String PATH_DIRECTIVE = "path:"; |
| 184 | String SIZE_ATTRIBUTE = "size"; |
| 185 | String LINK_ATTRIBUTE = "link"; |
| 186 | String NAME_ATTRIBUTE = "name"; |
| 187 | String DESCRIPTION_ATTRIBUTE = "description"; |
| 188 | String OSNAME_ATTRIBUTE = "osname"; |
| 189 | String OSVERSION_ATTRIBUTE = "osversion"; |
| 190 | String PROCESSOR_ATTRIBUTE = "processor"; |
| 191 | String LANGUAGE_ATTRIBUTE = "language"; |
| 192 | String SELECTION_FILTER_ATTRIBUTE = "selection-filter"; |
| 193 | String BLUEPRINT_WAIT_FOR_DEPENDENCIES_ATTRIBUTE = "blueprint.wait-for-dependencies"; |
| 194 | String BLUEPRINT_TIMEOUT_ATTRIBUTE = "blueprint.timeout"; |
| 195 | String VERSION_ATTRIBUTE = "version"; |
| 196 | String BUNDLE_SYMBOLIC_NAME_ATTRIBUTE = "bundle-symbolic-name"; |
| 197 | String BUNDLE_VERSION_ATTRIBUTE = "bundle-version"; |
| 198 | String FROM_DIRECTIVE = "from:"; |
| 199 | |
| 200 | String KEYSTORE_LOCATION_DIRECTIVE = "keystore:"; |
| 201 | String KEYSTORE_PROVIDER_DIRECTIVE = "provider:"; |
| 202 | String KEYSTORE_PASSWORD_DIRECTIVE = "password:"; |
| 203 | String SIGN_PASSWORD_DIRECTIVE = "sign-password:"; |
| 204 | |
| 205 | String NONE = "none"; |
| 206 | |
| 207 | String directives[] = { |
| 208 | SPLIT_PACKAGE_DIRECTIVE, NO_IMPORT_DIRECTIVE, IMPORT_DIRECTIVE, RESOLUTION_DIRECTIVE, |
| 209 | INCLUDE_DIRECTIVE, USES_DIRECTIVE, EXCLUDE_DIRECTIVE, KEYSTORE_LOCATION_DIRECTIVE, |
| 210 | KEYSTORE_PROVIDER_DIRECTIVE, KEYSTORE_PASSWORD_DIRECTIVE, SIGN_PASSWORD_DIRECTIVE, |
| 211 | COMMAND_DIRECTIVE, NOANNOTATIONS, LIB_DIRECTIVE, RUNPATH_LAUNCHER_DIRECTIVE, |
| 212 | FROM_DIRECTIVE, PRIVATE_DIRECTIVE |
| 213 | |
| 214 | // TODO |
| 215 | }; |
| 216 | |
| 217 | String USES_USES = "<<USES>>"; |
| 218 | String CURRENT_USES = "@uses"; |
| 219 | String IMPORT_REFERENCE = "reference"; |
| 220 | String IMPORT_PRIVATE = "private"; |
| 221 | String[] importDirectives = { |
| 222 | IMPORT_REFERENCE, IMPORT_PRIVATE }; |
| 223 | |
| 224 | static final Pattern VALID_PROPERTY_TYPES = Pattern |
| 225 | .compile("(String|Long|Double|Float|Integer|Byte|Character|Boolean|Short)"); |
| 226 | |
| 227 | String DEFAULT_BND_EXTENSION = ".bnd"; |
| 228 | String DEFAULT_JAR_EXTENSION = ".jar"; |
| 229 | String DEFAULT_BAR_EXTENSION = ".bar"; |
| 230 | String DEFAULT_BNDRUN_EXTENSION = ".bndrun"; |
Stuart McCulloch | 285034f | 2012-06-12 12:41:16 +0000 | [diff] [blame^] | 231 | String[] METAPACKAGES = {"META-INF", |
Stuart McCulloch | bb01437 | 2012-06-07 21:57:32 +0000 | [diff] [blame] | 232 | "OSGI-INF", "OSGI-OPT" }; |
| 233 | |
| 234 | String CURRENT_VERSION = "@"; |
| 235 | String CURRENT_PACKAGE = "@package"; |
| 236 | |
| 237 | String BUILDFILES = "buildfiles"; |
| 238 | |
| 239 | String EMPTY_HEADER = "<<EMPTY>>"; |
| 240 | |
| 241 | String EMBEDDED_REPO = "/embedded-repo.jar"; |
| 242 | String LAUNCHER_PLUGIN = "Launcher-Plugin"; |
| 243 | String TESTER_PLUGIN = "Tester-Plugin"; |
| 244 | |
| 245 | String DEFAULT_LAUNCHER_BSN = "biz.aQute.launcher"; |
| 246 | String DEFAULT_TESTER_BSN = "biz.aQute.junit"; |
| 247 | |
| 248 | String DEFAULT_DO_NOT_COPY = "CVS|\\.svn|\\.git|\\.DS_Store"; |
| 249 | |
| 250 | Charset DEFAULT_CHARSET = Charset |
| 251 | .forName("UTF8"); |
| 252 | String VERSION_FILTER = "version"; |
| 253 | String PROVIDER_TYPE_DIRECTIVE = "x-provider-type:"; |
| 254 | |
| 255 | /** |
| 256 | * Component constants |
| 257 | */ |
| 258 | public final static String NAMESPACE_STEM = "http://www.osgi.org/xmlns/scr"; |
| 259 | public final static String JIDENTIFIER = "<<identifier>>"; |
| 260 | public final static String COMPONENT_NAME = "name:"; |
| 261 | public final static String COMPONENT_FACTORY = "factory:"; |
| 262 | public final static String COMPONENT_SERVICEFACTORY = "servicefactory:"; |
| 263 | public final static String COMPONENT_IMMEDIATE = "immediate:"; |
| 264 | public final static String COMPONENT_ENABLED = "enabled:"; |
| 265 | public final static String COMPONENT_DYNAMIC = "dynamic:"; |
| 266 | public final static String COMPONENT_MULTIPLE = "multiple:"; |
| 267 | public final static String COMPONENT_PROVIDE = "provide:"; |
| 268 | public final static String COMPONENT_OPTIONAL = "optional:"; |
| 269 | public final static String COMPONENT_PROPERTIES = "properties:"; |
| 270 | public final static String COMPONENT_IMPLEMENTATION = "implementation:"; |
| 271 | public final static String COMPONENT_DESIGNATE = "designate:"; |
| 272 | public final static String COMPONENT_DESIGNATEFACTORY = "designateFactory:"; |
| 273 | public final static String COMPONENT_DESCRIPTORS = ".descriptors:"; |
| 274 | |
| 275 | // v1.1.0 |
| 276 | public final static String COMPONENT_VERSION = "version:"; |
| 277 | public final static String COMPONENT_CONFIGURATION_POLICY = "configuration-policy:"; |
| 278 | public final static String COMPONENT_MODIFIED = "modified:"; |
| 279 | public final static String COMPONENT_ACTIVATE = "activate:"; |
| 280 | public final static String COMPONENT_DEACTIVATE = "deactivate:"; |
| 281 | |
| 282 | final static Map<String, String> EMPTY = Collections |
| 283 | .emptyMap(); |
| 284 | |
| 285 | public final static String[] componentDirectives = new String[] { |
| 286 | COMPONENT_FACTORY, COMPONENT_IMMEDIATE, COMPONENT_ENABLED, COMPONENT_DYNAMIC, |
| 287 | COMPONENT_MULTIPLE, COMPONENT_PROVIDE, COMPONENT_OPTIONAL, COMPONENT_PROPERTIES, |
| 288 | COMPONENT_IMPLEMENTATION, COMPONENT_SERVICEFACTORY, COMPONENT_VERSION, |
| 289 | COMPONENT_CONFIGURATION_POLICY, COMPONENT_MODIFIED, COMPONENT_ACTIVATE, |
| 290 | COMPONENT_DEACTIVATE, COMPONENT_NAME, COMPONENT_DESCRIPTORS, COMPONENT_DESIGNATE, |
| 291 | COMPONENT_DESIGNATEFACTORY }; |
| 292 | |
| 293 | public final static Set<String> SET_COMPONENT_DIRECTIVES = new HashSet<String>( |
| 294 | Arrays.asList(componentDirectives)); |
| 295 | |
| 296 | public final static Set<String> SET_COMPONENT_DIRECTIVES_1_1 = // |
| 297 | new HashSet<String>( |
| 298 | Arrays.asList( |
| 299 | COMPONENT_VERSION, |
| 300 | COMPONENT_CONFIGURATION_POLICY, |
| 301 | COMPONENT_MODIFIED, |
| 302 | COMPONENT_ACTIVATE, |
| 303 | COMPONENT_DEACTIVATE)); |
| 304 | |
| 305 | } |