10 Replies Latest reply on Oct 27, 2014 6:33 AM by Ken Finnigan

    Provisioning an extension for an application

    Stephan Kleinert Newbie

      Hello,


      I'm having a little problem implementing a server side extension for LiveOak.

      The system-wide "extend" methods of my extension get called alright, but I can't finde the place to provide my extension to an existing application (so that I get the ApplicationExtensionContext).

      So, how is an extension configured to be valid for an application?

       

      Many thanks in advance,

      Stephan

        • 1. Re: Provisioning an extension for an application
          Ken Finnigan Master

          Hi Stephen,

           

          At present there is no way to "install" a custom extension into an Application, so the only way to do it would be to modify the content of "application.json" manually.

           

          All it needs is a section that specifies a name for the extension in the Application, which can be anything that is not already used for the Application, a 'type' which matches the name of the extension configuration file in /conf/extensions and then whatever 'config' is required for that extension.

           

          This is what the structure looks like for the 'aggregating-filesystem' extension installed as a 'clients' resource within the 'chat-html' application:

              "client": { "type" : "aggregating-filesystem", "config" : { "directory" : "${io.liveoak.js.dir}" } } 

           

          Hope that's of help.

           

          If it doesn't work, drop by #liveoak on freenode and we'll do our best to help

           

          Ken

           

          PS. Thanks for trying out LiveOak and developing a custom Resource. We'd appreciate any feedback about the process of developing a Resource, especially areas that could be easier or where there was any confusion.

          • 2. Re: Provisioning an extension for an application
            Stephan Kleinert Newbie

            Hi Ken,

             

            thanks a lot, works like a charm. I'll let you know how my custom resource works out, and if/when I get stuck somewhere else :-)

             

            Kind regards,

            Stephan

            • 3. Re: Provisioning an extension for an application
              Stephan Kleinert Newbie

              Hi Ken,

               

              another question just cropped up: How do I get the ServiceName frrom an ApplicationExtensionContext? The docs say, the context provides the service name, but I can't seem find it anywhere...

               

              Thanks in advance!
              Stephan

              • 4. Re: Provisioning an extension for an application
                Ken Finnigan Master

                Public mount points result in a service name of 'Services.resource(application().id(), resourceId())' and private mount points have a service name of 'Services.adminResource(application().id(), resourceId())'

                 

                Inside the extension, you can either Services with these same names, create services with a different name (passing that name into mount call), or simply create a RootResource instance (passing it into the mount call)

                 

                Does that explain it, or were you meaning something different?

                 

                Ken

                1 of 1 people found this helpful
                • 5. Re: Provisioning an extension for an application
                  Stephan Kleinert Newbie

                  Thanks for the quick reply... yes, that's what I wanted to know. The documentation  is a bit sketchy when it comes to service names...

                   

                  Kind regards

                  Stephan

                  • 6. Re: Provisioning an extension for an application
                    Ken Finnigan Master

                    No problem.

                     

                    We certainly need to work on our documentation. If you'd like to suggest any improvements, we'd be more than happy to include them

                     

                    Ken

                    • 7. Re: Provisioning an extension for an application
                      Stephan Kleinert Newbie

                      In my case, a simple example for building a service which provides a new resource would be nice; like some kind of skeleton code to build upon...

                       

                      Although I'm pretty sure I did everything according to the methods outlined in the "extensions" docs, I now have the problem that my new resource doesn't get registered

                       

                      I get the applications service name with:


                           ServiceName name = Services.resource(applicationExtensionContext.application().id(), applicationExtensionContext.resourceId());

                       

                      Then, I mount my new endpoint like this:

                       

                              applicationExtensionContext.mountPublic(name);

                              applicationExtensionContext.mountPrivate(new DefaultRootResource("magic"));

                       

                      but upon startup of my service, I get the following error message:

                       

                      JBAS014775:    New missing/unsatisfied dependencies:

                            service liveoak.application-resource.survey.magic (missing) dependents: [service liveoak.application-resource.survey.magic.default-mount]

                       

                      ('survey' is my application, 'magic' the extension...)

                       

                      Any ideas?

                      • 8. Re: Provisioning an extension for an application
                        Ken Finnigan Master

                        If you're using the same service name as ApplicationExtensionContextImpl uses, then you can just use the mountPublic() no arg version.

                         

                        I can tell you it's the mountPublic(name) call that's having the issue.

                         

                        Does the Service you created have a value of RootResource? ie. the service implements Service<RootResource>

                        • 9. Re: Provisioning an extension for an application
                          Stephan Kleinert Newbie

                          The service now implements Service<RootResource> and Extension, but unfortunately I'm still stuck with

                          JBAS014775:    New missing/unsatisfied dependencies:

                           

                          I didn't have the Service<RootResource> part in there before.

                          But there are some abstract methods in Service<T> which are undocumented and not really easy to understand (at least, for me). Basically: What should I return in getValue?

                           

                          Kind regards,

                          Stephan

                          • 10. Re: Provisioning an extension for an application
                            Ken Finnigan Master

                            Stephen,

                             

                            Documentation is an area we're lacking at the moment, apologies for that. We're going to work hard on fixing that over the next couple of months.

                             

                            Basically a "module", which is the unit of code that defines an extension that can be installed into a LiveOak application needs a class that implements Extension, for performing the mount operations for your public and private endpoints, and a class that implements Service<RootResource> which returns the instance of the extensions RootResource class.

                             

                            For example, in the 'git' resource module GitExtension will create a new GitRootResourceService instance, add it as a service and then mount it to the private endpoint. GitRootResourceService upon startup by the services container (ie. when start() is called) will create a new instance of GitRootResource and assign it to a variable of the class. It's the instance of the GitRootResource class which is returned from getValue() in the Service.

                             

                            Regards

                            Ken