Methods Summary |
---|
private java.lang.String | getApplicationId(com.sun.enterprise.config.serverbeans.TransformationRule trBean)
String name = null;
ConfigBean bean = null;
if ( trBean != null) {
bean = (ConfigBean) trBean.parent();
if (!( bean instanceof WebServiceEndpoint)) {
throw new RuntimeException();
}
}
if (bean != null) {
ConfigBean parent = (ConfigBean) bean.parent();
if (parent instanceof J2eeApplication) {
J2eeApplication app = (J2eeApplication) parent;
name = app.getName();
} else if (parent instanceof WebModule) {
WebModule wm = (WebModule) parent;
name = wm.getName();
} else if (parent instanceof EjbModule) {
EjbModule em = (EjbModule) parent;
name = em.getName();
}
}
return name;
|
private com.sun.enterprise.config.ConfigBean | getTRBean(com.sun.enterprise.admin.event.wsmgmt.TransformationRuleEvent event, boolean old)
if (event == null) {
throw new IllegalArgumentException();
}
ConfigBean bean = null;
ConfigContext ctx = null;
String xpath = event.getElementXPath();
if (old) {
ctx = event.getOldConfigContext();
} else {
ctx = event.getConfigContext();
}
if (ctx != null) {
bean = ctx.exactLookup(xpath);
}
return bean;
|
public void | handleCreate(com.sun.enterprise.admin.event.wsmgmt.TransformationRuleEvent event)Handles element additions.
handleReconfiguration(event,false, false);
|
public void | handleDelete(com.sun.enterprise.admin.event.wsmgmt.TransformationRuleEvent event)Handles web-service-endpoint/transformation-rule element removal.
handleReconfiguration(event,true, true);
|
private void | handleReconfiguration(com.sun.enterprise.admin.event.wsmgmt.TransformationRuleEvent event, boolean takeOld, boolean isRemove)
try {
ConfigBean bean = getTRBean(event, takeOld);
if ( bean instanceof TransformationRule ) {
TransformationRule tr = (TransformationRule) bean;
String appId = getApplicationId(tr);
WebServiceConfigImpl wsc = new WebServiceConfigImpl (
(WebServiceEndpoint) tr.parent());
TransformHandler trh = new TransformHandler( wsc , appId);
Filter f = trh.getFilter(appId, wsc);
TransformFilter tf = null;
if ( f != null) {
tf = (TransformFilter) f;
}
ConfigBean newBean = getTRBean(event, false);
WebServiceConfigImpl nwsc = null;
if ( newBean == null) {
if ( ! isRemove) {
// only remove operation can not have
// new element in the new config context
throw new AdminEventListenerException();
} else {
nwsc = wsc;
}
} else {
nwsc = new WebServiceConfigImpl(
(WebServiceEndpoint) newBean.parent());
}
if ( tf == null) {
// create new filter to handle transformation
tf = (TransformFilter) trh.registerFilter(wsc);
} else {
if ( isRemove) {
String applyTo = tr.getApplyTo();
if ( applyTo.equals(Constants.BOTH) ||
applyTo.equals(Constants.REQUEST)) {
com.sun.enterprise.admin.wsmgmt.config.spi.TransformationRule[] rtrs =
nwsc.getRequestTransformationRule();
tf.resetRequestChain( pruneList( rtrs,
tr.getName()));
}
if ( applyTo.equals(Constants.BOTH) ||
applyTo.equals(Constants.RESPONSE)) {
com.sun.enterprise.admin.wsmgmt.config.spi.TransformationRule[] rtrs =
nwsc.getResponseTransformationRule();
tf.resetResponseChain( pruneList( rtrs,
tr.getName()));
}
} else {
tf.resetRequestChain(
nwsc.getRequestTransformationRule());
tf.resetResponseChain(
nwsc.getResponseTransformationRule());
}
}
}
} catch (Exception e) {
throw new AdminEventListenerException(e);
}
|
public void | handleUpdate(com.sun.enterprise.admin.event.wsmgmt.TransformationRuleEvent event)Handles web-service-endpoint/transformation-rule element modification
(attributes/properties values changed).
handleReconfiguration(event,false,false);
|
private com.sun.enterprise.admin.wsmgmt.config.spi.TransformationRule[] | pruneList(com.sun.enterprise.admin.wsmgmt.config.spi.TransformationRule[] tRules, java.lang.String name)
// nothing to prune for a null or empty list
if (tRules == null || tRules.length < 1) {
return tRules;
}
com.sun.enterprise.admin.wsmgmt.config.spi.TransformationRule[]
newRules =
new com.sun.enterprise.admin.wsmgmt.config.spi.TransformationRule[
tRules.length-1];
int newIndex = 0;
for ( int index =0; index < tRules.length; index++) {
if ( tRules[index].getName().equals(name)) {
// found the match, do not add to the new list
} else {
if ( newIndex >= tRules.length-1) {
// removed rule should exist and should not cause array
// overflow.
throw new RuntimeException();
}
newRules[newIndex++] = tRules[index];
}
}
return newRules;
|