]> git.aero2k.de Git - tmp/jakarta-migration.git/commitdiff
NOJIRA checking in stuff before sandbox move
authorSanjay Dalal <sanjay.dalal@berkeley.edu>
Thu, 13 Aug 2009 17:15:35 +0000 (17:15 +0000)
committerSanjay Dalal <sanjay.dalal@berkeley.edu>
Thu, 13 Aug 2009 17:15:35 +0000 (17:15 +0000)
A    sanjay/prototypes/restws/HelloWorldDocService/nbactions.xml
M    sanjay/prototypes/restws/HelloWorldDocService/pom.all.xml
A    sanjay/prototypes/restws/HelloWorldDocService/nb-configuration.xml
M    sanjay/prototypes/restws/HelloWorldDocService/pom.xml
A    sanjay/prototypes/restws/HelloWorldDocService/README.txt
M    sanjay/prototypes/jaxrs-prototype/jaxrs-nuxeo-service/pom.xml
M    sanjay/prototypes/jaxrs-prototype/jaxrs-nuxeo-javaapi-service/pom.xml
A    sanjay/nuxeo
A    sanjay/nuxeo/NuxeoApp.java
A    sanjay/nuxeo/ConnectionListener.java
A    sanjay/nuxeo/LoginHandler.java
A    sanjay/nuxeo/DefaultLoginHandler.java
A    sanjay/nuxeo/NuxeoClient.java

12 files changed:
sandbox/sanjay/nuxeo/ConnectionListener.java [new file with mode: 0644]
sandbox/sanjay/nuxeo/DefaultLoginHandler.java [new file with mode: 0644]
sandbox/sanjay/nuxeo/LoginHandler.java [new file with mode: 0644]
sandbox/sanjay/nuxeo/NuxeoApp.java [new file with mode: 0644]
sandbox/sanjay/nuxeo/NuxeoClient.java [new file with mode: 0644]
sandbox/sanjay/prototypes/jaxrs-prototype/jaxrs-nuxeo-javaapi-service/pom.xml
sandbox/sanjay/prototypes/jaxrs-prototype/jaxrs-nuxeo-service/pom.xml
sandbox/sanjay/prototypes/restws/HelloWorldDocService/README.txt [new file with mode: 0644]
sandbox/sanjay/prototypes/restws/HelloWorldDocService/nb-configuration.xml [new file with mode: 0644]
sandbox/sanjay/prototypes/restws/HelloWorldDocService/nbactions.xml [new file with mode: 0644]
sandbox/sanjay/prototypes/restws/HelloWorldDocService/pom.all.xml
sandbox/sanjay/prototypes/restws/HelloWorldDocService/pom.xml

diff --git a/sandbox/sanjay/nuxeo/ConnectionListener.java b/sandbox/sanjay/nuxeo/ConnectionListener.java
new file mode 100644 (file)
index 0000000..080cfef
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * (C) Copyright 2006-2007 Nuxeo SAS (http://nuxeo.com/) and contributors.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the GNU Lesser General Public License
+ * (LGPL) version 2.1 which accompanies this distribution, and is available at
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * Contributors:
+ *     bstefanescu
+ *
+ * $Id$
+ */
+
+package org.collectionspace.services.nuxeo;
+
+/**
+ * Listen to connection events
+ *
+ * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a>
+ *
+ */
+public interface ConnectionListener {
+
+    /**
+     * The client connected to a server.
+     *
+     * @param client the client
+     */
+    void connected(NuxeoClient client);
+
+    /**
+     * The client disconnected.
+     *
+     * @param client the client
+     */
+    void disconnected(NuxeoClient client);
+
+    /**
+     * The client authentication failed against the remote server.
+     *
+     * @param client the client
+     */
+    boolean authenticationFailed(NuxeoClient client);
+
+}
diff --git a/sandbox/sanjay/nuxeo/DefaultLoginHandler.java b/sandbox/sanjay/nuxeo/DefaultLoginHandler.java
new file mode 100644 (file)
index 0000000..2b13311
--- /dev/null
@@ -0,0 +1,96 @@
+/*
+ * (C) Copyright 2006-2007 Nuxeo SAS (http://nuxeo.com/) and contributors.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the GNU Lesser General Public License
+ * (LGPL) version 2.1 which accompanies this distribution, and is available at
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * Contributors:
+ *     bstefanescu
+ *
+ * $Id$
+ */
+
+package org.collectionspace.services.nuxeo;
+
+import javax.security.auth.login.LoginContext;
+import javax.security.auth.login.LoginException;
+
+import org.nuxeo.runtime.api.Framework;
+
+/**
+ * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a>
+ *
+ */
+public class DefaultLoginHandler implements LoginHandler {
+
+    private LoginContext lc;
+
+    private String username;
+    private char[] password;
+
+    public DefaultLoginHandler() {
+    }
+
+    public DefaultLoginHandler(String username, String password) {
+        this(username, password.toCharArray());
+    }
+
+    public DefaultLoginHandler(String username, char[] password) {
+        this.username = username;
+        this.password = password;
+    }
+
+    public void setUsername(String username) {
+        this.username = username;
+    }
+
+    public void setPassword(char[] password) {
+        this.password = password;
+    }
+
+    public void setPassword(String password) {
+        this.password = password.toCharArray();
+    }
+
+    public char[] getPassword() {
+        return password;
+    }
+
+    public String getUsername() {
+        return username;
+    }
+
+    public synchronized LoginContext getLoginContext() {
+        return lc;
+    }
+
+    public synchronized LoginContext login() throws LoginException {
+        if (username == null) {
+            lc = Framework.login();
+        } else {
+            lc = Framework.login(username, password);
+        }
+        return lc;
+    }
+
+    public synchronized void logout() throws LoginException {
+        if (lc != null) {
+            lc.logout();
+        }
+    }
+
+    public synchronized void retryLogin() throws LoginException {
+        if (lc != null) {
+            lc.logout();
+        }
+        login();
+    }
+
+}
diff --git a/sandbox/sanjay/nuxeo/LoginHandler.java b/sandbox/sanjay/nuxeo/LoginHandler.java
new file mode 100644 (file)
index 0000000..57cb853
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * (C) Copyright 2006-2007 Nuxeo SAS (http://nuxeo.com/) and contributors.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the GNU Lesser General Public License
+ * (LGPL) version 2.1 which accompanies this distribution, and is available at
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * Contributors:
+ *     bstefanescu
+ *
+ * $Id$
+ */
+
+package org.collectionspace.services.nuxeo;
+
+import javax.security.auth.login.LoginContext;
+import javax.security.auth.login.LoginException;
+
+/**
+ * Manages user login and current user session.
+ *
+ * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a>
+ */
+public interface LoginHandler {
+
+    LoginContext login() throws LoginException;
+
+    void logout() throws LoginException;
+
+    LoginContext getLoginContext();
+
+    void retryLogin() throws LoginException;
+
+}
diff --git a/sandbox/sanjay/nuxeo/NuxeoApp.java b/sandbox/sanjay/nuxeo/NuxeoApp.java
new file mode 100644 (file)
index 0000000..6295b82
--- /dev/null
@@ -0,0 +1,176 @@
+/*
+ * (C) Copyright 2006-2008 Nuxeo SAS (http://nuxeo.com/) and contributors.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the GNU Lesser General Public License
+ * (LGPL) version 2.1 which accompanies this distribution, and is available at
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * Contributors:
+ *     bstefanescu
+ */
+package org.collectionspace.services.nuxeo;
+
+import java.io.File;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.LinkedHashSet;
+import java.util.List;
+import java.util.StringTokenizer;
+
+import org.nuxeo.common.Environment;
+import org.nuxeo.osgi.BundleFile;
+import org.nuxeo.osgi.BundleImpl;
+import org.nuxeo.osgi.DirectoryBundleFile;
+import org.nuxeo.osgi.JarBundleFile;
+import org.nuxeo.osgi.OSGiAdapter;
+import org.osgi.framework.BundleException;
+
+/**
+ * Nuxeo Runtime launcher.
+ *
+ * This launcher assume all bundles are already on the classpath.
+ *
+ *
+ * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a>
+ *
+ */
+public class NuxeoApp {
+
+    protected OSGiAdapter osgi;
+    protected final ClassLoader loader;
+    protected final Environment env;
+
+    public static ClassLoader getDefaultClassLoader() {
+        ClassLoader cl = Thread.currentThread().getContextClassLoader();
+        return cl == null ? NuxeoApp.class.getClassLoader() : cl;
+    }
+
+    public NuxeoApp() {
+        this (new File("."), getDefaultClassLoader());
+    }
+
+    public NuxeoApp(File home) {
+      this (home, getDefaultClassLoader());
+    }
+
+    public NuxeoApp(File home, ClassLoader loader) {
+        this.loader = loader;
+        env = new Environment(home);
+    }
+
+    public Environment getEnvironment() {
+        return this.env;
+    }
+
+    public synchronized void deployBundles(Collection<File> files) throws BundleException, IOException {
+        if (!isStarted()) {
+            throw new IllegalStateException("Framework not started");
+        }
+        for (File file : files) {
+            deployBundle(file);
+        }
+    }
+
+    public synchronized void deployBundle(File file) throws BundleException, IOException  {
+        if (!isStarted()) {
+            throw new IllegalStateException("Framework not started");
+        }
+        BundleFile bf = file.isDirectory() ? new DirectoryBundleFile(file) : new JarBundleFile(file);
+        osgi.install(new BundleImpl(osgi, bf, loader));
+        System.out.println(">>>NuxeoApp:deployed bundle: " + file.getName());
+    }
+
+    public synchronized void start() {
+        if (osgi != null) {
+            //throw new IllegalStateException("Nuxeo Runtime already started");
+            //sd: why throw exception?
+            return;
+        }
+        osgi = new OSGiAdapter(env.getHome(), env.getData(), env.getProperties());
+    }
+
+    public synchronized boolean isStarted() {
+        return osgi != null;
+    }
+
+    public synchronized OSGiAdapter getOsgi() {
+        return osgi;
+    }
+
+
+    public synchronized void shutdown() throws IOException {
+        if (osgi == null) {
+            throw new IllegalStateException("Nuxeo Runtime not started");
+        }
+        osgi.shutdown();
+        osgi = null;
+    }
+
+    public static Collection<File> getBundleFiles(File baseDir, String bundles, String delim) throws IOException {
+        LinkedHashSet<File> result = new LinkedHashSet<File>();
+        StringTokenizer tokenizer = new StringTokenizer(bundles, delim == null ? " \t\n\r\f" : delim);
+        while (tokenizer.hasMoreTokens()) {
+            String tok = tokenizer.nextToken();
+            List<File> files = expandFiles(baseDir, tok);
+            for (File file : files) {
+                result.add(file.getCanonicalFile());
+            }
+        }
+        return result;
+    }
+
+    public static List<File> expandFiles(File baseDir, String line) {
+        int p = line.lastIndexOf("/");
+        String fileName = null;
+        if (p > -1) {
+            fileName = line.substring(p+1);
+            baseDir = new File(baseDir, line.substring(0, p));
+        } else {
+            fileName = line;
+        }
+        p = fileName.indexOf("*");
+        if (p == -1) {
+            return Collections.singletonList(new File(baseDir, fileName));
+        } else if (fileName.length() == 0) {
+            return Arrays.asList(baseDir.listFiles());
+        } else if (p == 0) {
+            String suffix= fileName.substring(p+1);
+            ArrayList<File> result = new ArrayList<File>();
+            for (String name : baseDir.list()) {
+                if (name.endsWith(suffix)) {
+                    result.add(new File(baseDir, name));
+                }
+            }
+            return result;
+        } else if (p == fileName.length()-1) {
+            String prefix= fileName.substring(0, p);
+            ArrayList<File> result = new ArrayList<File>();
+            for (String name : baseDir.list()) {
+                if (name.startsWith(prefix)) {
+                    result.add(new File(baseDir, name));
+                }
+            }
+            return result;
+        } else {
+            String prefix= fileName.substring(0, p);
+            String suffix= fileName.substring(p+1);
+            ArrayList<File> result = new ArrayList<File>();
+            for (String name : baseDir.list()) {
+                if (name.startsWith(prefix) && name.endsWith(suffix)) {
+                    result.add(new File(baseDir, name));
+                }
+            }
+            return result;
+        }
+    }
+
+}
diff --git a/sandbox/sanjay/nuxeo/NuxeoClient.java b/sandbox/sanjay/nuxeo/NuxeoClient.java
new file mode 100644 (file)
index 0000000..c2458b9
--- /dev/null
@@ -0,0 +1,409 @@
+/*
+ * (C) Copyright 2006-2007 Nuxeo SAS (http://nuxeo.com/) and contributors.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the GNU Lesser General Public License
+ * (LGPL) version 2.1 which accompanies this distribution, and is available at
+ * http://www.gnu.org/licenses/lgpl.html
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * Contributors:
+ *     bstefanescu
+ *
+ * $Id$
+ */
+package org.collectionspace.services.nuxeo;
+
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Vector;
+
+import javax.security.auth.login.AppConfigurationEntry;
+import javax.security.auth.login.LoginException;
+
+import org.jboss.remoting.InvokerLocator;
+import org.nuxeo.common.collections.ListenerList;
+import org.nuxeo.ecm.core.api.repository.Repository;
+import org.nuxeo.ecm.core.api.repository.RepositoryInstance;
+import org.nuxeo.ecm.core.api.repository.RepositoryInstanceHandler;
+import org.nuxeo.ecm.core.api.repository.RepositoryManager;
+import org.nuxeo.ecm.core.schema.SchemaManager;
+import org.nuxeo.ecm.core.schema.SchemaManagerImpl;
+import org.nuxeo.ecm.core.schema.TypeProvider;
+import org.nuxeo.runtime.api.Framework;
+import org.nuxeo.runtime.api.ServiceDescriptor;
+import org.nuxeo.runtime.api.ServiceManager;
+import org.nuxeo.runtime.api.login.LoginComponent;
+import org.nuxeo.runtime.api.login.LoginService;
+import org.nuxeo.runtime.api.login.SecurityDomain;
+import org.nuxeo.runtime.config.AutoConfigurationService;
+import org.nuxeo.runtime.remoting.RemotingService;
+import org.nuxeo.runtime.services.streaming.StreamingService;
+
+/**
+ * @author <a href="mailto:bs@nuxeo.com">Bogdan Stefanescu</a>
+ *
+ */
+public final class NuxeoClient {
+
+    private LoginHandler loginHandler;
+    private final List<RepositoryInstance> repositoryInstances;
+    private final ListenerList connectionListeners;
+    private InvokerLocator locator;
+    private String serverName;
+    private final AutoConfigurationService cfg;
+    private RepositoryManager repositoryMgr;
+    private boolean multiThreadedLogin = false;
+    private static final NuxeoClient instance = new NuxeoClient();
+
+    private NuxeoClient() {
+        connectionListeners = new ListenerList();
+        cfg = new AutoConfigurationService();
+        loginHandler = loginHandler == null ? new DefaultLoginHandler() : loginHandler;
+        repositoryInstances = new Vector<RepositoryInstance>();
+    }
+
+    public static NuxeoClient getInstance() {
+        return instance;
+    }
+
+    public void setMultiThreadedLogin(boolean useMultiThreadedLogin) {
+        multiThreadedLogin = useMultiThreadedLogin;
+    }
+
+    public boolean getMultiThreadedLogin() {
+        return multiThreadedLogin;
+    }
+
+    public synchronized void connect(String locator) throws Exception {
+        if(this.locator != null){
+            throw new IllegalStateException("Client is already connected");
+        }
+        doConnect(AutoConfigurationService.createLocator(locator));
+    }
+
+    public synchronized void connect(InvokerLocator locator) throws Exception {
+        if(this.locator != null){
+            throw new IllegalStateException("Client is already connected");
+        }
+        doConnect(locator);
+    }
+
+    public synchronized void connect(String host, int port) throws Exception {
+        if(locator != null){
+            throw new IllegalStateException("Client is already connected");
+        }
+        doConnect(AutoConfigurationService.createLocator(host, port));
+    }
+
+    public synchronized void forceConnect(InvokerLocator locator) throws Exception {
+        if(this.locator != null){
+            disconnect();
+        }
+        doConnect(locator);
+    }
+
+    public synchronized void forceConnect(String locator) throws Exception {
+        if(this.locator != null){
+            disconnect();
+        }
+        doConnect(AutoConfigurationService.createLocator(locator));
+    }
+
+    public synchronized void forceConnect(String host, int port) throws Exception {
+        if(locator != null){
+            disconnect();
+        }
+        doConnect(AutoConfigurationService.createLocator(host, port));
+    }
+
+    public synchronized void tryConnect(String host, int port) throws Exception {
+        if(locator != null){
+            return; // do nothing
+        }
+        doConnect(AutoConfigurationService.createLocator(host, port));
+    }
+
+    public synchronized void tryConnect(String url) throws Exception {
+        if(locator != null){
+            return; // do nothing
+        }
+        doConnect(AutoConfigurationService.createLocator(url));
+    }
+
+    public synchronized void tryConnect(InvokerLocator locator) throws Exception {
+        if(this.locator != null){
+            return; // do nothing
+        }
+        doConnect(locator);
+    }
+
+    private void doConnect(InvokerLocator locator) throws Exception {
+        this.locator = locator;
+        try{
+            cfg.load(locator);
+            // FIXME TODO workaround to work with nxruntime core 1.3.3 --------------
+            String newPort = Framework.getProperty("org.nuxeo.runtime.1.3.3.streaming.port");
+            System.out.println(">>>NuxeoClient:newPort=" + newPort);//sd
+            if(newPort != null){
+                StreamingService streamingService = (StreamingService) Framework.getRuntime().getComponent(
+                        StreamingService.NAME);
+                // streaming config
+                String oldLocator = streamingService.getServerLocator();
+                int p = oldLocator.lastIndexOf(':');
+                if(p > -1){
+                    String withoutPort = oldLocator.substring(0, p);
+                    String serverLocator = withoutPort + ":" + newPort;
+                    streamingService.stopManager();
+                    streamingService.setServerLocator(serverLocator);
+                    streamingService.setServer(false);
+                    streamingService.startManager();
+                }
+            }
+            System.out.println(">>>NuxeoClient:pre schemaRemotingWorkaround");//sd
+            // FIXME TODO workaround for remote services -------------------------------
+            schemaRemotingWorkaround(locator.getHost());
+            System.out.println(">>>NuxeoClient:post schemaRemotingWorkaround");//sd
+
+
+            // workaround for client login configuration - we need to make it not multi threaded
+            // TODO put an option for this in NuxeoClient
+            if(!multiThreadedLogin){
+                LoginService ls = Framework.getService(LoginService.class);
+                SecurityDomain sysDomain = ls.getSecurityDomain(LoginComponent.SYSTEM_LOGIN);
+                SecurityDomain clientDomain = ls.getSecurityDomain(LoginComponent.CLIENT_LOGIN);
+                adaptClientSecurityDomain(sysDomain);
+                adaptClientSecurityDomain(clientDomain);
+            }
+            // ----------------
+            login();
+            System.out.println("NuxeoClient: login");
+        }catch(Exception e){
+            this.locator = null;
+            throw e;
+        }
+        fireConnected(this);
+    }
+
+    public static void adaptClientSecurityDomain(SecurityDomain sd) {
+        AppConfigurationEntry[] entries = sd.getAppConfigurationEntries();
+        if(entries != null){
+            for(int i = 0; i < entries.length; i++){
+                AppConfigurationEntry entry = entries[i];
+                if("org.jboss.security.ClientLoginModule".equals(entry.getLoginModuleName())){
+                    Map<String, ?> opts = entry.getOptions();
+                    Map<String, Object> newOpts = new HashMap<String, Object>(opts);
+                    newOpts.put("multi-threaded", "false");
+                    entries[i] = new AppConfigurationEntry(entry.getLoginModuleName(),
+                            entry.getControlFlag(), entry.getOptions());
+                }
+            }
+        }
+    }
+
+    /**
+     * Workaround for being able to load schemas from remote
+     * TODO integrate this in core
+     * FIXME integrate this in core
+     */
+    private static void schemaRemotingWorkaround(String host) throws Exception {
+        ServiceManager serviceManager = Framework.getLocalService(ServiceManager.class);
+        ServiceDescriptor sd = new ServiceDescriptor(TypeProvider.class, "core");
+        sd.setLocator("%TypeProviderBean");
+        serviceManager.registerService(sd);
+        TypeProvider typeProvider = Framework.getService(TypeProvider.class);
+        SchemaManager schemaMgr = Framework.getLocalService(SchemaManager.class);
+        ((SchemaManagerImpl) schemaMgr).importTypes(typeProvider);
+    }
+
+    public synchronized void disconnect() throws Exception {
+        if(locator == null){
+            throw new IllegalStateException("Client is not connected");
+        }
+        doDisconnect();
+    }
+
+    public synchronized void tryDisconnect() throws Exception {
+        if(locator == null){
+            return; // do nothing
+        }
+        doDisconnect();
+    }
+
+    private void doDisconnect() throws Exception {
+        locator = null;
+        serverName = null;
+        // close repository sessions if any
+        Iterator<RepositoryInstance> it = repositoryInstances.iterator();
+        while(it.hasNext()){
+            RepositoryInstance repo = it.next();
+            try{
+                repo.close();
+            }catch(Exception e){
+                e.printStackTrace();
+            }
+            it.remove();
+        }
+        // logout
+        logout();
+        repositoryMgr = null;
+        fireDisconnected(this);
+    }
+
+    public synchronized void reconnect() throws Exception {
+        if(locator == null){
+            throw new IllegalStateException("Client is not connected");
+        }
+        InvokerLocator locator = this.locator;
+        disconnect();
+        connect(locator);
+    }
+
+    public AutoConfigurationService getConfigurationService() {
+        return cfg;
+    }
+
+    public synchronized String getServerName() {
+        if(locator == null){
+            throw new IllegalStateException("Client is not connected");
+        }
+        if(serverName == null){
+            if(cfg == null){ // compatibility
+                serverName = RemotingService.ping(locator.getHost(), locator.getPort());
+            }else{
+                serverName = cfg.getServerConfiguration().getProductInfo();
+            }
+        }
+        return serverName;
+    }
+
+    public synchronized boolean isConnected() {
+        return locator != null;
+    }
+
+    public String getServerHost() {
+        if(locator == null){
+            throw new IllegalStateException("Client is not connected");
+        }
+        return locator.getHost();
+    }
+
+    public int getServerPort() {
+        if(locator == null){
+            throw new IllegalStateException("Client is not connected");
+        }
+        return locator.getPort();
+    }
+
+    public InvokerLocator getLocator() {
+        return locator;
+    }
+
+    public synchronized LoginHandler getLoginHandler() {
+        return loginHandler;
+    }
+
+    public synchronized void setLoginHandler(LoginHandler loginHandler) {
+        this.loginHandler = loginHandler;
+    }
+
+    public synchronized void login() throws LoginException {
+        if(loginHandler != null){
+            loginHandler.login();
+        }
+    }
+
+    public synchronized void logout() throws LoginException {
+        if(loginHandler != null){
+            loginHandler.logout();
+        }
+    }
+
+    public RepositoryManager getRepositoryManager() throws Exception {
+        if(repositoryMgr == null){
+            repositoryMgr = Framework.getService(RepositoryManager.class);
+        }
+        return repositoryMgr;
+    }
+
+    /**
+     * Gets the repositories available on the connected server.
+     *
+     * @return the repositories
+     */
+    public Repository[] getRepositories() throws Exception {
+        Collection<Repository> repos = getRepositoryManager().getRepositories();
+        return repos.toArray(new Repository[repos.size()]);
+    }
+
+    public Repository getDefaultRepository() throws Exception {
+        return getRepositoryManager().getDefaultRepository();
+    }
+
+    public Repository getRepository(String name) throws Exception {
+        return getRepositoryManager().getRepository(name);
+    }
+
+    public RepositoryInstance openRepository() throws Exception {
+        Repository repository = getRepositoryManager().getDefaultRepository();
+        RepositoryInstance repo = newRepositoryInstance(repository);
+        repositoryInstances.add(repo);
+        return repo;
+    }
+
+    public RepositoryInstance openRepository(String name) throws Exception {
+        Repository repository = getRepositoryManager().getRepository(name);
+        RepositoryInstance repo = newRepositoryInstance(repository);
+        repositoryInstances.add(repo);
+        return repo;
+    }
+
+    public void releaseRepository(RepositoryInstance repo) throws Exception {
+        try{
+            repo.close();
+        }finally{
+            repositoryInstances.remove(repo);
+        }
+    }
+
+    public RepositoryInstance[] getRepositoryInstances() {
+        return repositoryInstances.toArray(new RepositoryInstance[repositoryInstances.size()]);
+    }
+
+    public static RepositoryInstance newRepositoryInstance(Repository repository) {
+        ClassLoader cl = Thread.currentThread().getContextClassLoader();
+        if(cl == null){
+            cl = NuxeoClient.class.getClassLoader();
+        }
+        return new RepositoryInstanceHandler(repository).getProxy();
+    }
+
+    public void addConnectionListener(ConnectionListener listener) {
+        connectionListeners.add(listener);
+    }
+
+    public void removeConnectionListener(ConnectionListener listener) {
+        connectionListeners.remove(listener);
+    }
+
+    private void fireDisconnected(NuxeoClient client) {
+        Object[] listeners = connectionListeners.getListeners();
+        for(Object listener : listeners){
+            ((ConnectionListener) listener).disconnected(client);
+        }
+    }
+
+    private void fireConnected(NuxeoClient client) {
+        Object[] listeners = connectionListeners.getListeners();
+        for(Object listener : listeners){
+            ((ConnectionListener) listener).connected(client);
+        }
+    }
+}
index 8f903d3b16e4c4c071bb4ef4fea777d385ab749e..6c25b5405ac2135bb94d33a1f379f605f904928f 100644 (file)
             <url>http://repo1.maven.org/maven2/</url>\r
         </repository>\r
         <!-- For resteasy -->\r
-        <repository>\r
-            <id>cspace.local.jboss.client</id>\r
-            <url>${jboss.client.dir}</url>\r
-        </repository>\r
+\r
         <repository>\r
             <id>jboss</id>\r
             <name>jboss repo</name>\r
             <url>http://svn.codehaus.org/mojo/trunk/mojo/jboss-maven-plugin</url>\r
         </repository>\r
 \r
-        <repository>\r
-            <id>cspace.local.nuxeo</id>\r
-            <url>${nuxeo.local.repo.dir}</url>\r
-        </repository>\r
-        <repository>\r
-            <id>cspace.local.nuxeo.client</id>\r
-            <url>${nuxeo.local.repo.client.dir}</url>\r
-        </repository>\r
         <!--repository>\r
             <id>public</id>\r
             <url>http://maven.nuxeo.org/public</url>\r
index 5c8a0770e0871b30bcaeb06f2cbdf0a420729536..1a94a7889eb3623492d97e16a4b641ffe9d49359 100644 (file)
             <name>Public online Restlet repository</name>\r
             <url>http://maven.restlet.org</url>\r
         </repository>\r
-        \r
-        <repository>\r
-            <id>cspace.local.nuxeo</id>\r
-            <url>${nuxeo.local.repo.dir}</url>\r
-        </repository>\r
-        <repository>\r
-            <id>cspace.local.nuxeo.client</id>\r
-            <url>${nuxeo.local.repo.client.dir}</url>\r
-        </repository>\r
         <repository>\r
             <id>public</id>\r
             <url>http://maven.nuxeo.org/public</url>\r
diff --git a/sandbox/sanjay/prototypes/restws/HelloWorldDocService/README.txt b/sandbox/sanjay/prototypes/restws/HelloWorldDocService/README.txt
new file mode 100644 (file)
index 0000000..bd38e83
--- /dev/null
@@ -0,0 +1,15 @@
+
+This project is a simple example showing usage of @Path, @GET, PUT, POST, and @PathParam.  It uses pure streaming
+output as well. 
+
+System Requirements:
+====================
+- Maven 2.0.9 or higher
+
+Building the project:
+====================
+1. In root directoy
+
+mvn clean install
+
+This will build a WAR and run it with embedded Jetty
\ No newline at end of file
diff --git a/sandbox/sanjay/prototypes/restws/HelloWorldDocService/nb-configuration.xml b/sandbox/sanjay/prototypes/restws/HelloWorldDocService/nb-configuration.xml
new file mode 100644 (file)
index 0000000..3e5cd98
--- /dev/null
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<project-shared-configuration>\r
+    <!--
+This file contains additional configuration written by modules in the NetBeans IDE.
+The configuration is intended to be shared among all the users of project and
+therefore it is assumed to be part of version control checkout.
+Without this configuration present, some functionality in the IDE may be limited or fail altogether.
+-->\r
+    <properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">\r
+        <!--
+Properties that influence various parts of the IDE, especially code formatting and the like. 
+You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
+That way multiple projects can share the same settings (useful for formatting rules for example).
+Any value defined here will override the pom.xml file value but is only applicable to the current project.
+-->\r
+        <org-netbeans-modules-editor-indent.CodeStyle.usedProfile>default</org-netbeans-modules-editor-indent.CodeStyle.usedProfile>\r
+        <org-netbeans-modules-editor-indent.CodeStyle.project.tab-size>8</org-netbeans-modules-editor-indent.CodeStyle.project.tab-size>\r
+        <org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width>80</org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width>\r
+        <netbeans.hint.useExternalMaven>false</netbeans.hint.useExternalMaven>\r
+    </properties>\r
+</project-shared-configuration>\r
diff --git a/sandbox/sanjay/prototypes/restws/HelloWorldDocService/nbactions.xml b/sandbox/sanjay/prototypes/restws/HelloWorldDocService/nbactions.xml
new file mode 100644 (file)
index 0000000..9d30c23
--- /dev/null
@@ -0,0 +1,74 @@
+<?xml version="1.0" encoding="UTF-8"?>\r
+<actions>\r
+        <action>\r
+            <actionName>test</actionName>\r
+            <packagings>\r
+                <packaging>*</packaging>\r
+            </packagings>\r
+            <goals>\r
+                <goal>test</goal>\r
+            </goals>\r
+        </action>\r
+        <action>\r
+            <actionName>build</actionName>\r
+            <packagings>\r
+                <packaging>*</packaging>\r
+            </packagings>\r
+            <goals>\r
+                <goal>install</goal>\r
+            </goals>\r
+        </action>\r
+        <action>\r
+            <actionName>clean</actionName>\r
+            <packagings>\r
+                <packaging>*</packaging>\r
+            </packagings>\r
+            <goals>\r
+                <goal>clean</goal>\r
+            </goals>\r
+        </action>\r
+        <action>\r
+            <actionName>rebuild</actionName>\r
+            <packagings>\r
+                <packaging>*</packaging>\r
+            </packagings>\r
+            <goals>\r
+                <goal>clean</goal>\r
+                <goal>install</goal>\r
+            </goals>\r
+            <properties>\r
+                <maven.test.skip>true</maven.test.skip>\r
+            </properties>\r
+        </action>\r
+        <action>\r
+            <actionName>run</actionName>\r
+            <packagings>\r
+                <packaging>war</packaging>\r
+                <packaging>ear</packaging>\r
+                <packaging>ejb</packaging>\r
+            </packagings>\r
+            <goals>\r
+                <goal>package</goal>\r
+            </goals>\r
+            <properties>\r
+                \r
+                <netbeans.deploy>true</netbeans.deploy>\r
+            </properties>\r
+        </action>\r
+        <action>\r
+            <actionName>debug</actionName>\r
+            <packagings>\r
+                <packaging>war</packaging>\r
+                <packaging>ear</packaging>\r
+                <packaging>ejb</packaging>\r
+            </packagings>\r
+            <goals>\r
+                <goal>package</goal>\r
+            </goals>\r
+            <properties>\r
+                \r
+                <netbeans.deploy>true</netbeans.deploy>\r
+                <netbeans.deploy.debugmode>true</netbeans.deploy.debugmode>\r
+            </properties>\r
+        </action>\r
+    </actions>\r
index 5aa2f743c01b78b70af2f46cedacf5d5adeaee96..e00b239d69ecc653dcf510eafb7120ea4902bd6f 100644 (file)
             <name>mojo repo</name>\r
             <url>http://svn.codehaus.org/mojo/trunk/mojo/jboss-maven-plugin</url>\r
         </repository>\r
-        <repository>\r
-            <id>cspace.local.nuxeo</id>\r
-            <url>${nuxeo.local.repo.dir}</url>\r
-        </repository>\r
         <repository>\r
             <id>public</id>\r
             <url>http://maven.nuxeo.org/public</url>\r
index 41b3e6279037a30079a07807ae660eea848123a0..8f611c947aedc6de3bea1af3724ee43feb51adc2 100644 (file)
             <name>Public online Restlet repository</name>\r
             <url>http://maven.restlet.org</url>\r
         </repository>\r
-        \r
-        <repository>\r
-            <id>cspace.local.nuxeo</id>\r
-            <url>${nuxeo.local.repo.dir}</url>\r
-        </repository>\r
-        <repository>\r
-            <id>cspace.local.nuxeo.client</id>\r
-            <url>${nuxeo.local.repo.client.dir}</url>\r
-        </repository>\r
+\r
         <repository>\r
             <id>public</id>\r
             <url>http://maven.nuxeo.org/public</url>\r