Ah ok.. Yeah RuntimeException should work... :)

Bye,
Norman


2011/4/23 USHAKOV, Sergey <[email protected]>:
> Well, I mean something like this:
>
> import java.io.ByteArrayInputStream;
> import javax.xml.transform.Templates;
> import javax.xml.transform.TransformerFactory;
> import javax.xml.transform.stream.StreamSource;
>
> public class XXX extends GenericMatcher {
>  protected static Templates xsltTemplate;
>  private static final String XSLT_EXTRACT_TEXT = "...";
>
>  static {
>   TransformerFactory factory = TransformerFactory.newInstance ();
>   StreamSource xsltSource =
>     new StreamSource (new ByteArrayInputStream (XSLT_EXTRACT_TEXT.getBytes
> ()));
>   try {
>     xsltTemplate = factory.newTemplates (xsltSource);
>   }
>   catch (TransformerConfigurationException e) {
>     throw new RuntimeException ("Error creating compiled XSLT template", e);
>   }
>  }
> ...
> }
>
> static {...} allows to re-use the 'xsltTemplate' object that was created
> once for all instances of the same matcher.
>
> Regards,
> Sergey
>
>
>
> ----- Original Message ----- From: "Norman Maurer"
> <[email protected]>
> To: "James Users List" <[email protected]>
> Sent: Saturday, April 23, 2011 5:06 PM
> Subject: Re: Exception handling in a matcher static initializer block
>
>
>> Which static method you are refer to ?
>>
>> Bye,
>> Norman
>>
>>
>> 2011/4/23 USHAKOV, Sergey <[email protected]>:
>>>
>>> Well, I agree it would be the right approach in any other context.
>>> Unfortunately the compiler does not approve it in a static initializer
>>> and
>>> complains on unhandled exception. It has no objections against a
>>> RuntimeException (the one that is not expected to be caught) though.
>>>
>>> Will JAMES treat a RuntimeException in the right way?
>>>
>>> Regards,
>>> Sergey
>>>
>>>
>>> ----- Original Message ----- From: "Norman Maurer"
>>> <[email protected]>
>>> To: "James Users List" <[email protected]>
>>> Sent: Saturday, April 23, 2011 4:45 PM
>>> Subject: Re: Exception handling in a matcher static initializer block
>>>
>>>
>>>> You should just throw a MessagingException in this case. This will
>>>> make sure JAMES will not start at all.
>>>>
>>>>
>>>> Bye,
>>>> Norman
>>>>
>>>> 2011/4/23 USHAKOV, Sergey <[email protected]>:
>>>>>
>>>>> Hi all,
>>>>>
>>>>> what would be the right behavior for a matcher when an exception
>>>>> happens
>>>>> in
>>>>> its static initializer block?
>>>>>
>>>>> Wrap the exception into a RuntimeException and re-throw? Do a
>>>>> 'e.printStackTrace()'? Something else?
>>>>>
>>>>> Thanks and best regards,
>>>>> Sergey
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> 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]
>>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> 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]
>>
>
>
> ---------------------------------------------------------------------
> 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]

Reply via email to