Create a SpringApplicationContext service for legacy code

Guillaume applied changes to "Delete WebCryptography. Have all code use the EncryptionService instead. Also create a SpringApplicationContext service so that legacy code (where instances are not created by spring) can access the spring application context and lookup beans."

hal-ejb/src/main/java/com/hal/sf/service/SpringApplicationContext.java

SpringApplicationContext.java

Code using the above legacy class, need the following:

Declarations

import com.hal.sf.service.SpringApplicationContext;
import com.hollandamerica.common.encryption.EncryptionService;
private EncryptionService encryptionService;

Inside Construction

encryptionService =(EncryptionService) SpringApplicationContext.getBean("encryptionService");

Sample Code Usage

String newCCN = encryptionService.decrypt(encrypted);
String previousCCN = encryptionService.decrypt(previous);

Leave a Reply