1 5 package org.terracotta.modules.struts_1_1; 6 7 import org.osgi.framework.BundleActivator; 8 import org.osgi.framework.BundleContext; 9 import org.osgi.framework.BundleException; 10 import org.osgi.framework.ServiceReference; 11 12 import com.tc.object.config.StandardDSOClientConfigHelper; 13 import com.tc.object.config.TransparencyClassSpec; 14 15 public final class StrutsTerracottaConfigurator implements BundleActivator { 16 17 private static final String INCLUDE_TAG_CLASSNAME = "org.apache.struts.taglib.bean.IncludeTag"; 18 19 public void start(final BundleContext context) throws Exception { 20 final ServiceReference configHelperRef = context.getServiceReference(StandardDSOClientConfigHelper.class.getName()); 21 if (configHelperRef != null) { 22 final StandardDSOClientConfigHelper configHelper = (StandardDSOClientConfigHelper) context 23 .getService(configHelperRef); 24 addStrutsInstrumentation(configHelper); 25 context.ungetService(configHelperRef); 26 } else { 27 throw new BundleException("Expected the " + StandardDSOClientConfigHelper.class.getName() 28 + " service to be registered, was unable to find it"); 29 } 30 } 31 32 public void stop(final BundleContext context) throws Exception { 33 } 35 36 private void addStrutsInstrumentation(final StandardDSOClientConfigHelper configHelper) { 37 TransparencyClassSpec spec = configHelper.getOrCreateSpec("org.apache.struts.action.ActionForm"); 39 spec.setHonorTransient(true); 40 spec = configHelper.getOrCreateSpec("org.apache.struts.action.ActionMappings"); 41 spec.setHonorTransient(true); 42 spec = configHelper.getOrCreateSpec("org.apache.struts.action.ActionServletWrapper"); 43 spec.setHonorTransient(true); 44 spec = configHelper.getOrCreateSpec("org.apache.struts.action.DynaActionFormClass"); 45 spec.setHonorTransient(true); 46 47 synchronized (configHelper) { 50 if (!configHelper.hasCustomAdapter(INCLUDE_TAG_CLASSNAME)) { 51 configHelper.addCustomAdapter(INCLUDE_TAG_CLASSNAME, new IncludeTagAdapter()); 52 } 53 } 54 } 55 56 } 57 | Popular Tags |