View RSS Feed

All Blog Entries

  1. Creating JAR files

    by , 11-28-2011 at 06:02 PM (My Java Tips)
    This post is all about learning how to create JAR files. After going through this, you will be able to easily create JAR files.


    The basic JAR command syntax is as follows:

    jar cf myjar input-file(s)

    Let me explain the command;

    - c option indicates that I want to create a JAR file
    - f option indicates that I want the output to go to a file rather than to stdout
    - myjar is the name that I want the JAR file to have. It can be ...
    Categories
    Java SE
  2. Finding the Appropriate View in Spring

    by , 11-28-2011 at 01:19 AM
    In my previous tips we have gone through calling the appropriate RESTful methods, returning the results, and the initial parts of the determining the view involving determining the appropriate media type and looked at factors that could influence that decision. In the last tip on RESTful services I will show how the appropriate view is selected.

    Given that our previous post focused on the ContentNegotiatingViewResolver, one would expect that this view resolver directly resolves the ...

    Updated 11-30-2011 at 01:52 PM by Spring Framework

    Categories
    View Helper , MVC , REST , Resource
  3. Factors Influencing Media Type Selection in Spring

    by , 11-28-2011 at 01:17 AM
    In my previous tips, we looked at the components Spring uses to determine the appropriate media type for the results returned. We know that the ContentNegotiatingViewResolver is used to determine what the appropriate media type is for the results. I will discuss the second part of the strategy used for making this determination. This involves factors that influence the requested media type(s).

    After the ContentNegotiatingViewResolver has determined the requested media type, there ...

    Updated 11-30-2011 at 01:51 PM by Spring Framework

    Categories
    MVC , REST , Spring 3 , Resource
  4. Determining the Requested Media Type in Spring MVC

    by , 11-28-2011 at 01:12 AM
    In my previous tips, we looked at the components Spring uses to determine the appropriate media type for the results returned. We know that the ContentNegotiatingViewResolver is used to determine what the appropriate media type is for the results. I will discuss the first part of the strategy used for making this determination. This involves determining the requested media type(s).

    When the controllerís handler method finishes, and a logical view name is usually returned. The DispatcherServlet ...

    Updated 11-30-2011 at 01:44 PM by Spring Framework

    Categories
    View Helper , MVC , REST , Spring 3 , Resource
  5. Resource Representation in Spring

    by , 11-28-2011 at 01:05 AM
    In my previous tips, I looked out how to make the key RESTful method calls. In all of them the controllerís handler method finishes, and a logical view name is usually returned. In the case that the method doesnít return a logical view name (a method returning void) then the logical view name is derived from the requestís URL. The DispatcherServlet passes the view name to a view resolver in order to facilitate the determination of which view should render the results of the request.

    ...

    Updated 11-30-2011 at 01:42 PM by Spring Framework

    Categories
    REST , Resource , Configuration , View , XML
  6. RESTful POST Method in Spring

    by , 11-28-2011 at 01:02 AM
    In my previous tips, I have shown you how to write RESTful methods for GET, PUT and DELETE. In this tip, I will tackle the method which is probably the most used (and abused), the POST method.

    The POST method is the one method that you need to be most mindful of. First it is not safe and second it is not idempotent. Therefore you must take extra care in how you design your URL as well as your method . In this case, I will add another method to the CarController that creates a new ...

    Updated 11-30-2011 at 01:41 PM by Spring Framework

    Categories
    REST , HTTP
  7. RESTful DELETE Method in Spring

    by , 11-28-2011 at 12:59 AM
    Continuing on my previous tip, of showing how to write RESTful methods, in this tip, I will show you how to write RESTful methods using the verb HTTP Verb, PUT.

    There are times when we might want to get rid of a resource in its entirety. In the case we would use the HTTP DELETE method in order to accomplish this. In this case, I will add another method to the CarController that handles the DELETE requests to remove a Car resource:

    Java Code:
    @RequestMapping(value="/{id}",
    ...

    Updated 11-30-2011 at 01:40 PM by Spring Framework

    Categories
    REST , HTTP
  8. RESTful PUT Method in Spring

    by , 11-28-2011 at 12:56 AM
    In my previous tip, I looked at the verbs available for RESTful services. In this tip, I will show you how to write RESTful methods using the verb HTTP Verb, PUT.

    The purpose of the PUT methodís is exactly as it states. Is serves to transfer the resourceís state from the client to the server. For an example of this, please see the following method that Iíve created for putCar() that is annotated to receive a Car object from a PUT request:

    Java Code:
    @RequestMapping(value="/{id}",
    ...

    Updated 11-30-2011 at 01:39 PM by Spring Framework

    Categories
    REST , HTTP
  9. Key REST Verbs

    by , 11-28-2011 at 12:54 AM
    In my previous tip, I looked at setting up RESTful Controllers. Now in the post we will look at the verbs available for RESTful services. . Although this is nice for writing RESTless controllers, it is not ideal for writing RESTful controllers. The reason is that controllers made in this way are action oriented and not resource oriented. This can be easily surmised by the names used for the different requests which are focused on the particular use cases but not on the resources.

    ...

    Updated 11-30-2011 at 01:39 PM by Spring Framework

    Tags: rest, spring, verbs Add / Edit Tags
    Categories
    HTTP , REST
  10. RESTful Controllers in Spring

    by , 11-28-2011 at 12:47 AM
    In my previous tip, I presented to you an overview of how to handle RESTful URLs. In this tip, I will followup will look at RESTful Controllers. From my previous posts, I believe you have surmised that Spring MVCís model is a very flexible framework for for writing controller classes. Almost any method with almost any signature can be annotated to handle a web request. Although this is nice for writing RESTless controllers, it is not ideal for writing RESTful controllers. The reason is that controllers ...
    Categories
    MVC , Controller , REST , Spring 3
  11. RESTful URLs in Spring

    by , 11-28-2011 at 12:31 AM
    In my previous tip, I presented to you an overview of Spring support of REST. In this tip, I will followup with a tip for look at RESTful URLs.

    If you want to create a RESTful controller, you will need to handle URLs in a RESTful way. Thatís because everything thatís done in REST is done through a URL. The URLís RESTful nature is even implied by itís name, uniform resource locator. Given that name, it seems that a URL is intended to locate a resource. Above and beyond this, URLs ...

    Updated 11-30-2011 at 01:37 PM by Spring Framework

    Categories
    Web , Web Service , REST
  12. REST Services in Spring

    by , 11-28-2011 at 12:28 AM
    In Spring 3.0, the Spring team added support for Representational State Transfer (REST). It has emerged as a popular information-centric alternative to traditional SOAP-based web services. Spring developers have taken advantage of the REST architectural model to pack the Spring MVC with first-class support for working with REST. In this tip, we will look at the fundamentals of REST.

    In order to understand what REST is all about, it helps to break down the acronym into its constituent ...
    Categories
    Web Service , REST , Spring 3
  13. Proxying JAX-WS Services in Spring

    by , 11-28-2011 at 12:25 AM
    I have been exploring JAX-WS services in Spring. In this tip, I will look into proxying JAX-WS services on the client side. Consuming web services with Spring involves client-side proxies in a way similar to how Spring based clients consume other remoting technologies.

    Using JaxWsPortProxyFactoryBean is used to wire the Car web service in Spring similar to any other Spring bean. The JaxWsPortProxyFactoryBean is a factory bean that produces a proxy that knows how to talk to a SOAP ...

    Updated 11-30-2011 at 01:36 PM by Spring Framework

    Categories
    Web , Web Service
  14. How to Export JAX-WS EndPoints in Spring

    by , 11-28-2011 at 12:22 AM
    In my previous tip, I showed you how to autowire a JAX-WS endpoint. Although this is very useful, but recognize that the objects whose properties are being injected doesnít have its lifecycle managed by Spring. There are circumstances though, where itís possible to export a Spring-managed bean as a JAX-WS endpoint. In this tip, I will show you how.

    Springís SimpleJaxWsServiceExporter works by publishing Spring-managed beans as service endpoints in a JAX-WS runtime. SimpleJaxWsServiceExporter ...

    Updated 11-30-2011 at 01:35 PM by Spring Framework

    Categories
    Web , Web Service , Spring 3
  15. Intro to Web Services with Spring

    by , 11-27-2011 at 11:02 PM
    One of the most important changes in IT in the last 10 years has been the advent of Service Oriented Architecture (SOA). At the core SOA is the idea of building system via a common set of core services rather than the traditional monolithic method. Java and web services have been intimately intwined. There are a number of options are available for working with web services in Java. Spring facilitates the integration of many of these options. In fact, Spring provides support for publishing and consuming ...

    Updated 11-30-2011 at 01:35 PM by Spring Framework

    Categories
    Web , Web Service , Spring 3
  16. Using SpEL for Spring Security

    by , 11-27-2011 at 10:58 PM
    Sometimes you might need to have a more sophisticated method of defining security constraints. Fortunately as of version 3.0, Spring Security also supports SpEL as a means for declaring access requirements. I will give you show you how to use it in this tip.

    First thing you will need to do is to enable it. To do this, you must set the use-expressions attribute of <http> to true:

    Java Code:
    <http auto-config="true" use-expressions="true">
    ...

    Updated 11-30-2011 at 01:34 PM by Spring Framework

    Categories
    Spring EL , Security
  17. Request Interception with Spring Security

    by , 11-27-2011 at 10:54 PM
    This is the last of a series of tips on Spring Security. From my previous tips, you should be able to configure Spring Security as well as setup login and logout. In the last tip, I will show you how to intercept requests. The <intercept-url> element is the key in the request-level security. Its pattern attribute is provide with a URL pattern that will be matched against incoming requests. If any requests match the pattern, then the <intercept-url>ís security rules will be applied. So ...
  18. Logging Out with Spring Security

    by , 11-27-2011 at 10:52 PM
    In my previous tips, I showed you how to configure and setup Spring Security as well as the login form autogenerated when auto-config is set to true. In this tip, I will show you how to setup the logout for your application. Basically the <logout> element will setup a Spring Security filter that will invalidate a user session. If it is used as is, the filter set up by <logout> is mapped to /j_spring_security_ logout. In order to ensure that there is no collision with the DispatcherServlet, ...
    Categories
    Security , Web , Spring 3
  19. Login Forms with Spring Security

    by , 11-27-2011 at 10:51 PM
    In my previous tips I showed how to add in the necessary servlet filters in your Spring application file and then to configure minimal security in your Spring application. In this tip, we will look at setting up a form for logging into an application.

    As I mention in the last tip, by setting auto-config to true, the autoconfiguration give our a free login page, support for HTTP Basic authentication and logging out, and Spring Security will automatically generate a login page page. ...
    Categories
    Security , Web , Spring 3
  20. Configuring Web Security in Spring

    by , 11-27-2011 at 10:49 PM
    In a previous tip, I showed how to add in the necessary servlet filters in your Spring application file. We added both the Delegating FilterProxy along with the another filter, FilterChainProxy. In general, Spring security will automatically create these beans for you when you configure the <http> element.

    Java Code:
    <http> 
        <form-login />
        <http-basic />
        <logout /> 
        <intercept-url pattern="/**" access="ROLE_USER"
    ...
  21. Setting up Secure Web Requests in Spring

    by , 11-27-2011 at 10:48 PM
    Continuing our investigation of Spring Security, in this tip I will look at making secure web requests. All activities that starts in a java web application is initiated via an HttpServletRequests. As such, this is where the security of your application will start. This security takes the form of request-level security. This involves declaring one or more URL patterns as requiring some level of granted authority and restricting access to those without authority from accessing the content of those ...
  22. Configuring Spring Security

    by , 11-27-2011 at 10:45 PM
    In the last tip, I introduced Spring Security and outlined the modules that are available. In this tip, we will look at configuring namespaces. Using Spring, the nice thing about Spring Security is that all the security elements are configured as beans in the application context. It is not uncommon to have a Acegi configuration containing dozens of bean declarations that span multiple pages.

    Another nice feature is that Spring Security has its own security-specific namespace to simplify ...
  23. Intro to Spring Security

    by , 11-27-2011 at 10:44 PM
    Spring Security is a security framework that started out as Acegi Security and then became an official part of Spring in version 2.0. It provides declarative security for all Spring-based applications. Spring Security handles all aspects of security from authentication to authorization at both the web request level and at the method invocation level. Like many Spring Framework modules, it takes full advantage of dependency injection (DI) and aspect-oriented techniques.

    Irrespective ...
    Categories
    Spring 3 , Security
  24. Defining the Page View with Tiles View Resolvers in Spring MVC

    by , 11-27-2011 at 10:41 PM
    Following on from my previous tip, I will now define the page view from our previous tip. Using Tiles properly, the home page is composed of several distinct pieces. The main_template.jsp file describes the common layout for all pages in the Springexample application, while home.jsp displays the main content for the home page. Plus, carForm.jsp and login.jsp provide additional common elements.
    The home.jsp is where the home page request finishes its journey. It picks up the list of Cars ...
  25. Using Tiles in Spring MVC

    by , 11-27-2011 at 10:39 PM
    In earlier tips, I talked about using Spring MVC and the use of different view technologies. In this tip, I will look at Tiles as a view technology for Spring MVC. Tiles was initially built to be used with the Struts Framework. But as it is a powerful view technology it has been reused by other web frameworks. To use Tiles with Spring MVC you need to register the Tilesí view resolver as a bean with the applicationís xml file, springexamples.xml.

    Java Code:
    <bean class= "org.springframework.web.servlet.view.tiles2.TilesViewResolver"/>
    ...
    Tags: spring mvc, tiles Add / Edit Tags
    Categories
    MVC , Tiles , Spring 3
  26. Using Annotations for Transactions in Spring

    by , 11-27-2011 at 10:38 PM
    In the previous tip, I showed you how you could use XML to define a transaction. In this tip we will look at doing the same using annotations. It is blindly simple to use annotations for transactions. The tx namespace provides the <tx:annotation-driven> element. It appears like this :

    Java Code:
    <tx:annotation-driven transaction-manager="txManager" />
    With this you can now define transaction rules very easily. This tag tells Spring to examine all beans in ...
  27. Configuring Transactions in XML with Spring

    by , 11-27-2011 at 10:33 PM
    Continuing from my previous post, I will demonstrate how you can declare transactions in XML using Spring. Continuing from the previous tips on transaction attributes, letís dive straight in. Spring has a tx configuration namespace to simply declaring transactions in Spring. It is recommended that you include the aop namespace as well since some of the declarative transaction configuration elements use AOP configuration elements. The following shows how <tx:advice> is used for the Car service. ...

    Updated 11-27-2011 at 10:36 PM by Spring Framework

    Categories
    Configuration , Transaction , XML , Spring 3
    Attached Thumbnails Attached Images  
  28. Transaction Propagation Strategies in Spring

    by , 11-27-2011 at 10:29 PM
    In the previous tip, we looked at the key properties that are required for handling any transaction. In Spring, when you want to have your application are using. Spring transaction concepts are taken from the JEE specification specifically the EJB 3.0 specification. Another key aspect of managing transactions is the ability to control the propagation of transactions in your application. Spring has the org.springframework.transaction.TransactionStatus interface that allows an application to check ...
  29. Key Attributes of Spring Transactions

    by , 11-27-2011 at 10:25 PM
    Transactions are defined as doing a business unit of work. It is a key functionality that enable you to control concurrent access of data by multiple business operations. This is done in order to safeguard integrity and ensure that data remains in a consistent state. If for any reason the unit of work could not be completed as an indivisible unit of work, all the changes are unwound and the system is returned to its previous state. The key properties for the design of any application is to ensure ...

    Updated 11-30-2011 at 01:06 PM by Spring Framework

    Categories
    Transaction
  30. How to Test Your Spring MVC Controller

    by , 11-27-2011 at 10:21 PM
    In my previous post, I showed you how to create a HomeController for our home page in your application. You might have noted that there was little code that linked your HomeController with Spring that was included. It is simply a plain old java object (POJO). In this tip, we will look at unit testing your controller. Unit testing your controller will be very easy since a POJO doesnít need you to mock any Spring or other specific objects. I will create a test object using standard naming conventions, ...
    Categories
    MVC , Controller , Test
Page 32 of 48 FirstFirst ... 22303132333442 ... LastLast