Example usage for com.google.gwt.autobean.shared AutoBean as

List of usage examples for com.google.gwt.autobean.shared AutoBean as

Introduction

In this page you can find the example usage for com.google.gwt.autobean.shared AutoBean as.

Prototype

T as();

Source Link

Document

Returns a proxy implementation of the T interface which will delegate to the underlying wrapped object, if any.

Usage

From source file:com.acme.gwt.server.TvViewerJsonBootstrap.java

License:Apache License

public String getViewerAsJson() {
    SimpleRequestProcessor p = new SimpleRequestProcessor(ServiceLayer.create(isld));
    TvViewer user = viewerProvider.get();
    if (user == null) {
        return "";
    }/*  w w w . j  a  v a 2 s  .co  m*/

    MessageFactory factory = MessageFactoryHolder.FACTORY;
    AutoBean<IdMessage> id = factory.id();
    try {
        id.as().setServerId(Base64Utils.toBase64(user.getId().toString().getBytes("UTF-8")));
    } catch (UnsupportedEncodingException e) {
        return "";
    }
    id.as().setStrength(Strength.PERSISTED);
    id.as().setTypeToken(TvViewerProxy.class.getName());

    AutoBean<RequestMessage> msg = factory.request();
    msg.as().setInvocations(new ArrayList<InvocationMessage>());
    InvocationMessage invocation = factory.invocation().as();
    invocation.setOperation("com.google.gwt.requestfactory.shared.impl.FindRequest::find");
    invocation.setParameters(new ArrayList<Splittable>());
    invocation.getParameters().add(AutoBeanCodex.encode(id));
    msg.as().getInvocations().add(invocation);

    String value = p.process(AutoBeanCodex.encode(msg).getPayload());

    ResponseMessage response = AutoBeanCodex.decode(factory, ResponseMessage.class, value).as();
    OperationMessage opMsg = response.getOperations().get(0);
    DefaultProxyStore store = new DefaultProxyStore();
    store.put(TvViewerProxy.STORE_KEY, AutoBeanCodex.encode(AutoBeanUtils.getAutoBean(opMsg)));

    return store.encode();
}

From source file:org.jboss.as.console.client.shared.properties.PropertyRecordCategory.java

License:Open Source License

public static String toString(AutoBean<PropertyRecord> instance) {
    PropertyRecord record = instance.as();
    return "(\"" + record.getKey() + "\" => \"" + record.getValue() + "\")";
}

From source file:org.switchyard.console.client.model.ArtifactReferenceCategory.java

License:Open Source License

/**
 * @param instance the bean instance./*from ww  w  .  ja v  a  2 s . co  m*/
 * @return a unique identifier for the instance.
 */
public static String key(AutoBean<? extends ArtifactReference> instance) {
    ArtifactReference ar = instance.as();
    return "" + ar.getName() + "::" + ar.getUrl();
}

From source file:org.switchyard.console.client.model.QNameCategory.java

License:Open Source License

/**
 * @param instance the bean instance./*from w  ww.  j a  v a 2s  .  c o  m*/
 * @return the "local" part of the bean's name.
 */
public static String localName(AutoBean<? extends HasQName> instance) {
    String name = instance.as().getName();
    if (name == null) {
        return null;
    }
    return NameTokens.parseQName(name)[1];
}

From source file:org.switchyard.console.client.model.QNameCategory.java

License:Open Source License

/**
 * @param instance the bean instance.//from   w  w w .j av  a 2s. com
 * @return the "namespace" part of the bean's name.
 */
public static String namespace(AutoBean<? extends HasQName> instance) {
    String name = instance.as().getName();
    if (name == null) {
        return null;
    }
    return NameTokens.parseQName(name)[0];
}