English 中文(简体)
单吨物体如何使用不同舱载体......?
原标题:how use Singleton object in different class loader....?
  • 时间:2011-11-10 12:15:11
  •  标签:
  • java
  • eclipse

in eclipse plugin i have two plug-in which are used there own class loader to load classes.. 2 main problem
Case 1:- in 1st Plugin i made a singleton class and when ever i want it to set some property form another plugin (because singleton so every object will change same object) but it can t do same as i accept.. because for every class loader there its own singleton object....
Case 2:- in 1st or 2nd plugin i made a class with a single staticproperty and through another plugin i want to access that property...
i want to access that property but i can t because every class loader there own name-space that means there own static variable...
what i did is :-
1. i make a class in 1st plugin with a static String variable
2. through 2ND plugin i set the value of that property
3. when i use it through 1st it how its value null and if through 2nd the is show that what i set previously . Now the problem is how i can access those property...in case 1 and case 2

最佳回答

在Eclipse,每个OSGi bundle(plugin)都有自己的班轮。 与其他包裹相比,它们没有等级。

但是,如果你在plugin1中界定一个静态变量,并希望从plugin2中加以利用,那么,如果是plugin2, MANIFEST,的话,你将具备以下标准: MF:

Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %Plugin.name
Bundle-SymbolicName: org.eclipse.ui.examples.propertysheet; singleton:=true
Bundle-Version: 3.2.200.qualifier
Bundle-Activator: org.eclipse.ui.examples.propertysheet.PropertySheetPlugin
Bundle-Vendor: %Plugin.providerName
Bundle-Localization: plugin
Require-Bundle: plugin1
Bundle-ActivationPolicy: lazy
Export-Package: org.eclipse.ui.examples.propertysheet
Bundle-RequiredExecutionEnvironment: J2SE-1.4

<代码>Import-Package和Require-Bundle是正确的方式,只要捆包也使用,即可从一个捆绑到另一个捆锁的班级。 Export-Package

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签