当前位置: 首页>>代码示例>>Java>>正文


Java MarshalException类代码示例

本文整理汇总了Java中org.exolab.castor.xml.MarshalException的典型用法代码示例。如果您正苦于以下问题:Java MarshalException类的具体用法?Java MarshalException怎么用?Java MarshalException使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


MarshalException类属于org.exolab.castor.xml包,在下文中一共展示了MarshalException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getTestContextFields

import org.exolab.castor.xml.MarshalException; //导入依赖的package包/类
public String[] getTestContextFields() throws MarshalException, ValidationException {
	Set fields=new HashSet();
	
	for( Iterator iter=queryEntitlements.iterator(); iter.hasNext(); ) {
		QueryEntitlement entitle=(QueryEntitlement) iter.next();
		Query query=entitle.getQuery();
		
		org.ralasafe.db.sql.Query sqlQuery=query.getSqlQuery();
		Util.extractContextValueFields( sqlQuery, fields );
		
		String xmlContent=entitle.getUserCategory().getXmlContent();
		UserCategoryType unmarshal;
		unmarshal=UserCategory.unmarshal( new StringReader( xmlContent ) );
			
		DefineVariable[] variables=unmarshal.getDefineVariable();
		Util.extractContextValueFields( variables, queryManager, fields );
	}
	
	return (String[]) fields.toArray( new String[0] );
}
 
开发者ID:yswang0927,项目名称:ralasafe,代码行数:21,代码来源:QueryEntitlementHandler.java

示例2: getTestBusinessDataFieldTypes

import org.exolab.castor.xml.MarshalException; //导入依赖的package包/类
public String[] getTestBusinessDataFieldTypes() throws MarshalException, ValidationException {
	String[] fields=getTestBusinessDataFields();
	String[] types=new String[fields.length];
	
	if( !StringUtil.isEmpty( businessDataClass ) ) {
		String[][] reflectJavaBean=Util.reflectJavaBean( businessDataClass );
		
		for( int i=0; i<fields.length; i++ ) {
			String field=fields[i];
			
			for( int j=0; j<reflectJavaBean.length; j++ ) {
				String[] strings=reflectJavaBean[j];
				
				if( strings[0].equals( field ) ) {
					types[i]=strings[1];
					j=reflectJavaBean.length;
				}
			}
		}
	}
	
	return types;
}
 
开发者ID:yswang0927,项目名称:ralasafe,代码行数:24,代码来源:DecisionEntitlementHandler.java

示例3: unMarshallString

import org.exolab.castor.xml.MarshalException; //导入依赖的package包/类
public static Object unMarshallString(Reader reader, Class objectClass) throws IOException {
    Unmarshaller unmarshaller = new Unmarshaller(objectClass);
    Object castor;
    try {
        InputSource is = new InputSource(reader);
        is.setSystemId("stringBuffer");
        castor = unmarshaller.unmarshal(is);
        reader.close();
    } catch (MarshalException marshalException) {
        //TODO Juzer throw proper exception so that calling function can handle it
        throw new IOException(marshalException.getMessage());
    } catch (ValidationException validationException) {
        throw new IOException(validationException.getMessage());
    }
    return castor;
}
 
开发者ID:OpenDA-Association,项目名称:OpenDA,代码行数:17,代码来源:UncertaintyReader.java

示例4: updateServiceCompounds

import org.exolab.castor.xml.MarshalException; //导入依赖的package包/类
Map<String, ServiceCompound> updateServiceCompounds(Map<String, ServiceCompound> serviceCompounds) throws IOException, MarshalException, ValidationException {
    PollerConfiguration pollerConfiguration = readPollerConfiguration();

    for (Monitor monitor : pollerConfiguration.getMonitorCollection()) {
        if (!serviceCompounds.containsKey(monitor.getService())) {
            serviceCompounds.put(monitor.getService(), new ServiceCompound(monitor.getService()));
        }
        serviceCompounds.get(monitor.getService()).setMonitor(monitor);
    }
    for (org.opennms.netmgt.config.poller.Package pollerPackage : pollerConfiguration.getPackageCollection()) {
        for (Service service : pollerPackage.getServiceCollection()) {
            if (!serviceCompounds.containsKey(service.getName())) {
                serviceCompounds.put(service.getName(), new ServiceCompound(service.getName()));
            }
            serviceCompounds.get(service.getName()).setPollerService(service);
        }
    }
    return serviceCompounds;
}
 
开发者ID:indigo423,项目名称:opennms-config-audit,代码行数:20,代码来源:PollerChecker.java

示例5: updateServiceCompounds

import org.exolab.castor.xml.MarshalException; //导入依赖的package包/类
Map<String, ServiceCompound> updateServiceCompounds(Map<String, ServiceCompound> serviceCompounds) throws IOException, MarshalException, ValidationException {
    CollectdConfig collectdConfiguration = readCollectdConfiguration();

    for (CollectdPackage collectdPackage : collectdConfiguration.getPackages()) {
        for (Service collectdService : collectdPackage.getPackage().getServiceCollection()) {
            if (!serviceCompounds.containsKey(collectdService.getName())) {
                serviceCompounds.put(collectdService.getName(), new ServiceCompound(collectdService.getName()));
            }
            serviceCompounds.get(collectdService.getName()).setCollectdService(collectdService);
        }
    }
    for (Collector collector : collectdConfiguration.getConfig().getCollectorCollection()) {
        if (!serviceCompounds.containsKey(collector.getService())) {
                serviceCompounds.put(collector.getService(), new ServiceCompound(collector.getService()));
            }
            serviceCompounds.get(collector.getService()).setCollector(collector);
    }
    return serviceCompounds;
}
 
开发者ID:indigo423,项目名称:opennms-config-audit,代码行数:20,代码来源:CollectionChecker.java

示例6: convertCastorException

import org.exolab.castor.xml.MarshalException; //导入依赖的package包/类
/**
 * Convert the given {@code XMLException} to an appropriate exception from the
 * {@code org.springframework.oxm} hierarchy.
 * <p>A boolean flag is used to indicate whether this exception occurs during marshalling or
 * unmarshalling, since Castor itself does not make this distinction in its exception hierarchy.
 * @param ex Castor {@code XMLException} that occurred
 * @param marshalling indicates whether the exception occurs during marshalling ({@code true}),
 * or unmarshalling ({@code false})
 * @return the corresponding {@code XmlMappingException}
 */
protected XmlMappingException convertCastorException(XMLException ex, boolean marshalling) {
	if (ex instanceof ValidationException) {
		return new ValidationFailureException("Castor validation exception", ex);
	}
	else if (ex instanceof MarshalException) {
		if (marshalling) {
			return new MarshallingFailureException("Castor marshalling exception", ex);
		}
		else {
			return new UnmarshallingFailureException("Castor unmarshalling exception", ex);
		}
	}
	else {
		// fallback
		return new UncategorizedMappingException("Unknown Castor exception", ex);
	}
}
 
开发者ID:langtianya,项目名称:spring4-understanding,代码行数:28,代码来源:CastorMarshaller.java

示例7: MulgaraUserConfig

import org.exolab.castor.xml.MarshalException; //导入依赖的package包/类
/**
 * Create the config object, to look like a standard configuration.
 * @throws IOException 
 * @throws ValidationException 
 * @throws MarshalException 
 */
public MulgaraUserConfig(String configUrlStr) throws MarshalException, ValidationException, IOException {
  // Set up the system configuration. This should never fail, unless someone adjusted it incorrectly.
  URL sysUrl = ClassLoader.getSystemResource(CONFIG_PATH);
  if (sysUrl == null) throw new IOException("Unable to locate embedded server configuration file");

  systemConfig = MulgaraConfig.unmarshal(new InputStreamReader(sysUrl.openStream()));

  // Set up the user configuration. Users can create problems for themselves here.
  if (configUrlStr != null) {
    URL userUrl = new URL(configUrlStr);
    userConfig = MulgaraConfig.unmarshal(new InputStreamReader(userUrl.openStream()));
    usr = true;
  } else {
    userConfig = null;
    usr = false;
  }
  validate();

  initializeLists();
}
 
开发者ID:quoll,项目名称:mulgara,代码行数:27,代码来源:MulgaraUserConfig.java

示例8: init

import org.exolab.castor.xml.MarshalException; //导入依赖的package包/类
/**
 * Load the config from the default config file and create the singleton
 * instance of this factory.
 *
 * @exception java.io.IOException
 *                Thrown if the specified config file cannot be read
 * @exception org.exolab.castor.xml.MarshalException
 *                Thrown if the file does not conform to the schema.
 * @exception org.exolab.castor.xml.ValidationException
 *                Thrown if the contents do not match the required schema.
 * @throws java.io.IOException if any.
 * @throws org.exolab.castor.xml.MarshalException if any.
 * @throws org.exolab.castor.xml.ValidationException if any.
 */
public static synchronized void init() throws IOException, MarshalException, ValidationException {
    if (m_loaded) {
        // init already called - return
        // to reload, reload() will need to be called
        return;
    }

    final File cfgFile = ConfigFileConstants.getFile(ConfigFileConstants.DISCOVERY_CONFIG_FILE_NAME);

    LogUtils.debugf(DiscoveryConfigFactory.class, "init: config file path: %s", cfgFile.getPath());

    m_singleton = new DiscoveryConfigFactory(cfgFile.getPath());

    try {
        m_singleton.getInitialSleepTime();
        m_singleton.getRestartSleepTime();
        m_singleton.getIntraPacketDelay();
        m_singleton.getConfiguredAddresses();
    } catch (final Exception e) {
        throw new ValidationException("An error occurred while validating the configuration: " + e, e);
    }
    
    m_loaded = true;
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:39,代码来源:DiscoveryConfigFactory.java

示例9: marshal

import org.exolab.castor.xml.MarshalException; //导入依赖的package包/类
/**
 * <p>marshal</p>
 *
 * @param outputFile a {@link java.io.File} object.
 * @throws org.opennms.report.inventory.InventoryCalculationException if any.
 */
public void marshal(File outputFile)
throws InventoryCalculationException {
    try {
        Writer fileWriter = new OutputStreamWriter(new FileOutputStream(outputFile), "UTF-8");
        Marshaller marshaller = new Marshaller(fileWriter);
        marshaller.setSuppressNamespaces(true);
        marshaller.marshal(rnbi);
        log().debug("The xml marshalled from the castor classes is saved in "
                + outputFile.getAbsoluteFile());
        fileWriter.close();
    } catch (MarshalException me) {
        log().fatal("MarshalException ", me);
        throw new InventoryCalculationException(me);
    } catch (ValidationException ve) {
        log().fatal("Validation Exception ", ve);
        throw new InventoryCalculationException(ve);
    } catch (IOException ioe) {
        log().fatal("IO Exception ", ioe);
        throw new InventoryCalculationException(ioe);
    }

}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:29,代码来源:InventoryReportCalculator.java

示例10: BaseConnectionFactory

import org.exolab.castor.xml.MarshalException; //导入依赖的package包/类
/**
 * @param configFile A configuration file name.
 * @param dsName The data source's name.
 * @throws java.io.IOException if any.
 * @throws org.exolab.castor.xml.MarshalException if any.
 * @throws org.exolab.castor.xml.ValidationException if any.
 * @throws java.beans.PropertyVetoException if any.
 * @throws java.sql.SQLException if any.
 */
protected BaseConnectionFactory(final String configFile, final String dsName) throws IOException, MarshalException, ValidationException, PropertyVetoException, SQLException {
    /*
     * Set the system identifier for the source of the input stream.
     * This is necessary so that any location information can
     * positively identify the source of the error.
     */
	final FileInputStream fileInputStream = new FileInputStream(configFile);
    LogUtils.infof(this, "Setting up data sources from %s.", configFile);
    try {
    	final JdbcDataSource ds = ConnectionFactoryUtil.marshalDataSourceFromConfig(fileInputStream, dsName);
    	initializePool(ds);
    } finally {
        IOUtils.closeQuietly(fileInputStream);
    }
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:25,代码来源:BaseConnectionFactory.java

示例11: unmarshal

import org.exolab.castor.xml.MarshalException; //导入依赖的package包/类
/**
 * Unmarshal a Castor XML configuration file.  Uses Java 5 generics for
 * return type.
 *
 * @param clazz the class representing the marshalled XML configuration file
 * @param resource the marshalled XML configuration file to unmarshal
 * @param preserveWhitespace whether or not to preserve whitespace
 * @return Unmarshalled object representing XML file
 * @throws org.exolab.castor.xml.MarshalException if the underlying Castor
 *      Unmarshaller.unmarshal() call throws a org.exolab.castor.xml.MarshalException
 * @throws org.exolab.castor.xml.ValidationException if the underlying Castor
 *      Unmarshaller.unmarshal() call throws a org.exolab.castor.xml.ValidationException
 * @throws java.io.IOException if the resource could not be opened
 */
public static <T> T unmarshal(Class<T> clazz, Resource resource, boolean preserveWhitespace) throws MarshalException, ValidationException, IOException {
    InputStream in;
    try {
        in = resource.getInputStream();
    } catch (IOException e) {
        IOException newE = new IOException("Failed to open XML configuration file for resource '" + resource + "': " + e);
        newE.initCause(e);
        throw newE;
    }

    try {
        InputSource source = new InputSource(in);
        try {
            source.setSystemId(resource.getURL().toString());
        } catch (Throwable t) {
            // ignore
        }
        return unmarshal(clazz, source, preserveWhitespace);
    } finally {
        IOUtils.closeQuietly(in);
    }
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:37,代码来源:CastorUtils.java

示例12: testAddAdjacentSpecificToDefIPv6WithDifferentScopeIds

import org.exolab.castor.xml.MarshalException; //导入依赖的package包/类
public final void testAddAdjacentSpecificToDefIPv6WithDifferentScopeIds() throws MarshalException, ValidationException, IOException {

        String amiConfigXml = "<?xml version=\"1.0\"?>\n" + 
        "<wmi-config retry=\"3\" timeout=\"800\"\n" + 
        "   password=\"password\">\n" + 
        "   <definition>\n" + 
        "       <specific>fe80:0000:0000:0000:0000:0000:0000:fedb%1</specific>\n" + 
        "       <specific>fe80:0000:0000:0000:0000:0000:0000:fedc%2</specific>\n" + 
        "   </definition>\n" + 
        "\n" + 
        "</wmi-config>\n" + 
        "";

        WmiPeerFactory factory = new WmiPeerFactory(new ByteArrayInputStream(amiConfigXml.getBytes("UTF-8")));

        assertEquals(1, factory.getConfig().getDefinitionCount());
        assertEquals(2, factory.getConfig().getDefinition(0).getSpecificCount());
        assertEquals(0, factory.getConfig().getDefinition(0).getRangeCount());

        WmiPeerFactory.optimize();

        // No optimization should occur because the addresses have different scope IDs
        assertEquals(1, factory.getConfig().getDefinitionCount());
        assertEquals(2, factory.getConfig().getDefinition(0).getSpecificCount());
        assertEquals(0, factory.getConfig().getDefinition(0).getRangeCount());
    }
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:27,代码来源:WmiPeerFactoryTest.java

示例13: init

import org.exolab.castor.xml.MarshalException; //导入依赖的package包/类
/**
 * Load the config from the default config file and create the singleton
 * instance of this factory.
 *
 * @exception java.io.IOException
 *                Thrown if the specified config file cannot be read
 * @exception org.exolab.castor.xml.MarshalException
 *                Thrown if the file does not conform to the schema.
 * @exception org.exolab.castor.xml.ValidationException
 *                Thrown if the contents do not match the required schema.
 * @throws java.io.IOException if any.
 * @throws org.exolab.castor.xml.MarshalException if any.
 * @throws org.exolab.castor.xml.ValidationException if any.
 */
public static synchronized void init() throws IOException, MarshalException, ValidationException {
    if (m_loaded) {
        // init already called - return
        // to reload, reload() will need to be called
        return;
    }

    OpennmsServerConfigFactory.init();
    OpennmsServerConfigFactory onmsSvrConfig = OpennmsServerConfigFactory.getInstance();

    File cfgFile = ConfigFileConstants.getFile(ConfigFileConstants.SNMP_INTERFACE_POLLER_CONFIG_FILE_NAME);

    logStatic().debug("init: config file path: " + cfgFile.getPath());

    InputStream stream = null;
    try {
        stream = new FileInputStream(cfgFile);
        SnmpInterfacePollerConfigFactory config = new SnmpInterfacePollerConfigFactory(cfgFile.lastModified(), stream, onmsSvrConfig.getServerName(), onmsSvrConfig.verifyServer());
        setInstance(config);
    } finally {
        if (stream != null) {
            IOUtils.closeQuietly(stream);
        }
    }
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:40,代码来源:SnmpInterfacePollerConfigFactory.java

示例14: update

import org.exolab.castor.xml.MarshalException; //导入依赖的package包/类
/**
 * <p>update</p>
 *
 * @throws java.io.IOException if any.
 * @throws org.exolab.castor.xml.MarshalException if any.
 * @throws org.exolab.castor.xml.ValidationException if any.
 */
public void update() throws IOException, MarshalException, ValidationException {
    getWriteLock().lock();
    try {
        final File cfgFile = ConfigFileConstants.getFile(ConfigFileConstants.POLLER_CONFIG_FILE_NAME);
        if (cfgFile.lastModified() > m_currentVersion) {
            m_currentVersion = cfgFile.lastModified();
            LogUtils.debugf(this, "init: config file path: %s", cfgFile.getPath());
            InputStream stream = null;
            try {
                stream = new FileInputStream(cfgFile);
                m_config = CastorUtils.unmarshal(PollerConfiguration.class, stream);
            } finally {
                IOUtils.closeQuietly(stream);
            }
            init();
            LogUtils.debugf(this, "init: finished loading config file: %s", cfgFile.getPath());
        }
    } finally {
        getWriteLock().unlock();
    }
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:29,代码来源:PollerConfigFactory.java

示例15: testOneSpecific

import org.exolab.castor.xml.MarshalException; //导入依赖的package包/类
/**
 * @throws MarshalException
 * @throws ValidationException
 * @throws IOException 
 */
@Test
public final void testOneSpecific() throws MarshalException, ValidationException, IOException {

    String amiConfigXml = "<?xml version=\"1.0\"?>\n" + 
    "<nsclient-config retry=\"3\" timeout=\"800\"\n" + 
    "   password=\"password\">\n" + 
    "   <definition>\n" + 
    "       <specific>192.168.0.5</specific>\n" + 
    "   </definition>\n" + 
    "\n" + 
    "</nsclient-config>\n" + 
    "";

    NSClientPeerFactory factory = new NSClientPeerFactory(new ByteArrayInputStream(amiConfigXml.getBytes("UTF-8")));

    assertEquals(1, factory.getConfig().getDefinitionCount());

    factory.optimize();

    assertEquals(1, factory.getConfig().getDefinitionCount());
}
 
开发者ID:qoswork,项目名称:opennmszh,代码行数:27,代码来源:NSClientPeerFactoryTest.java


注:本文中的org.exolab.castor.xml.MarshalException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。