本文整理汇总了Java中org.apache.isis.core.runtime.system.context.IsisContext.openSession方法的典型用法代码示例。如果您正苦于以下问题:Java IsisContext.openSession方法的具体用法?Java IsisContext.openSession怎么用?Java IsisContext.openSession使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.isis.core.runtime.system.context.IsisContext
的用法示例。
在下文中一共展示了IsisContext.openSession方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例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();
}
示例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();
}
示例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();
}
示例5: preProcess
import org.apache.isis.core.runtime.system.context.IsisContext; //导入方法依赖的package包/类
@Override
public ServerResponse preProcess(HttpRequest httpRequest, ResourceMethod resourceMethod) throws Failure, WebApplicationException {
AuthenticationSession session = new AnonymousSession();
IsisContext.openSession(session);
return null;
}
示例6: 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();
}
示例7: 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();
}
示例8: 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();
}
示例9: 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();
}