/**************************************************************
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*
*************************************************************/
//_______________________________________________
// imports
import com.sun.star.uno.XComponentContext;
import com.sun.star.lib.uno.helper.Factory;
import com.sun.star.lib.uno.helper.WeakBase;
import com.sun.star.lang.XServiceInfo;
import com.sun.star.awt.*;
import com.sun.star.beans.*;
import com.sun.star.task.*;
import com.sun.star.uno.*;
import java.lang.*;
import javax.swing.*;
//_______________________________________________
// implementation
/** it implements a simple job component.
*
* Such jobs are executable in different ways:
*
* - registered for a special URL schema "vnd.sun.star.jobs:*" and used from the generic dispatch framework
* - the global com.sun.star.task.JobExecutor service and registered for special events.
*
*/
public class AsyncJob extends WeakBase implements XServiceInfo, XAsyncJob
{
//___________________________________________
// const
public final XComponentContext m_xCmpCtx;
/** the const list of supported uno service names. */
public static final java.lang.String[] SERVICENAMES = {"com.sun.star.task.AsyncJob"};
/** the const uno implementation name.
* It must be an unique value! The best naming schema seems to use
* a registered domain in reverse order ...
*/
public static final java.lang.String IMPLEMENTATIONNAME = "com.sun.star.comp.framework.java.services.AsyncJob";
//___________________________________________
// interface
/** initialize a new instance of this class with default values. */
public AsyncJob( XComponentContext xCompContext )
{
m_xCmpCtx = xCompContext;
}
//___________________________________________
/** starts execution of this job.
*
* @param lArgs
* list which contains:
*
* - generic job configuration data
* - job specific configuration data
* - some environment informations
* - may optional arguments of a corresponding dispatch request
*
*
* @params xListener
* callback to the executor of this job, which control our life time
*
* @throws com.sun.star.lang.IllegalArgumentException
* if given argument list seems to be wrong
*/
public synchronized void executeAsync(com.sun.star.beans.NamedValue[] lArgs ,
com.sun.star.task.XJobListener xListener)
throws com.sun.star.lang.IllegalArgumentException
{
// For asynchronous jobs a valid listener reference is guaranteed normally ...
if (xListener == null)
throw new com.sun.star.lang.IllegalArgumentException("invalid listener");
// extract all possible sub list of given argument list
com.sun.star.beans.NamedValue[] lGenericConfig = null;
com.sun.star.beans.NamedValue[] lJobConfig = null;
com.sun.star.beans.NamedValue[] lEnvironment = null;
com.sun.star.beans.NamedValue[] lDynamicData = null;
int c = lArgs.length;
for (int i=0; i