Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 357657

Summary: Support named resource bindings
Product: z_Archived Reporter: Justin Spadea <jspadea>
Component: EDTAssignee: Justin Spadea <jspadea>
Status: CLOSED FIXED QA Contact:
Severity: enhancement    
Priority: P3 CC: chenzhh, jinfahua, jvincens, mheitz, tww, zhuzhi
Version: unspecified   
Target Milestone: ---   
Hardware: PC   
OS: Linux   
Whiteboard:

Description Justin Spadea CLA 2011-09-14 12:17:37 EDT
After a lengthy discussion about resource bindings it became clear that there are pieces of information that will differ from machine to machine, and those that will differ between development and production. For example SQL information will be different among developer machines during development (different credentials, JDBC jar paths, etc).

Given this, there should be a way to define this information that is local to your machine. Each resource binding type would have two options: 1) specify a URI that describes how to access the information. 2) Specify the information directly (as is done today).

Users will be able to define named binding definitions in preferences. These named bindings will provide the real binding information as you would have formerly defined in the DD file. The definitions will have a unique identifier. The deployment descriptor can then point to these definitions via their unique identifier when running inside the IDE.

The URI for a named resource binding in the deployment descriptor will have different schemes, and each scheme will have a handler that knows how to deal with it. Here are some example schemes for a named REST binding:

1) http://localhost:8080/project/restservices/foo - The deployed service will be invoked directly.
2) workspace://ProjectName/pkg.Service1 - The service will be run locally on a test server.
3) preferences://Service1 - We'll look at the definition named 'Service1' from preferences, which will then tell us how to invoke it (could be http:// or workspace://, or anything else that has defined a handler).

For SQL the URI might look like:
1) jndi://jdbc/SAMPLE
2) workspace://nameOfConnectionProfile
3) preferences://someUniqueBindingId
Your development DD file would probably point to preferences:// and then the value in preferences would be either jndi:// if right now you're running on an app server, or workspace:// if you're running on the jetty test server. It is up to the user to configure the JNDI data source on the app server.

The "Add a Resource Binding" wizard will need to be updated. When you pick REST or SQL, the next page should let you choose whether you want this to be a named binding or whether you want to explicitly define the information. If you choose the named binding option then you should be able to pick from the current list of available binding definitions in preferences (would be nice if you could define a new one right there, or at least pop up the preference page to edit the definitions and then refresh the list in the wizard when the preference page is closed).

The details section of resource bindings in the DD editor should also let you choose between a named binding (maybe a drop-down with a button to open the preference page for configuration) vs explicitly defining binding information (as is done today). The list of properties for an SQL binding would then remove the "JNDI Name" property, since in this case you would use the named option instead of the explicitly defined option.
Comment 1 Justin Spadea CLA 2011-09-14 12:20:01 EDT
Tim / Joe - please correct anything I got wrong, or append anything I left out.
Comment 2 Tony Chen CLA 2011-09-15 11:08:39 EDT
I understand named bindings which points to a defined resource in IDE (using any other toolings), for example, a database connection profile defined by the Data tool, a JNDI configured in the local Tomcat server, an EGL service which can be deployed to debug server. But what is "preferences://Service1"? You mentioned a named resource probably point to preference:// and then the value in preferences would be either "jndi://" or something else. Why isn't the named resource directly pointing to "jndi://" etc? 

I think we may create a new binding type for named binding (instead of adding to the existing SQLBinding or RestBinding). A named resource binding will be just one text field (which saves the URI). Named binding will have its own detail section which only shows the URI. So, you choose what Database binding you are creating, named or explicit, after you created it, you can not switch the type. 

For the new resouce binding wizard, if we just support a few named binding types, maybe we can list them together with the existing two explicit bindings (rest & sql). The wizard will first show you the choice page like below. 

 [] REST Binding
 [] EGL Service on Test Server
 [] SQL Dtabase Binding
 [] JNDI Binding
 [] Reference to Workspace Database Connection
 
 I do not have a strong preference of how the UI should come, so if you feel the originally propose new wizard gives better user experience, I'm fine with it.
Comment 3 Justin Spadea CLA 2011-09-15 14:07:23 EDT
Hi Tony,

We decided in today's scrum that we will not support preference:// in 0.7.0. This means there is no preference page for configuration, and the overall work is greatly reduced. We can add preference support in 1.0.

For a named SQL binding you will use either "jndi://jdbc/SAMPLE" if the application's container will have such a name defined (e.g. running on Tomcat), or "workspace://nameOfConnectionProfile" if running in development mode such as the jetty test server.

For a named REST binding you will use either "http://locationOfService" if you want to invoke a deployed service, or "workspace://ProjectName/pkg.ServiceName" if you want to use the jetty test server.

As for your suggestion to create a new binding type, we actually want to avoid this. Rather than two versions of each binding type, any binding can be a named binding that uses a URI. When you open the "Add a Resource Binding" wizard you will still see just REST and SQL, and the next pages will let the user decide if they want the binding to be a named binding or not.

I'm going to get started on this work this week.
Comment 4 Tony Chen CLA 2011-09-15 21:58:47 EDT
ok, please create separate bugs for me if there's changes need me to take care. Thanks.
Comment 5 Justin Spadea CLA 2011-10-13 10:55:05 EDT
Support for workspace:// was added, and a separate enhancement was opened for preference://, to be implemented post-0.7.0. See bug 360842.
Comment 6 Justin Spadea CLA 2011-10-31 15:49:25 EDT
Verified