package helloworld.impl;
import commonj.sdo.helper.HelperContext;
import org.apache.tuscany.sdo.helper.HelperContextImpl;
import org.apache.tuscany.sdo.helper.TypeHelperImpl;
import commonj.sdo.DataObject;
import commonj.sdo.Property;
import commonj.sdo.Type;
import helloworld.*;
import helloworld.type.TypeFactory;
import helloworld.type.impl.TypeFactoryImpl;
import org.apache.tuscany.sdo.impl.FactoryBase;
import org.apache.tuscany.sdo.model.ModelFactory;
import org.apache.tuscany.sdo.model.impl.ModelFactoryImpl;
public class HelloworldFactoryImpl extends FactoryBase implements HelloworldFactory
{
public static final String NAMESPACE_URI = "http://helloworld";
public static final String NAMESPACE_PREFIX = "tns";
public static final String PATTERN_VERSION = "1.2";
public static final int GET_GREETINGS = 1;
public static final int GET_GREETINGS_RESPONSE = 2;
public static final int PARTY = 3;
public static final int PERSON = 4;
public HelloworldFactoryImpl()
{
super(NAMESPACE_URI, NAMESPACE_PREFIX, "helloworld");
}
public void register(HelperContext scope)
{
if(scope == null) {
throw new IllegalArgumentException("Scope can not be null");
}
if (((HelperContextImpl)scope).getExtendedMetaData().getPackage(NAMESPACE_URI) != null)
return;
// Register this package with provided scope
((HelperContextImpl)scope).getExtendedMetaData().putPackage(NAMESPACE_URI, this);
//Register dependent packages with provided scope
ModelFactory.INSTANCE.register(scope);
TypeFactory.INSTANCE.register(scope);
}
public DataObject create(int typeNumber)
{
switch (typeNumber)
{
case GET_GREETINGS: return (DataObject)creategetGreetings();
case GET_GREETINGS_RESPONSE: return (DataObject)creategetGreetingsResponse();
case PARTY: return (DataObject)createParty();
case PERSON: return (DataObject)createPerson();
default:
return super.create(typeNumber);
}
}
public getGreetings creategetGreetings()
{
getGreetingsImpl getGreetings = new getGreetingsImpl();
return getGreetings;
}
public getGreetingsResponse creategetGreetingsResponse()
{
getGreetingsResponseImpl getGreetingsResponse = new getGreetingsResponseImpl();
return getGreetingsResponse;
}
public Party createParty()
{
PartyImpl party = new PartyImpl();
return party;
}
public Person createPerson()
{
PersonImpl person = new PersonImpl();
return person;
}
// Following creates and initializes SDO metadata for the supported types.
protected Type getGreetingsType = null;
public Type getgetGreetings()
{
return getGreetingsType;
}
protected Type getGreetingsResponseType = null;
public Type getgetGreetingsResponse()
{
return getGreetingsResponseType;
}
protected Type partyType = null;
public Type getParty()
{
return partyType;
}
protected Type personType = null;
public Type getPerson()
{
return personType;
}
private static HelloworldFactoryImpl instance = null;
public static HelloworldFactoryImpl init()
{
if (instance != null ) return instance;
instance = new HelloworldFactoryImpl();
// Create package meta-data objects
instance.createMetaData();
// Initialize created meta-data
instance.initializeMetaData();
// Mark meta-data to indicate it can't be changed
//theHelloworldFactoryImpl.freeze(); //FB do we need to freeze / should we freeze ????
return instance;
}
private boolean isCreated = false;
public void createMetaData()
{
if (isCreated) return;
isCreated = true;
// Create types and their properties
getGreetingsType = createType(false, GET_GREETINGS);
createProperty(false, getGreetingsType,getGreetingsImpl._INTERNAL_PARTY);
getGreetingsResponseType = createType(false, GET_GREETINGS_RESPONSE);
createProperty(true, getGreetingsResponseType,getGreetingsResponseImpl._INTERNAL_GET_GREETINGS_RETURN);
partyType = createType(false, PARTY);
createProperty(false, partyType,PartyImpl._INTERNAL_PEOPLE);
personType = createType(false, PERSON);
createProperty(true, personType,PersonImpl._INTERNAL_LAST_NAME);
}
private boolean isInitialized = false;
public void initializeMetaData()
{
if (isInitialized) return;
isInitialized = true;
// Obtain other dependent packages
ModelFactoryImpl theModelPackageImpl = (ModelFactoryImpl)ModelFactoryImpl.init();
TypeFactoryImpl theTypePackageImpl = (TypeFactoryImpl)TypeFactoryImpl.init();
Property property = null;
// Add supertypes to types
addSuperType(personType, theTypePackageImpl.getPerson_Base());
// Initialize types and properties
initializeType(getGreetingsType, getGreetings.class, "getGreetings", false);
property = getLocalProperty(getGreetingsType, 0);
initializeProperty(property, this.getParty(), "party", null, 1, 1, getGreetings.class, false, true, false, true , null);
initializeType(getGreetingsResponseType, getGreetingsResponse.class, "getGreetingsResponse", false);
property = getLocalProperty(getGreetingsResponseType, 0);
initializeProperty(property, theModelPackageImpl.getString(), "getGreetingsReturn", null, 1, 1, getGreetingsResponse.class, false, true, false);
initializeType(partyType, Party.class, "Party", false);
property = getLocalProperty(partyType, 0);
initializeProperty(property, this.getPerson(), "people", null, 1, -1, Party.class, false, false, false, true , null);
initializeType(personType, Person.class, "Person", false);
property = getLocalProperty(personType, 0);
initializeProperty(property, theModelPackageImpl.getString(), "lastName", null, 1, 1, Person.class, false, true, false);
createXSDMetaData(theModelPackageImpl, theTypePackageImpl);
}
protected void createXSDMetaData(ModelFactoryImpl theModelPackageImpl, TypeFactoryImpl theTypePackageImpl)
{
super.initXSD();
Property property = null;
property = createGlobalProperty
("getGreetings",
this.getgetGreetings(),
new String[]
{
"kind", "element",
"name", "getGreetings",
"namespace", "##targetNamespace"
});
property = createGlobalProperty
("getGreetingsResponse",
this.getgetGreetingsResponse(),
new String[]
{
"kind", "element",
"name", "getGreetingsResponse",
"namespace", "##targetNamespace"
});
addXSDMapping
(getGreetingsType,
new String[]
{
"name", "getGreetings_._type",
"kind", "elementOnly"
});
addXSDMapping
(getLocalProperty(getGreetingsType, 0),
new String[]
{
"kind", "element",
"name", "party",
"namespace", "##targetNamespace"
});
addXSDMapping
(getGreetingsResponseType,
new String[]
{
"name", "getGreetingsResponse_._type",
"kind", "elementOnly"
});
addXSDMapping
(getLocalProperty(getGreetingsResponseType, 0),
new String[]
{
"kind", "element",
"name", "getGreetingsReturn",
"namespace", "##targetNamespace"
});
addXSDMapping
(partyType,
new String[]
{
"name", "Party",
"kind", "elementOnly"
});
addXSDMapping
(getLocalProperty(partyType, 0),
new String[]
{
"kind", "element",
"name", "people",
"namespace", "##targetNamespace"
});
addXSDMapping
(personType,
new String[]
{
"name", "Person",
"kind", "elementOnly"
});
addXSDMapping
(getLocalProperty(personType, 0),
new String[]
{
"kind", "element",
"name", "lastName",
"namespace", "##targetNamespace"
});
}
}
没有合适的资源?快使用搜索试试~ 我知道了~
SCA与SDO结合示例
共70个文件
class:17个
java:17个
svn-base:12个
5星 · 超过95%的资源 需积分: 3 35 下载量 153 浏览量
2010-06-27
17:09:45
上传
评论
收藏 50KB RAR 举报
温馨提示
一个可运行的web项目,包括SDO对象的创建、SDO对象在SCA组件中传输的示例,示例很好地展示了SDO与SCA的结合。 注,SDO使用2.1版本,项目中不包含依赖的jar,可以讲SDO-2.1版本中的jar拷贝到web项目中。
资源推荐
资源详情
资源评论
收起资源包目录
helloworld-ws-sdo.rar (70个子文件)
helloworld-ws-sdo
src
helloworldws.composite 2KB
helloworld
HelloWorld.java 462B
getGreetingsResponse.java 306B
HelloWorldComponent.java 581B
HelloworldFactory.java 2KB
getGreetings.java 236B
impl
PartyImpl.java 2KB
HelloworldFactoryImpl.java 8KB
PersonImpl.java 3KB
getGreetingsImpl.java 6KB
getGreetingsResponseImpl.java 5KB
Person.java 2KB
Party.java 165B
type
impl
TypeFactoryImpl.java 4KB
Person_BaseImpl.java 3KB
TypeFactory.java 337B
Person_Base.java 238B
HelloWorldImpl.java 827B
.svn
all-wcprops 734B
props
prop-base
HelloWorld.java.svn-base 65B
HelloWorldComponent.java.svn-base 65B
HelloWorldImpl.java.svn-base 65B
tmp
props
prop-base
text-base
text-base
HelloWorld.java.svn-base 1KB
HelloWorldComponent.java.svn-base 1KB
HelloWorldImpl.java.svn-base 2KB
entries 772B
wsdl
helloworld.wsdl 4KB
helloworld.xsd 1KB
.classpath 492B
build
.settings
org.eclipse.wst.jsdt.ui.superType.container 49B
org.eclipse.wst.common.project.facet.core.xml 229B
org.eclipse.jst.common.project.facet.core.prefs 217B
org.eclipse.wst.jsdt.ui.superType.name 6B
org.eclipse.wst.common.component 571B
.jsdtscope 454B
org.eclipse.jdt.core.prefs 330B
WebContent
META-INF
MANIFEST.MF 71B
sca-contribution.xml 1KB
wsdl
HelloWorld.jsp 1024B
WEB-INF
classes
helloworldws.composite 2KB
helloworld
Party.class 171B
HelloWorldComponent.class 1KB
HelloworldFactory.class 697B
impl
getGreetingsResponseImpl.class 3KB
PersonImpl.class 3KB
getGreetingsImpl.class 4KB
PartyImpl.class 3KB
HelloworldFactoryImpl.class 7KB
getGreetings.class 283B
HelloWorld.class 255B
HelloWorldImpl.class 2KB
getGreetingsResponse.class 351B
type
Person_Base.class 302B
impl
TypeFactoryImpl.class 4KB
Person_BaseImpl.class 3KB
TypeFactory.class 523B
Person.class 290B
.svn
all-wcprops 734B
props
prop-base
HelloWorld.java.svn-base 65B
HelloWorldComponent.java.svn-base 65B
HelloWorldImpl.java.svn-base 65B
tmp
props
text-base
HelloWorld.java.svn-base 1KB
HelloWorldComponent.java.svn-base 1KB
HelloWorldImpl.java.svn-base 2KB
entries 772B
wsdl
helloworld.wsdl 4KB
helloworld.xsd 1KB
geronimo-web.xml 2KB
lib
web.xml 2KB
.project 1KB
共 70 条
- 1
资源评论
- HUST_XPU2012-11-30有SDO的创建和传输等示例,比较有用
- haberKong2013-03-06新项目准备采用SCA技术,希望有帮助,谢谢
ma_liang
- 粉丝: 16
- 资源: 9
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功