I have a plugin, which has thread pool sized 5 threads. The threads stay in an array and whenever the array is empty, I create 5 new threads and put them in the array.
Now I have a problem, that when I reupload plugin, the threads keep running, but the array will have 0 threads in there. So each time I reupload plugin, 5 new threads will start running and check the queue for a job.
In a short time after few reuploads of plugin, I will have too many pointless threads running.
Is there a somekind of Jira's OSGi lifecycle API, that if the plugin is being removed(reuploaded), I can listen to that event and stop the old threads. The normal OSGi has this functionality, and since you use Felix+OSGi, you should also have something similar.
EDIT:
I am using hibernate in my pom.xml.
<dependency> <groupId>org.hibernate</groupId> <artifactId>hibernate-core</artifactId> <version>4.1.6.Final</version> </dependency>
After using my own BundleActivator, I get error:
2013-06-12 13:57:15,572 Thread-54 ERROR sellinjaanus 904x1413x1 1lhku79 192.168.54.111 /secure/IssueAction.jspa [osgi.container.felix.FelixOsgiContainerManager] JarContent: Unable to read bytes. java.lang.IllegalStateException: zip file closed at java.util.zip.ZipFile.ensureOpen(ZipFile.java:415) at java.util.zip.ZipFile.getEntry(ZipFile.java:160) at java.util.jar.JarFile.getEntry(JarFile.java:208) at org.apache.felix.framework.util.JarFileX.getEntry(JarFileX.java:61) at org.apache.felix.framework.cache.JarContent.getEntryAsBytes(JarContent.java:120) at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.findClass(ModuleImpl.java:1738) at org.apache.felix.framework.ModuleImpl.findClassOrResourceByDelegation(ModuleImpl.java:716) at org.apache.felix.framework.ModuleImpl.access$200(ModuleImpl.java:73) at org.apache.felix.framework.ModuleImpl$ModuleClassLoader.loadClass(ModuleImpl.java:1690) at java.lang.ClassLoader.loadClass(ClassLoader.java:247) at org.hibernate.id.AbstractPostInsertGenerator.generate(AbstractPostInsertGenerator.java:40) at org.hibernate.event.internal.AbstractSaveEventListener.saveWithGeneratedId(AbstractSaveEventListener.java:118) at org.hibernate.event.internal.DefaultMergeEventListener.saveTransientEntity(DefaultMergeEventListener.java:236) at org.hibernate.event.internal.DefaultMergeEventListener.entityIsTransient(DefaultMergeEventListener.java:216) at org.hibernate.event.internal.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:154) at org.hibernate.event.internal.DefaultMergeEventListener.onMerge(DefaultMergeEventListener.java:76) at org.hibernate.internal.SessionImpl.fireMerge(SessionImpl.java:904) at org.hibernate.internal.SessionImpl.merge(SessionImpl.java:888) at org.hibernate.internal.SessionImpl.merge(SessionImpl.java:892) at com.tech.jira.hibernate.GenericDao.merge(GenericDao.java:77) at com.tech.jira.hibernate.ExternalController.merge(ExternalController.java:34) at com.tech.jira.ssrs.threads.SrssJob.createIssue(SrssJob.java:48) at com.tech.jira.ssrs.threads.SrssJob.execute(SrssJob.java:273) at com.tech.jira.ssrs.threads.Worker.run(Worker.java:23) at java.lang.Thread.run(Thread.java:662)
Community moderators have prevented the ability to post new answers.
I do not have this problem, so you must do something wrong.
See: http://www.osgi.org/javadoc/r4v43/core/org/osgi/framework/BundleActivator.html
But you have to register this into your OSGI
Thanks, this seems promising.
When developing jira plugin I have never used bundleactivator, can you point me into direction, where should I add it into my code or such?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
https://github.com/rdumitriu/jira-qanda/blob/master/pom.xml
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Do I still compile with atlas-package ? Since I tried, but it didnt use my BundleActivator on plugin upload. I was using your POM from here though, I try with this new POM. https://answers.atlassian.com/questions/6374/how-do-i-access-jndi-from-a-version-2-osgi-plugin
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Ok it worked nice, now If i want to add external library, I just add it to the instructions there? or it must be osgi type library? whats the difference between obr file and jar file there?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
OBR is a package which contain bundling instructions + (optional) other jars. Specification allows you to specify index, environment, requirements for resolving other packages and bundles, etc.
Yes, check the bundling instructions, you can add dependencies as well.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Next time, open another question, pls, I've seen just by luck that you changed it. Besides, there are many users outthere, some of them may be better than me :)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.