Second, Spring Integration
1, Mail
(1) SimpleMailMessage
l Create a message
SimpleMailMersage Msg = new SimpleMailMAESSAGE ();
Msg.setfrom ("me@mail.org");
Msg.Setto ("You@mail.org");
Msg.setcc (new string [] {"he@mail.org", "she@mail.org"});
Msg.setbcc (new string [] {"US@mail.org", "them@mail.org"});
Msg.setsubject ("my subject");
Msg.setText ("My Text");
(2) Mailsender
l Defining a message sender
Class = "Org.springframework.mail.javamail.javamailsenderImpl"> bean> l Send a message Mailsender Sender = (Mailsender) CTX.getBean ("Mailsender"); Sender.send (MSG); 2, Scheduling (1) Scheduler l Built-in support: Ø Java 2 Timer: Timer, Timertask Ø Quartz: Schedules, JobDetails, Triggers (2) ScheduledTimertask l We want to run the task Public class mytask eXtends timertask { Public void run () { // do something } } Class = "... scheduling.timer.scheduledtimertask"> Property> bean> Packaging Java.util.Timertask Scheduling Bean (3) TimerFactoryBean l Create a scheduler Class = "... Scheduling.Timer.timerFactoryBean">
Property> bean> Create a java.util.timer object l When you created bean, Timer started running 3, JNDI (1) JNDITEMPLATE l Using JNDITEMPLATE Properties P = new profment (); P.SetProperty ("java.naming.factory.initial", "Org.jnp.interfaces.namingContextFactory"); P.SETPROPERTY ("java.naming.provider.URL", "JNP: // localhost: 1099"); JNDITEMPLATE JNDI = New JNDITEMPLATE (P); Properties env = jndi.getenvironment (); Try { JNDI.BIND ("Something", Something; Object o = jndi.lookup ("something"); JNDI.UNBIND ("Something"); } Catch (namingexception e) { ... } (2) JNDIOBJECTFACRORYBEAN l Use beans to replace loopup Class = "org.springframework.jndi.jndItemplate"> prOPS> constructor-arg> bean> Class = "org.springframework.jndi.jndiObjectFactoryBean"> Object o = ctx.getbean ("something");