code
stringlengths 1
2.01M
| repo_name
stringlengths 3
62
| path
stringlengths 1
267
| language
stringclasses 231
values | license
stringclasses 13
values | size
int64 1
2.01M
|
|---|---|---|---|---|---|
/*
* GetPluginOption.java
*
* Copyright (c) 2009, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.remote.options;
import net.xeoh.plugins.base.Option;
/**
* @author rb
*/
public interface ExportVanillaObjectOption extends Option {
//
}
|
100json-jspf
|
modules/plugins/remote.xmlrpcdelight/src/net/xeoh/plugins/remote/options/ExportVanillaObjectOption.java
|
Java
|
bsd
| 1,738
|
/*
* RemoteAPIImpl.java
*
* Copyright (c) 2008, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. Redistributions in
* binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other
* materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
package net.xeoh.plugins.remote.impl.xmlrpcdelight;
import java.io.IOException;
import java.net.InetAddress;
import java.net.ServerSocket;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.UnknownHostException;
import java.util.HashMap;
import java.util.Random;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import java.util.logging.Logger;
import net.xeoh.plugins.base.Plugin;
import net.xeoh.plugins.base.PluginConfiguration;
import net.xeoh.plugins.base.annotations.Capabilities;
import net.xeoh.plugins.base.annotations.PluginImplementation;
import net.xeoh.plugins.base.annotations.events.Init;
import net.xeoh.plugins.base.annotations.events.Shutdown;
import net.xeoh.plugins.base.annotations.injections.InjectPlugin;
import net.xeoh.plugins.base.annotations.meta.Author;
import net.xeoh.plugins.base.util.OptionUtils;
import net.xeoh.plugins.remote.ExportResult;
import net.xeoh.plugins.remote.PublishMethod;
import net.xeoh.plugins.remote.RemoteAPIXMLRPCDelight;
import net.xeoh.plugins.remote.options.ExportVanillaObjectOption;
import net.xeoh.plugins.remote.options.exportvanillaobject.OptionExportName;
import net.xeoh.plugins.remote.util.internal.PluginExport;
import net.xeoh.plugins.remote.util.vanilla.ExportResultImpl;
import net.xeoh.plugins.remotediscovery.RemoteDiscovery;
import net.xeoh.plugins.remotediscovery.util.RemoteAPIDiscoveryUtil;
import org.apache.xmlrpc.WebServer;
import org.apache.xmlrpc.XmlRpcHandler;
import de.dfki.util.xmlrpc.XmlRpc;
import de.dfki.util.xmlrpc.common.XmlRpcConnection;
import de.dfki.util.xmlrpc.server.XmlRpcHandlerFactory;
/**
* RemoteApi implementation for DFKI's XMLRPC Delight
*
* @author Ralf Biedert, Andreas Lauer, Christian Reuschling
*
*/
@Author(name = "Ralf Biedert, Andreas Lauer, Christian Reuschling")
@PluginImplementation
public class RemoteAPIImpl implements RemoteAPIXMLRPCDelight {
/**
* @return
*/
private static int getFreePort() {
try {
final ServerSocket serverSocket = new ServerSocket(0);
final int port = serverSocket.getLocalPort();
serverSocket.close();
return port;
} catch (final IOException e) {
e.printStackTrace();
}
return 1025 + new Random().nextInt(50000);
}
/** */
@InjectPlugin
public PluginConfiguration configuration;
/** */
@InjectPlugin
public RemoteDiscovery discovery;
/**
* Where this server can be found
*/
private String exportUrl = "http://";
/** */
private RemoteAPIDiscoveryUtil remoteAPIDiscoveryUtil;
/**
* Lock server from concurrent access
*/
private final Lock serverLock = new ReentrantLock();
/**
* Log events
*/
final Logger logger = Logger.getLogger(this.getClass().getName());
/** Used for unexport */
HashMap<Plugin, String> handlerToPluginMap = new HashMap<Plugin, String>();
/**
* Server object to receive requests
*/
volatile WebServer server;
/* (non-Javadoc)
* @see net.xeoh.plugins.remote.RemoteAPI#exportPlugin(net.xeoh.plugins.base.Plugin)
*/
public ExportResult exportPlugin(final Plugin plugin) {
this.serverLock.lock();
if (this.server == null) {
initServer();
}
this.serverLock.unlock();
// If this server is still null now, return
if (this.server == null) return null;
//
// Try to find the most appropriate export name
//
String exportName = PluginExport.getExportName(plugin);
/*
// FIXME: Might need improvement.
final Class<?>[] interfaces = plugin.getClass().getInterfaces();
// All interfaces this class implements
for (final Class<?> class1 : interfaces) {
if (Plugin.class.isAssignableFrom(class1)) {
exportName = class1.getSimpleName();
}
}
*/
// The URL we export at
final String exportURL = this.exportUrl + exportName;
this.serverLock.lock();
try {
final XmlRpcHandler delightHandler = XmlRpcHandlerFactory.createHandlerFor(plugin);
this.handlerToPluginMap.put(plugin, exportName);
this.server.addHandler(exportName, delightHandler);
} finally {
this.serverLock.unlock();
}
final URI createURI = createURI(exportURL);
// Announce the plugin
this.discovery.announcePlugin(plugin, getPublishMethod(), createURI);
return new ExportResultImpl(createURI);
}
/**
* @return .
*/
@Capabilities
public String[] getCapabilites() {
return new String[] { "xmlrpc", "XMLRPC", "xmlrpcdelight", "XMLRPCDELIGHT" };
}
public PublishMethod getPublishMethod() {
return PublishMethod.XMLRPCDELIGHT;
}
public <R extends Plugin> R getRemoteProxy(final URI url, final Class<R> remote) {
// In case this is a remote url, let the discoverer work.
if (this.remoteAPIDiscoveryUtil.isDiscoveryURI(url))
return this.remoteAPIDiscoveryUtil.getRemoteProxy(url, remote);
try {
String handler = url.getPath();
handler = handler.substring(handler.lastIndexOf('/') + 1);
final R client = XmlRpc.createClient(remote, handler, XmlRpcConnection.connect(url.toURL()));
return client;
} catch (final IOException e) {
e.printStackTrace();
} catch (final Exception e) {
e.printStackTrace();
}
return null;
}
/** */
@Init
public void init() {
this.remoteAPIDiscoveryUtil = new RemoteAPIDiscoveryUtil(this.discovery, this);
}
/** */
@Shutdown
public void shutdown() {
// shutdown in einem Extra-Thread, damit es sich nicht verhakt
if (this.server != null) {
final Thread shutDownThread = new Thread(new Runnable() {
public void run() {
RemoteAPIImpl.this.server.shutdown();
RemoteAPIImpl.this.server = null;
RemoteAPIImpl.this.logger.info("XmlRpc server shut down");
}
});
shutDownThread.start();
}
}
public void unexportPlugin(final Plugin plugin) {
final String strPluginID = this.handlerToPluginMap.get(plugin);
this.handlerToPluginMap.remove(plugin);
this.server.removeHandler(strPluginID);
}
/**
* Internally used to create an URL without 'try'
*
* @param string
* @return
*/
URI createURI(final String string) {
try {
return new URI(string);
} catch (final URISyntaxException e) {
e.printStackTrace();
}
return null;
}
/**
* Try to setup the server if it's not already there
*/
void initServer() {
int NUM_RETRIES = 10;
int SERVER_PORT = getFreePort();
try {
SERVER_PORT = Integer.parseInt(this.configuration.getConfiguration(RemoteAPIImpl.class, "xmlrpc.port"));
} catch (final NumberFormatException e) {
// Do nothing, as the most probable reason is the config was not set.
}
this.logger.info("Setting up XMLRPC-server on port " + SERVER_PORT);
boolean succeded = false;
while (!succeded && NUM_RETRIES-- > 0) {
try {
this.exportUrl += InetAddress.getLocalHost().getCanonicalHostName();
this.exportUrl += ":" + SERVER_PORT + "/";
this.server = new WebServer(SERVER_PORT);
// start wird schon im Konstruktor ausgeführt
// this.server.start();
this.logger.info("XMLRPC server listening on baseroot " + this.exportUrl);
succeded = true;
} catch (final UnknownHostException e) {
this.logger.warning("Unable to create XMLRPC handler for this host");
e.printStackTrace();
} catch (final IOException e) {
this.logger.warning("Unable to create XMLRPC handler for this host");
e.printStackTrace();
}
SERVER_PORT++;
}
}
/* (non-Javadoc)
* @see net.xeoh.plugins.remote.impl.RemoteAPIXMLRPCDelight#exportVanillaObject(java.lang.Object, net.xeoh.plugins.base.Option[])
*/
public URI exportVanillaObject(Object toExport, ExportVanillaObjectOption... option) {
this.serverLock.lock();
if (this.server == null) {
initServer();
}
this.serverLock.unlock();
//
//final String exportName = toExport.getClass().getSimpleName() + "@" + System.nanoTime();
final OptionUtils<ExportVanillaObjectOption> ou = new OptionUtils<ExportVanillaObjectOption>(option);
if (ou.contains(OptionExportName.class)) {
ou.get(OptionExportName.class);
// TODO: Get export name
}
// If this server is still null now, return
if (this.server == null) return null;
return null;
}
}
|
100json-jspf
|
modules/plugins/remote.xmlrpcdelight/src/net/xeoh/plugins/remote/impl/xmlrpcdelight/RemoteAPIImpl.java
|
Java
|
bsd
| 11,155
|
/*
* ClassWorlds.java
*
* Copyright (c) 2009, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.sandbox;
import java.io.File;
import org.codehaus.classworlds.ClassRealm;
import org.codehaus.classworlds.ClassWorld;
/**
* @author rb
*
*/
public class ClassWorldsTest {
/**
* @param args
* @throws Exception
*/
public static void main(String[] args) throws Exception {
ClassWorld cw = new ClassWorld();
ClassRealm realm = cw.newRealm("http://x.as?2");
realm.addConstituent(new File("bin/").toURI().toURL());
ClassLoader classLoader = realm.getClassLoader();
Class<?> loadClass = classLoader.loadClass("net.xeoh.plugins.base.Plugin");
System.out.println(loadClass);
ClassRealm realm2 = cw.newRealm("ASd");
ClassLoader classLoader2 = realm2.getClassLoader();
Class<?> loadClass2 = classLoader2.loadClass("net.xeoh.plugins.base.Plugin");
System.out.println(loadClass2);
}
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/sandbox/ClassWorldsTest.java
|
Java
|
bsd
| 2,517
|
/*
* Profiling.java
*
* Copyright (c) 2011, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.sandbox;
public class Profiling {
public static void main(String[] args) {
while(true) System.out.println(System.nanoTime());
}
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/sandbox/Profiling.java
|
Java
|
bsd
| 1,733
|
/*
* Cache.java
*
* Copyright (c) 2010, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.sandbox;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Collection;
import net.xeoh.plugins.base.PluginManager;
import net.xeoh.plugins.base.impl.PluginManagerFactory;
import net.xeoh.plugins.base.options.getplugin.OptionPluginSelector;
import net.xeoh.plugins.base.options.getplugin.PluginSelector;
import net.xeoh.plugins.base.util.JSPFProperties;
import net.xeoh.plugins.remote.ExportResult;
import net.xeoh.plugins.remote.PublishMethod;
import net.xeoh.plugins.remote.RemoteAPI;
import net.xeoh.plugins.testplugins.testannotations.TestAnnotations;
public class JSONTest {
public static void main(String[] args) throws URISyntaxException, InterruptedException {
final JSPFProperties props = new JSPFProperties();
props.setProperty(PluginManager.class, "cache.enabled", "true");
props.setProperty(PluginManager.class, "cache.mode", "weak");
props.setProperty(PluginManager.class, "cache.file", "jspf.cache");
PluginManager pm = PluginManagerFactory.createPluginManager(props);
pm.addPluginsFrom(new URI("classpath://*"));
TestAnnotations plugin = pm.getPlugin(TestAnnotations.class);
RemoteAPI remote = pm.getPlugin(RemoteAPI.class, new OptionPluginSelector<RemoteAPI>(new PluginSelector<RemoteAPI>() {
public boolean selectPlugin(final RemoteAPI p) {
if (p.getPublishMethod().equals(PublishMethod.JSON)) return true;
return false;
}
}));
ExportResult exportPlugin = remote.exportPlugin(plugin);
Collection<URI> exportURIs = exportPlugin.getExportURIs();
for (URI uri : exportURIs) {
System.out.println(uri);
}
Thread.sleep(6000000);
pm.shutdown();
}
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/sandbox/JSONTest.java
|
Java
|
bsd
| 3,379
|
/*
* Futures.java
*
* Copyright (c) 2009, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.sandbox;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorCompletionService;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
/**
* @author rb
*
*/
public class Futures {
/**
* @param args
*/
@SuppressWarnings("unchecked")
public static void main(String[] args) {
// Execute collection asynchronously
ExecutorService newCachedThreadPool = Executors.newCachedThreadPool();
final ExecutorCompletionService<String> ecs = new ExecutorCompletionService(newCachedThreadPool);
Future<String> submit = ecs.submit(new Callable<String>() {
public String call() {
try {
Thread.sleep(1012331872);
} catch (InterruptedException e) {
e.printStackTrace();
}
return "Yo";
}
});
// Wait at most half a second (TODO: Make this configurable)
try {
String string = submit.get(500, TimeUnit.MILLISECONDS);
if (string == null) {
System.out.println("OOPs");
return;
}
System.out.println("Okay " + string);
} catch (final InterruptedException e) {
System.err.println("Error while waiting for a getRemoteProxy() result");
e.printStackTrace();
} catch (final ExecutionException e) {
e.printStackTrace();
} catch (final TimeoutException e) {
e.printStackTrace();
} catch (final SecurityException e) {
e.printStackTrace();
} finally {
System.out.println("Cancelling");
newCachedThreadPool.shutdownNow();
submit.cancel(true);
}
System.out.println("xx");
}
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/sandbox/Futures.java
|
Java
|
bsd
| 3,594
|
package net.xeoh.plugins.sandbox;
import java.net.URL;
import java.net.URLClassLoader;
import net.xeoh.plugins.base.Plugin;
import net.xeoh.plugins.base.util.PluginManagerUtil;
public class PrintClasspath {
public static void main(String[] args) {
// Get the System Classloader
ClassLoader sysClassLoader = ClassLoader.getSystemClassLoader();
// Get the URLs
URL[] urls = ((URLClassLoader) sysClassLoader.getParent()).getURLs();
for (int i = 0; i < urls.length; i++) {
System.out.println(urls[i].getFile());
}
PluginManagerUtil util = new PluginManagerUtil(null);
util.getPlugin(Plugin.class, "a", "b");
util.getPlugin(Plugin.class, "a");
util.getPlugin(Plugin.class);
}
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/sandbox/PrintClasspath.java
|
Java
|
bsd
| 787
|
/*
* JMDNSTest.java
*
* Copyright (c) 2009, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.sandbox;
import static net.jcores.jre.CoreKeeper.$;
import java.io.Serializable;
import java.util.concurrent.atomic.AtomicInteger;
import net.xeoh.plugins.base.PluginManager;
import net.xeoh.plugins.base.impl.PluginManagerFactory;
import net.xeoh.plugins.base.util.uri.ClassURI;
import net.xeoh.plugins.diagnosis.local.Diagnosis;
import net.xeoh.plugins.diagnosis.local.DiagnosisMonitor;
import net.xeoh.plugins.diagnosis.local.DiagnosisStatus;
/**
* @author rb
*
*/
public class DiagnosisTest {
/**
* @param args
*/
public static void main(String[] args) {
PluginManager pm = PluginManagerFactory.createPluginManager();
pm.addPluginsFrom(ClassURI.CLASSPATH);
final AtomicInteger i = new AtomicInteger();
pm.getPlugin(Diagnosis.class).replay("1", new DiagnosisMonitor<Serializable>() {
@Override
public void onStatusChange(DiagnosisStatus<Serializable> status) {
if(!$(status.getValue()).string().contains("processadditional/param")) return;
System.out.println(status.getValue());
i.incrementAndGet();
}
});
System.out.println(i);
}
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/sandbox/DiagnosisTest.java
|
Java
|
bsd
| 2,802
|
/*
* URI.java
*
* Copyright (c) 2009, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.sandbox;
import java.net.URI;
import java.net.URISyntaxException;
/**
* @author rb
*
*/
public class URITest {
/**
* @param args
* @throws URISyntaxException
*/
public static void main(String[] args) throws URISyntaxException {
URI u = new URI("http://xxx:123/abc.x");
System.out.println(u);
System.out.println(u.getScheme());
System.out.println(u.getHost());
System.out.println(u.getPort());
System.out.println(u.getPath());
}
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/sandbox/URITest.java
|
Java
|
bsd
| 2,091
|
/*
* OptionsTest.java
*
* Copyright (c) 2009, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.sandbox;
import net.xeoh.plugins.base.options.GetPluginOption;
import net.xeoh.plugins.base.options.getplugin.OptionCapabilities;
import net.xeoh.plugins.base.util.OptionHandler;
import net.xeoh.plugins.base.util.OptionUtils;
/**
* @author rb
*
*/
public class OptionsTest {
/**
* @param args
*/
public static void main(String[] args) {
test(new OptionCapabilities("yo", "no"));
}
/**
* @param options
*/
static void test(GetPluginOption... options) {
final OptionUtils<GetPluginOption> ou = new OptionUtils<GetPluginOption>(options);
System.out.println(ou.contains(OptionCapabilities.class));
System.out.println(ou.get(OptionCapabilities.class).getCapabilities().length);
ou.handle(GetPluginOption.class, new OptionHandler<GetPluginOption>() {
public void handle(GetPluginOption option) {
System.out.println(option);
}
});
}
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/sandbox/OptionsTest.java
|
Java
|
bsd
| 2,559
|
/*
* JMDNSTest.java
*
* Copyright (c) 2009, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.sandbox;
import java.io.IOException;
import java.util.Random;
import javax.jmdns.JmDNS;
import javax.jmdns.ServiceInfo;
import javax.jmdns.impl.tasks.ServiceResolver;
/**
* @author rb
*
*/
public class JMDNSTestDiscovery {
/**
* @param args
* @throws IOException
* @throws InterruptedException
*/
public static void main(String[] args) throws IOException, InterruptedException {
ServiceResolver.ANNOUNCE_OVERRIDE = true;
int port = new Random().nextInt(32000);
System.out.println("Create JmDNS " + port);
JmDNS jmdns = JmDNS.create();
System.out.println("Create");
final ServiceInfo service = ServiceInfo.create("_httpx._tcp.local.", "Port@" + port, port, 0, 0, ":-)");
System.out.println("Register");
jmdns.registerService(service);
for (int i = 0; i < 10; i++) {
System.out.println("Query:");
ServiceInfo[] list = jmdns.list("_httpx._tcp.local.");
for (ServiceInfo serviceInfo : list) {
System.out.println(serviceInfo);
}
Thread.sleep(200);
}
}
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/sandbox/JMDNSTestDiscovery.java
|
Java
|
bsd
| 2,736
|
/*
* ClassFinderTest.java
*
* Copyright (c) 2009, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.sandbox;
import static net.jcores.jre.CoreKeeper.$;
import java.io.File;
import java.net.MalformedURLException;
import java.util.Collection;
import java.util.List;
import net.xeoh.plugins.base.Plugin;
import net.xeoh.plugins.base.PluginInformation;
import net.xeoh.plugins.base.PluginInformation.Information;
import net.xeoh.plugins.base.PluginManager;
import net.xeoh.plugins.base.impl.PluginManagerFactory;
import net.xeoh.plugins.base.util.PluginManagerUtil;
/**
* @author rb
*/
public class LoadIsolated {
/**
* @param args
* @throws MalformedURLException
* @throws ClassNotFoundException
*/
public static void main(String[] args) throws MalformedURLException,
ClassNotFoundException {
PluginManager pm = PluginManagerFactory.createPluginManager();
List<File> list = $(".").file().dir().filter(".*jar$").print().list();
for (File file : list) {
pm.addPluginsFrom(file.toURI());
}
PluginInformation pi = pm.getPlugin(PluginInformation.class);
PluginManagerUtil pmu = new PluginManagerUtil(pm);
Collection<Plugin> plugins = pmu.getPlugins();
for (Plugin plugin : plugins) {
System.out.println(plugin + ": ");
$(pi.getInformation(Information.CLASSPATH_ORIGIN, plugin)).print();
}
}
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/sandbox/LoadIsolated.java
|
Java
|
bsd
| 2,993
|
/*
* ShutdownTest.java
*
* Copyright (c) 2009, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.sandbox;
import java.io.File;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Collection;
import net.xeoh.plugins.base.Plugin;
import net.xeoh.plugins.base.PluginInformation;
import net.xeoh.plugins.base.PluginInformation.Information;
import net.xeoh.plugins.base.PluginManager;
import net.xeoh.plugins.base.impl.PluginManagerFactory;
import net.xeoh.plugins.base.util.JSPFProperties;
import net.xeoh.plugins.base.util.PluginManagerUtil;
/**
* @author rb
*
*/
public class ShutdownTest {
/**
* @param args
* @throws URISyntaxException
* @throws InterruptedException
*/
public static void main(String[] args) throws URISyntaxException,
InterruptedException {
final JSPFProperties props = new JSPFProperties();
props.setProperty(PluginManager.class, "cache.enabled", "true");
props.setProperty(PluginManager.class, "cache.file", "myjspf.cache");
PluginManager pm = PluginManagerFactory.createPluginManager(props);
System.out.println("X");
pm.addPluginsFrom(new URI("classpath://*"));
pm.addPluginsFrom(new File("coolplugin.jar").toURI());
System.out.println("Y");
final PluginInformation pi = pm.getPlugin(PluginInformation.class);
final PluginManagerUtil pmu = new PluginManagerUtil(pm);
Collection<Plugin> plugins = pmu.getPlugins(Plugin.class);
for (Plugin p : plugins) {
Collection<String> information = pi.getInformation(Information.CLASSPATH_ORIGIN, p);
for (String string : information) {
System.out.println(p + ": " + string);
}
}
Thread.sleep(5000);
pm.shutdown();
}
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/sandbox/ShutdownTest.java
|
Java
|
bsd
| 3,350
|
/*
* Profiling.java
*
* Copyright (c) 2011, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.sandbox;
import java.io.File;
import java.net.URI;
import net.xeoh.plugins.base.PluginInformation;
import net.xeoh.plugins.base.PluginManager;
import net.xeoh.plugins.base.impl.PluginManagerFactory;
import net.xeoh.plugins.base.options.getinformation.InformationAuthors;
import net.xeoh.plugins.base.util.JSPFProperties;
public class TestTiming {
public static void main(String[] args) {
System.out.println(new File("bin/").toURI());
final JSPFProperties props = new JSPFProperties();
props.setProperty(PluginManager.class, "cache.enabled", "true");
props.setProperty(PluginManager.class, "cache.mode", "weak");
props.setProperty(PluginManager.class, "cache.file", "jspf.cache");
props.setProperty(PluginManager.class, "logging.level", "INFO");
props.setProperty(PluginManager.class, "classpath.filter.default.pattern", "");
PluginManager pm = PluginManagerFactory.createPluginManager(props);
pm.addPluginsFrom(URI.create("classpath://*"));
final PluginInformation pi = pm.getPlugin(PluginInformation.class);
final InformationAuthors information = pi.getInformation(pi, InformationAuthors.class);
}
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/sandbox/TestTiming.java
|
Java
|
bsd
| 2,806
|
/*
* JMDNSTest.java
*
* Copyright (c) 2009, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.sandbox;
import java.io.IOException;
import javax.jmdns.JmDNS;
import javax.jmdns.ServiceInfo;
import org.freshvanilla.rmi.Proxies;
import org.freshvanilla.rmi.VanillaRmiServer;
/**
* @author rb
*
*/
public class JMDNSTest {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
JmDNS jmdns = JmDNS.create();
VanillaRmiServer<Object> newServer = Proxies.newServer("XXX", 12345, new Object());
final ServiceInfo service = ServiceInfo.create(".jo", "asdkjsah", 12345, 0, 0, "asdjk");
jmdns.registerService(service);
System.out.println("1");
newServer.close();
System.out.println("2");
jmdns.close();
System.out.println("3");
}
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/sandbox/JMDNSTest.java
|
Java
|
bsd
| 2,374
|
/*
* RemoteTest.java
*
* Copyright (c) 2008, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.remote;
import java.net.URI;
import net.xeoh.plugins.base.PluginManager;
import net.xeoh.plugins.base.impl.PluginManagerFactory;
import net.xeoh.plugins.base.options.getplugin.OptionPluginSelector;
import net.xeoh.plugins.base.options.getplugin.PluginSelector;
import net.xeoh.plugins.base.util.JSPFProperties;
import net.xeoh.plugins.remote.impl.lipermi.RemoteAPIImpl;
import net.xeoh.plugins.testplugins.testannotations.TestAnnotations;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
/**
* @author rb
*
*/
public class RemoteTest {
private PluginManager pm;
/**
* @throws Exception
*/
@Before
public void setUp() throws Exception {
final JSPFProperties props = new JSPFProperties();
props.setProperty(PluginManager.class, "cache.enabled", "true");
props.setProperty(PluginManager.class, "cache.mode", "weak");
props.setProperty(PluginManager.class, "cache.file", "jspf.cache");
props.setProperty(PluginManager.class, "supervision.enabled", "true");
props.setProperty(RemoteAPIImpl.class, "export.port", "12345");
this.pm = PluginManagerFactory.createPluginManager(props);
this.pm.addPluginsFrom(new URI("classpath://*"));
}
/**
* @throws Exception
*/
@After
public void tearDown() throws Exception {
this.pm.shutdown();
}
/**
*
*/
@Test
public void testERMI() {
Assert.assertNotNull(this.pm);
final TestAnnotations plugin = this.pm.getPlugin(TestAnnotations.class);
final RemoteAPI remote = this.pm.getPlugin(RemoteAPI.class, new OptionPluginSelector<RemoteAPI>(new PluginSelector<RemoteAPI>() {
public boolean selectPlugin(final RemoteAPI p) {
if (p.getPublishMethod().equals(PublishMethod.LIPE)) return true;
return false;
}
}));
Assert.assertNotNull(plugin);
Assert.assertNotNull(remote);
final ExportResult exportPluginURL = remote.exportPlugin(plugin);
System.out.println(exportPluginURL);
Assert.assertNotNull(exportPluginURL);
final TestAnnotations remoteProxy = remote.getRemoteProxy(exportPluginURL.getExportURIs().iterator().next(), TestAnnotations.class);
// System.out.println(remoteProxy);
Assert.assertNotNull(remoteProxy);
Assert.assertEquals(remoteProxy.getInitStatus(), "INIT OK");
}
/**
*
*/
@Test
public void testLIPE() {
Assert.assertNotNull(this.pm);
final TestAnnotations plugin = this.pm.getPlugin(TestAnnotations.class);
final RemoteAPI remote = this.pm.getPlugin(RemoteAPI.class, new OptionPluginSelector<RemoteAPI>(new PluginSelector<RemoteAPI>() {
public boolean selectPlugin(final RemoteAPI p) {
if (p.getPublishMethod().equals(PublishMethod.LIPE)) return true;
return false;
}
}));
Assert.assertNotNull(plugin);
Assert.assertNotNull(remote);
final ExportResult exportPluginURL = remote.exportPlugin(plugin);
System.out.println(exportPluginURL.getExportURIs().iterator().next());
Assert.assertNotNull(exportPluginURL);
final TestAnnotations remoteProxy = remote.getRemoteProxy(exportPluginURL.getExportURIs().iterator().next(), TestAnnotations.class);
// System.out.println(remoteProxy);
Assert.assertNotNull(remoteProxy);
Assert.assertEquals(remoteProxy.getInitStatus(), "INIT OK");
}
/**
*
*/
@Test
public void testXMLRPC() {
Assert.assertNotNull(this.pm);
final TestAnnotations plugin = this.pm.getPlugin(TestAnnotations.class);
this.pm.getPlugin(RemoteAPI.class);
final RemoteAPI remote = this.pm.getPlugin(RemoteAPI.class, new OptionPluginSelector<RemoteAPI>(new PluginSelector<RemoteAPI>() {
public boolean selectPlugin(final RemoteAPI p) {
if (p.getPublishMethod().equals(PublishMethod.XMLRPC)) return true;
return false;
}
}));
Assert.assertNotNull(plugin);
Assert.assertNotNull(remote);
final ExportResult exportPluginURL = remote.exportPlugin(plugin);
Assert.assertNotNull(exportPluginURL);
final TestAnnotations remoteProxy = remote.getRemoteProxy(exportPluginURL.getExportURIs().iterator().next(), TestAnnotations.class);
// System.out.println(remoteProxy);
Assert.assertNotNull(remoteProxy);
// TODO: Why does this line block sometimes?
Assert.assertEquals(remoteProxy.getInitStatus(), "INIT OK");
}
/**
*
*/
@Test
public void testXMLRPCDelight() {
Assert.assertNotNull(this.pm);
final TestAnnotations plugin = this.pm.getPlugin(TestAnnotations.class);
this.pm.getPlugin(RemoteAPI.class);
final RemoteAPI remote = this.pm.getPlugin(RemoteAPI.class, new OptionPluginSelector<RemoteAPI>(new PluginSelector<RemoteAPI>() {
public boolean selectPlugin(final RemoteAPI p) {
if (p.getPublishMethod().equals(PublishMethod.XMLRPCDELIGHT))
return true;
return false;
}
}));
Assert.assertNotNull(plugin);
Assert.assertNotNull(remote);
final ExportResult exportPluginURL = remote.exportPlugin(plugin);
Assert.assertNotNull(exportPluginURL);
final TestAnnotations remoteProxy = remote.getRemoteProxy(exportPluginURL.getExportURIs().iterator().next(), TestAnnotations.class);
// System.out.println(remoteProxy);
Assert.assertNotNull(remoteProxy);
// TODO: Why does this line block sometimes?
Assert.assertEquals(remoteProxy.getInitStatus(), "INIT OK");
}
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/remote/RemoteTest.java
|
Java
|
bsd
| 7,697
|
/*
* PluginTest.java
*
* Copyright (c) 2008, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.remote;
import java.net.URI;
import java.util.ArrayList;
import java.util.Collection;
import net.xeoh.plugins.base.Plugin;
import net.xeoh.plugins.base.PluginManager;
import net.xeoh.plugins.base.impl.PluginManagerFactory;
import net.xeoh.plugins.base.util.JSPFProperties;
import net.xeoh.plugins.remotediscovery.DiscoveredPlugin;
import net.xeoh.plugins.remotediscovery.RemoteDiscovery;
import net.xeoh.plugins.remotediscovery.options.discover.OptionCallback;
import net.xeoh.plugins.testplugins.testannotations.TestAnnotations;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
/**
* @author rb
*
*/
public class DiscoveryPluginTest3 {
private PluginManager pm;
/**
* @throws Exception
*/
@Before
public void setUp() throws Exception {
final JSPFProperties props = new JSPFProperties();
props.setProperty(PluginManager.class, "supervision.enabled", "true");
this.pm = PluginManagerFactory.createPluginManager(props);
System.out.println(11);
this.pm.addPluginsFrom(new URI("classpath://*"));
System.out.println(22);
}
/**
*
*/
@After
public void tearDown() {
this.pm.shutdown();
}
/** */
@Test
public void testDiscovery() {
System.out.println(1);
RemoteAPIXMLRPC p = this.pm.getPlugin(RemoteAPIXMLRPC.class);
System.out.println(2);
TestAnnotations p2 = this.pm.getPlugin(TestAnnotations.class);
System.out.println(p);
System.out.println(p2);
p.exportPlugin(p2);
System.out.println("exported to " + p2);
RemoteDiscovery plugin = this.pm.getPlugin(RemoteDiscovery.class);
//while(true) {
Collection<DiscoveredPlugin> discover = plugin.discover(Plugin.class, new OptionCallback(new OptionCallback.Callback() {
public void pluginsDiscovered(Collection<DiscoveredPlugin> plugins) {
ArrayList<DiscoveredPlugin> test = new ArrayList<DiscoveredPlugin>(plugins);
for (DiscoveredPlugin discoveredPlugin : test) {
System.out.println("Callback says: " + discoveredPlugin.getPublishURI() + " @" + discoveredPlugin.getDistance());
}
}
public void timeout() {
System.out.println("Timeout!");
}
}, 5000));
for (DiscoveredPlugin discoveredPlugin : discover) {
System.out.println(">>> " + discoveredPlugin.getPublishURI());
}
}
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/remote/DiscoveryPluginTest3.java
|
Java
|
bsd
| 4,249
|
/*
* PluginTest.java
*
* Copyright (c) 2008, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.remote;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.Collection;
import net.xeoh.plugins.base.Plugin;
import net.xeoh.plugins.base.PluginManager;
import net.xeoh.plugins.base.impl.PluginManagerFactory;
import net.xeoh.plugins.remotediscovery.DiscoveredPlugin;
import net.xeoh.plugins.remotediscovery.RemoteDiscovery;
import net.xeoh.plugins.testplugins.testannotations.TestAnnotations;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
/**
* @author rb
*
*/
public class DirectDiscoveryTest {
private PluginManager pm;
/**
* @throws Exception
*/
@Before
public void setUp() throws Exception {
this.pm = PluginManagerFactory.createPluginManager();
this.pm.addPluginsFrom(new URI("classpath://*"));
}
/**
* @throws Exception
*/
@After
public void tearDown() throws Exception {
this.pm.shutdown();
}
/**
* @throws URISyntaxException
* @throws InterruptedException */
@Test
public void testDiscovery() throws URISyntaxException, InterruptedException {
TestAnnotations p2 = this.pm.getPlugin(TestAnnotations.class);
RemoteDiscovery p = this.pm.getPlugin(RemoteDiscovery.class);
System.out.println(1);
p.announcePlugin(p2, PublishMethod.ERMI, new URI("ermi://lala:123/Jojo"));
System.out.println(2);
Collection<DiscoveredPlugin> discover = p.discover(Plugin.class);
System.out.println(3);
for (DiscoveredPlugin dp : discover) {
int distance = dp.getDistance();
System.out.println(dp.getPublishURI() + " " + distance);
}
}
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/remote/DirectDiscoveryTest.java
|
Java
|
bsd
| 3,355
|
/*
* PluginTest.java
*
* Copyright (c) 2008, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.remote;
import java.net.URI;
import java.net.URISyntaxException;
import junit.framework.Assert;
import net.xeoh.plugins.base.Plugin;
import net.xeoh.plugins.base.PluginManager;
import net.xeoh.plugins.base.impl.PluginManagerFactory;
import net.xeoh.plugins.base.util.JSPFProperties;
import net.xeoh.plugins.testplugins.testannotations.TestAnnotations;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
/**
* @author rb
*
*/
public class DiscoverPluginTest {
private PluginManager pm;
/**
* @throws Exception
*/
@Before
public void setUp() throws Exception {
final JSPFProperties props = new JSPFProperties();
props.setProperty(PluginManager.class, "cache.enabled", "false");
props.setProperty(PluginManager.class, "cache.file", "/tmp/xxxjspf.cache");
props.setProperty(PluginManager.class, "logging.level", "ALL");
this.pm = PluginManagerFactory.createPluginManager(props);
this.pm.addPluginsFrom(new URI("classpath://*"));
}
/**
* @throws Exception
*/
@After
public void tearDown() throws Exception {
this.pm.shutdown();
}
/**
* @throws URISyntaxException */
@Test
public void testDiscovery() throws URISyntaxException {
RemoteAPILipe p = this.pm.getPlugin(RemoteAPILipe.class);
TestAnnotations p2 = this.pm.getPlugin(TestAnnotations.class);
System.out.println("GO");
ExportResult exportPlugin = p.exportPlugin(p2);
System.out.println("1");
Assert.assertNotNull(exportPlugin);
System.out.println("2");
Plugin rp = p.getRemoteProxy(new URI("discover://nearest"), TestAnnotations.class);
System.out.println(rp);
Plugin remoteProxy = p.getRemoteProxy(new URI("discover://any"), Plugin.class);
Assert.assertNotNull(remoteProxy);
TestAnnotations remoteProxy2 = p.getRemoteProxy(new URI("discover://nearest"), TestAnnotations.class);
Assert.assertNotNull(remoteProxy2);
String injectionStatus = remoteProxy2.getInjectionStatus();
Assert.assertEquals(injectionStatus, "INJECTION OK");
System.out.println("YO");
Plugin youngest = p.getRemoteProxy(new URI("discover://youngest"), Plugin.class);
Assert.assertNotNull(youngest);
Plugin oldest = p.getRemoteProxy(new URI("discover://oldest"), Plugin.class);
Assert.assertNotNull(oldest);
}
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/remote/DiscoverPluginTest.java
|
Java
|
bsd
| 4,148
|
/*
* TestInitImpl.java
*
* Copyright (c) 2008, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.testplugins.testannotations.impl;
import java.lang.reflect.Method;
import net.xeoh.plugins.base.annotations.PluginImplementation;
import net.xeoh.plugins.base.annotations.configuration.ConfigurationFile;
import net.xeoh.plugins.base.annotations.meta.Author;
import net.xeoh.plugins.base.annotations.meta.Version;
/**
* @author rb
*
*/
@Author(name = "AUTHOR OK")
@Version(version = 667)
@ConfigurationFile(file="config.properties")
@PluginImplementation
public class TestAnnotationsImpl extends TestAnnotationsAbtractImpl {
public static void main(String[] args) {
for (final Method method : TestAnnotationsImpl.class.getMethods()) {
String implementationMethodId = method.toString();
System.out.println(implementationMethodId);
}
}
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/testplugins/testannotations/impl/TestAnnotationsImpl.java
|
Java
|
bsd
| 2,430
|
/*
* TestInitImpl.java
*
* Copyright (c) 2008, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.testplugins.testannotations.impl;
import net.xeoh.plugins.base.annotations.Capabilities;
import net.xeoh.plugins.base.annotations.PluginImplementation;
import net.xeoh.plugins.base.annotations.Timer;
import net.xeoh.plugins.base.annotations.configuration.IsDisabled;
import net.xeoh.plugins.base.annotations.meta.Author;
import net.xeoh.plugins.base.annotations.meta.Version;
import net.xeoh.plugins.testplugins.testannotations.TestAnnotations;
/**
* @author rb
*
*/
@IsDisabled
@Version(version = 1000000)
@Author(name = "Ralf Biedert")
@PluginImplementation
public class TestIsDisabled implements TestAnnotations {
/**
* @return .
*/
@Capabilities
public String[] getCapabilities() {
return new String[] { "IsDisabled" };
}
/**
* @return .
*/
@Timer(period = 50)
public boolean timerMeLala() {
System.out.println("THIS MUST NEVER BE PRINTED OR YOUR IsDisabled does not work!");
return false;
}
public String getInitStatus() {
// TODO Auto-generated method stub
return null;
}
public String getInjectionStatus() {
// TODO Auto-generated method stub
return null;
}
public String getThreadStatus() {
// TODO Auto-generated method stub
return null;
}
public String getTimerStatus() {
// TODO Auto-generated method stub
return null;
}
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/testplugins/testannotations/impl/TestIsDisabled.java
|
Java
|
bsd
| 3,086
|
/*
* TestInitImpl.java
*
* Copyright (c) 2008, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.testplugins.testannotations.impl;
import net.xeoh.plugins.base.annotations.Capabilities;
import net.xeoh.plugins.base.annotations.Thread;
import net.xeoh.plugins.base.annotations.Timer;
import net.xeoh.plugins.base.annotations.events.Init;
import net.xeoh.plugins.base.annotations.events.PluginLoaded;
import net.xeoh.plugins.base.annotations.injections.InjectPlugin;
import net.xeoh.plugins.informationbroker.InformationBroker;
import net.xeoh.plugins.informationbroker.util.InformationBrokerUtil;
import net.xeoh.plugins.remote.RemoteAPI;
import net.xeoh.plugins.testplugins.testannotations.TestAnnotations;
/**
* @author rb
*
*/
public class TestAnnotationsAbtractImpl implements TestAnnotations {
/**
*
*/
@InjectPlugin
public InformationBrokerUtil bus;
@InjectPlugin
public InformationBroker busbus;
String init = "INIT FAILED";
String thread = "THREAD FAILED";
String timer = "TIMER FAILED";
/**
* @return .
*/
@Capabilities
public String[] getCapabilities() {
return new String[] { "SUNSHINE", "RAIN" };
}
public String getInitStatus() {
return this.init;
}
public String getInjectionStatus() {
System.out.println("GET STATUS CALLED " + this.bus);
return this.bus != null && this.busbus != null && this.bus.getObject() == this.busbus ? "INJECTION OK" : "INJECTION FAILED";
}
public String getThreadStatus() {
return this.thread;
}
public String getTimerStatus() {
return this.timer;
}
/**
*
*/
@Init
public void initMeLala() {
this.init = "INIT OK";
System.out.println("Plugin Initialized");
// throw new NullPointerException();
}
/**
*
*/
@Thread
public void threadMeLala() {
this.thread = "THREAD OK";
}
/**
*
*/
//@Thread
public void bigbang() {
System.out.println("Testing VisualVM Big Bang Theory");
double d = 3.14;
while (true) {
System.getenv("" + System.currentTimeMillis());
d *= Math.sin(d);
}
}
/**
* @return .
*/
@Timer(period = 50)
public boolean timerMeLala() {
this.timer = "TIMER OK";
return true;
}
/**
* @param p
*/
@SuppressWarnings("boxing")
@PluginLoaded
public void newPlugin(RemoteAPI p) {
System.out.printf("PluginLoaded (%d): %s\n", System.currentTimeMillis(), p);
}
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/testplugins/testannotations/impl/TestAnnotationsAbtractImpl.java
|
Java
|
bsd
| 4,243
|
/*
* TestInit.java
*
* Copyright (c) 2008, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.testplugins.testannotations;
import net.xeoh.plugins.testplugins.core.TestCore;
/**
* @author rb
*
*/
public interface TestAnnotations extends TestCore {
/**
* @return .
*/
public String getInitStatus(); // 'INIT OK'
/**
* @return .
*/
public String getInjectionStatus(); // 'INJECTION OK'
/**
* @return .
*/
public String getThreadStatus(); // 'THREAD OK'
/**
* @return .
*/
public String getTimerStatus(); // 'TIMER OK'
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/testplugins/testannotations/TestAnnotations.java
|
Java
|
bsd
| 2,139
|
/*
* TestInitImpl.java
*
* Copyright (c) 2008, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.testplugins.testdoubleinclude.impl;
import net.xeoh.plugins.base.annotations.PluginImplementation;
import net.xeoh.plugins.base.annotations.events.Init;
import net.xeoh.plugins.base.annotations.injections.InjectPlugin;
import net.xeoh.plugins.testplugins.testannotations.TestAnnotations;
import net.xeoh.plugins.testplugins.testdoubleinclude.TestDoubleInclude;
/**
* @author rb
*
*/
@PluginImplementation
public class TestDoubleIncludeImpl implements TestDoubleInclude {
/**
*
*/
@InjectPlugin
public TestAnnotations annotations;
/**
*
*/
@Init
public void init() {
final String initStatus = this.annotations.getInitStatus();
System.out.println("I am fine if this is sensible: " + initStatus);
}
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/testplugins/testdoubleinclude/impl/TestDoubleIncludeImpl.java
|
Java
|
bsd
| 2,411
|
/*
* TestDoubleIncludePlugin.java
*
* Copyright (c) 2008, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.testplugins.testdoubleinclude;
import net.xeoh.plugins.testplugins.core.TestCore;
/**
* @author rb
*
*/
public interface TestDoubleInclude extends TestCore {
//
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/testplugins/testdoubleinclude/TestDoubleInclude.java
|
Java
|
bsd
| 1,810
|
/*
* TestInit.java
*
* Copyright (c) 2008, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.testplugins.core;
/**
* @author rb
*
*/
public interface Test2Core extends TestCore {
//
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/testplugins/core/Test2Core.java
|
Java
|
bsd
| 1,716
|
/*
* TestInit.java
*
* Copyright (c) 2008, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.testplugins.core;
import net.xeoh.plugins.base.Plugin;
/**
* @author rb
*
*/
public interface TestCore extends Plugin {
//
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/testplugins/core/TestCore.java
|
Java
|
bsd
| 1,751
|
/*
* TestInner.java
*
* Copyright (c) 2011, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.testplugins.testinner;
import net.xeoh.plugins.base.annotations.PluginImplementation;
import net.xeoh.plugins.base.annotations.events.Init;
public class TestInner {
@PluginImplementation
public static class TestInnerInner implements TestInnerInterface {
@Init
public void init() {
System.out.println("I am there");
}
}
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/testplugins/testinner/TestInner.java
|
Java
|
bsd
| 1,957
|
/*
* TestInit.java
*
* Copyright (c) 2008, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.testplugins.testinner;
import net.xeoh.plugins.base.Plugin;
/**
* @author rb
*
*/
public interface TestInnerInterface extends Plugin {
//
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/testplugins/testinner/TestInnerInterface.java
|
Java
|
bsd
| 1,766
|
/*
* Class.java
*
* Copyright (c) 2010, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.testplugins.classification;
import net.xeoh.plugins.base.Plugin;
/**
* @author rb
*
*/
public interface Class extends Plugin {
/**
* @return .
*/
public int classy();
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/testplugins/classification/Class.java
|
Java
|
bsd
| 1,774
|
/*
* Class.java
*
* Copyright (c) 2010, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.testplugins.classification.impl;
import net.xeoh.plugins.base.annotations.PluginImplementation;
/**
* @author rb
*
*/
@PluginImplementation
public class Class implements net.xeoh.plugins.testplugins.classification.Class {
/* (non-Javadoc)
* @see net.xeoh.plugins.testplugins.classification.Class#classy()
*/
@Override
public int classy() {
return 123;
}
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/testplugins/classification/impl/Class.java
|
Java
|
bsd
| 1,983
|
/*
* PluginTest.java
*
* Copyright (c) 2008, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.core;
import java.net.URI;
import java.util.Collection;
import junit.framework.Assert;
import net.xeoh.plugins.base.PluginInformation;
import net.xeoh.plugins.base.PluginInformation.Information;
import net.xeoh.plugins.base.PluginManager;
import net.xeoh.plugins.base.impl.PluginManagerFactory;
import net.xeoh.plugins.base.util.JSPFProperties;
import net.xeoh.plugins.testplugins.testannotations.TestAnnotations;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
/**
* @author rb
*
*/
public class PluginManagerCapabilities {
private PluginManager pm;
/**
* @throws Exception
*/
@Before
public void setUp() throws Exception {
final JSPFProperties props = new JSPFProperties();
props.setProperty(PluginManager.class, "cache.enabled", "true");
props.setProperty(PluginManager.class, "cache.mode", "weak");
props.setProperty(PluginManager.class, "cache.file", "jspf.cache");
props.setProperty(PluginManager.class, "supervision.enabled", "true");
this.pm = PluginManagerFactory.createPluginManager(props);
this.pm.addPluginsFrom(new URI("classpath://*"));
}
/**
* @throws Exception
*/
@After
public void tearDown() throws Exception {
this.pm.shutdown();
}
/**
*
*/
@Test
public void testGetPluginClassOfP() {
final PluginInformation pi = this.pm.getPlugin(PluginInformation.class);
final TestAnnotations ta = this.pm.getPlugin(TestAnnotations.class);
Assert.assertNotNull(ta);
Collection<String> information = pi.getInformation(Information.CAPABILITIES, ta);
Assert.assertNotNull(information);
Assert.assertTrue(information.size() > 0);
}
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/core/PluginManagerCapabilities.java
|
Java
|
bsd
| 3,440
|
/*
* PluginTest.java
*
* Copyright (c) 2008, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.core;
import java.io.File;
import net.xeoh.plugins.base.PluginManager;
import net.xeoh.plugins.base.impl.PluginManagerFactory;
import net.xeoh.test.coolplugin.CoolPlugin;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
/**
* @author rb
*
*/
public class PluginManagerCompatibility {
private PluginManager pm;
/**
* @throws Exception
*/
@Before
public void setUp() throws Exception {
this.pm = PluginManagerFactory.createPluginManager();
}
/**
* @throws Exception
*/
@After
public void tearDown() throws Exception {
this.pm.shutdown();
}
/**
* @throws InterruptedException
*
*/
@Test
public void testGetPluginClassOfP() throws InterruptedException {
this.pm.addPluginsFrom(new File("tests/plugins/coolplugin.jar").toURI());
final CoolPlugin plugin = this.pm.getPlugin(CoolPlugin.class);
System.out.println(plugin);
// System.out.println("...");
}
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/core/PluginManagerCompatibility.java
|
Java
|
bsd
| 2,680
|
/*
* PluginTest.java
*
* Copyright (c) 2008, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.core;
import net.xeoh.plugins.base.PluginManager;
import net.xeoh.plugins.base.impl.PluginManagerFactory;
import net.xeoh.plugins.base.util.uri.ClassURI;
import net.xeoh.plugins.remotediscovery.RemoteDiscovery;
import net.xeoh.plugins.remotediscovery.impl.v4.RemoteDiscoveryImpl;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
/**
* @author rb
*
*/
public class PluginManagerLoadDirectly {
private PluginManager pm;
/**
* @throws Exception
*/
@Before
public void setUp() throws Exception {
this.pm = PluginManagerFactory.createPluginManager();
}
/**
* @throws Exception
*/
@After
public void tearDown() throws Exception {
this.pm.shutdown();
}
/**
*
*/
@Test
public void testGetPluginClassOfP() {
Assert.assertNotNull(this.pm);
RemoteDiscovery plugin = this.pm.getPlugin(RemoteDiscovery.class);
Assert.assertNull("Plugin must not be there at this point", plugin);
this.pm.addPluginsFrom(ClassURI.PLUGIN(RemoteDiscoveryImpl.class));
this.pm.addPluginsFrom(new ClassURI(RemoteDiscoveryImpl.class).toURI());
this.pm.addPluginsFrom(new ClassURI(RemoteDiscoveryImpl.class).toURI());
this.pm.addPluginsFrom(new ClassURI(RemoteDiscoveryImpl.class).toURI());
this.pm.addPluginsFrom(new ClassURI(RemoteDiscoveryImpl.class).toURI());
this.pm.addPluginsFrom(new ClassURI(RemoteDiscoveryImpl.class).toURI());
plugin = this.pm.getPlugin(RemoteDiscovery.class);
Assert.assertNotNull("Now plugin must be there", plugin);
}
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/core/PluginManagerLoadDirectly.java
|
Java
|
bsd
| 3,328
|
/*
* PluginTest.java
*
* Copyright (c) 2008, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.core;
import static net.jcores.jre.CoreKeeper.$;
import java.io.File;
import net.xeoh.plugins.base.PluginInformation;
import net.xeoh.plugins.base.PluginInformation.Information;
import net.xeoh.plugins.base.PluginManager;
import net.xeoh.plugins.base.impl.PluginManagerFactory;
import net.xeoh.plugins.base.options.addpluginsfrom.OptionReportAfter;
import net.xeoh.plugins.base.util.JSPFProperties;
import net.xeoh.plugins.testplugins.testannotations.TestAnnotations;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
/**
* @author rb
*
*/
public class PluginManagerLoadMulti {
private PluginManager pm;
/**
* @throws Exception
*/
@Before
public void setUp() throws Exception {
final JSPFProperties props = new JSPFProperties();
props.setProperty(PluginManager.class, "cache.enabled", "true");
props.setProperty(PluginManager.class, "cache.mode", "weak");
props.setProperty(PluginManager.class, "cache.file", "jspf.cache");
props.setProperty(PluginManager.class, "logging.level", "FINE");
this.pm = PluginManagerFactory.createPluginManager(props);
}
/**
* @throws Exception
*/
@After
public void tearDown() throws Exception {
this.pm.shutdown();
}
/**
*
*/
@Test
public void testGetPluginClassOfP() {
Assert.assertNotNull("Pluginmanager must be there", this.pm);
this.pm.addPluginsFrom(new File("tests/plugins/").toURI(), new OptionReportAfter());
final TestAnnotations p1 = this.pm.getPlugin(TestAnnotations.class);
final PluginInformation p2 = this.pm.getPlugin(PluginInformation.class);
$(p2.getInformation(Information.CLASSPATH_ORIGIN, p1)).string().print();
}
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/core/PluginManagerLoadMulti.java
|
Java
|
bsd
| 3,485
|
/*
* PluginTest.java
*
* Copyright (c) 2008, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.core;
import static net.jcores.jre.CoreKeeper.$;
import java.net.MalformedURLException;
import java.net.URI;
import java.util.ArrayList;
import java.util.Collection;
import net.xeoh.plugins.base.Plugin;
import net.xeoh.plugins.base.PluginInformation;
import net.xeoh.plugins.base.PluginInformation.Information;
import net.xeoh.plugins.base.PluginManager;
import net.xeoh.plugins.base.impl.PluginManagerFactory;
import net.xeoh.plugins.base.options.getplugin.OptionPluginSelector;
import net.xeoh.plugins.base.options.getplugin.PluginSelector;
import net.xeoh.plugins.testplugins.testannotations.TestAnnotations;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
/**
* @author rb
*
*/
public class PluginManagerTest {
private PluginManager pm;
/**
* @throws Exception
*/
@Before
public void setUp() throws Exception {
this.pm = PluginManagerFactory.createPluginManager();
this.pm.addPluginsFrom(new URI("classpath://*"));
//this.pm.addPluginsFrom(new File("dist/").toURI());
}
/**
* @throws Exception
*/
@After
public void tearDown() throws Exception {
this.pm.shutdown();
}
/**
* @throws MalformedURLException
*/
@Test
public void testAddPluginsFrom() throws MalformedURLException {
final PluginManager pm2 = PluginManagerFactory.createPluginManager();
Assert.assertNull(pm2.getPlugin(TestAnnotations.class));
//pm2.addPluginsFrom(new File("tests/plugins/test.coredefinition.jar").toURI());
//pm2.addPluginsFrom(new File("tests/plugins/test.annotation.jar").toURI());
//Assert.assertNotNull(pm2.getPlugin(TestAnnotations.class));
}
/**
*
*/
//@Test
public void testGetPluginClassOfP() {
Assert.assertNotNull(this.pm);
final TestAnnotations plugin = this.pm.getPlugin(TestAnnotations.class);
Assert.assertNotNull(plugin);
Assert.assertEquals(plugin.getInitStatus(), "INIT OK");
Assert.assertEquals(plugin.getInjectionStatus(), "INJECTION OK");
try {
Thread.sleep(100);
} catch (final InterruptedException e) {
e.printStackTrace();
}
Assert.assertEquals(plugin.getThreadStatus(), "THREAD OK");
Assert.assertEquals(plugin.getTimerStatus(), "TIMER OK");
}
/**
*
*/
@Test
public void testAllInterfaces() {
final TestAnnotations plugin = this.pm.getPlugin(TestAnnotations.class);
Collection<Class<? extends Plugin>> allPluginClasses = getAllPluginClasses(plugin);
for (Class<? extends Plugin> class1 : allPluginClasses) {
System.out.println(class1.getCanonicalName());
}
}
/**
*
*/
@Test
public void testVersion() {
PluginInformation pi = this.pm.getPlugin(PluginInformation.class);
Collection<String> information = pi.getInformation(Information.VERSION, pm);
$(information).print();
}
@SuppressWarnings("unchecked")
private static Collection<Class<? extends Plugin>> getAllPluginClasses(Plugin plugin) {
Collection<Class<? extends Plugin>> rval = new ArrayList<Class<? extends Plugin>>();
Class<? extends Plugin> c = plugin.getClass();
Class<?>[] i = c.getInterfaces();
for (Class<?> cc : i) {
if (!Plugin.class.isAssignableFrom(cc)) continue;
Collection<Class<?>> allSuperInterfaces = getAllSuperInterfaces(cc);
for (Class<?> class1 : allSuperInterfaces) {
if (!rval.contains(class1)) rval.add((Class<? extends Plugin>) class1);
}
}
return rval;
}
private static Collection<Class<?>> getAllSuperInterfaces(Class<?> c) {
Collection<Class<?>> rval = new ArrayList<Class<?>>();
rval.add(c);
Class<?>[] interfaces = c.getInterfaces();
for (Class<?> class1 : interfaces) {
Collection<Class<?>> allSuperInterfaces = getAllSuperInterfaces(class1);
for (Class<?> class2 : allSuperInterfaces) {
if (rval.contains(class2)) continue;
rval.add(class2);
}
}
return rval;
}
/**
*
*/
//@Test
public void testGetPluginClassOfPPluginSelectorOfP() {
Assert.assertNotNull(this.pm);
final TestAnnotations plugin = this.pm.getPlugin(TestAnnotations.class, new OptionPluginSelector<TestAnnotations>(new PluginSelector<TestAnnotations>() {
public boolean selectPlugin(final TestAnnotations plugiN) {
return false;
}
}));
Assert.assertNull(plugin);
}
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/core/PluginManagerTest.java
|
Java
|
bsd
| 6,565
|
/*
* TestFrameworkManager.java
*
* Copyright (c) 2009, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.core;
import net.xeoh.plugins.base.PluginManager;
import net.xeoh.plugins.base.impl.PluginManagerFactory;
import sun.applet.AppletSecurity;
/**
* @author rb
*
*/
public class PluginManagerApplet {
private PluginManager pluginManager;
/**
*
*/
public PluginManagerApplet() {
System.setSecurityManager(new AppletSecurity());
this.pluginManager = PluginManagerFactory.createPluginManager();
this.pluginManager.shutdown();
}
/**
* @param args
*/
public static void main(String[] args) {
new PluginManagerApplet();
}
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/core/PluginManagerApplet.java
|
Java
|
bsd
| 2,203
|
/*
* PluginTest.java
*
* Copyright (c) 2008, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.core;
import net.xeoh.plugins.base.PluginManager;
import net.xeoh.plugins.base.impl.PluginManagerFactory;
import net.xeoh.plugins.base.util.JSPFProperties;
import net.xeoh.plugins.base.util.uri.ClassURI;
import net.xeoh.plugins.testplugins.testannotations.TestAnnotations;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
/**
* @author rb
*
*/
public class PluginManagerAnnotations {
private PluginManager pm;
/**
* @throws Exception
*/
@Before
public void setUp() throws Exception {
final JSPFProperties props = new JSPFProperties();
this.pm = PluginManagerFactory.createPluginManager(props);
this.pm.addPluginsFrom(ClassURI.CLASSPATH);
}
/**
* @throws Exception
*/
@After
public void tearDown() throws Exception {
this.pm.shutdown();
}
/**
*
*/
@Test
public void testAnnotations() {
Assert.assertNotNull(this.pm);
final TestAnnotations plugin = this.pm.getPlugin(TestAnnotations.class);
Assert.assertNotNull(plugin);
Assert.assertEquals(plugin.getInitStatus(), "INIT OK");
Assert.assertEquals(plugin.getInjectionStatus(), "INJECTION OK");
try {
Thread.sleep(100);
} catch (final InterruptedException e) {
e.printStackTrace();
}
Assert.assertEquals(plugin.getThreadStatus(), "THREAD OK");
Assert.assertEquals(plugin.getTimerStatus(), "TIMER OK");
}
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/core/PluginManagerAnnotations.java
|
Java
|
bsd
| 3,208
|
/*
* PluginTest.java
*
* Copyright (c) 2008, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.core;
import java.net.URI;
import java.net.URISyntaxException;
import net.xeoh.plugins.base.PluginManager;
import net.xeoh.plugins.base.impl.PluginManagerFactory;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
/**
* @author rb
*
*/
public class PluginManagerLoadHTTP {
private PluginManager pm;
/**
* @throws Exception
*/
@Before
public void setUp() throws Exception {
this.pm = PluginManagerFactory.createPluginManager();
}
/**
* @throws Exception
*/
@After
public void tearDown() throws Exception {
//this.pm.shutdown();
}
/**
*
*/
@Test
public void testGetPluginClassOfP() {
Assert.assertNotNull(this.pm);
try {
this.pm.addPluginsFrom(new URI("http://jspf.googlecode.com/files/coolplugin.jar"));
} catch (URISyntaxException e) {
e.printStackTrace();
}
}
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/core/PluginManagerLoadHTTP.java
|
Java
|
bsd
| 2,697
|
/*
* PluginTest.java
*
* Copyright (c) 2008, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.core;
import java.net.URI;
import net.xeoh.plugins.base.PluginInformation;
import net.xeoh.plugins.base.PluginManager;
import net.xeoh.plugins.base.impl.PluginManagerFactory;
import net.xeoh.plugins.base.util.JSPFProperties;
import net.xeoh.plugins.testplugins.testannotations.TestAnnotations;
import net.xeoh.plugins.testplugins.testannotations.impl.TestAnnotationsImpl;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
/**
* @author rb
*
*/
public class PluginManagerDisablingPlugins {
private PluginManager pm;
/**
* @throws Exception
*/
@Before
public void setUp() throws Exception {
final JSPFProperties props = new JSPFProperties();
props.setProperty(PluginManager.class, "cache.enabled", "true");
props.setProperty(PluginManager.class, "cache.mode", "weak");
props.setProperty(PluginManager.class, "cache.file", "jspf.cache");
props.setProperty(PluginManager.class, "supervision.enabled", "true");
// Enable and disable plugins like this:
props.setProperty(TestAnnotationsImpl.class, "plugin.disabled", "false");
this.pm = PluginManagerFactory.createPluginManager(props);
this.pm.addPluginsFrom(new URI("classpath://*"));
}
/**
* @throws Exception
*/
@After
public void tearDown() throws Exception {
this.pm.shutdown();
}
/**
*
*/
@Test
public void testGetPluginClassOfP() {
final PluginInformation pi = this.pm.getPlugin(PluginInformation.class);
final TestAnnotations ta = this.pm.getPlugin(TestAnnotations.class);
}
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/core/PluginManagerDisablingPlugins.java
|
Java
|
bsd
| 3,337
|
/*
* PluginTest.java
*
* Copyright (c) 2008, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.core;
import java.io.File;
import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.Collection;
import net.xeoh.plugins.base.Plugin;
import net.xeoh.plugins.base.PluginManager;
import net.xeoh.plugins.base.impl.PluginManagerFactory;
import net.xeoh.plugins.base.options.getplugin.OptionPluginSelector;
import net.xeoh.plugins.base.options.getplugin.PluginSelector;
import net.xeoh.plugins.testplugins.testannotations.TestAnnotations;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
/**
* @author rb
*
*/
public class PluginManagerLoadByPath {
private PluginManager pm;
/**
* @throws Exception
*/
@Before
public void setUp() throws Exception {
this.pm = PluginManagerFactory.createPluginManager();
this.pm.addPluginsFrom(new File("tests/plugins/").toURI());
//this.pm.addPluginsFrom(new File("dist/").toURI());
}
/**
* @throws Exception
*/
@After
public void tearDown() throws Exception {
this.pm.shutdown();
}
/**
* @throws MalformedURLException
*/
@Test
public void testAddPluginsFrom() throws MalformedURLException {
final PluginManager pm2 = PluginManagerFactory.createPluginManager();
Assert.assertNull(pm2.getPlugin(TestAnnotations.class));
}
/**
* @throws InterruptedException
*
*/
@Test
public void testClassName() throws InterruptedException {
net.xeoh.plugins.testplugins.classification.Class plugin = this.pm.getPlugin(net.xeoh.plugins.testplugins.classification.Class.class);
Assert.assertEquals(plugin.classy(), 123);
}
/**
*
*/
@Test
public void testGetPluginClassOfP() {
Assert.assertNotNull(this.pm);
final TestAnnotations plugin = this.pm.getPlugin(TestAnnotations.class);
Assert.assertNotNull(plugin);
Assert.assertEquals(plugin.getInitStatus(), "INIT OK");
Assert.assertEquals(plugin.getInjectionStatus(), "INJECTION OK");
try {
Thread.sleep(100);
} catch (final InterruptedException e) {
e.printStackTrace();
}
Assert.assertEquals(plugin.getThreadStatus(), "THREAD OK");
Assert.assertEquals(plugin.getTimerStatus(), "TIMER OK");
}
/**
*
*/
@Test
public void testAllInterfaces() {
final TestAnnotations plugin = this.pm.getPlugin(TestAnnotations.class);
System.out.println(plugin);
Collection<Class<? extends Plugin>> allPluginClasses = getAllPluginClasses(plugin);
for (Class<? extends Plugin> class1 : allPluginClasses) {
System.out.println(class1.getCanonicalName());
}
}
@SuppressWarnings("unchecked")
private static Collection<Class<? extends Plugin>> getAllPluginClasses(Plugin plugin) {
Collection<Class<? extends Plugin>> rval = new ArrayList<Class<? extends Plugin>>();
Class<? extends Plugin> c = plugin.getClass();
Class<?>[] i = c.getInterfaces();
for (Class<?> cc : i) {
if (!Plugin.class.isAssignableFrom(cc)) continue;
Collection<Class<?>> allSuperInterfaces = getAllSuperInterfaces(cc);
for (Class<?> class1 : allSuperInterfaces) {
if (!rval.contains(class1)) rval.add((Class<? extends Plugin>) class1);
}
}
return rval;
}
private static Collection<Class<?>> getAllSuperInterfaces(Class<?> c) {
Collection<Class<?>> rval = new ArrayList<Class<?>>();
rval.add(c);
Class<?>[] interfaces = c.getInterfaces();
for (Class<?> class1 : interfaces) {
Collection<Class<?>> allSuperInterfaces = getAllSuperInterfaces(class1);
for (Class<?> class2 : allSuperInterfaces) {
if (rval.contains(class2)) continue;
rval.add(class2);
}
}
return rval;
}
/**
*
*/
//@Test
public void testGetPluginClassOfPPluginSelectorOfP() {
Assert.assertNotNull(this.pm);
final TestAnnotations plugin = this.pm.getPlugin(TestAnnotations.class, new OptionPluginSelector<TestAnnotations>(new PluginSelector<TestAnnotations>() {
public boolean selectPlugin(final TestAnnotations plugiN) {
return false;
}
}));
Assert.assertNull(plugin);
}
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/core/PluginManagerLoadByPath.java
|
Java
|
bsd
| 6,260
|
/*
* PluginTest.java
*
* Copyright (c) 2008, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.core;
import java.net.URI;
import net.xeoh.plugins.base.PluginConfiguration;
import net.xeoh.plugins.base.PluginManager;
import net.xeoh.plugins.base.impl.PluginManagerFactory;
import net.xeoh.plugins.base.util.JSPFProperties;
import net.xeoh.plugins.base.util.uri.ClassURI;
import net.xeoh.plugins.testplugins.testannotations.TestAnnotations;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
/**
* @author rb
*
*/
public class ShutdownTest {
private PluginManager pm;
/**
* @throws Exception
*/
@Before
public void setUp() throws Exception {
JSPFProperties pros = new JSPFProperties();
pros.setProperty(PluginManager.class, "logging.level", "WARNING");
this.pm = PluginManagerFactory.createPluginManager(pros);
this.pm.addPluginsFrom(new URI("classpath://*"));
}
/**
*
*/
@Test
public void testShutdown() {
Assert.assertNotNull(this.pm);
TestAnnotations plugin = this.pm.getPlugin(TestAnnotations.class);
Assert.assertNotNull(plugin);
this.pm.shutdown();
plugin = this.pm.getPlugin(TestAnnotations.class);
Assert.assertNull(plugin);
Assert.assertNull(this.pm.getPlugin(PluginConfiguration.class));
}
/**
*
*/
@Test
public void testMany() {
for(int i=0; i<10000; i++) {
System.out.println();
System.out.println("Run " + i);
PluginManager manager = PluginManagerFactory.createPluginManager();
manager.addPluginsFrom(ClassURI.CLASSPATH);
manager.shutdown();
}
}
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/core/ShutdownTest.java
|
Java
|
bsd
| 3,323
|
/*
* PluginTest.java
*
* Copyright (c) 2008, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.core;
import java.net.URI;
import java.net.URISyntaxException;
import net.xeoh.plugins.base.PluginManager;
import net.xeoh.plugins.base.impl.PluginManagerFactory;
import net.xeoh.plugins.base.options.getplugin.OptionCapabilities;
import net.xeoh.plugins.remote.RemoteAPI;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
/**
* @author rb
*
*/
public class PluginManagerOptions {
private PluginManager pm;
/**
* @throws Exception
*/
@Before
public void setUp() throws Exception {
this.pm = PluginManagerFactory.createPluginManager();
}
/**
* @throws Exception
*/
@After
public void tearDown() throws Exception {
this.pm.shutdown();
}
/**
*
*/
@Test
public void testGetPluginClassOfP() {
Assert.assertNotNull("Pluginmanager must be there", this.pm);
RemoteAPI plugin = this.pm.getPlugin(RemoteAPI.class);
Assert.assertNull("Plugin must not be there at this point", plugin);
try {
this.pm.addPluginsFrom(new URI("classpath://*"));
} catch (URISyntaxException e) {
e.printStackTrace();
}
plugin = this.pm.getPlugin(RemoteAPI.class, new OptionCapabilities("ASOIDASJdasjkdhasdiasoDASOJd"));
Assert.assertNull("This plugins must not exist", plugin);
plugin = this.pm.getPlugin(RemoteAPI.class, new OptionCapabilities("XMLRPC"));
Assert.assertNotNull("Now plugin must be there", plugin);
}
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/core/PluginManagerOptions.java
|
Java
|
bsd
| 3,240
|
/*
* PluginTest.java
*
* Copyright (c) 2008, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.core;
import net.xeoh.plugins.base.PluginManager;
import net.xeoh.plugins.base.impl.PluginManagerFactory;
import net.xeoh.plugins.base.util.JSPFProperties;
import net.xeoh.plugins.base.util.uri.ClassURI;
import net.xeoh.plugins.diagnosis.local.Diagnosis;
import net.xeoh.plugins.remote.RemoteAPI;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
/**
* @author rb
*
*/
public class PluginManagerLoadClasspath {
private PluginManager pm;
/**
* @throws Exception
*/
@Before
public void setUp() throws Exception {
final JSPFProperties props = new JSPFProperties();
props.setProperty(PluginManager.class, "cache.enabled", "true");
props.setProperty(PluginManager.class, "cache.mode", "weak");
props.setProperty(PluginManager.class, "cache.file", "jspf.cache");
// props.setProperty(PluginManager.class, "logging.level", "ALL");
props.setProperty(PluginManager.class, "classpath.filter.default.pattern", "");
props.setProperty(Diagnosis.class, "recording.enabled", "true");
props.setProperty(Diagnosis.class, "recording.file", "diagnosis.record");
props.setProperty(Diagnosis.class, "recording.format", "java/serialization");
props.setProperty(Diagnosis.class, "analysis.stacktraces.enabled", "true");
props.setProperty(Diagnosis.class, "analysis.stacktraces.depth", "10000");
this.pm = PluginManagerFactory.createPluginManager(props);
}
/**
* @throws Exception
*/
@After
public void tearDown() throws Exception {
this.pm.shutdown();
}
/**
*
*/
@Test
public void testGetPluginClassOfP() {
Assert.assertNotNull("Pluginmanager must be there", this.pm);
RemoteAPI plugin = this.pm.getPlugin(RemoteAPI.class);
Assert.assertNull("Plugin must not be there at this point", plugin);
this.pm.addPluginsFrom(ClassURI.CLASSPATH);
// this.pm.addPluginsFrom(new File("bin/").toURI());
// this.pm.addPluginsFrom(new URI("classpath://net.xeoh.plugins.remote.impl.*.*"),
// new OptionReportAfter());
// this.pm.addPluginsFrom(new URI("classpath://*"));
plugin = this.pm.getPlugin(RemoteAPI.class);
Assert.assertNotNull("Now plugin must be there", plugin);
System.out.println("Fin");
}
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/core/PluginManagerLoadClasspath.java
|
Java
|
bsd
| 4,122
|
/*
* PluginTest.java
*
* Copyright (c) 2008, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.core;
import java.net.URI;
import net.xeoh.plugins.base.PluginManager;
import net.xeoh.plugins.base.impl.PluginManagerFactory;
import net.xeoh.plugins.base.util.JSPFProperties;
import net.xeoh.plugins.testplugins.testinner.TestInnerInterface;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
/**
* @author rb
*
*/
public class PluginManagerLoadInner {
private PluginManager pm;
/**
* @throws Exception
*/
@Before
public void setUp() throws Exception {
final JSPFProperties props = new JSPFProperties();
this.pm = PluginManagerFactory.createPluginManager(props);
this.pm.addPluginsFrom(URI.create("classpath://*"));
}
/**
* @throws Exception
*/
@After
public void tearDown() throws Exception {
this.pm.shutdown();
}
/**
*
*/
@Test
public void testInner() {
TestInnerInterface plugin = this.pm.getPlugin(TestInnerInterface.class);
Assert.assertNotNull(plugin);
}
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/core/PluginManagerLoadInner.java
|
Java
|
bsd
| 2,712
|
/*
* BusTest.java
*
* Copyright (c) 2008, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.core;
import java.net.URI;
import java.util.Collection;
import net.xeoh.plugins.base.PluginInformation;
import net.xeoh.plugins.base.PluginInformation.Information;
import net.xeoh.plugins.base.PluginManager;
import net.xeoh.plugins.base.impl.PluginManagerFactory;
import net.xeoh.plugins.testplugins.testannotations.TestAnnotations;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
/**
* @author rb
*
*/
public class PluginInformationTest {
private PluginManager pm;
/**
* @throws Exception
*/
@Before
public void setUp() throws Exception {
this.pm = PluginManagerFactory.createPluginManager();
this.pm.addPluginsFrom(new URI("classpath://*"));
}
/**
* @throws Exception
*/
@After
public void tearDown() throws Exception {
this.pm.shutdown();
}
/**
*
*/
@Test
public void testPluginInformation() {
Assert.assertNotNull(this.pm);
final TestAnnotations ta = this.pm.getPlugin(TestAnnotations.class);
final PluginInformation pi = this.pm.getPlugin(PluginInformation.class);
Assert.assertNotNull("TestAnnotaions must be there!", ta);
Assert.assertNotNull("Plugin Information must be there", pi);
final Collection<String> caps = pi.getInformation(Information.CAPABILITIES, ta);
final Collection<String> author = pi.getInformation(Information.AUTHORS, ta);
final Collection<String> version = pi.getInformation(Information.VERSION, ta);
final Collection<String> origin = pi.getInformation(Information.CLASSPATH_ORIGIN, ta);
Assert.assertTrue("Caps must contain SUNSHINE", caps.contains("SUNSHINE"));
Assert.assertTrue("Caps must contain RAIN", caps.contains("RAIN"));
Assert.assertTrue("Author must contain AUTHOR OK", author.contains("AUTHOR OK"));
Assert.assertTrue("Version must be 667", version.contains("667"));
System.out.println(origin);
}
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/core/PluginInformationTest.java
|
Java
|
bsd
| 3,703
|
/*
* PluginTest.java
*
* Copyright (c) 2008, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.diagnosis;
import java.io.Serializable;
import net.xeoh.plugins.base.PluginManager;
import net.xeoh.plugins.base.impl.PluginManagerFactory;
import net.xeoh.plugins.base.util.JSPFProperties;
import net.xeoh.plugins.diagnosis.diagnosis.channels.LoggingChannel1;
import net.xeoh.plugins.diagnosis.diagnosis.channels.LoggingChannel2;
import net.xeoh.plugins.diagnosis.diagnosis.channels.TestChannel;
import net.xeoh.plugins.diagnosis.local.Diagnosis;
import net.xeoh.plugins.diagnosis.local.DiagnosisChannel;
import net.xeoh.plugins.diagnosis.local.DiagnosisMonitor;
import net.xeoh.plugins.diagnosis.local.DiagnosisStatus;
import net.xeoh.plugins.diagnosis.local.options.status.OptionInfo;
import net.xeoh.plugins.diagnosis.local.util.DiagnosisChannelUtil;
import net.xeoh.plugins.diagnosis.local.util.DiagnosisUtil;
import net.xeoh.plugins.diagnosis.local.util.conditions.TwoStateMatcherAND;
import net.xeoh.plugins.diagnosis.local.util.conditions.matcher.Contains;
import net.xeoh.plugins.diagnosis.local.util.conditions.matcher.Is;
import net.xeoh.plugins.testplugins.testannotations.impl.TestAnnotationsImpl;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* @author rb
*
*/
public class DiagnosisGeneralTest {
private static PluginManager pm;
/**
* @throws Exception
*/
@BeforeClass
public static void setUp() {
final JSPFProperties props = new JSPFProperties();
props.setProperty(Diagnosis.class, "recording.enabled", "true");
props.setProperty(Diagnosis.class, "recording.file", "diagnosis.record");
props.setProperty(Diagnosis.class, "recording.format", "java/serialization");
props.setProperty(Diagnosis.class, "analysis.stacktraces.enabled", "true");
props.setProperty(Diagnosis.class, "analysis.stacktraces.depth", "10000");
// Enable and disable plugins like this:
props.setProperty(TestAnnotationsImpl.class, "plugin.disabled", "false");
try {
pm = PluginManagerFactory.createPluginManager(props);
} catch (Exception e) {
e.printStackTrace();
}
//pm.addPluginsFrom(URI.create("xxx:yyy"));
}
/**
* @throws Exception
*/
@AfterClass
public static void tearDown() throws Exception {
pm.shutdown();
}
/**
*
*/
@Test
public void benchmark() {
Assert.assertNotNull(this.pm);
final Diagnosis diagnosis = this.pm.getPlugin(Diagnosis.class);
long a = System.currentTimeMillis();
for(int i=0; i<10000;i++) {
diagnosis.channel(LoggingChannel1.class).status(""+i);
}
long b = System.currentTimeMillis();
System.out.println(b-a);
DiagnosisChannel<String> channel = diagnosis.channel(LoggingChannel2.class);
a = System.currentTimeMillis();
for(int i=0; i<10000;i++) {
channel.status(""+i);
}
b = System.currentTimeMillis();
System.out.println(b-a);
DiagnosisChannelUtil<String> c = new DiagnosisChannelUtil<String>(null);
c.status("null");
c.status("null", "a", "b");
c.status("null", new OptionInfo("a", "b"));
}
/**
*
*/
@SuppressWarnings("boxing")
@Test
public void testGetPluginClassOfP() {
Assert.assertNotNull(this.pm);
final Diagnosis diagnosis = this.pm.getPlugin(Diagnosis.class);
diagnosis.channel(LoggingChannel1.class).status("Starting Test.");
diagnosis.channel(TestChannel.class).status(100);
diagnosis.channel(TestChannel.class).status(100);
diagnosis.channel(TestChannel.class).status(100);
diagnosis.channel(TestChannel.class).status(3000);
diagnosis.channel(LoggingChannel1.class).status("Initializing Status");
DiagnosisUtil util = new DiagnosisUtil(diagnosis);
util.registerMonitors(new DiagnosisMonitor<Serializable>() {
@Override
public void onStatusChange(DiagnosisStatus<Serializable> status) {
if(status.getChannel().equals(TestChannel.class)) System.out.println("TC");
System.out.println(">>> " + status.getValue());
}
}, TestChannel.class, LoggingChannel1.class);
diagnosis.channel(TestChannel.class).status(6667);
diagnosis.channel(TestChannel.class).status(100);
util.registerCondition(new TwoStateMatcherAND() {
/** */
@Override
protected void setupMatcher() {
match(TestChannel.class, new Is(100));
match(LoggingChannel1.class, new Contains("xtatus"));
}
/** */
@Override
public void stateChanged(STATE state) {
System.out.println("STATE CJAMGE" + state);
}
});
diagnosis.channel(TestChannel.class).status(3000);
diagnosis.channel(TestChannel.class).status(100);
//D2 d;
//diagnosis.status(URI.create(TestChannel.class, "xxx"), 300);
//diagnosis.channel(LoggingChannel1.class).status("start/x");
//DiagnosisCondition condition = new TestCondition();
//condition
//diagnosis.registerCondition(condition);
// Was ist mit Multi-Threading?
// T1: start() -> state1 -> state2 .... -> state4
// T2: start() -> state1
// In dem Fall würde der Sensor sehen
// s1 s2 s1 s4 s2 s5 ...
// Und könnte nicht wirklich eine sinnvolle condition definieren.
// Andererseits, wir haben den Thread-Status dabei, so dass jeder Thread seine eigene
// time-line bekommt, bzw. bekommen kann
// Das würde bedeuten, dass es keinen einzigen Zustand s gibt, sondern eine unbestimmte menge davon.
// Wie macht man das nun mit conditions?
// if(s == 1 && t == 3)?
// if(s(threadA) == 1 && t(threadA) == 3)?
// Frage, wie kann ich einzelne Kanäle deaktivieren, die z.b: eine Hohe Last oder Debugausgaben verursachen?
// An die komme ich nämlich nicht einfach ran, wenn die in einem Plugin verborgen sind.
// --> InformationBroker
// Soll es eine Replay-API geben?
// --> Nicht notwendig, wenn es Tools zur Analyse in JSPF mit dazu gibt (z.B. Extraktor & Konverter)
// Was ist mit den serialisierten Werten, die können vom Tool nicht zurückgelesen werden, sofern es spezielle
// Werte sind.
// --> Müssen im Classpath mit aufgenommen werden, oder werden halt nicht wiede de-serialisiert
// Wird das nicht langsam sein?
// --> Ist nicht gedacht für high-volume recording, sondern eher für sagen wir <100 Nachrichten pro Sekunde
// auf Pluginebene.
// Was ist mit Erklärungen f. Messwerte, Conditions, usw. Die wären im Replay-Tool nicht verfügbar, insbesondere
// nicht, wenn die zur Laufzeit zusammengeschuhstert werden müssen
// --> Muss auf Klassenebene der Channels passieren, dort Konverter usw. reinzumachen
// Würde ein Recording auf den Channels mit primitiven Typen nicht viel schneller sein?
// z.B. diagnosis.channel(TestChannel.class).reportInt(30)
// dann hätte man auch keine Probleme beim De-Serialisieren
// --> Mmhm, ist was dran. Ist aber weniger elegant, außerdem können dann auf einem Channel
// Werte gemischt werden. Ich behaupte einfach mal dass in Richtung Java 7,8,9 Boxing-Typen
// irgendwann gleichschnell wie primitive Typen behandelt werden können. Und das Problem
// beim entpacken kann der Entwickler einfach dadurch lösen, dass er halt nur eingebaute Typen
// nimmt ...
// Q1: How does the condition access diagnosis-internal functions/variables?
// Q2: How do we associate conditions with messages / remedies / ...?
// Q3: Who fires *when* and *how* and triggers *what* when a condition is met?
diagnosis.channel(LoggingChannel1.class).status("Ending Test.");
}
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/diagnosis/DiagnosisGeneralTest.java
|
Java
|
bsd
| 10,255
|
/*
* TestChannel.java
*
* Copyright (c) 2011, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.diagnosis.diagnosis.channels;
import net.xeoh.plugins.diagnosis.local.DiagnosisChannelID;
public class TestChannel extends DiagnosisChannelID<Integer> {
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/diagnosis/diagnosis/channels/TestChannel.java
|
Java
|
bsd
| 1,746
|
/*
* TestChannel.java
*
* Copyright (c) 2011, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.diagnosis.diagnosis.channels;
import net.xeoh.plugins.diagnosis.local.DiagnosisChannelID;
public class LoggingChannel1 extends DiagnosisChannelID<String> {
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/diagnosis/diagnosis/channels/LoggingChannel1.java
|
Java
|
bsd
| 1,748
|
/*
* TestChannel.java
*
* Copyright (c) 2011, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.diagnosis.diagnosis.channels;
import net.xeoh.plugins.diagnosis.local.DiagnosisChannelID;
public class LoggingChannel2 extends DiagnosisChannelID<String> {
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/diagnosis/diagnosis/channels/LoggingChannel2.java
|
Java
|
bsd
| 1,748
|
/*
* D2.java
*
* Copyright (c) 2011, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.diagnosis.diagnosis;
import java.io.Serializable;
import java.net.URI;
import net.xeoh.plugins.diagnosis.local.DiagnosisChannel;
import net.xeoh.plugins.diagnosis.local.DiagnosisChannelID;
import net.xeoh.plugins.diagnosis.local.options.ChannelOption;
import net.xeoh.plugins.diagnosis.local.options.StatusOption;
public interface D2 {
public <T extends Serializable> DiagnosisChannel<T> channel(Class<? extends DiagnosisChannelID<T>> channel,
ChannelOption... options);
public void status(URI channel, Object object, StatusOption...options);
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/diagnosis/diagnosis/D2.java
|
Java
|
bsd
| 2,153
|
/*
* PluginTest.java
*
* Copyright (c) 2008, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.diagnosis;
import java.net.URI;
import net.xeoh.plugins.base.PluginManager;
import net.xeoh.plugins.base.impl.PluginManagerFactory;
import net.xeoh.plugins.base.util.JSPFProperties;
import net.xeoh.plugins.diagnosis.diagnosis.channels.LoggingChannel1;
import net.xeoh.plugins.diagnosis.local.Diagnosis;
import net.xeoh.plugins.testplugins.testannotations.impl.TestAnnotationsImpl;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.BeforeClass;
import org.junit.Test;
/**
* @author rb
*
*/
public class DiagnosisMiniTest {
private static PluginManager pm;
/**
* @throws Exception
*/
@BeforeClass
public static void setUp() throws Exception {
final JSPFProperties props = new JSPFProperties();
props.setProperty(Diagnosis.class, "recording.enabled", "true");
props.setProperty(Diagnosis.class, "recording.file", "diagnosis.record");
props.setProperty(Diagnosis.class, "recording.format", "java/serialization");
props.setProperty(Diagnosis.class, "analysis.stacktraces.enabled", "true");
props.setProperty(Diagnosis.class, "analysis.stacktraces.depth", "10000");
// Enable and disable plugins like this:
props.setProperty(TestAnnotationsImpl.class, "plugin.disabled", "false");
pm = PluginManagerFactory.createPluginManager(props);
pm.addPluginsFrom(URI.create("xxx:yyy"));
}
/**
* @throws Exception
*/
@AfterClass
public static void tearDown() throws Exception {
pm.shutdown();
}
/**
*
*/
@Test
public void benchmark() {
Assert.assertNotNull(this.pm);
final Diagnosis diagnosis = this.pm.getPlugin(Diagnosis.class);
diagnosis.channel(LoggingChannel1.class).status("XXX");
}
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/diagnosis/DiagnosisMiniTest.java
|
Java
|
bsd
| 3,497
|
/*
* BusTest.java
*
* Copyright (c) 2008, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.informationbroker;
import java.net.URI;
import net.xeoh.plugins.base.PluginManager;
import net.xeoh.plugins.base.impl.PluginManagerFactory;
import net.xeoh.plugins.informationbroker.util.InformationBrokerUtil;
import org.junit.After;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
/**
* @author rb
*
*/
public class InformationBrokerTest2 {
private PluginManager pm;
boolean called1 = false;
boolean called2 = false;
/**
* @throws Exception
*/
@Before
public void setUp() throws Exception {
this.pm = PluginManagerFactory.createPluginManager();
this.pm.addPluginsFrom(new URI("classpath://*"));
}
/**
* @throws Exception
*/
@After
public void tearDown() throws Exception {
this.pm.shutdown();
}
/**
* @throws InterruptedException
*/
/*
* @Test
* public void testBroker() throws InterruptedException {
* Assert.assertNotNull(this.pm);
*
* final InformationBroker plugin = this.pm.getPlugin(InformationBroker.class);
*
* plugin.publish(new StringItem("device:location", "Kaiserslautern, Germany"));
* plugin.subscribe(new StringID("device:location"), new InformationListener<String>()
* {
* public void update(InformationItem<String> item) {
* System.out.println(item.getContent());
* }
* });
* plugin.publish(new StringItem("device:location", "World's End."));
*
* final InformationBrokerUtil ibu = new InformationBrokerUtil(plugin);
* System.out.println(ibu.get(new StringID("device:location")));
*
* }
*/
@Test
public void testBroker() throws InterruptedException {
Assert.assertNotNull(this.pm);
final InformationBroker plugin = this.pm.getPlugin(InformationBroker.class);
plugin.subscribe(TestItemA.class, new InformationListener<String>() {
@Override
public void update(String item) {
System.out.println("Hello World");
}
});
final InformationBrokerUtil util = new InformationBrokerUtil(plugin);
util.subscribeAll(new InformationListener<Void>() {;
@Override
public void update(Void item) {
System.out.println("Got both");
System.out.println(item);
System.out.println(util.get(TestItemA.class));
System.out.println(util.get(TestItemB.class));
System.out.println(util.get(TestItemA.class));
System.out.println(util.get(TestItemB.class));
}
}, TestItemA.class, TestItemB.class);
System.out.println("1");
plugin.publish(TestItemA.class, "A) Hello");
System.out.println("2");
plugin.publish(TestItemB.class, "B) World");
System.out.println("3");
// plugin.publish(TestItem.class, new Object());
}
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/informationbroker/InformationBrokerTest2.java
|
Java
|
bsd
| 4,662
|
/*
* TestChannel.java
*
* Copyright (c) 2010, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.informationbroker;
public class TestItemA implements InformationItem<String> {
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/informationbroker/TestItemA.java
|
Java
|
bsd
| 1,670
|
/*
* TestChannel.java
*
* Copyright (c) 2010, Ralf Biedert All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. Redistributions in binary form must reproduce the
* above copyright notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* Neither the name of the author nor the names of its contributors may be used to endorse or
* promote products derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
* OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
* TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*/
package net.xeoh.plugins.informationbroker;
public class TestItemB implements InformationItem<String> {
}
|
100json-jspf
|
tests/src/net/xeoh/plugins/informationbroker/TestItemB.java
|
Java
|
bsd
| 1,670
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAOQLDV;
using DTOQLDV;
namespace BUSQLDV
{
public class BUSDichVu
{
public static List<DTODichVu> LayDanhSachDichVu()
{
return DAODichVu.LayDanhSachDichVu();
}
public static bool ThemDichVu(DTODichVu dtoDV)
{
if (dtoDV.TenDichVu != "")
{
throw new Exception("Xin nhập tên dịch vụ");
return false;
}
return DAODichVu.ThemDichVu(dtoDV);
}
public static bool CapNhatDichVu(DTODichVu dtoDV)
{
if (dtoDV.MaDichVu == 0)
{
throw new Exception("Xin chọn dịch vụ");
return false;
}
if (dtoDV.TenDichVu != "")
{
throw new Exception("Xin nhập tên dịch vụ");
return false;
}
return DAODichVu.CapNhatDichVu(dtoDV);
}
public static bool XoaDichVu(DTODichVu dtoDV)
{
if (dtoDV.MaDichVu==0)
{
throw new Exception("Xin chọn dịch vụ");
return false;
}
return DAODichVu.XoaDichVu(dtoDV);
}
public static int LayMaDichVu(String tenDichVu)
{
if (tenDichVu != "")
{
throw new Exception("Xin nhập tên dịch vụ");
return 0;
}
return DAODichVu.LayMaDichVu(tenDichVu);
}
}
}
|
10hca1-team4-qldv
|
trunk/ 10hca1-team4-qldv/BUSQLDV/BUSDichVu.cs
|
C#
|
asf20
| 1,676
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTOQLDV;
using DAOQLDV;
namespace BUSQLDV
{
public class BUSTinhThanh
{
public static List<DTOTinhThanh> LayDanhSachTinhThanh()
{
return DAOTinhThanh.LayDanhSachTinhThanh();
}
public static bool ThemTinhThanh(DTOTinhThanh dtoTT)
{
if (dtoTT.TenTinhThanh=="")
{
throw new Exception("Xin nhập tên tỉnh thành");
return false;
}
return DAOTinhThanh.ThemTinhThanh(dtoTT);
}
public static bool CapNhatTinhThanh(DTOTinhThanh dtoTT)
{
if (dtoTT.MaTinhThanh == 0)
{
throw new Exception("Xin chọn tỉnh thành");
return false;
}
if (dtoTT.TenTinhThanh == "")
{
throw new Exception("Xin nhập tên tỉnh thành");
return false;
}
return DAOTinhThanh.CapNhatTinhThanh(dtoTT);
}
public static bool XoaTinhThanh(DTOTinhThanh dtoTT)
{
if (dtoTT.MaTinhThanh== 0)
{
throw new Exception("Xin chọn tỉnh thành");
return false;
}
return DAOTinhThanh.XoaTinhThanh(dtoTT);
}
public static int LayMaTinhThanh(String tenTinhThanh)
{
if (tenTinhThanh == "")
{
throw new Exception("Xin nhập tên tỉnh thành");
return 0;
}
return DAOTinhThanh.LayMaTinhThanh(tenTinhThanh);
}
}
}
|
10hca1-team4-qldv
|
trunk/ 10hca1-team4-qldv/BUSQLDV/BUSTinhThanh.cs
|
C#
|
asf20
| 1,768
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAOQLDV;
using System.Data;
using DTOQLDV;
namespace BUSQLDV
{
public class BUSXuLi
{
public delegate void XuLiCount();
public static XuLiCount _xuLiCount;
public static bool KiemTraKetNoi()
{
return DAOXuLi.KiemTraKetNoi();
}
public static List<DTODuLieuEX> DocDuLieuTuFileExcel(String fileName)
{
return DAOXuLi.DocDuLieuTuFileExcel(fileName);
}
public static void MapDuLieu(List<DTODuLieu> dsDL, List<DTODuLieuEX> dsDLEX)
{
try
{
String tenDiaDiem = "", tenDichVu = "", tenDuong = "", tenPhuong = "", tenQuanHuyen = "", tenTinhThanh = "";
int maDiaDiem=0, maDichVu=0, maDuong=0, maPhuong=0, maQuanHuyen=0, maTinhThanh=0;
int n = dsDLEX.Count - 1;
DTODuLieuEX dtoDLEX;
for (int i = n; i >= 0; i--)
{
DTODuLieu dtoDL = new DTODuLieu();
dtoDLEX = dsDLEX[i];
if (String.Compare(dtoDLEX.TenDiaDiem,tenDiaDiem,true)!=0)
{
maDiaDiem = BUSDiaDiem.LayMaDiaDiem(dtoDLEX.TenDiaDiem);
if (maDiaDiem == 0)
{
continue;
}
else
{
tenDiaDiem = dtoDLEX.TenDiaDiem;
dtoDL.MaDiaDiem = maDiaDiem;
}
}
else
{
dtoDL.MaDiaDiem = maDiaDiem;
}
if (String.Compare(dtoDLEX.TenDichVu,tenDichVu,true)!=0)
{
maDichVu = BUSDichVu.LayMaDichVu(dtoDLEX.TenDichVu);
if (maDichVu == 0)
{
continue;
}
else
{
tenDichVu = dtoDLEX.TenDichVu;
dtoDL.MaDichVu = maDichVu;
}
}
else
{
dtoDL.MaDichVu = maDichVu;
}
if (String.Compare(dtoDLEX.Duong,tenDuong,true)!=0)
{
maDuong = BUSDuong.LayMaDuong(dtoDLEX.Duong);
if (maDuong == 0)
{
continue;
}
else
{
tenDuong = dtoDLEX.Duong;
dtoDL.MaDuong = maDuong;
}
}
else
{
dtoDL.MaDuong = maDuong;
}
if (String.Compare(dtoDLEX.Phuong,tenPhuong,true)!=0)
{
maPhuong = BUSPhuong.LayMaPhuong(dtoDLEX.Phuong);
if (maPhuong == 0)
{
continue;
}
else
{
tenPhuong = dtoDLEX.Phuong;
dtoDL.MaPhuong = maPhuong;
}
}
else
{
dtoDL.MaPhuong = maPhuong;
}
if (String.Compare(dtoDLEX.QuanHuyen,tenQuanHuyen,true)!=0)
{
maQuanHuyen = BUSQuanHuyen.LayMaQuanHuyen(dtoDLEX.QuanHuyen);
if (maQuanHuyen == 0)
{
continue;
}
else
{
tenQuanHuyen = dtoDLEX.QuanHuyen;
dtoDL.MaQuanHuyen = maQuanHuyen;
}
}
else
{
dtoDL.MaQuanHuyen = maQuanHuyen;
}
if (String.Compare(dtoDLEX.TinhThanh,tenTinhThanh,true)!=0)
{
maTinhThanh = BUSTinhThanh.LayMaTinhThanh(dtoDLEX.TinhThanh);
if (maTinhThanh == 0)
{
continue;
}
else
{
tenTinhThanh = dtoDLEX.TinhThanh;
dtoDL.MaTinhThanh = maTinhThanh;
}
}
else
{
dtoDL.MaTinhThanh = maTinhThanh;
}
dtoDL.SoNha = dtoDLEX.SoNha;
dtoDL.KinhDo = dtoDLEX.KinhDo;
dtoDL.ViDo = dtoDLEX.ViDo;
dtoDL.ChuThich = dtoDLEX.ChuThich;
dsDL.Add(dtoDL);
dsDLEX.RemoveAt(i);
}
}
catch (Exception ex)
{
throw ex;
}
}
public static void CaiDatDuLieuNhap(List<DTODuLieuEX> dsDL, bool[]arr)
{
try
{
String tenDiaDiem = "", tenDichVu="", tenDuong="", tenPhuong="", tenQuanHuyen="", tenTinhThanh="";
int kq=0;
DTODiaDiem dtoDD = new DTODiaDiem();
DTODichVu dtoDV = new DTODichVu();
DTODuong dtoD = new DTODuong();
DTOPhuong dtoP = new DTOPhuong();
DTOQuanHuyen dtoQ = new DTOQuanHuyen();
DTOTinhThanh dtoTT = new DTOTinhThanh();
foreach (DTODuLieuEX dtoDLEX in dsDL)
{
if (String.Compare(dtoDLEX.TenDiaDiem,tenDiaDiem,true)!=0)
{
kq = BUSDiaDiem.LayMaDiaDiem(dtoDLEX.TenDiaDiem);
if (kq == 0 && arr[0])
{
dtoDD.TenDiaDiem = dtoDLEX.TenDiaDiem;
BUSDiaDiem.ThemDiaDiem(dtoDD);
SESSION._dsDiaDiem.Add(dtoDD);
}
tenDiaDiem = dtoDLEX.TenDiaDiem;
}
if (String.Compare(dtoDLEX.TenDichVu,tenDichVu,true)!=0)
{
kq = BUSDichVu.LayMaDichVu(dtoDLEX.TenDichVu);
if (kq == 0 && arr[1])
{
dtoDV.TenDichVu = dtoDLEX.TenDichVu;
BUSDichVu.ThemDichVu(dtoDV);
SESSION._dsDichVu.Add(dtoDV);
}
tenDichVu = dtoDLEX.TenDichVu;
}
if (String.Compare(dtoDLEX.Duong,tenDuong,true)!=0)
{
kq = BUSDuong.LayMaDuong(dtoDLEX.Duong);
if (kq == 0 && arr[2])
{
dtoD.TenDuong = dtoDLEX.Duong;
BUSDuong.ThemDuong(dtoD);
SESSION._dsDuong.Add(dtoD);
}
tenDuong = dtoDLEX.Duong;
}
if (String.Compare(dtoDLEX.Phuong,tenPhuong,true)!=0)
{
kq = BUSPhuong.LayMaPhuong(dtoDLEX.Phuong);
if (kq == 0 && arr[3])
{
dtoP.TenPhuong = dtoDLEX.Phuong;
BUSPhuong.ThemPhuong(dtoP);
SESSION._dsPhuong.Add(dtoP);
}
tenPhuong = dtoDLEX.Phuong;
}
if (String.Compare(dtoDLEX.QuanHuyen,tenQuanHuyen,true)!=0)
{
kq = BUSQuanHuyen.LayMaQuanHuyen(dtoDLEX.QuanHuyen);
if (kq == 0 && arr[4])
{
dtoQ.TenQuanHuyen = dtoDLEX.QuanHuyen;
BUSQuanHuyen.ThemQuanHuyen(dtoQ);
SESSION._dsQuanHuyen.Add(dtoQ);
}
tenQuanHuyen = dtoDLEX.QuanHuyen;
}
if (String.Compare(dtoDLEX.TinhThanh,tenTinhThanh,true)!=0)
{
kq = BUSTinhThanh.LayMaTinhThanh(dtoDLEX.TinhThanh);
if (kq == 0 && arr[5])
{
dtoTT.TenTinhThanh = dtoDLEX.TinhThanh;
BUSTinhThanh.ThemTinhThanh(dtoTT);
SESSION._dsTinhThanh.Add(dtoTT);
}
tenTinhThanh = dtoDLEX.TinhThanh;
}
_xuLiCount();
}
}
catch (Exception ex)
{
throw ex;
}
}
}
}
|
10hca1-team4-qldv
|
trunk/ 10hca1-team4-qldv/BUSQLDV/BUSXuLi.cs
|
C#
|
asf20
| 9,858
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTOQLDV;
using DAOQLDV;
namespace BUSQLDV
{
public class BUSDuong
{
public static List<DTODuong> LayDanhSachDuong()
{
return DAODuong.LayDanhSachDuong();
}
public static bool ThemDuong(DTODuong dtoD)
{
if (dtoD.TenDuong == "")
{
throw new Exception("Xin nhập tên đường");
return false;
}
return DAODuong.ThemDuong(dtoD);
}
public static bool CapNhatDuong(DTODuong dtoD)
{
if (dtoD.MaDuong == 0)
{
throw new Exception("Xin chọn đường");
return false;
}
if (dtoD.TenDuong == "")
{
throw new Exception("Xin nhập tên đường");
return false;
}
return DAODuong.CapNhatDuong(dtoD);
}
public static bool XoaDuong(DTODuong dtoD)
{
if (dtoD.MaDuong == 0)
{
throw new Exception("Xin chọn đường");
return false;
}
return DAODuong.XoaDuong(dtoD);
}
public static int LayMaDuong(String tenDuong)
{
if (tenDuong == "")
{
throw new Exception("Xin nhập tên đường");
return 0;
}
return DAODuong.LayMaDuong(tenDuong);
}
}
}
|
10hca1-team4-qldv
|
trunk/ 10hca1-team4-qldv/BUSQLDV/BUSDuong.cs
|
C#
|
asf20
| 1,629
|
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("BUSQLDV")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BUSQLDV")]
[assembly: AssemblyCopyright("Copyright © 2011")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("13076bc4-c401-471d-b944-7b7585cd2827")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
|
10hca1-team4-qldv
|
trunk/ 10hca1-team4-qldv/BUSQLDV/Properties/AssemblyInfo.cs
|
C#
|
asf20
| 1,426
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAOQLDV;
using DTOQLDV;
using System.Data;
namespace BUSQLDV
{
public class BUSDuLieu
{
public static List<DTODuLieu> LayDanhSachDuLieu()
{
return DAODuLieu.LayDanhSachDuLieu();
}
public static bool CapNhatDanhSach(List<DTODuLieu> dsDuLieu)
{
return DAODuLieu.CapNhatDanhSach(dsDuLieu);
}
public static bool CapNhatDuLieu(DTODuLieu dtoDuLieu)
{
if (dtoDuLieu.MaDiaDiem == 0)
{
throw new Exception("Xin chọn tên địa điểm");
return false;
}
if (dtoDuLieu.MaDichVu == 0)
{
throw new Exception("Xin chọn tên dịch vụ");
return false;
}
if (dtoDuLieu.MaDuong == 0)
{
throw new Exception("Xin chọn tên đường");
return false;
}
if (dtoDuLieu.MaPhuong == 0)
{
throw new Exception("Xin chọn tên phường");
return false;
}
if (dtoDuLieu.MaQuanHuyen == 0)
{
throw new Exception("Xin chọn quận/huyện");
return false;
}
if (dtoDuLieu.MaTinhThanh == 0)
{
throw new Exception("Xin chọn tỉnh thành");
return false;
}
if (dtoDuLieu.SoNha == "")
{
throw new Exception("Xin nhập số nhà");
return false;
}
return DAODuLieu.CapNhatDuLieu(dtoDuLieu);
}
public static bool XoaDuLieu(DTODuLieu dtoDuLieu)
{
if (dtoDuLieu.MaDuLieu ==0)
{
throw new Exception("Xin nhập chọn dữ liệu");
return false;
}
return DAODuLieu.XoaDuLieu(dtoDuLieu);
}
public static bool XoaDanhSach(List<DTODuLieu> dsDuLieu)
{
return DAODuLieu.XoaDanhSach(dsDuLieu);
}
public static bool ThemDanhSachDuLieu(List<DTODuLieu> dsDuLieu)
{
return DAODuLieu.ThemDanhSachDuLieu(dsDuLieu);
}
public static bool ThemDuLieu(DTODuLieu dToDuLieu)
{
if (dToDuLieu.MaDiaDiem == 0)
{
throw new Exception("Xin chọn tên địa điểm");
return false;
}
if (dToDuLieu.MaDichVu == 0)
{
throw new Exception("Xin chọn tên dịch vụ");
return false;
}
if (dToDuLieu.MaDuong == 0)
{
throw new Exception("Xin chọn tên đường");
return false;
}
if (dToDuLieu.MaPhuong == 0)
{
throw new Exception("Xin chọn tên phường");
return false;
}
if (dToDuLieu.MaQuanHuyen == 0)
{
throw new Exception("Xin chọn quận/huyện");
return false;
}
if (dToDuLieu.MaTinhThanh == 0)
{
throw new Exception("Xin chọn tỉnh thành");
return false;
}
if (dToDuLieu.SoNha=="")
{
throw new Exception("Xin nhập số nhà");
return false;
}
return DAODuLieu.ThemDuLieu(dToDuLieu);
}
}
}
|
10hca1-team4-qldv
|
trunk/ 10hca1-team4-qldv/BUSQLDV/BUSDuLieu.cs
|
C#
|
asf20
| 3,771
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTOQLDV;
using DAOQLDV;
namespace BUSQLDV
{
public class BUSQuanHuyen
{
public static List<DTOQuanHuyen> LayDanhSachQuanHuyen()
{
return DAOQuanHuyen.LayDanhSachQuanHuyen();
}
public static bool ThemQuanHuyen(DTOQuanHuyen dtoQH)
{
if (dtoQH.TenQuanHuyen == "")
{
throw new Exception("Xin nhập tên quận huyện");
return false;
}
return DAOQuanHuyen.ThemQuanHuyen(dtoQH);
}
public static bool CapNhatQuanHuyen(DTOQuanHuyen dtoQH)
{
if (dtoQH.MaQuanHuyen == 0)
{
throw new Exception("Xin chọn quận/huyện");
return false;
}
if (dtoQH.TenQuanHuyen == "")
{
throw new Exception("Xin nhập tên quận huyện");
return false;
}
return DAOQuanHuyen.CapNhatQuanHuyen(dtoQH);
}
public static bool XoaQuanHuyen(DTOQuanHuyen dtoQH)
{
if (dtoQH.MaQuanHuyen==0)
{
throw new Exception("Xin chọn quận/huyện");
return false;
}
return DAOQuanHuyen.XoaQuanHuyen(dtoQH);
}
public static int LayMaQuanHuyen(String tenQuanHuyen)
{
if (tenQuanHuyen == "")
{
throw new Exception("Xin nhập tên quận huyện");
return 0;
}
return DAOQuanHuyen.LayMaQuanHuyen(tenQuanHuyen);
}
}
}
|
10hca1-team4-qldv
|
trunk/ 10hca1-team4-qldv/BUSQLDV/BUSQuanHuyen.cs
|
C#
|
asf20
| 1,772
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using DTOQLDV;
using BUSQLDV;
namespace BUSQLDV
{
public class BUSThread
{
public static List<DTODuLieu> _dsDuLieu;
private static List<DTODuLieuEX> _dsDuLieuEx;
private static Thread _threadNhap;
private static Thread _threadXoa;
private static void XoaDuLieu()
{
if (_dsDuLieu!=null && _dsDuLieu.Count > 0)
{
BUSDuLieu.XoaDanhSach(_dsDuLieu);
}
}
public static void ThucHienThreadXoaDuLieu()
{
_threadXoa = new Thread(new ThreadStart(XoaDuLieu));
_threadXoa.IsBackground = true;
_threadXoa.Start();
}
private static void NhapDuLieu()
{
}
public static void ThucHienThreadNhapDuLieu()
{
_threadNhap = new Thread(new ThreadStart(NhapDuLieu));
_threadNhap.IsBackground = true;
_threadNhap.Start();
}
}
}
|
10hca1-team4-qldv
|
trunk/ 10hca1-team4-qldv/BUSQLDV/BUSThread.cs
|
C#
|
asf20
| 1,131
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAOQLDV;
using DTOQLDV;
namespace BUSQLDV
{
public class BUSDiaDiem
{
public static List<DTODiaDiem> LayDanhSachDiaDiem()
{
return DAODiaDiem.LayDanhSachDiaDiem();
}
public static bool ThemDiaDiem(DTODiaDiem dtoDD)
{
if (dtoDD.TenDiaDiem=="")
{
throw new Exception("Xin nhập tên địa điểm");
return false;
}
return DAODiaDiem.ThemDiaDiem(dtoDD);
}
public static bool CapNhatDiaDiem(DTODiaDiem dtoDD)
{
if (dtoDD.MaDiaDiem == 0)
{
throw new Exception("Xin chọn địa điểm");
return false;
}
if (dtoDD.TenDiaDiem == "")
{
throw new Exception("Xin nhập tên địa điểm");
return false;
}
return DAODiaDiem.CapNhatDiaDiem(dtoDD);
}
public static bool XoaDiaDiem(DTODiaDiem dtoDD)
{
if (dtoDD.MaDiaDiem==0)
{
throw new Exception("Xin chọn địa điểm");
return false;
}
return DAODiaDiem.XoaDiaDiem(dtoDD);
}
public static int LayMaDiaDiem(String tenDiaDiem)
{
if (tenDiaDiem == "")
{
throw new Exception("Xin nhập tên địa điểm");
return 0;
}
return DAODiaDiem.LayMaDiaDiem(tenDiaDiem);
}
}
}
|
10hca1-team4-qldv
|
trunk/ 10hca1-team4-qldv/BUSQLDV/BUSDiaDiem.cs
|
C#
|
asf20
| 1,721
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTOQLDV;
using DAOQLDV;
namespace BUSQLDV
{
public class BUSPhuong
{
public static List<DTOPhuong> LayDanhSachPhuong()
{
return DAOPhuong.LayDanhSachPhuong();
}
public static bool ThemPhuong(DTOPhuong dtoP)
{
if (dtoP.TenPhuong == "")
{
throw new Exception("Xin nhập tên phường");
return false;
}
return DAOPhuong.ThemPhuong(dtoP);
}
public static bool CapNhatPhuong(DTOPhuong dtoP)
{
if (dtoP.MaPhuong == 0)
{
throw new Exception("Xin chọn phường");
return false;
}
if (dtoP.TenPhuong == "")
{
throw new Exception("Xin nhập tên phường");
return false;
}
return DAOPhuong.CapNhatPhuong(dtoP);
}
public static bool XoaPhuong(DTOPhuong dtoP)
{
if (dtoP.MaPhuong==0)
{
throw new Exception("Xin chọn phường");
return false;
}
return DAOPhuong.XoaPhuong(dtoP);
}
public static int LayMaPhuong(String tenPhuong)
{
if (tenPhuong == "")
{
throw new Exception("Xin nhập tên phường");
return 0;
}
return DAOPhuong.LayMaPhuong(tenPhuong);
}
}
}
|
10hca1-team4-qldv
|
trunk/ 10hca1-team4-qldv/BUSQLDV/BUSPhuong.cs
|
C#
|
asf20
| 1,656
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
namespace CTLQLDV
{
public partial class CLTTenDiaDiem : DevExpress.XtraEditors.XtraUserControl
{
public CLTTenDiaDiem()
{
InitializeComponent();
}
}
}
|
10hca1-team4-qldv
|
trunk/ 10hca1-team4-qldv/CTLQLDV/CLTTenDiaDiem.cs
|
C#
|
asf20
| 418
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
namespace CTLQLDV
{
public partial class CTLQuanHuyen : DevExpress.XtraEditors.XtraUserControl
{
public CTLQuanHuyen()
{
InitializeComponent();
}
}
}
|
10hca1-team4-qldv
|
trunk/ 10hca1-team4-qldv/CTLQLDV/CTLQuanHuyen.cs
|
C#
|
asf20
| 416
|
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("CTLQLDV")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CTLQLDV")]
[assembly: AssemblyCopyright("Copyright © 2012")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("f47bdcd7-6acc-405f-b3d4-e061aa01f2ed")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
|
10hca1-team4-qldv
|
trunk/ 10hca1-team4-qldv/CTLQLDV/Properties/AssemblyInfo.cs
|
C#
|
asf20
| 1,426
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using BUSQLDV;
using DTOQLDV;
namespace CTLQLDV
{
public partial class CTLDuLieu : DevExpress.XtraEditors.XtraUserControl
{
public CTLDuLieu()
{
_duLieu = new DTODuLieu();
InitializeComponent();
KhoiTao();
}
private void LamTuoi()
{
thTenDichVu.EditValue = _duLieu.MaDichVu;
thTenDiaDiem.EditValue = _duLieu.MaDiaDiem;
thTenDuong.EditValue = _duLieu.MaDuong;
thTenPhuong.EditValue = _duLieu.MaPhuong;
thTenQuanHuyen.EditValue = _duLieu.MaQuanHuyen;
thTenTinhThanh.EditValue = _duLieu.MaTinhThanh;
thSoNha.Text = _duLieu.SoNha;
thKinhDo.Text = _duLieu.KinhDo;
thViDo.Text = _duLieu.ViDo;
thChuThich.Text = _duLieu.ChuThich;
this.Refresh();
}
private DTODuLieu _duLieu;
private void KhoiTao()
{
thTenDichVu.Properties.DisplayMember = "TenDichVu";
thTenDichVu.Properties.ValueMember = "MaDichVu";
thTenDichVu.Properties.NullText = "Xin chọn tên dịch vụ";
thTenDichVu.Properties.ActionButtonIndex = 3;
thTenDichVu.Properties.Buttons[2].Enabled = false;
thTenDichVu.Properties.Buttons[1].Enabled = false;
thTenDichVu.EditValue = null;
thTenDuong.Properties.DisplayMember = "TenDuong";
thTenDuong.Properties.ValueMember = "MaDuong";
thTenDuong.Properties.NullText = "Xin chọn tên đường";
thTenDuong.Properties.ActionButtonIndex = 3;
thTenDuong.Properties.Buttons[2].Enabled = false;
thTenDuong.Properties.Buttons[1].Enabled = false;
thTenDuong.EditValue = null;
thTenPhuong.Properties.DisplayMember = "TenPhuong";
thTenPhuong.Properties.ValueMember = "MaPhuong";
thTenPhuong.Properties.NullText = "Xin chọn tên phường";
thTenPhuong.Properties.ActionButtonIndex = 3;
thTenPhuong.Properties.Buttons[2].Enabled = false;
thTenPhuong.Properties.Buttons[1].Enabled = false;
thTenPhuong.EditValue = null;
thTenQuanHuyen.Properties.DisplayMember = "TenQuanHuyen";
thTenQuanHuyen.Properties.ValueMember = "MaQuanHuyen";
thTenQuanHuyen.Properties.NullText = "Xin chọn quận huyện";
thTenQuanHuyen.Properties.ActionButtonIndex = 3;
thTenQuanHuyen.Properties.Buttons[2].Enabled = false;
thTenQuanHuyen.Properties.Buttons[1].Enabled = false;
thTenQuanHuyen.EditValue = null;
thTenTinhThanh.Properties.DisplayMember = "TenTinhThanh";
thTenTinhThanh.Properties.ValueMember = "MaTinhThanh";
thTenTinhThanh.Properties.NullText = "Xin chọn tỉnh thành";
thTenTinhThanh.Properties.ActionButtonIndex = 3;
thTenTinhThanh.Properties.Buttons[2].Enabled = false;
thTenTinhThanh.Properties.Buttons[1].Enabled = false;
thTenTinhThanh.EditValue = null;
thTenDiaDiem.Properties.DisplayMember = "TenDiaDiem";
thTenDiaDiem.Properties.ValueMember = "MaDiaDiem";
thTenDiaDiem.Properties.NullText = "Xin chọn địa điểm";
thTenDiaDiem.Properties.ActionButtonIndex = 3;
thTenDiaDiem.Properties.Buttons[2].Enabled = false;
thTenDiaDiem.Properties.Buttons[1].Enabled = false;
thTenDiaDiem.EditValue = null;
thSoNha.Properties.NullText = "Xin nhập số nhà";
thSoNha.EditValue = null;
thKinhDo.Properties.NullText = "Xin nhập kinh độ";
thKinhDo.EditValue = null;
thViDo.Properties.NullText = "Xin nhập vĩ độ";
thViDo.EditValue = null;
thChuThich.Properties.NullText = "Xin nhập chú thích";
thChuThich.EditValue = null;
thTenDichVu.Properties.DataSource = SESSION._dsDichVu;
thTenDuong.Properties.DataSource = SESSION._dsDuong;
thTenPhuong.Properties.DataSource = SESSION._dsPhuong;
thTenQuanHuyen.Properties.DataSource = SESSION._dsQuanHuyen;
thTenTinhThanh.Properties.DataSource = SESSION._dsTinhThanh;
thTenDiaDiem.Properties.DataSource = SESSION._dsDiaDiem;
}
public DTODuLieu LayDuLieu()
{
_duLieu.MaDichVu = int.Parse("0" + thTenDichVu.EditValue);
_duLieu.MaDuong = int.Parse("0" + thTenDuong.EditValue);
_duLieu.MaPhuong = int.Parse("0" + thTenPhuong.EditValue);
_duLieu.MaQuanHuyen = int.Parse("0" + thTenQuanHuyen.EditValue);
_duLieu.MaTinhThanh = int.Parse("0" + thTenTinhThanh.EditValue);
_duLieu.MaDiaDiem = int.Parse("0" + thTenDiaDiem.EditValue);
_duLieu.SoNha = thSoNha.EditValue + "";
_duLieu.ChuThich = thChuThich.EditValue + "";
_duLieu.ViDo = thViDo.EditValue + "";
return _duLieu;
}
public void GanDuLieu(DTODuLieu dtoDL)
{
_duLieu = dtoDL;
LamTuoi();
}
private void HienThiCapNhat(LookUpEdit lk)
{
lk.Properties.Buttons[0].Enabled = false;
lk.Properties.Buttons[1].Enabled = true;
lk.Properties.Buttons[2].Enabled = true;
}
private void ThoatXuLi(LookUpEdit lk, int ma)
{
lk.Properties.Buttons[0].Enabled = true;
lk.Properties.Buttons[1].Enabled = false;
lk.Properties.Buttons[1].Tag = null;
lk.Properties.Buttons[0].Tag = null;
lk.Properties.Buttons[2].Enabled = false;
lk.EditValue = ma;
}
private void HienThiThemMoi(LookUpEdit lk)
{
lk.Properties.Buttons[0].Enabled = true;
lk.Properties.Buttons[1].Enabled = false;
lk.Properties.Buttons[2].Enabled = true;
}
private void thTenDiaDiem_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
{
switch (e.Button.Index)
{
case 0:
{
if (thTenDiaDiem.Properties.Buttons[0].Tag != null)
{
DTODiaDiem dto = new DTODiaDiem();
dto.TenDiaDiem = thTenDiaDiem.Text+"";
BUSDiaDiem.ThemDiaDiem(dto);
SESSION._dsDiaDiem.Add(dto);
ThoatXuLi(thTenDiaDiem,dto.MaDiaDiem);
}
else
{
HienThiThemMoi(thTenDiaDiem);
thTenDiaDiem.Properties.Buttons[0].Tag = 1;
}
} break;
case 1:
{
if (thTenDiaDiem.Properties.Buttons[1].Tag != null)
{
DTODiaDiem dto = (DTODiaDiem)thTenDiaDiem.Properties.Buttons[1].Tag;
dto.TenDiaDiem = thTenDiaDiem.Text;
BUSDiaDiem.CapNhatDiaDiem(dto);
ThoatXuLi(thTenDiaDiem,dto.MaDiaDiem);
thTenDiaDiem.EditValue = dto.MaDiaDiem;
}
else
{
thTenDiaDiem.Properties.Buttons[1].Tag = thTenDiaDiem.GetSelectedDataRow();
HienThiCapNhat(thTenDiaDiem);
}
} break;
default: ThoatXuLi(thTenDiaDiem,_duLieu.MaDiaDiem); break;
}
}
private void thTenDiaDiem_EditValueChanged(object sender, EventArgs e)
{
if (thTenDiaDiem.ItemIndex >= 0 && thTenDiaDiem.Properties.Buttons[0].Tag==null)
{
thTenDiaDiem.Properties.Buttons[1].Enabled = true;
}
else
{
thTenDiaDiem.Properties.Buttons[1].Enabled = false;
}
}
private void thTenDichVu_EditValueChanged(object sender, EventArgs e)
{
if (thTenDichVu.ItemIndex >= 0 && thTenDichVu.Properties.Buttons[0].Tag == null)
{
thTenDichVu.Properties.Buttons[1].Enabled = true;
}
else
{
thTenDichVu.Properties.Buttons[1].Enabled = false;
}
}
private void thTenDuong_EditValueChanged(object sender, EventArgs e)
{
if (thTenDuong.ItemIndex >= 0 && thTenDuong.Properties.Buttons[0].Tag == null)
{
thTenDuong.Properties.Buttons[1].Enabled = true;
}
else
{
thTenDuong.Properties.Buttons[1].Enabled = false;
}
}
private void thTenPhuong_EditValueChanged(object sender, EventArgs e)
{
if (thTenPhuong.ItemIndex >= 0 && thTenPhuong.Properties.Buttons[0].Tag == null)
{
thTenPhuong.Properties.Buttons[1].Enabled = true;
}
else
{
thTenPhuong.Properties.Buttons[1].Enabled = false;
}
}
private void thTenQuanHuyen_EditValueChanged(object sender, EventArgs e)
{
if (thTenQuanHuyen.ItemIndex >= 0 && thTenQuanHuyen.Properties.Buttons[0].Tag == null)
{
thTenQuanHuyen.Properties.Buttons[1].Enabled = true;
}
else
{
thTenQuanHuyen.Properties.Buttons[1].Enabled = false;
}
}
private void thTenTinhThanh_EditValueChanged(object sender, EventArgs e)
{
if (thTenTinhThanh.ItemIndex >= 0 && thTenTinhThanh.Properties.Buttons[0].Tag == null)
{
thTenTinhThanh.Properties.Buttons[1].Enabled = true;
}
else
{
thTenTinhThanh.Properties.Buttons[1].Enabled = false;
}
}
private void thTenDichVu_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
{
switch (e.Button.Index)
{
case 0:
{
if (thTenDichVu.Properties.Buttons[0].Tag != null)
{
DTODichVu dto = new DTODichVu();
dto.TenDichVu = thTenDichVu.Text + "";
BUSDichVu.ThemDichVu(dto);
SESSION._dsDichVu.Add(dto);
ThoatXuLi(thTenDichVu,dto.MaDichVu);
}
else
{
HienThiThemMoi(thTenDichVu);
thTenDichVu.Properties.Buttons[0].Tag = 1;
}
} break;
case 1:
{
if (thTenDichVu.Properties.Buttons[1].Tag != null)
{
DTODichVu dto = (DTODichVu)thTenDichVu.Properties.Buttons[1].Tag;
dto.TenDichVu = thTenDichVu.Text;
BUSDichVu.CapNhatDichVu(dto);
ThoatXuLi(thTenDichVu,dto.MaDichVu);
}
else
{
thTenDichVu.Properties.Buttons[1].Tag = thTenDichVu.GetSelectedDataRow();
HienThiCapNhat(thTenDichVu);
}
} break;
default: ThoatXuLi(thTenDichVu,_duLieu.MaDichVu); break;
}
}
private void thTenDuong_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
{
switch (e.Button.Index)
{
case 0:
{
if (thTenDuong.Properties.Buttons[0].Tag != null)
{
DTODuong dto = new DTODuong();
dto.TenDuong = thTenDuong.Text + "";
BUSDuong.ThemDuong(dto);
SESSION._dsDuong.Add(dto);
ThoatXuLi(thTenDuong,dto.MaDuong);
}
else
{
HienThiThemMoi(thTenDuong);
thTenDuong.Properties.Buttons[0].Tag = 1;
}
} break;
case 1:
{
if (thTenDuong.Properties.Buttons[1].Tag != null)
{
DTODuong dto = (DTODuong)thTenDuong.Properties.Buttons[1].Tag;
dto.TenDuong = thTenDuong.Text;
BUSDuong.CapNhatDuong(dto);
ThoatXuLi(thTenDuong,dto.MaDuong);
}
else
{
thTenDuong.Properties.Buttons[1].Tag = thTenDuong.GetSelectedDataRow();
HienThiCapNhat(thTenDuong);
}
} break;
default: ThoatXuLi(thTenDuong,_duLieu.MaDuong); break;
}
}
private void thTenPhuong_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
{
switch (e.Button.Index)
{
case 0:
{
if (thTenPhuong.Properties.Buttons[0].Tag != null)
{
DTOPhuong dto = new DTOPhuong();
dto.TenPhuong = thTenPhuong.Text + "";
BUSPhuong.ThemPhuong(dto);
SESSION._dsPhuong.Add(dto);
ThoatXuLi(thTenPhuong,dto.MaPhuong);
}
else
{
HienThiThemMoi(thTenPhuong);
thTenPhuong.Properties.Buttons[0].Tag = 1;
}
} break;
case 1:
{
if (thTenPhuong.Properties.Buttons[1].Tag != null)
{
DTOPhuong dto = (DTOPhuong)thTenPhuong.Properties.Buttons[1].Tag;
dto.TenPhuong = thTenPhuong.Text;
BUSPhuong.CapNhatPhuong(dto);
ThoatXuLi(thTenPhuong,dto.MaPhuong);
}
else
{
thTenPhuong.Properties.Buttons[1].Tag = thTenPhuong.GetSelectedDataRow();
HienThiCapNhat(thTenPhuong);
}
} break;
default: ThoatXuLi(thTenPhuong,_duLieu.MaPhuong); break;
}
}
private void thTenQuanHuyen_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
{
switch (e.Button.Index)
{
case 0:
{
if (thTenQuanHuyen.Properties.Buttons[0].Tag != null)
{
DTOQuanHuyen dto = new DTOQuanHuyen();
dto.TenQuanHuyen = thTenQuanHuyen.Text + "";
BUSQuanHuyen.ThemQuanHuyen(dto);
SESSION._dsQuanHuyen.Add(dto);
ThoatXuLi(thTenQuanHuyen,dto.MaQuanHuyen);
}
else
{
HienThiThemMoi(thTenQuanHuyen);
thTenQuanHuyen.Properties.Buttons[0].Tag = 1;
}
} break;
case 1:
{
if (thTenQuanHuyen.Properties.Buttons[1].Tag != null)
{
DTOQuanHuyen dto = (DTOQuanHuyen)thTenQuanHuyen.Properties.Buttons[1].Tag;
dto.TenQuanHuyen = thTenQuanHuyen.Text;
BUSQuanHuyen.CapNhatQuanHuyen(dto);
ThoatXuLi(thTenQuanHuyen,dto.MaQuanHuyen);
}
else
{
thTenQuanHuyen.Properties.Buttons[1].Tag = thTenQuanHuyen.GetSelectedDataRow();
HienThiCapNhat(thTenQuanHuyen);
}
} break;
default: ThoatXuLi(thTenQuanHuyen,_duLieu.MaQuanHuyen); break;
}
}
private void thTenTinhThanh_ButtonClick(object sender, DevExpress.XtraEditors.Controls.ButtonPressedEventArgs e)
{
switch (e.Button.Index)
{
case 0:
{
if (thTenTinhThanh.Properties.Buttons[0].Tag != null)
{
DTOTinhThanh dto = new DTOTinhThanh();
dto.TenTinhThanh = thTenTinhThanh.Text + "";
BUSTinhThanh.ThemTinhThanh(dto);
SESSION._dsTinhThanh.Add(dto);
ThoatXuLi(thTenTinhThanh,dto.MaTinhThanh);
}
else
{
HienThiThemMoi(thTenTinhThanh);
thTenTinhThanh.Properties.Buttons[0].Tag = 1;
}
} break;
case 1:
{
if (thTenTinhThanh.Properties.Buttons[1].Tag != null)
{
DTOTinhThanh dto = (DTOTinhThanh)thTenTinhThanh.Properties.Buttons[1].Tag;
dto.TenTinhThanh = thTenTinhThanh.Text;
BUSTinhThanh.CapNhatTinhThanh(dto);
ThoatXuLi(thTenTinhThanh,dto.MaTinhThanh);
}
else
{
thTenTinhThanh.Properties.Buttons[1].Tag = thTenTinhThanh.GetSelectedDataRow();
HienThiCapNhat(thTenTinhThanh);
}
} break;
default: ThoatXuLi(thTenTinhThanh,_duLieu.MaTinhThanh); break;
}
}
}
}
|
10hca1-team4-qldv
|
trunk/ 10hca1-team4-qldv/CTLQLDV/CTLDuLieu.cs
|
C#
|
asf20
| 19,907
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
namespace CTLQLDV
{
public partial class CTLDuong : DevExpress.XtraEditors.XtraUserControl
{
public CTLDuong()
{
InitializeComponent();
}
}
}
|
10hca1-team4-qldv
|
trunk/ 10hca1-team4-qldv/CTLQLDV/CTLDuong.cs
|
C#
|
asf20
| 408
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
namespace CTLQLDV
{
public partial class CTLDichVu : DevExpress.XtraEditors.XtraUserControl
{
public CTLDichVu()
{
InitializeComponent();
}
}
}
|
10hca1-team4-qldv
|
trunk/ 10hca1-team4-qldv/CTLQLDV/CTLDichVu.cs
|
C#
|
asf20
| 410
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
namespace CTLQLDV
{
public partial class CTLTinhThanh : DevExpress.XtraEditors.XtraUserControl
{
public CTLTinhThanh()
{
InitializeComponent();
}
}
}
|
10hca1-team4-qldv
|
trunk/ 10hca1-team4-qldv/CTLQLDV/CTLTinhThanh.cs
|
C#
|
asf20
| 416
|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
namespace CTLQLDV
{
public partial class CTLPhuong : DevExpress.XtraEditors.XtraUserControl
{
public CTLPhuong()
{
InitializeComponent();
}
}
}
|
10hca1-team4-qldv
|
trunk/ 10hca1-team4-qldv/CTLQLDV/CTLPhuong.cs
|
C#
|
asf20
| 410
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTOQLDV;
using System.Data;
using System.Data.OleDb;
namespace DAOQLDV
{
public class DAODichVu
{
public static List<DTODichVu> LayDanhSachDichVu()
{
List<DTODichVu> dsDichVu = new List<DTODichVu>();
DataAccess da = new DataAccess();
try
{
da.Open();
String sql = "Select * From DichVu";
OleDbDataReader dr = da.ExecuteQuery(sql);
while (dr.Read())
{
DTODichVu dtoDV = new DTODichVu();
dtoDV.MaDichVu = (int)dr["MaDichVu"];
dtoDV.TenDichVu = (String)dr["TenDichVu"];
dsDichVu.Add(dtoDV);
}
dr.Close();
}
catch (Exception ex)
{
throw ex;
}
finally
{
da.Close();
}
return dsDichVu;
}
public static DTODichVu LayThongTinDichVu(String tenDichVu)
{
DTODichVu dtoDichVu = new DTODichVu();
DataAccess da = new DataAccess();
try
{
da.Open();
String sql = "Select * From DichVu Where TenDichVu Like '"+tenDichVu+"'";
OleDbDataReader dr = da.ExecuteQuery(sql);
if (dr.Read())
{
dtoDichVu.MaDichVu = (int)dr["MaDichVu"];
dtoDichVu.TenDichVu = dr["TenDichVu"].ToString();
}
dr.Close();
}
catch (Exception ex)
{
throw ex;
}
finally
{
da.Close();
}
return dtoDichVu;
}
public static bool ThemDichVu(DTODichVu dtoDV)
{
bool kq = false;
DataAccess da = new DataAccess();
try
{
da.Open();
da.BeginTran();
String sql = "Insert Into TenDichVu(TenDichVu) Values ('" + dtoDV.TenDichVu + "')";
da.ExecuteNonQuery(sql);
sql = "Select @@IDENTITY";
dtoDV.MaDichVu = (int)da.ExecuteScalar(sql);
da.CommitTran();
kq = true;
}
catch (Exception ex)
{
da.RollBackTran();
throw ex;
}
finally
{
da.Close();
}
return kq;
}
public static bool CapNhatDichVu(DTODichVu dtoDV)
{
bool kq = false;
DataAccess da = new DataAccess();
try
{
da.Open();
String sql = "Update TenDichVu Set TenDichVu = '" + dtoDV.TenDichVu + "' Where MaTenDichVu = " + dtoDV.MaDichVu;
da.ExecuteNonQuery(sql);
}
catch (Exception ex)
{
throw ex;
}
finally
{
da.Close();
}
return kq;
}
public static bool XoaDichVu(DTODichVu dtoDV)
{
bool kq = false;
DataAccess da = new DataAccess();
try
{
da.Open();
String sql = "Delete From TenDichVu Where MaTenDichVu = " + dtoDV.MaDichVu;
da.ExecuteNonQuery(sql);
kq = true;
}
catch (Exception ex)
{
throw ex;
}
finally
{
da.Close();
}
return kq;
}
public static int LayMaDichVu(String tenDichVu)
{
int kq = 0;
DataAccess da = new DataAccess();
try
{
da.Open();
String sql = "Select MaDichVu From DichVu Where TenDichVu Like '" + tenDichVu + "'";
kq = int.Parse("0" + da.ExecuteScalar(sql));
}
catch (Exception ex)
{
throw ex;
}
finally
{
da.Close();
}
return kq;
}
}
}
|
10hca1-team4-qldv
|
trunk/ 10hca1-team4-qldv/DAOQLDV/DAODichVu.cs
|
C#
|
asf20
| 4,572
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTOQLDV;
namespace DAOQLDV
{
internal class DAOTuKhoaTinhThanh
{
public static bool ThemTuKhoaTinhThanh(DTOTinhThanh dtoTT, DataAccess da)
{
bool kq = false;
try
{
List<String> dsTuKhoa = DAOXuLi.dsTuKhoa(dtoTT.TenTinhThanh);
String sql = "";
foreach (String tkhoa in dsTuKhoa)
{
sql = "Insert Into TuKhoaTenTinhThanh(TenTuKhoaTinhThanh, MaTinhThanh) Value ('" + tkhoa + "', " + dtoTT.MaTinhThanh + ")";
da.ExecuteNonQuery(sql);
}
}
catch (Exception ex)
{
throw ex;
}
return kq;
}
}
}
|
10hca1-team4-qldv
|
trunk/ 10hca1-team4-qldv/DAOQLDV/DAOTuKhoaTinhThanh.cs
|
C#
|
asf20
| 888
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTOQLDV;
namespace DAOQLDV
{
internal class DAOTuKhoaDichVu
{
public static bool ThemTuKhoaDichVu(DTODichVu dtoDV, DataAccess da)
{
bool kq = false;
try
{
if (dtoDV.TenDichVu.Equals(""))
{
List<String> dsTuKhoa = DAOXuLi.dsTuKhoa(dtoDV.TenDichVu);
String sql = "";
foreach (String tkhoa in dsTuKhoa)
{
sql = "Insert Into TuKhoaTenDichVu(TenTuKhoaDichVu, MaDichVu) Value ('" + tkhoa + "', " + dtoDV.MaDichVu + ")";
da.ExecuteNonQuery(sql);
}
}
}
catch (Exception ex)
{
throw ex;
}
return kq;
}
}
}
|
10hca1-team4-qldv
|
trunk/ 10hca1-team4-qldv/DAOQLDV/DAOTuKhoaDichVu.cs
|
C#
|
asf20
| 971
|
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("DAOQLDV")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DAOQLDV")]
[assembly: AssemblyCopyright("Copyright © 2011")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("54ba09a5-638f-4d7c-bf9e-73ae78586fe5")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
|
10hca1-team4-qldv
|
trunk/ 10hca1-team4-qldv/DAOQLDV/Properties/AssemblyInfo.cs
|
C#
|
asf20
| 1,426
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTOQLDV;
using System.Data.OleDb;
using System.Data;
namespace DAOQLDV
{
public class DAODuLieu
{
public static List<DTODuLieu> LayDanhSachDuLieu()
{
List<DTODuLieu> dsDL = new List<DTODuLieu>();
DataAccess da = new DataAccess();
try
{
da.Open();
String sql = "Select * From DuLieu";
OleDbDataReader dr = da.ExecuteQuery(sql);
while (dr.Read())
{
DTODuLieu dtoDL = new DTODuLieu();
dtoDL.MaDuLieu = (int)dr["MaDuLieu"];
dtoDL.MaDichVu = (int)dr["MaDichVu"];
dtoDL.MaDuong = (int)dr["MaDuong"];
dtoDL.MaPhuong = (int)dr["MaPhuong"];
dtoDL.MaQuanHuyen = (int)dr["MaQuanHuyen"];
dtoDL.MaDiaDiem = (int)dr["MaTenDiaDiem"];
dtoDL.MaTinhThanh = (int)dr["MaTinhThanh"];
dtoDL.SoNha = dr["SoNha"].ToString();
dtoDL.ViDo = dr["ViDo"].ToString();
dtoDL.KinhDo = dr["KinhDo"].ToString();
dtoDL.ChuThich = dr["ChuThich"].ToString();
dsDL.Add(dtoDL);
}
dr.Close();
}
catch (Exception ex)
{
throw ex;
}
finally
{
da.Close();
}
return dsDL;
}
public static bool ThemDuLieu(DTODuLieu dtoDL)
{
bool kq = false;
DataAccess da = new DataAccess();
try
{
da.Open();
String sql = "Insert Into DuLieu(MaDichVu, MaTenDiaDiem, SoNha, MaDuong, MaPhuong, MaQuanHuyen, MaTinhThanh, KinhDo, ViDo, ChuThich) Values (";
sql += dtoDL.MaDichVu + ", " + dtoDL.MaDiaDiem + ", '" + dtoDL.SoNha + "', " + dtoDL.MaDuong + ", " + dtoDL.MaPhuong + ", " + dtoDL.MaQuanHuyen + ", " + dtoDL.MaTinhThanh + ", '" + dtoDL.KinhDo + "', '" + dtoDL.ViDo + "', '" + dtoDL.ChuThich + "')";
da.ExecuteNonQuery(sql);
sql = "Select @@IDENTITY";
dtoDL.MaDuLieu = (int)da.ExecuteScalar(sql);
kq = true;
}
catch (Exception ex)
{
throw ex;
}
finally
{
da.Close();
}
return kq;
}
public static bool XoaDuLieu(DTODuLieu dtoDL)
{
bool kq = false;
DataAccess da = new DataAccess();
try
{
da.Open();
String sql = "Delete From DuLieu Where MaDuLieu = " + dtoDL.MaDuLieu;
da.ExecuteNonQuery(sql);
kq = true;
}
catch (Exception ex)
{
throw ex;
}
finally
{
da.Close();
}
return kq;
}
public static bool ThemDanhSach(List<DTODuLieu> dsdtoDL)
{
bool kq = false;
DataAccess da = new DataAccess();
try
{
da.Open();
da.BeginTran();
String sql = "";
foreach (DTODuLieu dtoDL in dsdtoDL)
{
da.ExecuteNonQuery(sql);
}
da.CommitTran();
kq = true;
}
catch (Exception ex)
{
da.RollBackTran();
throw ex;
}
finally
{
da.Close();
}
return kq;
}
public static bool CapNhatDuLieu(DTODuLieu dtoDL)
{
bool kq = false;
DataAccess da = new DataAccess();
try
{
da.Open();
//da.BeginTran();
String sql = "Update DuLieu Set MaDichVu=" + dtoDL.MaDichVu;
sql += ", SoNha='" + dtoDL.SoNha + "', MaDuong=" + dtoDL.MaDuong + ", MaPhuong=" + dtoDL.MaPhuong;
sql += ", MaQuanHuyen=" + dtoDL.MaQuanHuyen + ", MaTinhThanh=" + dtoDL.MaTinhThanh + ", KinhDo='" + dtoDL.KinhDo + "', ViDo='" + dtoDL.ViDo + "', ChuThich='" + dtoDL.ChuThich + "'";
sql += " Where MaDuLieu = " + dtoDL.MaDuLieu;
da.ExecuteNonQuery(sql);
//da.CommitTran();
kq = true;
}
catch (Exception ex)
{
//da.RollBackTran();
throw ex;
}
finally
{
da.Close();
}
return kq;
}
public static bool CapNhatDanhSach(List<DTODuLieu> dsDuLieu)
{
bool kq = false;
DataAccess da = new DataAccess();
try
{
da.Open();
da.BeginTran();
String sql = "";
foreach (DTODuLieu dtoDL in dsDuLieu)
{
sql = "Update DuLieu Set MaDichVu=" + dtoDL.MaDichVu;
sql += ", SoNha='" + dtoDL.SoNha + "', MaDuong=" + dtoDL.MaDuong + ", MaPhuong=" + dtoDL.MaPhuong;
sql += ", MaQuanHuyen=" + dtoDL.MaQuanHuyen + ", MaTinhThanh=" + dtoDL.MaTinhThanh + ", KinhDo='" + dtoDL.KinhDo + "', ViDo='" + dtoDL.ViDo + "', ChuThich='" + dtoDL.ChuThich + "'";
sql += " Where MaDuLieu = " + dtoDL.MaDuLieu;
da.ExecuteNonQuery(sql);
}
da.CommitTran();
kq = true;
}
catch (Exception ex)
{
da.RollBackTran();
throw ex;
}
finally
{
da.Close();
}
return kq;
}
public static bool XoaDanhSach(List<DTODuLieu> dsDuLieu)
{
bool kq = false;
DataAccess da = new DataAccess();
try
{
da.Open();
da.BeginTran();
foreach (DTODuLieu dtoDL in dsDuLieu)
{
XoaDuLieu(dtoDL);
}
da.CommitTran();
kq = true;
}
catch (Exception ex)
{
da.RollBackTran();
throw ex;
}
finally
{
da.Close();
}
return kq;
}
public static bool ThemDanhSachDuLieu(List<DTODuLieu> dsDuLieu)
{
bool kq = false;
DataAccess da = new DataAccess();
try
{
da.Open();
da.BeginTran();
foreach (DTODuLieu dtoDL in dsDuLieu)
{
try
{
String sql = "Insert Into DuLieu(MaDichVu, MaTenDiaDiem, SoNha, MaDuong, MaPhuong, MaQuanHuyen, MaTinhThanh, KinhDo, ViDo, ChuThich) Values (";
sql += dtoDL.MaDichVu + ", " + dtoDL.MaDiaDiem + ", '" + dtoDL.SoNha + "', " + dtoDL.MaDuong + ", " + dtoDL.MaPhuong + ", " + dtoDL.MaQuanHuyen + ", " + dtoDL.MaTinhThanh + ", '" + dtoDL.KinhDo + "', '" + dtoDL.ViDo + "', '" + dtoDL.ChuThich + "')";
da.ExecuteNonQuery(sql);
sql = "Select @@IDENTITY";
dtoDL.MaDuLieu = (int)da.ExecuteScalar(sql);
SESSION._dsDuLieu.Add(dtoDL);
}
catch (ExecutionEngineException ex)
{
throw ex;
}
}
da.CommitTran();
kq = true;
}
catch (Exception ex)
{
da.RollBackTran();
throw ex;
}
finally
{
da.Close();
}
return kq;
}
}
}
|
10hca1-team4-qldv
|
trunk/ 10hca1-team4-qldv/DAOQLDV/DAODuLieu.cs
|
C#
|
asf20
| 8,559
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTOQLDV;
using System.Data;
using System.Data.OleDb;
namespace DAOQLDV
{
public class DAOPhuong
{
public static List<DTOPhuong> LayDanhSachPhuong()
{
List<DTOPhuong> dsPhuong = new List<DTOPhuong>();
DataAccess da = new DataAccess();
try
{
da.Open();
String sql = "Select * From Phuong";
OleDbDataReader dr = da.ExecuteQuery(sql);
while (dr.Read())
{
DTOPhuong dtoP = new DTOPhuong();
dtoP.MaPhuong = (int)dr["MaPhuong"];
dtoP.TenPhuong = (String)dr["TenPhuong"];
dsPhuong.Add(dtoP);
}
dr.Close();
}
catch (Exception ex)
{
throw ex;
}
finally
{
da.Close();
}
return dsPhuong;
}
public static DTOPhuong LayThongTinPhuong(String tenPhuong)
{
DTOPhuong dtoPhuong = new DTOPhuong();
DataAccess da = new DataAccess();
try
{
da.Open();
String sql = "Select * From Phuong Where TenPhuong like '"+tenPhuong+"'";
OleDbDataReader dr = da.ExecuteQuery(sql);
if (dr.Read())
{
dtoPhuong.MaPhuong = (int)dr["MaPhuong"];
dtoPhuong.TenPhuong = dr["TenPhuong"].ToString();
}
dr.Close();
}
catch (Exception ex)
{
throw ex;
}
finally
{
da.Close();
}
return dtoPhuong;
}
public static bool ThemPhuong(DTOPhuong dtoP)
{
bool kq = false;
DataAccess da = new DataAccess();
try
{
if (!dtoP.TenPhuong.Equals(""))
{
da.Open();
da.BeginTran();
String sql = "Insert Into TenPhuong(TenPhuong) Values ('" + dtoP.TenPhuong + "')";
da.ExecuteNonQuery(sql);
sql = "Select @@IDENTITY";
dtoP.MaPhuong = (int)da.ExecuteScalar(sql);
da.CommitTran();
kq = true;
}
}
catch (Exception ex)
{
da.RollBackTran();
throw ex;
}
return kq;
}
public static bool CapNhatPhuong(DTOPhuong dtoP)
{
bool kq = false;
DataAccess da = new DataAccess();
try
{
if (!dtoP.TenPhuong.Equals(""))
{
da.Open();
String sql = "Update TenPhuong Set TenPhuong = '" + dtoP.TenPhuong + "' Where MaTenPhuong = " + dtoP.MaPhuong;
da.ExecuteNonQuery(sql);
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
da.Close();
}
return kq;
}
public static bool XoaPhuong(DTOPhuong dtoP)
{
bool kq = false;
DataAccess da = new DataAccess();
try
{
if (!dtoP.TenPhuong.Equals(""))
{
da.Open();
String sql = "Delete From TenPhuong Where MaTenPhuong = " + dtoP.MaPhuong;
da.ExecuteNonQuery(sql);
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
da.Close();
}
return kq;
}
public static int LayMaPhuong(String tenPhuong)
{
int kq = 0;
DataAccess da = new DataAccess();
try
{
da.Open();
String sql = "Select MaPhuong From Phuong Where TenPhuong Like '" + tenPhuong + "'";
kq = int.Parse("0" + da.ExecuteScalar(sql));
}
catch (Exception ex)
{
throw ex;
}
finally
{
da.Close();
}
return kq;
}
}
}
|
10hca1-team4-qldv
|
trunk/ 10hca1-team4-qldv/DAOQLDV/DAOPhuong.cs
|
C#
|
asf20
| 4,779
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.OleDb;
using System.Data;
using DTOQLDV;
namespace DAOQLDV
{
internal class DataAccess
{
private String _strcnn=SESSION._cnnStr;
private OleDbConnection _cnn;
public OleDbConnection Cnn
{
get { return _cnn; }
set { _cnn = value; }
}
private OleDbTransaction _tss;
private OleDbCommand _cmd;
public OleDbCommand Cmd
{
get { return _cmd; }
set { _cmd = value; }
}
public OleDbTransaction Tss
{
get { return _tss; }
set { _tss = value; }
}
public bool Open()
{
bool kq = false;
try
{
_cnn = new OleDbConnection(_strcnn);
_cnn.Open();
_cmd = _cnn.CreateCommand();
kq = true;
}
catch (Exception ex)
{
throw ex;
}
return kq;
}
public bool BeginTran()
{
bool kq = false;
try
{
if (_cnn.State == ConnectionState.Open)
{
_tss=Cnn.BeginTransaction();
_cmd.Transaction = _tss;
kq = true;
}
}
catch (Exception ex)
{
throw ex;
}
return kq;
}
public bool CommitTran()
{
bool kq = false;
try
{
if (_cnn.State == ConnectionState.Open)
{
_tss.Commit();
kq = true;
}
}
catch (Exception ex)
{
throw ex;
}
return kq;
}
public bool RollBackTran()
{
bool kq = false;
try
{
if (_cnn.State == ConnectionState.Open)
{
_tss.Rollback();
kq = true;
}
}
catch (Exception ex)
{
throw ex;
}
return kq;
}
public bool Close()
{
bool kq = false;
try
{
if (_cnn.State == ConnectionState.Open)
{
_cnn.Close();
kq = true;
}
}
catch(Exception ex)
{
throw ex;
}
return kq;
}
public OleDbDataReader ExecuteQuery(String sql)
{
OleDbDataReader dr = null;
try
{
_cmd = new OleDbCommand(sql, Cnn);
dr=_cmd.ExecuteReader();
}
catch (Exception ex)
{
throw ex;
}
return dr;
}
public int ExecuteNonQuery(String sql)
{
int kq = -1;
try
{
_cmd.CommandText = sql;
kq=_cmd.ExecuteNonQuery();
}
catch (Exception ex)
{
throw ex;
}
return kq;
}
public bool IsOpen()
{
if (Cnn.State == ConnectionState.Open)
{
return true;
}
return false;
}
public Object ExecuteScalar(String sql)
{
Object o = null;
try
{
_cmd.CommandText = sql;
o= _cmd.ExecuteScalar();
}
catch (Exception ex)
{
throw ex;
}
return o;
}
}
}
|
10hca1-team4-qldv
|
trunk/ 10hca1-team4-qldv/DAOQLDV/DataAccess.cs
|
C#
|
asf20
| 4,148
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTOQLDV;
namespace DAOQLDV
{
internal class DAOTuKhoaDuong
{
public static bool ThemTuKhoaDuong(DTODuong dtoD, DataAccess da)
{
bool kq = false;
try
{
if (dtoD.TenDuong.Equals(""))
{
List<String> dsTuKhoa = DAOXuLi.dsTuKhoa(dtoD.TenDuong);
String sql = "";
foreach (String tkhoa in dsTuKhoa)
{
sql = "Insert Into TuKhoaTenDuong(TenTuKhoaDuong, MaDuong) Value ('" + tkhoa + "', " + dtoD.MaDuong + ")";
da.ExecuteNonQuery(sql);
}
kq = true;
}
}
catch (Exception ex)
{
throw ex;
}
return kq;
}
}
}
|
10hca1-team4-qldv
|
trunk/ 10hca1-team4-qldv/DAOQLDV/DAOTuKhoaDuong.cs
|
C#
|
asf20
| 990
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTOQLDV;
namespace DAOQLDV
{
internal class DAOTuKhoaDiaDiem
{
public static bool ThemTuKhoaDiaDiem(DTODiaDiem dtoDD, DataAccess da)
{
bool kq = false;
try
{
List<String> dsTuKhoa = DAOXuLi.dsTuKhoa(dtoDD.TenDiaDiem);
String sql = "";
foreach (String tkhoa in dsTuKhoa)
{
sql = "Insert Into TuKhoaTenDiaDiem(TenTuKhoaDiaDiem, MaTenDiaDiem) Value ('" + tkhoa + "', " + dtoDD.MaDiaDiem + ")";
da.ExecuteNonQuery(sql);
}
}
catch (Exception ex)
{
throw ex;
}
return kq;
}
}
}
|
10hca1-team4-qldv
|
trunk/ 10hca1-team4-qldv/DAOQLDV/DAOTuKhoaDiaDiem.cs
|
C#
|
asf20
| 867
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTOQLDV;
using System.Data;
using System.Data.OleDb;
namespace DAOQLDV
{
public class DAODuong
{
public static List<DTODuong> LayDanhSachDuong()
{
List<DTODuong> dsDuong = new List<DTODuong>();
DataAccess da = new DataAccess();
try
{
da.Open();
String sql = "Select * From Duong";
OleDbDataReader dr = da.ExecuteQuery(sql);
while (dr.Read())
{
DTODuong dtoD = new DTODuong();
dtoD.MaDuong = (int)dr["MaDuong"];
dtoD.TenDuong = (String)dr["TenDuong"];
dsDuong.Add(dtoD);
}
dr.Close();
}
catch (Exception ex)
{
throw ex;
}
finally
{
da.Close();
}
return dsDuong;
}
public static DTODuong LayThongTinDuong(String tenDuong)
{
DTODuong dtoDuong = new DTODuong();
DataAccess da = new DataAccess();
try
{
da.Open();
String sql = "Select * From Duong Where TenDuong Like '"+tenDuong+"'";
OleDbDataReader dr = da.ExecuteQuery(sql);
if (dr.Read())
{
dtoDuong.MaDuong = (int)dr["MaDuong"];
dtoDuong.TenDuong = dr["TenDuong"].ToString();
}
dr.Close();
}
catch (Exception ex)
{
throw ex;
}
finally
{
da.Close();
}
return dtoDuong;
}
public static bool ThemDuong(DTODuong dtoD)
{
bool kq = false;
DataAccess da = new DataAccess();
try
{
if (!dtoD.TenDuong.Equals(""))
{
da.Open();
da.BeginTran();
String sql = "Insert Into TenDuong(TenDuong) Values ('" + dtoD.TenDuong + "')";
da.ExecuteNonQuery(sql);
sql = "Select @@IDENTITY";
dtoD.MaDuong = (int)da.ExecuteScalar(sql);
DAOTuKhoaDuong.ThemTuKhoaDuong(dtoD,da);
da.CommitTran();
kq = true;
}
}
catch (Exception ex)
{
da.RollBackTran();
throw ex;
}
finally
{
da.Close();
}
return kq;
}
public static bool CapNhatDuong(DTODuong dtoD)
{
bool kq = false;
DataAccess da = new DataAccess();
try
{
if (!dtoD.TenDuong.Equals(""))
{
da.Open();
String sql = "Update TenDuong Set TenDuong = '" + dtoD.TenDuong + "' Where MaTenDuong = " + dtoD.MaDuong;
da.ExecuteNonQuery(sql);
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
da.Close();
}
return kq;
}
public static bool XoaDuong(DTODuong dtoD)
{
bool kq = false;
DataAccess da = new DataAccess();
try
{
if (!dtoD.TenDuong.Equals(""))
{
da.Open();
String sql = "Delete From TenDuong Where MaTenDuong = " + dtoD.MaDuong;
da.ExecuteNonQuery(sql);
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
da.Close();
}
return kq;
}
public static int LayMaDuong(String tenDuong)
{
int kq = 0;
DataAccess da = new DataAccess();
try
{
da.Open();
String sql = "Select MaDuong From Duong Where TenDuong Like '" + tenDuong + "'";
kq = int.Parse("0" + da.ExecuteScalar(sql));
}
catch (Exception ex)
{
throw ex;
}
finally
{
da.Close();
}
return kq;
}
}
}
|
10hca1-team4-qldv
|
trunk/ 10hca1-team4-qldv/DAOQLDV/DAODuong.cs
|
C#
|
asf20
| 4,861
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.OleDb;
using COMExcel=Microsoft.Office.Interop.Excel;
using DTOQLDV;
namespace DAOQLDV
{
public class DAOXuLi
{
public static List<DTODuLieuEX> DocDuLieuTuFileExcel(String filePath)
{
List<DTODuLieuEX> dsDuLieu = new List<DTODuLieuEX>();
String connString = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + filePath + ";Extended Properties=Excel 12.0";
String sql = @"Select * From [Sheet1$]";
OleDbConnection cnn = new OleDbConnection(connString);
try
{
cnn.Open();
OleDbCommand cmd = new OleDbCommand(sql, cnn);
OleDbDataReader dr = cmd.ExecuteReader();
while (dr.Read())
{
DTODuLieuEX dtoDLEx = new DTODuLieuEX();
dtoDLEx.TenDichVu = dr[0].ToString();
dtoDLEx.TenDiaDiem = dr[1].ToString();
dtoDLEx.SoNha = dr[2].ToString();
dtoDLEx.Duong = dr[3].ToString();
dtoDLEx.Phuong = dr[4].ToString();
dtoDLEx.QuanHuyen = dr[5].ToString();
dtoDLEx.TinhThanh = dr[6].ToString();
dtoDLEx.KinhDo = dr[7].ToString();
dtoDLEx.ViDo = dr[8].ToString();
dtoDLEx.ChuThich = dr[9].ToString();
dsDuLieu.Add(dtoDLEx);
}
dr.Close();
}
catch (Exception ex)
{
throw ex;
}
finally
{
cnn.Close();
}
return dsDuLieu;
}
public static bool XuatDuLieuRaFileExcel(String fileName, DataTable dt)
{
bool kq = false;
return kq;
}
public static bool KiemTraKetNoi()
{
DataAccess dp = new DataAccess();
bool kq = false;
try
{
dp.Open();
kq= true;
}
catch (Exception ex)
{
}
finally
{
dp.Close();
}
return kq;
}
public static List<String> dsTuKhoa(String ten)
{
List<String> dsTuKhoa = new List<string>();
if (ten.Equals(""))
{
String[] tkarr = new String[4];
tkarr[0] = ten.ToLower();
tkarr[1] = ten.ToUpper();
tkarr[2] = ten.ToLower().Replace(" ", "");
tkarr[3] = ten.ToUpper().Replace(" ", "");
for (int i = 0; i < 4; i++)
{
dsTuKhoa.Add(tkarr[i]);
}
}
return dsTuKhoa;
}
}
}
|
10hca1-team4-qldv
|
trunk/ 10hca1-team4-qldv/DAOQLDV/DAOXuLi.cs
|
C#
|
asf20
| 3,069
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTOQLDV;
using System.Data;
using System.Data.OleDb;
namespace DAOQLDV
{
public class DAOTinhThanh
{
public static List<DTOTinhThanh> LayDanhSachTinhThanh()
{
List<DTOTinhThanh> dsTinhThanh = new List<DTOTinhThanh>();
DataAccess da = new DataAccess();
try
{
da.Open();
String sql = "Select * From TinhThanh";
OleDbDataReader dr = da.ExecuteQuery(sql);
while (dr.Read())
{
DTOTinhThanh dtoTT = new DTOTinhThanh();
dtoTT.MaTinhThanh = (int)dr["MaTinhThanh"];
dtoTT.TenTinhThanh = (String)dr["TenTinhThanh"];
dsTinhThanh.Add(dtoTT);
}
dr.Close();
}
catch (Exception ex)
{
throw ex;
}
finally
{
da.Close();
}
return dsTinhThanh;
}
public static DTOTinhThanh LayThongTinTinhThanh(String tenTinhThanh)
{
DTOTinhThanh dtoTinhThanh = new DTOTinhThanh();
DataAccess da = new DataAccess();
try
{
da.Open();
String sql = "Select * From TinhThanh Where TenTinhThanh like '" + tenTinhThanh + "'";
OleDbDataReader dr = da.ExecuteQuery(sql);
if (dr.Read())
{
dtoTinhThanh.MaTinhThanh = (int)dr["MaTinhThanh"];
dtoTinhThanh.TenTinhThanh = dr["TenTinhThanh"].ToString();
}
dr.Close();
}
catch (Exception ex)
{
throw ex;
}
finally
{
da.Close();
}
return dtoTinhThanh;
}
public static bool CapNhatTinhThanh(DTOTinhThanh dtoTT)
{
bool kq = false;
DataAccess da = new DataAccess();
try
{
da.Open();
String sql = "Update TenTinhThanh Set TenTinhThanh = '" + dtoTT.TenTinhThanh + "' Where MaTenTinhThanh = " + dtoTT.MaTinhThanh;
}
catch (Exception ex)
{
throw ex;
}
finally
{
da.Close();
}
return kq;
}
public static bool XoaTinhThanh(DTOTinhThanh dtoTT)
{
bool kq = false;
DataAccess da = new DataAccess();
try
{
da.Open();
String sql = "Delete From TenTinhThanh Where MaTenTinhThanh = " + dtoTT.MaTinhThanh;
da.ExecuteNonQuery(sql);
}
catch (Exception ex)
{
throw ex;
}
finally
{
da.Close();
}
return kq;
}
public static bool ThemTinhThanh(DTOTinhThanh dtoTT)
{
bool kq = false;
DataAccess da = new DataAccess();
try
{
da.Open();
da.BeginTran();
String sql = "Insert Into TenTinhThanh(TenTinhThanh) Values ('" + dtoTT.TenTinhThanh + "')";
da.ExecuteNonQuery(sql);
sql = "Select @@IDENTITY";
dtoTT.MaTinhThanh = (int)da.ExecuteScalar(sql);
DAOTuKhoaTinhThanh.ThemTuKhoaTinhThanh(dtoTT, da);
da.CommitTran();
kq = true;
}
catch (Exception ex)
{
da.RollBackTran();
throw ex;
}
finally
{
da.Close();
}
return kq;
}
public static int LayMaTinhThanh(String tenTinhThanh)
{
int kq = 0;
DataAccess da = new DataAccess();
try
{
da.Open();
String sql = "Select MaTinhThanh From TinhThanh Where TenTinhThanh Like '" + tenTinhThanh + "'";
kq = int.Parse("0" + da.ExecuteScalar(sql));
}
catch (Exception ex)
{
throw ex;
}
finally
{
da.Close();
}
return kq;
}
}
}
|
10hca1-team4-qldv
|
trunk/ 10hca1-team4-qldv/DAOQLDV/DAOTinhThanh.cs
|
C#
|
asf20
| 4,756
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTOQLDV;
using System.Data;
using System.Data.OleDb;
using System.Collections;
namespace DAOQLDV
{
public class DAODiaDiem
{
public static List<DTODiaDiem> LayDanhSachDiaDiem()
{
List<DTODiaDiem> dsDiaDiem = new List<DTODiaDiem>();
DataAccess da = new DataAccess();
try
{
da.Open();
String sql = "Select * From TenDiaDiem";
OleDbDataReader dr = da.ExecuteQuery(sql);
while (dr.Read())
{
DTODiaDiem dtoDD = new DTODiaDiem();
dtoDD.MaDiaDiem = (int)dr["MaTenDiaDiem"];
dtoDD.TenDiaDiem = (String)dr["TenDiaDiem"];
dsDiaDiem.Add(dtoDD);
}
dr.Close();
}
catch (Exception ex)
{
throw ex;
}
finally
{
da.Close();
}
return dsDiaDiem;
}
public static bool ThemDiaDiem(DTODiaDiem dtoDD)
{
bool kq = false;
DataAccess da = new DataAccess();
try
{
da.Open();
da.BeginTran();
String sql = "Insert Into TenDiaDiem(TenDiaDiem) Values ('" + dtoDD.TenDiaDiem + "')";
da.ExecuteNonQuery(sql);
sql = "Select @@IDENTITY";
dtoDD.MaDiaDiem = (int)da.ExecuteScalar(sql);
DAOTuKhoaDiaDiem.ThemTuKhoaDiaDiem(dtoDD, da);
da.CommitTran();
kq = true;
}
catch (Exception ex)
{
da.RollBackTran();
throw ex;
}
finally
{
da.Close();
}
return kq;
}
public static bool CapNhatDiaDiem(DTODiaDiem dtoDD)
{
bool kq = false;
DataAccess da = new DataAccess();
try
{
da.Open();
String sql = "Update TenDiaDiem Set TenDiaDiem = '" + dtoDD.TenDiaDiem + "' Where MaTenDiaDiem = " + dtoDD.MaDiaDiem;
da.ExecuteNonQuery(sql);
kq = true;
}
catch (Exception ex)
{
throw ex;
}
finally
{
da.Close();
}
return kq;
}
public static bool XoaDiaDiem(DTODiaDiem dtoDD)
{
bool kq = false;
DataAccess da = new DataAccess();
try
{
da.Open();
String sql = "Delete From TenDiaDiem Where MaTenDiaDiem = " + dtoDD.MaDiaDiem;
da.ExecuteNonQuery(sql);
kq = true;
}
catch (Exception ex)
{
throw ex;
}
finally
{
da.Close();
}
return kq;
}
public static int LayMaDiaDiem(String tenDiaDiem)
{
int kq = 0;
DataAccess da = new DataAccess();
try
{
da.Open();
String sql = "Select MaTenDiaDiem From TenDiaDiem Where TenDiaDiem Like '"+tenDiaDiem+"'";
kq = int.Parse("0" + da.ExecuteScalar(sql));
}
catch (Exception ex)
{
throw ex;
}
finally
{
da.Close();
}
return kq;
}
}
}
|
10hca1-team4-qldv
|
trunk/ 10hca1-team4-qldv/DAOQLDV/DAODiaDiem.cs
|
C#
|
asf20
| 3,902
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTOQLDV;
namespace DAOQLDV
{
internal class DAOTuKhoaQuanHuyen
{
public static bool ThemTuKhoaQuanHuyen(DTOQuanHuyen dtoQH, DataAccess da)
{
bool kq = false;
try
{
if ((dtoQH.TenQuanHuyen + "") != "")
{
List<String> dsTuKhoa = DAOXuLi.dsTuKhoa(dtoQH.TenQuanHuyen);
String sql = "";
foreach (String tkhoa in dsTuKhoa)
{
sql = "Insert Into TuKhoaTenQuanHuyen(TenTuKhoaQuanHuyen, MaQuanHuyen) Value ('" + tkhoa + "', " + dtoQH.MaQuanHuyen + ")";
da.ExecuteNonQuery(sql);
}
kq = true;
}
}
catch (Exception ex)
{
throw ex;
}
return kq;
}
}
}
|
10hca1-team4-qldv
|
trunk/ 10hca1-team4-qldv/DAOQLDV/DAOTuKhoaQuanHuyen.cs
|
C#
|
asf20
| 1,032
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTOQLDV;
using System.Data;
using System.Data.OleDb;
namespace DAOQLDV
{
public class DAOQuanHuyen
{
public static List<DTOQuanHuyen> LayDanhSachQuanHuyen()
{
List<DTOQuanHuyen> dsQuanHuyen = new List<DTOQuanHuyen>();
DataAccess da = new DataAccess();
try
{
da.Open();
String sql = "Select * From QUANHUYEN";
OleDbDataReader dr = da.ExecuteQuery(sql);
while (dr.Read())
{
DTOQuanHuyen dtoQH = new DTOQuanHuyen();
dtoQH.MaQuanHuyen = (int)dr["MaQuanHuyen"];
dtoQH.TenQuanHuyen = (String)dr["TenQuanHuyen"];
dsQuanHuyen.Add(dtoQH);
}
dr.Close();
}
catch (Exception ex)
{
throw ex;
}
finally
{
da.Close();
}
return dsQuanHuyen;
}
public static DTOQuanHuyen LayThongTinQuanHuyen(String tenQuanHuyen)
{
DTOQuanHuyen dtoQuanHuyen = new DTOQuanHuyen();
DataAccess da = new DataAccess();
try
{
da.Open();
String sql = "Select * From QUANHUYEN Where TenQuanHuyen like '" + tenQuanHuyen + "'";
OleDbDataReader dr = da.ExecuteQuery(sql);
if (dr.Read())
{
dtoQuanHuyen.MaQuanHuyen = (int)dr["MaQuanHuyen"];
dtoQuanHuyen.TenQuanHuyen = dr["TenQuanHuyen"].ToString();
}
dr.Close();
}
catch (Exception ex)
{
throw ex;
}
finally
{
da.Close();
}
return dtoQuanHuyen;
}
public static bool ThemQuanHuyen(DTOQuanHuyen dtoQH)
{
bool kq = false;
DataAccess da = new DataAccess();
try
{
if (!dtoQH.TenQuanHuyen.Equals(""))
{
da.Open();
da.BeginTran();
String sql = "Insert Into QUANHUYEN(TenQuanHuyen) Values ('" + dtoQH.TenQuanHuyen + "')";
da.ExecuteNonQuery(sql);
sql = "Select @@IDENTITY";
dtoQH.MaQuanHuyen = (int)da.ExecuteScalar(sql);
DAOTuKhoaQuanHuyen.ThemTuKhoaQuanHuyen(dtoQH, da);
da.CommitTran();
}
}
catch (Exception ex)
{
da.RollBackTran();
throw ex;
}
return kq;
}
public static bool CapNhatQuanHuyen(DTOQuanHuyen dtoQH)
{
bool kq = false;
DataAccess da = new DataAccess();
try
{
if (!dtoQH.TenQuanHuyen.Equals(""))
{
da.Open();
String sql = "Update QUANHUYEN Set TenQuanHuyen = '" + dtoQH.TenQuanHuyen + "' Where MaTenQuanHuyen = " + dtoQH.MaQuanHuyen;
da.ExecuteNonQuery(sql);
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
da.Close();
}
return kq;
}
public static bool XoaQuanHuyen(DTOQuanHuyen dtoQH)
{
bool kq = false;
DataAccess da = new DataAccess();
try
{
if (!dtoQH.TenQuanHuyen.Equals(""))
{
da.Open();
String sql = "Delete From QUANHUYEN Where MaTenQuanHuyen = " + dtoQH.MaQuanHuyen;
da.ExecuteNonQuery(sql);
}
}
catch (Exception ex)
{
throw ex;
}
finally
{
da.Close();
}
return kq;
}
public static int LayMaQuanHuyen(String tenQuanHuyen)
{
int kq = 0;
DataAccess da = new DataAccess();
try
{
da.Open();
String sql = "Select MaQuanHuyen From QUANHUYEN Where TenQuanHuyen Like '" + tenQuanHuyen + "'";
kq = int.Parse("0" + da.ExecuteScalar(sql));
}
catch (Exception ex)
{
throw ex;
}
finally
{
da.Close();
}
return kq;
}
}
}
|
10hca1-team4-qldv
|
trunk/ 10hca1-team4-qldv/DAOQLDV/DAOQuanHuyen.cs
|
C#
|
asf20
| 5,001
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTOQLDV;
namespace DAOQLDV
{
internal class DAOTuKhoaPhuong
{
public static bool ThemTuKhoaPhuong(DTOPhuong dtoP, DataAccess da)
{
bool kq = false;
try
{
if (dtoP.TenPhuong.Equals(""))
{
List<String> dsTuKhoa = DAOXuLi.dsTuKhoa(dtoP.TenPhuong);
String sql = "";
foreach (String tkhoa in dsTuKhoa)
{
sql = "Insert Into TuKhoaTenPhuong(TenTuKhoaPhuong, MaPhuong) Value ('" + tkhoa + "', " + dtoP.MaPhuong + ")";
da.ExecuteNonQuery(sql);
}
}
}
catch (Exception ex)
{
throw ex;
}
return kq;
}
}
}
|
10hca1-team4-qldv
|
trunk/ 10hca1-team4-qldv/DAOQLDV/DAOTuKhoaPhuong.cs
|
C#
|
asf20
| 967
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DTOQLDV
{
public class DTOTuKhoaDuong
{
private int _maTuKhoaDuong;
public int MaTuKhoaDuong
{
get { return _maTuKhoaDuong; }
set { _maTuKhoaDuong = value; }
}
private String _tuKhoaDuong;
public String TuKhoaDuong
{
get { return _tuKhoaDuong; }
set { _tuKhoaDuong = value; }
}
private int _maDuong;
public int MaDuong
{
get { return _maDuong; }
set { _maDuong = value; }
}
public DTOTuKhoaDuong()
{
_maDuong = 0;
_maTuKhoaDuong = 0;
_tuKhoaDuong = "";
}
}
}
|
10hca1-team4-qldv
|
trunk/ 10hca1-team4-qldv/DTOQLDV/DTOTuKhoaDuong.cs
|
C#
|
asf20
| 840
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DTOQLDV
{
public class DTODuLieu
{
private int _maDuLieu;
public int MaDuLieu
{
get { return _maDuLieu; }
set { _maDuLieu = value; }
}
private int _maDichVu;
public int MaDichVu
{
get { return _maDichVu; }
set { _maDichVu = value; }
}
private int _maDiaDiem;
public int MaDiaDiem
{
get { return _maDiaDiem; }
set { _maDiaDiem = value; }
}
private String _soNha;
public String SoNha
{
get { return _soNha; }
set { _soNha = value; }
}
private int _maDuong;
public int MaDuong
{
get { return _maDuong; }
set { _maDuong = value; }
}
private int _maPhuong;
public int MaPhuong
{
get { return _maPhuong; }
set { _maPhuong = value; }
}
private int _maQuanHuyen;
public int MaQuanHuyen
{
get { return _maQuanHuyen; }
set { _maQuanHuyen = value; }
}
private int _maTinhThanh;
public int MaTinhThanh
{
get { return _maTinhThanh; }
set { _maTinhThanh = value; }
}
private String _kinhDo;
public String KinhDo
{
get { return _kinhDo; }
set { _kinhDo = value; }
}
private String _viDo;
public String ViDo
{
get { return _viDo; }
set { _viDo = value; }
}
private String _chuThich;
public String ChuThich
{
get { return _chuThich; }
set { _chuThich = value; }
}
public DTODuLieu()
{
_chuThich = "";
_kinhDo = "";
_maDiaDiem = 0;
_maDichVu = 0;
_maDuLieu = 0;
_maDuong = 0;
_maPhuong = 0;
_maQuanHuyen = 0;
_maTinhThanh = 0;
_soNha = "";
_viDo = "";
}
}
}
|
10hca1-team4-qldv
|
trunk/ 10hca1-team4-qldv/DTOQLDV/DTODuLieu.cs
|
C#
|
asf20
| 2,337
|
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("DTOQLDV")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DTOQLDV")]
[assembly: AssemblyCopyright("Copyright © 2011")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]
// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("670ec004-02f6-4444-849c-948784a0e1c6")]
// Version information for an assembly consists of the following four values:
//
// Major Version
// Minor Version
// Build Number
// Revision
//
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
|
10hca1-team4-qldv
|
trunk/ 10hca1-team4-qldv/DTOQLDV/Properties/AssemblyInfo.cs
|
C#
|
asf20
| 1,426
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DTOQLDV
{
public class DTOTuKhoaTinhThanh
{
private int _maTuKhoaTinhThanh;
public int MaTuKhoaTinhThanh
{
get { return _maTuKhoaTinhThanh; }
set { _maTuKhoaTinhThanh = value; }
}
private String _tuKhoaTinhThanh;
public String TuKhoaTinhThanh
{
get { return _tuKhoaTinhThanh; }
set { _tuKhoaTinhThanh = value; }
}
private int _maTinhThanh;
public int MaTinhThanh
{
get { return _maTinhThanh; }
set { _maTinhThanh = value; }
}
public DTOTuKhoaTinhThanh()
{
_maTinhThanh = 0;
_maTuKhoaTinhThanh = 0;
_tuKhoaTinhThanh = "";
}
}
}
|
10hca1-team4-qldv
|
trunk/ 10hca1-team4-qldv/DTOQLDV/DTOTuKhoaTinhThanh.cs
|
C#
|
asf20
| 908
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DTOQLDV
{
public class DTOTuKhoaDichVu
{
private int _maTuKhoaDichVu;
public int MaTuKhoaDichVu
{
get { return _maTuKhoaDichVu; }
set { _maTuKhoaDichVu = value; }
}
private String _tuKhoaDichVu;
public String TuKhoaDichVu
{
get { return _tuKhoaDichVu; }
set { _tuKhoaDichVu = value; }
}
private int _maDichVu;
public int MaDichVu
{
get { return _maDichVu; }
set { _maDichVu = value; }
}
public DTOTuKhoaDichVu()
{
_maDichVu = 0;
_maTuKhoaDichVu = 0;
_tuKhoaDichVu = "";
}
}
}
|
10hca1-team4-qldv
|
trunk/ 10hca1-team4-qldv/DTOQLDV/DTOTuKhoaDichVu.cs
|
C#
|
asf20
| 857
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DTOQLDV
{
public class DTOTuKhoaPhuong
{
private int _maTuKhoaPhuong;
public int MaTuKhoaPhuong
{
get { return _maTuKhoaPhuong; }
set { _maTuKhoaPhuong = value; }
}
private String _tuKhoaPhuong;
public String TuKhoaPhuong
{
get { return _tuKhoaPhuong; }
set { _tuKhoaPhuong = value; }
}
private int _maPhuong;
public int MaPhuong
{
get { return _maPhuong; }
set { _maPhuong = value; }
}
public DTOTuKhoaPhuong()
{
_maPhuong = 0;
_tuKhoaPhuong = "";
_maTuKhoaPhuong = 0;
}
}
}
|
10hca1-team4-qldv
|
trunk/ 10hca1-team4-qldv/DTOQLDV/DTOTuKhoaPhuong.cs
|
C#
|
asf20
| 857
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DTOQLDV
{
public class DTOTinhThanh
{
private int _maTinhThanh;
public int MaTinhThanh
{
get { return _maTinhThanh; }
set { _maTinhThanh = value; }
}
private String _tenTinhThanh;
public String TenTinhThanh
{
get { return _tenTinhThanh; }
set { _tenTinhThanh = value; }
}
public DTOTinhThanh()
{
_maTinhThanh = 0;
_tenTinhThanh = "";
}
}
}
|
10hca1-team4-qldv
|
trunk/ 10hca1-team4-qldv/DTOQLDV/DTOTinhThanh.cs
|
C#
|
asf20
| 644
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DTOQLDV
{
public class DTODichVu
{
private int _maDichVu;
public int MaDichVu
{
get { return _maDichVu; }
set { _maDichVu = value; }
}
private String _tenDichVu;
public String TenDichVu
{
get { return _tenDichVu; }
set { _tenDichVu = value; }
}
public DTODichVu()
{
_tenDichVu = "";
_maDichVu = 0;
}
}
}
|
10hca1-team4-qldv
|
trunk/ 10hca1-team4-qldv/DTOQLDV/DTODichVu.cs
|
C#
|
asf20
| 616
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DTOQLDV
{
public class DTODuong
{
private int _maDuong;
public int MaDuong
{
get { return _maDuong; }
set { _maDuong = value; }
}
private String _tenDuong;
public String TenDuong
{
get { return _tenDuong; }
set { _tenDuong = value; }
}
public DTODuong()
{
_maDuong = 0;
_tenDuong = "";
}
}
}
|
10hca1-team4-qldv
|
trunk/ 10hca1-team4-qldv/DTOQLDV/DTODuong.cs
|
C#
|
asf20
| 596
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DTOQLDV
{
public class SESSION
{
public static String _cnnStr;
public static List<DTODuLieu> _dsDuLieu;
public static List<DTODiaDiem> _dsDiaDiem;
public static List<DTODichVu> _dsDichVu;
public static List<DTODuong> _dsDuong;
public static List<DTOPhuong> _dsPhuong;
public static List<DTOQuanHuyen> _dsQuanHuyen;
public static List<DTOTinhThanh> _dsTinhThanh;
}
}
|
10hca1-team4-qldv
|
trunk/ 10hca1-team4-qldv/DTOQLDV/SESSION.cs
|
C#
|
asf20
| 561
|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace DTOQLDV
{
public class DTOQuanHuyen
{
private int _maQuanHuyen;
public int MaQuanHuyen
{
get { return _maQuanHuyen; }
set { _maQuanHuyen = value; }
}
private String _tenQuanHuyen;
public String TenQuanHuyen
{
get { return _tenQuanHuyen; }
set { _tenQuanHuyen = value; }
}
public DTOQuanHuyen()
{
_maQuanHuyen = 0;
_tenQuanHuyen = "";
}
}
}
|
10hca1-team4-qldv
|
trunk/ 10hca1-team4-qldv/DTOQLDV/DTOQuanHuyen.cs
|
C#
|
asf20
| 644
|