本文整理汇总了Java中org.jboss.resteasy.client.ProxyFactory.create方法的典型用法代码示例。如果您正苦于以下问题:Java ProxyFactory.create方法的具体用法?Java ProxyFactory.create怎么用?Java ProxyFactory.create使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jboss.resteasy.client.ProxyFactory
的用法示例。
在下文中一共展示了ProxyFactory.create方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getClient
import org.jboss.resteasy.client.ProxyFactory; //导入方法依赖的package包/类
public static SlackApi getClient() {
PoolingHttpClientConnectionManager cm = new PoolingHttpClientConnectionManager();
HttpClient httpClient = HttpClientBuilder.create().setConnectionManager(cm).build();
//
ClientExecutor executor = new ApacheHttpClient4Executor(httpClient);
// new ApacheHttpClient4Engine(httpClient);
//
SlackApi slackApi = ProxyFactory.create(SlackApi.class, "https://hooks.slack.com", executor);
// ResteasyClient client = new ResteasyClientBuilder().httpEngine(new
// ApacheHttpClient4Engine(httpClient)).build();
// Client client = ResteasyClientBuilder.newClient();
// ResteasyWebTarget target =
// (ResteasyWebTarget)client.target("https://hooks.slack.com");
// ResteasyWebTarget rtarget = (ResteasyWebTarget) target;
// SlackApi slackApi = target.proxy(SlackApi.class);
return slackApi;
}
示例2: NubankImportador
import org.jboss.resteasy.client.ProxyFactory; //导入方法依赖的package包/类
public NubankImportador(){
ClientConnectionManager cm = new ThreadSafeClientConnManager();
DefaultHttpClient httpClient = new DefaultHttpClient(cm);
ClientExecutor executor = new ApacheHttpClient4Executor(httpClient);
authApi = ProxyFactory.create(NubankAPI.class, "https://prod-auth.nubank.com.br", executor);
costumersApi = ProxyFactory.create(NubankAPI.class, "https://prod-customers.nubank.com.br", executor);
accountsApi = ProxyFactory.create(NubankAPI.class, "https://prod-accounts.nubank.com.br", executor);
ClientResponse<RegistrationResp> resp = authApi.register(RegistrationReq.asNubank());
if(resp.getStatus() != RegistrationResp.SUCCESS_CODE){
throw new RuntimeException("Erro registrando api. Status code = "+resp.getStatus());
// System.out.println(resp.getEntity().getClient_id());
// System.out.println(resp.getEntity().getClient_secret());
}
this.regResp = resp.getEntity();
// api.token(TokenReq.create(resp.getEntity()));
}
示例3: proxyTest
import org.jboss.resteasy.client.ProxyFactory; //导入方法依赖的package包/类
/**
* Test that REST clients are correctly working
* @return
*/
@GET
@Path("/test")
public String proxyTest() {
StringBuilder retVal = new StringBuilder();
DemoInterface proxy = ProxyFactory.create(DemoInterface.class, "http://localhost:8080/rest"); //Interface-based proxy
String fancyOut = objectToJsonString(proxy.getStaticObject());
if (fancyOut.equals(objectToJsonString(fancy))) {
retVal.append("Interface-based client matches on LZF decompress. \n");
} else {
retVal.append("ERROR! Interface-based DOES NOT match on LZF decompress. \n");
}
fancyOut = objectToJsonString(proxy.getStaticObjectGzip());
if (fancyOut.equals(objectToJsonString(fancy))) {
retVal.append("Interface-based client matches on GZIP decompress. \n");
} else {
retVal.append("ERROR! Interface-based DOES NOT match on GZIP decompress. \n");
}
return retVal.toString();
}
示例4: getUptime
import org.jboss.resteasy.client.ProxyFactory; //导入方法依赖的package包/类
public synchronized MonitorTarget getUptime( String macAddress )
{
MonitorTarget monitorTarget = null;
logger.trace( "getUptime macAddress " + macAddress );
logger.debug( "restPath " + restPath );
if ( restPath != null && macAddress != null && !macAddress.isEmpty() )
{
try
{
RebootDetection rebootDetectionService = ProxyFactory.create( RebootDetection.class,
restPath.replace( MAC_ARG, macAddress ) );
if ( rebootDetectionService != null )
{
monitorTarget = rebootDetectionService.current();
}
}
catch ( Exception e )
{ // catch any exceptions due to any reason like snmp service not
// found etc
logger.error( "getUptime Error occurred restPath " + restPath + " " + e.getMessage() );
}
}
logger.info( "getUptime macAddress " + macAddress + " uptime " + monitorTarget );
return monitorTarget;
}
示例5: get
import org.jboss.resteasy.client.ProxyFactory; //导入方法依赖的package包/类
@Override
public KeyManagerProxy get() {
KeyManagerProxy keyManagerProxy = null;
try{
if(hostname == null || hostname.isEmpty()){
hostname = System.getProperty( KeyManagerConstants.KEY_MANAGER_PROXY_IP_NAME );
}
logger.trace( "KeyManagerProxyProviderRest get() "+hostname );
if(hostname != null){
String restUrl="http://"+hostname+"/keymanager-service"+KeyManagerConstants.APPLICATION_PATH+KeyManagerConstants.KEYMANAGER_PATH;
logger.info("Rest interface to keymanager service constructed "+restUrl);
keyManagerProxy = ProxyFactory.create(KeyManagerProxy.class,restUrl);
}else{
logger.warn( "System property "+KeyManagerConstants.KEY_MANAGER_PROXY_IP_NAME+" may not be set properly" );
}
logger.trace( "KeyManagerProxyProviderRest keyManagerProxy "+keyManagerProxy );
}catch(Exception e){
logger.warn( e.getMessage() );
}
return keyManagerProxy;
}
示例6: testGetRecommendationForAnonymousItem
import org.jboss.resteasy.client.ProxyFactory; //导入方法依赖的package包/类
@Test
public final void testGetRecommendationForAnonymousItem()
{
LOG.info("testing GET on recommendations");
Recommender proxy = ProxyFactory.create(Recommender.class, uri, new ApacheHttpClient4Executor());
try
{
// Recommendations result =
proxy.getRecommendationFor(ConstantsTest.CP, ConstantsTest.COLLECTION, ConstantsTest.RECOMMENDER, null,
ConstantsTest.ITEM, ConstantsTest.SOURCE, ConstantsTest.SIZE, null);
// result should be empty - as non of the resource actually exist:
}
catch (org.jboss.resteasy.client.ClientResponseFailure e)
{
assertEquals(404, e.getResponse().getStatus());
return;
}
fail("a 404 exception should have been thrown");
}
示例7: testInvalidGetItem
import org.jboss.resteasy.client.ProxyFactory; //导入方法依赖的package包/类
/**
* Test method for
* {@link nl.gridline.zieook.data.rest.CollectionDataImpl#getItem(java.lang.String, java.lang.String, java.lang.String)}
* .
*/
@Test
public final void testInvalidGetItem()
{
CollectionData proxy = ProxyFactory.create(CollectionData.class, uri, new ApacheHttpClient4Executor());
try
{
proxy.getItemRaw(ConstantsTest.CP, ConstantsTest.COLLECTION, null);
}
catch (org.jboss.resteasy.client.ClientResponseFailure e)
{
assertEquals(400, e.getResponse().getStatus());
return;
}
fail("A 400 exception should have been thrown.");
}
示例8: testGetRecommendationForUser
import org.jboss.resteasy.client.ProxyFactory; //导入方法依赖的package包/类
@Test
public final void testGetRecommendationForUser()
{
LOG.info("testing GET on recommendations");
Recommender proxy = ProxyFactory.create(Recommender.class, uri, new ApacheHttpClient4Executor());
try
{
// Recommendations result =
proxy.getRecommendationFor(ConstantsTest.CP, ConstantsTest.COLLECTION, ConstantsTest.RECOMMENDER,
ConstantsTest.USER, null, ConstantsTest.SOURCE, ConstantsTest.SIZE, null);
// result should be empty - as non of the resource actually exist:
}
catch (org.jboss.resteasy.client.ClientResponseFailure e)
{
assertEquals(404, e.getResponse().getStatus());
return;
}
fail("a 404 exception should have been thrown");
}
示例9: createInternalRestEasyClient
import org.jboss.resteasy.client.ProxyFactory; //导入方法依赖的package包/类
/**
* Creates a RestEasy client for a given service.
*/
private <T> T createInternalRestEasyClient(final Class<T> serviceInterface) throws URISyntaxException {
final URL location = new ServiceLocator().lookupService(serviceInterface);
CONTEXT.setTarget(
configurator.createContext(
new HttpHost(
location.getHost(),
location.getPort(),
location.getProtocol())));
return ProxyFactory.create(serviceInterface, location.toURI(), EXECUTOR, providerFactory);
}
示例10: init
import org.jboss.resteasy.client.ProxyFactory; //导入方法依赖的package包/类
public void init() {
if (authProvider == null) {
authProvider = new DeskOAuthProvider(accessKey, accessSecret, token, tokenSecret);
}
ClientConnectionManager cm = new ThreadSafeClientConnManager();
DefaultHttpClient httpClient = new DefaultHttpClient(cm);
ClientExecutor executor = new ApacheHttpClient4Executor(httpClient);
userApi = ProxyFactory.create(UserApi.class, endpoint, executor);
customerApi = ProxyFactory.create(CustomerApi.class, endpoint, executor);
caseApi = ProxyFactory.create(CaseApi.class, endpoint, executor);
}
示例11: setUp
import org.jboss.resteasy.client.ProxyFactory; //导入方法依赖的package包/类
@Before
public void setUp() throws Exception {
client = ProxyFactory.create(SchedulerRestInterface.class, "http://localhost:" + port + "/");
PortalConfiguration.SCHEDULER_LOGINFORWARDINGSERVICE_PROVIDER.updateProperty(SynchronousLocalLogForwardingProvider.class.getName());
scheduler = mock(SchedulerProxyUserInterface.class);
sessionId = SharedSessionStoreTestUtils.createValidSession(scheduler);
}
示例12: callGetStatHistory
import org.jboss.resteasy.client.ProxyFactory; //导入方法依赖的package包/类
private JSONObject callGetStatHistory() throws Exception {
RMProxyUserInterface rmMock = mock(RMProxyUserInterface.class);
String sessionId = SharedSessionStoreTestUtils.createValidSession(rmMock);
AttributeList value = new AttributeList(Collections.singletonList(new Attribute("test",
createRrdDb().getBytes())));
when(rmMock.getMBeanAttributes(Matchers.<ObjectName> any(), Matchers.<String[]> any())).thenReturn(value);
RMRestInterface client = ProxyFactory.create(RMRestInterface.class, "http://localhost:" + port + "/");
String statHistory = client.getStatHistory(sessionId, "hhhhh");
return (JSONObject) new JSONParser().parse(statHistory);
}
示例13: testShowResults
import org.jboss.resteasy.client.ProxyFactory; //导入方法依赖的package包/类
@GET
@Path("/test/show")
public String testShowResults() {
DemoInterface proxy = ProxyFactory.create(DemoInterface.class, "http://localhost:8080/rest"); //Interface-based proxy
String fancyOut = objectToJsonString(proxy.getStaticObject());
return fancyOut;
}
示例14: listAllReboots
import org.jboss.resteasy.client.ProxyFactory; //导入方法依赖的package包/类
public synchronized List< RebootInfo > listAllReboots( String macAddress, Date startDate, Date endDate )
{
List< RebootInfo > rebootInfoList = null;
logger.trace( "listAllReboots macAddress " + macAddress );
logger.debug( "restPath " + restPath );
if ( restPath != null && macAddress != null && !macAddress.isEmpty() && startDate != null && endDate != null )
{
try
{
RebootDetection rebootDetectionService = ProxyFactory.create( RebootDetection.class,
restPath.replace( MAC_ARG, macAddress ) );
if ( rebootDetectionService != null )
{
List< RebootInfo > reboots = rebootDetectionService.listAll();
if ( reboots != null )
{
rebootInfoList = new ArrayList< RebootInfo >();
for ( RebootInfo rebootInfo : reboots )
{
if ( rebootInfo.getExecutionDate().after( endDate )
&& rebootInfo.getExecutionDate().before( startDate ) )
{
rebootInfoList.add( rebootInfo );
}
}
}
}
}
catch ( Exception e )
{ // catch any exceptions due to any reason like snmp service not
// found etc
logger.error( "listReboots Error occurred restPath " + restPath + " " + e.getMessage() );
}
}
return rebootInfoList;
}
示例15: getRebootCount
import org.jboss.resteasy.client.ProxyFactory; //导入方法依赖的package包/类
public int getRebootCount( String macAddress )
{
int rebootCount = -1;
logger.trace( "getRebootCount ecmMacAddress " + macAddress );
logger.debug( "restPath " + restPath );
if ( restPath != null && macAddress != null && !macAddress.isEmpty() )
{
try
{
RebootDetection rebootDetectionService = ProxyFactory.create( RebootDetection.class,
restPath.replace( MAC_ARG, macAddress ) );
if ( rebootDetectionService != null )
{
rebootCount = rebootDetectionService.count();
}
}
catch ( Exception e )
{ // catch any exceptions due to any reason like snmp service not
// found etc
logger.error( "getRebootCount Error occurred restPath " + restPath + " " + e.getMessage() );
}
}
logger.info( "listReboots ecmMacAddress " + macAddress + " rebootCount " + rebootCount );
return rebootCount;
}