Sunday, November 8, 2009

Brown Hair With Highlights Images

A bit 'of ... Guice and EJB3, very exotic! - Part 3


And here we are at the climax of the series of posts about Guice and EJB3. Now starting to discover the wonders Guice JNDI. We will see how to inject through the EJB3 Dependency Iniection in non-managed (as POJOs) using Guice in JBoss AS 5. Basically the goal is to recreate the standard annotation "@ EJB3, pero 'around the limitations that require the EJB3 OF the only other components managed as EJB or Servlet.

We take 3 steps:
  • Create an EJB3 Stateless Session Bean to deploy our JBOSS AS
  • Write a Java application that invokes the remote in our EjbBean
  • use Guice to inject through the inside EjbBean DI ' application.
We start by creating our form now EJB3 the first step in this form will create a simple EJB3 Stateless Session Bean (which in remoting to invoke a Java application external to JBOSS).

Come on Eclipse and select menu: File -> New -> EJB Project and create a new project this way:

module

In this project part of a stateless session bean with a remote interface and its implementation. That 'the remote interface: package

 org.bizlogic; 

import javax.ejb.Remote;

@ Remote public interface
EJB3TestRemote {

statelessMethod public String (String s);}


and write any implementation like this: package

 org.bizlogic; 

import javax.annotation.PostConstruct;

javax.ejb.Remote import, import
javax.ejb.Stateless;

import org.apache.log4j.Logger;

/ ** * Session Bean Implementation class
EJB3Test
* /

@ Stateless @ Remote (EJB3TestRemote.class)
public class implements EJB3Test EJB3TestRemote

{private static Logger log = Logger.getLogger (EJB3Test.class.getName ());

/
** * Default constructor.
* / public
EJB3Test () {}

@ PostConstruct
public void useless () {
log.info (String.format ("postconstuct"));}


statelessMethod public String (String s) {
log.info (String.format ("Received: "+ s));
return String.format (" What a nice String! -% s ", new StringBuilder (s). reverse (). reverse ());}

}

Done! It 'was very simple. Now we can deploy this module in JBoss using the utility from making twiddle.sh (found in the distribution of jboss) or Eclipse: Right-click, on the project, select Export and select "EJB JAR file "to export it correctly. We give a name to the form and select the folder deploy our app server that is in $ JBOSS_HOME / server / default / deploy (though of course we use the configuration deployment). Once deployed at the end we will respond JBoss

 16:11:35,118 INFO [SessionSpecContainer] Starting jboss.j2ee: jar = Test-Guice.jar-EJB3, name = EJB3Test, service = EJB3 16:11:35,118 INFO 
[EJBContainer] STARTED EJB: org.bizlogic. EJB3Test ejbName: EJB3Test
16:11:35,126 INFO [JndiSessionRegistrarBase] Binding The following Entries in Global JNDI:

EJB3Test/remote - EJB3.x Default Remote Business Interface
EJB3Test/remote-org.bizlogic.EJB3TestRemote - Remote Business Interface EJB3.x

We jboss our active and deployed EJB3Test with its remote interface.
We arrived at the second point, and here comes into play immediately Guice. Let's create a simple Java project that uses this remote EJB3 and start having fun on the jndiContext Inject. Create a project "Java Project", press Alt + Enter to go on properties and go to "Build Path" and add the libraries that we have found in the distribution of Guice2 we downloaded from googlecode (here: http://google-guice .googlecode.com/files/guice-2.0.zip ) that are aopalliance.jar, Guice-2.0.jar, Guice-jndi.jar (and if we also want log4j-1.2.15.jar).

not we have inserted the code but now configure the jndi context that we will create: a source-level properties file that we insert a call jndi.properties with this content:

 java.naming.factory.initial = org.jnp.interfaces.NamingContextFactory 
java.naming . factory.url.pkgs = org.jboss.naming: org.jnp.interfaces
java.naming.provider.url = localhost

Usually Bean would have to call this to initialize a new instance of java.naming.InitialContext and do lookup on the object as in the following code: public class

 NiceClass 

{public void tryJndi () throws NamingException {InitialContext cxt

= new InitialContext ();
EJB3TestRemote test = (EJB3TestRemote) cxt.lookup (EJB3Test/remote ");
System.out.println (test.statelessMethod (" Hello JBOSS "));}

}

start with and configure Guice inject the JNDI context. We write a class that extends the class GuiceModule AbstractModule Guice and tell that every time he meets with a record selector Iniect @ @ Named ("JNDI") on a reference of type Context should inject a new instance of type as we saw in the InitialContext post 2 above.

 AbstractModule {public class extends GuiceModule 


@ Override protected void configure () {

bind (Context.class). AnnotatedWith (Names.named ("JNDI")). To (InitialContext.class);
}}



Ok now we can rewrite the class NiceClass like this: public class

 NiceClass 

{@ Inject @ Named ("JNDI")
private Context cxt;

public void tryJndi () throws

EJB3TestRemote NamingException {test = (EJB3TestRemote) cxt.lookup (EJB3Test/remote ");
System.out.println (test.statelessMethod (" Hello JBOSS "));}

}

So it works fine. But there 's a little problem. We told Guice to inject a new instance of InitialContext but this is not particularly useful. The real added value comes at a time that The Manage the context let Guice JNDI internally and we inject the EJB3 instead! Guice is already prepared to do this through a particular type of object called JndiIntegration. Going to see the code for this class we find that integrates with Guice JNDI but inside it has a reference @ Inject Context context; that at the time it is instantiated, it requires a binding to javax.naming.Context we have set ourselves. Obviously we have to be to indicate how to inject Guice JNDI context because of the jndi properties. So remove the configuration annotatedWith (Names.named ("JNDI"))

 bind (Context.class). To (InitialContext.class). In (Singleton.class) 

sources and also discover the operation of the static function "fromJndi" that creates an object of type Provider that retrieves the object from the JNDI context that we tried to bind to a class interface as follows:

 bind (DataSource . class). toProvider (fromJndi (DataSource.class, "java :...")); 

Perfect! We can then jack the remote interface of our ejb3 specifying the object name to evoke directly GuiceModule class. So let's add

 import static com.google.inject.jndi.JndiIntegration.fromJndi; 

and finally configure our EJB3:

 bind (EJB3TestRemote.class) . AnnotatedWith (Names.named (EJB3TestRemote ")). ToProvider (fromJndi (EJB3TestRemote.class," EJB3Test/remote ")); 

NOTE: One important note is that the suffix" / remote "part of the method of Invocation of default under JBOSS EJB3. OpenEJB on WebSphere or there may be some differences.

Now we make our bean: public class

 NiceClass 

{@ Inject @ Named ("EJB3TestRemote)
private EJB3TestRemote test;

public void tryJndi () throws NamingException {System.out.println

( test.statelessMethod ("Hello JBOSS"));}

}

Actually @ Named annotation selector there would be a real need that we saw only a remote interface. It would also be helpful if we had a local interface to choose which type of interface to use.
and we send ... et voila! how wonderful! Let's Try

 [com.google.inject.Guice] please 

--- What a nice string! - JBOSS HELLO

Now scenarios increases. We can inject through the EJB3 POJO inside, this way we can use objects that are not in EjbBean servlet and being able to extend our RPC calls using patterns other than standard, like the command pattern, where a good implementation and 'GWT-Dispatcher. Remains If in doubt want to use more 'java.naming.Context contexts within the same application (an environment configured for local objects, the other for remote objects). The only solution to this is to extend the class and add two static methods JndiIntegration fromJndiLocal fromJndiRemote and working on two different instances of InitialContext, instantiate, this time using a selector @ Named (). But it is a very specific case. For any comments please do not hesitate to contact me even davassi email [at] yahoo [dot] com. At the next post :-)

Friday, November 6, 2009

Mysore Maliga Bf Film

A bit 'of ... Guice and EJB3, very exotic! - Part 2


We're back to try the wonders of Guice. My goal is to be injected into EJB3 Session Bean non-managed, as POJO. The annotation for EJB3 standard @ Iniection Dependency is bad, then we have to work around this limitation. But let's step by step.

What, then, Guice specifically? a framework that allows us to configure, instantiate and inject object graph, so similar to Spring but with important differences. One of these is that Guice code is configured, is leaning on a Inglese-like syntax and does not depend on the configuration xml file. We start with an example.

I create an abstract class MyClass is a class that extends MyClass MyClassB this:

 package org.exquisitus; 

public abstract class MyClass {Abstract void

yellPlease (String str);}


 package org.exquisitus; 

MyClassB public class MyClass extends {@ Override


yellPlease void (String str) {
System.out.format (" You yell: -% s - \\ n ", str);}

}

NiceClass Without this we write a class that I use an instance of the class MyClassB from a reference of type MyClass

 org.exquisitus package; 

import com.google.inject.Inject;

public class NiceClass

{@ Inject private MyClass a;

callMethod public void () {
a.yellPlease ("OMG!");
}}


so far everything is very simple. callMethod () will invoke 'method yellPlease object (which does not yet know what will') refers to 'a'.
No one has defined 'a', there are no setter, and there is no 'class constructor. It appears, however, 'a particular entry called "@ Iniect. And here comes Guice.

 package org.exquisitus; 

import com.google.inject.AbstractModule;

AbstractModule {public class extends GuiceModule


@ Override protected void configure () {

bind (MyClassA.class). To (MyClassB . class);}


}

GuiceModule is a class that extends AbstractModule, in particular the method configure (). This is the way to configure Guice-dependencies of our object graphs. Through
syntax bind (nomeclasse.class). To (altraclasse.class) Guice to say that every time it encounters a reference to an annotation @ Iniect MyClass, to populate a new instance of object MyClassB.
There 's also a way to tell Guice the scope of the object to instantiate, for example if I want to instantiate a singleton object, but will speak of this' more' below.
Now we just need to test your code. Create a Main:

 package org.exquisitus; 

import com.google.inject.Guice;
import com.google.inject.Injector;

TryGuicePlease {public class

public static void main (String [] args) {

System.out.format ("Let's Try [% s] please --- \\ n \\ n ", Guice.class.getName ());

Guice.createInjector Injector injector = (new GuiceModule ());

NiceClass nice = injector.getInstance (NiceClass.class)

nice.callMethod ();


}}

Et voila '! We met the injector. There 's also a way to inject the injector, but here we go sull'esotico and now we are not interested. What interests us, and 'that just require an instance of a NiceClass Guice, Guice ce instanzierà with the dependencies that are already configured. Then inside the private field will not have 'the default value will be null but rather an instance of type MyClassB, as we have indicated. And here's the result: Let's Try

 [com.google.inject.Guice] please --- 

You yell: - OMG! -

Perfect, but now things get really interesting . Let's say you need to instantiate different objects for the same type of reference. Thus adding 'MyClassC class that extends the abstract class MyClass.

 package org.exquisitus; 

MyClassC public class MyClass extends {@ Override


yellPlease void (String str) {
System.out.format ("You yell reverse: -% s - \\ n", new StringBuilder (str). Reverse ());}


}

whose purpose sympathy and shout to the contrary :-) How do I tell Guice that when I encounter a reference to the MyClass class C instead of B? Should I use a selector . There are several ways to create a selector and a very nice way is to use a remark! Well then write notes for our two classes: @ e @ ReverseYell Yell

 package org.exquisitus; 

java.lang.annotation.Retention import, import
java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import static java.lang.annotation.ElementType.FIELD;

import com.google.inject.BindingAnnotation;

BindingAnnotation @ @ Target (FIELD) @ Retention (RetentionPolicy.RUNTIME)

public @ interface Yell

} {

and write exactly the same record but this call @ ReversedYell (note the @ Target (FIELD), I'm just using this for now, do not use annotations on methods.)

now and reconfigure it using the annotatedWith () to map the newly created records as selectors for our classes and MyClassB MyClassC:

 org.exquisitus package; 

import com.google.inject.AbstractModule;

AbstractModule {public class extends GuiceModule


@ Override protected void configure () {

bind (MyClassA.class). AnnotatedWith (Yell.class). To (MyClassB. class);

bind (MyClassA.class). annotatedWith (ReverseYell.class). to (MyClassC.class);}


}

the two objects instantiated in the same class but NiceClass starting 'the same kind of reference MyClass and invoke the method in two callMethod.

 package org.exquisitus; 

import com.google.inject.Inject;

public class NiceClass

{@ Inject Yell private MyClass @ a;

@ @ Inject private MyClass ReverseYell a2;

callMethod public void () {
a.yellPlease ("OMG!");
a2.yellPlease ("OMG!");

}}

and behold the result! Let's Try

 [com.google.inject.Guice] please --- 

You yell: - OMG! - Reverse
You yell: -! GMO -

This is very interesting but not so much for our purposes. Why? What we need to get is to inject the EJB3 who already have two different types of interface (local and remote) and depending on how well written a common interface and implementation. Add record increases the code. Then there 's also the possibility' of using bundled Guice annotation called @ Named (and then 'matter of taste ...). Using the configuration module would be this:

 bind (MyClassA.class). AnnotatedWith (Names.named ("Reverse")). To (MyClassC.class) 

and to use it

 @ Inject @ Named ("Reverse") private MyClass a2; 

Here. We are now ready to delve into JBoss using Guice and discover the wonders of using Guice JNDI with the next post :-) part 3.

Movies With Friendship Meaning

A bit 'of ... Guice and EJB3, very exotic! - Part 1

But in the end. It is now a bit 'that development in the field of web applications and java in the world of work I see the same old naivete: the use of very old framework (pre-ajax!) and many, but many "professionals" in the field who shoot without even a scratch on technologies know them.

Now I am a bit 'tired and I started this blog to discuss a bit' of technologies that I decided to use in my latest work.

I am working on a web project that involves the use of various J2EE components. Ok lets start.

Given the choice I chose to use the technologies to structure the project using the latest web framework. Why '?

1) I want a project that has the best design of the code.
2) I want a project that is easy to test
3) I want a project that is easy to extend
4) I want to realize a project that is easy to change
5) I want to make a project that ensures better maintainability 'possible
that projects in this vast and' a huge problem to consider.
6) I also want to make a project that is as' powerful and scalable as possible.

and last but not least ... passion for personal use of the latest technologies on the market! um seems to me a great respect. :)

(the list above and 'tidy but you can read random access, I resisted the temptation to confuse the issues)

I considered that the development environment and JBoss' scalable (and easily clustering) and the following libraries:

GWT and 'without doubt the best java framework which is being released in recent years as a strength and' chance 'to compile Java code directly in JavaScript code in a portable among different browsers on the market. Allows you to program the View as a web application if programmed a desktop application with Swing. After years spent on JSF and quarreled with designers, I can not help it to GWT.

MVP4G-GWT and GWT-Presenter
are two extensions of GWT to implement the Model-View-Presenter on GWT. I often worked with the MVC pattern also use the implementation of lightwave GWT-Ext but the MVP model and 'much more' adaptable to the logic GWT.

GWT-Dispatch other useful library that allows me to use one and only one servlet! The communication model on the server and 'Remote Procedure Call using GWT smooth but you have to write a servlet to call remote. Following the indications of Google ... command pattern.

To implement the business logic I wanted to map the POJO that make up the Domain Model using Hibernate and EJB3 Entity Bean. This approach and 'very fast and functional because' using Hibernate allows you to automatically map the logical model to my items directly on the logical model of the relational database, the database used in a transparent way! How wonderful!

The choice of business logic and 'fall on EJB3 session beans (stateful and stateless). The EJB3 are very interesting as a technology, and above all 'easy to control inputs remotely via RMI (which as he says, and' a lot more technology ' webservices fast ...).

I encountered a problem. It 's not possible to inject through Dependency Iniection managed components such as EJB3 components inside not managed as a POJO.

And how did this for me would be a problem? Simple! when I use a type of pattern or strategy for my RPC command, no longer uses' a servlet for remote call to me but a Pojo implements the handler of the call. So I find myself in difficulty 'of having to inject EJB3 components inside managed. And the standard annotation for Dependency Iniection "@ EJB" not permit it!

We circumvent limitation. I found myself making choices that were:

1) Use patterns and old fashion BusinessDelegate ServiceLocator pattern?
2) Use an extension of Spring to make the DI of EJB3?
3) Use a totally new approach ... chess' Guice? :-)

The first option seems to be discarded. I worked with Business Delegate and Service Locator pattern and inspire me just a little.
The second option sounds interesting but ... there is' a but. Spring is uncomfortable with the EJB3, the are just unpleasant. In particular, I found this: # ref it is possible to specify in the configuration of spring we are going to inject components jee. But the reflexive invocation of the objects in question introduces an overhead.
The third possibility 'of using Guice, and' the most interesting. but we leave in an orderly fashion.

What ' Guice?

Guice and 'a library provided by Google (again her!) To create and inject the object graph. And it 'code-configured. That is no longer 'cursed XML file that just can not stand (and you're asking me why I like jboss ..).
but the beauty of Guice and 'that allows you to configure, create and inject through of entire object graphs, indicating the desired goal, much Simple!

For example:

I have my own class that extends my class B, from which I want to instantiate an object through OF.

Nothing more 'simple!

 bind (B.class). To (A.class). In (Singleton.class) 

and to inject?

 @ A Iniect myObj; 

that's it! how wonderful!

I'll talk 'more' extensively Guice and how to use EJB3 with in the next post.

Monday, June 8, 2009

How Can I Hide Certain Wall Posts

THANKS

A big THANK YOU!
Here are the results as expected

Gay Cruising Blogpost

European Elections

Click here to see the results of European elections in Grottazzolina

Friday, June 5, 2009

Spa Bloor West Village

closure campaign

After the many constructive meetings with the candidates on the candidate list Colombia and Mayor Mariano Ambrogi, we expect you all tonight at Teatro Novelli Grottazzolina to 21. 30 for the closing of the election campaign.
participation of so many!

Sunday, May 24, 2009

Hyundai 2.4 Cam Timing

EVENTS

Tuesday, 26 May 21.30 - Municipal Gym

Wednesday 27 May 19.00 - off fish area Brancozzi
21.30 Pro Loco J. Lennon

THURSDAY 28 May 21.30 - Bowling

Monday 1 June at 21.30 - Piazza Bolzetta

Wednesday 3 June 21.30 - Via Fermana (place to be agreed)

Thursday 4 June at 21.30 - COMIZIO CLOSING CAMPAIGN ELECTION PIAZZA MARCONI

Wednesday, May 20, 2009

2005 Honda Civic Front License Bracket Used




Thursday 21 May at 21.30 THE THEATRE NOVELLI
INVITE ALL CITIZENS TO THE OFFICIAL PRESENTATION OF THE LIST "THE DOVE".
DO NOT MISS TO CONTINUE WITH THE GROWTH OF OUR COUNTRY

Tuesday, May 5, 2009

Juniors Dresses Valentine Dance

A breath of fresh air in the City Council in Ancona

In the upcoming elections for the renewal of the City Council of Ancona, I propose to support the candidacy of Conrad Cantani, a new face in politics per se, but a very known person in the territory for a sense of responsibility and the consistency with which it has undertaken many activities, both in private and personal dimension, which in that commitment in public and independent sociale.Si white as on the lists of the Democratic Party in support of the candidacy of Mayor Fiorello Gramillano.Ma Ancona Who is Jack? CORRADO Sing (Iaco said) was born in Ancona, October 31, 1959, is married with one daughter. As a child approaches the music with very transport and infinite passione.Dall 'age' of 12 years is part of musical groups with which it has come a long way and played in many cities' of Italy. Deepens professional techniques in the audio business by acquiring high professionalism that allows you to organize events by providing all his knowledge on the subject. Participates as an expert in management and audiotecnologie performing in concerts with artists of national and international caliber. He specializes in using advanced analog instruments used especially for live music, supported by a team of experienced employees and young professionals trained by himself. He has participated in programs dealing with the television audio-part technique. Corrado Cantani also plays with local bands working towards the promotion of cultural events related to music and other forms of entertainment. In 2006 he recorded with his band (the Springfield Group) to the song "My City" (dedicated to Ancona), which was the soundtrack of the election campaign of the Democratic Party in recent elections comunaliSi then approached the world of volunteers working in the social -care and sports, where he became involved in football for 12 years Federal semiprofessionistico intrerregionale, in various positions, from stock up to the leadership positions of one of the most 'major companies' cittadine.Durante this activity organized youth tournaments and gatherings in the name of loyalty 'and respect for the prossimo.Corrado, for his great communication skills and availability to the next has always been established with other relations of mutual friendship and esteem that abusing the relationship professionale.Il his new political commitment is aimed at enhancing the artistic talent of young people and promoting cultural and aggregative targeted education and respect for others and the recovery of difficult situations with the support of young people motivated and experts in the field of which Conrad will be used to substantiate its idee.Iaco has also been awarded for 30 years out of an outlet that leads with the help of his family, became a meeting point and reference for all musicians città.Iaco, while "young" is the grandfather of Jade sprint.

Pap Smear Hurt So Bad