小编frm*_*frm的帖子

What are the best resources to learn Ant?

I would like to learn Ant. Can anyone recommend some good learning resources about this topic? Any resource is appreciated, from online introductory tutorials to in-depth books.

Thanks for your help!

java ant

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

在IntelliJ IDEA 11中运行Apache Felix 4.0.2

根据这篇文章,IDEA使用Osmorc来运行OSGi框架.反过来,它使用Pax Runner来启动不同的框架实现.

IDEA 11中的工具链只能运行Apache Felix 3.0.2,但我必须运行4.0.2版本.可能吗?IDEA还有其他OSGi框架发射器吗?

java osgi intellij-idea apache-felix

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

为Either编写Functor实例时键入不匹配

在Typeclassopedia中练习之后,我尝试为Either实现一个Functor实例.我的第一次尝试如下:

instance Functor (Either a) where
  fmap f (Right a) = Right (f a)
  fmap _ left = left
Run Code Online (Sandbox Code Playgroud)

这会引发以下编译时错误:

functor.hs:7:17:
Couldn't match type ‘a1’ with ‘b’
  ‘a1’ is a rigid type variable bound by
       the type signature for
         fmap :: (a1 -> b) -> Either a a1 -> Either a b
       at functor.hs:6:3
  ‘b’ is a rigid type variable bound by
      the type signature for
        fmap :: (a1 -> b) -> Either a a1 -> Either a b
      at …
Run Code Online (Sandbox Code Playgroud)

haskell

6
推荐指数
2
解决办法
218
查看次数

在servlet和EJB之间使用@RunAs

我有以下servlet.

@DeclareRoles("remote-guest")
@RunAs("remote-guest")
public class GuestServlet extends HttpServlet {

    @EJB
    private Test test;

    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        test.guest();
    }

}
Run Code Online (Sandbox Code Playgroud)

映射servlet使得只有具有角色的用户guest才能调用它.

<servlet>
    <servlet-name>guest-servlet</servlet-name>
    <servlet-class>test.web.GuestServlet</servlet-class>
</servlet>

<servlet-mapping>
    <servlet-name>guest-servlet</servlet-name>
    <url-pattern>/guest</url-pattern>
</servlet-mapping>

<security-role>
    <role-name>guest</role-name>
</security-role>

<security-constraint>
    <web-resource-collection>
        <web-resource-name>guest-resources</web-resource-name>
        <url-pattern>/guest</url-pattern>
    </web-resource-collection>
    <auth-constraint>
        <role-name>guest</role-name>
    </auth-constraint>
</security-constraint>
Run Code Online (Sandbox Code Playgroud)

TestEJB由以下实现TestBean类.

@Stateless
@DeclareRoles("remote-guest")
public class TestBean implements Test {

    @RolesAllowed("remote-guest")
    public void guest() {
        System.out.println("TestBean.guest()");
    }

}
Run Code Online (Sandbox Code Playgroud)

问题:当我调用GuestServlet使用仅映射到guest角色的用户时,javax.ejb.EJBAccessException尽管@RunAs …

authentication servlets ejb java-ee

3
推荐指数
1
解决办法
5426
查看次数

Haskell的抽象工厂

我想知道如何在功能语言中实现面向对象语言中常见的抽象工厂设计模式.特别是,我对Haskell实现很感兴趣.

我尝试使用类型类来实现模式:

class Product p where
  toString :: p -> String

class Factory f where
  createProduct :: Product p => f -> p

data FirstProduct = FirstProduct
data FirstFactory = FirstFactory

instance Product FirstProduct where
  toString _ = "first product"

instance Factory FirstFactory where
  createProduct _ = FirstProduct
Run Code Online (Sandbox Code Playgroud)

编译此代码时,将返回以下错误:

Could not deduce (p ~ FirstProduct)
from the context (Product p)
  bound by the type signature for
             createProduct :: Product p => FirstFactory -> p
  at test.hs:14:3-15
  ‘p’ is a rigid …
Run Code Online (Sandbox Code Playgroud)

haskell design-patterns

0
推荐指数
1
解决办法
573
查看次数