List of usage examples for org.springframework.context ApplicationContextException ApplicationContextException
public ApplicationContextException(String msg, Throwable cause)
From source file:net.solarnetwork.web.gemini.ServerOsgiBundleXmlWebApplicationContext.java
/** * Register request/session scopes, a {@link ServletContextAwareProcessor}, * etc./* ww w .j av a2s. c om*/ * * @see WebApplicationContextUtils#registerWebApplicationScopes(ConfigurableListableBeanFactory) */ @Override protected void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) { super.postProcessBeanFactory(beanFactory); // Drive the kernel's bean factory post processors. BundleContext bundleContext = getBundleContext(); if (bundleContext != null) { ServiceReference<OsgiBeanFactoryPostProcessor> sr = bundleContext .getServiceReference(OsgiBeanFactoryPostProcessor.class); if (sr != null) { OsgiBeanFactoryPostProcessor kernelPostProcessor = bundleContext.getService(sr); try { kernelPostProcessor.postProcessBeanFactory(bundleContext, beanFactory); } catch (Exception e) { throw new ApplicationContextException("Kernel bean factory post processor failed", e); } finally { bundleContext.ungetService(sr); } } } beanFactory.addBeanPostProcessor(new ServletContextAwareProcessor(getServletContext(), getServletConfig())); beanFactory.ignoreDependencyInterface(ServletContextAware.class); beanFactory.ignoreDependencyInterface(ServletConfigAware.class); beanFactory.registerResolvableDependency(ServletContext.class, getServletContext()); beanFactory.registerResolvableDependency(ServletConfig.class, getServletConfig()); WebApplicationContextUtils.registerWebApplicationScopes(beanFactory); }
From source file:com.cisco.dvbu.ps.deploytool.services.ArchiveManagerImpl.java
private List<ArchiveType> getArchiveEntries(String serverId, String archiveIds, String pathToArchiveXML, String pathToServersXML) { // validate incoming arguments if (serverId == null || serverId.trim().length() == 0 || archiveIds == null || archiveIds.trim().length() == 0 || pathToServersXML == null || pathToServersXML.trim().length() == 0 || pathToArchiveXML == null || pathToArchiveXML.trim().length() == 0) { throw new ValidationException("Invalid Arguments"); }//from www .j a va2 s. c om // Validate whether the files exist or not if (!CommonUtils.fileExists(pathToArchiveXML)) { throw new CompositeException("File [" + pathToArchiveXML + "] does not exist."); } if (!CommonUtils.fileExists(pathToServersXML)) { throw new CompositeException("File [" + pathToServersXML + "] does not exist."); } try { //using jaxb convert xml to corresponding java objects ArchiveModule archiveModule = (ArchiveModule) XMLUtils.getModuleTypeFromXML(pathToArchiveXML); if (archiveModule != null && archiveModule.getArchive() != null && !archiveModule.getArchive().isEmpty()) { return archiveModule.getArchive(); } } catch (CompositeException e) { logger.error("Error while parsing ArchiveModule XML: ", e); throw new ApplicationContextException(e.getMessage(), e); } return null; }
From source file:org.jasig.springframework.web.portlet.context.PortletContextLoader.java
/** * Return the PortletApplicationContext implementation class to use, either the * default XmlPortletApplicationContext or a custom context class if specified. * @param portletContext current portlet context * @return the WebApplicationContext implementation class to use * @see #CONTEXT_CLASS_PARAM/*ww w . j a v a2 s. c o m*/ * @see org.springframework.web.portlet.context.XmlPortletApplicationContext */ protected Class<?> determineContextClass(PortletContext portletContext) { String contextClassName = portletContext.getInitParameter(CONTEXT_CLASS_PARAM); if (contextClassName != null) { try { return ClassUtils.forName(contextClassName, ClassUtils.getDefaultClassLoader()); } catch (ClassNotFoundException ex) { throw new ApplicationContextException( "Failed to load custom context class [" + contextClassName + "]", ex); } } else { contextClassName = defaultStrategies.getProperty(PortletApplicationContext.class.getName()); try { return ClassUtils.forName(contextClassName, PortletContextLoader.class.getClassLoader()); } catch (ClassNotFoundException ex) { throw new ApplicationContextException( "Failed to load default context class [" + contextClassName + "]", ex); } } }
From source file:com.cisco.dvbu.ps.deploytool.services.GroupManagerImpl.java
private List<GroupType> getGroups(String serverId, String groups, String pathToGroupsXML, String pathToServersXML) { // validate incoming arguments if (serverId == null || serverId.trim().length() == 0 || groups == null || groups.trim().length() == 0 || pathToServersXML == null || pathToServersXML.trim().length() == 0 || pathToGroupsXML == null || pathToGroupsXML.trim().length() == 0) { throw new ValidationException("Invalid Arguments"); }/*from w ww.ja v a 2 s.co m*/ try { //using jaxb convert xml to corresponding java objects GroupModule groupModuleType = (GroupModule) XMLUtils.getModuleTypeFromXML(pathToGroupsXML); if (groupModuleType != null && groupModuleType.getGroup() != null && !groupModuleType.getGroup().isEmpty()) { return groupModuleType.getGroup(); } } catch (CompositeException e) { CompositeServer targetServer = WsApiHelperObjects.getServer(serverId, pathToServersXML); String errorMessage = DeployUtil.constructMessage(DeployUtil.MessageType.ERROR.name(), "Parse Group XML", "GroupManagerImpl", pathToGroupsXML, targetServer); logger.error(errorMessage, e); throw new ApplicationContextException(errorMessage, e); } return null; }
From source file:com.gzj.tulip.jade.context.spring.JadeBeanFactoryPostProcessor.java
private List<ResourceRef> findRoseResources() { final List<ResourceRef> resources; try {//from ww w . j ava2 s. c o m resources = RoseScanner.getInstance().getJarOrClassesFolderResources(); } catch (IOException e) { throw new ApplicationContextException("error on getJarResources/getClassesFolderResources", e); } return resources; }
From source file:com.gzj.tulip.jade.context.spring.JadeBeanFactoryPostProcessor.java
private List<String> findJadeResources(final List<ResourceRef> resources) { List<String> urls = new LinkedList<String>(); for (ResourceRef ref : resources) { if (ref.hasModifier("dao") || ref.hasModifier("DAO")) { try { Resource resource = ref.getResource(); File resourceFile = resource.getFile(); if (resourceFile.isFile()) { urls.add("jar:file:" + resourceFile.toURI().getPath() + ResourceUtils.JAR_URL_SEPARATOR); } else if (resourceFile.isDirectory()) { urls.add(resourceFile.toURI().toString()); }/*from www .j a v a2 s . com*/ } catch (IOException e) { throw new ApplicationContextException("error on resource.getFile", e); } } } if (logger.isInfoEnabled()) { logger.info("[jade] found " + urls.size() + " jade urls: " + urls); } return urls; }
From source file:org.jasig.springframework.web.portlet.context.PortletContextLoader.java
/** * Return the {@link ApplicationContextInitializer} implementation classes to use * if any have been specified by {@link #CONTEXT_INITIALIZER_CLASSES_PARAM}. * @param portletContext current portlet context * @see #CONTEXT_INITIALIZER_CLASSES_PARAM *///from w w w . j a v a 2s. co m @SuppressWarnings("unchecked") protected List<Class<ApplicationContextInitializer<ConfigurableApplicationContext>>> determineContextInitializerClasses( PortletContext portletContext) { String classNames = portletContext.getInitParameter(CONTEXT_INITIALIZER_CLASSES_PARAM); List<Class<ApplicationContextInitializer<ConfigurableApplicationContext>>> classes = new ArrayList<Class<ApplicationContextInitializer<ConfigurableApplicationContext>>>(); if (classNames != null) { for (String className : StringUtils.tokenizeToStringArray(classNames, ",")) { try { Class<?> clazz = ClassUtils.forName(className, ClassUtils.getDefaultClassLoader()); Assert.isAssignable(ApplicationContextInitializer.class, clazz, "class [" + className + "] must implement ApplicationContextInitializer"); classes.add((Class<ApplicationContextInitializer<ConfigurableApplicationContext>>) clazz); } catch (ClassNotFoundException ex) { throw new ApplicationContextException( "Failed to load context initializer class [" + className + "]", ex); } } } return classes; }
From source file:com.cisco.dvbu.ps.deploytool.services.DataSourceManagerImpl.java
private List<DataSourceChoiceType> getDataSources(String serverId, String dataSourceIds, String pathToDataSourceXML, String pathToServersXML) { // Validate whether the files exist or not if (!CommonUtils.fileExists(pathToDataSourceXML)) { throw new CompositeException("File [" + pathToDataSourceXML + "] does not exist."); }/*from w w w . j a v a2s .com*/ if (!CommonUtils.fileExists(pathToServersXML)) { throw new CompositeException("File [" + pathToServersXML + "] does not exist."); } // validate incoming arguments if (serverId == null || serverId.trim().length() == 0 || dataSourceIds == null || dataSourceIds.trim().length() == 0 || pathToServersXML == null || pathToServersXML.trim().length() == 0 || pathToDataSourceXML == null || pathToDataSourceXML.trim().length() == 0) { throw new ValidationException("Invalid Arguments"); } try { //using jaxb convert xml to corresponding java objects DatasourceModule dataSourceModuleType = (DatasourceModule) XMLUtils .getModuleTypeFromXML(pathToDataSourceXML); if (dataSourceModuleType != null && dataSourceModuleType.getDatasource() != null && !dataSourceModuleType.getDatasource().isEmpty()) { return dataSourceModuleType.getDatasource(); } } catch (CompositeException e) { logger.error("Error while parsing DataSourceModule XML: ", e); throw new ApplicationContextException(e.getMessage(), e); } return null; }
From source file:com.cisco.dvbu.ps.deploytool.services.ServerAttributeManagerImpl.java
private void serverAttributeAction(String actionName, String serverId, String serverAttributeIds, String pathToServerAttributeXML, String pathToServersXML) throws CompositeException { // Validate whether the files exist or not if (!CommonUtils.fileExists(pathToServerAttributeXML)) { throw new CompositeException("File [" + pathToServerAttributeXML + "] does not exist."); }/*from ww w.ja va2 s. co m*/ if (!CommonUtils.fileExists(pathToServersXML)) { throw new CompositeException("File [" + pathToServersXML + "] does not exist."); } // Get the configuration property file set in the environment with a default of deploy.properties String propertyFile = CommonUtils.getFileOrSystemPropertyValue(CommonConstants.propertyFile, "CONFIG_PROPERTY_FILE"); String prefix = "ServerAttributeManagerImpl.serverAttributeAction"; String processedIds = null; // Extract variables for the serverAttributeIds serverAttributeIds = CommonUtils.extractVariable(prefix, serverAttributeIds, propertyFile, true); // Set the Module Action Objective String s1 = (serverAttributeIds == null) ? "no_serverAttributeIds" : "Ids=" + serverAttributeIds; System.setProperty("MODULE_ACTION_OBJECTIVE", actionName + " : " + s1); try { List<ServerAttributeType> serverAttributeList = getServerAttributes(serverId, serverAttributeIds, pathToServerAttributeXML, pathToServersXML); if (serverAttributeList != null && serverAttributeList.size() > 0) { // Loop over the list of server attributes and apply their attributes to // the target CIS instance. String serverAttributePath = null; ServerAttributeModule updateServerAttributeObj = new ServerAttributeModule(); // Get all server attribute def /*************************************** * * ServerAttributeWSDAOImpl Invocation * ***************************************/ for (ServerAttributeType serverAttribute : serverAttributeList) { // Get the identifier and convert any $VARIABLES String identifier = CommonUtils.extractVariable(prefix, serverAttribute.getId(), propertyFile, true); serverAttributePath = serverAttribute.getName(); /** * Possible values for server attributes * 1. csv string like sa1,sa2 (we process only resource names which are passed in) * 2. '*' or what ever is configured to indicate all resources (we process all resources in this case) * 3. csv string with '-' or what ever is configured to indicate exclude resources as prefix * like -sa1,sa2 (we ignore passed in resources and process rest of the in the input xml */ if (DeployUtil.canProcessResource(serverAttributeIds, identifier)) { ServerAttributeType updAttribute = new ServerAttributeType(); /*************************************** * * ServerAttributeWSDAOImpl Invocation * ***************************************/ // Get the server attribute definition for the current server attribute name being processed String name = serverAttribute.getName(); // Set the Module Action Objective s1 = (name == null) ? "no_serverAttributeName" : identifier + "=" + name; System.setProperty("MODULE_ACTION_OBJECTIVE", actionName + " : " + s1); // Add to the list of processed ids if (processedIds == null) processedIds = ""; else processedIds = processedIds + ","; processedIds = processedIds + identifier; ServerAttributeModule attributeDefModule = getServerAttributeDAO() .getServerAttributeDefinition(serverId, name, pathToServersXML); ServerAttributeDefType attributeDef = attributeDefModule.getServerAttributeDef().get(0); // Validate that the server attribute updateRule allows for READ_WRITE if ((attributeDef != null && (attributeDef.getUpdateRule().toString().equalsIgnoreCase("READ_WRITE"))) && !PropertyManager.getInstance().containsPropertyValue(propertyFile, "ServerAttributeModule_NonUpdateableAttributes", serverAttribute.getName())) { if (logger.isInfoEnabled()) { logger.info("processing action " + actionName + " on server attribute " + serverAttributePath); } // Get the id updAttribute.setId(serverAttribute.getId()); // Get the name updAttribute.setName(serverAttribute.getName()); // Get the type if (serverAttribute.getType() != null) { updAttribute.setType( AttributeTypeSimpleType.valueOf(serverAttribute.getType().toString())); } // Use this flag to add the attribute structure to the request only if there is a value Boolean valueFound = false; // Set the Value object if it exsts if (serverAttribute.getValue() != null) { // mtinius: 2012-07-03 - Parse the value for variables and resolve String value = CommonUtils.extractVariable(prefix, serverAttribute.getValue(), propertyFile, false); updAttribute.setValue(value); valueFound = true; } // Set the Value Array if it exists if (serverAttribute.getValueArray() != null) { // Instantiate a new CIS WS Schema Element (AttributeSimpleValueList) ServerAttributeValueArray updArray = new ServerAttributeValueArray(); ServerAttributeValueArray serverAttrValueArray = serverAttribute.getValueArray(); for (String item : serverAttrValueArray.getItem()) { // mtinius: 2012-07-03 - Parse the item value for variables and resolve String value = CommonUtils.extractVariable(prefix, item, propertyFile, false); updArray.getItem().add(value); } updAttribute.setValueArray(updArray); valueFound = true; } // Set the Value List if it exists if (serverAttribute.getValueList() != null) { // Instantiate a new CIS WS Schema Element (AttributeTypeValueList) ServerAttributeValueList updValueList = new ServerAttributeValueList(); ServerAttributeValueList serverAttrValueList = serverAttribute.getValueList(); for (ServerAttributeValueListItemType item : serverAttrValueList.getItem()) { ServerAttributeValueListItemType updAttributeValueType = new ServerAttributeValueListItemType(); updAttributeValueType .setType(AttributeTypeSimpleType.valueOf(item.getType().toString())); // mtinius: 2012-07-03 - Parse the value for variables and resolve String value = CommonUtils.extractVariable(prefix, item.getValue(), propertyFile, false); updAttributeValueType.setValue(value); updValueList.getItem().add(updAttributeValueType); } updAttribute.setValueList(updValueList); valueFound = true; } // Set the Value Map if it exists if (serverAttribute.getValueMap() != null) { // Instantiate a new CIS WS Schema Element (AttributeTypeValueMap) ServerAttributeValueMap updValueMap = new ServerAttributeValueMap(); ServerAttributeValueMap serverAttrValueMap = serverAttribute.getValueMap(); for (ServerAttributeValueMapEntryType item : serverAttrValueMap.getEntry()) { ServerAttributeValueMapEntryType updEntry = new ServerAttributeValueMapEntryType(); // Set the value map entry key node ServerAttributeValueMapEntryKeyType updKey = new ServerAttributeValueMapEntryKeyType(); updKey.setType( AttributeTypeSimpleType.valueOf(item.getKey().getType().toString())); updKey.setValue(item.getKey().getValue()); updEntry.setKey(updKey); // Set the value map entry value node ServerAttributeValueMapEntryValueType updValue = new ServerAttributeValueMapEntryValueType(); updValue.setType( AttributeTypeSimpleType.valueOf(item.getValue().getType().toString())); // mtinius: 2012-07-03 - Parse the value for variables and resolve String value2 = CommonUtils.extractVariable(prefix, item.getValue().getValue(), propertyFile, false); updValue.setValue(value2); updEntry.setValue(updValue); updValueMap.getEntry().add(updEntry); } updAttribute.setValueMap(updValueMap); valueFound = true; } if (valueFound) { updateServerAttributeObj.getServerAttribute().add(updAttribute); } else { if (logger.isInfoEnabled()) { String msg = "Warning: Skipping action " + actionName + " on server attribute " + serverAttributePath + " Reason: value not found."; logger.info(msg); System.setProperty("MODULE_ACTION_MESSAGE", msg); } } } else { if (logger.isInfoEnabled()) { String msg = "Warning: Skipping action " + actionName + " on server attribute " + serverAttributePath + " Reason: attribute is READ_ONLY or was found in Server Attribute Non-Updateable list."; logger.info(msg); System.setProperty("MODULE_ACTION_MESSAGE", msg); } } } } /*************************************** * * ServerAttributeWSDAOImpl Invocation * ***************************************/ getServerAttributeDAO().takeServerAttributeAction(actionName, updateServerAttributeObj, serverId, pathToServersXML); // Determine if any resourceIds were not processed and report on this if (processedIds != null) { if (logger.isInfoEnabled()) { logger.info("Server Attribute entries processed=" + processedIds); } } else { if (logger.isInfoEnabled()) { String msg = "Warning: No Server Attribute entries were processed for the input list. serverAttributeIds=" + serverAttributeIds; logger.info(msg); System.setProperty("MODULE_ACTION_MESSAGE", msg); } } } } catch (CompositeException e) { logger.error("Error on server attribute action (" + actionName + "): ", e); throw new ApplicationContextException(e.getMessage(), e); } }
From source file:com.cisco.dvbu.ps.deploytool.services.ServerAttributeManagerImpl.java
private List<ServerAttributeType> getServerAttributes(String serverId, String serverAttributeIds, String pathToServerAttributeXML, String pathToServersXML) { // validate incoming arguments if (serverId == null || serverId.trim().length() == 0 || serverAttributeIds == null || serverAttributeIds.trim().length() == 0 || pathToServersXML == null || pathToServersXML.trim().length() == 0 || pathToServerAttributeXML == null || pathToServerAttributeXML.trim().length() == 0) { throw new ValidationException("Invalid Arguments"); }/*ww w . j av a 2s .com*/ try { //using jaxb convert xml to corresponding java objects ServerAttributeModule serverAttributeModuleType = (ServerAttributeModule) XMLUtils .getModuleTypeFromXML(pathToServerAttributeXML); if (serverAttributeModuleType != null && serverAttributeModuleType.getServerAttribute() != null && !serverAttributeModuleType.getServerAttribute().isEmpty()) { return serverAttributeModuleType.getServerAttribute(); } } catch (CompositeException e) { logger.error("Error while parsing server attribute xml", e); throw new ApplicationContextException(e.getMessage(), e); } return null; }