sakai和jcloud操作流程

https://github.com/botimer/sakai/tree/master/cloud-content


这里为sakai新建了一种资源,叫做swift文件处理器。用于将文件保存到云中。

1 实现

/**
* The cloud implementation of FileSystemHandler.
* <p/>
* This class read and write files to and from OpenStack-Swift cloud storage.
*
* @author OpenCollab
*/
public class SwiftFileSystemHandler implements FileSystemHandler {

这个类重载接口,并实现了文件的存、取、关、开。

2 打包依赖(impl pom)

<!-- jclouds dependencies -->
<!-- Package these directly in the impl/component -->
<dependency>
<groupId>org.apache.jclouds.driver</groupId>
<artifactId>jclouds-slf4j</artifactId>
<version>${jclouds.version}</version>
<exclusions>
<exclusion>
<groupId>aopalliance</groupId>
<artifactId>aopalliance</artifactId>
</exclusion>
</exclusions>
</dependency>


3 定义bean实体

<!-- These beans are lazy inited as they won't startup unless correctly configured -->
<bean id="org.sakaiproject.content.api.FileSystemHandler.swift" class="coza.opencollab.sakai.cloudcontent.SwiftFileSystemHandler"
init-method="init" destroy-method="destroy" lazy-init="true">
</bean>

4 定义pack (pack pom)

 
<name>Sakai Cloud Resources Components</name>
<groupId>org.sakaiproject.content</groupId>
<artifactId>cloud-content-pack</artifactId>
 
<packaging>sakai-component</packaging>
<properties>
<deploy.target>components</deploy.target>
</properties>
<dependencies>
<dependency>
<groupId>org.sakaiproject.content</groupId>
<artifactId>cloud-content-impl</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>


在使用的时候使用方法

5 定义使用该类替代传统的文件处理 sakai-configuration.xml


<beans>
  <!-- Swift handler -->
  <alias name="org.sakaiproject.content.api.FileSystemHandler.swift" alias="org.sakaiproject.content.api.FileSystemHandler" />

  <!-- Generic BlobStore handler, currently only for AWS S3 -->
  <!-- <alias name="org.sakaiproject.content.api.FileSystemHandler.blobstore" alias="org.sakaiproject.content.api.FileSystemHandler" /> -->
</beans>

6 定义实现中的一些值的属性

[email protected]     = http://swift.server:5000/v2.0/
[email protected]     = tenant:username
[email protected]   = password
[email protected]       = RegionOne
useIdForPath@org.sakaiproject.content.api.FileSystemHandler.swift = true

provider@org.sakaiproject.content.api.FileSystemHandler.blobstore      = aws-s3
identity@org.sakaiproject.content.api.FileSystemHandler.blobstore      = <S3 Access Key ID>
credential@org.sakaiproject.content.api.FileSystemHandler.blobstore    = <S3 Secret Access Key>
baseContainer@org.sakaiproject.content.api.FileSystemHandler.blobstore = your-bucket-name
useIdForPath@org.sakaiproject.content.api.FileSystemHandler.blobstore  = true

[email protected]=/content/live/
bodyPathDeleted@org.sakaiproject.content.api.ContentHostingService=/content/deleted/

例如region对应实现里面的

/**
* The region to connect to.
*/
public void setRegion(String region) {
this.region = region;
}


你可能感兴趣的:(sakai和jcloud操作流程)