Revision 1207,
1.4 KB
checked in by wojtekp, 11 years ago
(diff) |
|
-
Property svn:mime-type set to
text/plain
|
Line | |
---|
1 | package dcworms.schedframe.scheduling.utils; |
---|
2 | |
---|
3 | import java.io.StringReader; |
---|
4 | |
---|
5 | import org.exolab.castor.xml.MarshalException; |
---|
6 | import org.exolab.castor.xml.ResolverException; |
---|
7 | import org.exolab.castor.xml.Unmarshaller; |
---|
8 | import org.exolab.castor.xml.ValidationException; |
---|
9 | import org.exolab.castor.xml.XMLContext; |
---|
10 | |
---|
11 | import schedframe.DescriptionContainer; |
---|
12 | |
---|
13 | public class ApplicationProfileDescription implements DescriptionContainer<org.qcg.broker.schemas.jobdesc.Task>{ |
---|
14 | |
---|
15 | private static final long serialVersionUID = 7853990656207447619L; |
---|
16 | protected static Unmarshaller unmarshaller; |
---|
17 | static { |
---|
18 | XMLContext context = new XMLContext(); |
---|
19 | try { |
---|
20 | context.addClass(org.qcg.broker.schemas.jobdesc.Job.class); |
---|
21 | unmarshaller = context.createUnmarshaller(); |
---|
22 | } catch (ResolverException e) { |
---|
23 | e.printStackTrace(); |
---|
24 | unmarshaller = null; |
---|
25 | } |
---|
26 | } |
---|
27 | |
---|
28 | protected String xml; |
---|
29 | protected org.qcg.broker.schemas.jobdesc.Job app; |
---|
30 | |
---|
31 | public ApplicationProfileDescription(String xmlJobDesc){ |
---|
32 | xml = xmlJobDesc; |
---|
33 | } |
---|
34 | |
---|
35 | |
---|
36 | public org.qcg.broker.schemas.jobdesc.Task getDescription() { |
---|
37 | if(app == null){ |
---|
38 | try { |
---|
39 | app = (org.qcg.broker.schemas.jobdesc.Job) unmarshaller.unmarshal(new StringReader(xml)); |
---|
40 | } catch (MarshalException e) { |
---|
41 | e.printStackTrace(); |
---|
42 | } catch (ValidationException e) { |
---|
43 | e.printStackTrace(); |
---|
44 | } |
---|
45 | } |
---|
46 | return app.getTask(0); |
---|
47 | } |
---|
48 | |
---|
49 | public String getDocument() throws Exception { |
---|
50 | return xml; |
---|
51 | } |
---|
52 | |
---|
53 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.