forked from alibaba/jvm-sandbox
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
杜琨
committed
Mar 12, 2018
1 parent
07f2992
commit 895d12a
Showing
4 changed files
with
90 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
sandbox-core/src/main/java/com/alibaba/jvm/sandbox/core/server/ProxyCoreServer.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
package com.alibaba.jvm.sandbox.core.server; | ||
|
||
import com.alibaba.jvm.sandbox.core.CoreConfigure; | ||
import com.alibaba.jvm.sandbox.core.server.jetty.JettyCoreServer; | ||
|
||
import java.io.IOException; | ||
import java.lang.instrument.Instrumentation; | ||
import java.net.InetSocketAddress; | ||
|
||
public class ProxyCoreServer implements CoreServer { | ||
|
||
private final static Class<? extends CoreServer> classOfCoreServerImpl | ||
= JettyCoreServer.class; | ||
|
||
private final CoreServer proxy; | ||
|
||
private ProxyCoreServer(CoreServer proxy) { | ||
this.proxy = proxy; | ||
} | ||
|
||
|
||
@Override | ||
public boolean isBind() { | ||
return proxy.isBind(); | ||
} | ||
|
||
@Override | ||
public void unbind() throws IOException { | ||
proxy.unbind(); | ||
} | ||
|
||
@Override | ||
public InetSocketAddress getLocal() throws IOException { | ||
return proxy.getLocal(); | ||
} | ||
|
||
@Override | ||
public void bind(CoreConfigure cfg, Instrumentation inst) throws IOException { | ||
proxy.bind(cfg, inst); | ||
} | ||
|
||
@Override | ||
public void destroy() { | ||
proxy.destroy(); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return "proxy:" + proxy.toString(); | ||
} | ||
|
||
public static CoreServer getInstance() { | ||
try { | ||
return new ProxyCoreServer( | ||
(CoreServer) classOfCoreServerImpl | ||
.getMethod("getInstance") | ||
.invoke(null) | ||
); | ||
} catch (Throwable cause) { | ||
throw new RuntimeException(cause); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters