Announcement Announcement Module
No announcement yet.
Rich-Client Addon Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Rich-Client Addon

    Hi, this is my first post in this forum.

    I'm currently working on my bachelor and my task is to evaluate the potential of Roo for the creation of spring-based Java Rich-Desktop-Clients. I know that there is a project called Spring-RCP that already solved this problem but it looks quite dead to me and I also don't like the idea of creating a new framework when I can also use much of the given Roo functionality for my task. So my approach to this is an add-on for Roo. But it seems quite difficult to find some documentation for addon creation. I already created an addon which is able to add some of the needed dependecies to the project that's to be created but now I'm slowing down because it's hard to find some more detailed information about Roo-Addon-programming.

    So here are my questions:
    • Is there any documenation available except the online-reference-documentation? I'm not able to find much about it.
    • Do you think an addon is an appropriate approach for my given task? And why or why not?

    Thanks for reading this. Would be nice if someone can help me out a little bit.


  • #2
    The trend and momentum today these days is towards HTML5/Flex based apps or complete native Mobile apps. You can witness this in the spring rich client project that not a lot has happened in last year or so (if i am mistaken please correct me)

    You can investigate how an HTML5 app based on Roo can be as good as a desktop app, with caching remote content etc you can do lots of things that native apps want to do.


    • #3
      Thanks for your answer. The thing is, that I already started to develop an addon and I don't have enough time left to change my approach.

      My problem is, that it is hard to get into the internals of roo addon development. I want to implement a controller function like in the web-mvc-controller addon. I already set up an advanced project which is able to add the needed dependencies. It also creates some empty controller classes. But now it's getting hard. I managed to create the aspectj files via the example given when u create a new addon and add an annotation to my controllers. The problem is, i don't really get, how it works. Where do i tell my addon to create an aspectj file for the class with a given annotation?

      Following example is from my OperationsImplementation class:

      public void annotateType(JavaType javaType) {
      		// Use Roo's Assert type for null checks
      		Assert.notNull(javaType, "Java type required");
      		// Retrieve metadata for the Java source type the annotation is being added to
      		String id = physicalTypeMetadataProvider.findIdentifier(javaType);
      		if (id == null) {
      			throw new IllegalArgumentException("Cannot locate source for '" + javaType.getFullyQualifiedTypeName() + "'");
      		// Obtain the physical type and itd mutable details
      		PhysicalTypeMetadata physicalTypeMetadata = (PhysicalTypeMetadata) metadataService.get(id);
      		Assert.notNull(physicalTypeMetadata, "Java source code unavailable for type " + PhysicalTypeIdentifier.getFriendlyName(id));
      		// Obtain physical type details for the target type
      		PhysicalTypeDetails physicalTypeDetails = physicalTypeMetadata.getMemberHoldingTypeDetails();
      		Assert.notNull(physicalTypeDetails, "Java source code details unavailable for type " + PhysicalTypeIdentifier.getFriendlyName(id));
      		// Test if the type is an MutableClassOrInterfaceTypeDetails instance so the annotation can be added
      		Assert.isInstanceOf(MutableClassOrInterfaceTypeDetails.class, physicalTypeDetails, "Java source code is immutable for type " + PhysicalTypeIdentifier.getFriendlyName(id));
      		MutableClassOrInterfaceTypeDetails mutableTypeDetails = (MutableClassOrInterfaceTypeDetails) physicalTypeDetails;
      		// Test if the annotation already exists on the target type
      		if (MemberFindingUtils.getAnnotationOfType(mutableTypeDetails.getAnnotations(), new JavaType("org.springframework.stereotype.Controller")) == null) {
      			// Create JavaType instance for the add-ons trigger annotation
      			JavaType controller = new JavaType("org.springframework.stereotype.Controller");
      			// Create Annotation Metadata
      			AnnotationMetadataBuilder annotationBuilder = new AnnotationMetadataBuilder(controller);
      			// Add annotation to target type
      I just used the code that was in the example and changed it that it uses a @Controller annotation. After the creation of the controller I just inject it to the method above to annotate it and create the aspectj files. But I don't get, how that works in detail. Can somebody help me out?


      • #4
        And I got another question. I want to create my own annotation. I want to give my controller some information about the backing entity like in the web-mvc-controller addon. I saw in different addons that u can create your own Annotation class, parse it to an AnnotationVlaue class and use this one in your Metadata class to get information provided. But there again I got no clue about the internals. Can anyone explain to me how it works or where I can find more information or documentation for this?


        • #5
          Ok, forget my last posts. I just learned that I can trigger the Metadata just by setting an annotation of a specific type. This type has to be declared in the metadata provider class. So is it right that


          protected void activate(ComponentContext context) {
          		metadataDependencyRegistry.registerDependency(PhysicalTypeIdentifier.getMetadataIdentiferType(), getProvidesType());
          		addMetadataTrigger(new JavaType("org.springframework.stereotype.Controller"));
          if the annotation declared is in my list of annotations? And if yes, how does it work? Or if no, what did I get wrong?


          • #6
            A quick, but useful question: Is there anything you need your Rich Client application to be able to do that GWT, or GWT related techs cannot do? Think Gmail, or Wave if you used it.


            • #7

              First, if you used the 'addon create advanced' command you already have a working example of an add-on which creates a java source and the corresponding ITD (.aj).

              Looking at the MVC controller add-on can be a bit overwhelming as this add-on does a lot of things. Maybe you take a look at the more easy to digest addon-tostring. Essentially, ITDs are generated if your add-on produces metadata (you need a ..MetadataProvider and a Metadata type). The MDProvider type is automatically triggered by Roo if a certain trigger annotation is found on a .java source type. The MDProvider then creates a new immutable instance of your Metadata type which defines the contents of the ITD. Roo core will then be able to transform your MD into an AspectJ ITD (.aj).

              Hope this helps,


              • #8
                This helps a lot. Thank you. I will take a look at the toString Addon. I just chose the mvc-controller addon because I also wanted ro implement some controller function. But I'm getting into it more and more.

                So thanks for your helpful answer!!



                • #9
                  Originally posted by Brad Murray View Post
                  A quick, but useful question: Is there anything you need your Rich Client application to be able to do that GWT, or GWT related techs cannot do? Think Gmail, or Wave if you used it.
                  I am not used to GWT. My Rich Client application needs to work offline and online. It connects to a database, which is also used by a web client and therefore my Rich Client has to be able to do some synchronisation. I will implement local business logic and data holding so that it can also work offline.

                  I'm not sure if that answered your question but since my job to to evaluate the potential of Roo for multi-channel applications I can't simply take GWT to create something that works like a Rich Client. I need a real Rich Client.

                  But like I said, I'm not used to GWT so I can't tell what you can do with this tool or with GWT related techs.



                  • #10
                    Sorry if I am a bit annoying but now I got the next problem. :P

                    I want to make use of the fields, that I create within my entities. For example: I want to create a JTextField from a String in my Entity. How can I get the information about that String property out of my entity class and use it for my addon? I tried to understand how it works for the mvc controller addon and got to the jsp addon, but to be honest, it's too complicated for me to understand how it's implemented.