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


Java Service类代码示例

本文整理汇总了Java中com.wm.app.b2b.server.Service的典型用法代码示例。如果您正苦于以下问题:Java Service类的具体用法?Java Service怎么用?Java Service使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Service类属于com.wm.app.b2b.server包,在下文中一共展示了Service类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: respond

import com.wm.app.b2b.server.Service; //导入依赖的package包/类
/**
 * Sets the HTTP response status, headers, and body for the current service invocation.
 *
 * @param code        The HTTP response status code to be returned.
 * @param message     The HTTP response status message to be returned; if null, the standard message for the given
 *                    code will be used.
 * @param headers     The HTTP headers to be returned; if null, no custom headers will be added to the response.
 * @param content     The HTTP response body to be returned.
 * @param contentType The MIME content type of the response body being returned.
 * @param charset     The character set used if a text response is being returned.
 * @throws ServiceException If an I/O error occurs.
 */
public static void respond(int code, String message, IData headers, InputStream content, String contentType, Charset charset) throws ServiceException {
    try {
        HttpHeader response = Service.getHttpResponseHeader();

        if (response == null) {
            // service was not invoked via HTTP, so throw an exception for HTTP statuses >= 400
            if (code >= 400) ExceptionHelper.raise(StringHelper.normalize(content, charset));
        } else {
            setResponseStatus(response, code, message);
            setContentType(response, contentType, charset);
            setHeaders(response, headers);
            setResponseBody(response, content);
        }
    } catch (IOException ex) {
        ExceptionHelper.raise(ex);
    }
}
 
开发者ID:Permafrost,项目名称:Tundra.java,代码行数:30,代码来源:ServiceHelper.java

示例2: invoke

import com.wm.app.b2b.server.Service; //导入依赖的package包/类
/**
 * Invokes the given service with the given pipeline synchronously.
 *
 * @param service           The service to be invoked.
 * @param pipeline          The input pipeline used when invoking the service.
 * @param raise             If true will rethrow exceptions thrown by the invoked service.
 * @param clone             If true the pipeline will first be cloned before being used by the invocation.
 * @param logError          Logs a caught exception if true and raise is false, otherwise exception is not logged.
 * @return                  The output pipeline returned by the service invocation.
 * @throws ServiceException If raise is true and the service throws an exception while being invoked.
 */
public static IData invoke(String service, IData pipeline, boolean raise, boolean clone, boolean logError) throws ServiceException {
    if (service != null) {
        if (pipeline == null) pipeline = IDataFactory.create();

        try {
            IDataUtil.merge(Service.doInvoke(NSName.create(service), normalize(pipeline, clone)), pipeline);
        } catch (Exception exception) {
            if (raise) {
                ExceptionHelper.raise(exception);
            } else {
                pipeline = addExceptionToPipeline(pipeline, exception);
                if (logError) ServerAPI.logError(exception);
            }
        }
    }

    return pipeline;
}
 
开发者ID:Permafrost,项目名称:Tundra.java,代码行数:30,代码来源:ServiceHelper.java

示例3: chain

import com.wm.app.b2b.server.Service; //导入依赖的package包/类
public ListenableFuture<IData> chain(String pool, ListenableFuture<IData> future, String service, IData input,
		String ref, boolean merge, boolean interruptable) throws ThreadException {
	if (future == null) {
		return null;
	}

	ISThreadPoolExecutor ex = getExecutor(pool);

	if (ex instanceof VolatileISThreadPoolExecutor) {
		VolatileISThreadPoolExecutor vol = (VolatileISThreadPoolExecutor) ex;
		int priority = vol.getPriority(ref);
		AsyncFunction<IData, IData> callback = new ReactiveAsyncFunction(ex, service, input, priority, merge,
				Service.getSession().getSessionID(), interruptable);

		return Futures.transform(future, callback);
	} else {
		throw new IllegalStateException(
				"The creation of ServiceThread using a priority reference is only possible within volatile thread pool");
	}
}
 
开发者ID:teivah,项目名称:reactiveWM,代码行数:21,代码来源:ReactiveServiceThreadManager.java

示例4: log

import com.wm.app.b2b.server.Service; //导入依赖的package包/类
/**
 * Adds an activity log statement to the given BizDocEnvelope.
 * TODO: convert this to a pure java service, rather than an invoke of a flow service.
 *
 * @param bizdoc            The BizDocEnvelope to add the activity log statement to.
 * @param messageType       The type of message to be logged.
 * @param messageClass      The class of the message to be logged.
 * @param messageSummary    The summary of the message to be logged.
 * @param messageDetails    The detail of the message to be logged.
 * @throws ServiceException If an error occurs while logging.
 */
public static void log(BizDocEnvelope bizdoc, String messageType, String messageClass, String messageSummary, String messageDetails) throws ServiceException {
    IData input = IDataFactory.create();
    IDataCursor cursor = input.getCursor();
    IDataUtil.put(cursor, "$bizdoc", bizdoc);
    IDataUtil.put(cursor, "$type", messageType);
    IDataUtil.put(cursor, "$class", messageClass);
    IDataUtil.put(cursor, "$summary", messageSummary);
    IDataUtil.put(cursor, "$message", messageDetails);
    cursor.destroy();

    try {
        Service.doInvoke(LOG_SERVICE, input);
    } catch (Exception ex) {
        ExceptionHelper.raise(ex);
    }
}
 
开发者ID:Permafrost,项目名称:TundraTN.java,代码行数:28,代码来源:BizDocEnvelopeHelper.java

示例5: put_object_in_session

import com.wm.app.b2b.server.Service; //导入依赖的package包/类
public static final Values put_object_in_session (Values in)
   {
       Values out = in;
	// --- <<IS-START(put_object_in_session)>> ---
	// @sigtype java 3.0
	// [i] object:0:required object
	// [i] field:0:required objectName
Object obj = in.get("object");
String strObjectName = in.getString("objectName");
Session session = Service.getSession();

// Data type
Object tobj = session.get(strObjectName);
if (tobj != null)
	session.remove(strObjectName);

session.put(strObjectName, obj);
	// --- <<IS-END>> ---
       return out;
               
}
 
开发者ID:iandrosov,项目名称:SimpleToolBox,代码行数:22,代码来源:sys.java

示例6: getUser

import com.wm.app.b2b.server.Service; //导入依赖的package包/类
public static final void getUser (IData pipeline)
       throws ServiceException
{
	// --- <<IS-START(getUser)>> ---
	// @sigtype java 3.5
	// [o] field:0:required user_id
IDataHashCursor idc = pipeline.getHashCursor();
Session session = Service.getSession();
User user = session.getUser();

String user_id = user.getName();

idc.first();
idc.insertAfter("user_id",user_id);
	// --- <<IS-END>> ---

               
}
 
开发者ID:iandrosov,项目名称:SimpleToolBox,代码行数:19,代码来源:user.java

示例7: getPackagePath

import com.wm.app.b2b.server.Service; //导入依赖的package包/类
public static final void getPackagePath (IData pipeline)
       throws ServiceException
{
	// --- <<IS-START(getPackagePath)>> ---
	// @specification pgp.specifications:getPackagePathSpec
	// @subtype unknown
	// @sigtype java 3.5
	
	// Handle input params
	IDataCursor pc = pipeline.getCursor();
	String packageName = IDataUtil.getString(pc, "package");
	String subdir      = IDataUtil.getString(pc, "subDir");
	String filename    = IDataUtil.getString(pc, "fileName");
	
	if (packageName == null) {
	    packageName = Service.getServiceEntry().getPackage().getName();
	}
	
	String packageDir = Server.getResources().getPackageDir(packageName)
	    .getAbsolutePath().concat(File.separator);
	
	if (new File(packageDir).exists()) {
	    if (subdir != null) {
	        packageDir = packageDir.concat(subdir).concat(File.separator);
	    }
	    if (filename != null) {
	        packageDir = packageDir.concat(filename);
	    }
	    IDataUtil.put(pc, "path", packageDir);
	}
	pc.destroy();
	
	// --- <<IS-END>> ---

               
}
 
开发者ID:SoftwareAG,项目名称:webmethods-integrationserver-pgpencryption,代码行数:37,代码来源:common.java

示例8: setResponseBody

import com.wm.app.b2b.server.Service; //导入依赖的package包/类
/**
 * Sets the response body in the given HTTP response.
 *
 * @param response The HTTP response to set the response body in.
 * @param content  The content to set the response body to.
 * @throws ServiceException If an I/O error occurs.
 */
private static void setResponseBody(HttpHeader response, InputStream content) throws ServiceException {
    if (response == null) return;

    try {
        if (content == null) content = new ByteArrayInputStream(new byte[0]);
        Service.setResponse(BytesHelper.normalize(content));
    } catch (IOException ex) {
        ExceptionHelper.raise(ex);
    }
}
 
开发者ID:Permafrost,项目名称:Tundra.java,代码行数:18,代码来源:ServiceHelper.java

示例9: run

import com.wm.app.b2b.server.Service; //导入依赖的package包/类
/**
 * Invokes the specified service with the provided pipeline and session.
 */
@Override
public void run() {
    try {
        Service.doInvoke(service, session, pipeline);
    } catch(Exception ex) {
        if (ex instanceof RuntimeException) {
            throw (RuntimeException)ex;
        } else {
            throw new RuntimeException(ex);
        }
    }
}
 
开发者ID:Permafrost,项目名称:Tundra.java,代码行数:16,代码来源:RunnableService.java

示例10: createServiceThread

import com.wm.app.b2b.server.Service; //导入依赖的package包/类
public ServiceThread createServiceThread(String pool, String service, IData input, String ref,
		boolean interruptable) throws ThreadException {
	ISThreadPoolExecutor ex = getExecutor(pool);

	if (ex instanceof VolatileISThreadPoolExecutor) {
		VolatileISThreadPoolExecutor vol = (VolatileISThreadPoolExecutor) ex;

		int priority = vol.getPriority(ref);

		return createServiceThread(service, input, Service.getSession(), priority, interruptable);
	} else {
		throw new IllegalStateException(
				"The creation of ServiceThread using a priority reference is only possible within volatile thread pool");
	}
}
 
开发者ID:teivah,项目名称:reactiveWM,代码行数:16,代码来源:ReactiveServiceThreadManager.java

示例11: save

import com.wm.app.b2b.server.Service; //导入依赖的package包/类
/**
 * Updates the given Trading Networks delivery queue with any changes that may have occurred.
 *
 * @param queue             The queue whose changes are to be saved.
 * @throws ServiceException If a database error occurs.
 */
public static void save(DeliveryQueue queue) throws ServiceException {
    if (queue == null) return;

    try {
        IData pipeline = IDataFactory.create();
        IDataCursor cursor = pipeline.getCursor();
        IDataUtil.put(cursor, "queue", queue);
        cursor.destroy();

        Service.doInvoke(UPDATE_QUEUE_SERVICE_NAME, pipeline);
    } catch(Exception ex) {
        ExceptionHelper.raise(ex);
    }
}
 
开发者ID:Permafrost,项目名称:TundraTN.java,代码行数:21,代码来源:DeliveryQueueHelper.java

示例12: get_object_from_session

import com.wm.app.b2b.server.Service; //导入依赖的package包/类
public static final Values get_object_from_session (Values in)
   {
       Values out = in;
	// --- <<IS-START(get_object_from_session)>> ---
	// @sigtype java 3.0
	// [i] field:0:required objectName
	// [o] object:0:required object
String strObjectName = in.getString("objectName");
Session session = Service.getSession();
out.put("object", session.get(strObjectName));
	// --- <<IS-END>> ---
       return out;
               
}
 
开发者ID:iandrosov,项目名称:SimpleToolBox,代码行数:15,代码来源:sys.java

示例13: invoke_thread

import com.wm.app.b2b.server.Service; //导入依赖的package包/类
public static final void invoke_thread (IData pipeline)
       throws ServiceException
{
	// --- <<IS-START(invoke_thread)>> ---
	// @sigtype java 3.5
	// [i] field:0:required service
	// [i] field:0:required data
	// [i] record:0:required in
	// [i] object:0:required obj
   IDataHashCursor idc = pipeline.getHashCursor();
   idc.first( "service" );

String svc_name = (String) idc.getValue();
try
{
	NSName nsName = NSName.create(svc_name);
	ServiceThread thrd = Service.doThreadInvoke(nsName, pipeline);
	thrd.getData();
}
catch (Exception e)
{
	throw new ServiceException(e.getMessage());
}
idc.destroy();
	// --- <<IS-END>> ---

               
}
 
开发者ID:iandrosov,项目名称:SimpleToolBox,代码行数:29,代码来源:service.java

示例14: call

import com.wm.app.b2b.server.Service; //导入依赖的package包/类
/**
 * Invokes the provided service with the provided pipeline and session against the job.
 *
 * @return              The output pipeline returned by the invocation.
 * @throws Exception    If the service encounters an error.
 */
public IData call() throws Exception {
    long startTime = System.nanoTime();

    IData output = null;
    Exception exception = null;

    Thread owningThread = Thread.currentThread();
    String owningThreadPrefix = owningThread.getName();
    String startDateTime = DateTimeHelper.now("datetime");

    try {
        BizDocEnvelope bizdoc = job.getBizDocEnvelope();

        owningThread.setName(MessageFormat.format("{0}: TaskID={1} TaskStart={2} PROCESSING", owningThreadPrefix, job.getJobId(), startDateTime));

        if (bizdoc != null) {
            BizDocEnvelopeHelper.setStatus(job.getBizDocEnvelope(), null, DEQUEUED_USER_STATUS, statusSilence);
        }

        GuaranteedJobHelper.log(job, "MESSAGE", "Processing", MessageFormat.format("Dequeued from {0} queue \"{1}\"", queue.getQueueType(), queue.getQueueName()), MessageFormat.format("Service \"{0}\" attempting to process document", service.getFullName()));

        IDataCursor cursor = pipeline.getCursor();
        IDataUtil.put(cursor, "$task", job);

        if (bizdoc != null) {
            bizdoc = BizDocEnvelopeHelper.get(bizdoc.getInternalId(), true);
            IDataUtil.put(cursor, "bizdoc", bizdoc);
            IDataUtil.put(cursor, "sender", ProfileCache.getInstance().get(bizdoc.getSenderId()));
            IDataUtil.put(cursor, "receiver", ProfileCache.getInstance().get(bizdoc.getReceiverId()));
        }

        cursor.destroy();

        output = Service.doInvoke(service, session, pipeline);

        owningThread.setName(MessageFormat.format("{0}: TaskID={1} TaskStart={2} TaskEnd={3} COMPLETED", owningThreadPrefix, job.getJobId(), startDateTime, DateTimeHelper.now("datetime")));
    } catch (Exception ex) {
        owningThread.setName(MessageFormat.format("{0}: TaskID={1} TaskStart={2} TaskEnd={3} FAILED: {4}", owningThreadPrefix, job.getJobId(), startDateTime, DateTimeHelper.now("datetime"), ExceptionHelper.getMessage(ex)));
        exception = ex;
    } finally {
        owningThread.setName(owningThreadPrefix);
        setJobCompleted(output, exception, (System.nanoTime() - startTime)/1000000L);
        if (exception != null) throw exception;
    }

    return output;
}
 
开发者ID:Permafrost,项目名称:TundraTN.java,代码行数:54,代码来源:CallableGuaranteedJob.java

示例15: get_dir

import com.wm.app.b2b.server.Service; //导入依赖的package包/类
public static final void get_dir (IData pipeline)
       throws ServiceException
{
	// --- <<IS-START(get_dir)>> ---
	// @subtype unknown
	// @sigtype java 3.5
	// [o] field:0:required pkg_config
	// [o] field:1:required config_file_list
	IDataHashCursor idc = pipeline.getHashCursor();
	
		// Get input values
	   	idc.first();
		String key = idc.getKey();
		
		Values vl = ValuesEmulator.getValues(pipeline, key);
		String pkg = Service.getPackageName(vl);
		File fl = ServerAPI.getPackageConfigDir(pkg);
		String config_dir = fl.getPath();
	
		try
		{	
			// Get list of files in a give directory
	        File fname = new File(config_dir);
	        String[] file_list = fname.list();
			fname = null;
		   	idc.first();
			idc.insertAfter("config_file_list", file_list);
		}
		catch(Exception e)
		{
			throw new ServiceException(e.getMessage());
		}
	
		// Setup output message
		idc.first();
		idc.insertAfter("pkg_config",config_dir + File.separator);
	
		idc.destroy();
	// --- <<IS-END>> ---

               
}
 
开发者ID:iandrosov,项目名称:SimpleExcel,代码行数:43,代码来源:util.java


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