|
|
Re: OSGi: loading an FXML file from another bundle [message #1132615 is a reply to message #1132561] |
Fri, 11 October 2013 09:14 |
Uwe San Messages: 119 Registered: January 2012 |
Senior Member |
|
|
Hi Tom,
I mentioned the validation and error handling simply to give you some context for why we want a centralised FXML loader. But these details are not relevant for the actual problem. Sorry if that was misleading.
Our current implementation looks similar to this:
public class FXMLLoaderService {
@Inject
private IEclipseContext context;
public Node load(final Class<?> requester, final String filePath) {
FXMLBuilder<Node> builder = InjectingFXMLLoader.create(context, requester, filePath);
Node node = builder.load();
return node;
}
}
The file path is a location within the bundle that contains the requester class.
In your FXMLService example, the loaderFactory.loadBundleRelative() method would use a path relative to the bundle in which the FXMLService is located, I believe. As a consequence, all the FXML files would need to be stored in the same bundle as the FXMLService class. But we want to specify a relative path for the bundle that uses this service such that the FXML files can distributed among multiple bundles.
Apart from that, your error handler extension would be a nice new feature.
Thanks,
Uwe
|
|
|
Re: OSGi: loading an FXML file from another bundle [message #1132634 is a reply to message #1132615] |
Fri, 11 October 2013 09:26 |
Thomas Schindl Messages: 6651 Registered: July 2009 |
Senior Member |
|
|
On 11.10.13 11:14, Uwe San wrote:
> Hi Tom,
>
> I mentioned the validation and error handling simply to give you some
> context for why we want a centralised FXML loader. But these details are
> not relevant for the actual problem. Sorry if that was misleading.
>
>
> Our current implementation looks similar to this:
>
>
> public class FXMLLoaderService {
>
> @Inject
> private IEclipseContext context;
>
> public Node load(final Class<?> requester, final String filePath) {
>
> FXMLBuilder<Node> builder = InjectingFXMLLoader.create(context,
> requester, filePath);
> Node node = builder.load();
> return node;
> }
> }
>
>
> The file path is a location within the bundle that contains the
> requester class.
>
> In your FXMLService example, the loaderFactory.loadBundleRelative()
> method would use a path relative to the bundle in which the FXMLService
> is located, I believe. As a consequence, all the FXML files would need
> to be stored in the same bundle as the FXMLService class. But we want to
> specify a relative path for the bundle that uses this service such that
> the FXML files can distributed among multiple bundles.
No this is the IContextFunction trick, the loadFactory is created in the
correct context (IEclipseContext wise) and OSGi-BundleContext wise so it
would load from the requestor bundle!
Please note that each requestor would get its distinct instance of
FXMLLoaderService, that's what IContextFunctions are good for ;-)
>
> Apart from that, your error handler extension would be a nice new
> feature. :)
>
I still ask myself if FXMLLoaderBuilder could not serve as what you try
to do with the service, or how we'd have to modify it to suite your needs.
Tom
|
|
|
|
Re: OSGi: loading an FXML file from another bundle [message #1137096 is a reply to message #1132634] |
Mon, 14 October 2013 08:56 |
Thomas Schindl Messages: 6651 Registered: July 2009 |
Senior Member |
|
|
On 11.10.13 11:26, Tom Schindl wrote:
> On 11.10.13 11:14, Uwe San wrote:
>> Hi Tom,
>>
>> I mentioned the validation and error handling simply to give you some
>> context for why we want a centralised FXML loader. But these details are
>> not relevant for the actual problem. Sorry if that was misleading.
>>
>>
>> Our current implementation looks similar to this:
>>
>>
>> public class FXMLLoaderService {
>>
>> @Inject
>> private IEclipseContext context;
>>
>> public Node load(final Class<?> requester, final String filePath) {
>>
>> FXMLBuilder<Node> builder = InjectingFXMLLoader.create(context,
>> requester, filePath);
>> Node node = builder.load();
>> return node;
>> }
>> }
>>
>>
>> The file path is a location within the bundle that contains the
>> requester class.
>>
>> In your FXMLService example, the loaderFactory.loadBundleRelative()
>> method would use a path relative to the bundle in which the FXMLService
>> is located, I believe. As a consequence, all the FXML files would need
>> to be stored in the same bundle as the FXMLService class. But we want to
>> specify a relative path for the bundle that uses this service such that
>> the FXML files can distributed among multiple bundles.
>
> No this is the IContextFunction trick, the loadFactory is created in the
> correct context (IEclipseContext wise) and OSGi-BundleContext wise so it
> would load from the requestor bundle!
I have to correct myself, I think this information was wrong the
OSGi-Context might be the wrong one :-( because the requestor is the
service impl :-(
Tom
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.05240 seconds