小编Alb*_*ola的帖子

如何在init脚本中以特定用户身份运行命令?

我正在编写一个init脚本,它应该以不同于root的用户身份执行单个命令.这就是我目前正在做的事情:
sudo -u username command

这通常在Ubuntu/Debian上按预期工作,但在RHEL上,作为command挂起执行的脚本.
是否有另一种方法以另一个用户身份运行该命令?
(请注意,我不能使用lsb init函数,因为它们在RHEL/Centos 5.x上不可用.)

linux bash centos rhel init

33
推荐指数
4
解决办法
14万
查看次数

Spring框架中的ehcache配置

我试图从RSS源加载一些上下文,并在春天使用ehcache库将其作为缓存传递给客户端.这是我的代码:

    import org.springframework.cache.annotation.Cacheable;
@Service
public class GlossaryReaderService {

    @Cacheable(value = "glossaryList")
    public List<Glossary> readGlossary(String url) {

        XmlReader reader = null;
        List<Glossary> extractedGlossay = new ArrayList<Glossary>();
        SyndEntry entry;
        SyndContent desc;
        Glossary glossaryList = null;
        try {
            String decodedURL = URLDecoder.decode(url, "UTF-8");
            reader = new XmlReader(new URL(decodedURL));
            SyndFeed feed = new SyndFeedInput().build(reader);

            for (Iterator i = feed.getEntries().iterator(); i.hasNext();) {
                entry = (SyndEntry) i.next();
                desc = entry.getDescription();
                if (desc != null) { ...
                        extractedGlossay.add(glossaryList);
                    }
                }
            }

        } catch (IOException | IllegalArgumentException | …
Run Code Online (Sandbox Code Playgroud)

spring ehcache spring-cache spring-4

15
推荐指数
2
解决办法
4万
查看次数

在cocos2d中添加UIViewController

我想在cocos2d项目中显示一个UIViewController,所以我在我的CCLayer类中这样做:

-(void)displayMainMenu {
    CGSize screenSize = [CCDirector sharedDirector].winSize;
    [CCMenuItemFont setFontName:@"Marker Felt"];
    [CCMenuItemFont setFontSize:26];

    CCMenuItemFont *openViewC = [CCMenuItemFont itemWithString:@"Open View" target:self selector:@selector(loadMyViewController)];
    mainMenu = [CCMenu menuWithItems:openViewC, nil];
    [self addChild:mainMenu z:0];
}

-(void) loadMyViewController{

    //Add the tableview when the transition is done
    myView = [[MyViewController alloc] init];
    UIView *viewHost = hostView.view;

    [[[CCDirector sharedDirector] view] addSubview:viewHost];
}
Run Code Online (Sandbox Code Playgroud)

然后在我的ViewController中返回我的CCLayer我这样做:

- (IBAction)exitAction:(id)sender
    {
    [self.view removeFromSuperview];

    [[CCDirector sharedDirector] pushScene: [MainMenu scene]]; //i need it or not?
}
Run Code Online (Sandbox Code Playgroud)

和所有的工作,我使用cocos2d v2.0,但我想知道是否有更好的方法在cocos2d场景中添加UIViewController,谢谢!

iphone uiviewcontroller cocos2d-iphone ios

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