Hi Gunnar,
Thx for the suggestion.
BTW ( maybe it was not clear as i've not specify it in my previous
messages ):
1) i'm not using javax.activation and mail packages *only for
sending/receive mail* but in general to handle
*attachments in general..
2) this would work if you've the total control on your client code...
but if for example you're usinf
third pard libraries it would not.
Looking around in the net the problem is in the implementation details
of activation and mail packages.
The solution of keeping activation and mail together was a suggestion
that has been confirmed
on osgi-dev mailing list too... so would make sense for me.
Andrea
Il 12/07/2010 11:23, Gunnar Wagenknecht ha scritto:
Hi Andrea,
Am 12.07.2010 10:19, schrieb Andrea Zoppello:
The only solution i've found is to merge activation and mail packages in
the same bundle and make this bundle exporting a specific
version of the two packages and then adjust all my client bundles to
import this version.
I'm using a different approach. Basically, javax.activation allows to
set a custom CommandMap. This allows to inject an OSGi-aware CommandMap.
private void doSend(final Email email) throws EmailException {
final ClassLoader tccl = Thread.currentThread().getContextClassLoader();
try {
// make sure to use *our* bundle class loader
Thread.currentThread().setContextClassLoader(getClass().getClassLoader());
CommandMap.setDefaultCommandMap(getMyCommandMap());
email.send();
} finally {
CommandMap.setDefaultCommandMap(null);
Thread.currentThread().setContextClassLoader(tccl);
}
}
Then I re-used the CommandMap implementation from Geronimo
(org.apache.geronimo.javax.activation.GeronimoMailcapCommandMap).
-Gunnar
--
Andrea Zoppello
Spagic Architect
|
Respect
the environment. Please don't print this e-mail unless you really need
to. |
The information transmitted is intended
only for the person or entity to which it is addressed and may contain
confidential and/or privileged material. Any review, retransmission,
dissemination or other use of, or taking of any action in reliance
upon, this information by persons or entities other than the intended
recipient is prohibited. If you received this in error, please contact
the sender and delete the material from any computer.
|