top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Discussion about Java Web Optimizer Wro4j?

0 votes
199 views

What is Wro4j?

Wro4j is a tool for analysis and optimization of web resources. It brings together almost all the modern web tools: JsHint, CssLint, JsMin, Google Closure compressor, YUI Compressor, UglifyJs, Dojo Shrinksafe, Css Variables Support, JSON Compression, Less, Sass, CoffeeScript and much more.
 

Getting started is as simple as following 3 steps:

  1. Configure wro4j filter in web.xml
  2. Create WEB-INF/wro.xml file
  3. Add resource to your html

 

1) Wro Filter :

<filter>
  <filter-name>WebResourceOptimizer</filter-name>
  <filter-class>
    ro.isdc.wro.http.WroFilter
  </filter-class>
</filter>
 
<filter-mapping>
  <filter-name>WebResourceOptimizer</filter-name>
  <url-pattern>/wro/*</url-pattern>
</filter-mapping>

2) wro.xml File

<groups xmlns="http://www.isdc.ro/wro">
  <group name="all">
    <css>/asset/*.css</css>
    <js>/asset/*.js</js>
  </group>
</groups> 

3) In HTML

<html>
  <head>
    <title>Web Page using wro4j</title>
    <link rel="stylesheet" type="text/css" href="/wro/all.css" />
    <script type="text/javascript" src="/wro/all.js"/>
  </head>
  <body>
    
  </body>
</html> 

posted Nov 16, 2016 by Manish Tiwari

  Promote This Article
Facebook Share Button Twitter Share Button LinkedIn Share Button


Related Articles

What is Dispatcher Servlet?

Spring's web MVC framework is, like many other web MVC frameworks, request-driven, designed around a central servlet that dispatches requests to controllers and offers other functionality that facilitates the development of web applications. 

Spring's DispatcherServlet however, does more than just that. It is completely integrated with the Spring IoC container and as such allows you to use every other feature that Spring has.

The request processing workflow of the Spring Web MVC DispatcherServlet is illustrated in the following diagram. The pattern-savvy reader will recognize that the DispatcherServlet is an expression of the “Front Controller” design pattern 

Front controller is a typical design pattern in the web applications development. In this case, a single servlet receives all requests and transfers them to to all other components of the application. The task of the DispatcherServlet is to send request to the specific Spring MVC controller.

Example:

<servlet-mapping>
    <servlet-name>dispatcher</servlet-name>
    <url-pattern>/*</url-pattern>
</servlet-mapping>

Video for Dispatcher Servlet

https://www.youtube.com/watch?v=AzI7E81TBfc
 

 

READ MORE

What is Ant in Java?

Apache Ant is a Java library and command-line tool whose mission is to drive processes described in build files as targets and extension points dependent upon each other. The main known usage of Ant is the build of Java applications.

Ant was the first build tool that was created for building Java applications. Ant is implemented in Java, and its build scripts are written in XML. The XML build scripts were easier to understand than the "make" files at that time, so Ant quickly became popular as a build tool among Java developers. Additionally, Ant is an open source project which made it available for free to all developers.

Features

  • Ant is the most complete Java build and deployment tool available.
  • Ant is platform neutral and can handle platform specific properties such as file separators.
  • Ant can be used to perform platform specific tasks such as modifying the modified time of a file using 'touch' command.
  • Ant scripts are written using plain XML. If you are already familiar with XML, you can learn Ant pretty quickly.
  • Ant is good at automating complicated repetitive tasks.
  • Ant comes with a big list of predefined tasks.
  • Ant provides an interface to develop custom tasks.
  • Ant can be easily invoked from the command line and it can integrate with free and commercial IDEs.

Ant is not the only build tool for Java. After Ant came Maven which has standardized how Java projects are built and how dependencies (external JAR files used by your Java project) are managed (specified and downloaded). Today Maven has taken a lot of the popularity that Ant used to have.

 

Video for Ant in Java

https://www.youtube.com/watch?v=Rpe5dkPsBSc

 

READ MORE

What is Spring MVC?

The Spring Web model-view-controller (MVC) framework is designed around a DispatcherServlet that dispatches requests to handlers, with configurable handler mappings, view resolution, locale and theme resolution as well as support for uploading files. 

The default handler is based on the @Controller and @RequestMapping annotations, offering a wide range of flexible handling methods. With the introduction of Spring 3.0, the @Controller mechanism also allows you to create RESTful Web sites and applications, through the @PathVariable annotation and other features.

Spring Web MVC you can use any object as a command or form-backing object; you do not need to implement a framework-specific interface or base class. Spring's data binding is highly flexible: for example, it treats type mismatches as validation errors that can be evaluated by the application, not as system errors. 

Thus you need not duplicate your business objects' properties as simple, untyped strings in your form objects simply to handle invalid submissions, or to convert the Strings properly. Instead, it is often preferable to bind directly to your business objects.

Spring's view resolution is extremely flexible. A Controller is typically responsible for preparing a model Map with data and selecting a view name but it can also write directly to the response stream and complete the request. View name resolution is highly configurable through file extension or Accept header content type negotiation, through bean names, a properties file, or even a custom ViewResolver implementation. 

The model (the M in MVC) is a Map interface, which allows for the complete abstraction of the view technology. You can integrate directly with template based rendering technologies such as JSP, Velocity and Freemarker, or directly generate XML, JSON, Atom, and many other types of content. The model Map is simply transformed into an appropriate format, such as JSP request attributes, a Velocity template model.

Spring MVC, like many other web frameworks, is designed around the front controller pattern where a central Servlet, the DispatcherServlet, provides a shared algorithm for request processing while actual work is performed by configurable, delegate components. This model is flexible and supports diverse workflows.

The DispatcherServlet, as any Servlet, needs to be declared and mapped according to the Servlet specification using Java configuration or in web.xml. In turn the DispatcherServlet uses Spring configuration to discover the delegate components it needs for request mapping, view resolution, exception handling

Video for Spring MVC

https://www.youtube.com/watch?v=xrExTCcv5Qg​

READ MORE

What is Thymeleaf ?

Thymeleaf is a modern server-side Java template engine for both web and standalone environments.

Thymeleaf's main goal is to bring elegant natural templates to your development workflow — HTML that can be correctly displayed in browsers and also work as static prototypes, allowing for stronger collaboration in development teams.

With modules for Spring Framework, a host of integrations with your favourite tools, and the ability to plug in your own functionality, Thymeleaf is ideal for modern-day HTML5 JVM web development — although there is much more it can do.

Thymeleaf is Open Source Software originally created by a Spanish Software Engineer called Daniel Fernández and now developed and maintained by a great team of awesome people.

It is neither made nor backed by any software (or any other type of) company, and it is offered to the public totally free of charge, both in binary and in source code forms, under the Apache License 2.0.

Thymeleaf version numbers have three components: x.y.z (like: 2.0.1).

  • x is the major version number. A change in this number means a rewrite of the core or architecture, or an important amount of changes in the library's APIs which might break backwards compatibility and/or legacy support.
  • y is the minor version number. A change in this number means a moderate set of changes has been applied, offering new features and improvements without changing APIs significantly and providing deprecation periods for all changed features in order to allow for a period of adaptation to the new interfaces.
  • z is the build/bugfix version number. A change in this number means the fix of some bugs or the addition of a series of performance or documentation improvements. Bugfix versions should modify no APIs and be therefore drop-in replacements for any previous version within the same major+minor version.
Video for ThemeLeaf
https://www.youtube.com/watch?v=GcqF_Kt1QBQ​
READ MORE

What is Jetty?

Jetty is an open-source project providing an HTTP server, HTTP client, and javax.servlet container.

Eclipse Jetty provides a Web server and javax.servlet container, plus support for HTTP/2, WebSocket, OSGi, JMX, JNDI, JAAS and many other integrations. These components are open source and available for commercial use and distribution.

Eclipse Jetty is used in a wide variety of projects and products, both in development and production. Jetty can be easily embedded in devices, tools, frameworks, application servers, and clusters. See the Jetty Powered page for more uses of Jetty.

The current recommended version for use is Jetty 9 which can be obtained on the Jetty Downloads page. Also available are the latest maintenance releases of Jetty 8 and Jetty 7,

The Jetty project has been hosted at the Eclipse Foundation since 2009. Prior releases of Jetty have existed in part or completely under the Jetty project at the The Codehaus and Sourceforge before that. See the About page for more information about the history of Jetty.

Jetty implements aspects of the Java EE specification, primarily the Servlet Specification. Recent releases of the Java EE platform have introduced a Web Profile, recognizing that many developers need only a subset of the many technologies under the Java EE umbrella.

While Jetty itself does not ship all of the Web Profile technologies, Jetty architecture is such that you can plug in third party implementations to produce a container customized to your exact needs.

Video for Jetty Server

https://www.youtube.com/watch?v=lvZfEXqIAyE

READ MORE

What is Mockito?

Mockito is a mocking framework, JAVA-based library that is used for effective unit testing of JAVA applications. Mockito is used to mock interfaces so that a dummy functionality can be added to a mock interface that can be used in unit testing.

Mocking is a way to test the functionality of a class in isolation. Mocking does not require a database connection or properties file read or file server read to test a functionality. Mock objects do the mocking of the real service. A mock object returns a dummy data corresponding to some dummy input passed to it.

Benefits

  • No Handwriting − No need to write mock objects on your own.
  • Refactoring Safe − Renaming interface method names or reordering parameters will not break the test code as Mocks are created at runtime.
  • Return value support − Supports return values.
  • Exception support − Supports exceptions.
  • Order check support − Supports check on order of method calls.
  • Annotation support − Supports creating mocks using annotation.
Video for Mockito
https://www.youtube.com/watch?v=79eXGJ2rKZs

 

READ MORE
...