Hi, Frank.
That's great news.
I think the issue is very similar as deserializing a java object which
requires the java class to be available. In some cases, we have to subclass
the ObjectInputStream to resolve the class by name (by default TCCL is not
honored).
I think your proposal would work. Is
HelperProvider.setThreadContextTypeHelper() a better method name?
A related question, is the spec going to define a way to link TypeHelpers,
for example, TypeHelper1 will delegate to TypeHelper2?
Thanks,
Raymond
----- Original Message -----
From: "Frank Budinsky" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Wednesday, October 18, 2006 3:16 PM
Subject: SDO INSTANCE fields
I'm sure some of you will be very to happy to hear that the SDO spec group
is starting to consider removing the Helper INSTANCE fields and coming up
with a design to properly handle SDO metadata scoping.
One of the questions that needs to be answered is how to pass a TypeHelper
(metadata scope) to existing code that isn't IOC enabled. For example, SDO
uses Java Serialization to pass DataObjects around. Here's a simple
example of a problem when we don't use a global TypeHelper.INSTANCE:
// get the TypeHelper for my current context
TypeHelper typeHelper = ...
// define the StockQuote type
typeHelper.define(...);
// get a/the DataFactory for the specified TypeHelper scope
DataFactory dataFactory = HelperProvider.getDataFactory(typeHelper);
// create an instance of the defined StockQuote type
DataObject quote = dataFactory.create(..., "StockQuote");
quote.set("companyName", "FlyByNightTechnology");
...
// serialize the quote
ObjectOutputStream out = new ObjectOutputStream(new
FileOutputStream("serializedQuote.xml"));
out.writeObject(quote);
...
// Later we want to read back the quote
ObjectInputStream in = new ObjectInputStream(new
FileInputStream("serializedQuote.xml"));
DataObject inQuote = (DataObject)in.readObject();
PROBLEM: how can the implementation of ObjectInputStream.readObject() find
the metadata needed to create the StockQuote DataObject? It needs to use
the typeHelper instance that has the quote metadata defined.
Does anybody have a suggestion for how this could be made to work. My
first thought was that we may need some way to set the default TypeHelper
for a Thread. Maybe something like this:
HelperProvider.setThreadDefaultTypeHelper(Thread.currentThread(),
typeHelper);
or just:
HelperProvider.setCurrentThreadTypeHelper(typeHelper);
Does this make any sense? If this example used static SDOs, then the TCCL
would also need to be able to load the actual Java implementation class.
Any advice or suggestions would be greatly appreciated.
Thanks,
Frank
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]