English 中文(简体)
java class creation dynamically and make it accessible across the network different jvms i.e. serializable
原标题:

I have a requirement of creating java classes dynamically and make it accessible different jvms across the network. I tried to use reflection and javassist tool,but nothing worked. Let me explain the scenario we are using Coherence distributed cache. It has a power of doing aggregation/filtering in parallel across the cluster. For example if a class has [dynamic class] has amount variable and getAmount/setAmount methods. Then if we execute COHERENCE queries, it will start process in parallel across the cluster.

I tried to create classes at run time by using javassist and reflection. I am able to access it from single JVM, but when I tried to access the same class from other jvm [through coherence cluster]. I am getting exception of class not found [as remote jvm is not having idea of this class].I can over come this by creating same class dynamically on remote jvm also and access the methods. But coherence in built methods/functions are not able to find the class. could some one help me on this matter

问题回答

A new class that gets created must be available to all nodes of the cluster. It means that the newly created bytecode must get on each node JVM s classpath/classloader. The simplest approach in my mind would be to put the generated classes on a shared network drive and have all JVMs point to that shared network location in their classpaths. Each time a JVM finds a reference to the new class it should load it dynamically from the network share.

You could copy the byte array that was created by javassist and send this byte array over the wire and load this byte array by a custom ClassLoader. This way, the class will be represented on all JVMs.





相关问题
Is there a way to look into L2 hibernate cache?

I have a task to attach Oracle Coherence (it is cache software) in my project. One way of using it is Level2 Hibernate cache. I want to see when hibernate takes results from L2 cache. How can i do ...

Client and Cache configuration for Oracle coherence

I have the specific scenario for which we want to use Coherence as sitributed cache. Which I am gonna describe here. I have 20+ standalone processes which are going to put the data in cache ...

Oracle Coherence w/ ASP.NET application

Is it possible to use Oracle Coherence to provide distributed caching to an ASP.NET application? We would like to use Coherence to scale out an ASP.NET application which does not have distributed ...

Oracle Coherence License Issue

Are there any restrictions for using coherence.jar without any license? coherence.jar is open for downloading without any fee.

热门标签