https://www.youtube.com/watch?v=xTGkWSZkyNg
https://www.youtube.com/watch?v=K43qyHJXmWI
Showing posts with label Spring. Show all posts
Showing posts with label Spring. Show all posts
Saturday, June 9, 2018
Saturday, January 12, 2013
Spring Configuration Options: XML vs. Annotations
http://www.theserverside.com/tip/How-the-Java-Config-Module-Pounced-on-Spring-30
Spring Configuration Options: XML vs. Annotations
The XML camp talks about separation of concerns. XML configuration is outside the classes. The whole configuration can be viewed easily in only a few files. Furthermore, configuration can change without recompiling, etc.
Cons of XML could be that we have all these String values that need to be converted. Typos occur all over the place, they are difficult to debug, and they are not type safe because of the Strings.
The Annotations party, like myself, like the type safety of annotations. It can also self document a class, so that you can look in the class and truly see what is being injected by Spring.
The cons of Annotations is that it clutters the POJO, sometimes where you might say it is not a POJO anymore. If you change, add or delete, annotations require a recompilation and deployment.
So, who wins the debate?
Guess what: they are all correct. There is no best answer to this debate. So wouldn't it be great if we could get the 'pro' benefits of both styles and remove the cons.
With @Configuration, we can do just that.
With @Configuration, we can do just that.
@Configuration is configuration using Java classes. Each @Configuration Java class is its own configuration. Since it is Java, it is type safe, we can keep it as a POJO (with just a couple of annotations, we promise not too much), and we can have a clean separation of concerns. We will also have a single resource representing the application's configuration, and we can change it without having to change our application code.
Thursday, July 26, 2012
Android & Twitter - OAuth authentation
http://automateddeveloper.blogspot.com/2011/06/android-twitter-oauth-authentication.html
I’ve seen a lot of questions about connecting Android apps with Twitter using OAuth and thought I would write up a walk-through of how it can be done. The example will be done using Twitter4J which is a great library for connecting Java apps with Twitter and provides a simple interface to connect to the public Twitter Web Services.
First thing you will need to do is to register your new app (even though you haven’t made it yet!). Do this by heading to https://dev.twitter.com/apps/new (you will need an existing Twitter account sign up). You should complete the form with the relevant details for your app:
I’ve seen a lot of questions about connecting Android apps with Twitter using OAuth and thought I would write up a walk-through of how it can be done. The example will be done using Twitter4J which is a great library for connecting Java apps with Twitter and provides a simple interface to connect to the public Twitter Web Services.
First thing you will need to do is to register your new app (even though you haven’t made it yet!). Do this by heading to https://dev.twitter.com/apps/new (you will need an existing Twitter account sign up). You should complete the form with the relevant details for your app:
Spring Social Twitter Oauth
http://stackoverflow.com/questions/7968641/spring-social-twitter-oauth
Tuesday, December 20, 2011
Spring annotations - @Service and @Repository
In Spring 2.0 and later, the @Repository annotation is a marker for any class that fulfills the role or stereotype (also known as Data Access Object or DAO) of a repository. Among the uses of this marker is the automatic translation of exceptions.
@Service serves as a specialization of @Component, allowing for implementation classes to be autodetected through classpath scanning. What this means is that you could annotate your service-layer classes with @Component, but by annotating them with @Service instead, your classes are more properly suited for processing by tools or associating with aspects, since @Service makes an ideal target for pointcuts.
@Service - business service facade (it makes use of DAO)
@Repository - indicate that a class function as a repository or a data access object (DAO)
http://www.slideshare.net/kensipe/spring-3-annotated-development
Then the only thing you need in the xml is the context:component-scan tag to tell Spring which package to scan for @Component annotations. @Repository extends @Component so @Repository is an @Component.
http://www.coderanch.com/t/61389/oa/autowired-annotation
@Service serves as a specialization of @Component, allowing for implementation classes to be autodetected through classpath scanning. What this means is that you could annotate your service-layer classes with @Component, but by annotating them with @Service instead, your classes are more properly suited for processing by tools or associating with aspects, since @Service makes an ideal target for pointcuts.
@Servicepublic class WorldServiceImpl implements WorldService {@Autowiredprivate CountryDao countryDao;
...
}@Repository - indicate that a class function as a repository or a data access object (DAO)
http://www.slideshare.net/kensipe/spring-3-annotated-development
The
The main advantage of using
Also, the specialized annotations help to clearly demarcate application layers (in a standard 3 tiers application).
http://stackoverflow.com/questions/6256331/spring-annotations-repository-and-service@Repository annotation (introduced in Spring 2.0) and @Service annotation (introduced in Spring 2.5) are specialization of the @Component annotation. The main advantage of using
@Repository or @Service over @Component is that it's easy to write an AOP pointcut that targets, for instance, all classes annotated with @Repository.Also, the specialized annotations help to clearly demarcate application layers (in a standard 3 tiers application).
Then the only thing you need in the xml is the context:component-scan tag to tell Spring which package to scan for @Component annotations. @Repository extends @Component so @Repository is an @Component.
http://www.coderanch.com/t/61389/oa/autowired-annotation
Subscribe to:
Posts (Atom)