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


Java Provider类代码示例

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


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

示例1: doCreateServiceWithReflectivelySetDelegate

import javax.xml.ws.spi.Provider; //导入依赖的package包/类
private static WinRm doCreateServiceWithReflectivelySetDelegate() {
    WinRmService service = doCreateService_1_CreateMinimalServiceInstance();

    try {
        Field delegateField = javax.xml.ws.Service.class.getDeclaredField("delegate"); //ALLOW CXF SPECIFIC SERVICE DELEGATE ONLY!
        delegateField.setAccessible(true);
        ServiceDelegate previousDelegate = (ServiceDelegate) delegateField.get(service);
        if (!previousDelegate.getClass().getName().contains("cxf")) {
            ServiceDelegate serviceDelegate = ((Provider) Class.forName("org.apache.cxf.jaxws.spi.ProviderImpl").newInstance())
                    .createServiceDelegate(WinRmService.WSDL_LOCATION, WinRmService.SERVICE, service.getClass());
            delegateField.set(service, serviceDelegate);
        }
    } catch (Exception e) {
        throw new RuntimeException("Error reflectively setting CXF WS service delegate", e);
    }
    return doCreateService_2_GetClient(service);
}
 
开发者ID:cloudsoft,项目名称:winrm4j,代码行数:18,代码来源:WinRmFactory.java

示例2: runJBossModulesClient

import javax.xml.ws.spi.Provider; //导入依赖的package包/类
private void runJBossModulesClient(String clientJar) throws Exception {
   File javaFile = new File (System.getProperty("java.home") + FS + "bin" + FS + "java");
   String javaCmd = javaFile.exists() ? javaFile.getCanonicalPath() : "java";
   
   final String jbh = System.getProperty("jboss.home");
   final String jbm = jbh + FS + "modules";
   final String jbmjar = jbh + FS + "jboss-modules.jar";
   
   final File f = new File(JBossWSTestHelper.getTestArchiveDir(), clientJar);

   //java -jar $JBOSS_HOME/jboss-modules.jar -mp $JBOSS_HOME/modules -jar client.jar
   String additionalJVMArgs = System.getProperty("additionalJvmArgs", "");
   additionalJVMArgs = additionalJVMArgs.replace('\n', ' ');
   String props = " " + additionalJVMArgs + " -Dlog4j.output.dir=" + System.getProperty("log4j.output.dir") + " -jar " + jbmjar + " -mp " + jbm; 
   final String command = javaCmd + props + " -jar " + f.getAbsolutePath() + " " + getServerHost() + " " + getServerPort();
   ByteArrayOutputStream bout = new ByteArrayOutputStream();
   executeCommand(command, bout);
   //check result (includes check on Provider impl, which might be affected by missing javax.xml.ws.api module dependency
   assertEquals(Provider.provider().getClass().getName() + ", " + TestClient.REQ_STR, readFirstLine(bout));
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:21,代码来源:JBWS1666TestCase.java

示例3: checkImplementationClassesAreNotVisible

import javax.xml.ws.spi.Provider; //导入依赖的package包/类
/**
 * AS7 check on client TCCL
 * 
 * @param cl
 */
private void checkImplementationClassesAreNotVisible(ClassLoader cl)
{
   //retrieve the stack specific Provider impl class name through the JAXWS API
   //classloading mechanism (JBEE-75), which is able to "see" implementation classes
   String providerImplClassName = Provider.provider().getClass().getName();
   if (!providerImplClassName.contains("jboss"))
   {
      throw new RuntimeException("Expected a JBoss(WS) specific implementation for javax.xml.ws.spi.Provider: "
            + providerImplClassName);
   }
   //then try loading the same class using the provided classloader
   try
   {
      cl.loadClass(providerImplClassName);
      throw new RuntimeException("ClassLoader " + cl + " should not be able to load " + providerImplClassName);
   }
   catch (ClassNotFoundException e)
   {
      //this is expected, just check the class that can't be found is our impl
      if (!(e.getMessage().contains(providerImplClassName)))
      {
         throw new RuntimeException("Unexpected Provider implementation being looked up: " + e.getMessage());
      }
   }
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:31,代码来源:Client.java

示例4: test

import javax.xml.ws.spi.Provider; //导入依赖的package包/类
public void test() throws Exception {
    System.setProperty(Provider.class.getName(), MockProvider.class.getName());
    Provider provider = Provider.provider();
    assertNotNull("provider is null", provider);
    assertFalse("provider should not be an instance of ProviderWrapper", provider instanceof JaxWsProviderWrapper);

    JaxWsProviderWrapper.beforeCreate(null);
    try {
        provider = Provider.provider();
        assertNotNull("provider is null", provider);
        assertTrue("provider should be an instance of ProviderWrapper", provider instanceof JaxWsProviderWrapper);
        final JaxWsProviderWrapper providerWrapper = (JaxWsProviderWrapper) provider;

        // check delegate
        final Provider delegate = providerWrapper.getDelegate();
        assertNotNull("providerWrapper delegate is null", delegate);
        assertFalse("providerWrapper delegate should not be an instance of ProviderWrapper", delegate instanceof JaxWsProviderWrapper);
    } finally {
        JaxWsProviderWrapper.afterCreate();
    }
}
 
开发者ID:apache,项目名称:tomee,代码行数:22,代码来源:JaxWsProviderWrapperTest.java

示例5: test

import javax.xml.ws.spi.Provider; //导入依赖的package包/类
public void test() throws Exception {
    System.setProperty(Provider.class.getName(), MockProvider.class.getName());
    Provider provider = Provider.provider();
    assertNotNull("provider is null", provider);
    assertFalse("provider should not be an instance of ProviderWrapper", provider instanceof ProviderWrapper);

    ProviderWrapper.beforeCreate(null, null, null);
    try {
        provider = Provider.provider();
        assertNotNull("provider is null", provider);
        assertTrue("provider should be an instance of ProviderWrapper", provider instanceof ProviderWrapper);
        final ProviderWrapper providerWrapper = (ProviderWrapper) provider;

        // check delegate
        final Provider delegate = providerWrapper.getDelegate();
        assertNotNull("providerWrapper delegate is null", delegate);
        assertFalse("providerWrapper delegate should not be an instance of ProviderWrapper", delegate instanceof ProviderWrapper);
    } finally {
        ProviderWrapper.afterCreate();
    }
}
 
开发者ID:apache,项目名称:tomee,代码行数:22,代码来源:ProviderWrapperTest.java

示例6: verifyJaxWsSpiProvider

import javax.xml.ws.spi.Provider; //导入依赖的package包/类
public static void verifyJaxWsSpiProvider(String expectedProviderClass)
{
   Provider provider = Provider.provider();
   String clazz = provider.getClass().getName();
   if (!clazz.equals(expectedProviderClass)) {
      throw new RuntimeException("Expected " + expectedProviderClass + " but got " + clazz);
   }
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:9,代码来源:Helper.java

示例7: main

import javax.xml.ws.spi.Provider; //导入依赖的package包/类
public static void main(String[] args) throws Exception
{
   String serverHost = args[0];
   String serverPort = args[1];
   String resStr = testPortAccess(serverHost, Integer.valueOf(serverPort));
   System.out.println(Provider.provider().getClass().getName() + ", " + resStr);
   
   //wait a bit before returning as the log processing can be aysnch, the test client
   //relies on the log contents and the log streams are closed by the system when the
   //process terminates
   Thread.sleep(1000);
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:13,代码来源:TestClient.java

示例8: testGetProvider

import javax.xml.ws.spi.Provider; //导入依赖的package包/类
@Test
public void testGetProvider()
{
   //just check we get the jbossws-cxf provider impl when the default maven tccl is set
   Provider providerImpl = Provider.provider();
   assertTrue(providerImpl instanceof ProviderImpl);
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:8,代码来源:ProviderImplTest.java

示例9: testGetProviderWithCustomClassLoaderIsBackwardCompatibility

import javax.xml.ws.spi.Provider; //导入依赖的package包/类
@Test
public void testGetProviderWithCustomClassLoaderIsBackwardCompatibility()
{
   ClassLoader tccl = Thread.currentThread().getContextClassLoader();
   try
   {
      //overwrite the TCCL so that no Provider configuration is specified,
      //hence the JAXWS RI default is tried (given this test is run
      //out of container); this verifies the additions due to JBEE-75 and
      //JBWS-3223 are backward compatible.
      TestClassLoader cl = new TestClassLoader();
      Thread.currentThread().setContextClassLoader(cl);
      try
      {
         Provider.provider();
         fail("Exception due to class not found expected!");
      }
      catch (Exception e)
      {
         //check the default ProviderImpl was being looked up given no configuration was provided
         List<String> list = cl.getLoadClassRequests();
         assertTrue(list.contains("com.sun.xml.internal.ws.spi.ProviderImpl"));
         assertEquals(1, list.size());
      }
   }
   finally
   {
      Thread.currentThread().setContextClassLoader(tccl);
   }
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:31,代码来源:ProviderImplTest.java

示例10: start

import javax.xml.ws.spi.Provider; //导入依赖的package包/类
@Override
public void start(final Deployment dep)
{
   if (BusFactory.getDefaultBus(false) == null)
   {
      //Make sure the default bus is created and set for client side usage
      //(i.e. no server side integration contribution in it)
      JBossWSBusFactory.getDefaultBus(Provider.provider().getClass().getClassLoader());
   }
   startDeploymentBus(dep);
}
 
开发者ID:jbossws,项目名称:jbossws-cxf,代码行数:12,代码来源:BusDeploymentAspect.java

示例11: testProvider

import javax.xml.ws.spi.Provider; //导入依赖的package包/类
@Test
public void testProvider() {
	Provider provider = Provider.provider();
	LOG.debug("provider class: " + provider.getClass().getName());
	assertEquals("org.apache.cxf.jaxws22.spi.ProviderImpl", provider
			.getClass().getName());
}
 
开发者ID:e-Contract,项目名称:mycarenet,代码行数:8,代码来源:CXFTest.java

示例12: createProviderInstance

import javax.xml.ws.spi.Provider; //导入依赖的package包/类
private static Provider createProviderInstance(final String providerClass, final ClassLoader classLoader) {
    if (providerClass != null && providerClass.length() > 0 && !providerClass.equals(JaxWsProviderWrapper.class.getName())) {
        try {
            final Class<? extends Provider> clazz = classLoader.loadClass(providerClass).asSubclass(Provider.class);
            return clazz.newInstance();
        } catch (Throwable e) {
            logger.log(Level.WARNING, "Unable to construct provider implementation " + providerClass, e);
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:tomee,代码行数:12,代码来源:JaxWsProviderWrapper.java

示例13: createProviderInstance

import javax.xml.ws.spi.Provider; //导入依赖的package包/类
private static Provider createProviderInstance(final String providerClass, final ClassLoader classLoader) {
    if (providerClass != null && providerClass.length() > 0 && !providerClass.equals(ProviderWrapper.class.getName())) {
        try {
            final Class<? extends Provider> clazz = classLoader.loadClass(providerClass).asSubclass(Provider.class);
            return clazz.newInstance();
        } catch (final Throwable e) {
            logger.warning("Unable to construct provider implementation " + providerClass, e);
        }
    }
    return null;
}
 
开发者ID:apache,项目名称:tomee,代码行数:12,代码来源:ProviderWrapper.java

示例14: Service

import javax.xml.ws.spi.Provider; //导入依赖的package包/类
protected Service(java.net.URL wsdlDocumentLocation, QName serviceName) {
    delegate = Provider.provider().createServiceDelegate(wsdlDocumentLocation,
            serviceName,
            this.getClass());
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:6,代码来源:Service.java

示例15: createServiceWithRetry

import javax.xml.ws.spi.Provider; //导入依赖的package包/类
private Service createServiceWithRetry(Class serviceInterface, ApiEnvironment env) throws Exception {

        final QName qName = getServiceQname(serviceInterface);
        final boolean isCxf = Provider.provider().getClass().getName().contains("org.apache.cxf");
        final URL url = (isCxf ? null : new URL(getServiceUrl(serviceInterface, env) + "?wsdl")); 

        int retryLeft = WS_CREATE_RETRY_TIMES;
        int timeout = 0;
        ExecutorService pool = Executors.newSingleThreadExecutor();

        try {
            while (retryLeft > 0) {
                retryLeft--;
                timeout = prolongTimeout(timeout);
                Future<Service> future = pool.submit(new Callable<Service>() {
                    public Service call() throws Exception {
                        if (isCxf) {
                            // CXF doesn't require WSDL url to be passed
                            return Service.create(qName);
                        } else {
                            return Service.create(url, qName);
                        }
                    }
                });

                try {
                    return future.get(timeout, TimeUnit.SECONDS);
                } catch (TimeoutException e) {
                    System.out.println(String.format("Timeout. Failed to create web service %s in %d seconds for %s. retry left %d",
                            serviceInterface.getName(), timeout, env.value(), retryLeft));
                    future.cancel(true);

                    try {
                        if (retryLeft > 0) {
                            Thread.sleep(WS_CREATE_RETRY_INTERVAL_IN_SECOND * 1000);
                        }
                    } catch (InterruptedException e1) {
                        e1.printStackTrace();
                    }
                }
            }
        } finally {
            pool.shutdown();
        }
        throw new Exception(String.format("Failed to create Service %s for %s!", serviceInterface.getName(), env.value()));
    }
 
开发者ID:BingAds,项目名称:BingAds-Java-SDK,代码行数:47,代码来源:ServiceFactoryImpl.java


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