/** * check whether the provided location is valid * @param f location where the .rar is present * @throws ConnectorRuntimeException */ private static void validateRARLocation(File f) throws ConnectorRuntimeException { if (!f.exists()) { String i18nMsg = localStrings.getString( "rar_archive_not_found", f); throw new ConnectorRuntimeException(i18nMsg); } }
public void closeMQMBeanServerConnection() throws ConnectorRuntimeException { try { if (connector != null) { connector.close(); } } catch (IOException e) { ConnectorRuntimeException cre = new ConnectorRuntimeException(e.getMessage()); cre.initCause(e); throw cre; } } }
public ConnectorArchivist getConnectorArchvist() throws ConnectorRuntimeException { try{ ArchivistFactory archivistFactory = habitat.getComponent(ArchivistFactory.class); return (ConnectorArchivist)archivistFactory.getArchivist(XModuleType.RAR); }catch(IOException ioe){ _logger.log(Level.WARNING, "unable to get Connector Archivist : ", ioe); ConnectorRuntimeException cre = new ConnectorRuntimeException(ioe.getMessage()); cre.setStackTrace(ioe.getStackTrace()); throw cre; } }
private DelegatingClassLoader.ClassFinder getLibrariesClassLoader(final List<URI> appLibs) throws MalformedURLException, ConnectorRuntimeException { try { return (DelegatingClassLoader.ClassFinder) AccessController.doPrivileged(new PrivilegedExceptionAction(){ public Object run() throws Exception { return clh.getAppLibClassFinder(appLibs); } }); } catch (PrivilegedActionException e) { _logger.log(Level.SEVERE, "error.creating.libraries.classloader", e); ConnectorRuntimeException cre = new ConnectorRuntimeException(e.getMessage()); cre.initCause(e); throw cre; } }
/** * Destroys/deletes the Active resource adapter object from the connector * container. Active resource adapter abstracts the rar deployed. * * @param moduleName Name of the rarModule to destroy/delete * @throws ConnectorRuntimeException if the deletion fails */ private void destroyActiveResourceAdapter(String moduleName) throws ConnectorRuntimeException { ResourcesUtil resutil = ResourcesUtil.createInstance(); if (resutil == null) { ConnectorRuntimeException cre = new ConnectorRuntimeException("Failed to get ResourcesUtil object"); _logger.log(Level.SEVERE, "rardeployment.resourcesutil_get_failure", moduleName); _logger.log(Level.SEVERE, "", cre); throw cre; } if (!stopAndRemoveActiveResourceAdapter(moduleName)) { ConnectorRuntimeException cre = new ConnectorRuntimeException("Failed to remove Active Resource Adapter"); _logger.log(Level.SEVERE, "rardeployment.ra_removal_registry_failure", moduleName); _logger.log(Level.SEVERE, "", cre); throw cre; } unbindConnectorDescriptor(moduleName); }
private void handleException(Exception ex, EnvironmentProperty prop, Object bean) throws ConnectorRuntimeException { logger.log(Level.WARNING, "rardeployment.exception_on_invoke_setter", new Object[]{prop.getName(), getFilteredPropValue(prop), ex.getMessage()}); if (logger.isLoggable(Level.FINE)) { logger.log(Level.FINE, "Exception while trying to set " + prop.getName() + " and value " + getFilteredPropValue(prop), ex + " on an instance of " + bean.getClass()); } throw(ConnectorRuntimeException) (new ConnectorRuntimeException(ex.getMessage()).initCause(ex)); }
/** * {@inheritDoc} */ public boolean hasAdminObject(ConnectorDescriptor desc, String intfName, String className) throws ConnectorRuntimeException { if (desc == null || intfName == null || className == null) { throw new ConnectorRuntimeException("Invalid arguments"); } Set adminObjectSet = desc.getAdminObjects(); if (adminObjectSet == null || adminObjectSet.size() == 0) { return false; } Iterator it = adminObjectSet.iterator(); AdminObject aor = null; for (int i = 0; it.hasNext(); ++i) { aor = (AdminObject) it.next(); if(aor.getAdminObjectInterface().equals(intfName) && aor.getAdminObjectClass().equals(className)){ return true; } } return false; }
public PoolType getPoolType(PoolInfo poolInfo) throws ConnectorRuntimeException { ConnectorConnectionPool ccp; try { ccp = getConnectorConnectionPool(poolInfo); } catch (NamingException e) { ConnectorRuntimeException cre = new ConnectorRuntimeException(e.getMessage()); cre.initCause(e); throw cre; } return getPoolType(ccp); }
public String[] getConnectionDefinitionNames(ConnectorDescriptor desc) throws ConnectorRuntimeException { if(desc == null) { throw new ConnectorRuntimeException("Invalid arguments"); } ConnectionDefDescriptor cdd[] = ddTransformUtil.getConnectionDefs(desc); String[] connDefNames = new String[0]; if(cdd != null) { connDefNames = new String[cdd.length]; for(int i=0;i<cdd.length;++i) { connDefNames[i] = cdd[i].getConnectionFactoryIntf(); } } return connDefNames; }
public String[] getMessageListenerTypes(ConnectorDescriptor desc) throws ConnectorRuntimeException { if(desc == null) { throw new ConnectorRuntimeException("Invalid arguments"); } MessageListener messageListeners[] = ddTransformUtil.getMessageListeners(desc); String[] messageListenerTypes = null; if(messageListeners != null) { messageListenerTypes = new String[messageListeners.length]; for(int i=0;i<messageListeners.length;++i) { messageListenerTypes[i] = messageListeners[i].getMessageListenerType(); } } return messageListenerTypes; }
/** * It initializes the resource adapter. It also creates the default pools * and resources of all the connection definitions. * * @throws ConnectorRuntimeException This exception is thrown if the * ra.xml is invalid or the default pools and resources couldn't * be created */ public void setup() throws ConnectorRuntimeException { if (connectionDefs_ == null || connectionDefs_.length != 1) { _logger.log(Level.SEVERE, "rardeployment.invalid_connector_desc", moduleName_); String i18nMsg = localStrings.getString("ccp_adm.invalid_connector_desc", moduleName_); throw new ConnectorRuntimeException(i18nMsg); } if (isServer() && !isSystemRar(moduleName_)) { createAllConnectorResources(); } if(_logger.isLoggable(Level.FINE)) { _logger.log(Level.FINE, "Completed Active Resource adapter setup", moduleName_); } }
/** * check whether the <i>required-work-context</i> list mandated by the resource-adapter * is supported by the application server * @param desc ConnectorDescriptor * @throws ConnectorRuntimeException when unable to support any of the requested work-context type. */ private void validateWorkContextSupport(ConnectorDescriptor desc) throws ConnectorRuntimeException { Set workContexts = desc.getRequiredWorkContexts(); Iterator workContextsIterator = workContexts.iterator(); WorkContextHandler workContextHandler = connectorRuntime_.getWorkContextHandler(); workContextHandler.init(moduleName_, jcl_); while(workContextsIterator.hasNext()){ String ic = (String)workContextsIterator.next(); boolean supported = workContextHandler.isContextSupported(true, ic ); if(!supported){ String errorMsg = "Unsupported work context [ "+ ic + " ] "; Object params[] = new Object[]{ic, desc.getName()}; _logger.log(Level.WARNING,"unsupported.work.context", params); throw new ConnectorRuntimeException(errorMsg); } } }
public ConnectorClassFinder getSystemRARClassLoader(String rarName) throws ConnectorRuntimeException { if (ConnectorsUtil.belongsToSystemRA(rarName)) { DelegatingClassLoader dch = clh.getConnectorClassLoader(null); for (DelegatingClassLoader.ClassFinder cf : dch.getDelegates()) { if (cf instanceof ConnectorClassFinder) { if (rarName.equals(((ConnectorClassFinder) cf).getResourceAdapterName())) { return (ConnectorClassFinder) cf; } } } } throw new ConnectorRuntimeException("No Classloader found for RA [ " + rarName + " ]"); }
/** * Flush Connection pool by reinitializing the connections * established in the pool. * @param poolInfo * @throws com.sun.appserv.connectors.internal.api.ConnectorRuntimeException */ public boolean flushConnectionPool(PoolInfo poolInfo) throws ConnectorRuntimeException { PoolManager poolMgr = _runtime.getPoolManager(); try { return poolMgr.flushConnectionPool( poolInfo ); } catch (PoolingException ex) { throw new ConnectorRuntimeException(ex.getMessage()); } }
public void loadDeferredResources(Resource[] resourcesToLoad) throws Exception { if (resourcesToLoad == null || resourcesToLoad.length == 0) { return; } for (Resource resource : resourcesToLoad) { if (resource == null) { continue; } else if (getResourcesUtil().isEnabled(resource)) { try { _runtime.getResourceDeployer(resource).deployResource(resource); } catch (Exception e) { ConnectorRuntimeException cre = new ConnectorRuntimeException(e.getMessage()); cre.initCause(e); throw cre; } } } }
private ActiveInboundResourceAdapter getActiveResourceAdapter(String resourceAdapterMid) throws Exception { Object activeRar = registry_.getActiveResourceAdapter(resourceAdapterMid); // Except system-rars, all other rars are loaded eagerly. // Check whether the rar is a system-rar. // (as of now, jms-ra is the only inbound system-rar) if (activeRar == null && ConnectorsUtil.belongsToSystemRA(resourceAdapterMid)) { ConnectorRuntime crt = ConnectorRuntime.getRuntime(); crt.loadDeferredResourceAdapter(resourceAdapterMid); activeRar = registry_.getActiveResourceAdapter(resourceAdapterMid); } if (activeRar == null) { String msg = "Resource adapter " + resourceAdapterMid + " is not deployed"; throw new ConnectorRuntimeException(msg); } if (!(activeRar instanceof ActiveInboundResourceAdapter)) { throw new Exception("Resource Adapter selected doesn't support Inbound"); } return (ActiveInboundResourceAdapter) activeRar; }
private void validateResource(ResourceInfo resourceInfo) throws ConnectorRuntimeException { ResourcesUtil resourcesUtil = ResourcesUtil.createInstance(); String jndiName = resourceInfo.getName(); String suffix = ConnectorsUtil.getValidSuffix(jndiName); if(suffix != null){ //Typically, resource is created without suffix. Try without suffix. String tmpJndiName = jndiName.substring(0, jndiName.lastIndexOf(suffix)); if(resourcesUtil.getResource(tmpJndiName, resourceInfo.getApplicationName(), resourceInfo.getModuleName(), JdbcResource.class) != null){ return; } } if(resourcesUtil.getResource(resourceInfo, JdbcResource.class) == null){ throw new ConnectorRuntimeException("Invalid resource : " + resourceInfo); } }
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); }
/** * create an empty connection pool * * @param poolInfo pool to be created * @param pt type of pool * @throws ConnectorRuntimeException */ private void createAndAddPool(PoolInfo poolInfo, PoolType pt, Hashtable env) throws ConnectorRuntimeException { PoolManager poolMgr = _runtime.getPoolManager(); try { poolMgr.createEmptyConnectionPool(poolInfo, pt, env); } catch (PoolingException pe) { String i18nMsg = localStrings.getString("ccp_adm.failed_to_create_pool_object"); ConnectorRuntimeException cre = new ConnectorRuntimeException(i18nMsg); cre.initCause(pe); throw cre; } }
/** * Loads RA javabean. This method is protected, so that any system * resource adapter can have specific configuration done during the * loading. * * @throws ConnectorRuntimeException if there is a failure. */ protected void loadRAConfiguration() throws ConnectorRuntimeException { try { Set mergedProps; ConnectorRegistry registry = ConnectorRegistry.getInstance(); ResourceAdapterConfig raConfig = registry.getResourceAdapterConfig(moduleName_); List<Property> raConfigProps = new ArrayList<Property>(); mergedProps = mergeRAConfiguration(raConfig, raConfigProps); logMergedProperties(mergedProps); SetMethodAction setMethodAction = new SetMethodAction(this.resourceadapter_, mergedProps); setMethodAction.run(); } catch (Exception e) { String i18nMsg = localStrings.getString("ccp_adm.wrong_params_for_create", e.getMessage()); ConnectorRuntimeException cre = new ConnectorRuntimeException(i18nMsg); cre.initCause(e); throw cre; } }