public class PubsubRequestInitializer
extends com.google.api.client.googleapis.services.json.CommonGoogleJsonClientRequestInitializer
The simplest usage is to use it to set the key parameter:
public static final GoogleClientRequestInitializer KEY_INITIALIZER = new PubsubRequestInitializer(KEY);
There is also a constructor to set both the key and userIp parameters:
public static final GoogleClientRequestInitializer INITIALIZER = new PubsubRequestInitializer(KEY, USER_IP);
If you want to implement custom logic, extend it like this:
public static class MyRequestInitializer extends PubsubRequestInitializer { @Override public void initializePubsubRequest(PubsubRequest <? > request) throws IOException { // custom logic } }
Finally, to set the key and userIp parameters and insert custom logic, extend it like this:
public static class MyRequestInitializer2 extends PubsubRequestInitializer { public MyKeyRequestInitializer() { super(KEY, USER_IP); } @Override public void initializePubsubRequest(PubsubRequest <? > request) throws IOException { // custom logic } }
Subclasses should be thread-safe.
Constructor and Description |
---|
PubsubRequestInitializer() |
PubsubRequestInitializer(java.lang.String key) |
PubsubRequestInitializer(java.lang.String key,
java.lang.String userIp) |
Modifier and Type | Method and Description |
---|---|
void |
initializeJsonRequest(com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest<?> request) |
protected void |
initializePubsubRequest(PubsubRequest<?> request)
Initializes Pubsub request.
|
initialize
public PubsubRequestInitializer()
public PubsubRequestInitializer(java.lang.String key)
key
- API key or null
to leave it unchangedpublic PubsubRequestInitializer(java.lang.String key, java.lang.String userIp)
key
- API key or null
to leave it unchangeduserIp
- user IP or null
to leave it unchangedpublic final void initializeJsonRequest(com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest<?> request) throws java.io.IOException
initializeJsonRequest
in class com.google.api.client.googleapis.services.json.CommonGoogleJsonClientRequestInitializer
java.io.IOException
protected void initializePubsubRequest(PubsubRequest<?> request) throws java.io.IOException
Default implementation does nothing. Called from
initializeJsonRequest(com.google.api.client.googleapis.services.json.AbstractGoogleJsonClientRequest)
.
java.io.IOException
- I/O exception