use of com.sun.enterprise.deployment.EnvironmentProperty in project Payara by payara.
the class ActivationConfigNode method writeDescriptor.
@Override
public Node writeDescriptor(Node parent, String nodeName, ActivationConfigDescriptor descriptor) {
Node activationConfigNode = null;
Set activationConfig = descriptor.getActivationConfig();
// ActionConfig must have at least one ActionConfigProperty
// and ActionConfigProperty must have a pair of name/value
// so filter out the entries with blank name or value
Set activationConfig2 = new HashSet();
for (Iterator iter = activationConfig.iterator(); iter.hasNext(); ) {
EnvironmentProperty next = (EnvironmentProperty) iter.next();
if (!next.getName().trim().equals("") && !next.getValue().trim().equals("")) {
activationConfig2.add(next);
}
}
if (activationConfig2.size() > 0) {
activationConfigNode = appendChild(parent, nodeName);
writeLocalizedDescriptions(activationConfigNode, descriptor);
for (Iterator iter = activationConfig2.iterator(); iter.hasNext(); ) {
Node activationConfigPropertyNode = appendChild(activationConfigNode, EjbTagNames.ACTIVATION_CONFIG_PROPERTY);
EnvironmentProperty next = (EnvironmentProperty) iter.next();
appendTextChild(activationConfigPropertyNode, EjbTagNames.ACTIVATION_CONFIG_PROPERTY_NAME, next.getName());
appendTextChild(activationConfigPropertyNode, EjbTagNames.ACTIVATION_CONFIG_PROPERTY_VALUE, next.getValue());
}
}
return activationConfigNode;
}
use of com.sun.enterprise.deployment.EnvironmentProperty in project Payara by payara.
the class SetMethodAction method run.
/**
* Executes the setter methods in the java bean.
*/
public Object run() throws Exception {
Iterator it = props.iterator();
methods = bean.getClass().getMethods();
while (it.hasNext()) {
EnvironmentProperty prop = (EnvironmentProperty) it.next();
String propName = prop.getName();
Class type = getTypeOf(prop);
// property type
if (type == null) {
type = Class.forName(prop.getType());
}
if (prop.getResolvedValue() != null && prop.getResolvedValue().trim().length() != 0) {
Method meth = getMutatorMethod(propName, type);
if (meth == null) {
// log WARNING, deployment can continue.
logger.log(Level.WARNING, "rardeployment.no_setter_method", new Object[] { prop.getName(), bean.getClass().getName() });
} else {
try {
if (logger.isLoggable(Level.FINER)) {
logger.log(Level.FINER, "Invoking" + meth + " on " + bean.getClass().getName() + "with " + "value [" + prop.getResolvedValueObject().getClass() + " , " + getFilteredPropValue(prop) + " ] ");
}
meth.invoke(bean, new Object[] { prop.getResolvedValueObject() });
} catch (IllegalArgumentException ia) {
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, "IllegalException while trying to set " + prop.getName() + " and value " + getFilteredPropValue(prop), ia + " on an instance of " + bean.getClass() + " -- trying again with the type from bean");
}
boolean prevBoundsChecking = EnvironmentProperty.isBoundsChecking();
try {
EnvironmentProperty.setBoundsChecking(false);
prop.setType(type.getName());
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, "2nd try :: Invoking" + meth + " on " + bean.getClass().getName() + "with value [" + prop.getResolvedValueObject().getClass() + " , " + getFilteredPropValue(prop) + " ] ");
}
meth.invoke(bean, new Object[] { prop.getResolvedValueObject() });
} catch (Exception e) {
handleException(e, prop, bean);
} finally {
// restore boundsChecking
EnvironmentProperty.setBoundsChecking(prevBoundsChecking);
}
} catch (Exception ex) {
handleException(ex, prop, bean);
}
}
}
}
return null;
}
use of com.sun.enterprise.deployment.EnvironmentProperty in project Payara by payara.
the class RARUtils method getMergedActivationConfigProperties.
/**
* Prepares the name/value pairs for ActivationSpec. <p>
* Rule: <p>
* 1. The name/value pairs are the union of activation-config on
* standard DD (message-driven) and runtime DD (mdb-resource-adapter)
* 2. If there are duplicate property settings, the value in runtime
* activation-config will overwrite the one in the standard
* activation-config.
*/
public static Set getMergedActivationConfigProperties(EjbMessageBeanDescriptor msgDesc) {
Set mergedProps = new HashSet();
Set runtimePropNames = new HashSet();
Set runtimeProps = msgDesc.getRuntimeActivationConfigProperties();
if (runtimeProps != null) {
Iterator iter = runtimeProps.iterator();
while (iter.hasNext()) {
EnvironmentProperty entry = (EnvironmentProperty) iter.next();
mergedProps.add(entry);
String propName = (String) entry.getName();
runtimePropNames.add(propName);
}
}
Set standardProps = msgDesc.getActivationConfigProperties();
if (standardProps != null) {
Iterator iter = standardProps.iterator();
while (iter.hasNext()) {
EnvironmentProperty entry = (EnvironmentProperty) iter.next();
String propName = (String) entry.getName();
if (runtimePropNames.contains(propName))
continue;
mergedProps.add(entry);
}
}
return mergedProps;
}
use of com.sun.enterprise.deployment.EnvironmentProperty in project Payara by payara.
the class ActiveJmsResourceAdapter method setValuesFromConfiguration.
private void setValuesFromConfiguration(String cfName, EjbMessageBeanDescriptor descriptor_) throws ConnectorRuntimeException {
// todo: need to enable
List<Property> ep = null;
try {
/*Resources rbeans = getAllResources();//ServerBeansFactory.getDomainBean(ctx).getResources();
ConnectorResource res = (ConnectorResource)
rbeans.getResourceByName(ConnectorResource.class, cfName);*/
String appName = descriptor_.getApplication().getAppName();
String moduleName = ConnectorsUtil.getModuleName(descriptor_);
ConnectorResource res = (ConnectorResource) ResourcesUtil.createInstance().getResource(cfName, appName, moduleName, ConnectorResource.class);
if (res == null) {
String msg = sm.getString("ajra.mdb_cf_not_created", cfName);
throw new ConnectorRuntimeException(msg);
}
ConnectorConnectionPool ccp = (ConnectorConnectionPool) ResourcesUtil.createInstance().getResource(res.getPoolName(), appName, moduleName, ConnectorConnectionPool.class);
// rbeans.getResourceByName(ConnectorConnectionPool.class, res.getPoolName());
ep = ccp.getProperty();
} catch (Exception ce) {
String msg = sm.getString("ajra.mdb_cf_not_created", cfName);
ConnectorRuntimeException cre = new ConnectorRuntimeException(msg);
cre.initCause(ce);
throw cre;
}
if (ep == null) {
String msg = sm.getString("ajra.cannot_find_phy_dest");
throw new ConnectorRuntimeException(msg);
}
for (int i = 0; i < ep.size(); i++) {
Property prop = ep.get(i);
String name = prop.getName();
if (name.equals(MCFADDRESSLIST)) {
name = ADDRESSLIST;
}
String val = prop.getValue();
if (val == null || val.equals("")) {
continue;
}
descriptor_.putRuntimeActivationConfigProperty(new EnvironmentProperty(name, val, null));
}
}
Aggregations