Mahol Dot Org

Icon

Weblog For All Your Need

Acegi Security Grails Acegi Plugin Acegi Tutorial

Number of View :487

Introduction to Grails plugins Grails Plugins Tutorials Understanding Grails Plugins

What is Grails Plugins

What is a plugin

One of the most important factors which makes Grails very configurable is the concept of plug and play plugins. Almost any functionality which needs to be coded in a web application can be introduced via plugins without any code to be written. The beauty of plugin lies in, we donot have to write any code but just include the plugin and customize codes to our requirement.

A plugin is nothing but a regular Grails application with this special file; but when plugin is installed, the plugin structure slightly differs.

Plugin’s structure

When a plugin is installed into a project, the contents of grails-app directory goes into a directory like $PROJECT_HOME/plugins/example-1.0/grails-app . They will NOT be copied into the main source tree. A plugin doesnot tamper a project’s primary source tree.

The plugin directory structure appears as below :

+ grails-app
     + controllers
     + domain
     + taglib
     etc.
 + lib
 + src
     + java
     + groovy
 + web-app
     + js
     + css

The static resources such as those inside the web-app directory will be copied into the project’s web-app directory under a special “plugins” directory for example web-app/plugins/example-1.0/js . It is therefore the responsibility of the plugin to make sure that it references static resources from the correct place. For example if you were

<g:createLinkTo dir="/plugins/example/js" file="mycode.js" />

To make this easier there is a special pluginContextPath variable available that changes whether you’re executing the plugin standalone or whether you’ve installed it into an application:

<g:createLinkTo dir="${pluginContextPath}" file="js/mycode.js" />

At runtime this will either evaluate to /js or /plugins/example/js depending on whether the plugin is running standalone or has been installed in an application.

Java & Groovy code that the plugin provides within the lib and src/java and src/groovy directories will be compiled into the main project’s web-app/WEB-INF/classes directory so that they are made available at runtime.

What a Plugin can and can’t do

A plugin can do just about anything, but a good plugin should be as intrusive as possible. It should use convention over configuration where possible, otherwise provide an artifact in a project’s grails-app/conf directory where configuration can be done.

One thing a plugin cannot do though is modify the web-app/WEB-INF/web.xml or web-app/WEB-INF/applicationContext.xml files. A plugin can participate in web.xml generation, but not modify the file or provide a replacement. A plugin can NEVER change the applicationContext.xml file, but can provide runtime bean definitions .

Number of View :365

Groovy Grails Quick Start Groovy Getting Started Grails Define Groovy

Quick Tutorial to run Groovy On Grails:

The following makes it simple to start a grails project with step wise demonstration.

Quick Start Steps :

  1. Create a Grails project
  2. Configure a Data Source (Optional)
  3. Create a Domain Class
  4. Create a controller
  5. Create Views(Optional)
  6. Start Grails

Step : 1 Create a Grails project

Once you have installed Grails you can use the built-in target for creating new projects:

grails create-app project-name

The project structure below:

%PROJECT_HOME%
    + grails-app
       + conf                 ---> location of configuration artifacts
           + hibernate              ---> optional hibernate config
           + spring                 ---> optional spring config
       + controllers          ---> location of controller artifacts
       + domain               ---> location of domain classes
       + i18n                 ---> location of message bundles for i18n
       + services             ---> location of services
       + taglib               ---> location of tag libraries
       + util                 ---> location of special utility classes
       + views                ---> location of views
           + layouts              ---> location of layouts
   + lib
   + scripts                  ---> scripts
   + src
       + groovy               ---> optional; location for Groovy source files
                                   (of types other than those in grails-app/*)
       + java                 ---> optional; location for Java source files
   + test                     ---> generated test classes
   + web-app
       + WEB-INF

Step : 2 Configure a Data Source (Optional)

The “create-app” command creates a DataSource.groovy file with default contents .

Each data source is configured with an in-memory HSQLDB database ,which is the default configuration.The code looks like :

dataSource {
  pooled = false
  driverClassName = "org.hsqldb.jdbcDriver"
  username = "sa"
  password = ""
}
// environment specific settings
environments {
  development {
    dataSource {
      dbCreate = "create-drop" // one of 'create', 'create-drop','update'
      url = "jdbc:hsqldb:mem:devDB"
//    loggingSql = true
    }
  }
  test {
    dataSource {
      dbCreate = "update"
      url = "jdbc:hsqldb:mem:testDb"
    }
  }
  production {
    dataSource {
      dbCreate = "update"
      url = "jdbc:hsqldb:file:prodDb;shutdown=true"
    }
  }
}

Configuring the data source is a simple matter of changing the values for the desired database and driver and placing the driver jar file in the <..>/lib directory. Properties set in the dataSource node are inherited by the children.

Step : 3 Create a Domain Class

AT first please go to the project directory.

cd my-project
grails create-domain-class ClassName

A domain class is a persistent object and all properties are by default persisted to the database

class ClassName {
    String Course

}

Step : 4 Create a controller

Controllers are request dispatchers in Grails applications they handle web requests and URLs of the request map to a controller class and a closure within the class.

grails create-controller ClassName

Class will be created by name ClassNameController.groovy in path GRAILS_HOME/grails-app/controllers/my/project. You can edit it with your favorite text editor or IDE

Open up this controller and change it as follows to use dynamic Scaffolding which dynamically generates your application at runtime:

class ClassNameController {
     def scaffold = ClassName
}

Alternatively, you could also have run “grails generate-all“, which creates all the scaffolding for you, and left the generated controller alone, instead of replacing it with the default scaffolding. It might be worth learning from.

Step : 5 Start Grails

To start your Grails app run the following target

grails run-app

This will startup an instance of the Jetty servlet engine running on port 8080. To access the list of domain class records open up a browser and type:

http://localhost:8080/project-name/ClassName/list

Or, as the “list” closure is the default action for the ClassNameController you can type:

http://localhost:8080/project-name/ClassName
          Note:

To increase response times during developing try increasing your maximum heap size by setting the JAVA_OPTS environment variable to something like: ‘-Xmx512m’ – this will set the maximum heap size to 512Mb when running Grails hence resulting in  improvement in response.

Number of View :508

Basics Of Groovy Define Groovy Introduction to Groovy

Basics on Groovy Tutorials

Groovy is a scripting language for Java,thus enabling java based development faster than ever before.It runs on grails platform.Talking particularly about web development, groovy on grails cuts more than half of the development work as it creates all the controllers and views itself from the domain classes(model). So,in the nut shell when it comes to MVC pattern in java based web development,groovy is the cherry on the cake,as it cuts down more than half of the development work and it recoganizes all the java pre-existing APIs,thats correct we can use java code in groovy as good as groovy itself.

Following steps describe how to install a binary distribution of Groovy.

  1. Atfirst, Download a binary distribution of Groovy and unpack it into some file on your local file systemset your GROOVY_HOME environment variable to the directory you unpacked the distribution add GROOVY_HOME/bin to your PATH environment variable
  2. Set your JAVA_HOME environment variable to point to your JDK. On OS X this is /Library/Java/Home, on other unixes its often /usr/java etc. If you’ve already installed tools like Ant or Maven you’ve probably already done this step.
  3. You should now have Groovy installed properly. You can test this by typing the following in a command shell:

groovysh
Which should create an interactive groovy shell where you can type Groovy statements. Or to run the Swing interactive console type:

groovyConsole
To run a specific Groovy script type:

Following steps describe how to install grails.

  1. Download latest version of Grails.
  2. Set the environment variable GRAIL_HOME to the home folder of Grails/bin,where you have dwnloaded it.
  3. Set PATH env to GRAIL_HOME/bin

Installation can be checked with grails command line options.

Commands like

  1. grails create-app project-name(Creates a new project)
  2. grails create-domain-class(creates domain class from current working directory as the project folder)
  3. grails generate-views(creates views from current working directory as the project folder)
  4. grails run-app (Runs project)

Grails is an open source framework.It is very flexible and configurable.It lessens the burden of developer as it creates almost all basic codes for domain classes,controllers and views.It is a nice replacement to struts or JSF where all these need to be written from scratch.

Number of View :490

Grade 5 Exam Results 2010 SRI LANKA Exam Department doenets.lk Scholarship Examination Results

Here is update on exam department grade 5 result 2010. Latest on Grade V Examination Sri Lanka Examination results for year 2010. DEPARTMENT OF EXAMINATIONS SRI LANKA website address is

doenets.lkfor Scholarship Examination Results 2010

Grade V Exam Results 2010 topper Sanuja Kalhan Edirisinghe of Pannipitiya Darmapala Vidyala has topped the exam with 196 marks. The cut off marks for Colombo and Gampaha districts are 148 for Sinhala medium

contact
Department of Examinations, Sri Lanka,
National Evaluation and Testing Service,
P.O. Box 1503, Colombo. http://www.doenets.lk/GCE/web/images/dosms.gif
SRI LANKA GRADE V EXAM RESULT 2010. The Commissioner General of the Examination Anura Edirisinghe said that results of the Grade-05 scholarship examination released yesterday will be available on internet by browsing http://www.doenets.lk from mid-day today(23.09.2010).
sri lanka o l results. results grade5 2010. exams@doenets.lk 2010 gread v result. Grade 5 exam results 2010.
Grade V Examination Results 2010.
grade v result galle districts. department of examination 2010 Grade V Exam ; how can i get the sri lanka grade 5 scholarship result 2010. 2010 grade v result. 

Number of View :5174

How To Run .exe In Debug Mode Microsoft Visual Studio 2008

How to run .exe in debug mode microsoft visual studio 2008?
Here are few solutions I got for Running .exe in debug mode using the Windows debugger.

Using Devenv

Devenv allows you to set various options for the integrated development environment (IDE);

/DebugExe

Loads a Visual C++ executable under the control of the debugger. This switch is not available for Visual Basic or Visual C# executable.

Example : if your win32 binary executable name is test.exe then, to run this win32 binary in debug mode use this command on windows command prompt.

C:\tmp>devenv /DebugExe test.exe

Your default debugger will start and loads this binary for debug mode. Then just hit F10 Key to go to main function. For Now on your debugging starts, ie to step into function use F11 key, you can put breakpoints and all debugging stuff.
I assume that you have compiled the binary test.exe with debug flag enabled, else debugger will not find the debug symbols and will not load the code.

Using Image File Execution Options

To setup an application to launch the debugger automatically.
How to: Launch the Debugger Automatically
the Image File Execution Options folder, locate the name of the application you want to debug, such as myapp.exe. If you cannot find the application you want to debug:

  1. right-click the Image File Execution Options folder, and on the shortcut menu, click New Key.
  2. Right-click the new key, and on the shortcut menu, click Rename.
  3. Edit the key name to the name of your application; myapp.exe, in this example.

read more
How to open a file, and go to a line number
devenv /edit E:\code.cpp /command “edit.goto 45″

In this example, devenv will open the code.cpp file, and go to line 45.

Number of View :1398

How To Resolve Error __curr_eh_stack_entry and __eh_curr_region With pgcpp C++ Compiler

Was getting Error __curr_eh_stack_entry and __eh_curr_region With pgcpp C++ Compiler.
check out complete man pgcpp - The Portland Group Inc. C++ compiler

Building an application software using pgcc compiler, developed by C++ Language generates two external references of symbols [__curr_eh_stack_entry] and [__eh_curr_region], and results in kink error. Why?

How To Resolve Error __curr_eh_stack_entry and __eh_curr_region With pgcpp C++ Compiler?

Answer:
Compiler automatically generates these symbols when -exception (C++ exception handling) and -rtti=on (Runtime type information) options are used. If these option is not required to use, Please do not enable them.
source

-rtti(default) –no_rtti An pgcc compiler option switch.
Enable (disable) support for RTTI (runtime type Information) features: dynamic_cast, typeid.

Number of View :535

How To _access Function For Long File Names As Path In Winddows Programming Use UNC

I use the function _access to check for file/directory existence in my program,
Problem definition: I have noticed that the function can’t deal with long file names.  I wanted to check if file is available or not at path located “C:\Documents and Settings\0001″, did Google search on how to give long file names in windows..

How To _access Function For Long File Names As Path In Winddows Programming make Use of UNC standards

Solution use the UNC(Universal Naming Convention) conventions for path to be specified while working with windows programs.

ie the path should be “C:\\Documents and Settings\\0001″

Now The next problem is wanted to use period ie . in file name path,

Eg. I need to use the path as “C:\\Documents and Settings\\.test\\0001″
So tried with something like “\\.\” But The “\\.\” prefix will access the Win32 device namespace instead of the Win32 file namespace.

Then how to Turns off automatic expansion of the path string? Use  the “\\?\” prefix also allows the use of “..” and “.” in the path names. To specify an extended-length path, use the “\\?\” prefix. For example, “\\?\D:\<very long path>”.  Read more about Naming Files, Paths, and Namespaces

That did not help much, and tried directly with “C:\\Documents and Settings\\.test\\0001″ It works.
you can also try the PathFileExists function

access function Return Value

Each function returns 0 if the file has the given mode. The function returns –1 if the named file does not exist or is not accessible in the given mode;

Do share your questions and views..

Number of View :543

How To Debug Err This Application Has Failed To Start Because MSVCR90.dll Was Not Found

Debugging for MSVCR90.DLL was not found error

This application has failed to start because MSVCR90.dll was not found. Re-installing the application may fix this problem.

why is it looking for MSVCR90.DLL while running debug? Shouldn’t it be looking for MSVCR90D.DLL?
While I did not compile it in debug mode.

A quick look using Dependency Walker
And doing windows dog sniffing got the location of msvcr90.dll location, at

C:\Program Files\Microsoft Visual Studio 9.0\VC\ce\dll\x86

If your application linking to both MSVCR90D.DLL and MSVCR90.DLL, then solution is simple, you need to ignore MSVCR90 (and if necessary, MSVCRT) when linking.
Now getting coredll.dll error, since msvcd90.dll links to this dll..
Well What is coredll.dll? I can’t find this dll on my PC and Windows CE device too. coredll.dll is roughly equivalent to kernel32.dll on a PC,
then its asking for mmvcr70.dll and mmvcp70.dll ;

Got downloaded all these dll from this site.
You may also use “dumpbin /imports” to debug dll in windows imports API list and find the category for any dll.

Number of View :967

Fork Implementation In Windows Operating System Vfork Implement in Win32

With little understanding of fork basics here are few more findings on how to vfork implementation in windows operating system and
fork implementation on win32
AT&T Labs Research - Software Tools pick out UWIN: Unix on Windows 95 and NT Machines
Major difference in Linux/Unix functionality and WIN32 applications
Process control and management:
Fork implementation
processes can be created using the fork(2) function, in win32 includes a spawn family of functions that combines the functionality of fork/exec for efficiency.
File descriptor
Open files, pipes, sockets, fifos, and character and block special devices files have file descriptors associated with them. In windows it is called handle.
signals
Most of the unix/linux signals are absent in windows, like SIGALRM
SIGCHLD
SIGHUP
SIGINT
SIGKILL
SIGPIPE
SIGQUIT
SIGUSR1
SIGUSR2
these can be implemented using replacement methods like SIGALRM Time-out alarm can be implemented using SetTimer – WM_TIMER – CreateWaitableTimer
SIGCHLD Change in status of child can be implemented using WaitForSingleObject
Terminal interface for consoles, sockets, and serial lines

sockets based on WINSOCK:

File control locking:

Memory mapping and shared memory
mmap()

System V IPC
semaphore; Shmget can be implemented using CreateFileMaping or
OpenFileMapping
shmdt can be implemented using UnmapViewOfFile
shmat can be implemented using MapViewOfFile
Pipe to _pipe
Close to _close

Runtime linking of dynamically linked libraries : like The dlopen(), dlsym() interface
Error mapping from Windows to UNIX

Symbolic links
Symbolic links to files and directories can be created and can be implemented as Windows shortcuts.

Few Good References for Unix2Win porting

  1. Porting Socket Applications to Winsock
  2. Process and Thread Functions
  3. Winsock Programmer’s FAQ Articles: BSD Sockets Compatibility
  4. LibGW32C for GNU C library for Windows
  5. Unix to Windows Porting Dictionary for HPC
  6. UNIX Application Migration Guide
Number of View :824
Content Protected Using Blog Protector By: PcDrome.

Mahol Dot Org is Digg proof thanks to caching by WP Super Cache