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


Java ApacheClient类代码示例

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


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

示例1: configureService

import retrofit.client.ApacheClient; //导入依赖的package包/类
private PublisherSvcApi configureService() {

        SessionManager session = new SessionManager(getActivity());
        String username = session.getUserDetails().get(SessionManager.KEY_USERNAME);
        String password = session.getUserDetails().get(SessionManager.KEY_PASSWORD);

        return new SecuredRestBuilder()
                .setLoginEndpoint(UserSvcApi.SERVICE_URL + UserSvcApi.TOKEN_PATH)
                .setUsername(username)
                .setPassword(password)
                .setClientId(UserSvcApi.CLIENT_ID)
                .setClient(new ApacheClient(UnsafeHttpsClient.createUnsafeClient()))
                .setEndpoint(UserSvcApi.SERVICE_URL)
                .setLogLevel(RestAdapter.LogLevel.FULL)
                .build()
                .create(PublisherSvcApi.class);
    }
 
开发者ID:kflauri2312lffds,项目名称:Android_watch_magpie,代码行数:18,代码来源:PublisherTestFragment.java

示例2: createRetrofitClient

import retrofit.client.ApacheClient; //导入依赖的package包/类
private MyClientGetInterface createRetrofitClient(String url) {
	// prepare apache client config with timeout
	RequestConfig configWithTimeout = RequestConfig.custom()
			.setSocketTimeout(MY_DEAR_TIMEOUT)
			.build();
	
	// build apache client with timeout 
	HttpClient httpClient = HttpClientBuilder.create().
			setDefaultRequestConfig(configWithTimeout)
			.build();
	
	// feed retrofit with the newly created rest client
	RestAdapter restAdapter = new RestAdapter.Builder()
			.setClient(new ApacheClient(httpClient ))
			.setEndpoint(url)
			.build();

	return restAdapter.create(MyClientGetInterface.class);
}
 
开发者ID:notsojug,项目名称:jug-material,代码行数:20,代码来源:RetrofitApacheClientIT.java

示例3: testRedirectToLoginWithoutAuth

import retrofit.client.ApacheClient; //导入依赖的package包/类
/**
 * This test creates a Video and attempts to add it to the video service
 * without logging in. The test checks to make sure that the request is
 * denied and the client redirected to the login page.
 * 
 * @throws Exception
 */
@Test
public void testRedirectToLoginWithoutAuth() throws Exception {
	ErrorRecorder error = new ErrorRecorder();

	VideoSvcApi videoService = new RestAdapter.Builder()
			.setClient(
					new ApacheClient(UnsafeHttpsClient.createUnsafeClient()))
			.setEndpoint(TEST_URL).setLogLevel(LogLevel.FULL)
			.setErrorHandler(error).build().create(VideoSvcApi.class);
	try {
		// This should fail because we haven't logged in!
		videoService.addVideo(video);

		fail("Yikes, the security setup is horribly broken and didn't require the user to login!!");

	} catch (Exception e) {
		// Ok, our security may have worked, ensure that
		// we got redirected to the login page
		assertEquals(HttpStatus.SC_MOVED_TEMPORARILY, error.getError()
				.getResponse().getStatus());
	}
}
 
开发者ID:juleswhite,项目名称:mobilecloud-15,代码行数:30,代码来源:VideoSvcClientApiTest.java

示例4: notifySubscription

import retrofit.client.ApacheClient; //导入依赖的package包/类
private void notifySubscription(
        final Context context, final long pubId, final long subId, final String subUsername, final boolean result) {

    SessionManager session = new SessionManager(context);
    String username = session.getUserDetails().get(SessionManager.KEY_USERNAME);
    String password = session.getUserDetails().get(SessionManager.KEY_PASSWORD);

    final SubscriptionResult subscriptionResult = new SubscriptionResult(subId, result);

    final PublisherSvcApi publisherSvc = new SecuredRestBuilder()
            .setLoginEndpoint(UserSvcApi.SERVICE_URL + UserSvcApi.TOKEN_PATH)
            .setUsername(username)
            .setPassword(password)
            .setClientId(UserSvcApi.CLIENT_ID)
            .setClient(new ApacheClient(UnsafeHttpsClient.createUnsafeClient()))
            .setEndpoint(UserSvcApi.SERVICE_URL)
            .setLogLevel(RestAdapter.LogLevel.FULL)
            .build()
            .create(PublisherSvcApi.class);

    Thread t = new Thread(new Runnable() {
        @Override
        public void run() {
            boolean answer = publisherSvc.confirmSubscription(pubId, subscriptionResult);
            if (answer) {
                if (result) {
                    handler.post(new ShowToastMessage(subUsername + " is now subscribed to your alerts"));
                    Intent intent = new Intent(UIUpdaterReceiver.ACTION_UPDATE_UI);
                    LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
                } else {
                    handler.post(new ShowToastMessage(subUsername + " will not receive your alerts"));
                }
            } else {
                handler.post(new ShowToastMessage("Error while processing the confirmation"));
            }
        }

    });
    t.start();
}
 
开发者ID:kflauri2312lffds,项目名称:Android_watch_magpie,代码行数:41,代码来源:NotificationProcessorReceiver.java

示例5: downloadAlerts

import retrofit.client.ApacheClient; //导入依赖的package包/类
private void downloadAlerts(final long pubId) {

        SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(this);
        final long subId = preferences.getLong(MobileClient.SUBSCRIBER_ID, 0);

        SessionManager session = new SessionManager(this);
        final String username = session.getUserDetails().get(SessionManager.KEY_USERNAME);
        String password = session.getUserDetails().get(SessionManager.KEY_PASSWORD);

        final SubscriberSvcApi subscriberSvc = new SecuredRestBuilder()
                .setLoginEndpoint(UserSvcApi.SERVICE_URL + UserSvcApi.TOKEN_PATH)
                .setUsername(username)
                .setPassword(password)
                .setClientId(UserSvcApi.CLIENT_ID)
                .setClient(new ApacheClient(UnsafeHttpsClient.createUnsafeClient()))
                .setEndpoint(UserSvcApi.SERVICE_URL)
                .setLogLevel(RestAdapter.LogLevel.FULL)
                .build()
                .create(SubscriberSvcApi.class);

        Thread t = new Thread(new Runnable() {
            @Override
            public void run() {
                publisherAlerts = subscriberSvc.getAlertsByUser(subId, pubId);
                AlertsActivity.this.runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        loadAlerts();
                        AlertsActivity.this.setListAdapter(alertsAdapter);
                        loadEmptyContent();
                        progress.dismiss();
                    }
                });
            }
        });
        t.start();
    }
 
开发者ID:kflauri2312lffds,项目名称:Android_watch_magpie,代码行数:38,代码来源:AlertsActivity.java

示例6: downloadContacts

import retrofit.client.ApacheClient; //导入依赖的package包/类
public void downloadContacts() {

        contactsAdapter.flushList();
        final long subId = user.getId();

        SessionManager session = new SessionManager(getActivity());
        final String username = session.getUserDetails().get(SessionManager.KEY_USERNAME);
        String password = session.getUserDetails().get(SessionManager.KEY_PASSWORD);

        final UserSvcApi userSvc = new SecuredRestBuilder()
                .setLoginEndpoint(UserSvcApi.SERVICE_URL + UserSvcApi.TOKEN_PATH)
                .setUsername(username)
                .setPassword(password)
                .setClientId(UserSvcApi.CLIENT_ID)
                .setClient(new ApacheClient(UnsafeHttpsClient.createUnsafeClient()))
                .setEndpoint(UserSvcApi.SERVICE_URL)
                .setLogLevel(RestAdapter.LogLevel.FULL)
                .build()
                .create(UserSvcApi.class);


        Thread t = new Thread(new Runnable() {
            @Override
            public void run() {
                ContactsFragment.this.contactsAccepted = userSvc.getContactsAccepted(subId);
                ContactsFragment.this.contactsPending = userSvc.getContactsPending(subId);
                ContactsFragment.this.getActivity().runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        loadContacts();
                        showHeaderView();
                        ContactsFragment.this.setListAdapter(contactsAdapter);
                    }
                });
            }
        });
        t.start();
    }
 
开发者ID:kflauri2312lffds,项目名称:Android_watch_magpie,代码行数:39,代码来源:ContactsFragment.java

示例7: revokeSubscription

import retrofit.client.ApacheClient; //导入依赖的package包/类
public void revokeSubscription(final MobileClient subscriber) {

        SessionManager session = new SessionManager(getActivity());
        final String username = session.getUserDetails().get(SessionManager.KEY_USERNAME);
        String password = session.getUserDetails().get(SessionManager.KEY_PASSWORD);

        final PublisherSvcApi publisherSvc = new SecuredRestBuilder()
                .setLoginEndpoint(UserSvcApi.SERVICE_URL + UserSvcApi.TOKEN_PATH)
                .setUsername(username)
                .setPassword(password)
                .setClientId(UserSvcApi.CLIENT_ID)
                .setClient(new ApacheClient(UnsafeHttpsClient.createUnsafeClient()))
                .setEndpoint(UserSvcApi.SERVICE_URL)
                .setLogLevel(RestAdapter.LogLevel.FULL)
                .build()
                .create(PublisherSvcApi.class);

        Thread t = new Thread(new Runnable() {
            @Override
            public void run() {
                final boolean result = publisherSvc.revokeSubscription(user.getId(), subscriber.getId());
                ContactsFragment.this.getActivity().runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        if (result) {
                            Toast.makeText(ContactsFragment.this.getActivity(),
                                    subscriber.getFullName() + " will no longer receive alerts from you",
                                    Toast.LENGTH_LONG)
                                    .show();
                            contactsAdapter.removeItem(subscriber);
                        }
                    }
                });
            }
        });
        t.start();
    }
 
开发者ID:kflauri2312lffds,项目名称:Android_watch_magpie,代码行数:38,代码来源:ContactsFragment.java

示例8: createRetrofitClient

import retrofit.client.ApacheClient; //导入依赖的package包/类
private <T> T createRetrofitClient(Class<T> iface){
	RestAdapter restAdapter = new RestAdapter.Builder()
			// java's url connection does not support custom verbs....
			// using apache client instead
			.setClient(new ApacheClient())
			.setEndpoint(serverUrl)
			.build();
	return restAdapter.create(iface);
}
 
开发者ID:notsojug,项目名称:jug-material,代码行数:10,代码来源:RetrofitCustomVerbIT.java

示例9: createRetrofitClient

import retrofit.client.ApacheClient; //导入依赖的package包/类
private <T> T createRetrofitClient(Class<T> iface){
	RestAdapter restAdapter = new RestAdapter.Builder()
			// java's url connection does not support non standard verbs. 
			// using apache client instead...
			.setClient(new ApacheClient())
			.setEndpoint(serverUrl)
			.build();
	return restAdapter.create(iface);
}
 
开发者ID:notsojug,项目名称:jug-material,代码行数:10,代码来源:RetrofitNonStandardVerbIT.java

示例10: testDenyVideoAddWithoutLogin

import retrofit.client.ApacheClient; //导入依赖的package包/类
/**
 * This test creates a Video and attempts to add it to the video service
 * without logging in. The test checks to make sure that the request is
 * denied and the client redirected to the login page.
 * 
 * @throws Exception
 */
@Test
public void testDenyVideoAddWithoutLogin() throws Exception {
	ErrorRecorder error = new ErrorRecorder();

	VideoSvcApi videoService = new RestAdapter.Builder()
			.setClient(
					new ApacheClient(UnsafeHttpsClient.createUnsafeClient()))
			.setEndpoint(TEST_URL).setLogLevel(LogLevel.FULL)
			.setErrorHandler(error).build().create(VideoSvcApi.class);
	try {
		// This should fail because we haven't logged in!
		videoService.addVideo(video);

		fail("Yikes, the security setup is horribly broken and didn't require the user to login!!");

	} catch (Exception e) {
		// Ok, our security may have worked, ensure that
		// we got redirected to the login page
		assertEquals(HttpStatus.SC_MOVED_TEMPORARILY, error.getError()
				.getResponse().getStatus());
	}

	// Now, let's login and ensure that the Video wasn't added
	videoService.login("coursera", "changeit");
	
	// We should NOT get back the video that we added above!
	Collection<Video> videos = videoService.getVideoList();
	assertFalse(videos.contains(video));
}
 
开发者ID:juleswhite,项目名称:mobilecloud-15,代码行数:37,代码来源:VideoSvcClientApiTest.java

示例11: init

import retrofit.client.ApacheClient; //导入依赖的package包/类
public static synchronized VideoSvcApi init(String server, String user,
		String pass) {

	videoSvc_ = new SecuredRestBuilder()
			.setLoginEndpoint(server + VideoSvcApi.TOKEN_PATH)
			.setUsername(user)
			.setPassword(pass)
			.setClientId(CLIENT_ID)
			.setClient(
					new ApacheClient(new EasyHttpClient()))
			.setEndpoint(server).setLogLevel(LogLevel.FULL).build()
			.create(VideoSvcApi.class);

	return videoSvc_;
}
 
开发者ID:juleswhite,项目名称:mobilecloud-15,代码行数:16,代码来源:VideoSvc.java

示例12: build

import retrofit.client.ApacheClient; //导入依赖的package包/类
public Client.Provider build() {

        return new Client.Provider() {

            public Client get() {
                return new ApacheClient(httpClientBuilder.build());
            }
        };
    }
 
开发者ID:ikust,项目名称:hello-pinnedcerts,代码行数:10,代码来源:RetrofitApacheClientBuilder.java

示例13: getEndPoint

import retrofit.client.ApacheClient; //导入依赖的package包/类
public FDroidEndPoint getEndPoint() {
    return new RestAdapter.Builder()
            .setConverter(new SimpleXMLConverter())
            .setErrorHandler(new FDroidErrorHandler())
            .setEndpoint(appMarketHost)
            .setClient(new ApacheClient())
            .setLogLevel(RestAdapter.LogLevel.FULL)
            .build().create(FDroidEndPoint.class);
}
 
开发者ID:clintonhealthaccess,项目名称:chailmis-android,代码行数:10,代码来源:FDroidEndPointFactory.java

示例14: makeRestAdapter

import retrofit.client.ApacheClient; //导入依赖的package包/类
private RestAdapter makeRestAdapter(User user) {
    AuthInterceptor requestInterceptor = new AuthInterceptor(user);
    return new RestAdapter.Builder()
            .setRequestInterceptor(requestInterceptor)
            .setErrorHandler(new Dhis2ErrorHandler())
            .setEndpoint(dhis2BaseUrl)
            .setClient(new ApacheClient())
            .setLogLevel(RestAdapter.LogLevel.FULL)
            .build();
}
 
开发者ID:clintonhealthaccess,项目名称:chailmis-android,代码行数:11,代码来源:Dhis2EndPointFactory.java

示例15: publishAlert

import retrofit.client.ApacheClient; //导入依赖的package包/类
private void publishAlert(final GlucoseAlert glucose) {

        SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getContext());
        final long pubId = preferences.getLong(MobileClient.PUBLISHER_ID, 0);

        SessionManager session = new SessionManager(getContext());
        String username = session.getUserDetails().get(SessionManager.KEY_USERNAME);
        String password = session.getUserDetails().get(SessionManager.KEY_PASSWORD);

        final PublisherSvcApi publisherSvc = new SecuredRestBuilder()
                .setLoginEndpoint(UserSvcApi.SERVICE_URL + UserSvcApi.TOKEN_PATH)
                .setUsername(username)
                .setPassword(password)
                .setClientId(UserSvcApi.CLIENT_ID)
                .setClient(new ApacheClient(UnsafeHttpsClient.createUnsafeClient()))
                .setEndpoint(UserSvcApi.SERVICE_URL)
                .setLogLevel(RestAdapter.LogLevel.FULL)
                .build()
                .create(PublisherSvcApi.class);

        Thread t = new Thread(new Runnable() {
            @Override
            public void run() {
                glucose.setPublisherId(pubId);
                final boolean result = publisherSvc.notifyAlert(pubId, glucose);
                ((PublisherActivity) getContext()).runOnUiThread(new Runnable() {
                    @Override
                    public void run() {
                        if (result) {
                            Toast.makeText(getContext(),
                                    "The alert was successfully notified to your contacts",
                                    Toast.LENGTH_LONG)
                                    .show();
                        } else {
                            Toast.makeText(getContext(),
                                    "You don't have contacts to notifiy the alert",
                                    Toast.LENGTH_LONG)
                                    .show();
                        }
                    }
                });
            }
        });
        t.start();
    }
 
开发者ID:kflauri2312lffds,项目名称:Android_watch_magpie,代码行数:46,代码来源:GlucoseBehavior.java


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