Search in sources :

Example 21 with URL

use of java.net.URL in project camel by apache.

the class WSAddressingTest method setUp.

@Before
public void setUp() throws Exception {
    template = context.createProducerTemplate();
    JaxWsServerFactoryBean svrBean = new JaxWsServerFactoryBean();
    svrBean.setAddress(getServerAddress());
    svrBean.setServiceClass(Greeter.class);
    svrBean.setServiceBean(new GreeterImpl());
    SpringBusFactory bf = new SpringBusFactory();
    URL cxfConfig = null;
    if (getCxfServerConfig() != null) {
        cxfConfig = ClassLoaderUtils.getResource(getCxfServerConfig(), this.getClass());
    }
    svrBean.setBus(bf.createBus(cxfConfig));
    serviceEndpoint = svrBean.create();
}
Also used : SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) GreeterImpl(org.apache.hello_world_soap_http.GreeterImpl) JaxWsServerFactoryBean(org.apache.cxf.jaxws.JaxWsServerFactoryBean) URL(java.net.URL) Before(org.junit.Before)

Example 22 with URL

use of java.net.URL in project camel by apache.

the class WSAddressingTest method testWSAddressing.

@Test
public void testWSAddressing() throws Exception {
    JaxWsProxyFactoryBean proxyFactory = new JaxWsProxyFactoryBean();
    ClientFactoryBean clientBean = proxyFactory.getClientFactoryBean();
    clientBean.setAddress(getClientAddress());
    clientBean.setServiceClass(Greeter.class);
    SpringBusFactory bf = new SpringBusFactory();
    URL cxfConfig = null;
    if (getCxfClientConfig() != null) {
        cxfConfig = ClassLoaderUtils.getResource(getCxfClientConfig(), this.getClass());
    }
    proxyFactory.setBus(bf.createBus(cxfConfig));
    Greeter client = (Greeter) proxyFactory.create();
    String result = client.greetMe("world!");
    assertEquals("Get a wrong response", "Hello world!", result);
}
Also used : SpringBusFactory(org.apache.cxf.bus.spring.SpringBusFactory) ClientFactoryBean(org.apache.cxf.frontend.ClientFactoryBean) Greeter(org.apache.hello_world_soap_http.Greeter) JaxWsProxyFactoryBean(org.apache.cxf.jaxws.JaxWsProxyFactoryBean) URL(java.net.URL) Test(org.junit.Test)

Example 23 with URL

use of java.net.URL in project camel by apache.

the class DozerThreadContextClassLoader method loadResource.

@Override
public URL loadResource(String uri) {
    URL answer = null;
    ClassLoader cl = Thread.currentThread().getContextClassLoader();
    if (cl != null) {
        LOG.debug("Loading resource from classloader: {}.", cl);
        answer = cl.getResource(uri);
    }
    // try treating it as a system resource
    if (answer == null) {
        answer = ClassLoader.getSystemResource(uri);
    }
    // one more time in case it's a normal URI
    if (answer == null && StringUtils.contains(uri, ":")) {
        try {
            answer = new URL(uri);
        } catch (MalformedURLException e) {
            MappingUtils.throwMappingException(e);
        }
    }
    return answer;
}
Also used : MalformedURLException(java.net.MalformedURLException) DozerClassLoader(org.dozer.util.DozerClassLoader) URL(java.net.URL)

Example 24 with URL

use of java.net.URL in project camel by apache.

the class DozerTypeConverterLoader method loadMappings.

private List<ClassMap> loadMappings(CamelContext camelContext, String mapperId, DozerBeanMapper mapper) {
    List<ClassMap> answer = new ArrayList<ClassMap>();
    // load the class map using the class resolver so we can load from classpath in OSGi
    MappingFileReader reader = new MappingFileReader(XMLParserFactory.getInstance());
    List<String> mappingFiles = mapper.getMappingFiles();
    if (mappingFiles == null) {
        return Collections.emptyList();
    }
    for (String name : mappingFiles) {
        URL url = loadMappingFile(camelContext.getClassResolver(), name);
        if (url != null) {
            MappingFileData data = reader.read(url);
            answer.addAll(data.getClassMaps());
        }
    }
    return answer;
}
Also used : MappingFileReader(org.dozer.loader.xml.MappingFileReader) MappingFileData(org.dozer.classmap.MappingFileData) ArrayList(java.util.ArrayList) ClassMap(org.dozer.classmap.ClassMap) URL(java.net.URL)

Example 25 with URL

use of java.net.URL in project camel by apache.

the class ElsqlEndpoint method doStart.

@Override
protected void doStart() throws Exception {
    super.doStart();
    ObjectHelper.notNull(resourceUri, "resourceUri", this);
    if (elSqlConfig == null && databaseVendor != null) {
        elSqlConfig = databaseVendor.asElSqlConfig();
    } else if (elSqlConfig == null) {
        elSqlConfig = ElSqlDatabaseVendor.Default.asElSqlConfig();
    }
    // there can be multiple resources
    // so we have all this lovely code to turn that into an URL[]
    final List<URL> list = new ArrayList<URL>();
    final Iterable it = ObjectHelper.createIterable(resourceUri);
    for (final Object path : it) {
        final URL url = ResourceHelper.resolveMandatoryResourceAsUrl(getCamelContext().getClassResolver(), path.toString());
        list.add(url);
    }
    final URL[] urls = list.toArray(new URL[list.size()]);
    elSql = ElSql.parse(elSqlConfig, urls);
}
Also used : ArrayList(java.util.ArrayList) URL(java.net.URL)

Aggregations

URL (java.net.URL)8112 IOException (java.io.IOException)2006 Test (org.junit.Test)1653 File (java.io.File)1638 MalformedURLException (java.net.MalformedURLException)1165 HttpURLConnection (java.net.HttpURLConnection)1030 InputStream (java.io.InputStream)1028 ArrayList (java.util.ArrayList)633 URLConnection (java.net.URLConnection)515 InputStreamReader (java.io.InputStreamReader)473 URLClassLoader (java.net.URLClassLoader)451 BufferedReader (java.io.BufferedReader)390 HashMap (java.util.HashMap)361 URISyntaxException (java.net.URISyntaxException)286 URI (java.net.URI)269 Map (java.util.Map)259 FileInputStream (java.io.FileInputStream)227 List (java.util.List)205 FileOutputStream (java.io.FileOutputStream)194 OutputStream (java.io.OutputStream)194