[openrtm-commit:00565] r629 - in trunk: . jp.go.aist.rtm.RTC jp.go.aist.rtm.RTC/src jp.go.aist.rtm.RTC/src/Extension jp.go.aist.rtm.RTC/src/Extension/LocalService jp.go.aist.rtm.RTC/src/Extension/LocalService/nameservice_file jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC
openrtm @ openrtm.org
openrtm @ openrtm.org
2012年 1月 10日 (火) 15:19:38 JST
Author: fsi-katami
Date: 2012-01-10 15:19:37 +0900 (Tue, 10 Jan 2012)
New Revision: 629
Added:
trunk/jp.go.aist.rtm.RTC/src/Extension/
trunk/jp.go.aist.rtm.RTC/src/Extension/LocalService/
trunk/jp.go.aist.rtm.RTC/src/Extension/LocalService/nameservice_file/
trunk/jp.go.aist.rtm.RTC/src/Extension/LocalService/nameservice_file/FileNameservice.java
trunk/jp.go.aist.rtm.RTC/src/Extension/LocalService/nameservice_file/NamingAction.java
Removed:
trunk/jp.go.aist.rtm.RTC/src/Extension/LocalService/
trunk/jp.go.aist.rtm.RTC/src/Extension/LocalService/nameservice_file/
trunk/jp.go.aist.rtm.RTC/src/Extension/LocalService/nameservice_file/FileNameservice.java
trunk/jp.go.aist.rtm.RTC/src/Extension/LocalService/nameservice_file/NamingAction.java
Modified:
trunk/
trunk/jp.go.aist.rtm.RTC/
trunk/jp.go.aist.rtm.RTC/build.xml
trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/LocalServiceProfile.java
Log:
Implemented FileNameservice. refs 2310
Property changes on: trunk
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/RELENG_1_0_0:60-401
/branches/work/ForComponentActionListener:521-522
/branches/work/ForComponentObserverConsumer:534-543
/branches/work/ForConfigurationListener:524-526
/branches/work/ForLogFormat:518-519
/branches/work/ForPortConnectListener:528-532
/branches/work/ForSDOServiceAdminClass:505-507
/branches/work/SourceSharing:591-603
/branches/work/ToGetProperties:545-548
/branches/work/ToIFR_ID:509-514
+ /branches/RELENG_1_0_0:60-401
/branches/work/ForComponentActionListener:521-522
/branches/work/ForComponentObserverConsumer:534-543
/branches/work/ForConfigurationListener:524-526
/branches/work/ForFileNameservice:623-628
/branches/work/ForLogFormat:518-519
/branches/work/ForPortConnectListener:528-532
/branches/work/ForSDOServiceAdminClass:505-507
/branches/work/SourceSharing:591-603
/branches/work/ToGetProperties:545-548
/branches/work/ToIFR_ID:509-514
Property changes on: trunk/jp.go.aist.rtm.RTC
___________________________________________________________________
Modified: svn:mergeinfo
- /branches/RELENG_1_0/jp.go.aist.rtm.RTC:408-498
/branches/RELENG_1_0_0/jp.go.aist.rtm.RTC:60-401
/branches/work/ForComponentActionListener/jp.go.aist.rtm.RTC:521-522
/branches/work/ForComponentObserverConsumer/jp.go.aist.rtm.RTC:534-543
/branches/work/ForConfigurationListener/jp.go.aist.rtm.RTC:524-526
/branches/work/ForLogFormat/jp.go.aist.rtm.RTC:518-519
/branches/work/ForPortConnectListener/jp.go.aist.rtm.RTC:528-532
/branches/work/ForSDOServiceAdminClass/jp.go.aist.rtm.RTC:505-507
/branches/work/SourceSharing/jp.go.aist.rtm.RTC:591-603
/branches/work/ToGetProperties/jp.go.aist.rtm.RTC:545-548
/branches/work/ToIFR_ID/jp.go.aist.rtm.RTC:509-514
+ /branches/RELENG_1_0/jp.go.aist.rtm.RTC:408-498
/branches/RELENG_1_0_0/jp.go.aist.rtm.RTC:60-401
/branches/work/ForComponentActionListener/jp.go.aist.rtm.RTC:521-522
/branches/work/ForComponentObserverConsumer/jp.go.aist.rtm.RTC:534-543
/branches/work/ForConfigurationListener/jp.go.aist.rtm.RTC:524-526
/branches/work/ForFileNameservice/jp.go.aist.rtm.RTC:623-628
/branches/work/ForLogFormat/jp.go.aist.rtm.RTC:518-519
/branches/work/ForPortConnectListener/jp.go.aist.rtm.RTC:528-532
/branches/work/ForSDOServiceAdminClass/jp.go.aist.rtm.RTC:505-507
/branches/work/SourceSharing/jp.go.aist.rtm.RTC:591-603
/branches/work/ToGetProperties/jp.go.aist.rtm.RTC:545-548
/branches/work/ToIFR_ID/jp.go.aist.rtm.RTC:509-514
Modified: trunk/jp.go.aist.rtm.RTC/build.xml
===================================================================
--- trunk/jp.go.aist.rtm.RTC/build.xml 2012-01-10 05:48:31 UTC (rev 628)
+++ trunk/jp.go.aist.rtm.RTC/build.xml 2012-01-10 06:19:37 UTC (rev 629)
@@ -26,6 +26,8 @@
<property name="source.examples" value="src/RTMExamples"/>
+ <property name="source.extension" value="src/Extension"/>
+
<property name="source.examplestemp" value="src/RTMExamplesTemp"/>
<property name="source.main" value="src/jp"/>
@@ -614,8 +616,12 @@
<javac srcdir="${source.sdo}:${source.rtc}:${source.rtm}:${source.openrtm}" destdir="${build.dir}" classpath="lib/commons-cli-1.1.jar" encoding="UTF-8" />
+
<javac srcdir="${source.main}:${source.rtcd}:${source.rtcprof}" destdir="${build.dir}" classpath="lib/commons-cli-1.1.jar" encoding="UTF-8" includes="go/aist/**" excludes="go/aist/ForSunOrb/**,go/aist/ForJacOrb/**" />
+
+ <javac srcdir="${source.extension}:" destdir="${build.dir}" classpath="lib/commons-cli-1.1.jar" encoding="UTF-8" />
+
<delete dir="${source.examplestemp}" />
<native2ascii encoding="UTF-8" src="${source.examples}" dest="${source.examplestemp}" >
@@ -644,80 +650,6 @@
<javac srcdir="${source.examples}:" destdir="${build.dir}" classpath="lib/commons-cli-1.1.jar" encoding="UTF-8" />
- <native2ascii encoding="UTF-8" src="${source.sdo}" dest="${source.sdotemp}" >
-
- <include name="**/*.java" />
-
- </native2ascii>
-
- <copy todir="${source.sdo}">
-
- <fileset dir="${source.sdotemp}" >
-
- <include name="**/*.java" />
-
- </fileset>
-
- </copy>
-
- <delete dir="${source.sdotemp}" />
-
- <native2ascii encoding="UTF-8" src="${source.rtc}" dest="${source.rtctemp}" >
-
- <include name="**/*.java" />
-
- </native2ascii>
-
- <copy todir="${source.rtc}">
-
- <fileset dir="${source.rtctemp}" >
-
- <include name="**/*.java" />
-
- </fileset>
-
- </copy>
-
- <delete dir="${source.rtctemp}" />
-
- <native2ascii encoding="UTF-8" src="${source.rtm}" dest="${source.rtmtemp}" >
-
- <include name="**/*.java" />
-
- </native2ascii>
-
- <copy todir="${source.rtm}">
-
- <fileset dir="${source.rtmtemp}" >
-
- <include name="**/*.java" />
-
- </fileset>
-
- </copy>
-
- <delete dir="${source.rtmtemp}" />
-
- <native2ascii encoding="UTF-8" src="${source.openrtm}" dest="${source.openrtmtemp}" >
-
- <include name="**/*.java" />
-
- </native2ascii>
-
- <copy todir="${source.openrtm}">
-
- <fileset dir="${source.openrtmtemp}" >
-
- <include name="**/*.java" />
-
- </fileset>
-
- </copy>
-
- <delete dir="${source.openrtmtemp}" />
-
- <javac srcdir="${source.sdo}:${source.rtc}:${source.rtm}:${source.openrtm}" destdir="${build.dir}" classpath="lib/commons-cli-1.1.jar" encoding="UTF-8" />
-
<copy todir="${source.common}" overwrite="true">
<fileset dir="${source.sunorb}" >
@@ -758,6 +690,8 @@
<javac srcdir="${source.examples}:" destdir="${build.dir}" classpath="lib/commons-cli-1.1.jar" encoding="UTF-8" />
+
+
</target>
Deleted: trunk/jp.go.aist.rtm.RTC/src/Extension/LocalService/nameservice_file/FileNameservice.java
===================================================================
--- branches/work/ForFileNameservice/jp.go.aist.rtm.RTC/src/Extension/LocalService/nameservice_file/FileNameservice.java 2012-01-10 05:48:31 UTC (rev 628)
+++ trunk/jp.go.aist.rtm.RTC/src/Extension/LocalService/nameservice_file/FileNameservice.java 2012-01-10 06:19:37 UTC (rev 629)
@@ -1,352 +0,0 @@
-package Extension.LocalService.nameservice_file;
-
-import java.io.BufferedWriter;
-import java.io.File;
-import java.io.FileWriter;
-import java.lang.IndexOutOfBoundsException;
-import java.lang.SecurityException;
-import java.util.Arrays;
-import java.util.ArrayList;
-import jp.go.aist.rtm.RTC.LocalServiceBase;
-import jp.go.aist.rtm.RTC.LocalServiceFactory;
-import jp.go.aist.rtm.RTC.LocalServiceProfile;
-import jp.go.aist.rtm.RTC.Manager;
-import jp.go.aist.rtm.RTC.ObjectCreator;
-import jp.go.aist.rtm.RTC.ObjectDestructor;
-import jp.go.aist.rtm.RTC.log.Logbuf;
-import jp.go.aist.rtm.RTC.util.CallbackFunction;
-import jp.go.aist.rtm.RTC.util.Properties;
-import jp.go.aist.rtm.RTC.util.StringUtil;
-
- /**
- * {@.ja FileNameservice クラス}
- * {@.en FileNameservice class}
- */
-public class FileNameservice implements LocalServiceBase, CallbackFunction, ObjectCreator<LocalServiceBase>, ObjectDestructor{
-
- private static String service_name
- = "org.openrtm.local_service.nameservice.file_nameservice";
- private static String service_uuid
- = "cc1744c2-6952-4ad8-a7f6-ceaa041c5541";
- private static String default_config[] = {
- "base_path", "/tmp/.openrtm_ns/",
- "file_structure", "tree",
- "context_delimiter", "|",
- ""
- };
- /**
- * {@.ja コンストラクタ。}
- * {@.en Constructor}
- *
- * <p>
- * {@.ja Protected コンストラクタ}
- * {@.en Protected Constructor}
- *
- */
- public FileNameservice() {
- rtcout = new Logbuf("file_nameservice");
- m_profile.name = service_name;
- m_profile.uuid = service_uuid;
- Properties prop = new Properties(default_config);
- m_profile.properties = prop;
- m_profile.service = this;
- rtcout.println(Logbuf.DEBUG,"FileNameservice was created(");
- rtcout.println(Logbuf.DEBUG," name = "+m_profile.name);
- rtcout.println(Logbuf.DEBUG," uuid = "+m_profile.uuid);
- rtcout.println(Logbuf.DEBUG," properties =");
- String str = new String();
- str = m_profile.properties._dump(str,m_profile.properties,0);
- rtcout.println(Logbuf.DEBUG,str);
- rtcout.println(Logbuf.DEBUG," service = "+this+")");
- }
-
- /**
- * {@.ja 初期化関数}
- * {@.en Initialization function}
- * <p>
- * @param profile
- * {@.ja 外部から与えられた property}
- * @return
- */
- public boolean init(final Properties props){
- rtcout.println(Logbuf.TRACE,"init()");
- String str = new String();
- str = props._dump(str,props,0);
- rtcout.println(Logbuf.DEBUG,str);
- m_profile.properties.merge(props);
-
- Manager manager = Manager.instance();
- manager.addNamingActionListener(new NamingAction(this));
- return true;
- }
-
- /**
- * {@.ja 再初期化関数}
- * {@.en Reinitialization function}
- *
- * @param profile
- * {@.ja 外部から与えられた property}
- * @return
- *
- *
- */
- public boolean reinit(final Properties props){
- rtcout.println(Logbuf.TRACE,"init()");
- String str = new String();
- str = props._dump(str,props,0);
- rtcout.println(Logbuf.DEBUG,str);
- boolean ret = processServiceProfile(props);
- m_profile.properties.merge(props);
- return ret;
- }
-
- /**
- * {@.ja LocalServiceProfile を取得する}
- * {@.en Getting LocalServiceProfile}
- *
- *
- * @return
- * {@.ja このオブジェクトが保持している LocalServiceProfile}
- * {@.en LocalServiceProfile of this service class}
- *
- */
- public final LocalServiceProfile getProfile() {
- rtcout.println(Logbuf.TRACE,"getProfile()");
- return m_profile;
- }
-
- /**
- * {@.ja 終了関数}
- * {@.en Finalization function}
- *
- *
- */
- public void _finalize(){
- cleanupFiles();
- }
-
- /**
- * {@.ja 名前登録時に呼ばれるコールバック}
- * {@.en A call-back at name registration}
- *
- *
- */
- public void onRegisterNameservice(String[] ns_path, String[] ns_info) {
- rtcout.println(Logbuf.TRACE,"onRegisterNameservice(path = "
- + Arrays.toString(ns_path)+")");
- rtcout.println(Logbuf.TRACE," nsinfo ="+Arrays.toString(ns_info));
-
- for (int ic=0; ic < ns_path.length; ++ic) {
- File filepath = new File(getFname(ns_path[ic]));
- File directory = filepath.getParentFile();
- rtcout.println(Logbuf.DEBUG,"file path: "+filepath);
- rtcout.println(Logbuf.DEBUG,"directory: "+directory);
- if (!createDirectory(directory)) {
- continue;
- }
- try {
- String filename = filepath.getName();
- rtcout.println(Logbuf.DEBUG,"file name: "+filename);
- FileWriter file = new FileWriter(filepath);
- BufferedWriter ofs = new BufferedWriter(file);
- for (int i=0; i < ns_info.length; ++i) {
- ofs.write(ns_info[i]);
- }
- ofs.flush();
- ofs.close();
- rtcout.println(Logbuf.INFO,"RTC "+filename
- +"'s IOR has been successfully registered: "
- +filepath);
- m_files.add(filepath.getAbsolutePath());
- }
- catch (Exception ex) {
- rtcout.println(Logbuf.ERROR,"Creating file has been failed. "
- + filepath);
- }
- }
- }
-
- /**
- * {@.ja 名前登録解除に呼ばれるコールバック}
- * {@.en A call-back at name runegistration}
- *
- *
- */
- public void onUnregisterNameservice(String[] ns_path){
- rtcout.println(Logbuf.TRACE,"onUnregisterNameservice("
- +Arrays.toString(ns_path)+")");
- for (int ic=0; ic < ns_path.length; ++ic) {
- String filepath = getFname(ns_path[ic]);
- File file = new File(filepath);
- if (!file.exists()) {
- rtcout.println(Logbuf.ERROR,"No such file: "+ filepath);
- continue;
- }
- try {
- m_files.remove(filepath);
- }
- catch(IndexOutOfBoundsException ex){
- rtcout.println(Logbuf.WARN,"This file ("
- +filepath
- +") might not be my file.");
- continue;
- }
-
- boolean error = false;
- boolean result = false;
- rtcout.println(Logbuf.DEBUG,"Removing file: "
- +filepath);
- try{
- result = file.delete();
- }
- catch(SecurityException se) {
- error = true;
- }
- if (!result||error) {
- rtcout.println(Logbuf.ERROR,"Removing a file has been failed."
- + filepath);
- continue;
- }
- rtcout.println(Logbuf.PARANOID,"Removing a file done: "
- +filepath);
- }
- return;
- }
-
- public void doOperate(){
- }
-
- /**
- * {@.ja ディレクトリ作成}
- * {@.en Creating directories}
- */
- protected boolean createDirectory(File directory){
- rtcout.println(Logbuf.TRACE,"createDirectory("
- + directory
- +")");
- if (!directory.exists()) {
- rtcout.println(Logbuf.DEBUG,"Directory "
- +directory
- +"not found");
- boolean error = false;
- boolean result = false;
- rtcout.println(Logbuf.DEBUG,"Creating directory: "
- + directory);
- try{
- result = directory.mkdir();
- }
- catch(SecurityException se){
- error = true;
- }
- if (!result || error) {
- rtcout.println(Logbuf.ERROR,
- "Creating directory has been failed."
- + directory);
- return false;
- }
- rtcout.println(Logbuf.PARANOID,"Creating directory done: "
- +directory);
-
- }
- else if (directory.exists() && directory.isDirectory()) {
- rtcout.println(Logbuf.DEBUG,"Directory "
- +directory
- +" exists.");
- }
- else {
- rtcout.println(Logbuf.ERROR,"File exists instead of base directory "
- +directory
- +" .");
- return false;
- }
- return true;
- }
-
- /**
- * {@.ja ファイル名取得}
- * {@.en Getting file name}
- */
- protected String getFname(String ns_path) {
- rtcout.println(Logbuf.TRACE,"getFname(" +ns_path +")");
-
- String pathstring = m_profile.properties.getProperty("base_path");
- String file_separator = System.getProperty("file.separator");
- pathstring += file_separator;
-
- String fs = m_profile.properties.getProperty("file_structure");
- fs = StringUtil.normalize(fs);
- if (fs.equals("flat")) {
- rtcout.println(Logbuf.DEBUG,"file_structure = flat");
- String d = m_profile.properties.getProperty("context_delimiter");
- ns_path.replaceAll(file_separator, d);
- pathstring += ns_path;
- }
- else if (fs.equals("tree")) {
- rtcout.println(Logbuf.DEBUG,"file_structure = tree");
- pathstring += ns_path;
- }
- rtcout.println(Logbuf.DEBUG,"path string = "+ pathstring);
-
- return pathstring;
- }
-
- /**
- * {@.ja 全ファイル削除}
- * {@.en Deleting all files}
- */
- protected void cleanupFiles() {
- rtcout.println(Logbuf.TRACE,"cleanupFiles()");
- for (int ic=0; ic < m_files.size(); ++ic) {
- File p = new File(m_files.get(ic));
- p.delete();
- }
- m_files.clear();
- }
-
- /**
- * {@.ja プロパティの処理}
- * {@.en Processing properties}
- */
- protected boolean processServiceProfile(final Properties props) {
- return true;
- }
-
-
- private LocalServiceProfile m_profile = new LocalServiceProfile();
- private ArrayList<String> m_files = new ArrayList<String>();
- private Logbuf rtcout;
-
- /**
- * <p> creator_ </p>
- *
- * @return Object Created instances
- *
- */
- public LocalServiceBase creator_() {
- return new FileNameservice();
- }
- /**
- * <p> destructor_ </p>
- *
- * @param obj The target instances for destruction
- *
- */
- public void destructor_(Object obj) {
- obj = null;
- }
- /**
- * {@.ja モジュール初期化関数}
- * {@.en Module initialization}
- * <p>
- * {@.ja FileNameserviceをファクトリに登録する初期化関数。}
- * {@.en This initialization function registers FileNameservice to the factory.}
- *
- */
- public static void FileNameserviceInit() {
- final LocalServiceFactory<LocalServiceBase,String> factory
- = LocalServiceFactory.instance();
- factory.addFactory(service_name,
- new FileNameservice(),
- new FileNameservice());
- }
-}
Copied: trunk/jp.go.aist.rtm.RTC/src/Extension/LocalService/nameservice_file/FileNameservice.java (from rev 628, branches/work/ForFileNameservice/jp.go.aist.rtm.RTC/src/Extension/LocalService/nameservice_file/FileNameservice.java)
===================================================================
--- trunk/jp.go.aist.rtm.RTC/src/Extension/LocalService/nameservice_file/FileNameservice.java (rev 0)
+++ trunk/jp.go.aist.rtm.RTC/src/Extension/LocalService/nameservice_file/FileNameservice.java 2012-01-10 06:19:37 UTC (rev 629)
@@ -0,0 +1,352 @@
+package Extension.LocalService.nameservice_file;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.lang.IndexOutOfBoundsException;
+import java.lang.SecurityException;
+import java.util.Arrays;
+import java.util.ArrayList;
+import jp.go.aist.rtm.RTC.LocalServiceBase;
+import jp.go.aist.rtm.RTC.LocalServiceFactory;
+import jp.go.aist.rtm.RTC.LocalServiceProfile;
+import jp.go.aist.rtm.RTC.Manager;
+import jp.go.aist.rtm.RTC.ObjectCreator;
+import jp.go.aist.rtm.RTC.ObjectDestructor;
+import jp.go.aist.rtm.RTC.log.Logbuf;
+import jp.go.aist.rtm.RTC.util.CallbackFunction;
+import jp.go.aist.rtm.RTC.util.Properties;
+import jp.go.aist.rtm.RTC.util.StringUtil;
+
+ /**
+ * {@.ja FileNameservice クラス}
+ * {@.en FileNameservice class}
+ */
+public class FileNameservice implements LocalServiceBase, CallbackFunction, ObjectCreator<LocalServiceBase>, ObjectDestructor{
+
+ private static String service_name
+ = "org.openrtm.local_service.nameservice.file_nameservice";
+ private static String service_uuid
+ = "cc1744c2-6952-4ad8-a7f6-ceaa041c5541";
+ private static String default_config[] = {
+ "base_path", "/tmp/.openrtm_ns/",
+ "file_structure", "tree",
+ "context_delimiter", "|",
+ ""
+ };
+ /**
+ * {@.ja コンストラクタ。}
+ * {@.en Constructor}
+ *
+ * <p>
+ * {@.ja Protected コンストラクタ}
+ * {@.en Protected Constructor}
+ *
+ */
+ public FileNameservice() {
+ rtcout = new Logbuf("file_nameservice");
+ m_profile.name = service_name;
+ m_profile.uuid = service_uuid;
+ Properties prop = new Properties(default_config);
+ m_profile.properties = prop;
+ m_profile.service = this;
+ rtcout.println(Logbuf.DEBUG,"FileNameservice was created(");
+ rtcout.println(Logbuf.DEBUG," name = "+m_profile.name);
+ rtcout.println(Logbuf.DEBUG," uuid = "+m_profile.uuid);
+ rtcout.println(Logbuf.DEBUG," properties =");
+ String str = new String();
+ str = m_profile.properties._dump(str,m_profile.properties,0);
+ rtcout.println(Logbuf.DEBUG,str);
+ rtcout.println(Logbuf.DEBUG," service = "+this+")");
+ }
+
+ /**
+ * {@.ja 初期化関数}
+ * {@.en Initialization function}
+ * <p>
+ * @param profile
+ * {@.ja 外部から与えられた property}
+ * @return
+ */
+ public boolean init(final Properties props){
+ rtcout.println(Logbuf.TRACE,"init()");
+ String str = new String();
+ str = props._dump(str,props,0);
+ rtcout.println(Logbuf.DEBUG,str);
+ m_profile.properties.merge(props);
+
+ Manager manager = Manager.instance();
+ manager.addNamingActionListener(new NamingAction(this));
+ return true;
+ }
+
+ /**
+ * {@.ja 再初期化関数}
+ * {@.en Reinitialization function}
+ *
+ * @param profile
+ * {@.ja 外部から与えられた property}
+ * @return
+ *
+ *
+ */
+ public boolean reinit(final Properties props){
+ rtcout.println(Logbuf.TRACE,"init()");
+ String str = new String();
+ str = props._dump(str,props,0);
+ rtcout.println(Logbuf.DEBUG,str);
+ boolean ret = processServiceProfile(props);
+ m_profile.properties.merge(props);
+ return ret;
+ }
+
+ /**
+ * {@.ja LocalServiceProfile を取得する}
+ * {@.en Getting LocalServiceProfile}
+ *
+ *
+ * @return
+ * {@.ja このオブジェクトが保持している LocalServiceProfile}
+ * {@.en LocalServiceProfile of this service class}
+ *
+ */
+ public final LocalServiceProfile getProfile() {
+ rtcout.println(Logbuf.TRACE,"getProfile()");
+ return m_profile;
+ }
+
+ /**
+ * {@.ja 終了関数}
+ * {@.en Finalization function}
+ *
+ *
+ */
+ public void _finalize(){
+ cleanupFiles();
+ }
+
+ /**
+ * {@.ja 名前登録時に呼ばれるコールバック}
+ * {@.en A call-back at name registration}
+ *
+ *
+ */
+ public void onRegisterNameservice(String[] ns_path, String[] ns_info) {
+ rtcout.println(Logbuf.TRACE,"onRegisterNameservice(path = "
+ + Arrays.toString(ns_path)+")");
+ rtcout.println(Logbuf.TRACE," nsinfo ="+Arrays.toString(ns_info));
+
+ for (int ic=0; ic < ns_path.length; ++ic) {
+ File filepath = new File(getFname(ns_path[ic]));
+ File directory = filepath.getParentFile();
+ rtcout.println(Logbuf.DEBUG,"file path: "+filepath);
+ rtcout.println(Logbuf.DEBUG,"directory: "+directory);
+ if (!createDirectory(directory)) {
+ continue;
+ }
+ try {
+ String filename = filepath.getName();
+ rtcout.println(Logbuf.DEBUG,"file name: "+filename);
+ FileWriter file = new FileWriter(filepath);
+ BufferedWriter ofs = new BufferedWriter(file);
+ for (int i=0; i < ns_info.length; ++i) {
+ ofs.write(ns_info[i]);
+ }
+ ofs.flush();
+ ofs.close();
+ rtcout.println(Logbuf.INFO,"RTC "+filename
+ +"'s IOR has been successfully registered: "
+ +filepath);
+ m_files.add(filepath.getAbsolutePath());
+ }
+ catch (Exception ex) {
+ rtcout.println(Logbuf.ERROR,"Creating file has been failed. "
+ + filepath);
+ }
+ }
+ }
+
+ /**
+ * {@.ja 名前登録解除に呼ばれるコールバック}
+ * {@.en A call-back at name runegistration}
+ *
+ *
+ */
+ public void onUnregisterNameservice(String[] ns_path){
+ rtcout.println(Logbuf.TRACE,"onUnregisterNameservice("
+ +Arrays.toString(ns_path)+")");
+ for (int ic=0; ic < ns_path.length; ++ic) {
+ String filepath = getFname(ns_path[ic]);
+ File file = new File(filepath);
+ if (!file.exists()) {
+ rtcout.println(Logbuf.ERROR,"No such file: "+ filepath);
+ continue;
+ }
+ try {
+ m_files.remove(filepath);
+ }
+ catch(IndexOutOfBoundsException ex){
+ rtcout.println(Logbuf.WARN,"This file ("
+ +filepath
+ +") might not be my file.");
+ continue;
+ }
+
+ boolean error = false;
+ boolean result = false;
+ rtcout.println(Logbuf.DEBUG,"Removing file: "
+ +filepath);
+ try{
+ result = file.delete();
+ }
+ catch(SecurityException se) {
+ error = true;
+ }
+ if (!result||error) {
+ rtcout.println(Logbuf.ERROR,"Removing a file has been failed."
+ + filepath);
+ continue;
+ }
+ rtcout.println(Logbuf.PARANOID,"Removing a file done: "
+ +filepath);
+ }
+ return;
+ }
+
+ public void doOperate(){
+ }
+
+ /**
+ * {@.ja ディレクトリ作成}
+ * {@.en Creating directories}
+ */
+ protected boolean createDirectory(File directory){
+ rtcout.println(Logbuf.TRACE,"createDirectory("
+ + directory
+ +")");
+ if (!directory.exists()) {
+ rtcout.println(Logbuf.DEBUG,"Directory "
+ +directory
+ +"not found");
+ boolean error = false;
+ boolean result = false;
+ rtcout.println(Logbuf.DEBUG,"Creating directory: "
+ + directory);
+ try{
+ result = directory.mkdir();
+ }
+ catch(SecurityException se){
+ error = true;
+ }
+ if (!result || error) {
+ rtcout.println(Logbuf.ERROR,
+ "Creating directory has been failed."
+ + directory);
+ return false;
+ }
+ rtcout.println(Logbuf.PARANOID,"Creating directory done: "
+ +directory);
+
+ }
+ else if (directory.exists() && directory.isDirectory()) {
+ rtcout.println(Logbuf.DEBUG,"Directory "
+ +directory
+ +" exists.");
+ }
+ else {
+ rtcout.println(Logbuf.ERROR,"File exists instead of base directory "
+ +directory
+ +" .");
+ return false;
+ }
+ return true;
+ }
+
+ /**
+ * {@.ja ファイル名取得}
+ * {@.en Getting file name}
+ */
+ protected String getFname(String ns_path) {
+ rtcout.println(Logbuf.TRACE,"getFname(" +ns_path +")");
+
+ String pathstring = m_profile.properties.getProperty("base_path");
+ String file_separator = System.getProperty("file.separator");
+ pathstring += file_separator;
+
+ String fs = m_profile.properties.getProperty("file_structure");
+ fs = StringUtil.normalize(fs);
+ if (fs.equals("flat")) {
+ rtcout.println(Logbuf.DEBUG,"file_structure = flat");
+ String d = m_profile.properties.getProperty("context_delimiter");
+ ns_path.replaceAll(file_separator, d);
+ pathstring += ns_path;
+ }
+ else if (fs.equals("tree")) {
+ rtcout.println(Logbuf.DEBUG,"file_structure = tree");
+ pathstring += ns_path;
+ }
+ rtcout.println(Logbuf.DEBUG,"path string = "+ pathstring);
+
+ return pathstring;
+ }
+
+ /**
+ * {@.ja 全ファイル削除}
+ * {@.en Deleting all files}
+ */
+ protected void cleanupFiles() {
+ rtcout.println(Logbuf.TRACE,"cleanupFiles()");
+ for (int ic=0; ic < m_files.size(); ++ic) {
+ File p = new File(m_files.get(ic));
+ p.delete();
+ }
+ m_files.clear();
+ }
+
+ /**
+ * {@.ja プロパティの処理}
+ * {@.en Processing properties}
+ */
+ protected boolean processServiceProfile(final Properties props) {
+ return true;
+ }
+
+
+ private LocalServiceProfile m_profile = new LocalServiceProfile();
+ private ArrayList<String> m_files = new ArrayList<String>();
+ private Logbuf rtcout;
+
+ /**
+ * <p> creator_ </p>
+ *
+ * @return Object Created instances
+ *
+ */
+ public LocalServiceBase creator_() {
+ return new FileNameservice();
+ }
+ /**
+ * <p> destructor_ </p>
+ *
+ * @param obj The target instances for destruction
+ *
+ */
+ public void destructor_(Object obj) {
+ obj = null;
+ }
+ /**
+ * {@.ja モジュール初期化関数}
+ * {@.en Module initialization}
+ * <p>
+ * {@.ja FileNameserviceをファクトリに登録する初期化関数。}
+ * {@.en This initialization function registers FileNameservice to the factory.}
+ *
+ */
+ public static void FileNameserviceInit() {
+ final LocalServiceFactory<LocalServiceBase,String> factory
+ = LocalServiceFactory.instance();
+ factory.addFactory(service_name,
+ new FileNameservice(),
+ new FileNameservice());
+ }
+}
Deleted: trunk/jp.go.aist.rtm.RTC/src/Extension/LocalService/nameservice_file/NamingAction.java
===================================================================
--- branches/work/ForFileNameservice/jp.go.aist.rtm.RTC/src/Extension/LocalService/nameservice_file/NamingAction.java 2012-01-10 05:48:31 UTC (rev 628)
+++ trunk/jp.go.aist.rtm.RTC/src/Extension/LocalService/nameservice_file/NamingAction.java 2012-01-10 06:19:37 UTC (rev 629)
@@ -1,63 +0,0 @@
-package Extension.LocalService.nameservice_file;
-
-import org.omg.CORBA.Object;
-
-import jp.go.aist.rtm.RTC.Manager;
-import jp.go.aist.rtm.RTC.NamingActionListener;
-import jp.go.aist.rtm.RTC.RTObject_impl;
-import jp.go.aist.rtm.RTC.util.Properties;
-
- /**
- * {@.ja NamingAction class}
- * {@.en NamingAction class}
- */
-public class NamingAction extends NamingActionListener {
- public void operator() {
- ;
- }
-
- /**
- * {@.ja コンストラクタ}
- * {@.en Constructor}
- */
- public NamingAction(FileNameservice fns){
- m_fns = fns;
- }
-
- /**
- * {@.ja preBind コールバック関数}
- * {@.en preBind callback function}
- */
- public void preBind(RTObject_impl rtobj, String[] name_) {
- String[] name = name_;
-
- Object objref = rtobj.getObjRef()._duplicate();
- String ior =
- Manager.instance().getORB().object_to_string(objref);
- String[] ns_info = new String[1];
- ns_info[0] = ior;
- m_fns.onRegisterNameservice(name, ns_info);
- }
- /**
- * {@.ja postBind コールバック関数}
- * {@.en postBind callback function}
- */
- public void postBind(RTObject_impl rtobj, String[] name) {
- }
-
- /**
- * {@.ja preUnbind コールバック関数}
- * {@.en preUnbind callback function}
- */
- public void preUnbind(RTObject_impl rtobj, String[] name){
- }
- /**
- * {@.ja postUnbind コールバック関数}
- * {@.en postUnbind callback function}
- */
- public void postUnbind(RTObject_impl rtobj, String[] name) {
- m_fns.onUnregisterNameservice(name);
- }
-
- private FileNameservice m_fns = new FileNameservice();
-}
Copied: trunk/jp.go.aist.rtm.RTC/src/Extension/LocalService/nameservice_file/NamingAction.java (from rev 628, branches/work/ForFileNameservice/jp.go.aist.rtm.RTC/src/Extension/LocalService/nameservice_file/NamingAction.java)
===================================================================
--- trunk/jp.go.aist.rtm.RTC/src/Extension/LocalService/nameservice_file/NamingAction.java (rev 0)
+++ trunk/jp.go.aist.rtm.RTC/src/Extension/LocalService/nameservice_file/NamingAction.java 2012-01-10 06:19:37 UTC (rev 629)
@@ -0,0 +1,63 @@
+package Extension.LocalService.nameservice_file;
+
+import org.omg.CORBA.Object;
+
+import jp.go.aist.rtm.RTC.Manager;
+import jp.go.aist.rtm.RTC.NamingActionListener;
+import jp.go.aist.rtm.RTC.RTObject_impl;
+import jp.go.aist.rtm.RTC.util.Properties;
+
+ /**
+ * {@.ja NamingAction class}
+ * {@.en NamingAction class}
+ */
+public class NamingAction extends NamingActionListener {
+ public void operator() {
+ ;
+ }
+
+ /**
+ * {@.ja コンストラクタ}
+ * {@.en Constructor}
+ */
+ public NamingAction(FileNameservice fns){
+ m_fns = fns;
+ }
+
+ /**
+ * {@.ja preBind コールバック関数}
+ * {@.en preBind callback function}
+ */
+ public void preBind(RTObject_impl rtobj, String[] name_) {
+ String[] name = name_;
+
+ Object objref = rtobj.getObjRef()._duplicate();
+ String ior =
+ Manager.instance().getORB().object_to_string(objref);
+ String[] ns_info = new String[1];
+ ns_info[0] = ior;
+ m_fns.onRegisterNameservice(name, ns_info);
+ }
+ /**
+ * {@.ja postBind コールバック関数}
+ * {@.en postBind callback function}
+ */
+ public void postBind(RTObject_impl rtobj, String[] name) {
+ }
+
+ /**
+ * {@.ja preUnbind コールバック関数}
+ * {@.en preUnbind callback function}
+ */
+ public void preUnbind(RTObject_impl rtobj, String[] name){
+ }
+ /**
+ * {@.ja postUnbind コールバック関数}
+ * {@.en postUnbind callback function}
+ */
+ public void postUnbind(RTObject_impl rtobj, String[] name) {
+ m_fns.onUnregisterNameservice(name);
+ }
+
+ private FileNameservice m_fns = new FileNameservice();
+}
Modified: trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/LocalServiceProfile.java
===================================================================
--- trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/LocalServiceProfile.java 2012-01-10 05:48:31 UTC (rev 628)
+++ trunk/jp.go.aist.rtm.RTC/src/jp/go/aist/rtm/RTC/LocalServiceProfile.java 2012-01-10 06:19:37 UTC (rev 629)
@@ -5,7 +5,7 @@
* {@.ja LocalServiceのプロファイルデータ}
* {@.en Profile data structure of LocalService}
*/
-public interface LocalServiceProfile {
+public class LocalServiceProfile {
/**
* {@.ja LocalServiceのサービス名}
* {@.en The name of LocalService}
openrtm-commit メーリングリストの案内