View Javadoc

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