use of com.sun.enterprise.deployment.ConnectorDescriptor in project Payara by payara.
the class ConnectorAnnotationHandler method processAnnotation.
public HandlerProcessingResult processAnnotation(AnnotationInfo element) throws AnnotationProcessorException {
AnnotatedElementHandler aeHandler = element.getProcessingContext().getHandler();
Connector connector = (Connector) element.getAnnotation();
List<Class<? extends Annotation>> list = new ArrayList<Class<? extends Annotation>>();
list.add(getAnnotationType());
if (aeHandler instanceof RarBundleContext) {
RarBundleContext rarContext = (RarBundleContext) aeHandler;
ConnectorDescriptor desc = rarContext.getDescriptor();
Class annotatedClass = (Class) element.getAnnotatedElement();
if (desc.getResourceAdapterClass().equals("")) {
desc.addConnectorAnnotation(element);
return getSuccessfulProcessedResult(list);
} else if (!isResourceAdapterClass(annotatedClass)) {
desc.addConnectorAnnotation(element);
return getSuccessfulProcessedResult(list);
} else if (!desc.getResourceAdapterClass().equals(annotatedClass.getName())) {
desc.addConnectorAnnotation(element);
return getSuccessfulProcessedResult(list);
} else {
processDescriptor(annotatedClass, connector, desc);
desc.setValidConnectorAnnotationProcessed(true);
}
} else {
String logMessage = "Not a rar bundle context";
return getFailureResult(element, logMessage, true);
}
return getSuccessfulProcessedResult(list);
}
use of com.sun.enterprise.deployment.ConnectorDescriptor in project Payara by payara.
the class ConnectorConfigurationParserServiceImpl method getConnectionDefinitionNames.
/**
* Obtains all the Connection definition names of a rar
* @param rarName rar moduleName
* @return Array of connection definition names.
*/
public String[] getConnectionDefinitionNames(String rarName) throws ConnectorRuntimeException {
String[] result = new String[0];
ConnectorDescriptor desc = getConnectorDescriptor(rarName);
if (desc != null) {
MCFConfigParser mcfConfigParser = (MCFConfigParser) ConnectorConfigParserFactory.getParser(ConnectorConfigParser.MCF);
return mcfConfigParser.getConnectionDefinitionNames(desc);
} else {
return result;
}
}
use of com.sun.enterprise.deployment.ConnectorDescriptor in project Payara by payara.
the class ConnectorService method createActiveResourceAdapterForEmbeddedRar.
public void createActiveResourceAdapterForEmbeddedRar(String rarModuleName) throws ConnectorRuntimeException {
ConnectorDescriptor cdesc = loadConnectorDescriptorForEmbeddedRAR(rarModuleName);
String appName = ConnectorAdminServiceUtils.getApplicationName(rarModuleName);
String rarFileName = ConnectorAdminServiceUtils.getConnectorModuleName(rarModuleName) + ".rar";
String loc = getResourcesUtil().getApplicationDeployLocation(appName);
loc = loc + File.separator + FileUtils.makeFriendlyFilename(rarFileName);
String path = null;
try {
URI uri = new URI(loc);
path = uri.getPath();
} catch (URISyntaxException use) {
ConnectorRuntimeException cre = new ConnectorRuntimeException("Invalid path [ " + use.getMessage() + " ]");
cre.setStackTrace(use.getStackTrace());
_logger.log(Level.WARNING, cre.getMessage(), cre);
throw cre;
}
// start RA
_runtime.createActiveResourceAdapter(cdesc, rarModuleName, path);
}
use of com.sun.enterprise.deployment.ConnectorDescriptor in project Payara by payara.
the class ConnectorSecurityAdminServiceImpl method getAuthenticationService.
/**
* Obtain the authentication service associated with rar module.
* Currently only the BasicPassword authentication is supported.
*
* @param rarName Rar module Name
* @param poolInfo Name of the pool. Used for creation of
* BasicPasswordAuthenticationService
* @return AuthenticationService
*/
public AuthenticationService getAuthenticationService(String rarName, PoolInfo poolInfo) {
ConnectorDescriptor cd = _registry.getDescriptor(rarName);
OutboundResourceAdapter obra = cd.getOutboundResourceAdapter();
Set authMechs = obra.getAuthMechanisms();
for (Object authMech : authMechs) {
AuthMechanism authMechanism = (AuthMechanism) authMech;
String mech = authMechanism.getAuthMechType();
if (mech.equals("BasicPassword")) {
return new BasicPasswordAuthenticationService(rarName, poolInfo);
}
}
return null;
}
use of com.sun.enterprise.deployment.ConnectorDescriptor in project Payara by payara.
the class ActiveJmsResourceAdapter method setAvailabilityProperties.
/*
* Set Availability related properties
* If JMS availability true set availability properties
* read configured pool information and set.
*/
private void setAvailabilityProperties() throws ConnectorRuntimeException {
if (!isClustered())
return;
try {
Domain domain = Globals.get(Domain.class);
ServerContext serverContext = Globals.get(ServerContext.class);
Server server = domain.getServerNamed(serverContext.getInstanceName());
JmsService jmsService = server.getConfig().getExtensionByType(JmsService.class);
if (jmsService.getType().equals(REMOTE)) {
// been configured with the right properties.
return;
}
AvailabilityService as = server.getConfig().getAvailabilityService();
if (as == null) {
if (_logger.isLoggable(Level.FINE))
logFine("Availability Service is null. Not setting AvailabilityProperties.");
return;
}
boolean useMasterBroker = true;
if (as.getExtensionByType(JmsAvailability.class) != null && !MASTERBROKER.equalsIgnoreCase(as.getExtensionByType(JmsAvailability.class).getConfigStoreType()))
useMasterBroker = false;
// jmsService.getUseMasterBroker() != null ? Boolean.valueOf(jmsService.getUseMasterBroker()) :true;
boolean isJmsAvailabilityEnabled = this.isJMSAvailabilityOn(as);
if (_logger.isLoggable(Level.FINE))
logFine("Setting AvailabilityProperties .. ");
if (!useMasterBroker || isJmsAvailabilityEnabled) {
// For conventional cluster of peer brokers and Enhanced Broker Cluster.
ConnectorDescriptor cd = getDescriptor();
String clusterName = getMQClusterName();
ConnectorConfigProperty envProp1 = new ConnectorConfigProperty(CLUSTERID, clusterName, "Cluster Id", "java.lang.String");
setProperty(cd, envProp1);
if (brokerInstanceName == null) {
brokerInstanceName = getBrokerInstanceName(jmsService);
}
ConnectorConfigProperty envProp2 = new ConnectorConfigProperty(BROKERID, brokerInstanceName, "Broker Id", "java.lang.String");
setProperty(cd, envProp2);
// Only if JMS availability is true - Enhanced Broker Cluster only.
if (isJmsAvailabilityEnabled) {
// Set HARequired as true - irrespective of whether it is REMOTE or
// LOCAL
ConnectorConfigProperty envProp3 = new ConnectorConfigProperty(HAREQUIRED, "true", "HA Required", "java.lang.String");
setProperty(cd, envProp3);
/* The broker has a property to control whether
* it starts in HA mode or not and that's represented on
* the RA by BrokerEnableHA.
* On the MQ Client connection side it is HARequired -
* this does not control the broker, it just is a client
* side requirement.
* So for AS EE, if BrokerType is LOCAL or EMBEDDED,
* and AS HA is enabled for JMS then both these must be
* set to true. */
ConnectorConfigProperty envProp4 = new ConnectorConfigProperty(BROKERENABLEHA, "true", "BrokerEnableHA flag", "java.lang.Boolean");
setProperty(cd, envProp4);
String nodeHostName = domain.getNodeNamed(server.getNodeRef()).getNodeHost();
if (nodeHostName != null) {
ConnectorConfigProperty envProp5 = new ConnectorConfigProperty(BROKERBINDADDRESS, nodeHostName, "Broker Bind Address", "java.lang.String");
setProperty(cd, envProp5);
}
loadDBProperties(as.getExtensionByType(JmsAvailability.class), ClusterMode.ENHANCED);
} else {
// Conventional cluster of peer brokers
JmsAvailability jmsAvailability = as.getExtensionByType(JmsAvailability.class);
if ("jdbc".equals(jmsAvailability.getMessageStoreType()))
loadDBProperties(jmsAvailability, ClusterMode.ENHANCED);
loadDBProperties(jmsAvailability, ClusterMode.CONVENTIONAL_OF_PEER_BROKERS);
}
/*
ConnectorConfigProperty envProp4 = new ConnectorConfigProperty (
DBTYPE , DBTYPE_HADB,"DBType",
"java.lang.String");
setProperty(cd, envProp4);
* The broker has a property to control whether
* it starts in HA mode or not and that's represented on
* the RA by BrokerEnableHA.
* On the MQ Client connection side it is HARequired -
* this does not control the broker, it just is a client
* side requirement.
* So for AS EE, if BrokerType is LOCAL or EMBEDDED,
* and AS HA is enabled for JMS then both these must be
* set to true.
ConnectorConfigProperty envProp5 = new ConnectorConfigProperty (
BROKERENABLEHA , "true",
"BrokerEnableHA flag","java.lang.Boolean");
setProperty(cd, envProp5);
String nodeHostName = domain.getNodeNamed(server.getNode()).getNodeHost();
if (nodeHostName != null) {
ConnectorConfigProperty envProp6 = new ConnectorConfigProperty (
BROKERBINDADDRESS , nodeHostName,
"Broker Bind Address","java.lang.String");
setProperty(cd, envProp6);
}
//get pool name
String poolJNDIName = as.getJmsAvailability().getMqStorePoolName();
//If no MQ store pool name is specified, use default poolname
//XXX: default pool name is jdbc/hastore but asadmin
//configure-ha-cluster creates a resource called
//"jdbc/<asclustername>-hastore" which needs to be used.
if (poolJNDIName == null || poolJNDIName =="" ) {
//get Web container's HA store's pool name
poolJNDIName = as.getWebContainerAvailability().
getHttpSessionStorePoolName();
logFine("HTTP Session store pool jndi name " +
"is " + poolJNDIName);
}
//XXX: request HADB team mq-store-pool name to be
//populated as part of configure-ha-cluster
JdbcConnectionPool jdbcConPool = getJDBCConnectionPoolInfo(
poolJNDIName);
//DBProps: compute values from pool object
String userName = getPropertyFromPool(jdbcConPool, DUSERNAME);
logFine("HA username is " + userName);
String password = getPropertyFromPool(jdbcConPool, DPASSWORD);
logFine("HA Password is " + password);
String driverClass = jdbcConPool.getDatasourceClassname();
logFine("HA driverclass" + driverClass);
dbProps = new Properties();
dbProps.setProperty(DB_HADB_USER, userName);
dbProps.setProperty(DB_HADB_PASSWORD, password);
dbProps.setProperty(DB_HADB_DRIVERCLASS, driverClass);
//DSProps: compute values from pool object
String serverList = getPropertyFromPool(jdbcConPool, DSERVERLIST);
logFine("HADB server list is " + serverList);
dsProps = new Properties();
if (serverList != null) {
dsProps.setProperty(DS_HADB_SERVERLIST, serverList);
} else {
_logger.warning("ajra.incorrect_hadb_server_list");
}
//set all other properties in dsProps as well.
Properties p = getDSPropertiesFromThePool(jdbcConPool);
Iterator iterator = p.keySet().iterator();
while (iterator.hasNext()) {
String key = (String) iterator.next();
String val = (String)p.get(key);
dsProps.setProperty(key, val);
}*/
} else {
// Conventional cluster with master broker.
if ("jdbc".equals(as.getExtensionByType(JmsAvailability.class).getMessageStoreType()))
loadDBProperties(as.getExtensionByType(JmsAvailability.class), ClusterMode.CONVENTIONAL_WITH_MASTER_BROKER);
}
} catch (Exception e) {
ConnectorRuntimeException crex = new ConnectorRuntimeException(e.getMessage());
throw (ConnectorRuntimeException) crex.initCause(e);
}
}
Aggregations