View Javadoc

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