エントリー
こんにちは、ガード。 私はすぐに予約をしたいと思います。名前は私がこれまでにコメントを書かないように促すことを意味するものではありません。 私はただ、どこにでもコメントを書きたいという欲求は、コードのより重要な問題を示しており、対処することでコメントの必要性がなくなることを示したいと思います。
開始する前に、Javaを使用して例を示し
ます 。
ここで説明するプロジェクトから、小さなコード(小さな追加コード)を取得し
ます 。
問題を理解するには、Wikiにアクセスして、例に進みます。
コメント-プログラムのソースコードの説明。コメントコード内に直接配置されます。
コードコメントの例
public static void main(String[] args) throws IOException {
// "ua.in.link.rest.server" - name of package with classes for Jersey server
ResourceConfig rc = new PackagesResourceConfig("ua.in.link.rest.server");
// creating httpServer for url "http://localhost:8080"
HttpServer httpServer = GrizzlyServerFactory.createHttpServer("http://localhost:8080", rc);
InetSocketAddress socketAddres = httpServer.getAddress();
doSomethisWithSocket(socketAddres); // waiting for Enter before stoping the server
System.in.read();
httpServer.stop();
}
. :
// "ua.in.link.rest.server" - name of package with classes for Jersey server
ResourceConfig rc = new PackagesResourceConfig("ua.in.link.rest.server");
, Jersey, , («ua.in.link.rest.server»). , , . , , - , , , , . , , ( ) . , «» («ua.in.link.rest.server»). , , . , :
private static final String JERSEY_CLASSES_PACKAGE_NAME = "ua.in.link.rest.server";
public static void main(String[] args) throws IOException {
ResourceConfig rc = new PackagesResourceConfig(JERSEY_CLASSES_PACKAGE_NAME);
// creating httpServer for url "http://localhost:8080"
HttpServer httpServer = GrizzlyServerFactory.createHttpServer("http://localhost:8080", rc);
InetSocketAddress socketAddres = httpServer.getAddress();
doSomethisWithSocket(socketAddres);
// waiting for Enter before stoping the server
System.in.read();
httpServer.stop();
}
. , — JERSEY_CLASSES_PACKAGE_NAME. , .
… :
// creating httpServer for url "http://localhost:8080"
HttpServer httpServer = GrizzlyServerFactory.createHttpServer("http://localhost:8080", rc);
InetSocketAddress socketAddres = httpServer.getAddress();
doSomethisWithSocket(socketAddres);
=). , , , , , . . , - . . . :
HttpServer httpServer = GrizzlyServerFactory.createHttpServer("http://localhost:8080", rc);
, , :
HttpServer httpServer = GrizzlyServerFactory.createHttpServer("http://localhost:8080", rc);
InetSocketAddress socketAddres = httpServer.getAddress();
doSomethisWithSocket(socketAddres);
, , - . , :
ResourceConfig rc = new PackagesResourceConfig(JERSEY_CLASSES_PACKAGE_NAME);
.
.
private static final String JERSEY_CLASSES_PACKAGE_NAME = "ua.in.link.rest.server";
private static final String SERVER_URL = "http://localhost:8080";
public static void main(String[] args) throws IOException {
HttpServer httpServer = startServer();
InetSocketAddress socketAddres = httpServer.getAddress();
prepareSocket(socketAddres);
// waiting for Enter before stoping the server
System.in.read();
httpServer.stop();
}
private static HttpServer startServer() {
ResourceConfig rc = new PackagesResourceConfig(JERSEY_CLASSES_PACKAGE_NAME);
return GrizzlyServerFactory.createHttpServer(SERVER_URL, rc);
}
private static void prepareSocket(InetSocketAddress socketAddres){
doSomethisWithSocket(socketAddres);
}
, Socket , , - :
private static HttpServer startServer() {
ResourceConfig rc = new PackagesResourceConfig(JERSEY_CLASSES_PACKAGE_NAME);
HttpServer httpServer = GrizzlyServerFactory.createHttpServer(SERVER_URL, rc);
InetSocketAddress socketAddres = httpServer.getAddress();
prepareSocket(socketAddres);
return httpServer;
}
, . , , .
, . , , , . :
private static final String JERSEY_CLASSES_PACKAGE_NAME = "ua.in.link.rest.server";
private static final String SERVER_URL = "http://localhost:8080";
private static final String PRESS_ENTER__TO_STOP_STRING = "Press Enter to stop server";
public static void main(String[] args) throws IOException {
HttpServer httpServer = startServer();
InetSocketAddress socketAddres = httpServer.getAddress();
prepareSocket(socketAddres);
userStopsServer(httpServer);
}
private static HttpServer startServer() {
ResourceConfig rc = new PackagesResourceConfig(JERSEY_CLASSES_PACKAGE_NAME);
return GrizzlyServerFactory.createHttpServer(SERVER_URL, rc);
}
private static void prepareSocket(InetSocketAddress socketAddres){
doSomethisWithSocket(socketAddres);
}
private static void userStopsServer(HttpServer httpServer){
System.out.println(PRESS_ENTER__TO_STOP_STRING + httpServer.toString());
System.in.read();
httpServer.stop();
}
?
, :
, , ; , , — , , , , ., , , . . ( ), — , .
Unit . ( ), , Unit . , , .. , ( , ) , . , , . .
, , . — @Depricated . , .
JavaDoc
, - , :
/**
*
*
*
*
* @_
* @return _
*/
«»- , , JavaDoc , . , . , - . , , .
— . , , , - , — « » . , , , KISS, , . , , , , - . ( ) , .