[ADOS] ADOS Developer's Site - XML Stadium
ADOS Company slogan - XML Total Solution

目次||

目次

概要

【PIPSenderStoredMap.java】

1 : import java.io.File;
2 : import java.io.FileInputStream;
3 : import java.util.Date;
4 : import java.util.Properties;
5 : 
6 : import com.ados.hestia.mapping.Translator;
7 : import com.ados.hestia.mapping.TranslatorFactory;
8 : import com.ados.hestia.parser.rnbm.access.Validator;
9 : import com.ados.hestia.parser.rnbm.exchange.Container;
10 : import com.ados.hestia.parser.rnbm.exchange.PayloadContainer;
11 : import com.ados.hestia.parser.rnbm.exchange.StatusContainer;
12 : import com.ados.hestia.parser.rnbm.particle.ServiceContent;
13 : import com.ados.hestia.repository.MapRuleStore;
14 : import com.ados.hestia.repository.Mapping;
15 : import com.ados.hestia.sdk.Configuration;
16 : import com.ados.hestia.sdk.Connection;
17 : import com.ados.hestia.sdk.message.DirectMessageExchanger;
18 : import com.ados.hestia.sdk.session.InitiationSession;
19 : import com.ados.hestia.sdk.session.Session;
20 : import com.ados.hestia.utils.UID;
21 : 
22 : public class PIPSenderStoredMap {
23 : 
24 :   public static void main(String[] args) {
25 :     try {
26 :       String mapid = args[0];
27 :       String xml = args[1];
28 : 
29 :       Properties prop = new Properties();
30 :       prop.load(new FileInputStream("sample.properties"));
31 :       String HOST = prop.getProperty("HOST");
32 :       String USER = prop.getProperty("USER");
33 :       String PASS = prop.getProperty("PASS");
34 :       String HANDLER_ID = prop.getProperty("HANDLER_ID");
35 : 
36 :       Connection connection = new Connection(HOST, USER, PASS,
37 :           Connection.EXCHANGE_MODE_DIRECT, null, null, null,
38 :           HANDLER_ID);
39 :       DirectMessageExchanger exchanger = new DirectMessageExchanger(
40 :           connection, Configuration.getInstance());
41 : 
42 :       MapRuleStore store = new MapRuleStore(System
43 :           .getProperty("user.dir")
44 :           + File.separator, "mapRule");
45 :       SampleUtils.println("Mapping :" + store.size());
46 :       Mapping mapping = store.getMapping(mapid);
47 :       store.fillMappingBaseDir(mapping);
48 :       SampleUtils.println("Mapping :" + mapping.toString());
49 :       TranslatorFactory factory = new TranslatorFactory();
50 :       Translator translator = factory.newTranslator(mapping);
51 :       translator.setTargetDocument(new FileInputStream(xml));
52 :       translator.translate();
53 :       ServiceContent sc = translator.getResultAsServiceContent();
54 : 
55 :       Session session = new InitiationSession(new PayloadContainer(
56 :           new Date(), sc.getFromRole()
57 :               .getGlobalBusinessIdentifierNorm(), sc.getToRole()
58 :               .getGlobalBusinessIdentifierNorm(), (new UID())
59 :               .toString(), sc, null));
60 :       SampleUtils.printSessionState("created", session);
61 :       PayloadContainer request = session.getMessageToSend();
62 :       SampleUtils.printSessionState("got", session);
63 :       SampleUtils.printContainerInformation(request);
64 :       SampleUtils.printServiceContent(request.getServiceContent());
65 :       new Validator(request.getServiceContent().getElement()).validate();
66 :       exchanger.sendMessage(request);
67 :       SampleUtils.printSessionState("sent", session);
68 : 
69 :       int time = 0;
70 :       boolean loop = true;
71 :       while (loop) {
72 :         Thread.sleep(5000);
73 :         exchanger.hit();
74 :         SampleUtils.printSessionState("loop=" + time++, session);
75 : 
76 :         Container container = exchanger.receiveMessage();
77 :         if (container != null) {
78 :           SampleUtils.printContainerInformation(container);
79 :           session.pushStatus((StatusContainer) container);
80 :           SampleUtils.printSessionState("pushed", session);
81 :           loop = false;
82 :         }
83 :       }
84 : 
85 :     } catch (Exception e) {
86 :       e.printStackTrace();
87 :     }
88 :   }
89 : 
90 : }

トップ   一覧 単語検索 最終更新   ヘルプ   最終更新のRSS

Copyright 2005-2008. ADOS Co., Ltd. All Rights Reserved.