snippetjournal

- notes, snippet codes, and my journal

Send Multipart/Attachment email Using MimeMessageHelper

leave a comment »

Berikut ini penjelasan singkat dari penggunaan javaMailSender yang saya implementasikan pada project. Dengan menggunakan velocity template kita dapat menggunakan template html dengan mudah pada class email sender kita.

anda bisa menggunakan beberapa template email yang bertebaran di internet, saya sendiri mengambil template email dari zurb.com.

pada contoh kedua link di atas menurut saya implementasi kode ketika akan mengirim email cukup banyak boilerplate codes yang digunakan. sehingga saya mencoba untuk membungkus code tersebut nya agar lebih mudah penggunaannya dan menghindari menggunakan code secara berulang ulang.

  • Pertama buat class , class ini hanya berfungsi sebagai penampung dari attribute attribute yang diperlukan pada java mail sender.
  • Kemudian buat class class ini berperan sebagai class yang ditujukan untuk mengirim email. autowired object javaMailSender dan velocityEngine agar bisa kita gunakan untuk mengirim email.
  • Yang perlu diperhatikan adalah ketika kita akan membuat email yang di sertakan email attachment maka constructor MimeMessageHelper harus di buat TRUE, new MimeMessageHelper(mm, true);

setelah class class tadi sudah di buat maka cara penggunaan javaSender pun akan berubah, berikut cara nya jangan lupa untuk autowired class emailSender.

  • yang perlu diperhatikan, saya mengubah object String menjadi file yang akan di attachment.
  • emailErrorLogs.vm adalah template html yang akan di tampilkan pada email. cukup ubah ekstensi html menjadi vm

Written by snippetjournal

October 17, 2014 at 2:16 pm

AJAX Tutorial

leave a comment »

Written by snippetjournal

October 16, 2014 at 1:56 pm

Posted in Uncategorized

Spark

leave a comment »

Apache Spark is a fast and general-purpose cluster computing system. It provides high-level APIs in Java, Scala and Python, and an optimized engine that supports general execution graphs. It also supports a rich set of higher-level tools including Spark SQL for SQL and structured data processing, MLlib for machine learning, GraphX for graph processing, and Spark Streaming.

Written by snippetjournal

October 16, 2014 at 2:00 am

Posted in Uncategorized

Spring AOP : simple explanation and simple Example

leave a comment »

  • <aop:aspectj-autoproxy />

Many new spring developers forget that Spring AOP is proxy-based, i.e. its main idea is to return aspect-aware bean proxy instead of the bean itself from the context. So, the user thinks that he or she works with the bean itself and calls bean methods. However, the methods are invoked on a proxy object, hence, the proxy may execute aspect logic before/after delegating the call to the target bean.

That’s all is fine but how does proxy-based AOP relate to the ClassCastException? The answer is that spring framework offers two proxying mechanism – JDK proxy-based and CGLIB-based. The first one can create proxies only for the interfaces; the second one is able to proxy concrete classes with particular limitations (feel free to check spring reference to get more about that – 6.6. Proxying mechanisms). The same reference chapter says the following about proxying mechanism selection:

If the target object to be proxied implements at least one interface then a JDK dynamic proxy will be used. All of the interfaces implemented by the target type will be proxied. If the target object does not implement any interfaces then a CGLIB proxy will be created.

reference : Spring AOP top problem #2 – java.lang.ClassCastException: $Proxy7

example basic aop pada spring, contoh nya sederhana dan mudah di pahami, ada contoh konfigurasi dengan annotation dan juga dengan xml

Written by snippetjournal

September 30, 2014 at 3:10 am

Posted in Uncategorized

18 Things mentally strong people do

leave a comment »

image

Written by snippetjournal

September 28, 2014 at 2:55 am

Posted in Uncategorized

zenjava – maven plugin for easy assembly application

leave a comment »

The JavaFX Maven Plugin provides a way to assemble distribution bundles for JavaFX applications (2.2+) from within Maven.

Written by snippetjournal

September 26, 2014 at 2:09 am

Posted in Uncategorized

JSF – Spring – Hibernate Tutorial

leave a comment »

Written by snippetjournal

September 10, 2014 at 7:15 am

Posted in Uncategorized

Follow

Get every new post delivered to your Inbox.

Join 64 other followers