Extension Implementation

To implement your own extension, apply the extension interface directly or inherit from the BaseExtension class in the Java package com.tibco.sf.container.bw.extenson.This class name is the value used in plugin.impl present in plugin.properties. Refer to the following Java code, in the MyFirstExtension.java file:

public class MyFirstPluginExtension implements Extension {
private final transient Logger logger = LogUtils.forClass(this.getClass());
private BWContainer bwContainer = null;
		
 /***
* Please handle extension events in onEvent and onFailureEvent function 
		 * accordingly.
 * Possible events are
		
* BEFORE_INIT,
		
* AFTER_INIT,
 * BEFORE_START, 
		
 * AFTER_START, 
		
 * BEFORE_INSTALL, 
		
* AFTER_INSTALL, 
		
 * BEFORE_SHUTDOWN,
 * AFTER_SHUTDOWN, 
		
 * BEFORE_CLEANUP, 
		
* AFTER_CLEANUP
		
 ***/
		
public void onEvent(ExtensionEvent event) throws ExtensionException {
		
 (event.getEventName().equals(BWContainer.ContainerEvent.AFTER_ INIT.name())) {
		
 // Write your code to do plugin specific actions in AFTER_INIT
}
}
 /***
		
* In case any extension throws an exception when handling an event, the Container will call onFailureEvent of each plugin that has handled the event, 
		 * so the extension may get a chance to rollback the work.
		
		
 ***/
		
public void onFailureEvent(ExtensionEvent event) throws ExtensionException {
		
 // Roll back what is done in onEvent if ant exception happens
 if (event.getEventName().equals(BWContainer.ContainerEvent.AFTER_INIT)) {
		
 // roll back actions in onEvent
		
}
		
}
		
 @Override
		
public void setContainer(Container container) throws ExtensionException {
		
bwContainer = (BWContainer)container;
		
}
@Override
		
 public Container getContainer() throws ExtensionException {
		
 if(bwContainer == null)
		
throw new ExtensionException("BWContainer instance is null");
 return bwContainer;
		
}
		
}
		

Note: Most plugins do not need to implement onEvent() and onFailureEvent() if they only add additional JAR or WAR archives in specific plugin directories. If a plugin needs to perform additional tasks, such as modifying the bwengine.tra file to add additional properties, the plugin needs to implement onEvent(), and most likely to do something in AFTER_INIT.