View Javadoc

1   /*
2    * Copyright 2004-2008 the Seasar Foundation and the Others.
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, 
13   * either express or implied. See the License for the specific language
14   * governing permissions and limitations under the License.
15   */
16  package org.seasar.uruma.rcp.util;
17  
18  import java.util.Dictionary;
19  
20  import org.osgi.framework.Bundle;
21  
22  /**
23   * OSGi {@link Bundle} のメタ情報を取得するためのユーティリティクラスです。
24   * 
25   * @author y-komori
26   */
27  public class BundleInfoUtil {
28      /**
29       * {@value} を表す定数です。
30       */
31      public static final String ACTIVATION_POLICY = "Bundle-ActivationPolicy";
32  
33      /**
34       * {@value} を表す定数です。
35       */
36      public static final String ACTIVATOR = "Bundle-Activator";
37  
38      /**
39       * {@value} を表す定数です。
40       */
41      public static final String CATEGORY = "Bundle-Category";
42  
43      /**
44       * {@value} を表す定数です。
45       */
46      public static final String CLASSPATH = "Bundle-Classpath";
47  
48      /**
49       * {@value} を表す定数です。
50       */
51      public static final String CONTACT_ADDRESS = "Bundle-ContactAddress";
52  
53      /**
54       * {@value} を表す定数です。
55       */
56      public static final String COPYRIGHT = "Bundle-Copyright";
57  
58      /**
59       * {@value} を表す定数です。
60       */
61      public static final String DESCRIPTION = "Bundle-Description";
62  
63      /**
64       * {@value} を表す定数です。
65       */
66      public static final String DOC_URL = "Bundle-DocURL";
67  
68      /**
69       * {@value} を表す定数です。
70       */
71      public static final String LOCALIZATION = "Bundle-Localization";
72  
73      /**
74       * {@value} を表す定数です。
75       */
76      public static final String MANIFEST_VERSION = "Bundle-ManifestVersion";
77  
78      /**
79       * {@value} を表す定数です。
80       */
81      public static final String NAME = "Bundle-Name";
82  
83      /**
84       * {@value} を表す定数です。
85       */
86      public static final String NATIVE_CODE = "Bundle-NativeCore";
87  
88      /**
89       * {@value} を表す定数です。
90       */
91      public static final String REQUIRED_EXECUTION_ENVIRONMENT = "Bundle-RequiredExecutionEnvironment";
92  
93      /**
94       * {@value} を表す定数です。
95       */
96      public static final String SYMBOLIC_NAME = "Bundle-SymbolicName";
97  
98      /**
99       * {@value} を表す定数です。
100      */
101     public static final String UPDATE_LOCATION = "Bundle-UpdateLocation";
102 
103     /**
104      * {@value} を表す定数です。
105      */
106     public static final String VENDOR = "Bundle-Vendor";
107 
108     /**
109      * {@value} を表す定数です。
110      */
111     public static final String VERSION = "Bundle-Version";
112 
113     /**
114      * {@value} を表す定数です。
115      */
116     public static final String DYNAMIC_IMPORT_PACKAGE = "DynamicImport-Package";
117 
118     /**
119      * {@value} を表す定数です。
120      */
121     public static final String EXPORT_PACKAGE = "Export-Package";
122 
123     /**
124      * {@value} を表す定数です。
125      */
126     public static final String EXPORT_SERVICE = "Export-Service";
127 
128     /**
129      * {@value} を表す定数です。
130      */
131     public static final String FRAGMENT_HOST = "Fragment-Host";
132 
133     /**
134      * {@value} を表す定数です。
135      */
136     public static final String IMPORT_PACKAGE = "Import-Package";
137 
138     /**
139      * {@value} を表す定数です。
140      */
141     public static final String IMPORT_SERVICE = "Import-Service";
142 
143     /**
144      * {@value} を表す定数です。
145      */
146     public static final String REQUIRE_BUNDLE = "Require-Bundle";
147 
148     private BundleInfoUtil() {
149 
150     }
151 
152     /**
153      * 指定したバンドルのマニフェスト情報からエントリを取得します。
154      * 
155      * @param bundle
156      *            {@link Bundle} オブジェクト
157      * @param header
158      *            ヘッダ名称 (本クラスの定数を利用して指定できます)
159      * @return 取得できた値
160      */
161     @SuppressWarnings("unchecked")
162     public static String getHeader(final Bundle bundle, final String header) {
163         Dictionary headers = bundle.getHeaders();
164         if (headers != null) {
165             return (String) headers.get(header);
166         }
167         return null;
168     }
169 }