-
Notifications
You must be signed in to change notification settings - Fork 4
/
EObjectTypeFactory.java
75 lines (69 loc) · 2.47 KB
/
EObjectTypeFactory.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
/*******************************************************************************
* Copyright (c) 2008-2011 Chair for Applied Software Engineering,
* Technische Universitaet Muenchen.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* wesendon
******************************************************************************/
package org.eclipse.emf.emfstore.internal.server.connection.xmlrpc.util;
import org.apache.ws.commons.util.NamespaceContextImpl;
import org.apache.xmlrpc.common.TypeFactoryImpl;
import org.apache.xmlrpc.common.XmlRpcController;
import org.apache.xmlrpc.common.XmlRpcStreamConfig;
import org.apache.xmlrpc.parser.TypeParser;
import org.apache.xmlrpc.serializer.TypeSerializer;
import org.eclipse.emf.ecore.EObject;
import org.eclipse.emf.emfstore.internal.server.filetransfer.FileChunk;
import org.eclipse.emf.emfstore.internal.server.filetransfer.FileTransferInformation;
import org.xml.sax.SAXException;
/**
* Type Factory for XML RPC Transportation.
*
* @author wesendon
*/
public class EObjectTypeFactory extends TypeFactoryImpl {
/**
* Default constructor.
*
* @param pController
* XML RPC controller.
*/
public EObjectTypeFactory(XmlRpcController pController) {
super(pController);
}
/**
* {@inheritDoc}
*/
@Override
public TypeParser getParser(XmlRpcStreamConfig pConfig, NamespaceContextImpl pContext, String pURI,
String pLocalName) {
if (EObjectSerializer.EOBJECT_TAG.equals(pLocalName)) {
return new EObjectDeserializer();
}
if (FileTransferInformationSerializer.FTI_TAG.equals(pLocalName)) {
return new FileTransferInformationParser();
}
final TypeParser parser = super.getParser(pConfig, pContext, pURI, pLocalName);
if (parser instanceof org.apache.xmlrpc.parser.SerializableParser) {
throw new IllegalArgumentException("A SerializableParser is not supported"); //$NON-NLS-1$
}
return parser;
}
/**
* {@inheritDoc}
*/
@Override
public TypeSerializer getSerializer(XmlRpcStreamConfig pConfig, Object pObject) throws SAXException {
if (pObject instanceof EObject) {
return new EObjectSerializer();
}
if (pObject instanceof FileTransferInformation || pObject instanceof FileChunk) {
return new FileTransferInformationSerializer();
}
return super.getSerializer(pConfig, pObject);
}
}