use of com.sun.appserv.connectors.internal.api.ConnectorRuntimeException in project Payara by payara.
the class ActiveJmsResourceAdapter method loadRAConfiguration.
/**
* Loads RA configuration for MQ Resource adapter.
*
* @throws ConnectorRuntimeException in case of an exception.
*/
@Override
protected void loadRAConfiguration() throws ConnectorRuntimeException {
JmsService jmsService = getJmsService();
if (jmsService != null && jmsService.getType().equals("DISABLED")) {
throw new ConnectorRuntimeException("JMS Broker is Disabled");
}
if (connectorRuntime.isServer()) {
// Check whether MQ has started up or not.
try {
// if (!JmsProviderLifecycle.shouldUseMQRAForLifecycleControl()) {
// JmsProviderLifecycle.checkProviderStartup();
// } else {
setLifecycleProperties();
// }
} catch (Exception e) {
ConnectorRuntimeException cre = new ConnectorRuntimeException(e.getMessage());
throw (ConnectorRuntimeException) cre.initCause(e);
}
setMdbContainerProperties();
setJmsServiceProperties(null);
setClusterRABeanProperties();
setAvailabilityProperties();
} else {
setAppClientRABeanProperties();
}
super.loadRAConfiguration();
postRAConfiguration();
}
use of com.sun.appserv.connectors.internal.api.ConnectorRuntimeException in project Payara by payara.
the class ActiveJmsResourceAdapter method getPhysicalDestinationFromConfiguration.
private String getPhysicalDestinationFromConfiguration(String logicalDest, String appName, String moduleName) throws ConnectorRuntimeException {
Property ep = null;
try {
// ServerContext sc = ApplicationServer.getServerContext();
// ConfigContext ctx = sc.getConfigContext();
// Resources rbeans = ServerBeansFactory.getDomainBean(ctx).getResources();
AdminObjectResource res = null;
res = (AdminObjectResource) ResourcesUtil.createInstance().getResource(logicalDest, appName, moduleName, AdminObjectResource.class);
// AdminObjectResource res = (AdminObjectResource) allResources.getAdminObjectResourceByJndiName(logicalDest);
if (res == null) {
String msg = sm.getString("ajra.err_getting_dest", logicalDest);
throw new ConnectorRuntimeException(msg);
}
// getElementPropertyByName(PHYSICAL_DESTINATION);
ep = res.getProperty(PHYSICAL_DESTINATION);
} catch (Exception ce) {
String msg = sm.getString("ajra.err_getting_dest", logicalDest);
ConnectorRuntimeException cre = new ConnectorRuntimeException(msg);
cre.initCause(ce);
throw cre;
}
if (ep == null) {
String msg = sm.getString("ajra.cannot_find_phy_dest", null);
throw new ConnectorRuntimeException(msg);
}
return ep.getValue();
}
use of com.sun.appserv.connectors.internal.api.ConnectorRuntimeException in project Payara by payara.
the class JMSDestination method getMQJMXConnectorInfos.
protected MQJMXConnectorInfo[] getMQJMXConnectorInfos(final String target, final Config config, final ServerContext serverContext, final Domain domain, ConnectorRuntime connectorRuntime) throws ConnectorRuntimeException {
try {
final JmsService jmsService = config.getExtensionByType(JmsService.class);
ActiveJmsResourceAdapter air = getMQAdapter(connectorRuntime);
final Class mqRAClassName = air.getResourceAdapter().getClass();
final CommandTarget ctarget = this.getTypeForTarget(target);
MQJMXConnectorInfo mqjmxForServer = (MQJMXConnectorInfo) java.security.AccessController.doPrivileged(new java.security.PrivilegedExceptionAction() {
public java.lang.Object run() throws Exception {
if (ctarget == CommandTarget.CLUSTER || ctarget == CommandTarget.CLUSTERED_INSTANCE) {
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, "Getting JMX connector for" + " cluster target " + target);
}
return _getMQJMXConnectorInfoForCluster(target, jmsService, mqRAClassName, serverContext);
} else {
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, "Getting JMX connector for" + " standalone target " + target);
}
return _getMQJMXConnectorInfo(target, jmsService, mqRAClassName, serverContext, config, domain);
}
}
});
return new MQJMXConnectorInfo[] { mqjmxForServer };
} catch (Exception e) {
// e.printStackTrace();
ConnectorRuntimeException cre = new ConnectorRuntimeException(e.getMessage());
cre.initCause(e);
throw cre;
}
}
use of com.sun.appserv.connectors.internal.api.ConnectorRuntimeException in project Payara by payara.
the class JMSDestination method _getMQJMXConnectorInfo.
protected MQJMXConnectorInfo _getMQJMXConnectorInfo(String targetName, JmsService jmsService, Class mqRAClassName, ServerContext serverContext, Config config, Domain domain) throws ConnectorRuntimeException {
try {
// If DAS, use the default address list, else obtain
String connectionURL = null;
MQAddressList mqadList = new MQAddressList();
if (getTypeForTarget(targetName) == CommandTarget.DAS) {
connectionURL = getDefaultAddressList(jmsService).toString();
} else {
// Standalone server instance
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, "not in DAS");
logger.log(Level.FINE, " _getMQJMXConnectorInfo - NOT in DAS");
}
JmsService serverJmsService = getJmsServiceOfStandaloneServerInstance(targetName, config, domain);
// MQAddressList mqadList = new MQAddressList(serverJmsService, targetName);
mqadList.setJmsService(serverJmsService);
mqadList.setTargetName(targetName);
mqadList.setup(false);
connectionURL = mqadList.toString();
}
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, " _getMQJMXConnectorInfo - connection URL " + connectionURL);
}
String adminUserName = null;
String adminPassword = null;
JmsHost jmsHost = mqadList.getDefaultJmsHost(jmsService);
if (jmsHost != null) {
// && jmsHost.isEnabled()) {
adminUserName = jmsHost.getAdminUserName();
adminPassword = JmsRaUtil.getUnAliasedPwd(jmsHost.getAdminPassword());
} else {
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, " _getMQJMXConnectorInfo, using default jms admin user and password ");
}
}
ResourceAdapter raInstance = getConfiguredRA(mqRAClassName, connectionURL, adminUserName, adminPassword);
String jmxServiceURL = null, jmxServiceURLList = null;
Map<String, ?> jmxConnectorEnv = null;
Method[] methds = raInstance.getClass().getMethods();
for (int i = 0; i < methds.length; i++) {
Method m = methds[i];
if (m.getName().equalsIgnoreCase("get" + JMXSERVICEURLLIST)) {
jmxServiceURLList = (String) m.invoke(raInstance, new Object[] {});
} else if (m.getName().equalsIgnoreCase("get" + JMXCONNECTORENV)) {
jmxConnectorEnv = (Map<String, ?>) m.invoke(raInstance, new Object[] {});
}
}
if (logger.isLoggable(Level.FINE)) {
logger.log(Level.FINE, " _getMQJMXConnectorInfo - jmxServiceURLList " + jmxServiceURLList);
logger.log(Level.FINE, " _getMQJMXConnectorInfo - jmxConnectorEnv " + jmxConnectorEnv);
}
jmxServiceURL = getFirstJMXServiceURL(jmxServiceURLList);
MQJMXConnectorInfo mqInfo = new MQJMXConnectorInfo(targetName, ActiveJmsResourceAdapter.getBrokerInstanceName(jmsService), jmsService.getType(), jmxServiceURL, jmxConnectorEnv);
return mqInfo;
} catch (Exception e) {
e.printStackTrace();
ConnectorRuntimeException cre = new ConnectorRuntimeException(e.getMessage());
cre.initCause(e);
throw cre;
}
}
use of com.sun.appserv.connectors.internal.api.ConnectorRuntimeException in project Payara by payara.
the class MQJMXConnectorInfo method getMQMBeanServerConnection.
/**
* Returns an <code>MBeanServerConnection</code> representing the MQ broker instance's MBean
* server.
* @return
* @throws ConnectorRuntimeException
*/
// XXX:Enhance to support SSL (once MQ team delivers support in the next drop)
// XXX: Discuss how <code>ConnectionNotificationListeners</code> could
// be shared with the consumer of this API
public MBeanServerConnection getMQMBeanServerConnection() throws ConnectorRuntimeException {
try {
if (getJMXServiceURL() == null || getJMXServiceURL().equals("")) {
String msg = localStrings.getLocalString("error.get.jmsserviceurl", "Failed to get MQ JMXServiceURL of {0}.", getASInstanceName());
throw new ConnectorRuntimeException(msg);
}
if (_logger.isLoggable(Level.FINE)) {
_logger.log(Level.FINE, "creating MBeanServerConnection to MQ JMXServer with " + getJMXServiceURL());
}
JMXServiceURL jmxServiceURL = new JMXServiceURL(getJMXServiceURL());
connector = JMXConnectorFactory.connect(jmxServiceURL, this.jmxConnectorEnv);
// XXX: Do we need to pass in a Subject?
MBeanServerConnection mbsc = connector.getMBeanServerConnection();
return mbsc;
} catch (Exception e) {
e.printStackTrace();
ConnectorRuntimeException cre = new ConnectorRuntimeException(e.getMessage());
cre.initCause(e);
throw cre;
}
}
Aggregations