The include directive doesn't work for asl files loaded via file: URLs

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

The include directive doesn't work for asl files loaded via file: URLs

Stephen Cranefield-2

I have an application that uses the Jason BDI engine (following the example at https://github.com/jason-lang/jason/blob/master/demos/using-only-jason-BDI-engine/SimpleJasonAgent.java).

 

My application loads asl files via its class loader, and when I am running the code within my IDE (NetBeans) these files are read using URLs of the form file:/<path-to-project-home>/target/classes/<package-path>/agent.asl.

 

However, the implementation of the include directive cannot find files that are included into other files that were read via file: URLs. I am currently using an older version of Jason via maven (version 1.3.9), but the latest version of Include.java on GitHub doesn’t appear to handle file: URLs either.

 

I solved the problem by using my own version of Include.java that has the following added case:

 

Existing code:

                    …

                    } if (outerPrefix.startsWith(CRPrefix)) {

                        // outer is loaded from a resource ("application".jar) file, used for java web start

                        …

                    }

 

Inserted code:

 

                    } else if (outerPrefix.startsWith("file:")) {

                        URL url = new URL(new URL(outerPrefix), file);

                        file = url.toString();

                        in = url.openStream();

                    }

 

Regards,

Stephen


------------------------------------------------------------------------------

_______________________________________________
Jason-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jason-users
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: The include directive doesn't work for asl files loaded via file: URLs

Jomi Hubner
Hi Stephen,

thanks for the proposal!

It was added in the github version!

Regards,

Jomi

> On 28 de ago de 2016, at 22:01, Stephen Cranefield <[hidden email]> wrote:
>
> I have an application that uses the Jason BDI engine (following the example at https://github.com/jason-lang/jason/blob/master/demos/using-only-jason-BDI-engine/SimpleJasonAgent.java).
>  
> My application loads asl files via its class loader, and when I am running the code within my IDE (NetBeans) these files are read using URLs of the form file:/<path-to-project-home>/target/classes/<package-path>/agent.asl.
>  
> However, the implementation of the include directive cannot find files that are included into other files that were read via file: URLs. I am currently using an older version of Jason via maven (version 1.3.9), but the latest version of Include.java on GitHub doesn’t appear to handle file: URLs either.
>  
> I solved the problem by using my own version of Include.java that has the following added case:
>  
> Existing code:
>                     …
>                     } if (outerPrefix.startsWith(CRPrefix)) {
>                         // outer is loaded from a resource ("application".jar) file, used for java web start
>                         …
>                     }
>  
> Inserted code:
>  
>                     } else if (outerPrefix.startsWith("file:")) {
>                         URL url = new URL(new URL(outerPrefix), file);
>                         file = url.toString();
>                         in = url.openStream();
>                     }
>  
> Regards,
> Stephen
> ------------------------------------------------------------------------------
> _______________________________________________
> Jason-users mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/jason-users

--
Jomi Fred Hubner
Federal University of Santa Catarina
Department of Automation and Systems Engineering
PO Box 476, Florianópolis, SC
88040-900 Brazil
http://jomi.das.ufsc.br


------------------------------------------------------------------------------
_______________________________________________
Jason-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/jason-users
Loading...