Create a new resource type from scratch

  • Run build Script

    • First we create an empty resource-type. For this type following build script in the console
          ./build.sh new-resource-type for Linux
           build.bat new-resource-type for windows
    • It will ask you for a name for your resource-type and type a name (e.g.: your-resource)
    • It asks you for a namespace for your resource. Insert a namespace:( e.g. http://yourname.org/yanel/resource/1.0)
    • Then give a short description for your resource-type
    • Now it asks you for a package name where java class of your resource type to be stored. Type a package e.g. org.wyona.yanel.impl.resources.yourpackage
    • Enter a java class name of this resource-type (e.g.YourResource)
    • Now choose the template for your java class. Type any one of the following: (empty, xml, usecase, examples).
    • Then it will ask to implement some interfaces to your java class.Type yes to implement interfaces.
    • You will be asked for the different interfaces. Type yes for necessary interfaces.
    • Now the newly created resource is available in the following directory. $YANELHOME/src/contributions/resources

    Your resource type directory contains the following:

    • ./yanel-htdocs/doc/index.html
    • ./yanel-htdocs/icons/scalable/rt-icon.svg
    • ./yanel-htdocs/icons/32x32/rt-icon.png
    • ./yanel-htdocs/icons/22x22/rt-icon.png
    • ./yanel-htdocs/icons/16x16/rt-icon.png
    • ./resource.xml
    • ./build.xml
    • ./src/build/dependencies.xml
    • ./src/build/build.properties
    • ./src/java/org/yourname/yanel/impl/resources/ YourResource.java
  • Register New Resource

    • Register your newly created resource to the local.resource-type.xml ($YANELHOME/conf/local/local.resource-type.xml) by adding following line:
               <resource-type src="@YANEL_SRC_DIR@/src/contributions/resources/your-resource/" compile="true"/>
  • Implement Functionality

    • Implement necessary functionality in the YourResource.java.
  • Rebuild Yanel

    • Rebuild the Yanel so that yanel can build our newly created resource-type also.
    • Please note that a resource type can also be built on its own (e.g. ./build.sh -f src/resources/xml/build.xml), whereas one might has to update the dependencies (e.g. src/resources/xml/src/build/dependencies.xml)
  • Restart Yanel

    • Type build script ./yanel.sh start for Linux or start-yanel.bat for Windows
    • Your new resource type should be listed now at http://127.0.0.1:8080/yanel/
  • Add Resource Type configuration

    • Yanel looks up a configuration for a requested URL, to determine what resource-type to use. This resource-type configuration files are located in the repository which is configured as the rti (resource type identifier) repository in a realm.
    • (e.g $YANELHOME/src/realms/use-cases/yanel/rti/your-resource.html.yanel-rc)
    				<?xml version="1.0"?><yanel:resource-config xmlns:yanel="http://www.wyona.org/yanel/rti/1.0">
    				  <yanel:rti name="hello-world"namespace="http://yourname.org/yanel/resource/1.0"/></yanel:resource-config>
  • Browse Resource

    • You can view the newly created resource by browsing http://localhost:8080/yanel/test/use-cases/your-resource.html.