Wednesday, September 23, 2015

Actionable Data Structures (ADS) in CABOOSE

Team. We have been looking for ways in which we could include an actionable data structure (ADS) in CABOOSE. Considering the current design which has been somewhat organic because we are developing an evolve-able prototype, the primary goals of our use of ADSs should be easy integration with the current code-base, a reduction in the overall number of instructions, increased readability and maintainability, plus a better partitioning of the CABOOSE concerns.  

The Value of an ActionHashMap as a Request Processor
  
Each page concern whose content specification is drawn by a controller application bundle (CAB) represents an entity which is requesting a fulfillment service from the CABOOSE controller. The request is in the form of a unique user-defined identifier such as #PRODUCT_TABLE#. Such a label is a placeholder in an markup template for each concern. This placeholder also doubles as a string replacement variable within its XHTML stencil. In other words, the controller will replace this label with a markup string which provides a specification of the appropriate dynamic content. This content specification is the return value of a given method within a class that provides a bundle of one or more rendering services for the controller. An XML directory file contains a mapping between the user-defined placeholders and its associated rendering methods for each view that the application requests.

So, one can build an ActionHashMap which invokes behavior given a key versus returning only an object. An ActionHashMap can be built for each view based on the XML directory mappings, and when a web application requests that a given #PLACEHOLDER# be drawn with the appropriate markup specification, this placeholder might be used as a key for the ActionHashMap. The resulting object returned by this map's keyed behavior would the markup content string which the controller would inject in the XHTML stencil at the position of the placeholder.

Finally, a traditional HashMap could be built which holds all of the ActionHashMaps as values which are keyed by their associated view name.

It seems that we might have some slight convergence between ADSs and CABOOSE.

Hunt. Peck. Think. Happy Coding. The CABOOSE Team.

Sunday, September 13, 2015

Ozark Tutorial for Netbeans 8.0.2 and the Bundled Glassfish Server + Maven

Team. The work hours are mounting on other projects. Fortunately, the roll-out for Ozark (MVC 1.0) is the Q3 of 2016. From the reading in the early draft it seems that CABOOSE would fit best as a ViewEngine for MVC 1.0 with possible support for the reflective JSP/JSF tags. Ozark has been available for review with the associated test archives since March of 2015. These with a sample Maven project archive are available at the following Google Drive locations:

Googlge Doc Shareable Links for Ozark Archives
java-ee-8-mvc-master.zip
https://drive.google.com/file/d/0B101EUHMgepNTVpGTWNZY0JuTm8/view?usp=sharing
javax.mvc-api-1.0-edr1.jar
https://drive.google.com/file/d/0B101EUHMgepNSHlrU2xaVHR2MHc/view?usp=sharing
ozark-1.0.0-m01.jar
https://drive.google.com/file/d/0B101EUHMgepNVW03RFdVem5JcVU/view?usp=sharing


The following is the first draft of a simple tutorial which shows one how he can compile and run the sample project "getting-started" contained in java-ee-8-mvc-master.zip plus create his own project called the OzarkTemplate.

The tutorial should take about 45 minutes or less:

Compiling and Testing the GettingStarted Ozark MVC Project

A. Transfer the java-ee-8-mvc-master.zip archive from the Google Docs link or GitHub
B. File>Import Project>From ZIP...
C. Browse for the above archive and select Import. Complete any remaining importing steps.
D. Right-click the "getting-started" Maven web archive and select Build with Dependencies.
E. Select Green Run Triangle on Toolbar which will run the project.
F. Select the blue link on the index page which appears and the controller should return hello.jsp.

Preparing for Creating your Own Ozark MVC Project

X. Transfer javax.mvc-api-1.0-edr1.jar and ozark-1.0.0-m01.jar from their listed Google Docs links, java.net, or the web.
Y. These will be used as package denpendencies in our project.
Z. They might be needed if your IDE does not find them automatically.

Creating an Ozark MVC "Hey" Project (Maven-Netbeans 8.0.2 IDE)

1.File>New Project>Maven>Web Application on the the Choose Project Page
2.Select Next
3.Enter OzarkTemplate for Project Name: (Everything else can use the default values) on the Name and Location Page
4.Select Next
5. Ensure that the GlassFish Server 4.1 is the chosen Server: and the Java EE Version: is Java EE 7 Web on the Settings

Page of the New Web Applciation Widget
6. Select Finish

Adding Dependencies

7. In the Project Explorer, right-click the Dependencies Folder under the OzarkTempalte Maven Web Application>Add

Dependency.
8. Enter the following values:
    groupId:     com.oracle.ozark
    artifactId:    ozark
    version:    1.0.0-m01
9. Select a scope of compile.
10. The jar files, ozark-1.0.0-m01.jar and javax.mvc-api-1.0-edr1.jar, are added in the project dependencies.

Adding RESTful web-service

11. In the Project Explorer, right-click the OzarkTemplates Maven Web Application >New>RESTFul WebServices from Patterns
12. Select Simple Root Resource>Next
13. Enter the following value:
    path:         ozark
    Class Name:    OzarkController
14. Select Finish

Editing OzarkController.java

12. In the generated OzarkContoller.java source add the following imports:

import javax.mvc.Controller;
import javax.mvc.View;

13. The annotate the class as a Controller:

...

@Controller
@Path("ozark")
public class OzarkResource {

....

14. The add the following resource method:

...

    @GET
    @Controller
    public String ozarkString(){
        return("/WEB-INF/jsp/hey.jsp");
    }

...

Creating "hey.jsp"

15. In the Project Explorer, right-click the OzarkTemplates Maven Web Application >New>JSP
16. Enter the following value:
    FileName:     hey
17. Select Finish.
18. Place the following content in hey.jsp:
...
<title>Ozarkian HEY</title>
...
<h1>Hey! From the Ozarks</h1>
...

19. Right-click the WEB-INF folder>New>Folder
20. Enter the following value:
    FolderName:     jsp
21. Select Finish.
22. Drag hey.jsp and drop it on the newly created jsp folder.

Creating a link which activates the controller.

23. Place the following content in the body of the index.html file:
...
<a href="ozarkHey/ozark">Ozark</a>
...

Testing WebApp

19. In the Project Explorer, right-click the OzarkTemplates Maven Web Application >Set As Main Project
20. Select Green Run Triangle on Toolbar which will build and run the project.
21. Select the Ozark link on the index page which appears. The hey.jsp page content should appear.


Hope it was fun! The CABOOSE Team... Hunt...Peck...Think...!