How to replace a parameterized type with a more specific one

Consider the following setup: We have an interface SuperType which is parameterized like this: public interface SuperType<V> { } SuperType supports method chaining. Hence it defines another type parameter which captures the concrete implementing subtype returned by each method like this: public interface SuperType<V, S extends SuperType<V, S>> { public S doSomething()

如何用更具体的替换参数化类型

考虑以下设置: 我们有一个如此参数化的接口SuperType : public interface SuperType<V> { } SuperType支持方法链接。 因此它定义了另一个类型参数,它捕获每个方法返回的具体实现子类型,如下所示: public interface SuperType<V, S extends SuperType<V, S>> { public S doSomething(); } 让我们考虑一下SuperType<V, S extends SuperType<V, S>> : public class SubType<V&g

It is a bad practice to use Sun's proprietary Java classes?

The compiler display warnings if you use Sun's proprietary Java classes. I'm of the opinion that it's generally a bad idea to use these classes. I read this somewhere. However, aside from the warnings are there any fundamental reasons why you should not use them? Because they are internal APIs: they are subject to change in a undocumented or unsupported way and they are bound to

使用Sun专有的Java类是不好的做法?

如果您使用Sun的专有Java类,编译器会显示警告。 我认为使用这些类通常是一个糟糕的主意。 我在某处读过这篇文章。 但是,除了警告之外,你有什么根本原因不应该使用它们? 因为它们是内部API:它们可能会以无证或不受支持的方式进行更改,并且它们绑定到特定的JRE / JDK(您的情况为Sun ),从而限制了程序的可移植性。 尽量避免使用这样的API,总是喜欢公开记录和指定的类。 JDK 6文档包含标题为“关于sun.*包”的链接

Need of Prototype design pattern?

When exactly do we go for the prototype design pattern ? What I understood from various resources is to use the pattern when we find instantiating a class using new Operator Or when we want the run-time initialization of object. So How exactly we could define an instantiation of class using new operator to be expensive? when the class definition contains too many fields and that too seldom goi

需要Prototype设计模式?

到底什么时候我们会选择原型设计模式? 我从各种资源中了解到的是,当我们使用新的操作符或者当我们想要对象的运行时初始化时发现实例化类时使用该模式。 那么,我们究竟能够使用new运算符来定义一个类的实例化成本呢? 当类定义包含太多的字段,并且以后很少会改变? 为每个新游戏设置的所有玩家实例化一个棋盘将会太昂贵,无法使用新运算符实例化? 有人可以通过相同的光线? 确实Prototype模式与OOP没有多大关系。

Apache Felix shell with SSH

I'm interested how I can use Apache Felix with SSH? I want to access Felix shell from remote computer using SSH. I know that there is a telnet support but it's too unsafe. Is there any solution? Yes, there is one, as described here (the guide is relative to eclipse's equinox but it doesn't matter) using a combination of gogo shell, apache mina sshd server and three equinox co

使用SSH的Apache Felix shell

我感兴趣的是如何通过SSH使用Apache Felix? 我想使用SSH从远程计算机访问Felix shell。 我知道有一个telnet支持,但它太不安全了。 有没有解决方法? 是的,有一个,这里描述(该指南是相对于日食的春分,但它并不重要)使用gogo shell,apache mina sshd服务器和三个春分控制台捆绑(核心+ ssh插件+ jaas插件的sshd组合身份验证),您将能够连接到mina的ssh服务器,并且与OSGi相关的命令将由gogo shell执行。 你需要这

Determine if mouse outside window

I need to be able to check if the mouse is outside the window of my libgdx app running on a windows desktop. Gdx.input.getX() and Gdx.input.getY() are constrained to my app window on Windows (but not on Mac). I tried Gdx.input.setCatched(true) which does make it unconstrained, but it also binds the mouse entirely to my app. So Windows doesn't get any mouse events until I alt+tab to a dif

确定鼠标是否在窗外

我需要能够检查鼠标是否在Windows桌面上运行的我的libgdx应用程序的窗口之外。 Gdx.input.getX()和Gdx.input.getY()被限制在我的Windows上的应用程序窗口(但不是在Mac上)。 我试过Gdx.input.setCatched(true) ,它确实使它不受约束,但它也将鼠标完全绑定到我的应用程序。 所以Windows没有得到任何鼠标事件,直到我alt +选项卡到另一个应用程序。 我也尝试编写一个InputProcessor,但mouseMoved只能在窗口内被触发。 T

Spring Transactional Annotation

I'm trying to get a better handle on the use of Spring's @Transactional attribute. I understand that it basically wraps the contents of the method marked as @Transactional in a transaction. Would it be appropriate to mark a service/business layer method as transactional, as opposed to the actual DAO method, as I have done here? Service Implementation public class UserServiceImpl impl

Spring事务注释

我试图更好地使用Spring的@Transactional属性。 我明白,它基本上将标记为@Transactional的方法的内容包装在一个事务中。 像我在这里所做的那样,将服务/业务层方法标记为事务性的,而不是实际的DAO方法是否合适? 服务实施 public class UserServiceImpl implements UserServiceInt{ @Autowired private UserServiceDAO serviceDAO; @Override public User getUser(int id){ return serviceDAO.getUser

How to get the file list for a commit with JGit

I have been working on a Java based product for which the Git features are going to be integrated. Using one of the Git features, I have done adding 10+ files into the Git repository by staging followed by committing them in a single commit. Is the reverse of the above process possible? Ie Finding the list of files committed as part of a commit. I got the commit with the help of the git.log

如何获取JGit提交的文件列表

我一直在研究基于Java的产品,这些产品将集成Git功能。 使用其中一个Git特性,我通过登台将10多个文件添加到Git存储库中,然后在单次提交中提交它们。 上述过程的可能性是否相反? 即查找作为提交一部分提交的文件列表。 我在git.log()命令的帮助下得到了提交,但我不确定如何获取提交的文件列表。 示例代码: Git git = (...); Iterable<RevCommit> logs = git.log().call(); for(RevCommit commit : logs) {

Convert String to valid URI object

I am trying to get a java.net.URI object from a String . The string has some characters which will need to be replaced by their percentage escape sequences. But when I use URLEncoder to encode the String with UTF-8 encoding, even the / are replaced with their escape sequences. How can I get a valid encoded URL from a String object? http://www.google.com?q=ab gives http%3A%2F%2www.google.com

将String转换为有效的URI对象

我想从一个String获取一个java.net.URI对象。 该字符串有一些字符,需要用它们的百分比转义序列替换。 但是,当我使用URLEncoder对UTF-8编码的字符串进行编码时,甚至将其替换为它们的转义序列。 如何从String对象获取有效的编码URL? http://www.google.com?q=ab提供http%3A%2F%2www.google.com ...而我希望输出为http://www.google.com?q=a%20b 有人可以告诉我如何做到这一点。 我正在尝试在Android应用中执行此

Visitor Pattern for two arguments

Here is a problem statement: We have interfaces/super classes Student and Teacher Student has two implementations/sub clasees, ScienceStudent and PhysicalEducationStudent Teacher has ScienceTeacher and PhysicalEducationTeacher. We want to implement a method getMeetingPoint(Student s, Teacher t) which returns a place where they meet based on the type of Student and Teacher. For example, if

访问者模式的两个参数

这是一个问题陈述:我们有接口/超级班的学生和老师 学生有两个实施/分类,ScienceStudent和PhysicalEducationStudent 教师有科学教师和物理教育教师。 我们想要实现一种方法getMeetingPoint(Student,Teacher t),它根据学生和教师的类型返回他们见面的地方。 举例来说,如果其ScienceStudent和ScienceTeacher他们在实验室会面,如果PEStudent和体育教师 ,他们在地面上,如果其ScienceStudent和体育教师或反之亦然见

JNDI naming exception on JRE7

We are facing a problem , we have code base complied in JDK 6 . Now we are migrating to JRE-7 . Which eventually means we are running code compiled in JDK-6 with JRE -7 . Every thing is working fine apart from JNDI . We are getting following exception. 2015-05-25 09:44:41,769 ERROR ne.LdapNeNotifListener - NamingExceptionEvent recieved from ABC: javax.naming.NamingException: LDAP response re

JRE7上的JNDI命名异常

我们遇到了一个问题,我们在JDK 6中编写了代码库。 现在我们正在迁移到JRE-7。 这最终意味着我们正在运行使用JRE-7在JDK-6中编译的代码。 除了JNDI之外,每件事情都很好。 我们正在接受例外。 2015-05-25 09:44:41,769 ERROR ne.LdapNeNotifListener - NamingExceptionEvent recieved from ABC: javax.naming.NamingException: LDAP response read timed out, timeout used:-1ms. at com.sun.jndi.ldap.Connection.r