SampleBean:
package com.springexample;
import javax.annotation.PostConstruct;
import javax.annotation.PreDestroy;
public class SampleBean {
private BeanTypeOne beanOne;
private BeanTypeTwo beanTwo;
public void init() {
System.out.println("This is from the init() method");
}
@PostConstruct
public void initAnnotation() {
System.out.println("This is from the initAnnotation() method");
}
Run Code Online (Sandbox Code Playgroud)
和配置文件如下:
<bean id="SampleBean" class="com.springexample.SampleBean">
<property name="beanOne" ref="beanOneOne"></property>
<property name="beanTwo" ref="beanTwoOne"></property>
</bean>
Run Code Online (Sandbox Code Playgroud)
我没有在beans标记上设置default-init-method属性.
任何人都可以告诉为什么@PostConstruct方法不会被调用.
我这几天正在研究关系代数,我想知道......
如果编译器存在可以编译关系代数而不是编译SQL,那么你不是更好吗?
在哪种情况下,数据库程序员会更高效?
是否有关于关系代数编译器的研究?
提前致谢
是否可以登录我的Gmail帐户并使用php中的curl发送邮件?我不想使用pop3或任何其他功能.
$msg = "something";
$email = "sa@sas.com";
$pass= "something"
function send($msg, $email, $pass)
{
//something
}
Run Code Online (Sandbox Code Playgroud)
说实话,我从未使用过curl.刚刚听说过它.
好的,所以我昨天开始观看,我有这个想法.我真的不太了解网络安全或互联网.这就是你们的意思,告诉我这是否安全甚至可能.顺便说一句,它是通过网络发送安全数据的.
我的想法需要发送所需的数据并对其进行加密.然后将数据分成小比特,并在多个套接字或连接中发送给接收器.然后发送包含加密密钥的最终分组.一旦接收器获得了信息,他就可以组装数据然后解密它.
我的想法是,如果有人试图收集数据包,因为他们只获得了部分数据而变得无用.
那么这是安全还是以前完成的?
一个)
select decode(count(*), 0, 'N', 'Y') rec_exists
from (select 'X'
from dual
where exists (select 'X'
from sales
where sales_type = 'Accessories'));
Run Code Online (Sandbox Code Playgroud)
B)
select decode(count(*), 0, 'N', 'Y') rec_exists
from (select 'X'
from sales
where sales_type = 'Accessories');
Run Code Online (Sandbox Code Playgroud)
C)其他(指定)
编辑:很难选择"正确"的答案,因为最佳方法取决于在检查值是否存在后您想要做什么,如APC指出的那样.我最终选择了RedFilter的答案,因为我最初设想这个检查本身就是一个功能.
我试图将一个自定义throws子句添加到由接口定义的方法.这是不可能的.我怎么能绕过它呢?这是一些代码:
private void sendRequestToService(final ModuleRequest pushRequest)
{
ServiceConnection serviceConnection = new ServiceConnection()
{
public void onServiceConnected(ComponentName name, IBinder service)
{
try
{
//some lines..
} catch (RemoteException e)
{
throw new RuntimeException(new UnavailableDestException()) ;
}
}
};
}
Run Code Online (Sandbox Code Playgroud)
知道如何抛出我的自定义异常吗?
我写了下面的awk来打印从匹配线到EOF的线
awk '/match_line/,/*/' file
Run Code Online (Sandbox Code Playgroud)
我怎样才能在sed中做同样的事情?
目前我有一个基于给定String充当工厂的方法.例如:
public Animal createAnimal(String action)
{
if (action.equals("Meow"))
{
return new Cat();
}
else if (action.equals("Woof"))
{
return new Dog();
}
...
etc.
}
Run Code Online (Sandbox Code Playgroud)
我想要做的是在类列表增长时避免整个if-else问题.我想我需要有两个方法,一个将字符串注册到类,另一个根据操作的字符串返回类.
在Java中这样做的好方法是什么?
在iOS4之前,我的应用程序的初始视图控制器将检查viewWillAppear中的密码开/关设置变量,如果设置为on,则会显示一个模态密码屏幕,该屏幕将保持不变,直到输入正确的密码或按下Home按钮.
使用iOS4,如果我的应用程序已经在后台,我希望用户感到很舒服,如果他们要将手机交给某人使用,则应用程序中包含的数据不易被访问.
由于应用程序可以返回到任何屏幕(应用程序最后一次打开的屏幕),我想我将使用UIApplicationWillEnterForegroundNotification到处使用本地选择器(重复的enterPasscode方法),每个都有正确的视图控制器来推送基于本地屏幕,但必须有一个更好的方法.
我可能在这里有一个轻微的概念误解.有人可以提出另一种方法,或者推动我继续下一步.我可以将此作为共享方法,但仍然知道要推送正确的本地视图控制器吗?
谢谢
编辑/ UPDATE:
简短版本:它有效,但可能仍有更好的方式(任何帮助赞赏)...
我用视图控制器创建了一个标准单例.
PasscodeView.h包含:
UIViewController *viewController;
@property (nonatomic, retain) UIViewController *viewController;
Run Code Online (Sandbox Code Playgroud)
PasscodeView.m包含:
@synthesize viewController;
Run Code Online (Sandbox Code Playgroud)
我把它放在AppDelegate中:
-(void)applicationWillEnterForeground:(UIApplication*)application {
PasscodeView *passcodeView = [PasscodeView sharedDataManager];
UIViewController *currentController = [passcodeView viewController];
NSLog(@"%@", currentController); //testing
EnterPasscode *passcodeInput = [[EnterPasscode alloc] initWithNibName:@"Passcode" bundle:nil];
[currentController presentModalViewController:passcodeInput animated:NO];
[passcodeInput release];
}
Run Code Online (Sandbox Code Playgroud)
以及我所有viewDidLoad中的以下内容,当我进入每个屏幕时更新当前视图控制器(只有2行,但似乎还有更好的方法):
PasscodeView *passcodeView = [PasscodeView sharedSingleton];
passcodeView.viewController = [[self navigationController] visibleViewController];
Run Code Online (Sandbox Code Playgroud)
我希望有一种方法可以从applicationWillEnterForeground获得当前的视图控制器,但我找不到它 - 这里的任何帮助仍然很感激.
为了保持一致性,我更改了一行并添加了一行以获得导航栏以匹配应用程序的其余部分并包含标题.
UINavigationController *passcodeNavigationController = [[UINavigationController alloc] initWithRootViewController:passcodeInput];
[currentController presentModalViewController: passcodeNavigationController animated:NO];
Run Code Online (Sandbox Code Playgroud) 我尝试使用推荐的方式(来自Rails指南)来测试插件中生成的路由,但测试仍然失败.
奇怪的是,如果我在创建路线后重新加载路线(或者我认为),测试失败,但如果我让测试经过一次(例如使用自动测试),那么路线会在后续尝试中被识别.
这是代码:
describe "named route report_with_last_name_smith_path" do
before :all do
Reports::Application.routes.draw do
match "/report_some_report_for_us" => "report#report_some_report_for_us",
:as => :report_some_report_for_us
end
Rails.application.reload_routes! # If I leave this out, then the test
# passes the second time that autotest/autospec
# go through.
end
it "route for every record" do
{:get => '/report_some_report_for_us'}.should route_to(:controller => 'report', :action => 'report_some_report_for_us')
end
end
Run Code Online (Sandbox Code Playgroud)
知道如何让它一直通过吗?