当前位置: 首页>>代码示例>>Java>>正文


Java IsisContext.closeSession方法代码示例

本文整理汇总了Java中org.apache.isis.core.runtime.system.context.IsisContext.closeSession方法的典型用法代码示例。如果您正苦于以下问题:Java IsisContext.closeSession方法的具体用法?Java IsisContext.closeSession怎么用?Java IsisContext.closeSession使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.isis.core.runtime.system.context.IsisContext的用法示例。


在下文中一共展示了IsisContext.closeSession方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: objectActions

import org.apache.isis.core.runtime.system.context.IsisContext; //导入方法依赖的package包/类
/**
 * Returns the object actions
 */
@GET
@Path("/object/{object}/{id}/actions")
@Produces("application/xml")
public Response objectActions(@PathParam("object") String object, @PathParam("id") String id) {
    Component component = null;
    AuthenticationSession session = new AnonymousSession();
    IsisContext.openSession(session);


    try {
        final ObjectAdapter instance = IsisContext.getPersistenceSession().getAdapterManager().adapterFor(RootOidDefault.deString(id, IsisContext.getOidMarshaller()));

        component = factory.createComponent(Component.MENU);
        component = component.acceptInstance(instance);
    } catch (Exception e) {
        log.error("viewObjectInstance exception", e);
    } finally {
        IsisContext.closeSession();
    }


    return Response.status(200).entity(component).build();


}
 
开发者ID:madytyoo,项目名称:dhtmlx-isis-viewer,代码行数:29,代码来源:ViewerObject.java

示例2: serviceActionInvoke

import org.apache.isis.core.runtime.system.context.IsisContext; //导入方法依赖的package包/类
/**
    * Action invocation
    * @param service
    * @param method
    * @return
    */
   @GET
@Path("/{service}/actions/{action}/invoke")
   @Produces("application/xml")
public Response serviceActionInvoke(@PathParam("service") String service,
                                       @PathParam("action") String method,
                                       @Context UriInfo info) {

       Component component = null;
       AuthenticationSession session = new AnonymousSession();
       IsisContext.openSession(session);

       try {
           final ObjectAdapter object = Utils.findService(service);
           final ObjectAction action = Utils.findAction(object, method);

           final int parameterCount = action.getParameterCount();
           final ObjectAdapter[] parameters = new ObjectAdapter[parameterCount];

           final ObjectAdapter result = action.execute(object, parameters);

           String dhx = info.getQueryParameters().getFirst("dhx");
           dhx = (dhx != null ? dhx : Component.GRID );
           component = factory.createComponent( dhx );

           String columns = info.getQueryParameters().getFirst("columns");
           if( columns != null ) {
               component.setParameter("columns",columns);
           }
           component.acceptObject(object,action, result);

       } catch (Exception e) {
           e.printStackTrace();
       } finally {
             IsisContext.closeSession();
       }


	return Response.status(200).entity(component).build();
}
 
开发者ID:madytyoo,项目名称:dhtmlx-isis-viewer,代码行数:46,代码来源:ViewerServiceDesktop.java

示例3: viewObjectInstance

import org.apache.isis.core.runtime.system.context.IsisContext; //导入方法依赖的package包/类
/**
 * Obtain a view for object ID
 *
 * @param object
 * @param id
 * @return
 */
@GET
@Path("/object/{object}/{id}")
@Produces("application/xml")
public Response viewObjectInstance(@PathParam("object") String object,
                                   @PathParam("id") String id,
                                   @Context HttpServletRequest request) {
    Component component = null;

    AuthenticationSession session = new AnonymousSession();
    IsisContext.openSession(session);

    try {
        ObjectAdapter instance = IsisContext.getPersistenceSession().getAdapterManager().adapterFor(RootOidDefault.deString(id, IsisContext.getOidMarshaller()));

        String code = loadDSL(object, "view", request);
        if (code.length() > 0) {
            ParserHelper parser = new ParserHelper();
            component = (Component) parser.parseForObjectInstance(code, instance);
        } else {

        }
    } catch (Exception e) {
        log.error("viewObjectInstance exception", e);
    } finally {
        IsisContext.closeSession();
    }


    return Response.status(200).entity(component).build();
}
 
开发者ID:madytyoo,项目名称:dhtmlx-isis-viewer,代码行数:38,代码来源:ViewerObject.java

示例4: viewObjectCollection

import org.apache.isis.core.runtime.system.context.IsisContext; //导入方法依赖的package包/类
/**
 * Obtain a view for object ID
 *
 * @param object
 * @param id
 * @return
 */
@GET
@Path("/object/{object}/{id}/collections/{collection}")
@Produces("application/xml")
public Response viewObjectCollection(@PathParam("object") String object, @PathParam("id") String id, @PathParam("collection") String collection, @Context UriInfo info) {
    Component component = null;

    AuthenticationSession session = new AnonymousSession();
    IsisContext.openSession(session);

    try {
        String dhx = info.getQueryParameters().getFirst("dhx");
        dhx = (dhx == null ? Component.GRID : dhx);

        ObjectAdapter instance = IsisContext.getPersistenceSession().getAdapterManager().adapterFor(RootOidDefault.deString(id, IsisContext.getOidMarshaller()));
        component = factory.createComponent(dhx);

        String columns = info.getQueryParameters().getFirst("columns");
        if (columns != null) {
            component.setParameter("columns", columns);
        }

        component = component.acceptInstance(instance, collection);
    } catch (Exception e) {
        log.error("viewObjectInstance exception", e);
    } finally {
        IsisContext.closeSession();
    }


    return Response.status(200).entity(component).build();
}
 
开发者ID:madytyoo,项目名称:dhtmlx-isis-viewer,代码行数:39,代码来源:ViewerObject.java

示例5: closeSession

import org.apache.isis.core.runtime.system.context.IsisContext; //导入方法依赖的package包/类
public static void closeSession() {
    if (IsisContext.inSession()) {
        IsisContext.getTransactionManager().endTransaction();
        IsisContext.closeSession();
    }
}
 
开发者ID:subes,项目名称:invesdwin-nowicket,代码行数:7,代码来源:IsisInjector.java

示例6: postProcess

import org.apache.isis.core.runtime.system.context.IsisContext; //导入方法依赖的package包/类
@Override
public void postProcess(ServerResponse serverResponse) {
    IsisContext.closeSession();
}
 
开发者ID:madytyoo,项目名称:dhtmlx-isis-viewer,代码行数:5,代码来源:ViewerInterceptor.java

示例7: saveObjectCode

import org.apache.isis.core.runtime.system.context.IsisContext; //导入方法依赖的package包/类
/**
    * Obtain a view for object ID
    *
    * @param object
    * @param id
    * @return
    */
   @POST
@Path("/objects/object/{object}/{id}")
   @Consumes("application/x-www-form-urlencoded")
   @Produces("application/xml")
public Response saveObjectCode(@PathParam("object") String object,
                                  @PathParam("id") String id,
                                  @Context HttpServletRequest request,
                                  MultivaluedMap<String, String> form) {


       AuthenticationSession session = new AnonymousSession();
       IsisContext.openSession(session);

       try {
           ObjectAdapter instance = IsisContext.getPersistenceSession().getAdapterManager().adapterFor(RootOidDefault.deString(id, IsisContext.getOidMarshaller()));

           List<String> enteredValue = form.get("code");
           if (enteredValue != null) {
               String code = enteredValue.get(0);
               if (code.length() > 0) {
                   ParserHelper parser = new ParserHelper();
                   parser.parseForObjectInstance(code, instance);

                   List<ParserError> errorList = parser.getErrors();
                   if( errorList.size() == 0 ) {
                       saveDSL(object,"view",code,request);
                   }
                   ParserErrorList errors = new ParserErrorList( errorList );



                   return Response.status(200).entity(errors).build();
               }
           }

       } catch (Exception e) {
           log.error("saveObjectCode exception", e);
       } finally {
           IsisContext.closeSession();
       }

       return Response.status(200).entity("").build();
   }
 
开发者ID:madytyoo,项目名称:dhtmlx-isis-viewer,代码行数:51,代码来源:ViewerCode.java

示例8: objectActionPrompt

import org.apache.isis.core.runtime.system.context.IsisContext; //导入方法依赖的package包/类
/**
 * Action prompt
 *
 * @param object
 * @param method
 * @return
 */
@GET
@Path("/object/{object}/{id}/actions/{action}")
@Produces("application/xml")
public Response objectActionPrompt(@PathParam("object") String object,
                                   @PathParam("id") String id,
                                   @PathParam("action") String method,
                                   @Context HttpServletRequest request) {

    Component component = null;
    AuthenticationSession session = new AnonymousSession();
    IsisContext.openSession(session);


    try {
        ObjectAdapter instance = IsisContext.getPersistenceSession().getAdapterManager().adapterFor(RootOidDefault.deString(id, IsisContext.getOidMarshaller()));
        final ObjectAction action = Utils.findAction(instance, method);

        /* The service prompts for parameters */
        if (action.promptForParameters(instance)) {
            String code = loadDSL(object, method,request);
            if (code.length() > 0) {
                ParserHelper parser = new ParserHelper();
                component = (Component) parser.parseForServicePrompt(code, object, method);

            } else {
                Form form = (Form) factory.createComponent(Component.FORM);
                form = (Form) form.acceptObject(instance, action);
                /* PATCH : the _ref must point to the object instance */
                String oid = Utils.computeOid(instance.getOid().enString(IsisContext.getOidMarshaller()));
                FormItem ref = form.get("_ref");
                ref.setValue("dhx/objects/object/" + instance.getSpecification().getFullIdentifier() + "/" + oid + "/actions/" + method);

                component = new ContainerForm(form);
            }
        }

    } catch (Exception e) {
        log.error("viewObjectInstance exception", e);
    } finally {
        IsisContext.closeSession();
    }

    return Response.status(200).entity(component).build();

}
 
开发者ID:madytyoo,项目名称:dhtmlx-isis-viewer,代码行数:53,代码来源:ViewerObject.java

示例9: serviceActionPost

import org.apache.isis.core.runtime.system.context.IsisContext; //导入方法依赖的package包/类
/**
 * Direct action invocation for post
 *
 * @param service
 * @param method
 * @return
 */
@POST
@Path("/object/{object}/{id}/actions/{action}/invoke")
@Produces("application/xml")
public Response serviceActionPost(@PathParam("object") String service,
                                  @PathParam("id") String id,
                                  @PathParam("action") String method) {
    int status = 404;
    Component component = null;
    AuthenticationSession session = new AnonymousSession();
    IsisContext.openSession(session);


    try {
        final ObjectAdapter instance = IsisContext.getPersistenceSession().getAdapterManager().adapterFor(RootOidDefault.deString(id, IsisContext.getOidMarshaller()));
        final ObjectAction action = Utils.findAction(instance, method);

        final List<ObjectActionParameter> parameterList = action.getParameters();
        final ObjectAdapter[] parameters = new ObjectAdapter[action.getParameterCount()];
        for (int i = 0; i < action.getParameterCount(); i++) {
            ObjectActionParameter parameter = parameterList.get(i);
            if (parameter.getSpecification().isParseable()) {

            }

        }

        final Consent consent = action.isProposedArgumentSetValid(instance, parameters);
        if (consent.isAllowed()) {
            final ObjectAdapter result = action.execute(instance, parameters);
            component = factory.createComponent(Component.REF);
            component = component.acceptInstance(result);
            status = 200;
        }


    } catch (Exception e) {
        log.error("viewObjectInstance exception", e);
    } finally {
        IsisContext.closeSession();
    }


    return Response.status(status).entity(component).build();
}
 
开发者ID:madytyoo,项目名称:dhtmlx-isis-viewer,代码行数:52,代码来源:ViewerObject.java

示例10: viewObjectProperty

import org.apache.isis.core.runtime.system.context.IsisContext; //导入方法依赖的package包/类
/**
 * Obtain a view for object ID
 *
 * @param object
 * @param id
 * @return
 */
@GET
@Path("/object/{object}/{id}/property/{property}")
public Response viewObjectProperty(@PathParam("object") String object, @PathParam("id") String id, @PathParam("property") String property, @Context HttpServletResponse response) {
    Component component = null;

    AuthenticationSession session = new AnonymousSession();
    IsisContext.openSession(session);

    try {

        ObjectAdapter instance = IsisContext.getPersistenceSession().getAdapterManager().adapterFor(RootOidDefault.deString(id, IsisContext.getOidMarshaller()));
        final ObjectSpecification specification = instance.getSpecification();
        final List<ObjectAssociation> fields = specification.getAssociations(ObjectAssociationFilters.dynamicallyVisible(IsisContext.getAuthenticationSession(), instance, Where.NOWHERE));
        for (ObjectAssociation field : fields) {
            if (property.equalsIgnoreCase(field.getId())) {
                if (field.getSpecification().getFullIdentifier().endsWith("BlobKey")) {
                    final ObjectAdapter associatedObject = field.get(instance);
                    if (associatedObject != null) {
                        BlobKey blobKey = (BlobKey) associatedObject.getObject();

                        BlobInfoFactory blobInfoFactory = new BlobInfoFactory(DatastoreServiceFactory.getDatastoreService());
                        BlobInfo blobInfo = blobInfoFactory.loadBlobInfo(blobKey);
                        BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();

                        byte[] image = blobstoreService.fetchData(blobKey, 0, blobInfo.getSize());

                        return Response.status(200).type(blobInfo.getContentType()).entity( image ).build();

                    }
                }
            }
        }

    } catch (Exception e) {
        log.error("viewObjectProperty exception", e);
    } finally {
        IsisContext.closeSession();
    }
    return Response.status(200).entity("").build();
}
 
开发者ID:madytyoo,项目名称:dhtmlx-isis-viewer,代码行数:48,代码来源:ViewerObject.java


注:本文中的org.apache.isis.core.runtime.system.context.IsisContext.closeSession方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。