`
uule
  • 浏览: 6351505 次
  • 性别: Icon_minigender_1
  • 来自: 一片神奇的土地
社区版块
存档分类
最新评论

CDO框架架构

 
阅读更多

架构:

1、监听器WebApplicationListener 启动时,读取servicebus.xml内容,转化为String型

 

public void contextInitialized(ServletContextEvent arg0)
	{
		BusinessService app = BusinessService.getInstance();
		Return	ret = app.start();
		...
	}

 

public class BusinessService
{
	//静态对象
	private static BusinessService instance=new BusinessService();

	private BusinessService()
	{		
		serviceBus=new ServiceBus();
	}
	
	public static BusinessService getInstance()
	{//使用单列
		return instance;
	}

	//内部对象
	private ServiceBus serviceBus;	
	private boolean bIsRunning;
	
	public IServiceBus getServiceBus()
	{
		return this.serviceBus;
	}	
	
	public boolean isRunning()
	{
		return this.bIsRunning;
	}

	public Return start()
	{
		return start("servicebus.xml","UTF-8");
	}
	public Return start(String strServiceBusXMLFile,String encoding)
	{
		if(this.bIsRunning==true)
		{
			return Return.OK;
		}

		//将servicebus.xml内容解析为字符串
		String strBusinessServiceBusXML=Utility.readTextResource(strServiceBusXMLFile,encoding);
		Return ret=serviceBus.init(strBusinessServiceBusXML);
		if(ret.getCode()!=0)
		{
			return ret;
		}
		
		ret=serviceBus.start();
		if(ret.getCode()!=0)
		{
			serviceBus.destroy();
			return ret;
		}
		
		this.bIsRunning=true;

		return Return.OK;
	}
	public void stop()
	{
		if(this.bIsRunning==false)
		{
			return;
		}
		serviceBus.stop();
		serviceBus.destroy();
		
		this.bIsRunning=false;
	}

	public Return handleTrans(CDO cdoRequest,CDO cdoResponse)
	{
		Return ret=serviceBus.handleTrans(cdoRequest,cdoResponse);
		if(ret==null)
		{
			return Return.valueOf(-1,"Invalid request","System.Error");
		}
		
		return ret;
	}
	
	
}

 

 

start("servicebus.xml","UTF-8");

String strBusinessServiceBusXML=Utility.readTextResource(strServiceBusXMLFile,encoding);

InputStreamInputStreamReaderBufferReader  readLine

 

Return ret=serviceBus.init(strBusinessServiceBusXML);

 

 

2、serviceBus.init(strBusinessServiceBusXML) 方法

 

a、先解析XML内容字符串并转换为ServiceBus 对象

 

//使用castor将XML数据转换为业务对象  	
	
	public static ServiceBus fromXML(String strXML)  {
		StringReader reader = null;
		try	{
			  reader = new StringReader(strXML);
			  ServiceBus serviceBus = unmarshal(reader);
			  return serviceBus;
		}
		finally{ }	
	}

	public static ServiceBus unmarshal(Reader reader) {
		return (ServiceBus)Unmarshaller.unmarshal(ServiceBus.class, reader);
	}

 

 

b、从ServiceBus 对象中获取各配置项,同时解析赋值到对应的Map对象或其他对象中

 

this.strDefaultDataGroupId = serviceBus.getDataGroupId();
	 
	this.hmDataGroup = new HashMap(20);
	DataGroup[] dgs = serviceBus.getDataGroup();
	try
	{
	  for (int i = 0; i < dgs.length; i++)
	  {
		  /* DataGroup中init()方法
		  * 每一个DataGroup中有多个Database,每一个Database中有一个IDataEngine,
		  * 在IDataEngine中填充各数据库连接属性并打开连接
		  */
		CycleList clDataEngine = dgs[i].init();
		this.hmDataGroup.put(dgs[i].getId(), clDataEngine);
	  }
	}
	catch (Exception e)
	{
	  this.hmDataGroup.clear();
	  this.hmDataGroup = null;
	  this.logger.error("When parse DataGroup , caught exception: ", e);
	  return Return.valueOf(-1, "Init ServiceBus Failed: " + e.getLocalizedMessage());
	}

	
	//分别解析Plugin.xml文件
	int nPluginCount = serviceBus.getPluginXMLResourceCount();
    this.plugins = new ServicePlugin[nPluginCount];
    try
    {
      for (int i = 0; i < nPluginCount; i++)
      {
		//<PluginXMLResource>com/service/mobile/Plugin.xml</PluginXMLResource>标签中间的内容,即文件名
        String strXMLResource = serviceBus.getPluginXMLResource(i);
        if (this.logger.isInfoEnabled()) this.logger.info("loading " + strXMLResource + "..............................");
		
		//将各Plugin.xml文件内容解析为字符串
        String strXML = Utility.readTextResource(strXMLResource, "utf-8");
        if (strXML == null)
        {
          throw new Exception("Resource " + strXMLResource + " invalid");
        }
		
		//解析Plugin.xml内容为对应的ServicePlugin对象(同上方的解析为ServiceBus对象)
        com.cdoframework.cdolib.servicebus.schema.ServicePlugin servicePluginDefine = com.cdoframework.cdolib.servicebus.schema.ServicePlugin.fromXML(strXML);
        this.plugins[i] = new ServicePlugin();

        this.plugins[i].setServiceBus(this);
        this.plugins[i].setPublicDataGroup(this.hmDataGroup);
        this.plugins[i].setPublicNoSQLDataEngine(this.hmNoSQLDataEngine);
        this.plugins[i].init(i, this, servicePluginDefine);
      }
    }
    catch (Exception e)
    {
      this.plugins = null;

      this.logger.error("when parse plugin ,caught Exception: ", e);
      return Return.valueOf(-1, "Init ServiceBus Failed: " + e.getLocalizedMessage());
    }

 

 

 

各文件摘要:

 

Plugin.xml:

 

<?xml version="1.0" encoding="UTF-8"?>
<ServicePlugin xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../../../../../../Design/ServiceBus.xsd">
	<ServiceConfig Id="ActivityService"/>
	<DataService Id="ActivityService" Resource="com/service/activity/ActivitySQLTrans.xml"/>
	<TransService Id="ActivityService"  ClassPath="com.service.activity.ActivityService" />
		
	<ServiceConfig Id="WxActivityService"/>
	<DataService Id="WxActivityService" Resource="com/service/activity/WxActivitySQLTrans.xml"/>
	<TransService Id="WxActivityService"  ClassPath="com.service.activity.WxActivityService" />
	...	
</ServicePlugin>

 

 

servicebus.xml内容摘要:

 

<?xml version="1.0" encoding="utf-8"?>
<ServiceBus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Design/ServiceBus.xsd"
		DataGroupId="writeMall" NoSQLDBId="mainId">
		
		<!-- 多个dataGroup-->
		<DataGroup Weight="0" Num="1" Id="write0" ClassPath="com.lepus.businessCenter.DataEngine" Driver="com.mysql.jdbc.Driver" Charset="gbk">
			<Database URI="jdbc:mysql://192.168.3.230:3306/1more" LoadLevel="100">
				<User UserName="root" Password="123456"/>
				<ConnectionPool>
					<MaxConnectionsPerPartition>2</MaxConnectionsPerPartition>
					<MinConnectionsPerPartition>2</MinConnectionsPerPartition>
					<AcquireIncrement>2</AcquireIncrement>
					<ReleaseHelperThreads>2</ReleaseHelperThreads>
					<ConnectionTimeout>2000</ConnectionTimeout>
					<PartitionCount>2</PartitionCount>
				</ConnectionPool>
			</Database>
		</DataGroup>
		
		<!-- 多个PluginXMLResource-->		
		<PluginXMLResource>com/service/product/Plugin.xml</PluginXMLResource>
		<PluginXMLResource>com/service/platform/Plugin.xml</PluginXMLResource>
	
		<!-- 系统服务器,缓存,filter等等-->
		<EventProcessor MaxIdelTreadCount="3" MaxThreadCount="50" MaxWaitEventCount="1000" MinThreadCount="3"></EventProcessor>
		
		...
</ServiceBus>

 

 

 

ServiceBus.java:

 

//有多个的为ArrayList对象(_dataGroupList等),单个的为字符串(_noSQLDBId)或其他对象(EventProcessor)

	package com.cdoframework.cdolib.servicebus.schema;

	import java.io.IOException;
	import java.io.Reader;
	import java.io.Serializable;
	import java.io.StringReader;
	import java.io.Writer;
	import java.util.ArrayList;
	import java.util.Enumeration;
	import org.apache.log4j.Logger;
	import org.exolab.castor.util.IteratorEnumeration;
	import org.exolab.castor.xml.MarshalException;
	import org.exolab.castor.xml.Marshaller;
	import org.exolab.castor.xml.Unmarshaller;
	import org.exolab.castor.xml.ValidationException;
	import org.exolab.castor.xml.Validator;
	import org.xml.sax.ContentHandler;

	public class ServiceBus  implements Serializable
	{
	  private String _dataGroupId;
	  private String _noSQLDBId;
	  private ArrayList _parameterList;
	  private ArrayList _dataGroupList;
	  private ArrayList _noSQLDBList;
	  private ClusterController _clusterController;
	  private EventProcessor _eventProcessor;
	  private ArrayList _pluginXMLResourceList;
	  
	  public ServiceBus()
	  {
		this._parameterList = new ArrayList();
		this._dataGroupList = new ArrayList();
		this._noSQLDBList = new ArrayList();
		this._pluginXMLResourceList = new ArrayList();
	  }

	  public void addDataGroup(DataGroup vDataGroup)
			throws IndexOutOfBoundsException
	  {
		this._dataGroupList.add(vDataGroup);
	  }

	  public void addDataGroup(int index, DataGroup vDataGroup)
			throws IndexOutOfBoundsException
	  {
		this._dataGroupList.add(index, vDataGroup);
	  }

	  public void clearDataGroup()
	  {
		this._dataGroupList.clear();
	  }

	   public boolean removeDataGroup(DataGroup vDataGroup) {
			boolean removed = this._dataGroupList.remove(vDataGroup);
			return removed;
	  }

	  public void setEventProcessor(EventProcessor eventProcessor)
	  {
		this._eventProcessor = eventProcessor;
	  }
	  
	  public EventProcessor getEventProcessor()
	  {
		return this._eventProcessor;
	  }
	  
	  public String[] getPluginXMLResource()
	  {
		int size = this._pluginXMLResourceList.size();
		String[] mArray = new String[size];
		for (int index = 0; index < size; index++) {
		  mArray[index] = ((String)this._pluginXMLResourceList.get(index));
		}
		return mArray;
	  }
	  
	  public static ServiceBus unmarshal(Reader reader)
			throws MarshalException, ValidationException
	  {
		return (ServiceBus)Unmarshaller.unmarshal(ServiceBus.class, reader);
	  }
	  ...
	}

 

 

DataGroup.java:

 

public class DataGroup  implements Serializable
	{
	  private String _id;
	  private String _num;
	  private String _weight;
	  private String _driver;
	  private String _charset;
	  private String _classPath;
	  private ArrayList _databaseList;

	  public DataGroup()
	  {
		this._databaseList = new ArrayList();
	  }

	  public void addDatabase(Database vDatabase)
		throws IndexOutOfBoundsException  {
		this._databaseList.add(vDatabase);
	  }

	  public void addDatabase(int index, Database vDatabase)
		throws IndexOutOfBoundsException
	  {
		this._databaseList.add(index, vDatabase);
	  }

	  public Database getDatabase(int index)
		throws IndexOutOfBoundsException
	  {
		if ((index < 0) || (index >= this._databaseList.size())) {
		  throw new IndexOutOfBoundsException();
		}

		return (Database)this._databaseList.get(index);
	  }

	  public Database[] getDatabase()
	  {
		int size = this._databaseList.size();
		Database[] mArray = new Database[size];
		for (int index = 0; index < size; index++) {
		  mArray[index] = ((Database)this._databaseList.get(index));
		}
		return mArray;
	  }
	  
	   public static DataGroup unmarshal(Reader reader)
			throws MarshalException, ValidationException
	  {
		return (DataGroup)Unmarshaller.unmarshal(DataGroup.class, reader);
	  }

	  /*
	  * DataGroup中init()方法
	  * 每一个DataGroup中有多个Database,每一个Database中有一个IDataEngine,
	  * 在IDataEngine中填充各数据库连接属性并打开连接
	  */
	  public CycleList<IDataEngine> init()
		throws Exception
	  {
		Database[] dbs = getDatabase();

		CycleList clDataEngine = new CycleList();
		for (int i = 0; i < dbs.length; i++)
		{
		  IDataEngine dataEngine = (IDataEngine)Class.forName(getClassPath()).newInstance();
		  dataEngine.setNum(getNum());
		  dataEngine.setWeight(getWeight());
		  dataEngine.setDriver(getDriver());
		  dataEngine.setURI(dbs[i].getURI());
		  dataEngine.setCharset(getCharset());
		  dataEngine.setLoadLevel(dbs[i].getLoadLevel());
		  dataEngine.setUserName(dbs[i].getUser().getUserName());
		  dataEngine.setPassword(dbs[i].getUser().getPassword());

		  Properties properties = null;
		  int nPropertyCount = dbs[i].getPropertyCount();
		  if (nPropertyCount > 0)
		  {
			properties = new Properties();
			for (int j = 0; j < nPropertyCount; j++)
			{
			  Property proper = dbs[i].getProperty(j);
			  properties.setProperty(proper.getName(), proper.getValue());
			}
		  }
		  if (properties != null)
		  {
			dataEngine.setProperties(properties);
		  }

		  ConnectionPool connPool = dbs[i].getConnectionPool();
		  if (connPool != null)
		  {
			dataEngine.setAcquireIncrement(connPool.getAcquireIncrement());
			dataEngine.setMaxConnectionsPerPartition(connPool.getMaxConnectionsPerPartition());
			dataEngine.setMinConnectionsPerPartition(connPool.getMinConnectionsPerPartition());
			dataEngine.setPartitionCount(connPool.getPartitionCount());
			dataEngine.setReleaseHelperThreads(connPool.getReleaseHelperThreads());
			dataEngine.setConnectionTimeout(connPool.getConnectionTimeout());
		  }

		  Return ret = dataEngine.open();
		  if (ret.getCode() != 0)
		  {
			throw new Exception("Could not create JDBC connection " + dataEngine.getURI());
		  }

		  clDataEngine.add(dataEngine);
		}

		return clDataEngine;
	  }
	  ...
	}

 

 

Database.java:

public class Database  implements Serializable
	{
	  private String _URI;
	  private int _loadLevel;
	  private boolean _has_loadLevel;
	  private User _user;
	  private ArrayList _propertyList;
	  private ConnectionPool _connectionPool;

	  public Property getProperty(int index)
			throws IndexOutOfBoundsException
	  {
		if ((index < 0) || (index >= this._propertyList.size())) {
		  throw new IndexOutOfBoundsException();
		}

		return (Property)this._propertyList.get(index);
	  }

	  public Property[] getProperty()
	  {
		int size = this._propertyList.size();
		Property[] mArray = new Property[size];
		for (int index = 0; index < size; index++) {
		  mArray[index] = ((Property)this._propertyList.get(index));
		}
		return mArray;
	  }  

	  public void setProperty(int index, Property vProperty)
		throws IndexOutOfBoundsException
	  {
		if ((index < 0) || (index >= this._propertyList.size())) {
		  throw new IndexOutOfBoundsException();
		}
		this._propertyList.set(index, vProperty);
	  }

	  public void setProperty(Property[] propertyArray)
	  {
		this._propertyList.clear();
		for (int i = 0; i < propertyArray.length; i++)
		  this._propertyList.add(propertyArray[i]);
	  }

	   public static Database unmarshal(Reader reader)
			throws MarshalException, ValidationException
	  {
		return (Database)Unmarshaller.unmarshal(Database.class, reader);
	  }
	  ...
	}

 

Property.java:

public class Property  implements Serializable
	{
	  private String _name;
	  private String _value;

	  public static Property unmarshal(Reader reader)
			throws MarshalException, ValidationException
	  {
		return (Property)Unmarshaller.unmarshal(Property.class, reader);
	  }	  
	  ...
	}

 

 

ConnectionPool.java:

public class ConnectionPool  implements Serializable
	{
	  private int _maxConnectionsPerPartition = 2;
	  private boolean _has_maxConnectionsPerPartition;
	  private int _minConnectionsPerPartition = 2;
	  private boolean _has_minConnectionsPerPartition;
	  private int _acquireIncrement = 2;
	  private boolean _has_acquireIncrement;
	  private int _releaseHelperThreads = 3;
	  private boolean _has_releaseHelperThreads;
	  private long _connectionTimeout = 1000L;
	  private boolean _has_connectionTimeout;
	  private int _partitionCount = 2;
	  private boolean _has_partitionCount;

	  public void deleteAcquireIncrement()
	  {
		this._has_acquireIncrement = false;
	  }

	  public static ConnectionPool unmarshal(Reader reader)
			throws MarshalException, ValidationException
	  {
		return (ConnectionPool)Unmarshaller.unmarshal(ConnectionPool.class, reader);
	  }

	  ...
	}

 

 

 

 

 

 

 

分享到:
评论

相关推荐

    CDO Architecture

    CDO(Common Data Object)是一种在软件开发中用于处理数据对象的框架,它在分布式环境中提供了一种统一的数据访问接口。CDO全称是Eclipse Common Data Object,它是Eclipse Modeling Framework (EMF)项目的一部分,...

    cdo pricing

    5. **软件架构**:构建可扩展、模块化的软件架构,以便于维护和升级,同时满足高性能计算需求。 6. **Cygwin的使用**:熟练运用Cygwin提供的工具,如bash shell、make工具、版本控制系统(如Git)等,进行项目开发...

    数字化转型中的大数据治理架构

    工业园区通过构建“三库、三通、九枢纽”的信息化总体框架,将人口、法人信息等高关联度局办的信息纳入政务资源平台,极大地提升了政府服务的效率和质量。这表明,大数据治理架构有助于打破信息孤岛,实现数据的流通...

    制造业数字化转型的新运营架构.pdf

    最后,建立CDO+IT+OT的超级团队是实现运营架构转型的重要步骤。这个跨职能团队应专注于数据体验的开发,通过建立协作文化,促进不同部门之间的沟通和合作。 总的来说,制造业的数字化转型是一项系统工程,涉及战略...

    企业数据中台架构及应用技术解决方案共33页.ppt

    企业高层需从战略层面理解并支持数字化转型,包括设立以CEO、CIO、CTO、CDO等为核心的管理团队,建立完整的组织架构以支撑数据中台的运作。同时,组织内部需要配备相应的人力资源,培养数据人才,确保数据的管理、...

    数字化转型中的大数据治理架构.pdf

    随着企业对数据资产的重视,CDO办公室已成为许多企业组织架构的标准设置,负责协调整个企业的数据战略和管理。 总结来说,数字化转型中的大数据治理架构是企业适应快速变化的市场环境,实现高效运营和创新的关键。...

    企业数据中台技术架构及应用解决方案共33页.ppt

    企业需要从高层战略层面明确数字化转型的目标,这包括设立以CEO、CIO、CTO、CDO等为核心的数据管理团队,建立完善的数据组织架构,确保数据中台项目得到足够的重视和支持。此外,选择适合的一站式大数据平台工具是...

    数字化转型中的大数据治理架构.pptx

    苏州工业园区则在政务信息化规划中,建立了“三库、三通、九枢纽”的框架,实现政务信息共享,提升了公共服务的效率和质量。 大数据治理的关键技术主要包括数据采集、数据清洗、数据整合、数据分析和数据发布。其中...

    企业数据中台技术架构及应用解决方案共36页.pptx

    9. **技术架构统一**:核心技术架构与框架全国统一,打破“烟囱式”系统,实现业务全局共享和数据全局打通。通过技术架构分层,确保各层之间的调用关系清晰,形成统一的技术调用闭环。 10. **PAAS层能力**:地方...

    99-《2018国际研究机构数据安全治理框架解读》.pdf

    - **数据治理体系**:包括首席数据官(CDO)在内的数据管理团队,负责具体实施数据安全策略。 - **数据安全保护**:在整个数据生命周期中实施保护措施。 - **数据安全治理体系**:涵盖数据生命周期安全、数据通用安全...

    金融服务业首席数据官战略转型.docx

    CDO被赋予了统筹和治理关键数据资产的重任,需要对公司的核心业务、产品、客户和数据架构有全面的了解。随着时间的推移,CDO的角色逐渐扩展,不仅要管理数据,还要通过数据分析来驱动业务决策,甚至在某些机构中,...

    awesome-nocode:关于很棒的无代码的合集-为什么要编码? 我们去购物吧! 让我们购买程序,流程和敏捷方法。 关于首席数字官(CDO)clicky-clicky-clicky的梦想未来。 没有代码。 没有文字。 没有数字再见,代码猴子! 您好,业务架构师!

    关于首席数字官(CDO)clicky-clicky-clicky的梦想未来。 没有代码。 没有文字。 没有数字再见,代码猴子! 您好,业务架构师! 没有密码 ★19 551 by Kelsey Hightower-没有代码是编写安全可靠的应用程序的最佳...

    dama cdga 考试练习题(70题)

    4. BI(商业智能)架构师是一种混合角色,需要同时具备业务理解和技术能力,他们负责设计和实施数据驱动的决策支持系统。 5. 数据管理成熟度模型除了DAMA的知识体系外,还有CMMI的数据成熟度模型(DMM)、EDM委员会...

    SAS data governance framework

    数据治理框架的组件包括数据管理、数据架构、元数据、数据质量、数据生命周期、数据安全、数据治理方法和解决方案。 数据管理涉及对组织数据的综合策略,包括数据的收集、存储、保护、整合和使用。数据架构定义了...

    大数据技术就业岗位大盘点 .pdf

    首先,首席数据官(CDO)是企业的数据战略领导者,他们负责构建数据框架,管理数据资源,确保数据安全,并通过商务智能提升企业洞察力。CDO需要具备全面的技术知识和领导才能,以制定符合公司发展目标的数据策略。 ...

    大数据技术就业岗位大盘点 .docx

    数据架构师可为尖端的大数据解决方案提供根底,其职责包括使用 AWS,Azure 和 GoogleCloud 了解云中的数据存储和使用 Hadoop 或 NoSQL 设计根底架构数据库来管理非结构化数据。 数据科学家是“美国的最正确工作〞,...

Global site tag (gtag.js) - Google Analytics