use of javax.jcr.Repository in project jackrabbit by apache.
the class RepositoryStubImpl method getRepositoryService.
/**
*
* @return
* @throws RepositoryStubException
*/
public RepositoryService getRepositoryService() throws RepositoryStubException {
Repository jackrabbitRepo = super.getRepository();
// TODO: make configurable
BatchReadConfig brconfig = new BatchReadConfig();
brconfig.setDepth(NameConstants.NT_UNSTRUCTURED, BatchReadConfig.DEPTH_INFINITE);
return new RepositoryServiceImpl(jackrabbitRepo, brconfig);
}
use of javax.jcr.Repository in project jackrabbit by apache.
the class ServiceStubImpl method getRepositoryService.
public RepositoryService getRepositoryService() throws RepositoryException {
if (service == null) {
Repository repository;
try {
repository = RepositoryStub.getInstance(Collections.EMPTY_MAP).getRepository();
} catch (RepositoryStubException e) {
throw new RepositoryException(e);
}
service = new RepositoryServiceImpl(repository, new BatchReadConfig());
}
return service;
}
use of javax.jcr.Repository in project jackrabbit by apache.
the class Main method run.
public void run() throws Exception {
String defaultFile = "jackrabbit-standalone.jar";
URL location = Main.class.getProtectionDomain().getCodeSource().getLocation();
if (location != null && "file".equals(location.getProtocol())) {
File file = new File(location.getPath());
if (file.isFile()) {
defaultFile = location.getPath();
}
}
File file = new File(command.getOptionValue("file", defaultFile));
if (command.hasOption("help")) {
HelpFormatter formatter = new HelpFormatter();
formatter.printHelp("java -jar " + file.getName(), options, true);
} else if (command.hasOption("notice")) {
copyToOutput("/META-INF/NOTICE.txt");
} else if (command.hasOption("license")) {
copyToOutput("/META-INF/LICENSE.txt");
} else if (command.hasOption("cli")) {
System.setProperty("logback.configurationFile", "logback-cli.xml");
String uri = command.getOptionValue("cli");
Repository repository = JcrUtils.getRepository(uri);
Context context = new ContextBase();
CommandHelper.setRepository(context, repository, uri);
try {
Session session = repository.login();
CommandHelper.setSession(context, session);
CommandHelper.setCurrentNode(context, session.getRootNode());
} catch (RepositoryException ignore) {
// anonymous login not possible
}
new JcrClient(context).runInteractive();
try {
CommandHelper.getSession(context).logout();
} catch (CommandException ignore) {
// already logged out
}
} else {
message("Welcome to Apache Jackrabbit!");
message("-------------------------------");
File repository = new File(command.getOptionValue("repo", "jackrabbit"));
message("Using repository directory " + repository);
repository.mkdirs();
File tmp = new File(repository, "tmp");
tmp.mkdir();
File log = new File(repository, "log");
log.mkdir();
message("Writing log messages to " + log);
prepareServerLog(log);
if (command.hasOption("backup")) {
backup(repository);
} else {
message("Starting the server...");
prepareWebapp(file, repository, tmp);
accessLog.setHandler(webapp);
prepareAccessLog(log);
server.setHandler(accessLog);
prepareConnector();
server.addConnector(connector);
prepareShutdown();
try {
server.start();
String host = connector.getHost();
if (host == null) {
host = "localhost";
}
message("Apache Jackrabbit is now running at " + "http://" + host + ":" + connector.getPort() + "/");
} catch (Throwable t) {
System.err.println("Unable to start the server: " + t.getMessage());
System.exit(1);
}
}
}
}
use of javax.jcr.Repository in project jackrabbit by apache.
the class ConnectToJNDIServer method execute.
/**
* {@inheritDoc}
*/
public boolean execute(Context ctx) throws Exception {
String url = (String) ctx.get(this.urlKey);
if (log.isDebugEnabled()) {
log.debug("connecting to jndi server at " + url);
}
InitialContext iCtx = new InitialContext();
ClientAdapterFactory adapter = new ClientAdapterFactory();
RemoteRepository remote = (RemoteRepository) iCtx.lookup(url);
Repository repo = adapter.getRepository(remote);
CommandHelper.setRepository(ctx, repo, "jndi " + url);
return false;
}
use of javax.jcr.Repository in project jackrabbit by apache.
the class ConnectToRmiServer method execute.
/**
* {@inheritDoc}
*/
public boolean execute(Context ctx) throws Exception {
String url = (String) ctx.get(this.urlKey);
if (log.isDebugEnabled()) {
log.debug("connecting to jcr-rmi server at " + url);
}
ClientRepositoryFactory factory = new ClientRepositoryFactory();
Repository repository = factory.getRepository(url);
CommandHelper.setRepository(ctx, repository, "jcr-rmi " + url);
return false;
}
Aggregations