web文件管理器java,著名Web文件管理器elfinder的java servlet后端,支持自定义

elfinder是一款基于Web的文件浏览器前端,但一直缺乏比较好的Java后端代码。

本项目集成了elfinder的前端代码,并提供了一个基于Java的后端实现。

文件管理器支持文件的浏览、查看、搜索等操作。通过接口设计,开发者可根据具体的情况模拟文件目录。

what's elfinder-2.x-servlet

elfinder-2.x-servlet implements a java servlet for elfinder-2.x connector

elfinder is an Open-source file manager for web, written in JavaScript using jQuery and jQuery UI. see also http://elfinder.org

0818b9ca8b590ca3270a3433284dd417.png

0818b9ca8b590ca3270a3433284dd417.png

importing elfinder-2.x-servlet

this project is released as an artifact on the central repostory

use

com.github.bluejoe2008

elfinder-servlet-2

1.1

classes

to add dependency in your pom.xml

building elfinder-2.x-servlet

the source files includes:

src/main/webapp : a normal j2ee application includes elfinder, WEB-INF...

src/main/java: source codes for elfinder-servlet

src/main/resources: source codes for elfinder-servlet

To build this project with maven run:

mvn install

to run this project within a jetty container use:

mvn jetty:run

using elfinder-2.x-servlet in your web apps

just use following codes to tell elfinder to connect with server-side servlet:

$(document).ready(function() {

$('#elfinder').elfinder({

url : 'elfinder-servlet/connector',

});

});

in your web.xml, following codes should be added to enable the servlet:

elfinder

org.springframework.web.servlet.DispatcherServlet

elfinder

/elfinder-servlet/*

yes! elfinder-2.x-servlet is developed upon SpringFramework (http://springframework.org)

an example elfinder-servlet.xml configuration is shown below:

class="cn.bluejoe.elfinder.controller.executor.DefaultCommandExecutorFactory">

value="cn.bluejoe.elfinder.controller.executors.%sCommandExecutor" />

A ConnectorServlet is provided for people who do not use spring framework:

elfinder-connector-servlet

cn.bluejoe.elfinder.servlet.ConnectorServlet

elfinder-connector-servlet

/elfinder-servlet/connector

If you want to customize behavior of ConnectorServlet(see https://github.com/bluejoe2008/elfinder-2.x-servlet/blob/0.9/src/main/java/cn/bluejoe/elfinder/servlet/ConnectorServlet.java), you may need to create a derivided servlet class based on ConnectorServlet.

features

easy to use: just define a servlet in your web.xml, or configure the XML file in spring IOC format, and then start your web application

easy to import: an artifact on the central repostory is provided, use maven to manage the dependency

logic file views: a local file system is not necessary, you can define your FsService

easy to personalize: different file views are allowed for different users, just provide a custom FsServiceFactory

easy to modify and extend: provide your own CommandExecutors to respond new commands

Command, CommandExecutor, CommandExecutorManager

elfinder-2.x-servlet implements file management commands including:

DIM

DUPLICATE

FILE

GET

LS

MKDIR

MKFILE

OPEN

PARENT

PASTE

PUT

RENAME

RM

SEARCH

SIZE

TMB

TREE

UPLOAD(CHUNK supported!!!)

Each command corresponds to a CommandExecutor class, for example, the TREE command is implemented by the class TreeCommandExecutor(see https://github.com/bluejoe2008/elfinder-2.x-servlet/src/main/java/cn/bluejoe/elfinder/controller/executors/TreeCommandExecutor.java). Users can modify existing class or entend new executor class by following this naming rule.

Furthermore, this rule can even be modified via setting the commandExecutorFactory in elfinder-servlet.xml, in which default factory is DefaultCommandExecutorFactory(see https://github.com/bluejoe2008/elfinder-2.x-servlet/src/main/java/cn/bluejoe/elfinder/controller/executor/DefaultCommandExecutorFactory.java). A CommandExecutorFactory tells how to locate the command executor(TreeCommandExecutor as an example) by a given command name("TREE" as an example), it is designed as an interface:

public interface CommandExecutorFactory

{

CommandExecutor get(String commandName);

}

FsItem, FsVolume, FsService, FsServiceFactory

Each file is represented as a FsItem. And the root of a file is represented as a FsVolume. A FsVolume tells parent-children relations between all FsItems and implements all file operation (for example, create/delete).

A FsService may have many FsVolumes. Users can create a FsService via a FsServiceFactory:

public interface FsServiceFactory

{

FsService getFileService(HttpServletRequest request, ServletContext servletContext);

}

A simple (and stupid) StaticFsServiceFactory is provided in https://github.com/bluejoe2008/elfinder-2.x-servlet/src/main/java/cn/bluejoe/elfinder/impl/StaticFsServiceFactory.java, which always returns a fixed FsService, despite of whatever it is requested. However, sometimes a FsService should be constructed dynamically according to current Web request. For example, users may own separated file spaces in a network disk service platform, in this case, getFileService() get user principal from current request and offers him/her different file view.

Making a release

For a developer to make a release they need to have setup an account and with Sonatype and have a PGP key for signing the release more details can be found at: http://central.sonatype.org/pages/apache-maven.html

Then to make a release you first tag the version and push this to github:

mvn release:clean release:prepare

and if everything goes ok you can then release the actual artifact based on the tag:

mvn release:perform

This will stage the artifacy on the Sonatype servers, once there it will be checked and it it's ok you can then release it: http://central.sonatype.org/pages/releasing-the-deployment.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值