Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Epsilon » A Problem Deploying a Plug-in with ETL
A Problem Deploying a Plug-in with ETL [message #639460] Tue, 16 November 2010 11:25 Go to next message
Andy Ed is currently offline Andy Ed
Messages: 41
Registered: December 2009
Member
Hi,
I'm attempting, for the first time, to deploy my ETL files in a plug-in. I have a problem extracting a URL from the bundle in the following code. I use the URL to create a file to pass to the parser.


module = createModule();
// Create the path to the bundle
IPath bundlePath = new Path(etlPath.segment(0).toString());
// Create the path to the ETL file (relative to the bundle)
IPath filePath = new Path(etlPath.toString()).removeFirstSegments(1);
// Get the bundle and file, convert the file to a file URI
Bundle bundle = Platform.getBundle(bundlePath.toString());
URL url = FileLocator.find(bundle, filePath, null);
java.net.URI fileURI = FileLocator.toFileURL(url).toURI();
File etlFile = new File(fileURI);

module.parse(etlFile);


FileLocator.find(bundle, filePath, null) works in my development environment, but not in the deployed system.
My questions are: is this the correct approach for accessing the ETL file in a deployed plug-in? If so, why does FileLocator (and other methods) fail to return the URL ?

Cheers, Andy
Re: A Problem Deploying a Plug-in with ETL [message #639618 is a reply to message #639460] Wed, 17 November 2010 03:35 Go to previous messageGo to next message
Dimitrios Kolovos is currently offline Dimitrios Kolovos
Messages: 1776
Registered: July 2009
Senior Member
Hi Andy,

Two thoughts:

1. Could you check that the folder containing your transformation is
exported in the compiled plugin (should be checked in the "Build" tab of
MANIFEST.MF)

2. The code I'm using to find ETL/EOL files in EuGENia looks a bit
different:

....
URI uri = bundle.getResource("transformations/t.etl").toURI();
module.parse(uri);
....

Could you please give these a go and let me know if any of them fixes
the problem?

Cheers,
Dimitris

On 16/11/2010 16:26, Andy wrote:
> Hi,
> I'm attempting, for the first time, to deploy my ETL files in a plug-in.
> I have a problem extracting a URL from the bundle in the following code.
> I use the URL to create a file to pass to the parser.
>
>
> module = createModule();
> // Create the path to the bundle
> IPath bundlePath = new Path(etlPath.segment(0).toString());
> // Create the path to the ETL file (relative to the bundle)
> IPath filePath = new Path(etlPath.toString()).removeFirstSegments(1);
> // Get the bundle and file, convert the file to a file URI
> Bundle bundle = Platform.getBundle(bundlePath.toString());
> URL url = FileLocator.find(bundle, filePath, null);
> java.net.URI fileURI = FileLocator.toFileURL(url).toURI();
> File etlFile = new File(fileURI);
>
> module.parse(etlFile);
>
>
> FileLocator.find(bundle, filePath, null) works in my development
> environment, but not in the deployed system. My questions are: is this
> the correct approach for accessing the ETL file in a deployed plug-in?
> If so, why does FileLocator (and other methods) fail to return the URL ?
>
> Cheers, Andy
Re: A Problem Deploying a Plug-in with ETL [message #639619 is a reply to message #639460] Wed, 17 November 2010 03:49 Go to previous messageGo to next message
Andy Ed is currently offline Andy Ed
Messages: 41
Registered: December 2009
Member
Ok I see I can parse a URI - I'll see if this works and get back to you Smile
Re: A Problem Deploying a Plug-in with ETL [message #639641 is a reply to message #639619] Wed, 17 November 2010 05:21 Go to previous messageGo to next message
Andy Ed is currently offline Andy Ed
Messages: 41
Registered: December 2009
Member
Ok, the following works, and gets a URI which can be parsed.

Bundle bundle = Platform.getBundle(bundlePath.toString());
URL fileURL = FileLocator.find(bundle, filePath, null);
java.net.URI uri = fileURL.toURI();

module.parse(uri);


I get the following exception when reaching the part where we try to open the imported files,

java.io.FileNotFoundException: /org.eventb.codegeneration.common/epsilon/TEB_IL1_IniValSubs titution.etl
at org.eclipse.osgi.framework.internal.protocol.bundleentry.Han dler.findBundleEntry(Handler.java:44)
at org.eclipse.osgi.framework.internal.core.BundleResourceHandl er.openConnection(BundleResourceHandler.java:175)
at java.net.URL.openConnection(Unknown Source)
at java.net.URL.openStream(Unknown Source)
at org.eclipse.epsilon.eol.AbstractModule.parse(AbstractModule. java:103)
......



It seems to be that the URL for the attempted import is wrong, since the imported ETL files reside in a different plug-in (thus bundle). I also think that the plug-in name 'org.eventb.codegeneration.common' would need to be removed to retrieve the bundle correctly.


bundleentry://436.fwk6206601/src/teb_il1Src/TEB_IL1_MULTITAS K.etl
bundleentry://436.fwk6206601/org.eventb.codegeneration.commo n/epsilon/TEB_IL1_IniValSubstitution.etl

Investigation continues ...

Andy
Re: A Problem Deploying a Plug-in with ETL [message #639656 is a reply to message #639618] Wed, 17 November 2010 06:01 Go to previous messageGo to next message
Andy Ed is currently offline Andy Ed
Messages: 41
Registered: December 2009
Member
Yes, I've tried both approaches that you suggest, and the problem still seems to be with obtaining the URI from the following:

URI uri = bundle.getResource(filePath).toURI();

The resource is not being found.

I cannot see anything wrong with the filePath

src/teb_il1Src/TEB_IL1_MULTITASK.etl

and the bundle is apparently accessible.
Re: A Problem Deploying a Plug-in with ETL [message #639667 is a reply to message #639656] Wed, 17 November 2010 07:21 Go to previous messageGo to next message
Andy Ed is currently offline Andy Ed
Messages: 41
Registered: December 2009
Member
Dimitris,

I think I'm getting there slowly! I can now obtain a valid URL in the deployment and begin parsing. (I was missing ETL files in my build options).

So I'm back to the following problem - accessing imported files. I suspect it may be arising because the files reside in a different plug-in to the main file. I have ETL that is shared between plug-ins.

java.io.FileNotFoundException: C:\rodin1.3\configuration\org.eclipse.osgi\bundles\893\1\org .eventb.codegeneration.common\epsilon\TEB_IL1_IniValSubstitu tion.etl (The system cannot find the path specified)
at java.io.FileInputStream.open(Native Method)
at java.io.FileInputStream.<init>(Unknown Source)
at java.io.FileInputStream.<init>(Unknown Source)
at sun.net.www.protocol.file.FileURLConnection.connect(Unknown Source)
at sun.net.www.protocol.file.FileURLConnection.getInputStream(U nknown Source)
at java.net.URL.openStream(Unknown Source)
at org.eclipse.epsilon.eol.AbstractModule.parse(AbstractModule. java:103)


Do you think that having ETL in different plug-ins is causing a problem? If so, is there a quick fix ?

I guess I could duplicate the ETL in each plug-in.


Andy
Re: A Problem Deploying a Plug-in with ETL [message #639730 is a reply to message #639667] Wed, 17 November 2010 10:41 Go to previous messageGo to next message
Andy Ed is currently offline Andy Ed
Messages: 41
Registered: December 2009
Member
Dimitris,

further to my investigations ...
In org.eclipse.epsilon.commons.util.UriUtil, where the path is resolved to the parent's path, the imported plug-in is assumed to have the same path as the parent - is that correct??

We would need to have details of the imported plug-in's path at this point.


public static URI resolve(String path, URI... relativeTo) throws URISyntaxException {

...

for (URI parent : relativeTo) {
...

final URI resolved = parent.resolve(path);
...
}
...
}



Do you have any thoughts/suggestions.

Andy

Re: A Problem Deploying a Plug-in with ETL [message #639758 is a reply to message #639730] Wed, 17 November 2010 11:54 Go to previous messageGo to next message
Dimitrios Kolovos is currently offline Dimitrios Kolovos
Messages: 1776
Registered: July 2009
Senior Member
Hi Andy,

Off the top of my head, I believe you can import files residing in other
plugins using "platform:/plugin/..." URIs e.g.

import "platform:/plugin/my.other.plugin/some.eol";

Cheers,
Dimitris

Andy wrote:
> Dimitris,
>
> further to my investigations ...
> In org.eclipse.epsilon.commons.util.UriUtil, where the path is resolved
> to the parent's path, the imported plug-in is assumed to have the same
> path as the parent - is that correct??
>
> We would need to have details of the imported plug-in's path at this point.
>
>
> public static URI resolve(String path, URI... relativeTo) throws
> URISyntaxException {
>
> ..
>
> for (URI parent : relativeTo) {
> ..
>
> final URI resolved = parent.resolve(path);
> ..
> }
> ..
> }
>
>
> Do you have any thoughts/suggestions.
>
> Andy
>
>
Re: A Problem Deploying a Plug-in with ETL [message #639924 is a reply to message #639758] Thu, 18 November 2010 07:35 Go to previous message
Andy Ed is currently offline Andy Ed
Messages: 41
Registered: December 2009
Member
Dimitris,

Success!! I used the following:

import " platform://org.eventb.codegeneration.common/plugin/org.event b.codegeneration.common/epsilon/TEB_IL1_IniValSubstitution.e tl";

So something of the form ....

import "platform://<pluginName>/plugin/<bundleName>/<path>/<fileName>";

It doesn't syntax-check but looks like it will work.

Cheers, Andy
Previous Topic:[EWL] Accessing model
Next Topic:Validation test for my GMF editor
Goto Forum:
  


Current Time: Sat Aug 23 01:50:25 EDT 2014

Powered by FUDForum. Page generated in 0.01756 seconds