{"id":25974598,"url":"https://github.com/dwtj/at-paninij-helloworld","last_synced_at":"2025-03-05T02:31:58.678Z","repository":{"id":78015245,"uuid":"47642717","full_name":"dwtj/at-paninij-helloworld","owner":"dwtj","description":null,"archived":false,"fork":false,"pushed_at":"2015-12-08T18:57:28.000Z","size":68,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2023-08-14T10:10:39.213Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dwtj.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-12-08T18:57:14.000Z","updated_at":"2015-12-08T18:57:29.000Z","dependencies_parsed_at":"2023-02-25T02:30:59.421Z","dependency_job_id":null,"html_url":"https://github.com/dwtj/at-paninij-helloworld","commit_stats":null,"previous_names":[],"tags_count":0,"template":null,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dwtj%2Fat-paninij-helloworld","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dwtj%2Fat-paninij-helloworld/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dwtj%2Fat-paninij-helloworld/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dwtj%2Fat-paninij-helloworld/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dwtj","download_url":"https://codeload.github.com/dwtj/at-paninij-helloworld/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241953550,"owners_count":20048207,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-03-05T02:31:58.138Z","updated_at":"2025-03-05T02:31:58.664Z","avatar_url":"https://github.com/dwtj.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# at-paninij-helloworld\nHow to use @PaniniJ version 0.0.1\n\n## Setting up A @PaniniJ Project\n\nThese are the overall steps to setting up an @PaniniJ project in eclipse:\n\n1. Create a project using JRE 1.8\n2. Download the at-paninij-0.0.1-SNAPSHOT.jar\n3. Enable annotation processing\n4. Add at-paninij annotation processor to your build\n5. Add the at-paninij as a referenced library\n\n\n### 1. Setup project to use JRE 1.8\n\nWhen you create a new project, be sure to choose JRE 1.8, this is necessary for the annotation processing to work correctly.\n\n![alt tag](http://dec1512.sd.ece.iastate.edu/src/img/example/fig1.png)\n\n\n### 2. Download the at-paninij-0.0.1-SNAPSHOT.jar\n\nDownload the JAR from  http://dec1512.sd.ece.iastate.edu/src/snapshot/at-paninij-0.0.1-SNAPSHOT.jar.\n\n\n### 3. Enable Annotation Processing\n\nEnable annotation processing by right clicking on your project in the project explorer and choosing \"properties.\" Browse to `Java Compiler` \u003e `Annotation Processing` and check the `Enable project specific settings` checkbox and `Enable annotation processing`.\n\n![enable annotation processing](http://dec1512.sd.ece.iastate.edu/src/img/example/fig2.png)\n\nOnce you hit `Apply`, Eclipse will inform you that a rebuild on the project is required. You can rebuild the project now.\n\n![confirm rebuild of the project](http://dec1512.sd.ece.iastate.edu/src/img/example/fig3.png)\n\n\n### 4. Add at-paninij annotation processor\n\nNavigate to the `Factory Path` section of the project properties. It is beneath the `Annotation Processing` option. Check the `Enable project specific settings` checkbox, and click the `Add External JARs...` button.\n\n![enable project specific settings](http://dec1512.sd.ece.iastate.edu/src/img/example/fig4.png)\n\nBrowse to where you have downloaded the JAR file from step 2. Hit `Apply` and confirm the projct rebuild.\n\n![include JAR and confirm rebuild](http://dec1512.sd.ece.iastate.edu/src/img/example/fig5.png)\n\n\n### 5. Add the at-paninij as a referenced library\n\nThe @PaniniJ JAR file includes code necessary for the annotation processing and runtime. To include the JAR file as a referenced libaray, right click the project in the project explorer, and choose `Add External Archives...`:\n\n![Add External Archives](http://dec1512.sd.ece.iastate.edu/src/img/example/fig6.png)\n\nBrowse to where you downloaded the JAR file from step 2, and include it in your project. Once it is included, the project should appear like this in the Eclipse project explorer:\n\n![Project explorer view](http://dec1512.sd.ece.iastate.edu/src/img/example/fig7.png)\n\n\n### Finised project setup!\n\nNow you're ready to start programming in @PaniniJ.\n\n## Hello World Example\nThis example is a side-by-side comparison between the @PaniniJ code and regular PaniniJ code. It uses the Helloworld example from [PaniniJ](http://paninij.org/).\n\nThe hello world example consists of four files:\n\n1. The Stream Signature. (`Stream.java`)\n2. The Console Capsule Template which implements the Stream signature. (`ConsoleTemplate.java`)\n3. The Greeter Capsule Template which uses a Stream (`GreeterTemplate.java`)\n4. The HelloWorld Capsule Template which *wires* the Greeter Capsule to use the Console. (`HelloWorldTemplate.java`)\n\n### Stream.java\n\nTo create a Signature, use the `@Signature` annotation included in the `org.paninij.lang` package. The Stream signature defines one method, `void write(String s);`. Notice that the `String` is from the `org.paninij.lang` package. \n\n**@PaniniJ is on the left, PaniniJ is on the right**\n![Stream comparison](http://dec1512.sd.ece.iastate.edu/src/img/example/ex-fig-stream.png)\n\n\n### ConsoleTemplate.java\n\nTo define a Capsule called `Console` we create a concrete class called `ConsoleTemplate`. The @PaniniJ annotation processor will automatically generate the `Console` class. If we did not include word `Template` in the name, the class will not compile. \n\n* **line 6**: The `ConsoleTemplate` is annoted with `@Capsule`. This lets the @PaniniJ know to treat this object as a Capsule definition (template).\n* **line 7**: The template for the (automatically generated) `Console` capsule is called `ConsoleTemplate`. Notice that the `ConsoleTemplate` also implements the `Stream` signature.\n\nThe `void design(Console self) { ; }` method on line `8` is currently required to be included on all Capsules. The Console capsule does not make use of the design method, so it is left empty.\n\nThe capsule must override the methods provided by the `Stream` signature.\n\n**@PaniniJ is on the left, PaniniJ is on the right**\n![Console comparison](http://dec1512.sd.ece.iastate.edu/src/img/example/ex-fig-console.png)\n\n\n### GreeterTemplate.java\n\nThe Greeter capsule generates a message and sends it to a `Stream` to `write()`.\n\n* **line 9**: Include the `@Capsule` annotation\n* **line 10**: To make it a valid capsule definition, the class must have `Template` at the end of the classname.\n* **line 11**: We declare a state variable. Notice that it is **not** initialized. That is done on line `15` in the `init()`` method.\n* **line 12**: We use the `@Wired` annotation to declare a Capsule field (which implements the `Stream` signature) that the `Greeter` Capsule will be \"wired\" with by it's parent Capsule (`HelloWorld`).\n* **line 14-16**: The `init()` method is used to initalize any state variables that the capsule has. In this case it initializes the `message` variable. Notice that we also use `new String(\"Hello World!\");`. This is because we're using the `org.paninij.lang.String` class imported on line `6`.\n* **line 18**: The `design(Greeter self)` method is needs to be present on every capsule template.\n* **line 20**: We define a capsule procedure called `greet()`.\n* **line 21-23**: We `write()` to the `Stream s`. Notice again that we're using `new String(...)`. Also notice that we did not instantiate the `Stream s` object inside this capsule. The `Stream s` will be provided by it's parent. This is similar to line `10` in the PaniniJ example (on the right hand side). \n\n**@PaniniJ is on the left, PaniniJ is on the right**\n![Greeter comparison](http://dec1512.sd.ece.iastate.edu/src/img/example/ex-fig-greeter.png)\n\n\n### HelloWorldTemplate.java\n\n* **line 11-12**: We declare two child capsules, `Console c` and `Greeter g`. These are the same as lines `19-20` in the PaniniJ code (on the right hand side).\n* **line 14-16**: We don't have any state variables to initialize\n* **line 18**: We decare the `design()` method. Notice that a `HelloWorld` capsule will be passed in. The `self` parameter can be passed to `child` capsules to wire. It must be used instead of `this`, because in this context, `this` refers to `HelloWorldTemplate` and not `HelloWorld`, which is an actual capsule.\n* **line 21**: We call the `g.wire(c)`. This will populate the `@Wired Stream s` field on the `GreeterTemplate`.\n* **line 25**: The HelloWorldTemplate just calls `greet()` on it's `@Child` capsule `g`.\n* **line 29-32**:\n\n**@PaniniJ is on the left, PaniniJ is on the right**\n![HelloWorld comparison](http://dec1512.sd.ece.iastate.edu/src/img/example/ex-fig-helloworld.png)\n\n### The Final Output\n```\nPanini: Hello World!\nTime is now: 1429473957091\n```\n\n\n## Known Issues\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdwtj%2Fat-paninij-helloworld","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdwtj%2Fat-paninij-helloworld","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdwtj%2Fat-paninij-helloworld/lists"}