Skip to content
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

Merged
merged 6 commits into from
Jul 30, 2015
Merged

Conversation

bserdar
Copy link
Contributor

@bserdar bserdar commented Jul 30, 2015

No description provided.

*
* @return An instance of the extension, or null if the controller doesn't support this extension
*/
Extension getExtensionInstance(Class<? extends Extension> extensionClass);
Copy link
Member

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

Copy link
Contributor Author

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
.

Copy link
Member

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);

Copy link
Member

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);

Copy link
Contributor Author

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
.

Copy link
Member

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.

Copy link
Contributor Author

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
.

Copy link
Member

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);
Copy link
Member

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.

Copy link
Member

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

dcrissman added a commit that referenced this pull request Jul 30, 2015
Synchronization extensions
@dcrissman dcrissman merged commit 7b6ecd0 into lightblue-platform:master Jul 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants