Monday, November 02, 2015

Implementasi AOP dengan Spring

Dengan membuat kelas untuk Aspect yang sangat sederhana, misalnya :

package id.web.mige.wlsp.bbs;


import org.aspectj.lang.ProceedingJoinPoint;


public class SecurityAspect {
 
 
    public Object aroundFunction(ProceedingJoinPoint pjp) throws Throwable {
     System.out.println("Before " + pjp.getSignature().getName());
        Object retVal = pjp.proceed();
        System.out.println("After " + pjp.getSignature().getName());
        return retVal;
    }

}

Setting untuk AOP bisa di masukkan ke dalam berkas XML untuk servlet context, misalnya :


<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 xmlns:aop="http://www.springframework.org/schema/aop"
 xmlns:beans="http://www.springframework.org/schema/beans"
 xmlns:context="http://www.springframework.org/schema/context"
 xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd
  http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
  http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
  http://www.springframework.org/schema/aop 
      http://www.springframework.org/schema/aop/spring-aop.xsd">

 <!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->
 
 <!-- Enables the Spring MVC @Controller programming model -->
 <annotation-driven />

 <!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
 <resources mapping="/resources/**" location="/resources/" />

 <!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory -->
 <beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
  <beans:property name="prefix" value="/WEB-INF/views/" />
  <beans:property name="suffix" value=".jsp" />
 </beans:bean>
 
  <context:component-scan base-package="id.web.mige.wlsp.bbs" />
 
    <beans:bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
      <beans:property name="jndiName" value="jdbc/localtestdb"/>
    </beans:bean>
 
    <beans:bean id="articleJDBCTemplate" 
       class="id.web.mige.wlsp.bbs.ArticleJDBCTemplate">
       <beans:property name="dataSource"  ref="dataSource" />    
    </beans:bean>
           <aop:aspectj-autoproxy/>
    
    <beans:bean id="articleController" class="id.web.mige.wlsp.bbs.ArticleController"/>
    
    <beans:bean id="myAspect" class="id.web.mige.wlsp.bbs.SecurityAspect">
     <!-- configure properties of aspect here as normal -->
  </beans:bean>
  
  <aop:config proxy-target-class="true">
        <aop:aspect ref="myAspect">

            <aop:pointcut id="mypointcut"
                expression="execution(* id.web.mige.wlsp.bbs.ArticleController.*(..))"/>

            <aop:around pointcut-ref="mypointcut"
                method="aroundFunction"/>  
   
   
   

        </aop:aspect>
     </aop:config>
  
</beans:beans> 

Atau jika lebih menyukai bentuk annotation, kelas Aspect dapat diubah menjadi seperti ini :

@Aspect
public class SecurityAspect {
 
 @Around("execution(* id.web.mige.wlsp.bbs.ArticleController.*(..))")
    public Object aroundFunction(ProceedingJoinPoint pjp) throws Throwable {
     System.out.println("Before " + pjp.getSignature().getName());
        Object retVal = pjp.proceed();
        System.out.println("After " + pjp.getSignature().getName());
        return retVal;
    }

}

dan setting/config XML untuk tag <aop:aspect ... > ...  </aop:aspect> dapat dihilangkan.

Thursday, October 22, 2015

Memulai Membangun Aplikasi dengan Spring untuk WebLogic Server

Tutorial ini menggunakan :
- Microsoft Windows 8

- MySQL Server

- Spring versi 4.2.2
Berkas jar Spring Bisa diunduh di
http://maven.springframework.org/release/org/springframework/spring/4.2.2.RELEASE/

- Oracle Fusion Middleware WebLogic 12.1.3
Bisa diunduh di
http://www.oracle.com/technetwork/middleware/fusion-middleware/downloads/index.html
Pilih "Windows 32 installer including OEPE". Installer ini berukuran cukup besar, sekitar 2 GB. OEPE adalah Oracle Enterprise Pack for Eclipse. Jadi paket installer ini sudah ada Eclipse yang sudah siap untuk membangun aplikasi untuk WebLogic.

Untuk memudahkah pengembangan Spring di Eclipse telah tersedia Spring IDE plugin. Silahkan memasang plugin ini. Bisa melalui Eclipse Marketplace



Gambar: Spring IDE plugin di Eclipse


Sebelum tutorial ini dapat berjalan. Harus ada WebLogic Server yang telah siap dijalankan. Untuk menyiapkan WebLogic Server dapat mengikuti tutorial berikut (link).

Mulai dengan membuat proyek baru di Eclipse. Pilih menu File > New > Other ...

Gambar: New Project di Eclipse


Akan muncul dialog :

Gambar: New Dialog di Eclipse


Pilih "Spring Project", klik tombol "Next".

Gambar: New Spring Project Dialog


Isi "WLSpringTutorial" sebagai Project Name. Pilih "Spring MVC Project" sebagai Template. Klik tombol "Next".

Gambar: Project Settings


Isi nama package : id.web.harimurti . Boleh diubah sesuai dengan kebutuhan. Klik tombol "Finnish". Tunggu sampai Eclipse selasai menyiapkan proyek ini.

Gambar: Struktur proyek



Jika kita buka proyek ini akan tampak seperti gambar diatas. Proyek ini sudah dapat kita jalankan di WebLogic Server. Klik kanan di nama proyek.

Gambar: Menu "Run on Server"


Setelah itu akan muncul dialog untuk memilih di Server mana kita akan jalankan aplikasi web ini.

Gambar: Pilih Server


Klik tombol Next, akan muncul dialog untuk memilih resources (aplikasi) yang dijalankan di Server.

Gambar: Pilih aplikasi


Pilih proyek kita dan pindahkan ke kolom kanan dan pindahkan aplikasi lain yang tidak diperlukan (jika ada) ke kolom kiri. Klik tombol Finish.
Tunggulah sampai Eclipse selesai melakukan deployment dan membuka browser untuk menampilkan halaman web dari aplikasi ini.

Gambar: Tampilan default aplikasi di browser.


Server Aplikasi Oracle Fusion Middleware WebLogic Server

Yang ingin mencoba server aplikasi yang cukup komprehensif dan dapat terskala secara enterprise, mungkin dapat mencoba Oracle Fusion Middleware WebLogic.

WebLogic bisa diunduh dari :
http://www.oracle.com/technetwork/middleware/weblogic/downloads/index.html?ssSourceSiteId=ocomen

Biasanya, untuk mudahnya kita unduh paket installer untuk OEPE. OEPE adalah Oracle Enterprise Pack for Eclipse, sehingga setelah terinstal akan tersedia Eclipse yang telah siap untuk membangun aplikasi untuk WebLogic.

Untuk itu kita perlu membuat domain dan server di WebLogic terlebih dahulu.

Setelah instalasi, buka "Start" menu dari Windows dan pilih "Configuration Wizard" seperti di gambar di bawah ini.

Gambar: Configuration Wizard


Kemudian ikuti perintah di Configuration Wizard sampai selesai.











Sunday, October 04, 2015

How to Start WebLogic WLST

On WebLogic 12c 

Got to :
WL_HOME/user_projects/domain/domain_name/bin

Run :
> setDomainEnv.[sh|cmd]
> java weblogic.WLST
> java weblogic.WLST script.py

or on Windows, a shortcut on the Start menu sets the environment variables and invokes WLST (Tools—>WebLogic Scripting Tool).


Wednesday, March 25, 2015

How to Side Load apps on your BlackBerry 10 device

source : http://forums.berryverse.com/threads/76-How-to-Side-Load-apps-on-your-BlackBerry-10-device



    Side Loading, it's one of the most interesting topics since the launch of the BlackBerry PlayBook device which runs on QNX, same as the BlackBerry 10 platform. Because by Side Loading you can always get access to applications ported from Android that has not been released yet on BlackBerry World for any reason, also in some case you might participate in a developer Beta testing group and he will be providing you with bar files to test their applications. Then how do you side load?


  1. Download the application bar file from any website on your computer.
  2. Steps to do on your BlackBerry 10 device:
    • Head to the BlackBerry 10 Settings > Security > Development Mode
    • Activate the Development Mode (It will ask for a password, enter one and REMEMBER IT well)
    • Get back to the device Settings and select About
    • Select Network from the drop-down menu and copy your IPv4 IP Address(or USB if connected via USB for faster Side-loading)
  3. Steps to do on your computer:
    • Download Google Chrome (if not already installed)
    • Download the PlayBook App Manager Extension for Chrome from Chrome Store
    • Once Installed it will open the local web page
    • Enter your BlackBerry 10 device IPv4 Address (or USB if connected via USB)
    • Hit Save
    • You will find your IPv4(or USB Address) added to a list in the bottom, click on it
        It will start connecting to your BlackBerry 10 device
        You will be asked to enter the password you set when you activated the development mode
        Now the PlayBook App Manager will show the apps you have installed
        Click Install app and select the bar file
        Enjoy!