JNDI に Array を指定することが可能になっています
次のように指定可能です
web.xml
<resource-ref>
<description>Maintenance Property</description>
<res-ref-name>maintenance</res-ref-name>
<res-type>java.lang.reflect.Array</res-type>
<res-auth>Container</res-auth>
</resource-ref>
jetty-env.xml
<New id="maintenance" class="org.eclipse.jetty.plus.jndi.Resource">
<Arg></Arg>
<Arg>maintenance</Arg>
<Arg>
<Array type="com.gauuud.Property.MaintenanceProp">
<item><New class="com.gauuud.Property.MaintenanceProp">
<Set name="start">2012/9/11 1:25</Set>
<Set name="end">2012/9/11 1:30</Set>
<Set name="type">10</Set>
<Set name="desc">test</Set>
</New></item>
<item><New class="com.gauuud.Property.MaintenanceProp">
<Set name="start">2012/9/12 1:25</Set>
<Set name="end">2012/9/13 1:30</Set>
<Set name="type">10</Set>
<Set name="desc">test2</Set>
</New></item>
</Array>
</Arg>
</New>
MaintenanceProp.java :
package com.gauuud.Property;
import java.util.Date;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
public class MaintenanceProp {
private int type;
public int getType() {
return this.type;
}
public void setType(int type) {
this.type = type;
}
private Date start;
public Date getStart() {
return this.start;
}
public void setStart(Date start) {
this.start = start;
}
private Date end;
public Date getEnd() {
return this.end;
}
public void setEnd(Date end) {
this.end = end;
}
private String desc;
public String getDesc() {
return this.desc;
}
public void setDesc(String desc) {
this.desc = desc;
}
public MaintenanceProp() {}
}
MaintenancePropArray.java:
package com.gauuud.Property;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
public class MaintenancePropArray {
private static final MaintenanceProp[] array;
public static MaintenanceProp[] get(){
return array;
}
static {
MaintenanceProp[] props = null;
try {
InitialContext ic = new InitialContext();
Context envCtx = (Context) ic.lookup("java:comp/env");
props = (MaintenanceProp[]) envCtx.lookup("maintenance");
} catch (NamingException e) {
e.printStackTrace();
}
array = props;
}
}
0 件のコメント:
コメントを投稿