-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Synchronization extensions #430
Conversation
* | ||
* @return An instance of the extension, or null if the controller doesn't support this extension | ||
*/ | ||
Extension getExtensionInstance(Class<? extends Extension> extensionClass); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should the returned Extension be of the same type as the extensionClass? Why not create a generic type?
It would save you a cast in initializeLockingMap
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should, but couldn't figure out the syntax to get it done using
generics. Do you have a suggestion?
On Thu, Jul 30, 2015 at 12:11 PM, Dennis Crissman notifications@github.com
wrote:
In
extensions/src/main/java/com/redhat/lightblue/extensions/ExtensionSupport.java
#430 (comment)
:
- * Here's how it all comes together:
- * - XXXCrudController: implement ExtensionSupport
- * interface. Implement the getExtensionInstance that returns an
- * instance of the requested extension.
- * - The extension implementation extends Extension interface.
- */
+public interface ExtensionSupport {- /**
\* Returns an instance of the given extension
*
\* @param extensionClass The class for the requested extension
*
\* @return An instance of the extension, or null if the controller doesn't support this extension
*/
- Extension getExtensionInstance(Class<? extends Extension> extensionClass);
Should the returned Extension be of the same type as the extensionClass?
Why not create a generic type?—
Reply to this email directly or view it on GitHub
https://github.com/lightblue-platform/lightblue-core/pull/430/files#r35901263
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be:
E <E extends Extension> getExtensionInstance(Class<E> extensionClass);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops... other way around, sorry.
<E extends Extension> E getExtensionInstance(Class<E> extensionClass);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Then, when I override:
public <E extends Extension> E getExtensionInstance(Class<E>
extensionClass) {
if(extensionClass.equals(LockingSupport.class))
return (Extension)new MongoLockingSupport(this);
else
return null;
}
I get:
error: incompatible types
MongoLockingSupport implements LockingSupport, which extends Extension
On Thu, Jul 30, 2015 at 12:19 PM, Dennis Crissman notifications@github.com
wrote:
In
extensions/src/main/java/com/redhat/lightblue/extensions/ExtensionSupport.java
#430 (comment)
:
- * Here's how it all comes together:
- * - XXXCrudController: implement ExtensionSupport
- * interface. Implement the getExtensionInstance that returns an
- * instance of the requested extension.
- * - The extension implementation extends Extension interface.
- */
+public interface ExtensionSupport {- /**
\* Returns an instance of the given extension
*
\* @param extensionClass The class for the requested extension
*
\* @return An instance of the extension, or null if the controller doesn't support this extension
*/
- Extension getExtensionInstance(Class<? extends Extension> extensionClass);
Oops... other way around, sorry.
E getExtensionInstance(Class extensionClass);
—
Reply to this email directly or view it on GitHub
https://github.com/lightblue-platform/lightblue-core/pull/430/files#r35902236
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Strange, this looks good to my eyes. I pulled down your branches and maven compiled and ran the tests just fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Jdk 7 or 8? 8 isn't compiling it. I think this is valid too, might be a
compiler bug.
On Thu, Jul 30, 2015 at 12:51 PM, Dennis Crissman notifications@github.com
wrote:
In
extensions/src/main/java/com/redhat/lightblue/extensions/ExtensionSupport.java
#430 (comment)
:
- * Here's how it all comes together:
- * - XXXCrudController: implement ExtensionSupport
- * interface. Implement the getExtensionInstance that returns an
- * instance of the requested extension.
- * - The extension implementation extends Extension interface.
- */
+public interface ExtensionSupport {- /**
\* Returns an instance of the given extension
*
\* @param extensionClass The class for the requested extension
*
\* @return An instance of the extension, or null if the controller doesn't support this extension
*/
- Extension getExtensionInstance(Class<? extends Extension> extensionClass);
Strange, this looks good to my eyes. I pulled down your branches and maven
compiled and ran the tests just fine.—
Reply to this email directly or view it on GitHub
https://github.com/lightblue-platform/lightblue-core/pull/430/files#r35906123
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Jdk 7
LOGGER.debug("Inspecting {}",controller.getClass()); | ||
if(controller instanceof ExtensionSupport) { | ||
LOGGER.debug("{} supports extensions",controller.getClass()); | ||
LockingSupport lockingSupport=(LockingSupport)((ExtensionSupport)controller).getExtensionInstance(LockingSupport.class); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The LockingSupport cast should be unnecessary now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I won't hold you up because of that
No description provided.