Java Code Examples for org.apache.cxf.common.classloader.ClassLoaderUtils#getResource()
The following examples show how to use
org.apache.cxf.common.classloader.ClassLoaderUtils#getResource() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractColocTest.java From cxf with Apache License 2.0 | 6 votes |
/** * Setup this test case */ @Before public void setUp() throws Exception { // initialize Mule Manager URL cxfConfig = null; if (getCxfConfig() != null) { cxfConfig = ClassLoaderUtils.getResource(getCxfConfig(), AbstractColocTest.class); if (cxfConfig == null) { throw new Exception("Make sure " + getCxfConfig() + " is in the CLASSPATH"); } assertNotNull(cxfConfig.toExternalForm()); } //Bus is shared by client, router and server. SpringBusFactory bf = new SpringBusFactory(); bus = bf.createBus(cxfConfig); BusFactory.setDefaultBus(bus); //Start the Remote Server // the endpoint of the "real" cxf server endpoint = Endpoint.publish(getTransportURI(), getServiceImpl()); }
Example 2
Source File: AbstractWSS4JInterceptor.java From steady with Apache License 2.0 | 5 votes |
@Override protected Crypto loadCryptoFromPropertiesFile( String propFilename, RequestData reqData ) throws WSSecurityException { ClassLoaderHolder orig = null; try { try { URL url = ClassLoaderUtils.getResource(propFilename, this.getClass()); if (url == null) { ResourceManager manager = ((Message)reqData.getMsgContext()).getExchange() .getBus().getExtension(ResourceManager.class); ClassLoader loader = manager.resolveResource("", ClassLoader.class); if (loader != null) { orig = ClassLoaderUtils.setThreadContextClassloader(loader); } url = manager.resolveResource(propFilename, URL.class); } if (url != null) { Properties props = new Properties(); InputStream in = url.openStream(); props.load(in); in.close(); return CryptoFactory.getInstance(props, this.getClassLoader(reqData.getMsgContext())); } } catch (Exception e) { //ignore } return CryptoFactory.getInstance(propFilename, this.getClassLoader(reqData.getMsgContext())); } finally { if (orig != null) { orig.reset(); } } }
Example 3
Source File: AbstractWSS4JInterceptor.java From steady with Apache License 2.0 | 5 votes |
@Override protected Crypto loadCryptoFromPropertiesFile( String propFilename, RequestData reqData ) throws WSSecurityException { ClassLoaderHolder orig = null; try { try { URL url = ClassLoaderUtils.getResource(propFilename, this.getClass()); if (url == null) { ResourceManager manager = ((Message)reqData.getMsgContext()).getExchange() .getBus().getExtension(ResourceManager.class); ClassLoader loader = manager.resolveResource("", ClassLoader.class); if (loader != null) { orig = ClassLoaderUtils.setThreadContextClassloader(loader); } url = manager.resolveResource(propFilename, URL.class); } if (url != null) { Properties props = new Properties(); InputStream in = url.openStream(); props.load(in); in.close(); return CryptoFactory.getInstance(props, this.getClassLoader(reqData.getMsgContext())); } } catch (Exception e) { //ignore } return CryptoFactory.getInstance(propFilename, this.getClassLoader(reqData.getMsgContext())); } finally { if (orig != null) { orig.reset(); } } }
Example 4
Source File: AbstractWSS4JInterceptor.java From steady with Apache License 2.0 | 5 votes |
@Override protected Crypto loadCryptoFromPropertiesFile( String propFilename, RequestData reqData ) throws WSSecurityException { ClassLoaderHolder orig = null; try { try { URL url = ClassLoaderUtils.getResource(propFilename, this.getClass()); if (url == null) { ResourceManager manager = ((Message)reqData.getMsgContext()).getExchange() .getBus().getExtension(ResourceManager.class); ClassLoader loader = manager.resolveResource("", ClassLoader.class); if (loader != null) { orig = ClassLoaderUtils.setThreadContextClassloader(loader); } url = manager.resolveResource(propFilename, URL.class); } if (url != null) { Properties props = new Properties(); InputStream in = url.openStream(); props.load(in); in.close(); return CryptoFactory.getInstance(props, this.getClassLoader(reqData.getMsgContext())); } } catch (Exception e) { //ignore } return CryptoFactory.getInstance(propFilename, this.getClassLoader(reqData.getMsgContext())); } finally { if (orig != null) { orig.reset(); } } }
Example 5
Source File: AbstractWSS4JInterceptor.java From steady with Apache License 2.0 | 5 votes |
@Override protected Crypto loadCryptoFromPropertiesFile( String propFilename, RequestData reqData ) throws WSSecurityException { ClassLoaderHolder orig = null; try { try { URL url = ClassLoaderUtils.getResource(propFilename, this.getClass()); if (url == null) { ResourceManager manager = ((Message)reqData.getMsgContext()).getExchange() .getBus().getExtension(ResourceManager.class); ClassLoader loader = manager.resolveResource("", ClassLoader.class); if (loader != null) { orig = ClassLoaderUtils.setThreadContextClassloader(loader); } url = manager.resolveResource(propFilename, URL.class); } if (url != null) { Properties props = new Properties(); InputStream in = url.openStream(); props.load(in); in.close(); return CryptoFactory.getInstance(props, this.getClassLoader(reqData.getMsgContext())); } } catch (Exception e) { //ignore } return CryptoFactory.getInstance(propFilename, this.getClassLoader(reqData.getMsgContext())); } finally { if (orig != null) { orig.reset(); } } }
Example 6
Source File: JexlClaimsMapper.java From cxf with Apache License 2.0 | 5 votes |
public final void setScript(String scriptLocation) throws IOException { URL resource = ClassLoaderUtils.getResource(scriptLocation, this.getClass()); if (resource != null) { scriptLocation = resource.getPath(); if (LOG.isLoggable(Level.FINE)) { LOG.fine("Script found within Classpath: " + scriptLocation); } } File scriptFile = new File(scriptLocation); if (scriptFile.exists()) { this.script = jexlEngine.createScript(scriptFile); } else { throw new IllegalArgumentException("Script resource not found!"); } }
Example 7
Source File: WSDL11Validator.java From cxf with Apache License 2.0 | 5 votes |
protected List<InputSource> getDefaultSchemas() throws IOException { List<InputSource> xsdList = new ArrayList<>(); URL url = ClassLoaderUtils.getResource("/schemas/configuration/parameterized-types.xsd", this.getClass()); if (url != null) { InputSource is = new InputSource(url.openStream()); is.setSystemId(url.toString()); xsdList.add(is); } addDefaultSchemas(ToolConstants.CXF_SCHEMAS_DIR_INJAR, xsdList); return xsdList; }
Example 8
Source File: CorbaBindingFactoryConfigurerTest.java From cxf with Apache License 2.0 | 4 votes |
@Test public void testOrbConfiguration() throws Exception { SpringBusFactory bf = new SpringBusFactory(); URL cxfConfig = null; cxfConfig = ClassLoaderUtils.getResource("corba_binding_factory_configurer.xml", this.getClass()); bus = bf.createBus(cxfConfig); BusFactory.setDefaultBus(bus); BindingFactoryManager bfm = bus.getExtension(BindingFactoryManager.class); CorbaBindingFactory factory = (CorbaBindingFactory)bfm.getBindingFactory("http://cxf.apache.org/bindings/corba"); OrbConfig orbConfig = factory.getOrbConfig(); assertNotNull("CorbaBindingFactoryConfigurer is null", orbConfig); Properties props = orbConfig.getOrbProperties(); assertNotNull("probs is null", props); assertTrue("prob1 is not equal to value1", "value1".equals(props.get("prop1"))); assertTrue("prob2 is not equal to value2", "value2".equals(props.get("prop2"))); assertTrue("ORBClass is not equal to MyORBImpl", "com.orbimplco.MyORBImpl".equals(props.get("org.omg.CORBA.ORBClass"))); assertTrue("ORBSingletonClass is not equal to MyORBSingleton", "com.orbimplco.MyORBSingleton".equals(props.get("org.omg.CORBA.ORBSingletonClass"))); List <String> orbArgs = orbConfig.getOrbArgs(); assertNotNull("orbArgs is null", orbArgs); String domainNameId = orbArgs.get(0); assertTrue("domainNameId is not equal to -ORBdomain_name", "-ORBdomain_name".equals(domainNameId)); String domainNameValue = orbArgs.get(1); assertTrue("domainNameValue is not equal to test-domain", "test-domain".equals(domainNameValue)); String configDomainsDirId = orbArgs.get(2); assertTrue("configDomainsDirId is not equal to -ORBconfig_domains_dir", "-ORBconfig_domains_dir".equals(configDomainsDirId)); String configDomainsDirValue = orbArgs.get(3); assertTrue("configDomainsDirValue is not equal to src/test/resources", "src/test/resources".equals(configDomainsDirValue)); String orbNameId = orbArgs.get(4); assertTrue("orbNameId is not equal to -ORBname", "-ORBname".equals(orbNameId)); String orbNameValue = orbArgs.get(5); assertTrue("orbNameValue is not equal to test", "test".equals(orbNameValue)); }
Example 9
Source File: CachingTest.java From cxf with Apache License 2.0 | 4 votes |
@org.junit.Test public void testSymmetricSharedCache() throws Exception { SpringBusFactory bf = new SpringBusFactory(); URL busFile = CachingTest.class.getResource("client.xml"); Bus bus = bf.createBus(busFile.toString()); BusFactory.setDefaultBus(bus); BusFactory.setThreadDefaultBus(bus); URL wsdl = CachingTest.class.getResource("DoubleItCache.wsdl"); Service service = Service.create(wsdl, SERVICE_QNAME); QName portQName = new QName(NAMESPACE, "DoubleItCacheSymmetricPort"); // First invocation DoubleItPortType port = service.getPort(portQName, DoubleItPortType.class); updateAddressPort(port, test.getPort()); // Create shared cache String cacheKey = SecurityConstants.TOKEN_STORE_CACHE_INSTANCE + '-' + Math.abs(new Random().nextInt()); TokenStore tokenStore = new EHCacheTokenStore(cacheKey, bus, ClassLoaderUtils.getResource("cxf-ehcache.xml", this.getClass())); Client client = ClientProxy.getClient(port); client.getEndpoint().getEndpointInfo().setProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE, tokenStore); if (test.isStreaming()) { SecurityTestUtil.enableStreaming(port); } assertEquals(50, port.doubleIt(25)); // We expect two tokens as the identifier + SHA-1 are cached assertEquals(2, tokenStore.getTokenIdentifiers().size()); // Second invocation DoubleItPortType port2 = service.getPort(portQName, DoubleItPortType.class); updateAddressPort(port2, test.getPort()); client = ClientProxy.getClient(port2); client.getEndpoint().getEndpointInfo().setProperty(SecurityConstants.TOKEN_STORE_CACHE_INSTANCE, tokenStore); if (test.isStreaming()) { SecurityTestUtil.enableStreaming(port2); } port2.doubleIt(35); client = ClientProxy.getClient(port2); tokenStore = (TokenStore)client.getEndpoint().getEndpointInfo().getProperty( SecurityConstants.TOKEN_STORE_CACHE_INSTANCE ); assertNotNull(tokenStore); // We expect four tokens as the identifier + SHA-1 are cached assertEquals(4, tokenStore.getTokenIdentifiers().size()); ((java.io.Closeable)port).close(); ((java.io.Closeable)port2).close(); bus.shutdown(true); }
Example 10
Source File: DefaultInMemoryTokenStore.java From cxf with Apache License 2.0 | 4 votes |
public DefaultInMemoryTokenStore(Bus b) throws TokenStoreException { super(TokenStore.class.getName() + "-STS", b, ClassLoaderUtils.getResource("cxf-ehcache.xml", DefaultInMemoryTokenStore.class)); }
Example 11
Source File: DefaultInMemoryTokenStore.java From cxf with Apache License 2.0 | 4 votes |
public DefaultInMemoryTokenStore() throws TokenStoreException { super(TokenStore.class.getName() + "-STS", BusFactory.getDefaultBus(), ClassLoaderUtils.getResource("cxf-ehcache.xml", DefaultInMemoryTokenStore.class)); }
Example 12
Source File: ResourceUtils.java From cxf with Apache License 2.0 | 4 votes |
public static URL getClasspathResourceURL(String path, Class<?> callingClass, Bus bus) { URL url = ClassLoaderUtils.getResource(path, callingClass); return url == null ? getResource(path, URL.class, bus) : url; }
Example 13
Source File: JoseUtils.java From cxf with Apache License 2.0 | 4 votes |
public static URL getClasspathResourceURL(String path, Class<?> callingClass, Bus bus) { URL url = ClassLoaderUtils.getResource(path, callingClass); return url == null ? getResource(path, URL.class, bus) : url; }
Example 14
Source File: KeyManagementUtils.java From cxf with Apache License 2.0 | 4 votes |
private static URL getClasspathResourceURL(String path, Class<?> callingClass, Bus bus) { URL url = ClassLoaderUtils.getResource(path, callingClass); return url == null ? getResource(path, URL.class, bus) : url; }