use of com.sun.enterprise.deployment.ConnectorDescriptor in project Payara by payara.
the class AuthMechNode method writeDescriptor.
/**
* write the descriptor class to a DOM tree and return it
*
* @param parent node for the DOM tree
* @param the descriptor to write
* @return the DOM tree top node
*/
public Node writeDescriptor(Node parent, Descriptor descriptor) {
if (!(descriptor instanceof OutboundResourceAdapter) && !(descriptor instanceof ConnectorDescriptor)) {
throw new IllegalArgumentException(getClass() + " cannot handle descriptors of type " + descriptor.getClass());
}
Iterator authMechs = null;
if (descriptor instanceof ConnectorDescriptor) {
authMechs = ((ConnectorDescriptor) descriptor).getAuthMechanisms().iterator();
} else if (descriptor instanceof OutboundResourceAdapter) {
authMechs = ((OutboundResourceAdapter) descriptor).getAuthMechanisms().iterator();
}
// auth mechanism info
if (authMechs != null) {
for (; authMechs.hasNext(); ) {
AuthMechanism auth = (AuthMechanism) authMechs.next();
Node authNode = appendChild(parent, ConnectorTagNames.AUTH_MECHANISM);
appendTextChild(authNode, TagNames.DESCRIPTION, auth.getDescription());
appendTextChild(authNode, ConnectorTagNames.AUTH_MECH_TYPE, auth.getAuthMechType());
appendTextChild(authNode, ConnectorTagNames.CREDENTIAL_INTF, auth.getCredentialInterface());
}
}
return parent;
}
use of com.sun.enterprise.deployment.ConnectorDescriptor in project Payara by payara.
the class ConnectorConnectionPoolDeployer method populateConnectorConnectionPool.
private void populateConnectorConnectionPool(ConnectorConnectionPool ccp, String connectionDefinitionName, String rarName, List<Property> props, List<SecurityMap> securityMaps) throws ConnectorRuntimeException {
ConnectorDescriptor connectorDescriptor = runtime.getConnectorDescriptor(rarName);
if (connectorDescriptor == null) {
ConnectorRuntimeException cre = new ConnectorRuntimeException("Failed to get connection pool object");
_logger.log(Level.SEVERE, "rardeployment.connector_descriptor_notfound_registry", rarName);
_logger.log(Level.SEVERE, "", cre);
throw cre;
}
Set connectionDefs = connectorDescriptor.getOutboundResourceAdapter().getConnectionDefs();
ConnectionDefDescriptor cdd = null;
Iterator it = connectionDefs.iterator();
while (it.hasNext()) {
cdd = (ConnectionDefDescriptor) it.next();
if (connectionDefinitionName.equals(cdd.getConnectionFactoryIntf()))
break;
}
ConnectorDescriptorInfo cdi = new ConnectorDescriptorInfo();
cdi.setRarName(rarName);
cdi.setResourceAdapterClassName(connectorDescriptor.getResourceAdapterClass());
cdi.setConnectionDefinitionName(cdd.getConnectionFactoryIntf());
cdi.setManagedConnectionFactoryClass(cdd.getManagedConnectionFactoryImpl());
cdi.setConnectionFactoryClass(cdd.getConnectionFactoryImpl());
cdi.setConnectionFactoryInterface(cdd.getConnectionFactoryIntf());
cdi.setConnectionClass(cdd.getConnectionImpl());
cdi.setConnectionInterface(cdd.getConnectionIntf());
Properties properties = new Properties();
// Refer Sun Bug :6579154 - Equivalent Oracle Bug :12206278
if (rarName.trim().equals(ConnectorRuntime.DEFAULT_JMS_ADAPTER)) {
properties.put("AddressList", "localhost");
}
Set mergedProps = ConnectorDDTransformUtils.mergeProps(props, cdd.getConfigProperties(), properties);
cdi.setMCFConfigProperties(mergedProps);
cdi.setResourceAdapterConfigProperties(connectorDescriptor.getConfigProperties());
ccp.setConnectorDescriptorInfo(cdi);
ccp.setSecurityMaps(SecurityMapUtils.getConnectorSecurityMaps(securityMaps));
}
use of com.sun.enterprise.deployment.ConnectorDescriptor in project Payara by payara.
the class ActiveJmsResourceAdapter method setLifecycleProperties.
/**
* Set MQ4.0 RA lifecycle properties
*/
private void setLifecycleProperties() throws Exception, ConnectorRuntimeException {
// ConfigContext ctx = ApplicationServer.getServerContext().getConfigContext();
// If PE:
// EMBEDDED/LOCAL goto jms-service, get defaultjmshost info and set
// accordingly
// if EE:
// EMBEDDED/LOCAL get this instance and cluster name, search for a
// jms-host wth this this name in jms-service gets its proeprties
// and set
// @siva As of now use default JMS host. As soon as changes for modifying EE
// cluster to LOCAL is brought in, change this to use system properties
// for EE to get port, host, adminusername, adminpassword.
// JmsService jmsService = ServerBeansFactory.getJmsServiceBean(ctx);
String defaultJmsHost = getJmsService().getDefaultJmsHost();
if (_logger.isLoggable(Level.FINE))
logFine("Default JMS Host :: " + defaultJmsHost);
JmsHost jmsHost = getJmsHost();
if (jmsHost != null) {
// todo: && jmsHost.isEnabled()) {
JavaConfig javaConfig = (JavaConfig) Globals.get(JavaConfig.class);
;
String java_home = javaConfig.getJavaHome();
// Get broker type from JMS Service.
// String brokerType = jmsService.getType();
/*
* XXX: adjust the brokertype for the new DIRECT mode in 4.1
* uncomment the line below once we have an MQ integration
* that has DIRECT mode support
*/
String brokerType = adjustForDirectMode(getJmsService().getType());
String brokerPort = jmsHost.getPort();
brkrPort = brokerPort;
String adminUserName = jmsHost.getAdminUserName();
String adminPassword = JmsRaUtil.getUnAliasedPwd(jmsHost.getAdminPassword());
List jmsHostProps = getJmsService().getProperty();
String username = null;
String password = null;
if (jmsHostProps != null) {
for (int i = 0; i < jmsHostProps.size(); i++) {
Property jmsProp = (Property) jmsHostProps.get(i);
String propName = jmsProp.getName();
String propValue = jmsProp.getValue();
if ("user-name".equals(propName)) {
username = propValue;
} else if ("password".equals(propName)) {
password = propValue;
}
// Add more properties as and when you want.
}
}
if (_logger.isLoggable(Level.FINE))
logFine("Broker UserName = " + username);
createMQVarDirectoryIfNecessary();
String brokerVarDir = getMQVarDir();
String tmpString = getJmsService().getStartArgs();
if (tmpString == null) {
tmpString = "";
}
String brokerArgs = tmpString;
// by adding the start-args for the broker configuration
if (!tmpString.contains("-jrehome") && availableJDKForStartArgs()) {
brokerArgs = brokerArgs + buildStartArgsForJREHome(java_home);
}
// XX: Extract the information from the optional properties.
List jmsProperties = getJmsService().getProperty();
List jmsHostProperties = jmsHost.getProperty();
Properties jmsServiceProp = listToProperties(jmsProperties);
Properties jmsHostProp = listToProperties(jmsHostProperties);
jmsServiceProp.putAll(jmsHostProp);
if (jmsServiceProp.size() > 0) {
if (dbProps == null)
dbProps = new Properties();
dbProps.putAll(jmsServiceProp);
}
/*
String jmsPropertiesStr = null ;
if(jmsServiceProp.size() > 0)
{
try{
StringWriter writer = new StringWriter();
jmsServiceProp.store(writer, "Properties defined in JMSService and JMSHost");
jmsPropertiesStr = writer.toString();
}catch(Exception e){}//todo: log error;
} */
String brokerHomeDir = getBrokerHomeDir();
String brokerLibDir = getBrokerLibDir();
if (brokerInstanceName == null) {
brokerInstanceName = getBrokerInstanceName(getJmsService());
}
long brokerTimeOut = getBrokerTimeOut(getJmsService());
// Need to set the following properties
// BrokerType, BrokerInstanceName, BrokerPort,
// BrokerArgs, BrokerHomeDir, BrokerVarDir, BrokerStartTimeout
// adminUserName, adminPassword
ConnectorDescriptor cd = getDescriptor();
/*if(jmsPropertiesStr != null){
ConnectorConfigProperty envProp = new ConnectorConfigProperty (
"BrokerProps", jmsPropertiesStr, "Broker Props", "java.lang.String");
setProperty(cd, envProp);
} */
ConnectorConfigProperty envProp1 = new ConnectorConfigProperty(BROKERTYPE, brokerType, "Broker Type", "java.lang.String");
setProperty(cd, envProp1);
ConnectorConfigProperty envProp2 = new ConnectorConfigProperty(BROKERINSTANCENAME, brokerInstanceName, "Broker Instance Name", "java.lang.String");
setProperty(cd, envProp2);
ConnectorConfigProperty envProp3 = new ConnectorConfigProperty(BROKERPORT, brokerPort, "Broker Port", "java.lang.String");
setProperty(cd, envProp3);
ConnectorConfigProperty envProp4 = new ConnectorConfigProperty(BROKERARGS, brokerArgs, "Broker Args", "java.lang.String");
setProperty(cd, envProp4);
ConnectorConfigProperty envProp5 = new ConnectorConfigProperty(BROKERHOMEDIR, brokerHomeDir, "Broker Home Dir", "java.lang.String");
setProperty(cd, envProp5);
ConnectorConfigProperty envProp14 = new ConnectorConfigProperty(BROKERLIBDIR, brokerLibDir, "Broker Lib Dir", "java.lang.String");
setProperty(cd, envProp14);
ConnectorConfigProperty envProp6 = new ConnectorConfigProperty(BROKERJAVADIR, java_home, "Broker Java Dir", "java.lang.String");
setProperty(cd, envProp6);
ConnectorConfigProperty envProp7 = new ConnectorConfigProperty(BROKERVARDIR, brokerVarDir, "Broker Var Dir", "java.lang.String");
setProperty(cd, envProp7);
ConnectorConfigProperty envProp8 = new ConnectorConfigProperty(BROKERSTARTTIMEOUT, "" + brokerTimeOut, "Broker Start Timeout", "java.lang.String");
setProperty(cd, envProp8);
ConnectorConfigProperty envProp9 = new ConnectorConfigProperty(ADMINUSERNAME, adminUserName, "Broker admin username", "java.lang.String");
setProperty(cd, envProp9);
ConnectorConfigProperty envProp10 = new ConnectorConfigProperty(ADMINPASSWORD, adminPassword, "Broker admin password", "java.lang.String");
setProperty(cd, envProp10);
ConnectorConfigProperty envProp11 = new ConnectorConfigProperty(USERNAME, username, "Broker username", "java.lang.String");
setProperty(cd, envProp11);
ConnectorConfigProperty envProp12 = new ConnectorConfigProperty(PASSWORD, password, "Broker password", "java.lang.String");
setProperty(cd, envProp12);
/* //set adminpassfile
if (!getJmsService().getType().equals(REMOTE)) {
//For LOCAL and EMBEDDED, we pass in the admin pass file path
//containing the MQ admin password to enable authenticated
//startup of the broker.
String adminPassFilePath = getAdminPassFilePath(adminPassword);
if (adminPassFilePath != null) {
ConnectorConfigProperty envProp13 = new ConnectorConfigProperty (
ADMINPASSFILE , adminPassFilePath ,
"Broker admin password", "java.lang.String");
setProperty(cd, envProp13);
}
}*/
}
// Optional
// BrokerBindAddress, RmiRegistryPort
}
use of com.sun.enterprise.deployment.ConnectorDescriptor in project Payara by payara.
the class ActiveJmsResourceAdapter method setClusterRABeanProperties.
// //@Siva: provide an API to read JMX information from RA and return it.
// private
/**
* Sets the SE/EE specific MQ-RA bean properties
* @throws ConnectorRuntimeException
*/
private void setClusterRABeanProperties() throws ConnectorRuntimeException {
ConnectorDescriptor cd = super.getDescriptor();
try {
if (isClustered()) {
JmsService jmsService = (JmsService) Globals.get(JmsService.class);
/* ConfigContext ctx = ApplicationServer.getServerContext().
getConfigContext();
JmsService jmsService = ServerBeansFactory.
getConfigBean(ctx).getJmsService(); */
String val = getGroupName();
ConnectorConfigProperty envProp = new ConnectorConfigProperty(GROUPNAME, val, "Group Name", "java.lang.String");
setProperty(cd, envProp);
if (_logger.isLoggable(Level.FINE))
logFine("CLUSTERED instance - setting groupname as" + val);
boolean inClusteredContainer = false;
if (jmsService.getType().equals(EMBEDDED) || jmsService.getType().equals(LOCAL))
inClusteredContainer = true;
ConnectorConfigProperty envProp1 = new ConnectorConfigProperty(CLUSTERCONTAINER, Boolean.toString(inClusteredContainer), "Cluster container flag", "java.lang.Boolean");
setProperty(cd, envProp1);
if (_logger.isLoggable(Level.FINE))
logFine("CLUSTERED instance - setting inclusteredcontainer as" + inClusteredContainer);
if (jmsService.getType().equals(REMOTE)) {
/*
* Do not set master broker for remote broker.
* The RA might ignore it if we set, but we have to
* be certain from our end.
*/
return;
} else {
if (!isDBEnabled()) {
String masterbrkr = getMasterBroker();
ConnectorConfigProperty envProp2 = new ConnectorConfigProperty(MASTERBROKER, masterbrkr, "Master Broker", "java.lang.String");
setProperty(cd, envProp2);
if (_logger.isLoggable(Level.FINE))
logFine("MASTERBROKER - setting master broker val" + masterbrkr);
}
}
} else {
if (_logger.isLoggable(Level.FINE))
logFine("Instance not Clustered and hence not setting " + "groupname");
}
} catch (Exception e) {
ConnectorRuntimeException crex = new ConnectorRuntimeException(e.getMessage());
throw (ConnectorRuntimeException) crex.initCause(e);
}
}
use of com.sun.enterprise.deployment.ConnectorDescriptor in project Payara by payara.
the class ActiveJmsResourceAdapter method setJmsServiceProperties.
private void setJmsServiceProperties(JmsService service) throws ConnectorRuntimeException {
JmsRaUtil jmsraUtil = new JmsRaUtil(service);
jmsraUtil.setupAddressList();
urlList = jmsraUtil.getUrlList();
addressList = urlList.toString();
if (_logger.isLoggable(Level.INFO)) {
_logger.log(Level.INFO, JMSLoggerInfo.ADDRESSLIST_JMSPROVIDER, new Object[] { addressList });
}
ConnectorDescriptor cd = super.getDescriptor();
setConnectionURL(service, urlList);
String val = "" + jmsraUtil.getReconnectEnabled();
ConnectorConfigProperty envProp2 = new ConnectorConfigProperty(RECONNECTENABLED, val, val, "java.lang.Boolean");
setProperty(cd, envProp2);
// convert to milliseconds
int newval = Integer.parseInt(jmsraUtil.getReconnectInterval()) * 1000;
val = "" + newval;
ConnectorConfigProperty envProp3 = new ConnectorConfigProperty(RECONNECTINTERVAL, val, val, "java.lang.Integer");
setProperty(cd, envProp3);
val = "" + jmsraUtil.getReconnectAttempts();
ConnectorConfigProperty envProp4 = new ConnectorConfigProperty(RECONNECTATTEMPTS, val, val, "java.lang.Integer");
setProperty(cd, envProp4);
val = "" + jmsraUtil.getAddressListBehaviour();
ConnectorConfigProperty envProp5 = new ConnectorConfigProperty(ADRLIST_BEHAVIOUR, val, val, "java.lang.String");
setProperty(cd, envProp5);
val = "" + jmsraUtil.getAddressListIterations();
ConnectorConfigProperty envProp6 = new ConnectorConfigProperty(ADRLIST_ITERATIONS, val, val, "java.lang.Integer");
setProperty(cd, envProp6);
boolean useExternal = shouldUseExternalRmiRegistry(jmsraUtil);
val = Boolean.valueOf(useExternal).toString();
ConnectorConfigProperty envProp7 = new ConnectorConfigProperty(USEEXTERNALRMIREGISTRY, val, val, "java.lang.Boolean");
setProperty(cd, envProp7);
_logger.log(Level.FINE, "Start RMI registry set as " + val);
// If MQ RA needs to use AS RMI Registry Port, then set
// the RMI registry port, else MQ RA uses its default RMI
// Registry port [as of now 1099]
String configuredRmiRegistryPort = null;
if (!useExternal) {
configuredRmiRegistryPort = getRmiRegistryPort();
} else {
/* We will be here if we are LOCAL or REMOTE, standalone
* or clustered. We could set the Rmi registry port.
* The RA should ignore the port if REMOTE and use it only
* for LOCAL cases.
*/
configuredRmiRegistryPort = getUniqueRmiRegistryPort();
}
val = configuredRmiRegistryPort;
if (val != null) {
ConnectorConfigProperty envProp8 = new ConnectorConfigProperty(RMIREGISTRYPORT, val, val, "java.lang.Integer");
setProperty(cd, envProp8);
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "RMI registry port set as " + val);
}
} else {
if (_logger.isLoggable(Level.WARNING)) {
_logger.log(Level.WARNING, JMSLoggerInfo.INVALID_RMI_PORT);
}
}
}
Aggregations