生成されたコードを次のコードで置き換えてください。
package oracle.model.mycompany;
import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;
import oracle.mds.core.MetadataObject;
import oracle.mds.core.RestrictedSession;
import oracle.mds.cust.CacheHint;
import oracle.mds.cust.CustomizationClass;
public class SiteCC extends CustomizationClass {
private static final String DEFAULT_LAYER_NAME = "site";
private String mLayerName = DEFAULT_LAYER_NAME;
public SiteCC() {
}
public SiteCC(String layerName) {
mLayerName = layerName;
}
public CacheHint getCacheHint() {
return CacheHint.ALL_USERS;
}
public String getName() {
return mLayerName;
}
public String[] getValue(RestrictedSession sess, MetadataObject mo) {
// This needs to return the site value at runtime.
// For now, it's always null.
Properties properties = new Properties();
String configuredValue = null;
Class clazz = SiteCC.class;
InputStream is = clazz.getResourceAsStream("/customization.properties");
if (is != null){
try {
properties.load(is);
String propValue = properties.getProperty(mLayerName);
if (propValue != null){
configuredValue = propValue;
}
} catch (IOException e) {
e.printStackTrace();
}
}
return new String[] {configuredValue};
}
}
サンプル・コードを入力するかわりに、このウィンドウのコードをコピーしてJavaソース・エディタに貼り付けることができます。
Copyright © 1997, 2009, Oracle. All rights reserved.