wms-restlet-2.2.2

16:54:15.788 INFO  jd.cli.Main - Decompiling wms-restlet-2.2.2.jar
package org.restlet;

import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import org.restlet.engine.Engine;
import org.restlet.engine.application.ApplicationHelper;
import org.restlet.engine.resource.AnnotationUtils;
import org.restlet.resource.ServerResource;
import org.restlet.security.Role;
import org.restlet.service.ConnectorService;
import org.restlet.service.ConnegService;
import org.restlet.service.ConverterService;
import org.restlet.service.DecoderService;
import org.restlet.service.EncoderService;
import org.restlet.service.MetadataService;
import org.restlet.service.RangeService;
import org.restlet.service.StatusService;
import org.restlet.service.TaskService;
import org.restlet.service.TunnelService;
import org.restlet.util.ServiceList;

public class Application
  extends Restlet
{
  private static final ThreadLocal<Application> CURRENT = new ThreadLocal();
  private volatile ApplicationHelper helper;
  private volatile Restlet inboundRoot;
  private volatile Restlet outboundRoot;
  private final List<Role> roles;
  private final ServiceList services;
  
  public static Application getCurrent()
  {
    return (Application)CURRENT.get();
  }
  
  public static void setCurrent(Application application)
  {
    CURRENT.set(application);
  }
  
  public Application()
  {
    this(null);
  }
  
  public Application(Context context)
  {
    super(context);
    if (Engine.getInstance() != null)
    {
      helper = new ApplicationHelper(this);
      helper.setContext(context);
    }
    outboundRoot = null;
    inboundRoot = null;
    roles = new CopyOnWriteArrayList();
    services = new ServiceList(context);
    services.add(new TunnelService(true, true));
    services.add(new StatusService());
    services.add(new DecoderService());
    services.add(new EncoderService(false));
    services.add(new RangeService());
    services.add(new ConnectorService());
    services.add(new ConnegService());
    services.add(new ConverterService());
    services.add(new MetadataService());
    
    services.add(new TaskService(false));
  }
  
  public Restlet createInboundRoot()
  {
    return null;
  }
  
  public Restlet createOutboundRoot()
  {
    return getHelper().getFirstOutboundFilter();
  }
  
  public ConnectorService getConnectorService()
  {
    return (ConnectorService)getServices().get(ConnectorService.class);
  }
  
  public ConnegService getConnegService()
  {
    return (ConnegService)getServices().get(ConnegService.class);
  }
  
  public ConverterService getConverterService()
  {
    return (ConverterService)getServices().get(ConverterService.class);
  }
  
  public DecoderService getDecoderService()
  {
    return (DecoderService)getServices().get(DecoderService.class);
  }
  
  public EncoderService getEncoderService()
  {
    return (EncoderService)getServices().get(EncoderService.class);
  }
  
  private ApplicationHelper getHelper()
  {
    return helper;
  }
  
  public Restlet getInboundRoot()
  {
    if (inboundRoot == null) {
      synchronized (this)
      {
        if (inboundRoot == null) {
          inboundRoot = createInboundRoot();
        }
      }
    }
    return inboundRoot;
  }
  
  public MetadataService getMetadataService()
  {
    return (MetadataService)getServices().get(MetadataService.class);
  }
  
  public Restlet getOutboundRoot()
  {
    if (outboundRoot == null) {
      synchronized (this)
      {
        if (outboundRoot == null) {
          outboundRoot = createOutboundRoot();
        }
      }
    }
    return outboundRoot;
  }
  
  public RangeService getRangeService()
  {
    return (RangeService)getServices().get(RangeService.class);
  }
  
  public Role getRole(String name)
  {
    for (Role role : getRoles()) {
      if (role.getName().equals(name)) {
        return role;
      }
    }
    return null;
  }
  
  public List<Role> getRoles()
  {
    return roles;
  }
  
  public ServiceList getServices()
  {
    return services;
  }
  
  public StatusService getStatusService()
  {
    return (StatusService)getServices().get(StatusService.class);
  }
  
  @Deprecated
  public TaskService getTaskService()
  {
    return (TaskService)getServices().get(TaskService.class);
  }
  
  public TunnelService getTunnelService()
  {
    return (TunnelService)getServices().get(TunnelService.class);
  }
  
  public void handle(Request request, Response response)
  {
    super.handle(request, response);
    if (getHelper() != null) {
      getHelper().handle(request, response);
    }
  }
  
  public void setConnectorService(ConnectorService connectorService)
  {
    getServices().set(connectorService);
  }
  
  public void setConnegService(ConnegService connegService)
  {
    getServices().set(connegService);
  }
  
  public void setContext(Context context)
  {
    super.setContext(context);
    getHelper().setContext(context);
    getServices().setContext(context);
  }
  
  public void setConverterService(ConverterService converterService)
  {
    getServices().set(converterService);
  }
  
  public void setDecoderService(DecoderService decoderService)
  {
    getServices().set(decoderService);
  }
  
  public void setEncoderService(EncoderService encoderService)
  {
    getServices().set(encoderService);
  }
  
  public synchronized void setInboundRoot(Class<? extends ServerResource> inboundRootClass)
  {
    setInboundRoot(createFinder(inboundRootClass));
  }
  
  public synchronized void setInboundRoot(Restlet inboundRoot)
  {
    this.inboundRoot = inboundRoot;
    if ((inboundRoot != null) && (inboundRoot.getContext() == null)) {
      inboundRoot.setContext(getContext());
    }
  }
  
  public void setMetadataService(MetadataService metadataService)
  {
    getServices().set(metadataService);
  }
  
  public synchronized void setOutboundRoot(Class<? extends ServerResource> outboundRootClass)
  {
    setOutboundRoot(createFinder(outboundRootClass));
  }
  
  public synchronized void setOutboundRoot(Restlet outboundRoot)
  {
    this.outboundRoot = outboundRoot;
    if ((outboundRoot != null) && (outboundRoot.getContext() == null)) {
      outboundRoot.setContext(getContext());
    }
  }
  
  public void setRangeService(RangeService rangeService)
  {
    getServices().set(rangeService);
  }
  
  public void setRoles(List<Role> roles)
  {
    synchronized (getRoles())
    {
      if (roles != getRoles())
      {
        getRoles().clear();
        if (roles != null) {
          getRoles().addAll(roles);
        }
      }
    }
  }
  
  public void setStatusService(StatusService statusService)
  {
    getServices().set(statusService);
  }
  
  public void setTaskService(TaskService taskService)
  {
    getServices().set(taskService);
  }
  
  public void setTunnelService(TunnelService tunnelService)
  {
    getServices().set(tunnelService);
  }
  
  public synchronized void start()
    throws Exception
  {
    if (isStopped())
    {
      if (getHelper() != null) {
        getHelper().start();
      }
      getServices().start();
      if (getInboundRoot() != null) {
        getInboundRoot().start();
      }
      if (getOutboundRoot() != null) {
        getOutboundRoot().start();
      }
      super.start();
    }
  }
  
  public synchronized void stop()
    throws Exception
  {
    if (isStarted())
    {
      super.stop();
      if (getOutboundRoot() != null) {
        getOutboundRoot().stop();
      }
      if (getInboundRoot() != null) {
        getInboundRoot().stop();
      }
      getServices().stop();
      if (getHelper() != null) {
        getHelper().stop();
      }
      AnnotationUtils.getInstance().clearCache();
    }
  }
}

/* Location:
 * Qualified Name:     org.restlet.Application
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.restlet;

import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ConcurrentMap;
import org.restlet.data.Protocol;
import org.restlet.data.Status;
import org.restlet.engine.Engine;
import org.restlet.engine.RestletHelper;

public class Client
  extends Connector
{
  private final RestletHelper<Client> helper;
  
  public Client(Context context, List<Protocol> protocols)
  {
    this(context, protocols, null);
  }
  
  public Client(Context context, List<Protocol> protocols, String helperClass)
  {
    super(context, protocols);
    if ((protocols != null) && (!protocols.isEmpty()))
    {
      if (Engine.getInstance() != null) {
        helper = Engine.getInstance().createHelper(this, helperClass);
      } else {
        helper = null;
      }
    }
    else {
      helper = null;
    }
    if ((context != null) && (helper != null)) {
      context.getAttributes().put("org.restlet.engine.helper", helper);
    }
  }
  
  public Client(Context context, Protocol protocol)
  {
    this(context, protocol == null ? null : Arrays.asList(new Protocol[] { protocol }), null);
  }
  
  public Client(List<Protocol> protocols)
  {
    this(null, protocols, null);
  }
  
  public Client(Protocol protocol)
  {
    this(null, protocol);
  }
  
  public Client(String protocolName)
  {
    this(Protocol.valueOf(protocolName));
  }
  
  private RestletHelper<Client> getHelper()
  {
    return helper;
  }
  
  public void handle(Request request, Response response)
  {
    super.handle(request, response);
    if (getHelper() != null)
    {
      getHelper().handle(request, response);
    }
    else
    {
      StringBuilder sb = new StringBuilder();
      sb.append("No available client connector supports the required protocol: ");
      sb.append("'").append(request.getProtocol().getName()).append("'.");
      sb.append(" Please add the JAR of a matching connector to your classpath.");
      response.setStatus(Status.CONNECTOR_ERROR_INTERNAL, sb.toString());
    }
  }
  
  public boolean isAvailable()
  {
    return getHelper() != null;
  }
  
  public synchronized void start()
    throws Exception
  {
    if (isStopped())
    {
      if (getHelper() != null) {
        getHelper().start();
      }
      super.start();
    }
  }
  
  public synchronized void stop()
    throws Exception
  {
    if (isStarted())
    {
      super.stop();
      if (getHelper() != null) {
        getHelper().stop();
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.restlet.Client
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.restlet;

import java.io.File;
import java.io.PrintStream;
import java.net.URI;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.restlet.data.Reference;
import org.restlet.engine.Engine;
import org.restlet.engine.component.ComponentHelper;
import org.restlet.engine.component.ComponentXmlParser;
import org.restlet.engine.component.InternalRouter;
import org.restlet.representation.Representation;
import org.restlet.resource.ClientResource;
import org.restlet.routing.Router;
import org.restlet.routing.VirtualHost;
import org.restlet.security.Realm;
import org.restlet.service.LogService;
import org.restlet.service.StatusService;
import org.restlet.service.TaskService;
import org.restlet.util.ClientList;
import org.restlet.util.ServerList;
import org.restlet.util.ServiceList;

public class Component
  extends Restlet
{
  private final ClientList clients;
  private volatile VirtualHost defaultHost;
  private volatile ComponentHelper helper;
  private final List<VirtualHost> hosts;
  private volatile Router internalRouter;
  private final List<Realm> realms;
  private final ServerList servers;
  private final ServiceList services;
  
  public static void main(String[] args)
    throws Exception
  {
    try
    {
      if ((args == null) || (args.length != 1))
      {
        System.err.println("Can't launch the component. Requires the path to an XML configuration file.\n");
      }
      else
      {
        URI currentDirURI = new File(".").toURI();
        URI confURI = currentDirURI.resolve(args[0]);
        new Component(confURI.toString()).start();
      }
    }
    catch (Exception e)
    {
      System.err.println("Can't launch the component.\nAn unexpected exception occurred:");
      
      e.printStackTrace(System.err);
    }
  }
  
  public Component()
  {
    hosts = new CopyOnWriteArrayList();
    clients = new ClientList(null);
    servers = new ServerList(null, this);
    realms = new CopyOnWriteArrayList();
    services = new ServiceList(getContext());
    if (Engine.getInstance() != null)
    {
      services.add(new TaskService());
      
      helper = new ComponentHelper(this);
      Context childContext = getContext().createChildContext();
      defaultHost = new VirtualHost(childContext);
      internalRouter = new InternalRouter(childContext);
      services.add(new LogService());
      getLogService().setContext(childContext);
      services.add(new StatusService());
      getStatusService().setContext(childContext);
      clients.setContext(childContext);
      servers.setContext(childContext);
    }
  }
  
  public Component(Reference xmlConfigRef)
  {
    this();
    
    Representation xmlConfigRepresentation = null;
    if (xmlConfigRef != null)
    {
      ClientResource cr = new ClientResource(xmlConfigRef);
      xmlConfigRepresentation = cr.get();
      if (xmlConfigRepresentation != null) {
        new ComponentXmlParser(this, xmlConfigRepresentation).parse();
      } else {
        getLogger().log(Level.WARNING, "Unable to get the Component XML configuration located at this URI: " + xmlConfigRef);
      }
    }
  }
  
  public Component(Representation xmlConfigRepresentation)
  {
    this();
    if (xmlConfigRepresentation != null) {
      new ComponentXmlParser(this, xmlConfigRepresentation).parse();
    } else {
      getLogger().log(Level.WARNING, "Unable to parse the Component XML configuration.");
    }
  }
  
  public Component(String xmlConfigurationRef)
  {
    this(xmlConfigurationRef == null ? null : new Reference(xmlConfigurationRef));
  }
  
  public ClientList getClients()
  {
    return clients;
  }
  
  public VirtualHost getDefaultHost()
  {
    return defaultHost;
  }
  
  private ComponentHelper getHelper()
  {
    return helper;
  }
  
  public List<VirtualHost> getHosts()
  {
    return hosts;
  }
  
  public Router getInternalRouter()
  {
    return internalRouter;
  }
  
  public LogService getLogService()
  {
    return (LogService)getServices().get(LogService.class);
  }
  
  public Realm getRealm(String name)
  {
    if (name != null) {
      for (Realm realm : getRealms()) {
        if (name.equals(realm.getName())) {
          return realm;
        }
      }
    }
    return null;
  }
  
  public List<Realm> getRealms()
  {
    return realms;
  }
  
  public ServerList getServers()
  {
    return servers;
  }
  
  public ServiceList getServices()
  {
    return services;
  }
  
  public StatusService getStatusService()
  {
    return (StatusService)getServices().get(StatusService.class);
  }
  
  public TaskService getTaskService()
  {
    return (TaskService)getServices().get(TaskService.class);
  }
  
  public void handle(Request request, Response response)
  {
    super.handle(request, response);
    if (getHelper() != null) {
      getHelper().handle(request, response);
    }
  }
  
  public void setClients(ClientList clients)
  {
    synchronized (getClients())
    {
      if (clients != getClients())
      {
        getClients().clear();
        if (clients != null) {
          getClients().addAll(clients);
        }
      }
    }
  }
  
  public void setContext(Context context)
  {
    super.setContext(context);
    getServices().setContext(context);
  }
  
  public void setDefaultHost(VirtualHost defaultHost)
  {
    this.defaultHost = defaultHost;
  }
  
  public void setHosts(List<VirtualHost> hosts)
  {
    synchronized (getHosts())
    {
      if (hosts != getHosts())
      {
        getHosts().clear();
        if (hosts != null) {
          getHosts().addAll(hosts);
        }
      }
    }
  }
  
  public void setInternalRouter(Router internalRouter)
  {
    this.internalRouter = internalRouter;
  }
  
  public void setLogService(LogService logService)
  {
    getServices().set(logService);
  }
  
  public void setRealms(List<Realm> realms)
  {
    synchronized (getRealms())
    {
      if (realms != getRealms())
      {
        getRealms().clear();
        if (realms != null) {
          getRealms().addAll(realms);
        }
      }
    }
  }
  
  public void setServers(ServerList servers)
  {
    synchronized (getServers())
    {
      if (servers != getServers())
      {
        getServers().clear();
        if (servers != null) {
          getServers().addAll(servers);
        }
      }
    }
  }
  
  public void setStatusService(StatusService statusService)
  {
    getServices().set(statusService);
  }
  
  public void setTaskService(TaskService taskService)
  {
    getServices().set(taskService);
  }
  
  public synchronized void start()
    throws Exception
  {
    if (isStopped())
    {
      startClients();
      startServers();
      startRouters();
      startServices();
      startRealms();
      startHelper();
      
      super.start();
    }
  }
  
  protected synchronized void startClients()
    throws Exception
  {
    if (clients != null) {
      for (Client client : clients) {
        client.start();
      }
    }
  }
  
  protected synchronized void startHelper()
    throws Exception
  {
    if (getHelper() != null) {
      getHelper().start();
    }
  }
  
  protected synchronized void startRealms()
    throws Exception
  {
    if (realms != null) {
      for (Realm realm : realms) {
        realm.start();
      }
    }
  }
  
  protected synchronized void startRouters()
    throws Exception
  {
    if (internalRouter != null) {
      internalRouter.start();
    }
    if (defaultHost != null) {
      defaultHost.start();
    }
    for (VirtualHost host : getHosts()) {
      host.start();
    }
  }
  
  protected synchronized void startServers()
    throws Exception
  {
    if (servers != null) {
      for (Server server : servers) {
        server.start();
      }
    }
  }
  
  protected synchronized void startServices()
    throws Exception
  {
    getServices().start();
  }
  
  public synchronized void stop()
    throws Exception
  {
    stopHelper();
    stopRealms();
    stopServices();
    stopRouters();
    stopServers();
    stopClients();
    super.stop();
  }
  
  protected synchronized void stopClients()
    throws Exception
  {
    if (clients != null) {
      for (Client client : clients) {
        client.stop();
      }
    }
  }
  
  protected synchronized void stopHelper()
    throws Exception
  {
    if (getHelper() != null) {
      getHelper().stop();
    }
  }
  
  protected synchronized void stopRealms()
    throws Exception
  {
    if (realms != null) {
      for (Realm realm : realms) {
        realm.stop();
      }
    }
  }
  
  protected synchronized void stopRouters()
    throws Exception
  {
    for (VirtualHost host : getHosts()) {
      host.stop();
    }
    if (defaultHost != null) {
      defaultHost.stop();
    }
    if (internalRouter != null) {
      internalRouter.stop();
    }
  }
  
  protected synchronized void stopServers()
    throws Exception
  {
    if (servers != null) {
      for (Server server : servers) {
        server.stop();
      }
    }
  }
  
  protected synchronized void stopServices()
    throws Exception
  {
    getServices().stop();
  }
  
  public synchronized void updateHosts()
    throws Exception
  {
    getHelper().update();
  }
}

/* Location:
 * Qualified Name:     org.restlet.Component
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.restlet;

import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import org.restlet.data.Protocol;

public abstract class Connector
  extends Restlet
{
  private final List<Protocol> protocols;
  
  public Connector(Context context)
  {
    this(context, null);
  }
  
  public Connector(Context context, List<Protocol> protocols)
  {
    super(context);
    if (protocols == null) {
      this.protocols = new CopyOnWriteArrayList();
    } else {
      this.protocols = new CopyOnWriteArrayList(protocols);
    }
  }
  
  public List<Protocol> getProtocols()
  {
    return protocols;
  }
  
  public abstract boolean isAvailable();
  
  public void setProtocols(List<Protocol> protocols)
  {
    synchronized (getProtocols())
    {
      if (protocols != getProtocols())
      {
        getProtocols().clear();
        if (protocols != null) {
          getProtocols().addAll(protocols);
        }
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.restlet.Connector
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.restlet;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.concurrent.ScheduledExecutorService;
import java.util.logging.Logger;
import org.restlet.data.Parameter;
import org.restlet.engine.Engine;
import org.restlet.engine.util.ChildContext;
import org.restlet.security.Enroler;
import org.restlet.security.Verifier;
import org.restlet.util.Series;

public class Context
{
  private static final ThreadLocal<Context> CURRENT = new ThreadLocal();
  private volatile Restlet clientDispatcher;
  private volatile Restlet serverDispatcher;
  private final ConcurrentMap<String, Object> attributes;
  private volatile Logger logger;
  private final Series<Parameter> parameters;
  private volatile Enroler defaultEnroler;
  private volatile Verifier defaultVerifier;
  private volatile ScheduledExecutorService executorService;
  
  public static Context getCurrent()
  {
    return (Context)CURRENT.get();
  }
  
  public static Logger getCurrentLogger()
  {
    return getCurrent() != null ? getCurrent().getLogger() : Engine.getLogger("org.restlet");
  }
  
  public static void setCurrent(Context context)
  {
    CURRENT.set(context);
  }
  
  public Context()
  {
    this("org.restlet");
  }
  
  public Context(Logger logger)
  {
    attributes = new ConcurrentHashMap();
    this.logger = logger;
    parameters = new Series(Parameter.class, new CopyOnWriteArrayList());
    
    clientDispatcher = null;
    
    defaultEnroler = null;
    serverDispatcher = null;
    defaultVerifier = null;
  }
  
  public Context(String loggerName)
  {
    this(Engine.getLogger(loggerName));
  }
  
  public Context createChildContext()
  {
    return new ChildContext(this);
  }
  
  public ConcurrentMap<String, Object> getAttributes()
  {
    return attributes;
  }
  
  public Restlet getClientDispatcher()
  {
    return clientDispatcher;
  }
  
  public Enroler getDefaultEnroler()
  {
    return defaultEnroler;
  }
  
  public Verifier getDefaultVerifier()
  {
    return defaultVerifier;
  }
  
  public ScheduledExecutorService getExecutorService()
  {
    return executorService;
  }
  
  public Logger getLogger()
  {
    return logger;
  }
  
  public Series<Parameter> getParameters()
  {
    return parameters;
  }
  
  public Restlet getServerDispatcher()
  {
    return serverDispatcher;
  }
  
  public void setAttributes(Map<String, Object> attributes)
  {
    synchronized (getAttributes())
    {
      if (attributes != getAttributes())
      {
        getAttributes().clear();
        if (attributes != null) {
          getAttributes().putAll(attributes);
        }
      }
    }
  }
  
  public void setClientDispatcher(Restlet clientDispatcher)
  {
    this.clientDispatcher = clientDispatcher;
  }
  
  public void setDefaultEnroler(Enroler enroler)
  {
    defaultEnroler = enroler;
  }
  
  public void setDefaultVerifier(Verifier verifier)
  {
    defaultVerifier = verifier;
  }
  
  public void setExecutorService(ScheduledExecutorService executorService)
  {
    this.executorService = executorService;
  }
  
  public void setLogger(Logger logger)
  {
    this.logger = logger;
  }
  
  public void setLogger(String loggerName)
  {
    setLogger(Engine.getLogger(loggerName));
  }
  
  public void setParameters(Series<Parameter> parameters)
  {
    synchronized (getParameters())
    {
      if (parameters != getParameters())
      {
        getParameters().clear();
        if (parameters != null) {
          getParameters().addAll(parameters);
        }
      }
    }
  }
  
  public void setServerDispatcher(Restlet serverDispatcher)
  {
    this.serverDispatcher = serverDispatcher;
  }
}

/* Location:
 * Qualified Name:     org.restlet.Context
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.restlet;

import java.io.IOException;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.restlet.data.CacheDirective;
import org.restlet.data.MediaType;
import org.restlet.data.RecipientInfo;
import org.restlet.data.Warning;
import org.restlet.representation.BufferingRepresentation;
import org.restlet.representation.Representation;
import org.restlet.representation.StringRepresentation;

public abstract class Message
{
  private volatile ConcurrentMap<String, Object> attributes;
  private volatile List<CacheDirective> cacheDirectives;
  private volatile Date date;
  private volatile Representation entity;
  private volatile String entityText;
  private volatile Uniform onError;
  private volatile Uniform onSent;
  private volatile List<RecipientInfo> recipientsInfo;
  private volatile List<Warning> warnings;
  
  public Message()
  {
    this((Representation)null);
  }
  
  public Message(Representation entity)
  {
    attributes = null;
    cacheDirectives = null;
    date = null;
    this.entity = entity;
    entityText = null;
    onSent = null;
    recipientsInfo = null;
    warnings = null;
  }
  
  public void bufferEntity()
  {
    if ((getEntity() != null) && ((getEntity().isTransient()) || (getEntity().getSize() == -1L)) && (getEntity().isAvailable())) {
      setEntity(new BufferingRepresentation(getEntity()));
    }
  }
  
  public void flushBuffers()
    throws IOException
  {}
  
  public ConcurrentMap<String, Object> getAttributes()
  {
    ConcurrentMap<String, Object> r = attributes;
    if (r == null) {
      synchronized (this)
      {
        r = attributes;
        if (r == null) {
          attributes = (r = new ConcurrentHashMap());
        }
      }
    }
    return attributes;
  }
  
  public List<CacheDirective> getCacheDirectives()
  {
    List<CacheDirective> r = cacheDirectives;
    if (r == null) {
      synchronized (this)
      {
        r = cacheDirectives;
        if (r == null) {
          cacheDirectives = (r = new CopyOnWriteArrayList());
        }
      }
    }
    return r;
  }
  
  public Date getDate()
  {
    return date;
  }
  
  public Representation getEntity()
  {
    return entity;
  }
  
  public String getEntityAsText()
  {
    if (entityText == null) {
      try
      {
        entityText = (getEntity() == null ? null : getEntity().getText());
      }
      catch (IOException e)
      {
        Context.getCurrentLogger().log(Level.FINE, "Unable to get the entity text.", e);
      }
    }
    return entityText;
  }
  
  public Uniform getOnError()
  {
    return onError;
  }
  
  public Uniform getOnSent()
  {
    return onSent;
  }
  
  public List<RecipientInfo> getRecipientsInfo()
  {
    List<RecipientInfo> r = recipientsInfo;
    if (r == null) {
      synchronized (this)
      {
        r = recipientsInfo;
        if (r == null) {
          recipientsInfo = (r = new CopyOnWriteArrayList());
        }
      }
    }
    return r;
  }
  
  public List<Warning> getWarnings()
  {
    List<Warning> r = warnings;
    if (r == null) {
      synchronized (this)
      {
        r = warnings;
        if (r == null) {
          warnings = (r = new CopyOnWriteArrayList());
        }
      }
    }
    return r;
  }
  
  public abstract boolean isConfidential();
  
  public boolean isEntityAvailable()
  {
    boolean result = (getEntity() != null) && (getEntity().isAvailable());
    return result;
  }
  
  public void release()
  {
    if (getEntity() != null) {
      getEntity().release();
    }
  }
  
  public void setAttributes(Map<String, Object> attributes)
  {
    synchronized (getAttributes())
    {
      if (attributes != getAttributes())
      {
        getAttributes().clear();
        if (attributes != null) {
          getAttributes().putAll(attributes);
        }
      }
    }
  }
  
  public void setCacheDirectives(List<CacheDirective> cacheDirectives)
  {
    synchronized (getCacheDirectives())
    {
      if (cacheDirectives != getCacheDirectives())
      {
        getCacheDirectives().clear();
        if (cacheDirectives != null) {
          getCacheDirectives().addAll(cacheDirectives);
        }
      }
    }
  }
  
  public void setDate(Date date)
  {
    this.date = date;
  }
  
  public void setEntity(Representation entity)
  {
    this.entity = entity;
  }
  
  public void setEntity(String value, MediaType mediaType)
  {
    setEntity(new StringRepresentation(value, mediaType));
  }
  
  public void setOnError(Uniform onError)
  {
    this.onError = onError;
  }
  
  public void setOnSent(Uniform onSentCallback)
  {
    onSent = onSentCallback;
  }
  
  public void setRecipientsInfo(List<RecipientInfo> recipientsInfo)
  {
    synchronized (getRecipientsInfo())
    {
      if (recipientsInfo != getRecipientsInfo())
      {
        getRecipientsInfo().clear();
        if (recipientsInfo != null) {
          getRecipientsInfo().addAll(recipientsInfo);
        }
      }
    }
  }
  
  public void setWarnings(List<Warning> warnings)
  {
    synchronized (getWarnings())
    {
      if (warnings != getWarnings())
      {
        getWarnings().clear();
        if (warnings != null) {
          getWarnings().addAll(warnings);
        }
      }
    }
  }
}

/* Location:
 * Qualified Name:     org.restlet.Message
 * Java Class Version: 6 (50.0)
 * JD-Core Version:    0.7.1
 */
package org.restlet;

import java.security.Principal;
import java.util.List;
import java.util.Map.Entry;
import java.util.concurrent.ConcurrentMap;
import java.util.concurrent.CopyOnWriteArrayList;
import org.restlet.data.CacheDirective;
import org.restlet.data.ChallengeResponse;
import org.restlet.data.CharacterSet;
import org.restlet.data.ClientInfo;
import org.restlet.data.Conditions;
import org.restlet.data.Cookie;
import org.restlet.data.Encoding;
import org.restlet.data.Expectation;
import org.restlet.data.Language;
import org.restlet.data.MediaType;
import org.restlet.data.Method;
import org.restlet.data.Preference;
import org.restlet.data.Protocol;
import org.restlet.data.Range;
import org.restlet.data.Reference;
import org.restlet.data.Tag;
import org.restlet.data.Warning;
import org.restlet.representation.Representation;
import org.restlet.security.Role;
import org.restlet.util.Series;

public class Request
  extends Message
{
  private volatile ChallengeResponse challengeResponse;
  private volatile ClientInfo clientInfo;
  private volatile Conditions conditions;
  private volatile Series<Cookie> cookies;
  private volatile Reference hostRef;
  private volatile boolean loggable;
  private volatile int maxForwards;
  private volatile Method method;
  private volatile Uniform onResponse;
  private volatile Reference originalRef;
  private volatile Protocol protocol;
  private volatile ChallengeResponse proxyChallengeResponse;
  private volatile List<Range> ranges;
  private volatile Reference referrerRef;
  private volatile Reference resourceRef;
  private volatile Reference rootRef;
  
  public static Request getCurrent()
  {
    return Response.getCurrent() == null ? null : Response.getCurrent().getRequest();
  }
  
  public Request()
  {
    this((Method)null, (Reference)null, (Representation)null);
  }
  
  public Request(Method method, Reference resourceRef)
  {
    this(method, resourceRef, null);
  }
  
  public Request(Method method, Reference resourceRef, Representation entity)
  {
    super(entity);
    challengeResponse = null;
    clientInfo = null;
    conditions = null;
    cookies = null;
    hostRef = null;
    loggable = true;
    maxForwards = -1;
    this.method = method;
    originalRef = null;
    onResponse = null;
    proxyChallengeResponse = null;
    protocol = null;
    ranges = null;
    referrerRef = null;
    this.resourceRef = resourceRef;
    rootRef = null;
  }
  
  public Request(Method method, String resourceUri)
  {
    this(method, new Reference(resourceUri));
  }
  
  public Request(Method method, String resourceUri, Representation entity)
  {
    this(method, new Reference(resourceUri), entity);
  }
  
  public Request(Request request)
  {
    this(request.getMethod(), new Reference(request.getResourceRef()), request.getEntity());
    
    challengeResponse = request.getChallengeResponse();
    
    ClientInfo rci = request.getClientInfo();
    clientInfo = new ClientInfo();
    for (Preference<CharacterSet> o : rci.getAcceptedCharacterSets()) {
      clientInfo.getAcceptedCharacterSets().add(o);
    }
    for (Preference<Encoding> o : rci.getAcceptedEncodings()) {
      clientInfo.getAcceptedEncodings().add(o);
    }
    for (Preference<Language> o : rci.getAcceptedLanguages()) {
      clientInfo.getAcceptedLanguages().add(o);
    }
    for (Preference<MediaType> o : rci.getAcceptedMediaTypes()) {
      clientInfo.getAcceptedMediaTypes().add(o);
    }
    clientInfo.setAddress(rci.getAddress());
    clientInfo.setAgent(rci.getAgent());
    for (String o : rci.getForwardedAddresses()) {
      clientInfo.getForwardedAddresses().add(o);
    }
    clientInfo.setFrom(rci.getFrom());
    clientInfo.setPort(rci.getPort());
    
    clientInfo.setAgentAttributes(rci.getAgentAttributes());
    clientInfo.setAgentProducts(rci.getAgentProducts());
    clientInfo.setAuthenticated(rci.isAuthenticated());
    for (Expectation o : rci.getExpectations()) {
      clientInfo.getExpectations().add(o);
    }
    for (Principal o : rci.getPrincipals()) {
      clientInfo.getPrincipals().add(o);
    }
    for (Role o : rci.getRoles()) {
      clientInfo.getRoles().add(o);
    }
    clientInfo.setUser(rci.getUser());
    
    conditions = new Conditions();
    for (Tag o : request.getConditions().getMatch()) {
      conditions.getMatch().add(o);
    }
    conditions.setModifiedSince(request.getConditions().getModifiedSince());
    for (Tag o : request.getConditions().getNoneMatch()) {
      conditions.getNoneMatch().add(o);
    }
    conditions.setRangeDate(request.getConditions().getRangeDate());
    conditions.setRangeTag(request.getConditions().getRangeTag());
    conditions.setUnmodifiedSince(request.getConditions().getUnmodifiedSince());
    for (Cookie o : request.getCookies()) {
      getCookies().add(o);
    }
    hostRef = request.getHostRef();
    maxForwards = request.getMaxForwards();
    originalRef = (request.getOriginalRef() == null ? null : new Reference(request.getOriginalRef()));
    
    onResponse = request.getOnResponse();
    proxyChallengeResponse = request.getProxyChallengeResponse();
    protocol = request.getProtocol();
    for (Range o : request.getRanges()) {
      getRanges().add(o);
    }
    referrerRef = (request.getReferrerRef() == null ? null : new Reference(request.getReferrerRef()));
    
    rootRef = (request.getRootRef() == null ? null : request.getRootRef());
    for (Map.Entry<String, Object> e : request.getAttributes().entrySet()) {
      getAttributes().put(e.getKey(), e.getValue());
    }
    for (CacheDirective o : request.getCacheDirectives()) {
      getCacheDirectives().add(o);
    }
    setOnSent(request.getOnSent());
    for (Warning o : request.getWarnings()) {
      getWarnings().add(o);
    }
    setDate(request.getDate());
  }
  
  public boolean abort()
  {
    return false;
  }
  
  public void commit(Response response) {}
  
  public ChallengeResponse getChallengeResponse()
  {
    return challengeResponse;
  }
  
  public ClientInfo getClientInfo()
  {
    ClientInfo c = clientInfo;
    if (c == null) {
      synchronized (this)
      {
        c = clientInfo;
        if (c == null) {
          clientInfo = (c = new ClientInfo());
        }
      }
    }
    return c;
  }
  
  public Conditions getConditions()
  {
    Conditions c = conditions;
    if (c == null) {
      synchronized (this)
      {
        c = conditions;
        if (c == null) {
          conditions = (c = new Conditions());
        }
      }
    }
    return c;
  }
  
  public Series<Cookie> getCookies()
  {
    Series<Cookie> c = cookies;
    if (c == null) {
      synchronized (this)
      {
        c = cookies;
        if (c == null) {
          cookies = (c = new Series(Cookie.class));
        }
      }
    }
    return c;
  }
  
  public Reference getHostRef()
  {
    return hostRef;
  }
  
  public int getMaxForwards()
  {
    return maxForwards;
  }
  
  public Method getMethod()
  {
    return method;
  }
  
  public Uniform getOnResponse()
  {
    return onResponse;
  }
  
  public Reference getOriginalRef()
  {
    return originalRef;
  }
  
  public Protocol getProtocol()
  {
    Protocol result = protocol;
    if ((result == null) && (getResourceRef() != null))
    {
      result = getResourceRef().getSchemeProtocol();
      if (result == null) {
        result = getResourceRef().getBaseRef() != null ? getResourceRef().getBaseRef().getSchemeProtocol() : null;
      }
    }
    return result;
  }
  
  public ChallengeResponse getProxyChallengeResponse()
  {
    return proxyChallengeResponse;
  }
  
  public List<Range> getRanges()
  {
    List<Range> r = ranges;
    if (r == null) {
      synchronized (this)
      {
        r = ranges;
        if (r == null) {
          ranges = (r = new CopyOnWriteArrayList());
        }
      }
    }
    return r;
  }
  
  public Reference getReferrerRef()
  {
    return referrerRef;
  }
  
  public Reference getResourceRef()
  {
    return resourceRef;
  }
  
  public Reference getRootRef()
  {
    return rootRef;
  }
  
  public boolean isAsynchronous()
  {
    return getOnResponse() != null;
  }
  
  public boolean isConfidential()
  {
    return getProtocol() == null ? false : getProtocol().isConfidential();
  }
  
  public boolean isEntityAvailable()
  {
    boolean result = (Method.GET.equals(getMethod())) || (Method.HEAD.equals(getMethod()));
    if (result) {
      return false;
    }
    return super.isEntityAvailable();
  }
  
  public boolean isExpectingResponse()
  {
    return getMethod() == null ? false : getMethod().isReplying();
  }
  
  public boolean isLoggable()
  {
    return loggable;
  }
  
  public boolean isSynchronous()
  {
    return getOnResponse() == null;
  }
  
  public void setChallengeResponse(ChallengeResponse challengeResponse)
  {
    this.challengeResponse = challengeResponse;
  }
  
  public void setClientInfo(ClientInfo clientInfo)
  {
    this.clientInfo = clientInfo;
  }
  
  public void setConditions(Conditions conditions)
  {
    this.conditions = conditions;
  }
  
  public void setCookies(Series<Cookie> cookies)
  {
    synchronized (getCookies())
    {
      if (cookies != getCookies())
      {
        if (getCookies() != null) {
          getCookies().clear();
        }
        if (cookies != null) {
          getCookies().addAll(cookies);
        }
      }
    }
  }
  
  public void setHostRef(Reference hostRef)
  {
    this.hostRef = hostRef;
  }
  
  public void setHostRef(String hostUri)
  {
    setHostRef(new Reference(hostUri));
  }
  
  public void setLoggable(boolean loggable)
  {
    this.loggable = loggable;
  }
 
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2019. Infinite Loop Ltd