本文整理汇总了Java中com.googlecode.jsonrpc4j.ProxyUtil类的典型用法代码示例。如果您正苦于以下问题:Java ProxyUtil类的具体用法?Java ProxyUtil怎么用?Java ProxyUtil使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ProxyUtil类属于com.googlecode.jsonrpc4j包,在下文中一共展示了ProxyUtil类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onCreate
import com.googlecode.jsonrpc4j.ProxyUtil; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_lobby);
username = getIntent().getStringExtra("Username");
teamName = getIntent().getStringExtra("TeamName");
players = findViewById(R.id.players);
//Add to SQL//Sets quiz bowl server and connects to it
try {
server = new URL("http:///127.0.01/QuizBowl.json");
} catch (MalformedURLException e) {
e.printStackTrace();
}
client = new JsonRpcHttpClient(server);
quizBowl = ProxyUtil.createClientProxy(getClass().getClassLoader(), QuizBowl.class, client);
quizBowl.addUser(username, teamName, 0);
startTimer();
}
示例2: testStopWhileClientsWorking
import com.googlecode.jsonrpc4j.ProxyUtil; //导入依赖的package包/类
@Test
public void testStopWhileClientsWorking() throws Exception {
StreamServer streamServer = createAndStartServer();
Socket socket = new Socket(serverSocket.getInetAddress(), serverSocket.getLocalPort());
final Service service1 = ProxyUtil.createClientProxy(this.getClass().getClassLoader(), Service.class, jsonRpcClient, socket);
Thread t = new Thread(new Runnable() {
@Override
public void run() {
// noinspection InfiniteLoopStatement
while (true) {
service1.inc();
}
}
});
t.start();
while (service.val < 10) {
Thread.yield();
}
streamServer.stop();
}
示例3: createProxyFromKlass
import com.googlecode.jsonrpc4j.ProxyUtil; //导入依赖的package包/类
private void createProxyFromKlass(String klassName, JsonRpcHttpClient client, Dictionary<String, Object> props, ImportDeclaration importDeclaration) throws BinderException {
final Class<?> klass;
// Use given klass
try {
klass = FuchsiaUtils.loadClass(context, klassName);
} catch (ClassNotFoundException e) {
throw new BinderException(
"Cannot create a proxy for the ImportDeclaration : " + importDeclaration
+ " unable to find a bundle which export the service class.", e
);
}
// create the proxy !
final Object proxy = ProxyUtil.createClientProxy(klass.getClassLoader(), klass, client);
ServiceRegistration sReg = context.registerService(klassName, proxy, props);
handleImportDeclaration(importDeclaration);
String id = (String) importDeclaration.getMetadata().get(ID);
// Add the registration to the registration list
registrations.put(id, sReg);
}
示例4: setupRemoteRpc
import com.googlecode.jsonrpc4j.ProxyUtil; //导入依赖的package包/类
private void setupRemoteRpc() throws Exception {
System.out.println("Creating RPC interface...");
JsonRpcHttpClient httpClient = new JsonRpcHttpClient(new URL("http://localhost:8545"));
final JsonRpc jsonRpc = ProxyUtil.createClientProxy(getClass().getClassLoader(), JsonRpc.class, httpClient);
System.out.println("Pinging remote RPC...");
String protocolVersion = jsonRpc.eth_protocolVersion();
System.out.println("Remote OK. Version: " + protocolVersion);
final String pTxFilterId = jsonRpc.eth_newPendingTransactionFilter();
new Thread(new Runnable() {
@Override
public void run() {
try {
while (Boolean.TRUE) {
Object[] changes = jsonRpc.eth_getFilterChanges(pTxFilterId);
if (changes.length > 0) {
for (Object change : changes) {
TransactionResultDTO tx = jsonRpc.eth_getTransactionByHash((String) change);
newRemotePendingTx(tx);
}
}
Thread.sleep(100);
}
} catch (Exception e) {
e.printStackTrace();
}
}
}).start();
}
示例5: onCreate
import com.googlecode.jsonrpc4j.ProxyUtil; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_gm_lobby);
players = findViewById(R.id.players);
startGame = findViewById(R.id.startGame);
try {
server = new URL("http://localhost:8080/quizbowl.json");
} catch (MalformedURLException e) {
e.printStackTrace();
}
client = new JsonRpcHttpClient(server);
quizBowl = ProxyUtil.createClientProxy(getClass().getClassLoader(), QuizBowl.class, client);
String username = getIntent().getStringExtra("Username");
quizBowl.addUser(username, "GameMaster", 1);
startTimer();
startGame.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
quizBowl.setLobbyState();
Intent masterIntent = new Intent(GameMasterLobbyActivity.this, GameMasterActivity.class);
startActivity(masterIntent);
}
});
}
示例6: onCreate
import com.googlecode.jsonrpc4j.ProxyUtil; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_create_team);
createTeam = findViewById(R.id.createTeam);
teamName = findViewById(R.id.teamName);
//Final modifier might cause issues
final String nameP = getIntent().getStringExtra("Username");
//Sets quiz bowl server and connects to it
try {
server = new URL("http://localhost:8080/quizbowl.json");
} catch (MalformedURLException e) {
e.printStackTrace();
}
client = new JsonRpcHttpClient(server);
quizBowl = ProxyUtil.createClientProxy(getClass().getClassLoader(), QuizBowl.class, client);
createTeam.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
String nameT = teamName.getText().toString();
//Pass team name to SQL
quizBowl.addTeam(nameT);
Intent intent = new Intent(CreateTeamActivity.this, LobbyActivity.class);
intent.putExtra("Username", nameP);
intent.putExtra("TeamName", nameT);
startActivity(intent);
}
});
}
示例7: onCreate
import com.googlecode.jsonrpc4j.ProxyUtil; //导入依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_end_game);
scrollScores = findViewById(R.id.scores);
exit = findViewById(R.id.exit);
try {
server = new URL("http://localhost:8080/quizbowl.json");
} catch (MalformedURLException e) {
e.printStackTrace();
}
client = new JsonRpcHttpClient(server);
quizBowl = ProxyUtil.createClientProxy(getClass().getClassLoader(), QuizBowl.class, client);
ArrayList<Team> teamList = quizBowl.getTeams();
for(int i = 0; i < teamList.size(); i++){
addTeamPoints(teamList.get(i).getName() + " - " + teamList.get(i).getScore() + " points");
}
exit.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
finish();
System.exit(0);
}
});
}
示例8: EthRpcClient
import com.googlecode.jsonrpc4j.ProxyUtil; //导入依赖的package包/类
/**
* Constructor to specify hostname and port for ethereum client.
*
* @param hostname
* Hostname for ethereum client.
* @param port
* Port for ethereum client.
*/
public EthRpcClient(String hostname, int port) {
URL url;
log.log(Level.INFO, "Geth address: " + hostname + ":" + port);
try {
url = new URL("http://" + hostname + ":" + port + "/");
rpcClient = new JsonRpcHttpClient(url);
rpc = ProxyUtil.createClientProxy(getClass().getClassLoader(), EthRpcInterface.class,
rpcClient);
} catch (MalformedURLException exception) {
exception.printStackTrace();
}
}
示例9: runJsonRpcHttpClient
import com.googlecode.jsonrpc4j.ProxyUtil; //导入依赖的package包/类
public void runJsonRpcHttpClient() throws MalformedURLException {
JsonRpcHttpClient jsonRpcHttpClient = new JsonRpcHttpClient(new URL(
"http://127.0.0.1:" + JsonRpcServletEngine.PORT + "/"+ Config.appName.toLowerCase()));
JsonRpcService service = ProxyUtil.createClientProxy(
JsonRpcService.class.getClassLoader(), JsonRpcService.class,
jsonRpcHttpClient);
System.out.println(service.getBalance("1BckY64TE6VrjVcGMizYBE7gt22axnq6CM"));
}
示例10: EthRpcClient
import com.googlecode.jsonrpc4j.ProxyUtil; //导入依赖的package包/类
/**
* Constructor to specify hostname and port for ethereum client.
*
* @param hostname Hostname for ethereum client.
* @param port Port for ethereum client.
*/
public EthRpcClient(String hostname, int port) {
URL url;
logger.log(Level.INFO, "Geth address: " + hostname + ":" + port);
try {
url = new URL("http://" + hostname + ":" + port + "/");
JsonRpcHttpClient rpcClient = new JsonRpcHttpClient(url);
rpc = ProxyUtil.createClientProxy(getClass().getClassLoader(), EthRpcInterface.class,
rpcClient);
} catch (MalformedURLException exception) {
exception.printStackTrace();
}
}
示例11: main
import com.googlecode.jsonrpc4j.ProxyUtil; //导入依赖的package包/类
public static void main(String[] args) throws Throwable {
JsonRpcHttpClient jsonRpcHttpClient = new JsonRpcHttpClient(new URL("http://localhost:8099/com.doctor.jsonrpc.UserService"));
String result = jsonRpcHttpClient.invoke("getName", new Object[] { "docotr who" }, String.class);
System.out.println(result);
// or user ProxyUtil
UserService userService = ProxyUtil.createClientProxy(UserService.class.getClassLoader(), UserService.class, jsonRpcHttpClient);
String name = userService.getName("doctor who !");
System.out.println(name);
}
示例12: runJsonRpcHttpClient
import com.googlecode.jsonrpc4j.ProxyUtil; //导入依赖的package包/类
public void runJsonRpcHttpClient() throws MalformedURLException {
JsonRpcHttpClient jsonRpcHttpClient = new JsonRpcHttpClient(new URL(
"http://127.0.0.1:" + JsonRpcServletEngine.PORT + "/"+ Config.appName.toLowerCase()));
JsonRpcService service = ProxyUtil.createClientProxy(
JsonRpcService.class.getClassLoader(), JsonRpcService.class,
jsonRpcHttpClient);
System.out.println(service.getBalance("1BckY64TE6VrjVcGMizYBE7gt22axnq6CM"));
System.out.println(service.getSends("15QN22d2nzNM2FE9dyPrwAdLfxUkgavSUY"));
System.out.println(service.getReceives("15QN22d2nzNM2FE9dyPrwAdLfxUkgavSUY"));
}
示例13: testAllMethodsViaCompositeProxy
import com.googlecode.jsonrpc4j.ProxyUtil; //导入依赖的package包/类
@Test
public void testAllMethodsViaCompositeProxy() throws Throwable {
Object compositeService = ProxyUtil.createCompositeServiceProxy(ClassLoader.getSystemClassLoader(), new Object[]{client},
new Class<?>[]{Service.class}, true);
Service clientService = (Service) compositeService;
testCommon(clientService);
}
示例14: testTimingOutRequests
import com.googlecode.jsonrpc4j.ProxyUtil; //导入依赖的package包/类
@Test
public void testTimingOutRequests() throws Exception {
JsonRpcHttpClient client = getHttpClient(true, false);
client.setReadTimeoutMillis(1);
expectedEx.expectCause(isA(SocketTimeoutException.class));
service = ProxyUtil.createClientProxy(this.getClass().getClassLoader(), FakeTimingOutService.class, client);
service.doTimeout();
}
示例15: http405OnInvalidUrl
import com.googlecode.jsonrpc4j.ProxyUtil; //导入依赖的package包/类
@Test
public void http405OnInvalidUrl() throws MalformedURLException {
expectedEx.expectMessage(anyOf(
equalTo("405 HTTP method POST is not supported by this URL"),
equalTo("404 Not Found"),
equalTo("HTTP method POST is not supported by this URL"),
startsWith("Server returned HTTP response code: 405 for URL: http://127.0.0.1")));
expectedEx.expect(Exception.class);
FakeServiceInterface service = ProxyUtil.createClientProxy(FakeServiceInterface.class, getClient("error"));
service.doSomething();
}