Can Griffon be integrated with other frameworks (like NB Platform)?

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|

Can Griffon be integrated with other frameworks (like NB Platform)?

Marcelo
Hi,

In a different post that mentioned DromblerFX and Griffon, I read a comment from Andres that states that Griffon would not work out-of-the-box with other frameworks because it was not designed in that way.

I would like to work within the NetBeans Platform module system and would like to use Griffon to create an manage the views in a JavaFX-Java application. Is there a way to achieve this or Griffon's design will make this impossible? I know NetBeans Platform can define modules to wrap java libraries and I could use the lifecyle events in NetBeans and linked them to Griffon's.

Also, I have been struggling to create dist jar files of the sources to try to wrap them with NetBeans modules. Can someone tell me how to achieve this? Gradle has officially frustrated me

Thanks!

Reply | Threaded
Open this post in threaded view
|

Re: Can Griffon be integrated with other frameworks (like NB Platform)?

aalmiray
Administrator
Hi Marcelo,

To be honest I haven't heard of someone writing an NB platform + Griffon hybrid application, perhaps mostly because when one writes an NB platform application it's all NB based due to all the facilities, modules, and examples that exist out there.

In principle it's possible to use a modular system with Griffon but I yet to see such application in the wild. Another problem you may face trying to integrate NB platform and Griffon is to determine which framework is the one in charge. My gut feeling tells me it should be NB which means you'll loose some goodies from Griffon (MVC and Addon management for example). My recommendation is to avoid using a modular system but that's just my personal preference after being burned by all major modular systems (OSGi, JBoss modules, NB's).

Regarding the source JARs, the Griffon build defines a `sourceJar` task that can be used to JAR the sources of each subproject. You'll find the JAR in the subproject's build directory, for example `griffon-core/build/libs`. OTOH projects generated using the lazybones templates do not define such task, but you can add it to the build.gradle file

        task sourceJar(type: Jar) {
            group 'Build'
            description 'An archive of the source code'
            classifier 'sources'
            from sourceSets.main.allSource
        }

Cheers,
Andres
Reply | Threaded
Open this post in threaded view
|

Re: Can Griffon be integrated with other frameworks (like NB Platform)?

Marcelo
This post was updated on .
Hi Andres,

I will try to stick to your recommendation yet and ditch the idea of using the NB Modules in favor of Griffon if I cannot make it work in the hybrid mode or if I can get replacements for some of the functionality I am used to with NB. Regarding the last point, I noticed the use of the @ServiceProviderFor annotation: it seems easy to define services and register implementations but is there a way to get all the registered providers for a service in the same way NB's Lookup does?

In Griffon in Action there is information about the griffon command line to create MVC groups and I know the command line was removed from the new versions. Is there anything replacing it? (I'm thinking maybe lazybone's templates that create the groups). Also, can the griffon lazybones templates be used in a Gradle multiproject structure? If so, is there any recommended way to do that?

Thanks again for all your help.

Marcelo.


Reply | Threaded
Open this post in threaded view
|

Re: Can Griffon be integrated with other frameworks (like NB Platform)?

aalmiray
Administrator
Hi Marcelo,

@ServiceProviderFor is used to generate metadata files inside `META-INF/services`. This is just a convenience for automatically generating files that follow the conventions required by JDK6's ServiceLoader. @ArtifactProviderFor works in a similar way but registers Griffon artifacts, which follow a different set of conventions. This artifact metadata is loaded and handled by `griffon.core.artifact.ArtifactManager`. Thus if you want to find all artifacts of a particular type you must use the `ArtifactManager`, for example

    import javax.inject.Inject;
    import griffon.core.artifact.ArtifactManager;
    import griffon.core.artifact.GriffonService;
    import griffon.core.artifact.GriffonServiceClass;

    @Inject
    private ArtifactManager artifactManager;

    artifactManager.getClassesOfType(GriffonServiceClass.TYPE).forEach( gc -> {
        GriffonService s = (GriffonService) artifactManager.newInstance(gc);
        System.out.println(s);
    });

This will print out all services. Don't worry, no duplicate instances will be created as services are automatically registered as singletons.

Lazybones templates have the capability to generate more artifacts, not just the initial project. We make use of this feature too; have a look at http://griffon-framework.org/guide/2.7.0/#_buildtools_lazybones
Basically what you want is

    $ lazybones generate artifact::mvcgroup

Finally, using the provided Griffon templates in a multiple project Gradle build is possible, however you'll have to update the generated files as the project templates assume the Griffon project to a standalone one instead of a part of a bigger build. Please follow the calculator example to get some ideas on how this can be done

    https://github.com/griffon/griffon/tree/development/tutorials/calculator

Cheers,
Andres
Reply | Threaded
Open this post in threaded view
|

Re: Can Griffon be integrated with other frameworks (like NB Platform)?

Marcelo
Hi Andres,

Thanks again for your answers. Being new to Gradle, I read the online documentation for multi-project builds.

Even though I took a look at the calculator project, it was too much for this newbie!

Do you think in a future Griffon could provide lazybones templates to generate basic multi-projects builds Griffon style (meaning sub-projects following Griffon conventions)? Is that even possible? I notice that generating the sub-project myself is quite challenging: I spent long hours trying to figure out the way the build scripts should be and also I lost the help from, lazybones to generate artifacts for me. If I do try to generate the sub-project with lazybones as a basic Griffon ones, I drive myself crazy trying to figure out how to make it work...

Regarding that last point, are there instructions on what to change in a generated lazybones griffon-javafx-java  project (or any project)  to make it work as a subproject? I could not find this information anywhere and my understanding of the whole process limit me from solving the problem properly.

Thanks!,

Marcelo.
Reply | Threaded
Open this post in threaded view
|

Re: Can Griffon be integrated with other frameworks (like NB Platform)?

aalmiray
Administrator
Hi Marcelo,

While it's possible to provide lazybones templates for such scenarios I think the work would be too much, as once you get into a multi-project build you'll quick find out there are many different choices at hand, regardless of Maven or Gradle usage as build tool.

I'm thinking there can be an alternative: a wizard like application that may or may not leverage lazybones to bootstrap the project. This will take some time to be realized.

On your last point, there are no instructions as moving code form the griffon subproject to the root project is a matter of preference. I personally like to put all common concerns on the root project, leaving what's griffon specific on the subproject. Others like to have a single build file, where all subprojects are also configured.

Cheers,
Andres
Reply | Threaded
Open this post in threaded view
|

Re: Can Griffon be integrated with other frameworks (like NB Platform)?

Marcelo
Hi Andres,

Again, thanks for your time.

I understand what you say about the lazybones templates. I also think
the application is a lot of work... IMHO, maybe as an intermediate
approach, either a single lazybones template, a download link in the
tutorial, or another example in the sources of a very basic project
would help newcomers to Griffon to easily get up to speed.

My idea of a basic project is one that could be used as a template for
developing complex decoupled multi-project applications, where its main
point would be how to decouple the application using Griffon's
artifacts.

To give you an example of what I think it would be very valuable, I am
thinking of a structure like this:

Sample-Multi-Project
|
|---- App-Launcher
|
|---- PMVC-Group-One-Service
|
|---- PMVC-Group-All-Services
|
|---- Service-Definition
|
|---- Service1
|
|---- Service2

Where:

App Launcher will display the application and show the MVC Groups
provided by PMVC-Group-One-Service (displaying the output of Service1)
and PMVC-Group-All-Services (displaying the output of both Service1 and
Service2). Each view could be just a simple panel with a button that
will trigger the action.

Service Definition would provide an simple interface (with a trivial
method like 'public String saySomething()') and Service1 and Service2
implementing it with "I'm Service 1" and "I'm Service 2".

Maybe this structure does not make sense, maybe it does. You as a
Griffon developer have a better understanding of what could be useful to
new developers.

If whatever sample project you decide is the best choice has also
testing integrated (like the current -fabulous- Griffon lazybones
templates) it would be terrific: users will leverage on your experience
and will have a very clear starting point to develop multi-project
applications the Griffon way (and obviously with this understanding they
will be free to adapt it to their needs).

If you feel Java and javaFX are the future default technologies for
Griffon, this sample multi-project app could be developed just for those
technologies. Once the concepts are learned from it, developers could
take a look a the more advanced calculator example.

Thanks again for your time and patience!

Marcelo.


On Wed, 2016-07-20 at 00:23 -0700, aalmiray [via griffon-user] wrote:

> Hi Marcelo,
>
> While it's possible to provide lazybones templates for such scenarios
> I think the work would be too much, as once you get into a
> multi-project build you'll quick find out there are many different
> choices at hand, regardless of Maven or Gradle usage as build tool.
>
> I'm thinking there can be an alternative: a wizard like application
> that may or may not leverage lazybones to bootstrap the project. This
> will take some time to be realized.
>
> On your last point, there are no instructions as moving code form the
> griffon subproject to the root project is a matter of preference. I
> personally like to put all common concerns on the root project,
> leaving what's griffon specific on the subproject. Others like to have
> a single build file, where all subprojects are also configured.
>
> Cheers,
> Andres
>
>
> ______________________________________________________________________
> If you reply to this email, your message will be added to the
> discussion below:
> http://griffon-user.74797.x6.nabble.com/Can-Griffon-be-integrated-with-other-frameworks-like-NB-Platform-tp228p233.html 
> To unsubscribe from Can Griffon be integrated with other frameworks
> (like NB Platform)?, click here.
> NAML