View Javadoc

1   package com.atlassian.plugin.osgi.factory;
2   
3   import com.atlassian.plugin.*;
4   import com.atlassian.plugin.elements.ResourceLocation;
5   import com.atlassian.plugin.elements.ResourceDescriptor;
6   
7   import java.util.*;
8   
9   import org.osgi.framework.Bundle;
10  import org.osgi.framework.Constants;
11  
12  /**
13   * Plugin that wraps an OSGi bundle that has no plugin descriptor.
14   */
15  public class OsgiBundlePlugin extends OsgiPlugin
16  {
17  
18      private Bundle bundle;
19      private PluginInformation pluginInformation;
20      private Date dateLoaded;
21  
22      public OsgiBundlePlugin(Bundle bundle)
23      {
24          super(bundle);
25          this.bundle = bundle;
26          this.pluginInformation = new PluginInformation();
27          pluginInformation.setDescription((String) bundle.getHeaders().get(Constants.BUNDLE_DESCRIPTION));
28          pluginInformation.setVersion((String) bundle.getHeaders().get(Constants.BUNDLE_VERSION));
29          this.dateLoaded = new Date();
30      }
31      
32  
33      public int getPluginsVersion()
34      {
35          return 2;
36      }
37  
38      public void setPluginsVersion(int version)
39      {
40          throw new UnsupportedOperationException("Not available");
41      }
42  
43      public String getName()
44      {
45          return (String) bundle.getHeaders().get("Bundle-Name");
46      }
47  
48      public void setName(String name)
49      {
50          throw new UnsupportedOperationException("Not available");
51      }
52  
53      public String getI18nNameKey()
54      {
55          return bundle.getSymbolicName();
56      }
57  
58      public void setI18nNameKey(String i18nNameKey)
59      {
60          throw new UnsupportedOperationException("Not available");
61      }
62  
63      public String getKey()
64      {
65          return bundle.getSymbolicName();
66      }
67  
68      public void setKey(String aPackage)
69      {
70          throw new UnsupportedOperationException("Not available");
71      }
72  
73      public void addModuleDescriptor(ModuleDescriptor moduleDescriptor)
74      {
75          throw new UnsupportedOperationException("Not available");
76      }
77  
78      public Collection getModuleDescriptors()
79      {
80          return Collections.emptyList();
81      }
82  
83      public ModuleDescriptor getModuleDescriptor(String key)
84      {
85          return null;
86      }
87  
88      public List getModuleDescriptorsByModuleClass(Class aClass)
89      {
90          return null;
91      }
92  
93      public boolean isEnabledByDefault()
94      {
95          return true;
96      }
97  
98      public void setEnabledByDefault(boolean enabledByDefault)
99      {
100         throw new UnsupportedOperationException("Not available");
101     }
102 
103     public PluginInformation getPluginInformation()
104     {
105         return pluginInformation;
106     }
107 
108     public void setPluginInformation(PluginInformation pluginInformation)
109     {
110         throw new UnsupportedOperationException("Not available");
111     }
112 
113     public void setResources(Resourced resources)
114     {
115         throw new UnsupportedOperationException("Not available");
116     }
117 
118     public boolean isSystemPlugin()
119     {
120         return false;
121     }
122 
123     public boolean containsSystemModule()
124     {
125         return false;
126     }
127 
128     public void setSystemPlugin(boolean system)
129     {
130         throw new UnsupportedOperationException("Not available");
131     }
132 
133     public boolean isBundledPlugin()
134     {
135         return false;
136     }
137 
138     public Date getDateLoaded()
139     {
140         return dateLoaded;
141     }
142 
143     public boolean isUninstallable()
144     {
145         return true;
146     }
147 
148     public boolean isDeleteable()
149     {
150         return true;
151     }
152 
153     public boolean isDynamicallyLoaded()
154     {
155         return true;
156     }
157 
158 
159     public List getResourceDescriptors()
160     {
161         return Collections.emptyList();
162     }
163 
164     public List getResourceDescriptors(String type)
165     {
166         return Collections.emptyList();
167     }
168 
169     public ResourceLocation getResourceLocation(String type, String name)
170     {
171         return null;
172     }
173 
174     public ResourceDescriptor getResourceDescriptor(String type, String name)
175     {
176         return null;
177     }
178 
179 }