小编Tro*_*roy的帖子

需要一种以编程方式检查Windows服务状态的方法

情况如下:

我被要求使用InstallAnywhere 8,这是一个基于Java的安装程序IDE,允许启动和停止Windows服务,但没有内置方法来查询它们的状态.幸运的是,它允许您使用Java创建自定义操作,可以在安装过程中随时调用(通过我认为是一个相当复杂的API).

我只需要一些能告诉我特定服务是否已启动或停止的内容.

IDE还允许调用批处理脚本,所以这也是一个选项,虽然一旦运行脚本,几乎没有办法验证它是否成功,所以我试图避免这种情况.

欢迎任何建议或批评.

java command-line windows-services

11
推荐指数
3
解决办法
2万
查看次数

d3美国国家地图与标记,缩放转换问题

我按照这个例子创建了一个美国各州的d3地图:

http://bl.ocks.org/mbostock/4699541

并在此SO问题后添加标记:

将标记放到使用topoJSON和d3.js生成的地图上

问题是在缩放时,地图标记保持不变.我相信我需要将它们转化为新的位置,但不确定如何实现这一目标.

在此输入图像描述

var width = 900,
  height = 500,
  active = d3.select(null);

var projection = d3.geo.albersUsa()
  .scale(1000)
  .translate([width / 2, height / 2]);

var path = d3.geo.path()
  .projection(projection);

var svg = d3.select(".rebates").append("svg")
  .attr("width", width)
  .attr("height", height);

svg.append("rect")
  .attr("class", "background")
  .attr("width", width)
  .attr("height", height)
  .on("click", reset);

var g = svg.append("g")
  .style("stroke-width", "1.5px");

d3.json("/files/d3-geo/us.json", function(error, us) {
  if (error) { throw error; }

  g.selectAll("path")
    .data(topojson.feature(us, us.objects.states).features)
    .enter().append("path")
    .attr("d", path)
    .attr("class", function(item) {
      return window.US_STATES[item.id].water_authorities > 0 ? 'avail' : …
Run Code Online (Sandbox Code Playgroud)

javascript mapping geospatial geo d3.js

7
推荐指数
1
解决办法
3952
查看次数

Grails:如何引用已安装插件中的资源?

我有一个Grails插件,我使用它作为一些共享静态资源的容器,将由内部的各种其他Grails项目(CSS,JS文件等)使用.使用插件的想法只是为了分享这些东西 - 插件并没有真正做任何其他非常有趣的事情.直接引用插件内资源的最佳方法是什么?我宁愿不创建自定义标记库,因为我实际上并没有在这里添加任何功能; 我只想访问插件中的资源 - 例如,从GSP引用CSS文件:

<g:link rel="stylesheet" url="${resource(dir:'css', file:'mycss.css',
plugin:'myplugin')}"/>
Run Code Online (Sandbox Code Playgroud)

这个想法是否违反了插件的概念,其中只有某些方面应该暴露,其余的是黑盒子?在相关的Grails项目之间共享静态资源的替代方法也是受欢迎的,以防我试图通过这种方式走向疯狂,错误的道路.:)

grails resources plugins

6
推荐指数
1
解决办法
3579
查看次数

在返回集合的接口中使用Java泛型.最佳实践?陷阱?

我今天碰到了一些我发现有问题的代码.这是一个简化的例子(不现实).

public interface IListable {
    //returns first n items from list
    public ArrayList getFirstNThings(int n);

    //returns last n items from list
    public ArrayList getLastNThings(int n);
}
Run Code Online (Sandbox Code Playgroud)

然后有一个像这样的实现者:

public GroceryList implements IListable {
    private ArrayList<GroceryItem> groceries;

    public GroceryList() {
        this.groceries = new ArrayList<GroceryItem>();
    }

    public ArrayList<GroceryItem> getFirstNThings(int n) {
        ArrayList<GroceryItem> firstNThings = new ArrayList<GroceryItem>();
        for (int i=0; i < n; i++) {
            firstNThings.add(this.groceries.get(i));
        }
        return firstNThings
     }

     public ArrayList<GroceryItem> getLastNThings(int n) {
         ArrayList<GroceryItem> lastNThings = new ArrayList<GroceryItem>();
         for (int i=this.groceries.size(); i …
Run Code Online (Sandbox Code Playgroud)

java oop generics collections interface

5
推荐指数
1
解决办法
3206
查看次数